This meta-layer is used to provide recipes for packages required in Coda's Cluster node and images for both Cluster and Processing-Delegate node. This meta-layer is designed for use with Kirkstone and has been tested on Raspberry Pi 3B+, Raspberry Pi 4B, and NVIDIA Jetson Nano.
-
Start things off with by updating and upgrading packages.
sudo apt update && upgrade -y -
The Yocto Project documentation recommends installing the following packages.
sudo apt install gawk wget git diffstat unzip texinfo gcc build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev python3-subunit mesa-common-dev zstd liblz4-tool file locales libacl1
-
The first step is to clone
pokyand checkout Kirkstone branch.git clone https://github.com/yoctoproject/poky.git cd poky git checkout kirkstone -
Next, clone
meta-openembedded.git clone https://github.com/openembedded/meta-openembedded.git cd meta-openembedded git checkout kirkstone
This layer was designed for use with Raspberry Pi 4B and NVIDIA Jetson Nano; so, their BSP layers have to be cloned. I went for meta-raspberrypi with no modifications since it suited my needs. However, for the Jetson Nano, I forked meta-tegra and modified the .conf file to parse recipes related to virtualization and docker: hence this will be the layer I will use.
git clone https://github.com/agherzan/meta-raspberrypi.git
cd meta-raspberrypi
git checkout kirkstonegit clone https://github.com/AhmedAlyElGhannam/meta-tegra.git
cd meta-tegra
git checkout kirkstone-l4t-r32.7.x-
Finally, a meta-layer for Qt6 is needed for the Cluster application. I chose this one provided by shr-project.
git clone https://github.com/shr-project/meta-qt6.git cd meta-qt6 git checkout jansa/kirkstone
-
Source the script located in the
pokyfolder to startbitbakeand create a new image folder. Here, I named my imagebuild-cluster. Conventionally, all image names start withbuildto make them distinct. Sourcing this script will change your directory to a new folder named the same as the image name and start bitbake.source poky/oe-init-build-env build-cluster -
Next, we will start adding layers one by one to the image using the command
bitbake-layers add-layer. Note thatmeta-raspberrypidepends on other layers to function correctly, hence they will be added before it. Same story goes tometa-qt6. Ergo, add the layers in the same order as written here to avoid any unnecessary errors.bitbake-layers add-layer ../meta-openembedded/meta-oe bitbake-layers add-layer ../meta-openembedded/meta-python bitbake-layers add-layer ../meta-openembedded/meta-networking bitbake-layers add-layer ../meta-openembedded/meta-multimedia bitbake-layers add-layer ../meta-raspberrypi bitbake-layers add-layer ../meta-qt6/
-
Make sure all the layers were added successfully by using the command:
bitbake-layers show-layers
In $PWD/build-cluster/conf/local.conf, add/set fields below. Some of these are Raspberry Pi 4B, so if you want to use another target, adjust accordingly.
### Added by me ###
MACHINE = "raspberrypi4-64"
ENABLE_UART = "1"
ENABLE_I2C = "1"
KERNEL_MODULE_AUTOLOAD:rpi += "i2c-dev i2c-bcm2708"
MACHINE_FEATURES:append = " vc4graphics "
DISTRO = "hehos"
#DISTRO = "poky"
DL_DIR = "$HOME/Yocto_Playground/DL_DIR"
SSTATE_DIR = "$HOME/Yocto_Playground/SSTATE_DIR"
# this should enable remote desktop in theory
PACKAGECONFIG:append:pn-weston = " rdp"
### Added by me ###
In meta-coda, there are two image recipes: core-image-coda-cluster and core-image-coda-ai. As the name suggests, one is made for the cluster ECU with Qt6 dependencies; and the other is made for the AI-Delegate ECU with Python3 and other stuff. Obviously, both will contain vsomeip and CommonAPI libraries since they are the main method of communication between ECUs.
bitbake core-image-coda-cluster
The final image is found in $PWD/build-cluster/tmp/deploy/images/raspberrypi4-64/ directory under the name core-image-coda-cluster-raspberrypi4-64.wic.bz2. It has to be decompressed using bzip2 in order to flash it or simply use bmaptools to do it. Personally, I like to decompress it then flash it using balenaEtcher.
bzip2 -d -f core-image-coda-cluster-raspberrypi4-64.wic.bz2
During development, the cluster app created using Qt6 has to be tested multiple times on the Pi. So, the best way is to create a Qt6 SDK with all binaries and libraries compiled for the target in order to develop and deploy effortlessly on my Laptop.
bitbake meta-toolchain-qt6
The output of this command is a shell script found in $PWD/build/cluster/tmp/deploy/sdk with a size of 2GB (yeah, I am not joking!). This script will be run to export a sysroot for the image and an environment script that has to be sourced everytime a Qt6 app has to be built for the Pi (or any other target).
Any app written in C/C++ (like the VSOMEIP services that will be created) have to be compiled for the Pi. So, the following command will be used to create a script that will be used to generate an SDK with the libraries and binaries of the image.
bitbake core-image-coda-cluster -c populate_sdk
-
Source the script located in the
pokyfolder to startbitbakeand create a new image folder. Here, I named my imagebuild-coda-ai.source poky/oe-init-build-env build-coda-ai -
Next, we will start adding layers one by one to the image using the command
bitbake-layers add-layer.bitbake-layers add-layer ../meta-openembedded/meta-oe bitbake-layers add-layer ../meta-openembedded/meta-python bitbake-layers add-layer ../meta-openembedded/meta-networking bitbake-layers add-layer ../meta-openembedded/meta-multimedia bitbake-layers add-layer ../meta-tegra
-
Make sure all the layers were added successfully by using the command:
bitbake-layers show-layers
In $PWD/build-cluster/conf/local.conf, add/set fields below. The only thing that is specific to the Jetson Nano is the MACHINE name.
### ADDED BY ME
MACHINE = "jetson-nano-devkit"
DISTRO = "hehos"
#DISTRO = "poky"
DL_DIR = "/home/nemesis/Storage/Playground/ELBS_Playground/Yocto_Playground/DL_DIR"
SSTATE_DIR = "/home/nemesis/Storage/Playground/ELBS_Playground/Yocto_Playground/SSTATE_DIR"
# this should enable remote desktop in theory
PACKAGECONFIG:append:pn-weston = " rdp"
### ADDED BY ME
As explained earlier, meta-coda contains two image recipes: core-image-coda-cluster and core-image-coda-ai. This time, the second will be used:
bitbake core-image-coda-ai
The output will be found in $PWD/build-cluster/tmp/deploy/images/jetson-nano-devkit/ directory. But, this time, the image is not flashed easily. meta-tegra provide some scripts that are generated with the "image" to flash it but I had no luck and they always produced corrupt output. So, I opted for an unconventional way to flash the image.
- Format the partition table of the sd card to a SINGLE PRIMARY PARTITION in ext4 format using cfdisk.
sudo cfdisk /dev/sda
- Format the sd card itself to
ext4format and name itrootfs. Make sure the disk is unmounted before formating it.sudo mkfs.ext4 /dev/sda1 -L rootfs
- Navigate into the directory where the image output is located, and mount the generated rootfs as a loop device.
sudo losetup core-image-coda-ai-jetson-nano-devkit.ext4 -f --show --partscan
- Copy the content of the loop device into the sd card.
sudo cp -r * /media/$USER/rootfs
- Finally, navigate to
boot/extlinuxdirectory in the sd card and edit the bootargs to be as shown below. Basically, specify the sd card partition the root is located in.APPEND ${cbootargs} root=/dev/mmcblk0p1 rw rootwait ${bootargs}