Yocto Build Release

From Variscite Wiki

DART-MX8M-PLUS - Yocto Kirkstone 4.0 based on FSL Community BSP 4.0 with L5.15.32_2.0.0 Linux release

Installing required packages

Please make sure your host PC is running Ubuntu 18.04/20.04/22.04 64-bit and is up to date:

 $ sudo apt-get update && sudo apt-get dist-upgrade

Then, install the following packages:

 $ sudo apt-get install gawk wget git diffstat unzip texinfo gcc-multilib \
 build-essential chrpath socat cpio python3 python3-pip python3-pexpect \
 xz-utils debianutils iputils-ping libsdl1.2-dev xterm libyaml-dev libssl-dev
 $ sudo apt-get install autoconf libtool libglib2.0-dev libarchive-dev \
 sed cvs subversion coreutils texi2html docbook-utils \
 help2man make gcc g++ desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev \
 mercurial automake groff curl lzop asciidoc u-boot-tools dos2unix mtd-utils pv \
 libncurses5 libncurses5-dev libncursesw5-dev libelf-dev zlib1g-dev bc rename \
 zstd libgnutls28-dev
 $ sudo apt-get install python3-git zstd liblz4-tool

For Ubuntu 20.04 and earlier, install python2:

$ sudo apt-get install python python-pysqlite2

Starting in Ubuntu 22.04, python2 is no longer available. Install the following to create a symbolic link from python to python3:

$ sudo apt-get install python-is-python3

Note: Variscite provides Docker containers that can be used for a development environment as an alternative to using a virtual machine or a dedicated computer. To learn more, please see Variscite's Docker Build Environment guide.

Reference documentation

  • Yocto Project Core - Kirkstone 4.0

Documentation is available from www.docs.yoctoproject.org

Download Yocto Kirkstone based on Freescale Community BSP 4.0

Configure git user and email:

$ git config --global user.name "Your Name"
$ git config --global user.email "Your Email"

Fetch and install the Google git-repo tool:

$ mkdir -p ~/bin

# For Ubuntu 20.04 and older, install repo 2.32 according to https://gerrit.googlesource.com/git-repo/+/HEAD/docs/python-support.md:
$ curl https://commondatastorage.googleapis.com/git-repo-downloads/repo-2.32 > ~/bin/repo

# For Ubuntu 22.04 and newer, install the latest repo tool:
$ curl https://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo

# Give repo execute permissions and add it to the path:
$ chmod a+x ~/bin/repo
$ export PATH=~/bin:$PATH

Create a build directory:

$ mkdir ~/var-fsl-yocto
$ cd ~/var-fsl-yocto

Now, choose between downloading a release tag, and downloading the latest revision (recommended) and follow only one of the next two bullet sections, accordingly:

  • Download the latest revision (recommended)
$ repo init -u https://github.com/varigit/variscite-bsp-platform.git -b kirkstone -m kirkstone-5.15.xml
$ repo sync -j$(nproc)


  • Download a release tag

Each release in https://github.com/varigit/variscite-bsp-platform/releases corresponds to a tag.
The tags are also listed in https://github.com/varigit/variscite-bsp-platform/tags
To specify a specific release/tag, run the following:

$ repo init -u https://github.com/varigit/variscite-bsp-platform.git -b refs/tags/TAG_NAME

For example:
$ repo init -u https://github.com/varigit/variscite-bsp-platform.git -b refs/tags/mx8mp-yocto-kirkstone-5.15-2.0.x-v1.2 -m kirkstone-5.15.xml
$ repo sync -j$(nproc)

Setup and build Yocto

Supported images

The following images are provided by Variscite for evaluation purpose

  • fsl-image-gui: Default Variscite demo image with GUI and without any Qt5 content. This image recipe works for Xwayland and Wayland backends.
  • fsl-image-qt5: Extends fsl-image-gui image with Qt5 support and various Qt samples for Xwayland and Wayland backends.

See the list of Yocto Project’s reference images in Yocto Project Reference Manual

Supported distros

The following distros can be used:

  • fslc-xwayland: Distro for Wayland with X11. This distro includes both wayland and X11 features.
  • fslc-wayland: Distro for Wayland without X11. This distro includes wayland feature but doesn’t have x11 support.

Note: Also standard Poky distros can be used

Build XWayland GUI demo image

$ cd ~/var-fsl-yocto
$ MACHINE=imx8mp-var-dart DISTRO=fslc-xwayland . var-setup-release.sh build_xwayland

The above command is only mandatory for the very first build setup: whenever restarting a newer build session (from a different terminal or in a different time), you can skip the full setup and just run

$ cd ~/var-fsl-yocto
$ source setup-environment build_xwayland

Optional steps: local.conf customization

launch bitbake:

Without Qt content:
$ bitbake fsl-image-gui

Or with Qt content:
$ bitbake fsl-image-qt5

local.conf customization

Change the downloads directory

Create a /opt/yocto_downloads directory and set its permissions:

$ sudo mkdir /opt/yocto_downloads
$ sudo chmod 777 /opt/yocto_downloads/

Direct downloads to it, by replacing 'DL_DIR ?= "${BSPDIR}/downloads/"' with 'DL_DIR = "/opt/yocto_downloads/"' in conf/local.conf under your build directory:

$ sed -i 's/DL_DIR ?= "${BSPDIR}\/downloads/DL_DIR = "\/opt\/yocto_downloads/g' conf/local.conf

Add Qt creator and Eclipse debug support to your images

Append the following to the conf/local.conf file in your Yocto build directory, to add Eclipse debug support to your images:

    eclipse-debug \
    ssh-server-openssh \

Append the following to the conf/local.conf file in your Yocto build directory, to add Qt creator debug support to your images:

    qtcreator-debug \
    ssh-server-openssh \

Create a read-only root file system

Append the following to the conf/local.conf file in your Yocto build directory, to create a read-only rootfs:

EXTRA_IMAGE_FEATURES += "read-only-rootfs"

Build Results

The resulting images are located in tmp/deploy/images/imx8mp-var-dart.

Image Name
How to use
fsl-image-gui-imx8mp-var-dart.wic.gz This image is for SD card boot.
It can be flashed as-is on an SD card that can then be used to boot your system,
according to the relevant startup-guide of your product
(usually requires to press the boot select button, or toggle a DIP switch).
For detailed information refer to the Create a bootable SD card section below.
fsl-image-gui-imx8mp-var-dart.tar.gz Tarball with rootfs files.
Can be used to create an NFS root file system on the host.
See the Yocto Setup TFTP/NFS section for more info.
Also used to create our extended SD card.
See the Create a bootable SD card section below.
Image.gz Linux kernel image, same binary for SD card and eMMC.
imx-boot-sd.bin U-Boot built for SD card boot or eMMC boot.
File Name
imx8mp-var-dart-dt8mcustomboard.dtb Device tree blob for DART-MX8M-PLUS on DT8MCustomBoard V2.x and above
imx8mp-var-dart-dt8mcustomboard-legacy.dtb Device tree blob for DART-MX8M-PLUS on DT8MCustomBoard V1.x
imx8mp-var-som-symphony.dtb Device tree blob for VAR-SOM-MX8M-PLUS on Symphony-Board
imx8mp-var-som-symphony-2nd-ov5640.dtb Device tree blob for VAR-SOM-MX8M-PLUS on Symphony-Board with a 2nd OV5640 camera
imx8mp-var-dart-dt8mcustomboard-m7.dtb Device tree blob for DART-MX8M-PLUS with Cortex-M7 on DT8MCustomBoard V2.x and above
imx8mp-var-dart-dt8mcustomboard-legacy-m7.dtb Device tree blob for DART-MX8M-PLUS with Cortex-M7 on DT8MCustomBoard V1.x
imx8mp-var-som-symphony-m7.dtb Device tree blob for VAR-SOM-MX8M-PLUS with Cortex-M7 on Symphony-Board
imx8mp-var-som-symphony-2nd-ov5640-m7.dtb Device tree blob for VAR-SOM-MX8M-PLUS with Cortex-M7 on Symphony-Board with a 2nd OV5640 camera

Create a bootable SD card

SD card structure

This is the structure of our Recovery/Extended SD card:
SD card part mx8m.png

The SD card is divided into 2 sections as shown in the picture above:

  • The first unallocated 8MiB section reserved for U-Boot. It can be replaced using the dd command as described in the Yocto Build U-Boot section.
  • The first partition is an ext4 partition that contains the complete root filesystem (including kernel image and device tree files under /boot).

The last unallocated area is not used. It is there so that the rootfs will fit on any 4GB SD card, as not all 4GB SD cards are really the same size. If you want, you can use a program such as GParted to resize the roofs partition and make it end at the end of your specific SD card (of course, you can also use SD cards with much bigger capacity than 4GB, and then it makes more sense to resize the partition).
Also, if you create the extended SD card yourself by following the Create an extended SD card section below, and you use the '-a' option, the rootfs partition will end at the end of your specific SD card automatically.

Yocto pre-built bootable SD card

The Yocto build products contains many files as explained in the Build Results section. For example, fsl-image-gui-imx8mp-var-dart.wic.gz, depending on your build. This is a complete image to be flashed directly to an SD card.

Example usage:

$ sudo umount /dev/sdX*
$ cd ~/var-fsl-yocto/build_xwayland
$ cd ~/var-fsl-yocto/build_wayland

# For fsl-image-gui image (GUI-XWAYLAND & GUI-WAYLAND)
$ zcat tmp/deploy/images/imx8mp-var-dart/fsl-image-gui-imx8mp-var-dart.wic.gz | sudo dd of=/dev/sdX bs=1M conv=fsync

# For fsl-image-qt5 image (Qt5-XWAYLAND & Qt5-WAYLAND)
$ zcat tmp/deploy/images/imx8mp-var-dart/fsl-image-qt5-imx8mp-var-dart.wic.gz | sudo dd of=/dev/sdX bs=1M conv=fsync

Replace sdX with the right device name. This can be obtained by "dmesg" command on your host Linux PC, after the SD card reader is inserted.

  • Note: Booting your system from an SD card requires pressing the boot-select button, or switching the relevant DIP switch to "Boot from SD card", according to the relevant start-up guide of your system

Drawbacks of the native .wic.gz yocto-built image, (relative to the Recovery/Extended SD card):

  • The rootfs partition doesn't use the entire SD card.
  • The rootfs partition is not labeled as rootfs.
  • The NAND flash and eMMC installation scripts and images are not included.

Create an extended SD card

Variscite provides the var-create-yocto-sdcard.sh script which creates our recovery SD card - an SD card based on the fsl-image-gui filesystem, which also contain the scripts and relevant binaries for installation to the internal storage of the SOM.
Later, you will be able to follow either the more automatic Yocto Recovery SD card guide or the more manual Installing Yocto to the SOM's internal storage guide.

This is essentially the same as our pre-built Recovery SD image, with the following main differences:

  • The pre-built image's rootfs partition size is 3700MiB, which is also the default size when using the script, but the script also has an option to set the rootfs partition size to fill the whole free space of the used SD card. Anyway, you can always resize the partition later with an external tool such as gparted.

Naturally, the pre-built image is more straight forward and easier to use, while the script method is easier to customize.


  • Follow the Setup and build Yocto guide, and bitbake fsl-image-gui.
  • Plug-in the SD card to your Linux Host PC, run dmesg and see which device is added (i.e. /dev/sdX or /dev/mmcblkX)
$ cd ~/var-fsl-yocto
$ sudo MACHINE=imx8mp-var-dart sources/meta-variscite-sdk/scripts/var_mk_yocto_sdcard/var-create-yocto-sdcard.sh <options> /dev/sdX
(Replace /dev/sdX with your actual device)
 -h            Display help message
 -s            Only show partition sizes to be written, without actually write them
 -a            Automatically set the rootfs partition size to fill the SD card
 -r            Select alternative rootfs for recovery images (default: /tmp/deploy/images/imx8mp-var-dart/fsl-image-gui-imx8mp-var-dart.*)
If you don't use the '-a' option, a default rootfs size of 3700MiB will be used
The '-r' option allows you to create a bootable SD card with an alternative image for the installation to NAND flash or eMMC.
Example: "-r tmp/deploy/images/imx8mp-var-dart/fsl-image-qt5-imx8mp-var-dart" -- selected the "Qt5 image with X11" recovery image

Create an extended SD card image using a loop device

It is also possible to use the var-create-yocto-sdcard.sh script to create an extended SD card image, while using a loop device instead of attaching a real SD card.

Create an empty file using the following command:

$ dd if=/dev/zero of=imx8mp-var-dart-extended-sd.img bs=1M count=7420

The above command creates a 7420MiB file representing the SD card.

Attach the first available loop device to this file:

$ sudo losetup -Pf imx8mp-var-dart-extended-sd.img

To find the actual loop device being used, run:

$ losetup -a | grep imx8mp-var-dart-extended-sd.img

Write the content to the loop device to generate the SD card image:

$ sudo MACHINE=imx8mp-var-dart sources/meta-variscite-sdk/scripts/var_mk_yocto_sdcard/var-create-yocto-sdcard.sh <options> /dev/loopX

(Replace /dev/loopX with your actual loop device, e.g. /dev/loop0)

Detach the loop device from the file:

$ sudo losetup -d /dev/loopX

To compress the SD card image file use the following command:

$ gzip -9 imx8mp-var-dart-extended-sd.img

To write the SD card image to a real SD card device use the following command:

$ zcat imx8mp-var-dart-extended-sd.img.gz | sudo dd of=/dev/sdX bs=1M && sync

(Replace /dev/sdX with your actual SD device, e.g. /dev/sdb)

Boot the board with a bootable SD card

Setting the Boot Mode

Make sure the BOOT SELECT DIP switch on the carrier board is set correctly before you power on the board.

 0 : Boot from SD card
 1 : Boot from eMMC

Automatic device tree selection in U-Boot

As shown in the Build Results table above, we have different kernel device trees, corresponding to our different H/W configurations.
We implemented a script in U-Boot's environment, which sets the fdt_file environment variable based on the detected hardware.

Enable/Disable automatic device tree selection

To enable the automatic device tree selection in U-Boot (already enabled by default):

$ setenv fdt_file undefined
$ saveenv

To disable the automatic device tree selection in U-Boot, set the device tree file manually:

$ setenv fdt_file YOUR_DTB_FILE
$ saveenv

Useful example: To list all files in the /boot directory (where the dtb files are by default) of an SD card:

$ ls mmc 1:1 /boot

Flash images to NAND/eMMC

Please refer to Yocto NAND Flash Burning guide.

Yocto Image Customization

Update Yocto Kirkstone to latest revision

From time to time we update the Yocto sources (especially meta-variscite) with new features and bug fixes.
Follow the Download the latest revision (recommended) bullet section of the Download Yocto Kirkstone based on Freescale Community BSP step again to update your tree to the latest revision, and rebuild your image.

Update Yocto Kirkstone to a release tag

Follow the Download a release tag bullet section of the Download Yocto Kirkstone based on Freescale Community BSP step to update your tree to a release tag, and rebuild your image.

Forcing Clean Build

In order to update the kernel, U-Boot and rootfs:
$ bitbake -c cleanall u-boot-variscite linux-variscite kernel-module-imx-gpu-viv ti-compat-wireless-wl18xx wl18xx-firmware cryptodev-module

for GUI image
$ bitbake -c clean fsl-image-gui
for Qt5 image
$ bitbake -c clean fsl-image-qt5

Make changes to the rootfs

The following is usually not the recommended way to work with Yocto.
You should usually create new specific recipes (.bb files) and/or append to specific present recipes by using .bbappend files.
However, if you are not yet experienced enough with Yocto, and you just want to quickly add your files to the resultant file system (or make any other change to it), you can do it in a general way, by using the following variable:


    Specifies a list of functions to call once the OpenEmbedded build system has created the root filesystem.
    You can specify functions separated by semicolons:

         ROOTFS_POSTPROCESS_COMMAND += "function; ... "                  

    If you need to pass the root filesystem path to a command within a function, you can use ${IMAGE_ROOTFS},
    which points to the directory that becomes the root filesystem image. See the IMAGE_ROOTFS variable for more information. 

The functions will be called right after the root filesystem is created and right before it is packed to images (.wic.gz, .ubi, .tar.gz, etc.).


Let's say you have your files that you want to put in the filesystem arranged on your host under a directory called /my_rootfs_additions, like the following:

├── data
│   ├── example.m4v
│   └── example.bin
├── etc
│   └── example.conf
└── home
    └── root
        └── .example

And let's say you want to build the fsl-image-gui image.

Create a file called ~/var-fsl-yocto/sources/meta-variscite-bsp/recipes-images/images/fsl-image-gui.bbappend
with the following content:

add_my_files() {
    cp -r /my_rootfs_additions/*  ${IMAGE_ROOTFS}/


Now, when you bitbake fsl-image-gui, the files in /my_rootfs_additions will be added to the rootfs (be careful when overwriting files).

Useful Bitbake commands

Bitbake Cheat Sheet

Useful bitbake commands

i.MX Yocto Project: ltib versus bitbake