Skip to content

RPI5 image update with qbee and RAUC

Introduction

In the ever-evolving landscape of embedded systems and single-board computers, two prominent entities have garnered significant attention: RAUC and Raspberry Pi 5. RAUC, which stands for "Robust Auto-Update Controller," is a crucial component in managing software updates for embedded Linux systems. On the other hand, Raspberry Pi 5 represents the latest iteration of the immensely popular Raspberry Pi series, known for its versatility, affordability, and extensive community support. This tutorial shows how you can integrate RAUC and qbee-agent on Raspberry PI 5 to perform A/B image updates through the qbee platform.

Get boilerplate sources

Set up the general yocto build environment with dependencies.

export YOCTO_DIR=$(pwd)
git clone -b scarthgap https://git.yoctoproject.org/poky.git $YOCTO_DIR/sources/poky
source $YOCTO_DIR/sources/poky/oe-init-build-env
bitbake-layers layerindex-fetch --branch master --fetchdir $YOCTO_DIR/sources meta-networking meta-multimedia

Get sources for Raspberry PI

We need a specially tweaked build of u-boot for RAUC.

This build has not been added to the stable branch but we expect it to appear there soon. A Big thanks to Konsulko Group for their great work in integrating u-boot for Raspberry PI 5.

bitbake-layers layerindex-fetch --branch master --fetchdir $YOCTO_DIR/sources meta-raspberrypi
cd $YOCTO_DIR/sources/meta-raspberrypi
git remote add timo https://github.com/moto-timo/meta-raspberrypi.git
git remote update
git checkout scarthgap/raspberrypi5_u-boot

Get BSP layers for rauc on Raspberry PI

bitbake-layers layerindex-fetch --branch master --fetchdir $YOCTO_DIR/sources meta-rauc-raspberrypi
cd $YOCTO_DIR/sources/meta-rauc-community
git remote add timo https://github.com/moto-timo/meta-rauc-community.git
git remote update
git checkout scarthgap/raspberrypi5_u-boot
NB! This command will produce an error regarding missing dependency, but that will be handled below.

u-boot support for raspberrypi5 scarthgap

This adds u-boot support for Raspberry PI 5 on Yocto release scarthgap.

git clone --branch scarthgap/u-boot https://github.com/moto-timo/meta-lts-mixins.git $YOCTO_DIR/sources/meta-lts-mixins
bitbake-layers add-layer $YOCTO_DIR/sources/meta-lts-mixins

Add qbee-agent

git clone --branch master https://github.com/qbee-io/meta-qbee.git $YOCTO_DIR/sources/meta-qbee
bitbake-layers add-layer $YOCTO_DIR/sources/meta-qbee/meta-qbee

Configure $YOCTO_DIR/build/conf/local.conf

MACHINE = "raspberrypi5"
INIT_MANAGER = "systemd"
DISTRO_FEATURES += "rauc"
IMAGE_INSTALL:append = " rauc"
IMAGE_FSTYPES = "tar.bz2 ext4 wic.bz2 wic.bmap"
SDIMG_ROOTFS_TYPE = "ext4"
ENABLE_UART = "1" 
RPI_USE_U_BOOT = "1" 
PREFERRED_PROVIDER_virtual/bootloader = "u-boot"
WKS_FILE = "sdimage-dual-raspberrypi.wks.in"
# qbee-agent bootstrap key to use
QBEE_BOOTSTRAP_KEY = "<bootstrap_key>"

Verify files

Verify that the following file contains these lines:

$YOCTO_DIR/sources/meta-raspberrypi/conf/machine/raspberrypi5.conf

KERNEL_IMAGETYPE_UBOOT ?= "Image"
KERNEL_IMAGETYPE_DIRECT ?= "Image"
KERNEL_BOOTCMD ?= "booti"

Verify that the following file is identical this:

$YOCTO_DIR/sources/meta-rauc-community/meta-rauc-raspberrypi/recipes-core/bundles/update-bundle.bb

DESCRIPTION = "RAUC bundle generator"

inherit bundle

RAUC_BUNDLE_COMPATIBLE = "RaspberryPi5"
RAUC_BUNDLE_VERSION = "v20200703"
RAUC_BUNDLE_DESCRIPTION = "RAUC Demo Bundle"

RAUC_BUNDLE_FORMAT = "verity"

RAUC_BUNDLE_SLOTS = "rootfs"
RAUC_SLOT_rootfs = "core-image-minimal"
RAUC_SLOT_rootfs[fstype] = "ext4"
RAUC_SLOT_rootfs[adaptive] = "block-hash-index"

Create a PKI for signing of RAUC update bundles

bitbake openssl-native
bitbake openssl-native -c addto_recipe_sysroot
$YOCTO_DIR/sources/meta-rauc-community/create-example-keys.sh

Build the image

bitbake core-image-minimal

Flash the sdcard using the following command. NB! Make sure you use the right device for flashing.

cd $YOCTO_DIR/build
sudo umount /dev/sdX*
bzcat tmp-glibc/deploy/images/raspberrypi5/core-image-minimal-raspberrypi5.rootfs.wic.bz2 | sudo dd of=/dev/sdX
sync

Put the sdcard in the Raspberry PI 5, attach the ethernet port to a working network and power on the device. The device will now auto-bootstrap to the qbee platform given that the bootstrap key above is a valid one.

Create the update bundle

Add the following to local.conf

IMAGE_INSTALL:append =" nano"

Build the update bundle

bitbake update-bundle

This produces a .raucb file which is symlinked to tmp-glibc/deploy/images/raspberrypi5/update-bundle-raspberrypi5.raucb.

This file can be uploaded to the qbee file manager and used in combination with the RAUC image update configuration option in the qbee platform.

Update RPI5 firmware image with RAUC