Dies ist eine alte Version des Dokuments!


Building a New Image

Images are built using bitbake and yocto.

The build process is based on this toradex guide .

Customising the Toradex image

Note that everything in this section assumes a build environment that is set up accoring to the guide above.

Adding a custom application

A custom application can be added to a yocto build by means of a new recipes and a new layer.

There are various ways to source application to be added to a build. This guide describes how to add this hello world application from github into the toradex image. If you want to build your own hello world application, check out this guide on how to do that.

On layers and recipes

Recipes could be considered the fundamental building block of yocto. A recipe describes how to build the thing you want to build (i.e an application, kernel module, …), its dependencies and more.

Groups of recipes that belong together are grouped into layers. For example meta-toradex-nxp is the layer that contains all the things needed to support the hardware specific to Toradex's modules that use NXP based processors.

Creating a custom layer

To create a new layer, create a new directory in the oe-core/layers directory(oe-core is the folder the build environment was set up in above). Since this is the NTB wiki, this guide will use oe-core/layers/meta-ntb. The directory name can be anything, but it should start with meta-. Now change into that directory and create another folder called conf. In conf, create a file named layer.conf with the following content:

BBPATH := "${BBPATH}:${LAYERDIR}"

BBFILES := "${BBFILES} ${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bappend"

BBFILE_COLLECTIONS += "ntb"

BBFILE_PATTERN_ntb := "^${LAYERDIR}/"
BBFILE_PRIORITY_ntb := "5"

This file configures the layer and where to look for recipes. In this case it will look for file in meta-ntb/recipes-<some name>/<some other name>/<file name>.bb. .bb is the file extension used by bitbake the build system used by yocto. Finally, create a folder named recipes-ntb inside meta-ntb. This folder will store all the recipes for this layer. The directory structure should now look like this:

  • oe-core
    • meta-ntb
      • conf
        • layer.conf
      • recipes-ntb

Adding a Recipe to the Layer

As configured above, bitbake will look for recipes in any sub directory of recipes-ntb, but not in recipes-ntb itself! Create a folder inside recipes-ntb called helloworld and inside that create a file called helloworld_1_0.bb with the following content:

DESCRIPTION = "Example Hello World"
SECTION = "ntb"
DEPENDS = ""

LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=96af5705d6f64a88e035781ef00e98a8"

FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PV}:"

SRCREV = "b9fb7785e9e1f357f29bef63dce8f1d91adb6170"
SRC_URI = "git://github.com/DynamicDevices/bbexample.git"

S = "${WORKDIR}/git"

inherit autotools

bitbake is very particular about licenses to ensure no closed source software ends up in a project that only wants open source software. Hence the recipe needs to specify the license used (MIT in this case) and a checksum for the license file to ensure it has not been altered. All this is handled by the LIC_FILES_CHKSUM field. THe other two interesting fields are SRC_URI and SRC_REV. SRC_URI specifies where the source for the application/module/… for this recipe is. In this case git:// lets bitbake know the source lives in a git repository. Note that https:// will not work.

To add the new recipe to the build edit oe-core/build/conf/local.conf and append IMAGE_INSTALL_append = „ helloworld“ (make sure to include the space before helloworld).

Now running bitbake console-tdx-image should run without errors and the image should include a hello executable that prints Hello World when executed.

Additional Information

Building the SDK

To build the SDK for an image append -c populate_sdk to the bitbake build command.

For example, to build the SDK for the standard toradex image console-tdx-image run bitbake console-tdx-image -c populate_sdk

For more information check the Toradex guide .