rauc demo: add
PATCH v2 1/1 rauc demo: add
Add an example of implementing rauc on a rockchip board. Adding the meta-rauc layer, adding 'rauc' to DISTRO_FEATURES, and enabling RK_RAUC_DEMO will build an image using the example provided in dynamic-layers/rk-rauc-demo.
This example uses a simple A/B + D scheme (i.e. two root partitions and a non-updated /data partition). Repartitioning occurs automatically on first boot thanks to systemd's 'repart' mechanism.
NOTE:
- this example only works with systemd
If you wish to provide your own implementation, simply add the meta-rauc layer, add 'rauc' to DISTRO_FEATURES, don't enable RK_RAUC_DEMO, and provide your own implementation in a separate layer.
---
v2 changes:
- add information/instructions to README
- rauc-conf cleanup:
- remove ca.cert.pem from SRC_URI, it's already in parent
- rename systemd.conf.in to system.conf so the parent handles it
- process the system.conf file as a prepend, leaving it for the parent to manage
- use walrus operator with THISDIR
- break out the systemd repart config files into their own recipe so they can be updated without triggering a full rebuild of systemd (and its dependents)
- class cleanup:
- update the classes so they have only 1 job (each)
- rename the classes to reflect their jobs
- update recipes/configs to use the new classes
--- README | 18 +++++ .../rk-rauc-demo-features-check.bbclass | 8 ++ classes/rk-rauc-demo-override.bbclass | 3 + conf/layer.conf | 4 + conf/machine/include/rockchip-wic.inc | 4 + .../recipes-bsp/u-boot/files/boot.cmd.in | 51 ++++++++++++ .../recipes-bsp/u-boot/files/uboot-rauc.cfg | 8 ++ .../recipes-bsp/u-boot/u-boot_%.bbappend | 27 +++++++ .../base-files/base-files_%.bbappend | 7 ++ .../recipes-core/base-files/files/fstab | 7 ++ .../rauc-bundles/files/development-1.cert.pem | 80 +++++++++++++++++++ .../rauc-bundles/files/development-1.key.pem | 28 +++++++ .../rauc-bundles/rockchip-rauc-bundle.bb | 14 ++++ .../recipes-core/rauc/files/ca.cert.pem | 80 +++++++++++++++++++ .../recipes-core/rauc/files/system.conf | 17 ++++ .../recipes-core/rauc/rauc-conf.bbappend | 8 ++ .../recipes-core/systemd/abd-partition.bb | 25 ++++++ .../systemd/files/25-rootfsA.conf | 4 + .../systemd/files/35-rootfsB.conf | 7 ++ .../recipes-core/systemd/files/45-data.conf | 6 ++ .../recipes-core/systemd/systemd_%.bbappend | 4 + 21 files changed, 410 insertions(+) create mode 100644 classes-recipe/rk-rauc-demo-features-check.bbclass create mode 100644 classes/rk-rauc-demo-override.bbclass create mode 100644 dynamic-layers/rk-rauc-demo/recipes-bsp/u-boot/files/boot.cmd.in create mode 100644 dynamic-layers/rk-rauc-demo/recipes-bsp/u-boot/files/uboot-rauc.cfg create mode 100644 dynamic-layers/rk-rauc-demo/recipes-bsp/u-boot/u-boot_%.bbappend create mode 100644 dynamic-layers/rk-rauc-demo/recipes-core/base-files/base-files_%.bbappend create mode 100644 dynamic-layers/rk-rauc-demo/recipes-core/base-files/files/fstab create mode 100644 dynamic-layers/rk-rauc-demo/recipes-core/rauc-bundles/files/development-1.cert.pem create mode 100644 dynamic-layers/rk-rauc-demo/recipes-core/rauc-bundles/files/development-1.key.pem create mode 100644 dynamic-layers/rk-rauc-demo/recipes-core/rauc-bundles/rockchip-rauc-bundle.bb create mode 100644 dynamic-layers/rk-rauc-demo/recipes-core/rauc/files/ca.cert.pem create mode 100644 dynamic-layers/rk-rauc-demo/recipes-core/rauc/files/system.conf create mode 100644 dynamic-layers/rk-rauc-demo/recipes-core/rauc/rauc-conf.bbappend create mode 100644 dynamic-layers/rk-rauc-demo/recipes-core/systemd/abd-partition.bb create mode 100644 dynamic-layers/rk-rauc-demo/recipes-core/systemd/files/25-rootfsA.conf create mode 100644 dynamic-layers/rk-rauc-demo/recipes-core/systemd/files/35-rootfsB.conf create mode 100644 dynamic-layers/rk-rauc-demo/recipes-core/systemd/files/45-data.conf create mode 100644 dynamic-layers/rk-rauc-demo/recipes-core/systemd/systemd_%.bbappend
README +18 -0
@@ -85,6 +85,24 @@ Notes: in the configuration (e.g. conf/local.conf). + A/B updates with RAUC + This layer now contains one example of building an A/B update using RAUC. + Users are free to use/test this example, to optionally enable it, to build + their own update strategies based on this one, or to ignore it completely. + This example only works with + + INIT_MANAGER = "systemd" + + If you wish to use this example in your builds: + - enable 'systemd' as your init system + - add the meta-rauc layer to your build (with the corresponding branch) + - add 'rauc' to your DISTRO_FEATURES + - enable RK_RAUC_DEMO in your config + + If you wish to implement your own RAUC update without using the example from + this layer, perform the same steps as above except for the step enabling + RK_RAUC_DEMO. + U-Boot Environment: ------------------ In order to configure U-Boot to be able to store its environment into the
classes-recipe/rk-rauc-demo-features-check.bbclass new file +8 -0
@@ -0,0 +1,8 @@ +inherit features_check + +REQUIRED_DISTRO_FEATURES += "systemd rauc" +REQUIRED_MACHINE_FEATURES += "rk-u-boot-env" + +# 'RK_RAUC_DEMO' indicates the user wants to use the +# rauc demo configuration from this layer +OVERRIDES .= "${@ ':rk-rauc-demo' if bb.utils.to_boolean(d.getVar('RK_RAUC_DEMO'), False) else ''}"
classes/rk-rauc-demo-override.bbclass new file +3 -0
@@ -0,0 +1,3 @@ +# 'RK_RAUC_DEMO' indicates the user wants to use the +# rauc demo configuration from this layer +OVERRIDES .= "${@ ':rk-rauc-demo' if bb.utils.to_boolean(d.getVar('RK_RAUC_DEMO'), False) else ''}"
conf/layer.conf +4 -0
@@ -21,3 +21,7 @@ BBFILES_DYNAMIC += " \ qt5-layer:${LAYERDIR}/dynamic-layers/qt5-layer/*/*/*.bb \ qt5-layer:${LAYERDIR}/dynamic-layers/qt5-layer/*/*/*.bbappend \ " +BBFILES_DYNAMIC += " \ + rauc:${LAYERDIR}/dynamic-layers/rk-rauc-demo/*/*/*.bb \ + rauc:${LAYERDIR}/dynamic-layers/rk-rauc-demo/*/*/*.bbappend \ +"
conf/machine/include/rockchip-wic.inc +4 -0
@@ -1,5 +1,7 @@ # common meta-rockchip wic/wks items +inherit rk-rauc-demo-override + require conf/machine/include/rockchip-extlinux.inc require conf/machine/include/rockchip-rk-u-boot-env.inc
@@ -9,6 +11,8 @@ SPL_BINARY ?= "idbloader.img" # WIC_COMPRESSION_EXTENSION = ".xz" WIC_COMPRESSION_EXTENSION ?= "" IMAGE_FSTYPES += "wic${WIC_COMPRESSION_EXTENSION} wic.bmap" +IMAGE_FSTYPES:append:rk-rauc-demo = " ext4" +IMAGE_INSTALL:append:rk-rauc-demo = " abd-partition" WKS_FILE ?= "rockchip.wks" WKS_FILE_DEPENDS ?= " \ e2fsprogs-native \
dynamic-layers/rk-rauc-demo/recipes-bsp/u-boot/files/boot.cmd.in new file +51 -0
51 lines not on this page · raw message
dynamic-layers/rk-rauc-demo/recipes-bsp/u-boot/files/uboot-rauc.cfg new file +8 -0
@@ -0,0 +1,8 @@ +CONFIG_CMD_BOOTDEV=y +CONFIG_CMD_BOOTMETH=y +CONFIG_CMD_SETEXPR=y +CONFIG_CMD_SETEXPR_FMT=y +CONFIG_BOOTSTD_DEFAULTS=n +CONFIG_BOOTMETH_EXTLINUX=n +CONFIG_BOOTMETH_EXTLINUX_PXE=n +CONFIG_BOOTMETH_VBE=n
dynamic-layers/rk-rauc-demo/recipes-bsp/u-boot/u-boot_%.bbappend new file +27 -0
@@ -0,0 +1,27 @@ +inherit rk-rauc-demo-override +inherit rk-rauc-demo-features-check + +FILESEXTRAPATHS:prepend:rk-rauc-demo := "${THISDIR}/files:" + +DEPENDS:append:rk-rauc-demo = " u-boot-mkimage-native" +SRC_URI:append:rk-rauc-demo = " \ + file://uboot-rauc.cfg \ + file://boot.cmd.in \ + " + +do_compile:append:rk-rauc-demo() { + # create boot script + sed -e 's|@@KERNEL_BOOTFILE@@|${UBOOT_EXTLINUX_KERNEL_IMAGE}|' \ + "${UNPACKDIR}/boot.cmd.in" > "${UNPACKDIR}/boot.cmd" + mkimage -A ${UBOOT_ARCH} -T script -C none -n "Boot script" -d "${UNPACKDIR}/boot.cmd" ${UNPACKDIR}/boot.scr + + # tweak environment + echo "bootmeths=script extlinux" >> ${B}/u-boot-initial-env + echo "bootargsbase=${UBOOT_EXTLINUX_KERNEL_ARGS} ${UBOOT_EXTLINUX_CONSOLE}" >> ${B}/u-boot-initial-env +} + +do_install:append:rk-rauc-demo() { + install -d ${D}/boot + install -m 0644 ${UNPACKDIR}/boot.scr ${D}/boot +} +FILES:${PN}-extlinux += "/boot/boot.scr"
dynamic-layers/rk-rauc-demo/recipes-core/base-files/base-files_%.bbappend new file +7 -0
@@ -0,0 +1,7 @@ +inherit rk-rauc-demo-override +inherit rk-rauc-demo-features-check + +FILESEXTRAPATHS:prepend:rk-rauc-demo := "${THISDIR}/files:" + +# Add a mount point for a shared data partition +dirs755 += "/data"
dynamic-layers/rk-rauc-demo/recipes-core/base-files/files/fstab new file +7 -0
@@ -0,0 +1,7 @@ +/dev/root / auto x-systemd.growfs 1 1 +proc /proc proc defaults 0 0 +devpts /dev/pts devpts mode=0620,ptmxmode=0666,gid=5 0 0 +tmpfs /run tmpfs mode=0755,nodev,nosuid,strictatime 0 0 +tmpfs /var/volatile tmpfs defaults 0 0 + +LABEL=data /data ext4 defaults 0 0
dynamic-layers/rk-rauc-demo/recipes-core/rauc-bundles/files/development-1.cert.pem new file +80 -0
80 lines not on this page · raw message
dynamic-layers/rk-rauc-demo/recipes-core/rauc-bundles/files/development-1.key.pem new file +28 -0
@@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCsKw8FAtC7sEcF +NnE8IA6ndo11wSNebHotlP88F9gLREgqggOSxf0zdgxCz02KyUd/r1J8FWw752DR +BJckewcfVn1sPzHo+TZ7M1vPVOo3mKaxmh3alqEHFJwVgE3bDAOGzsc9clei2qDA +jLKaoGrluF9S0vYnykj044brviSTaq9gaH8JO4GWzoUMY5PY+pHcUC53u7w4QumG +2Kwz3ebUN2njAY0hj6lKfxWlqqm+/DaTpBAMGDMwBn8cE7OpxlfXa5ZFFef1jz1I +4AhGT3/vFHeVJSWbFCGEJes3CwFI5vXBi2HGy4xrp9jS+THjgD946mpBbF1Ng6ZU +DVvCDvbvAgMBAAECggEASphBYq9sltVyf/ytpRpSnxYLhmiPFXs0mIlE6Nl/3qnQ +BrLcL3yfD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qL1ZZyywC +W2BmHfGMPUyQHux4btsdJhlWcS7z7aYXM9QWiKlI+EKLHLILYk+LPIEf85sUcOZV +eCBpViT7fv2iv/0L+mzjWtLA +-----END PRIVATE KEY-----
dynamic-layers/rk-rauc-demo/recipes-core/rauc-bundles/rockchip-rauc-bundle.bb new file +14 -0
@@ -0,0 +1,14 @@ +DESCRIPTION = "Rockchip RAUC bundle generator" + +inherit bundle + +RAUC_BUNDLE_COMPATIBLE = "${MACHINE}" +RAUC_BUNDLE_VERSION = "v20240512" +RAUC_BUNDLE_DESCRIPTION = "RAUC Demo Bundle" +RAUC_BUNDLE_FORMAT = "verity" +RAUC_BUNDLE_SLOTS = "rootfs" +RAUC_SLOT_rootfs = "core-image-base" +RAUC_SLOT_rootfs[fstype] = "ext4" + +RAUC_KEY_FILE := "${THISDIR}/files/development-1.key.pem" +RAUC_CERT_FILE := "${THISDIR}/files/development-1.cert.pem"
dynamic-layers/rk-rauc-demo/recipes-core/rauc/files/ca.cert.pem new file +80 -0
80 lines not on this page · raw message
dynamic-layers/rk-rauc-demo/recipes-core/rauc/files/system.conf new file +17 -0
@@ -0,0 +1,17 @@ +[system] +compatible=@MACHINE@ +bootloader=uboot +data-directory=/data/ + +[keyring] +path=/etc/rauc/ca.cert.pem + +[slot.rootfs.0] +device=/dev/disk/by-partlabel/rootfsA +type=ext4 +bootname=A + +[slot.rootfs.1] +device=/dev/disk/by-partlabel/rootfsB +type=ext4 +bootname=B
dynamic-layers/rk-rauc-demo/recipes-core/rauc/rauc-conf.bbappend new file +8 -0
@@ -0,0 +1,8 @@ +inherit rk-rauc-demo-override +inherit rk-rauc-demo-features-check + +FILESEXTRAPATHS:prepend:rk-rauc-demo := "${THISDIR}/files:" + +do_install:prepend:rk-rauc-demo() { + sed -ie 's!@MACHINE@!${MACHINE}!g' ${UNPACKDIR}/system.conf +}
dynamic-layers/rk-rauc-demo/recipes-core/systemd/abd-partition.bb new file +25 -0
@@ -0,0 +1,25 @@ +SUMMARY = "A/B+D partition definition for systemd's repart mechanism" +LICENSE = "OSL-3.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/OSL-3.0;md5=438ec6d864bbb958a49df939a56511cf" + +inherit rk-rauc-demo-override +inherit rk-rauc-demo-features-check + +FILESEXTRAPATHS:prepend:rk-rauc-demo := "${THISDIR}/files:" + +S = "${UNPACKDIR}" + +SRC_URI:append:rk-rauc-demo = " \ + file://25-rootfsA.conf \ + file://35-rootfsB.conf \ + file://45-data.conf \ + " + +do_install:append:rk-rauc-demo() { + install -d ${D}${sysconfdir}/repart.d/ + install -m 0644 ${UNPACKDIR}/25-rootfsA.conf ${D}${sysconfdir}/repart.d/ + install -m 0644 ${UNPACKDIR}/35-rootfsB.conf ${D}${sysconfdir}/repart.d/ + install -m 0644 ${UNPACKDIR}/45-data.conf ${D}${sysconfdir}/repart.d/ +} + +FILES:${PN}:append:rk-rauc-demo = " ${sysconfdir}/repart.d/"
dynamic-layers/rk-rauc-demo/recipes-core/systemd/files/25-rootfsA.conf new file +4 -0
@@ -0,0 +1,4 @@ +[Partition] +Type=root +Weight=250 +SizeMaxBytes=5G
dynamic-layers/rk-rauc-demo/recipes-core/systemd/files/35-rootfsB.conf new file +7 -0
@@ -0,0 +1,7 @@ +[Partition] +Type=root +Label=rootfsB +Weight=250 +SizeMaxBytes=5G +Format=ext4 +GrowFileSystem=yes
dynamic-layers/rk-rauc-demo/recipes-core/systemd/files/45-data.conf new file +6 -0
@@ -0,0 +1,6 @@ +[Partition] +Type=root-secondary +Label=data +Weight=500 +Format=ext4 +GrowFileSystem=yes
dynamic-layers/rk-rauc-demo/recipes-core/systemd/systemd_%.bbappend new file +4 -0
@@ -0,0 +1,4 @@ +inherit rk-rauc-demo-override +inherit rk-rauc-demo-features-check + +PACKAGECONFIG:append:rk-rauc-demo = " repart openssl"
Signature · 1 line
2.44.0.478.g7774cfed6261
Hi Trevor,
On 6/19/24 6:07 AM, Trevor Woerner via lists.yoctoproject.org wrote:
[...]
classes-recipe/rk-rauc-demo-features-check.bbclass line 5
Quoted 11 lines
classes-recipe/rk-rauc-demo-features-check.bbclass new file +5
-0@@ -0,0 +1,8 @@ +inherit features_check + +REQUIRED_DISTRO_FEATURES += "systemd rauc" +REQUIRED_MACHINE_FEATURES += "rk-u-boot-env" +
This isn't correct. If you inherit this class in any recipe, it'll now depend on systemd, rauc and rk-u-boot-env even if RK_RAUC_DEMO isn't set.
Two options here:
"""
REQUIRED_DISTRO_FEATURES:append:rk-rauc-demo = " systemd rauc" REQUIRED_MACHINE_FEATURES:append:rk-rauc-demo = " rk-u-boot-env" """
or in each recipe
"""inherit_defer ${'rk-rauc-demo-features-check' if bb.utils.to_boolean(d.getVar('RK_RAUC_DEMO'), False) else ''} """
Not tested.
classes-recipe/rk-rauc-demo-features-check.bbclass line 8
Quoted 3 lines
classes-recipe/rk-rauc-demo-features-check.bbclass new file +3
-0+# 'RK_RAUC_DEMO' indicates the user wants to use the +# rauc demo configuration from this layer +OVERRIDES .= "${@ ':rk-rauc-demo' if bb.utils.to_boolean(d.getVar('RK_RAUC_DEMO'), False) else ''}"
I don't understand why this override is in this class. OVERRIDES are generally set in conf files. Is there a usecase for which we want one recipe to have RK_RAUC_DEMO set and not another? Because that's the only scenario I could think of that would justify having an OVERRIDES set in a recipe class.
[...]
dynamic-layers/rk-rauc-demo/recipes-bsp/u-boot/u-boot_%.bbappend line 1
Quoted 7 lines
dynamic-layers/rk-rauc-demo/recipes-bsp/u-boot/u-boot_%.bbappend new file +1
-0@@ -0,0 +1,27 @@ +inherit rk-rauc-demo-override
Why this override in a recipe? If a conf file sets RK_RAUC_DEMO then the OVERRIDES would be set on all metadata if the machine conf file inherit rk-rauc-demo-override?
This feedback applies to all recipes/bbappends in this patch. [...]
Quoted 6 lines
dynamic-layers/rk-rauc-demo/recipes-core/systemd/abd-partition.bb new file +0
-0
dynamic-layers/rk-rauc-demo/recipes-core/systemd/abd-partition.bb line 9
Quoted 9 lines
dynamic-layers/rk-rauc-demo/recipes-core/systemd/abd-partition.bb new file +9
-0@@ -0,0 +1,25 @@ +SUMMARY = "A/B+D partition definition for systemd's repart mechanism" +LICENSE = "OSL-3.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/OSL-3.0;md5=438ec6d864bbb958a49df939a56511cf" + +inherit rk-rauc-demo-override +inherit rk-rauc-demo-features-check + +FILESEXTRAPATHS:prepend:rk-rauc-demo := "${THISDIR}/files:" +
This is already in FILESPATH considering this is a recipe, so it's redundant and can be removed.
Quoted 6 lines
dynamic-layers/rk-rauc-demo/recipes-core/systemd/abd-partition.bb new file +6
-0+S = "${UNPACKDIR}" + +SRC_URI:append:rk-rauc-demo = " \ + file://25-rootfsA.conf \ + file://35-rootfsB.conf \ + file://45-data.conf \
dynamic-layers/rk-rauc-demo/recipes-core/systemd/abd-partition.bb line 25
Quoted 10 lines
dynamic-layers/rk-rauc-demo/recipes-core/systemd/abd-partition.bb new file +10
-0+ " + +do_install:append:rk-rauc-demo() { + install -d ${D}${sysconfdir}/repart.d/ + install -m 0644 ${UNPACKDIR}/25-rootfsA.conf ${D}${sysconfdir}/repart.d/ + install -m 0644 ${UNPACKDIR}/35-rootfsB.conf ${D}${sysconfdir}/repart.d/ + install -m 0644 ${UNPACKDIR}/45-data.conf ${D}${sysconfdir}/repart.d/ +} + +FILES:${PN}:append:rk-rauc-demo = " ${sysconfdir}/repart.d/"
If I'm not mistaken, this should be unnecessary since
meta/conf/bitbake.conf has:
FILES:${PN} = "
[...]
${sysconfdir}"
?
Doesn't hurt in any case.
For the whole recipe, I'm not sure we need to use rk-rauc-demo override?
Cheers,
Quentin