Building a Linux Image with Yocto

Our Linux software stack is based on the Yocto project.

In order to build it, we use kas, which fetches and builds bitbake based project. If you already know about Yocto, you don’t have to use kas. Our layer, meta-scobc, can be used as a regular yocto layer.

Setup the Build Environment

The meta-xilinx-tool layer depends on some packages that are not available in Ubuntu 24.04.

To install them, you need to add Ubuntu 22.04 (Jammy) repositories to your system.

$ sudo tee /etc/apt/sources.list.d/jammy.list << 'EOF'
deb http://archive.ubuntu.com/ubuntu jammy main universe
deb http://archive.ubuntu.com/ubuntu jammy-updates main universe
deb http://security.ubuntu.com/ubuntu jammy-security main universe
EOF
$ sudo tee /etc/apt/preferences.d/jammy-pin << 'EOF'
Package: *
Pin: release a=jammy
Pin-Priority: -1

Package: libncurses5 libtinfo5
Pin: release a=jammy
Pin-Priority: 990
EOF

Then, install the required packages.

$ sudo apt update
$ sudo apt install binutils chrpath cpio diffstat file g++ gawk gcc \
                   git libncurses5 libtinfo5 lz4 make python3 \
                   rpcsvc-proto zstd

Next, install uv, which is a tool to manage Python virtual environments.

$ curl -LsSf https://astral.sh/uv/install.sh | sh

Clone the Repository

$ git clone https://github.com/spacecubics/meta-scobc
$ cd meta-scobc

Install and Enable the Required Python Packages

$ uv sync
$ source .venv/bin/activate

Build the Minimal Image

With kas, it’s easier than bitbake to build the whole system. Just let it do the work with the following command.

From meta-scobc version scobc-v1-v0.3.0, SDT(System Device Tree)-based builds are the default.

By default, the build uses sc-image-ramroot. A ramroot system loads the root filesystem into RAM as an initramfs and uses it as / instead of mounting the root filesystem partition on the SD card. Changes made to the root filesystem are therefore lost when the system is rebooted unless they are saved to separately mounted persistent storage.

Ramroot is the default because the onboard eMMC is less tolerant of radiation than the memories intended for high-reliability use. Radiation-induced errors can corrupt data stored in the eMMC or make the device temporarily unavailable. Loading the root filesystem into RAM reduces Linux’s dependency on the eMMC during operation and allows the system to keep running if access to the eMMC is disrupted. This does not protect the boot image or other persistent data kept on the eMMC, so mission-critical persistent data requires appropriate protection and redundancy.

For Space Grade

$ kas build kas/scobc-v1.yml

build/tmp/deploy/images/versal-scobc-v1-ve2302i-sdt-full/ will contain the generated image files.

$ ls -1F build/tmp/deploy/images/versal-scobc-v1-ve2302i-sdt-full/*.wic
build/tmp/deploy/images/versal-scobc-v1-ve2302i-sdt-full/sc-image-ramroot-versal-scobc-v1-ve2302i-sdt-full-yyyyMMddHHmmss.wic
build/tmp/deploy/images/versal-scobc-v1-ve2302i-sdt-full/sc-image-ramroot-versal-scobc-v1-ve2302i-sdt-full.wic@
sc-image-ramroot-versal-scobc-v1-ve2302i-sdt-full.wic is a symlink to the latest build.

For Developer Grade

$ kas build kas/scobc-v1-devgrade.yml

build/tmp/deploy/images/versal-scobc-v1-ve2302e-sdt-full/ will contain the generated image files.

$ ls -1F build/tmp/deploy/images/versal-scobc-v1-ve2302e-sdt-full/*.wic
build/tmp/deploy/images/versal-scobc-v1-ve2302e-sdt-full/sc-image-ramroot-versal-scobc-v1-ve2302e-sdt-full-yyyyMMddHHmmss.wic
build/tmp/deploy/images/versal-scobc-v1-ve2302e-sdt-full/sc-image-ramroot-versal-scobc-v1-ve2302e-sdt-full.wic@
sc-image-ramroot-versal-scobc-v1-ve2302e-sdt-full.wic is a symlink to the latest build.

Build an Image that uses the SD Card Root Filesystem

To use the usual boot configuration, which mounts the root filesystem from the SD card, add kas/targets/sc-image-minimal.yml to the kas configuration.

$ kas build kas/scobc-v1.yml:kas/targets/sc-image-minimal.yml

For a Developer Grade build, use the same target with the Developer Grade configuration.

$ kas build kas/scobc-v1-devgrade.yml:kas/targets/sc-image-minimal.yml

The Space Grade image is generated in build/tmp/deploy/images/versal-scobc-v1-ve2302i-sdt-full/.

$ ls -1F build/tmp/deploy/images/versal-scobc-v1-ve2302i-sdt-full/sc-image-minimal-*.wic
build/tmp/deploy/images/versal-scobc-v1-ve2302i-sdt-full/sc-image-minimal-versal-scobc-v1-ve2302i-sdt-full-yyyyMMddHHmmss.wic
build/tmp/deploy/images/versal-scobc-v1-ve2302i-sdt-full/sc-image-minimal-versal-scobc-v1-ve2302i-sdt-full.wic@

The Developer Grade image is generated in build/tmp/deploy/images/versal-scobc-v1-ve2302e-sdt-full/.

$ ls -1F build/tmp/deploy/images/versal-scobc-v1-ve2302e-sdt-full/sc-image-minimal-*.wic
build/tmp/deploy/images/versal-scobc-v1-ve2302e-sdt-full/sc-image-minimal-versal-scobc-v1-ve2302e-sdt-full-yyyyMMddHHmmss.wic
build/tmp/deploy/images/versal-scobc-v1-ve2302e-sdt-full/sc-image-minimal-versal-scobc-v1-ve2302e-sdt-full.wic@

The .wic file without a timestamp is a symlink to the latest build.