Skip to main content
Version: BSP 8.x.y (Next)

Build a Reference Image with Yocto Project/OpenEmbedded

Introduction​

This article provides instructions on how to build Toradex Reference Images with the Yocto Project/OpenEmbedded.

For an overview of Toradex BSP versions, Yocto layers, and Reference Images, refer to BSP Layers and Reference Images for Yocto Project - Overview. For a conceptual description of the layers, build configuration, and artifacts, refer to BSP Layers, and Reference Images Architecture.

For information about the Yocto Project beyond the scope of Toradex documentation, refer to the Yocto Project Documentation and the Yocto Project Reference Manual.

info

To build Torizon OS from source, refer to Build Torizon OS With Yocto Project documentation.

The build process consists of the following steps:

  1. Initialize the build environment with the bitbake-setup tool
  2. Build the image with the bitbake tool
  3. Customize the build with fragments to adjust the machine, BSP variant, or other settings
  4. Deploy the built image to your device

This article complies with the Typographic Conventions for the Toradex Documentation.

Prerequisites​

A configured build environment as described in the Host Machine Setup for Yocto documentation.

Initialize the Build Environment​

After setting up the host machine, source the Python virtual environment where the bitbake-setup tool is installed:

$ source ./bitbake-setup-venv/bin/activate

Set Up Layers and Configuration Files​

By default, bitbake-setup creates the Yocto build environment in the bitbake-builds/tdxref-wrynose directory, inside the directory where you run the command.

Optionally, you can customize the build environment location using the top-dir-prefix and top-dir-name settings. These settings are stored in ~/.config/bitbake-setup/settings.conf and apply to all subsequent bitbake-setup commands.

To configure them, run the following commands, where <ABSOLUTE_PATH> is the parent directory and <NAME> replaces the default bitbake-builds directory name:

$ bitbake-setup settings set default top-dir-prefix <ABSOLUTE_PATH>
$ bitbake-setup settings set default top-dir-name <NAME>

For example, the following commands create the build environment in /home/user/yocto/toradex-builds/tdxref-wrynose:

$ bitbake-setup settings set default top-dir-prefix /home/user/yocto
$ bitbake-setup settings set default top-dir-name toradex-builds

To initialize a new build environment, run the following command:

$ bitbake-setup \
--setting default registry 'git://git.toradex.com/meta-toradex-demos.git;protocol=https;branch=wrynose;rev=wrynose' \
init

During initialization, the bitbake-setup tool prompts for a configuration template. The tdxref-wrynose template pins fixed revisions for the layers, while the tdxref-wrynose-floating template tracks the latest revisions. Make sure to select the most appropriate template for your use case.

Available Configuration Templates:
1. tdxref-wrynose Toradex Reference Images Wrynose setup
2. tdxref-wrynose-floating Toradex Reference Images Wrynose floating development setup
info

By default, the tdxref-wrynose template with rev=wrynose selects fixed layer revisions corresponding to the latest stable BSP release. These revisions are defined in the configuration template maintained in the meta-toradex-demos repository and are updated as new stable BSP releases become available, such as BSP 8.1 and later.

To target a specific BSP release, set the rev parameter in the --setting default registry option to the corresponding release revision. For example, to target BSP 8.0, set rev=wrynose-8.0:

$ bitbake-setup \
--setting default registry 'git://git.toradex.com/meta-toradex-demos.git;protocol=https;branch=wrynose;rev=wrynose-8.0' \
init
info

The --use-local-source option allows bitbake-setup to use an existing local directory instead of cloning the corresponding Git repository. It creates a symbolic link to the local directory within the setup's layers/ directory, allowing changes to the local source to be reflected directly in the build. Use this option when developing layers locally.

In the following example, meta-custom-layer identifies the source defined in the configuration template, while /path/to/meta-custom-layer specifies the directory containing the local source. The directory remains independently managed, and bitbake-setup does not modify its contents.

$ bitbake-setup \
--setting default registry 'git://git.toradex.com/meta-toradex-demos.git;protocol=https;branch=wrynose;rev=wrynose' \
init \
--use-local-source meta-custom-layer /path/to/meta-custom-layer

Set Up the Image​

At the start of the setup process, the bitbake-setup tool prompts you to select the target machine and accept the Freescale End User License Agreement (EULA), if applicable. Note that the variant and distribution are selected automatically based on the target machine. Refer to the Select the BSP Variant and Select the Distribution sections for more information.

The following example shows the selection of the target machine machine/verdin-imx8mp and the acceptance of the Freescale EULA, as required to build recipes that use proprietary NXP software.

Target machine:
1. machine/apalis-imx6
2. machine/apalis-imx8
3. machine/aquila-am69
4. machine/aquila-imx95
5. machine/colibri-imx6
6. machine/colibri-imx6ull
7. machine/colibri-imx6ull-emmc
8. machine/colibri-imx7
9. machine/colibri-imx7-emmc
10. machine/colibri-imx8x
11. machine/lino-imx93
12. machine/toradex-osm-imx93
13. machine/toradex-osm-imx95
14. machine/toradex-smarc-imx8mp
15. machine/toradex-smarc-imx95
16. machine/verdin-am62
17. machine/verdin-am62p
18. machine/verdin-imx8mm
19. machine/verdin-imx8mp
20. machine/verdin-imx95

Please select one of the above options by its number: 19

Accept the FSL EULA:
1. freescale-layer/eula/accept-fsl-eula Required to build recipes that use proprietary NXP software.
2. Do not accept the FSL EULA

Please select one of the above options by its number: 1

After configuring the image, the bitbake-setup tool prompts you to name the build environment directory. By default, the suggested name matches the selected configuration template. If you choose a different name, adjust the paths in the following steps accordingly.

tip

To set up a build environment for a non-interactive session, use the --non-interactive flag with the bitbake-setup init command.

The following example shows how to set up a non-interactive build environment for the machine/verdin-imx8mp target machine, with the acceptance of the Freescale EULA, and using the tdxref-wrynose-floating template with the tdxref-floating build configuration to track the latest development revisions.

$ bitbake-setup \
--setting default registry 'git://git.toradex.com/meta-toradex-demos.git;protocol=https;branch=wrynose;rev=wrynose' \
init --non-interactive \
tdxref-wrynose-floating \
tdxref-floating \
freescale-layer/eula/accept-fsl-eula \
machine/verdin-imx8mp

Build Environment Directory Structure​

Once the setup process is complete, the build environment contains the following directory structure:

bitbake-builds
├── site.conf
└── tdxref-wrynose
├── build
│ ├── bitbake-cookerdaemon.log
│ ├── cache
│ ├── conf
│ ├── init-build-env
│ ├── README
│ └── tmp
├── config
│ ├── config-upstream.json
│ └── sources-fixed-revisions.json
└── layers
├── bitbake
├── logs
├── meta-arm
├── meta-freescale
├── meta-lts-mixins
├── meta-openembedded
├── meta-qcom
├── meta-security
├── meta-ti
├── meta-toradex-bsp
├── meta-toradex-demos
├── meta-yocto
├── oe-init-build-env-dir -> openembedded-core
├── oe-scripts -> openembedded-core/scripts
├── openembedded-core
├── setup-build -> openembedded-core/scripts/oe-setup-build
└── sources-fixed-revisions.json -> ../config/sources-fixed-revisions.json

23 directories, 8 files

Save the Build Environment​

During initialization, bitbake-setup generates files that record the build configuration and the source revisions used to create the environment.

The config/sources-fixed-revisions.json file stores the exact layer revisions, which maps each source to the corresponding commit hash. Additionally, the file config/config-upstream.json stores the selected build configuration, including the target machine, BSP variant, and distribution.

Update the Build Environment​

The bitbake-setup update command synchronizes the local build environment with the upstream configuration, fetching the latest revisions of the layers and rebasing any local changes on top of the new upstream revisions, according to the references defined in the config-upstream.json file.

To update the build environment, run the following command, replacing bitbake-builds/tdxref-wrynose with <ABSOLUTE_PATH>/<NAME>/tdxref-wrynose if you have set up a custom directory for the Yocto build environment:

$ bitbake-setup update --setup-dir bitbake-builds/tdxref-wrynose

Build the Image​

Set Up the Environment Shell​

After setting up the build environment, source the init-build-env script to set up the shell environment for the build:

$ source bitbake-builds/tdxref-wrynose/build/init-build-env

This script sets up the environment variables and paths required for the build process. It also changes the current working directory to the build directory, where the build configuration files are located.

Select the Image​

Toradex provides two Reference Images, built with the tdx-xwayland reference distribution. The following table summarizes each image and its main features. To learn about all the features, check the recipes on the meta-toradex-demos repository, keeping in mind that these images are intended for BSP evaluation only, and are not recommended for production use.

Toradex also provides the Torizon OS Yocto Reference Minimal Image, intended as a starting point for production images. For instructions on building Torizon OS images with Yocto, refer to Build Torizon OS from Source With Yocto Project/OpenEmbedded documentation.

ImageDescription
tdx-reference-minimal-imageMinimal image without a graphical interface.

- Network management: connman and its Ethernet/Wi-Fi plugins
- Base packages from packagegroup-boot and packagegroup-basic
- Toradex command-line packages from packagegroup-base-tdx-cli, packagegroup-machine-tdx-cli, and packagegroup-wifi-tdx-cli
- Package management enabled
tdx-reference-multimedia-imageImage for BSP verification with multimedia features.

- Includes everything from the Reference Minimal Image
- Weston enabled when Wayland is available
- XWayland enabled when both X11 and Wayland are available
- Command-line packages from packagegroup-tdx-cli
- Graphical packages from packagegroup-tdx-graphical
- Utilities including v4l-utils, gpicview, and media-files

Useful BitBake Commands​

The following bitbake commands are useful for common build and troubleshooting tasks. For more information about BitBake commands and options, refer to the Yocto BitBake Documentation.

  • bitbake -k <image>: Build the image and continue building independent tasks after an error occurs.
  • bitbake virtual/kernel: Build only the Linux Kernel for the target machine.
  • bitbake -e <recipe>: Display the environment variables and configuration applied to a recipe. Use tools such as less to inspect the complete output or grep to find a specific variable.
  • bitbake -c listtasks <recipe>: List all tasks available for a recipe.

Run BitBake​

After defining the image to build, run the bitbake command to start the build process. Keep in mind the following points when using the bitbake tool:

  • First, source the init-build-env script in your current shell, as instructed in the Set Up the Environment Shell section.
  • It is necessary to be in the build directory when executing the bitbake command.
  • BitBake automatically logs console output to timestamped files in build/tmp/log/cooker/$MACHINE/.
  • The first build may take a long time, possibly several hours, to complete.
$ bitbake <image>
Optimize Yocto Build RAM and CPU Usage

Your computer may run out of RAM while compiling some packages (such as Qt, in the tdx-reference-multimedia-image).

To reduce RAM usage, set the environment variables PARALLEL_MAKE and BB_NUMBER_THREADS to a limited number of threads.

  • PARALLEL_MAKE: number of threads used by make.
  • BB_NUMBER_THREADS: number of threads used by bitbake. Setting BB_NUMBER_THREADS also limits the number of download and configuration threads.
$ PARALLEL_MAKE="-j 4" BB_NUMBER_THREADS="6" bitbake <image>

Alternatively, to apply these settings across all builds using the same build directory, add the following lines to the conf/local.conf file in your build directory. This eliminates the need to specify the environment variables each time you run bitbake.

local.conf
PARALLEL_MAKE = "-j 4"
BB_NUMBER_THREADS = "6"

To verify that BitBake is using the configured values, run the following command. The output should match the values specified in conf/local.conf:

$ bitbake -e | grep -E '^(PARALLEL_MAKE|BB_NUMBER_THREADS)='
BB_NUMBER_THREADS="6"
PARALLEL_MAKE="-j 4"
warning

If a build fails due to lack of RAM, some files could be corrupted. Trying to build again may not solve this issue. In this situation:

  1. Delete the corrupted package state
  2. Delete all temporary files
  3. Attempt to build the image again

Debug a Failing Build​

If a build fails, try the following troubleshooting steps:

  • Run the build again without removing any files to check whether the failure is reproducible.
  • Clean the failed recipe with one of BitBake's clean tasks, such as clean, cleansstate, or cleanall, and then restart the build. For example, if the recipe python-native fails:
    $ bitbake -c clean python-native
    $ bitbake <image>
  • Check the layer that provides the failing recipe for newer commits that may address the issue.

Customize the Build with Fragments​

Starting with BSP 8, the Reference Images use configuration fragments provided by the BSP layers to define the build configuration. These fragments allow users to select different machines and BSP variants.

During the build setup, bitbake-setup init enables the selected fragments, including those for the target machine and, when required, the fragment for accepting the Freescale EULA. After initialization, use bitbake-config-build to update the enabled configuration without creating a new build environment.

info

Configuration fragments are the recommended way to configure BSP 8 builds. The settings defined by these fragments are standard BitBake variables, and can still be set in another configuration file. However, Toradex recommends using fragments to avoid conflicts.

List the Available Fragments​

To list all fragments provided by the configured layers, together with their descriptions, run the following command:

$ bitbake-config-build list-fragments

To list only BSP variant fragments, filter the output:

$ bitbake-config-build list-fragments | grep variants

Enable and Disable Fragments​

To enable a fragment, specify the layer that provides it, the fragment directory, and the fragment name. For example, to enable the tdx-nxp-6_18-rt fragment, run the following command:

$ bitbake-config-build enable-fragment toradex-nxp-layer/variants/tdx-nxp-6_18-rt

To disable a fragment, use the disable-fragment command. For example, to disable the tdx-nxp-6_18-rt fragment, run the following command:

$ bitbake-config-build disable-fragment toradex-nxp-layer/variants/tdx-nxp-6_18-rt

Select the Target Machine​

The machine fragment specifies the Toradex module for which the image is built, and it is enabled during the build environment initialization. For example, an environment initialized with machine/verdin-imx8mp targets the Verdin iMX8M Plus.

The available machines are listed in the following table:

Machine NameCorresponding Toradex Module
aquila-am69Aquila AM69/TDA4
aquila-imx95Aquila iMX95
verdin-imx95Verdin iMX95
verdin-imx8mpVerdin iMX8M Plus
verdin-imx8mmVerdin iMX8M Mini
verdin-am62pVerdin AM62P
verdin-am62Verdin AM62
lino-imx93Lino iMX93
toradex-osm-imx95OSM iMX95
toradex-osm-imx93OSM iMX93
toradex-smarc-imx95SMARC iMX95
toradex-smarc-imx8mpSMARC iMX8M Plus
apalis-imx8Apalis iMX8
apalis-imx6Apalis iMX6
colibri-imx8xColibri iMX8X V1.0C or newer
colibri-imx7-emmcColibri iMX7D 1 GB (equipped with eMMC flash)
colibri-imx6ull-emmcColibri iMX6ULL 1 GB (equipped with eMMC flash)
colibri-imx7Colibri iMX7S 256 MB and iMX7D 512 MB (equipped with raw NAND flash)
colibri-imx6ullColibri iMX6ULL 512 MB (equipped with raw NAND flash)
colibri-imx6Colibri iMX6

To build for a different module, enable the fragment for the target machine. For example, to build for the Verdin iMX95 module, run the following command:

$ bitbake-config-build enable-fragment machine/verdin-imx95

Select the BSP Variant​

A BSP variant defines a consistent set of BSP components and settings, including the Linux Kernel, device tree provider, GPU libraries, and vendor BSP mode. The TDX_BSP_VARIANT variable identifies the selected variant.

Before BSP 8, these settings were selected through the DISTRO variable. Switching between upstream and downstream BSPs, or between standard and PREEMPT_RT kernels, therefore required selecting a different distribution. Starting with BSP 8, BSP variants provide this selection independently of the distribution.

Toradex provides the following BSP variants:

VariantKernel BranchLayer
tdx-upstream-6_18linux-6.18.y stablemeta-toradex-bsp-common
tdx-upstream-6_18-rtlinux-6.18.y stable with PREEMPT_RTmeta-toradex-bsp-common
tdx-nxp-6_18toradex_6.18-2.0.x-imxmeta-toradex-nxp
tdx-nxp-6_18-rttoradex_6.18-2.0.x-imx with PREEMPT_RTmeta-toradex-nxp
tdx-ti-6_18toradex_ti-linux-6.18.ymeta-toradex-ti
tdx-ti-6_18-rttoradex_ti-linux-6.18.y with PREEMPT_RTmeta-toradex-ti
tdx-qcom-6_18toradex_qcom-6.18.ymeta-toradex-qcom
tdx-qcom-6_18-rttoradex_qcom-6.18.y with PREEMPT_RTmeta-toradex-qcom

Each machine defines a default BSP variant:

Default VariantMachines
tdx-upstream-6_18
  • colibri-imx7-emmc
  • colibri-imx6ull-emmc
  • colibri-imx7
  • colibri-imx6ull
  • colibri-imx6
  • apalis-imx6
tdx-nxp-6_18
  • aquila-imx95
  • verdin-imx95
  • verdin-imx8mp
  • verdin-imx8mm
  • lino-imx93
  • toradex-osm-imx95
  • toradex-osm-imx93
  • toradex-smarc-imx95
  • toradex-smarc-imx8mp
  • colibri-imx8x
  • apalis-imx8
tdx-ti-6_18
  • aquila-am69
  • verdin-am62p
  • verdin-am62
tdx-qcom-6_18
  • tdx-iq-8275-evk

To build for a different BSP variant, enable its corresponding configuration fragment. For example, to build for tdx-nxp-6_18-rt, run the following command:

$ bitbake-config-build enable-fragment toradex-nxp-layer/variants/tdx-nxp-6_18-rt

Select the Distribution​

The distro fragment specifies the target distribution. From BSP 8 onwards, tdx-xwayland is the only supported distribution, so no fragment is required to select it. The BSP-specific distributions of earlier BSP versions were removed, and the BSP variants replaced them.

Deploy the Built Image to Your Device​

After BitBake completes the build, you can find the generated image in the build/deploy/images/${MACHINE}/ directory. For example, a Reference Minimal Image build for the Verdin iMX8M Plus module generates an image with a filename similar to Verdin-iMX8MP_Reference-Minimal-Image-tdx-nxp-6_18-Tezi_8.0-devel-20261019153331+build.0.tar.

The generated .tar file contains the TEZI image that you can deploy to the target device. Refer to Flash a New Image Using Toradex Easy Installer documentation for instructions on how to install the image on your module.

Production Programming​

Starting with BSP 5.2, Toradex Reference Images include an End User License Agreement (EULA). When the EULA is present in the image, TEZI does not allow the use of the autoinstall feature, as described in the Production Programming for Linux article.

To enable the autoinstall feature, remove the license line from the image.json file included in the deployable tarball image generated by the OpenEmbedded build. Note that removing the license line indicates your acceptance of the EULA.

Customize a Yocto Build​

Toradex Reference Images are intended for evaluation purposes and include a minimal set of packages and configurations. Since BSP 3.0, Reference Images do not include a package manager.

To add packages required by an application, use one of the following approaches:

  • Use Torizon OS and install additional packages from Debian repositories inside containers.
  • Customize the Yocto build to include the required packages and configurations directly in the image.

Yocto builds are typically customized by adding custom meta-layers on top of the layers provided by Toradex. For instructions and examples, refer to Custom meta layers, recipes and images in Yocto Project (hello-world examples) documentation.

Read-Only Rootfs​

Toradex base BSP layers and Reference Images do not support a read-only root filesystem. Several system features require write access to the root filesystem at runtime and may not function correctly when it is mounted read-only.

For example, the system updates the module hostname at runtime to include its serial number. This change cannot be persisted when the root filesystem is read-only.

For information about implementing a read-only root filesystem, refer to How to implement a Read-Only Rootfs (Linux).

Send Feedback!