Yocto Build Release
Installing required packages
Please make sure your host PC is running Ubuntu 18.04/20.04/22.04/24.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 python3 python3-pip python3-pexpect \ python3-git python3-jinja2 python3-subunit python3-git liblz4-tool \ python3-jinja2 python3-subunit curl zstd
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
Ubuntu 24.04 introduced additional unprivileged user namespace restrictions. They must be disabled to avoid permission errors during Yocto fetch tasks when using Variscite's docker container.
Disable this restriction on the entire system for one boot:
$ echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
Alternatively, disable this restriction using a persistent setting by adding a new file (/etc/sysctl.d/60-apparmor-namespace.conf) with the following contents:
$ echo 'kernel.apparmor_restrict_unprivileged_userns=0' | sudo tee /etc/sysctl.d/60-apparmor-namespace.conf $ sudo sysctl -p /etc/sysctl.d/60-apparmor-namespace.conf
Install Docker:
$ sudo apt update && sudo apt install docker.io qemu-user-static
Give permissions to run Docker without sudo:
$ sudo usermod -aG docker ${USER} # Logout and login again for the permissions to take effect.
Reference documentation
Download Yocto Scarthgap based on NXP BSP L6.6.52_2.2.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 scarthgap -m imx-6.6.52-2.2.0.xml $ repo sync -j$(nproc)
or
- 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/mx8mm-yocto-scarthgap-6.6.52_2.2.0-v1.0 -m imx-6.6.52-2.2.0.xml $ repo sync -j$(nproc)
Start a Ubuntu Docker container:
$ ./var-start-container.sh
All references to commands without this prompt should be executed in a native terminal (outside Docker).
If you need to run a command using 'sudo' inside the container, the default password is ubuntu.
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 Qt6 content. This image recipe works for Xwayland and Wayland backends.
- fsl-image-gui-chromium: Extends fsl-image-gui image with Chromium web browser.
- fsl-image-qt6: Extends fsl-image-gui image with Qt6 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:
- fsl-imx-wayland: Distro for Wayland without X11. This distro includes wayland feature but doesn’t have X11 support.
- fsl-imx-xwayland: Distro for Wayland with X11. This distro includes both wayland and X11 emulation features.
Note: Also standard Poky distros can be used
Build XWayland GUI demo image
vari@yocto-22-04-fc27a5d:/workdir$ MACHINE=imx8mm-var-dart DISTRO=fsl-imx-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
vari@yocto-22-04-fc27a5d:/workdir$ source setup-environment build_xwayland
Optional steps: local.conf customization
launch bitbake:
Without Qt content: vari@yocto-22-04-fc27a5d:/workdir/build_xwayland$ bitbake fsl-image-gui Or with Chromium: vari@yocto-22-04-fc27a5d:/workdir/build_xwayland$ bitbake fsl-image-gui-chromium Or with Qt content: vari@yocto-22-04-fc27a5d:/workdir/build_xwayland$ bitbake fsl-image-qt6
local.conf customization
Change the downloads directory
Create a /opt/yocto_downloads directory and set its permissions:
vari@yocto-22-04-fc27a5d:/workdir/build_xwayland$ sudo mkdir /opt/yocto_downloads vari@yocto-22-04-fc27a5d:/workdir/build_xwayland$ 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:
vari@yocto-22-04-fc27a5d:/workdir/build_xwayland$ 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:
EXTRA_IMAGE_FEATURES = " \ 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:
EXTRA_IMAGE_FEATURES = " \ 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/imx8mm-var-dart.
Image Name |
How to use |
---|---|
fsl-image-gui-imx8mm-var-dart.rootfs.wic.zst | 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-imx8mm-var-dart.tar.zst | 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 | U-Boot built for SD card boot or eMMC boot. |
File Name |
Description |
---|---|
imx8mm-var-dart-1.x-dt8mcustomboard.dtb | Device tree blob for DART-MX8M-MINI V1.x on DT8MCustomBoard |
imx8mm-var-dart-1.x-dt8mcustomboard-m4.dtb | Device tree blob for DART-MX8M-MINI V1.x with Cortex-M4 on DT8MCustomBoard |
imx8mm-var-dart-dt8mcustomboard.dtb | Device tree blob for DART-MX8M-MINI V2.x on DT8MCustomBoard |
imx8mm-var-dart-dt8mcustomboard-m4.dtb | Device tree blob for DART-MX8M-MINI V2.x with Cortex-M4 on DT8MCustomBoard |
imx8mm-var-dart-wbe-dt8mcustomboard.dtb | Device tree blob for DART-MX8M-MINI V2.x with WBE on DT8MCustomBoard |
imx8mm-var-dart-wbe-dt8mcustomboard-m4.dtb | Device tree blob for DART-MX8M-MINI V2.x with Cortex-M4 and WBE on DT8MCustomBoard |
imx8mm-var-som-1.x-symphony.dtb | Device tree blob for VAR-SOM-MX8M-MINI V1.x on Symphony-Board |
imx8mm-var-som-1.x-symphony-m4.dtb | Device tree blob for VAR-SOM-MX8M-MINI V1.x with Cortex-M4 on Symphony-Board |
imx8mm-var-som-symphony.dtb | Device tree blob for VAR-SOM-MX8M-MINI V2.x on Symphony-Board |
imx8mm-var-som-symphony-m4.dtb | Device tree blob for VAR-SOM-MX8M-MINI V2.x with Cortex-M4 on Symphony-Board |
imx8mm-var-som-wbe-symphony.dtb | Device tree blob for VAR-SOM-MX8M-MINI V2.x with WBE on Symphony-Board |
imx8mm-var-som-wbe-symphony-m4.dtb | Device tree blob for VAR-SOM-MX8M-MINI V2.x with WBE and Cortex-M4 on Symphony-Board |
Create a bootable SD card
SD Card Structure
This is the structure of our default SD card programmed from Yocto images:
Disk /dev/sdX: 59.48 GiB, 63864569856 bytes, 124735488 sectors Disk model: MassStorageClass Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x5ebf1617 Device Boot Start End Sectors Size Id Type /dev/sdX1 16384 15165439 15149056 7.2G 83 Linux
- At the beginning of the card is 8 MiB of reserved area for the partition table and bootloader.
- The first and only SD card partition begins at offset 16,384 (of 512 byte sectors) which is due to the reserved area explained above. This partition is an ext4 partition that contains the complete root filesystem (including kernel image and device tree files under /boot).
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-imx8mm-var-dart.rootfs.wic.zst, depending on your build. This is a complete and bootable image ready to be flashed directly to an SD card.
Example usage:
vari@yocto-22-04-fc27a5d:/workdir/build_xwayland$ sudo umount /dev/sdX* # For fsl-image-gui image (GUI-XWAYLAND & GUI-WAYLAND) vari@yocto-22-04-fc27a5d:/workdir/build_xwayland$ zstdcat tmp/deploy/images/imx8mm-var-dart/fsl-image-gui-imx8mm-var-dart.rootfs.wic.zst | sudo dd of=/dev/sdX bs=1M conv=fsync Or # For fsl-image-gui-chromium image (GUI-XWAYLAND & GUI-WAYLAND) vari@yocto-22-04-fc27a5d:/workdir/build_xwayland$ zstdcat tmp/deploy/images/imx8mm-var-dart/fsl-image-gui-chromium-imx8mm-var-dart.rootfs.wic.zst | sudo dd of=/dev/sdX bs=1M conv=fsync Or # For fsl-image-qt6 image (Qt6-XWAYLAND & Qt6-WAYLAND) vari@yocto-22-04-fc27a5d:/workdir/build_xwayland$ zstdcat tmp/deploy/images/imx8mm-var-dart/fsl-image-qt6-imx8mm-var-dart.rootfs.wic.zst | 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.
Yocto Recovery Image
Beginning in Yocto Langdale, Variscite has released a new recovery Yocto image recipe called "var-recovery-image." This image is used to create a bootable SD card that contains another target image to be programmed to the eMMC. See the yocto Recovery SD card or the more manual Installing Yocto to the SOM's internal storage articles for specifics of installing a recovery image.
Usage:
By default, the recovery image boots fsl-image-gui and contains a fsl-image-gui target image to be programmed to eMMC.
You can also specify a different target eMMC image to be embedded in the recovery image by setting this variable in local.conf:
VAR_RECOVERY_TARGET_ROOTFS = "<desired-emmc-image-recipe>"
Additionally, the recovery image output file name can be modified by setting something like the following in local.conf:
VAR_RECOVERY_SD_NAME = "mx8mm__yocto-scarthgap-6.6.52_2.2.0-v1.0__android-14.0.0_1.0.0-v1.2"
This is an example of configurations added to local.conf:
VAR_RECOVERY_SD_NAME = "mx8mm__yocto-scarthgap-6.6.52_2.2.0-v1.0__android-14.0.0_1.0.0-v1.2" VAR_RECOVERY_SD_IMAGE = "recipes-fsl/images/fsl-image-gui-chromium.bb" VAR_RECOVERY_TARGET_ROOTFS = "fsl-image-gui-chromium"
To create a recovery image, run the following from your Yocto environment:
vari@yocto-22-04-fc27a5d:/workdir/build_xwayland$ bitbake var-recovery-image
Using the default configuration, this will produce an output relative to the build folder of "./tmp/deploy/images/imx8mm-var-dart/var-recovery-image-imx8mm-var-dart.rootfs.wic.zst" that can be flashed to the SD card.
If you set the variables mentioned above, this will produce a recovery image relative to the build folder of "./tmp/deploy/images/imx8mm-var-dart/mx8mm__yocto-scarthgap-6.6.52_2.2.0-v1.0__android-14.0.0_1.0.0-v1.2.wic.zst"
Extending the SD Card Size
Flashing the default .rootfs.wic.zst images from Yocto results in a rootfs that does not utilize the entire SD card. This section explains how the SD card can be extended on the build host after flashing.
Procedure:
Begin with an SD card on which you have previously flashed a Yocto .rootfs.wic.zst image. Ensure the SD card is inserted and the device present (i.e. /dev/sda, /dev/mmcblk0, etc.)
Start by running fdisk as below and typing "p" and enter to print current partitions. You should see a layout similar to below but numbers may differ depending on card sizes. Note that the partition starts at 16,384 (bytes offset 16384*512) which is to account for the boot content explained above.
$ sudo fdisk /dev/sdX Welcome to fdisk (util-linux 2.37.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): p Disk /dev/sdX: 59.48 GiB, 63864569856 bytes, 124735488 sectors Disk model: MassStorageClass Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x5ebf1617 Device Boot Start End Sectors Size Id Type /dev/sdX1 16384 15165439 15149056 7.2G 83 Linux
Next, run the following sequence of commands followed by enter with each step explained with a "-" to the right. Each command/input should be followed by enter:
- d - Delete current partition (1).
- n - Create a new parition.
- - Empty, hit enter only which will leave default response p for primary partition.
- - Empty, hit enter only which will leave default response 1 for first partition.
- 16384 - Enter 16384 to begin partition past bootloader section.
- - Empty, hit enter only which will leave last sector as default which should choose ending size of the SD card.
- N - Answers no to not remove the ext4 signature on the disk
- p - Print output and verify before we write. We should see the starting offset the same and the end expanded to fill the SD card.
- w - Write output to disk
See the full log of the above sequence below:
Command (m for help): d Selected partition 1 Partition 1 has been deleted. Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): Using default response p. Partition number (1-4, default 1): First sector (2048-124735487, default 2048): 16384 Last sector, +/-sectors or +/-size{K,M,G,T,P} (16384-124735487, default 124735487): Created a new partition 1 of type 'Linux' and of size 59.5 GiB. Partition #1 contains a ext4 signature. Do you want to remove the signature? [Y]es/[N]o: N Command (m for help): p Disk /dev/sdX: 59.48 GiB, 63864569856 bytes, 124735488 sectors Disk model: MassStorageClass Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos identifier: 0x5ebf1617 Device Boot Start End Sectors Size Id Type /dev/sdX1 16384 124735487 124719104 59.5G 83 Linux Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
Finally, the file system needs to be resized on the disk to fill the now larger partition. Do that as follows:
$ sudo e2fsck -f /dev/sdX1 e2fsck 1.46.5 (30-Dec-2021) root: recovering journal Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information root: 43155/947488 files (0.1% non-contiguous), 674097/1893632 blocks $ sudo resize2fs /dev/sdX1 resize2fs 1.46.5 (30-Dec-2021) Resizing the filesystem on /dev/sdX1 to 15589888 (4k) blocks. The filesystem on /dev/sdX1 is now 15589888 (4k) blocks long. $ sync
Again, numbers and output should differ slightly depending on your card.
Your rootfs image should now fill the entire SD card and is ready to boot.
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.
SW7 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 Scarthgap 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 Scarthgap based on Freescale Community BSP step again to update your tree to the latest revision, and rebuild your image.
Update Yocto Scarthgap to a release tag
Follow the Download a release tag bullet section of the Download Yocto Scarthgap 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: vari@yocto-22-04-fc27a5d:/workdir/build_xwayland$ bitbake -c cleanall u-boot-variscite linux-variscite kernel-module-imx-gpu-viv ti-compat-wireless-wl18xx wl18xx-firmware cryptodev-module for GUI image vari@yocto-22-04-fc27a5d:/workdir/build_xwayland$ bitbake -c clean fsl-image-gui for Qt6 image vari@yocto-22-04-fc27a5d:/workdir/build_xwayland$ bitbake -c clean fsl-image-qt6
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:
ROOTFS_POSTPROCESS_COMMAND 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 (.rootfs.wic.zst, .ubi, .tar.gz, etc.).
Example
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:
my_rootfs_additions/ ├── 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-imx/recipes-images/images/fsl-image-gui.bbappend
with the following content:
add_my_files() { cp -r /my_rootfs_additions/* ${IMAGE_ROOTFS}/ } ROOTFS_POSTPROCESS_COMMAND += "add_my_files;"
Now, when you bitbake fsl-image-gui, the files in /my_rootfs_additions will be added to the rootfs (be careful when overwriting files).