In the following article, we will discuss how to successfully compile our base image using the Yocto environment.
To proceed with this article you need to have:
A Linux system with the following essential packages
sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat cpio python python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm
- The Yocto source files.
Note: Engicam provides a script to download and set up our latest BSP release at the following link https://github.com/engicam-stable/engicam-bsp-scripts
Set environment variables
Enter Yocto folder and launch the script setting environment variables:
DISTRO=<distro name> MACHINE=<machine name> source imx-setup-release.sh -b <build dir>
where machine-name corresponds to the module for which the operating system image will be compiled and build-dir-name is the building directory name chosen by the user, as in the following example:
DISTRO=eng-imx-xwayland MACHINE=imx8mp-icore source imx-setup-release.sh -b build
where a directory named build is created and environment variables are set to compile images for the module i.Core MX8M Plus. An important thing to point out is that the machine-name corresponds to the names of the relative configuration files at the following path /sources/meta-engicam-nxp/conf/machine.
Note: If the build directory already exists due to previous compilations it will be required to set the environment variables only executing the command:
source setup-environment build
Configure Yocto layers
In order to have access to our recipes and configuration files you need to add with Bitbake the meta-engicam-nxp layer to the image layers:
bitbake-layers add-layer ../sources/meta-engicam-nxp
Now you need to compile the desired image with Bitbake:
engicam-evaluation-image is our standard image and provides all needed packages for a full functioning kit.
Note: The first compilation will download and cross-compile all needed packages required for the image so it might need a very long time (depending on the hardware you are working with) and various GB of free space in your hard disk. The following compilation won\'t take the same amount of time because Yocto will keep track of what has been already compiled so it doesn\'t needs to do it again
Once the image is compiled it will be possible to find in the build directory a deploy folder with the image files. The standard path to this folder from the Yocto directory will be:
So in this example, the path will be:
This folder will contain the image file and plenty other useful files like:
- the compiled device tree
- the u-boot
- the kernel
- the fyle system
Flash the Image in an SD Card
To flash the finished image you can either use the following combination of the bzcat and dd command :
bzcat engicam-evaluation-image-imx8mp-icore.wic.bz2 | sudo dd of=/dev/sd[x] bs=10M status=progress && sync
Note: The [x] corresponds to the alias of the SD Card in the linux ssystem. To check the correct one you can use the command:
Or you can use dedicated software like BalenaEtcher