rauc demo: add
PATCH v4 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.
---
v4 change:
- remove OVERRIDE from the features-check class (left in by mistake)
v3 changes:
- change the OVERRIDE mechanism from a class to a config
- fix the required features check to include an OVERRIDE
- use a systemd mount unit for the /data partition
- abd-partition recipe cleanup:
- remove extraneous FILESEXTRAPATHS
- remove OVERRIDES, this recipe will only be used with rauc
- remove extraneous FILES:${PN} for ${sysconfdir}
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 | 4 + conf/layer.conf | 4 + conf/machine/include/rockchip-rauc.inc | 4 + conf/machine/include/rockchip-wic.inc | 2 + .../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 | 26 ++++++ .../base-files/base-files_%.bbappend | 2 + .../recipes-core/base-files/files/fstab | 5 ++ .../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 | 7 ++ .../recipes-core/systemd/abd-partition.bb | 26 ++++++ .../systemd/files/25-rootfsA.conf | 4 + .../systemd/files/35-rootfsB.conf | 7 ++ .../recipes-core/systemd/files/45-data.conf | 6 ++ .../recipes-core/systemd/files/data.mount | 10 +++ .../recipes-core/systemd/systemd_%.bbappend | 3 + 22 files changed, 406 insertions(+) create mode 100644 classes-recipe/rk-rauc-demo-features-check.bbclass create mode 100644 conf/machine/include/rockchip-rauc.inc 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/files/data.mount 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 +4 -0
@@ -0,0 +1,4 @@ +inherit features_check + +REQUIRED_DISTRO_FEATURES:append:rk-rauc-demo = " systemd rauc" +REQUIRED_MACHINE_FEATURES:append:rk-rauc-demo = " rk-u-boot-env"
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-rauc.inc new file +4 -0
@@ -0,0 +1,4 @@ +# '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 ''}" +IMAGE_INSTALL:append:rk-rauc-demo = " abd-partition"
conf/machine/include/rockchip-wic.inc +2 -0
@@ -2,6 +2,7 @@ require conf/machine/include/rockchip-extlinux.inc require conf/machine/include/rockchip-rk-u-boot-env.inc +require conf/machine/include/rockchip-rauc.inc SPL_BINARY ?= "idbloader.img"
@@ -9,6 +10,7 @@ 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" 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 +26 -0
@@ -0,0 +1,26 @@ +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 +2 -0
@@ -0,0 +1,2 @@ +inherit rk-rauc-demo-features-check +FILESEXTRAPATHS:prepend:rk-rauc-demo := "${THISDIR}/files:"
dynamic-layers/rk-rauc-demo/recipes-core/base-files/files/fstab new file +5 -0
@@ -0,0 +1,5 @@ +/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
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+THjgD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ZdENuYOQofPSjmezytAoGBALhwvtzgqvqGSXID2w5N +ullK8ny3WRa1o5DLXuMV19CvknmrN/zmmjQLblKkdp9VBb7uo8czon+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 +7 -0
@@ -0,0 +1,7 @@ +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 +26 -0
@@ -0,0 +1,26 @@ +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-features-check systemd + +SYSTEMD_SERVICE:${PN} = "data.mount" + +S = "${UNPACKDIR}" + +SRC_URI = " \ + file://data.mount \ + file://25-rootfsA.conf \ + file://35-rootfsB.conf \ + file://45-data.conf \ + " + +do_install() { + 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/ + + install -d ${D}${sysconfdir}/systemd/system + install -m 0644 ${UNPACKDIR}/data.mount ${D}${sysconfdir}/systemd/system/ +}
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/files/data.mount new file +10 -0
@@ -0,0 +1,10 @@ +[Unit] +Description=data partition + +[Mount] +What=/dev/disk/by-partlabel/data +Where=/data +Type=ext4 + +[Install] +WantedBy=multi-user.target
dynamic-layers/rk-rauc-demo/recipes-core/systemd/systemd_%.bbappend new file +3 -0
@@ -0,0 +1,3 @@ +inherit rk-rauc-demo-features-check + +PACKAGECONFIG:append:rk-rauc-demo = " repart openssl"
Signature · 1 line
2.44.0.478.g7774cfed6261
Hi Trevor,
Quoted 8 lines · Trevor Woerner via lists.yoctoproject.org
Add an example of implementing rauc on a rockchip board. Adding the meta-rauc layer, adding 'rauc' to
DISTRO_FEATURES, and enablingRK_RAUC_DEMOwill 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.
Quoted 8 lines
NOTE:
- this example only works with systemdIf you wish to provide your own implementation, simply add the meta-rauc layer, add 'rauc' to
DISTRO_FEATURES, don't enableRK_RAUC_DEMO, and provide your own implementation in a separate layer.Signed-off-by Trevor Woerner <[email protected]>
I think it's fine now :)
BTW, I found https://www.konsulko.com/rauc-on-rockchip yesterday. Is this something we want to discuss with Leon to see if he has some feedback or if he plans on using this feature here?
Thanks!
Quentin
Trevor Woerner
AppliedQuoted 18 lines · Quentin Schulz via lists.yoctoproject.org
Hi Trevor,
Quoted 15 lines · Trevor Woerner via lists.yoctoproject.org
Add an example of implementing rauc on a rockchip board. Adding the meta-rauc layer, adding 'rauc' to
DISTRO_FEATURES, and enablingRK_RAUC_DEMOwill 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 systemdIf you wish to provide your own implementation, simply add the meta-rauc layer, add 'rauc' to
DISTRO_FEATURES, don't enableRK_RAUC_DEMO, and provide your own implementation in a separate layer.
Quoted 5 lines
Quoted 1 line
Signed-off-by Trevor Woerner <[email protected]>I think it's fine now :)
Reviewed-by Quentin Schulz <[email protected]>
Thanks! Applied to meta-rockchip, master branch.