Skip to contentSkip to conversation

rauc demo: add

PATCH Superseded Trevor Woerner 2 participants 5 messages Jun 26, 2024 Arm Rockchip

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 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.

---
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       |  8 ++
 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, 410 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
index 6003e7c652fe..8ff006e942b9 100644
@@ -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
new file mode 100644
index 000000000000..946091802f8d
@@ -0,0 +1,8 @@
+inherit features_check
+
+REQUIRED_DISTRO_FEATURES:append:rk-rauc-demo = " systemd rauc"
+REQUIRED_MACHINE_FEATURES:append:rk-rauc-demo = " 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 ''}"
conf/layer.conf +4 -0
index 68205dd7ea4c..03914d2952e1 100644
@@ -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
new file mode 100644
index 000000000000..a6f79503076b
@@ -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
index ebfc0cb96507..0e0aa5d9b340 100644
@@ -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
new file mode 100644
index 000000000000..77b7164e0192
@@ -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
new file mode 100644
index 000000000000..fa96b4dd18bf
@@ -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
new file mode 100644
index 000000000000..705979a17c3e
@@ -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
new file mode 100644
index 000000000000..3be093e457e9
@@ -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
new file mode 100644
index 000000000000..80305f8291b1
@@ -0,0 +1,28 @@
+-----BEGIN PRIVATE KEY-----
+MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCsKw8FAtC7sEcF
+NnE8IA6ndo11wSNebHotlP88F9gLREgqggOSxf0zdgxCz02KyUd/r1J8FWw752DR
+BJckewcfVn1sPzHo+TZ7M1vPVOo3mKaxmh3alqEHFJwVgE3bDAOGzsc9clei2qDA
+jLKaoGrluF9S0vYnykj044brviSTaq9gaH8JO4GWzoUMY5PY+pHcUC53u7w4QumG
+2Kwz3ebUN2njAY0hj6lKfxWlqqm+/DaTpBAMGDMwBn8cE7OpxlfXa5ZFFef1jz1I
+4AhGT3/vFHeVJSWbFCGEJes3CwFI5vXBi2HGy4xrp9jS+THjgD946mpBbF1Ng6ZU
+DVvCDvbvAgMBAAECggEASphBYq9sltVyf/ytpRpSnxYLhmiPFXs0mIlE6Nl/3qnQ
+BrLcL3yfDuvntg6xjx9UXistNtvlUDMYzJcLkV/InzhPEVZ0HnfTth9zeOpWrI30
+M2EN7EZ1MGcqlVpI4U5cPM1cn+/proLBQYv0WnCEwFFY477JrkXDxG7MZ1mz6TaL
+IGcCCIUu1BxECngQ344eaKrSR5F2MtlxAl19Pt5QSPfmuMdmElrK6RtBjnKrDu1K
+fe6DCfObZ3nbG2fhFV4uTxhlTC9lUmfTQMKR79rLmHNKnbMx74kFNvy3XlT2l35I
+ZVfRMLPWph7yMom9v/Im3Q70uhJ1lxyqbbl/DFZVmQKBgQDVo19SqR/QeDIxPIPn
+XvVWzo5ml3KO/dVxA8sok6twr+G7yUeIUnuauYFA/tX/FS32azFRa/7GjUfoTx3q
+GHK43TBCMyEt0we6WwZb+FkWa/b/RBoyD/audrpmgDDi1+fXPs8bBvoO8/oju20D
+I6wOjSovcIMaeLo/+u3U6ShNQwKBgQDOTpoGMsQzXchZfDmxL61h3j4Gtjrl4BpU
+WhAkJ9U2BRpL8NSZLErn5ik8MwgK2ut+YdU7aogI0D6Gc+4zZoJDEbhhmPD9cprv
+LMyfAKoisR01OyU57mMSGQq0dfjmK6PfYJdX5sQJGkMFptNAJLTDoYtmXItSICoY
+1j5KTvwe5QKBgGytxmErjfakHoxzh3pdERuOylwgMPPS5xCt6FyE+pLBtmisFQqh
+QyXLtpgUy1IPOSmBED6mXJ4u4uSn0sTymPG3+8PBdOB12RmREqQYq2E/nQ/wWg8b
+ldbcqShZkATl5pfV6M+L9gtDS/1/bA5LyExCvbISX29I+R5xDSnhTlI3AoGBAJRK
+VVXtOa/+UhtYOpPMxGCbgZQLemxvWB2XmxCR/SRWKJ+7XOU4vCLSAoO93qMG1szB
+/6Y0ndFP9hFo1SfnH+ybmR+18ksLDKisV+xWavSCwI7Zk5l/a4C/tT0fqyeu6JyQ
+bliFjBVK5i/yyNfLSo9v16ZdENuYOQofPSjmezytAoGBALhwvtzgqvqGSXID2w5N
+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
new file mode 100644
index 000000000000..5a42f59b821e
@@ -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
new file mode 100644
index 000000000000..4945c67345c4
@@ -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
new file mode 100644
index 000000000000..281eb2c4de91
@@ -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
new file mode 100644
index 000000000000..1952805f4a6d
@@ -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
new file mode 100644
index 000000000000..dba01e1ff863
@@ -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
new file mode 100644
index 000000000000..31a7c06c17ff
@@ -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
new file mode 100644
index 000000000000..1aac59addc26
@@ -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
new file mode 100644
index 000000000000..c81a55be1d1a
@@ -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
new file mode 100644
index 000000000000..cf6c188277db
@@ -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
#1 lore raw

Hi Trevor,

Quoted 118 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 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.

---
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       |  8 ++
  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, 410 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
index 6003e7c652fe..8ff006e942b9 100644
@@ -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 +0 -0
new file mode 100644
index 000000000000..946091802f8d

classes-recipe/rk-rauc-demo-features-check.bbclass line 8

Quoted 8 lines
classes-recipe/rk-rauc-demo-features-check.bbclass new file +8 -0
@@ -0,0 +1,8 @@
+inherit features_check
+
+REQUIRED_DISTRO_FEATURES:append:rk-rauc-demo = " systemd rauc"
+REQUIRED_MACHINE_FEATURES:append:rk-rauc-demo = " 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 ''}"

I don't understand why this is in a recipe bbclass, the one in conf/machine/include/rockchip-rauc.inc should already be enough?

[...]

Quoted 9 lines
conf/machine/include/rockchip-rauc.inc new file +3 -0
new file mode 100644
index 000000000000..a6f79503076b
@@ -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 ''}"

[...]

conf/machine/include/rockchip-rauc.inc

Quoted 6 lines
conf/machine/include/rockchip-rauc.inc new file +6 -0
+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
+

Richard has said today he'd prefer we don't use UNPACKDIR for that kind of things, c.f. https://lore.kernel.org/openembedded-core/[email protected]/T/#md4b10cea4af07c1a2e5be43e4ee8c8b1fbc6e420 (though we "agreed" later in the thread to use ${B} instead of the originally suggested ${WORKDIR}).

[...]

Quoted 29 lines
dynamic-layers/rk-rauc-demo/recipes-core/rauc/files/system.conf new file +17 -0
new file mode 100644
index 000000000000..4945c67345c4
@@ -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 +0 -0
new file mode 100644
index 000000000000..281eb2c4de91

dynamic-layers/rk-rauc-demo/recipes-core/rauc/rauc-conf.bbappend line 4

Quoted 4 lines
dynamic-layers/rk-rauc-demo/recipes-core/rauc/rauc-conf.bbappend new file +4 -0
@@ -0,0 +1,7 @@
+inherit rk-rauc-demo-features-check
+
+FILESEXTRAPATHS:prepend:rk-rauc-demo := "${THISDIR}/files:"
+

I would recommend renaming the directory to rauc-conf here, but that's just up to one's preference.

Looking good otherwise :)

Cheers,
Quentin

#2 lore raw
Quoted 122 lines · Quentin Schulz via lists.yoctoproject.org

Hi Trevor,

Quoted 119 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 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.

---
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       |  8 ++
  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, 410 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
index 6003e7c652fe..8ff006e942b9 100644
@@ -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 +3 -0
new file mode 100644
index 000000000000..946091802f8d
@@ -0,0 +1,8 @@
+inherit features_check
+
+REQUIRED_DISTRO_FEATURES:append:rk-rauc-demo = " systemd rauc"
Quoted 8 lines

classes-recipe/rk-rauc-demo-features-check.bbclass line 8

Quoted 5 lines
classes-recipe/rk-rauc-demo-features-check.bbclass new file +5 -0
+REQUIRED_MACHINE_FEATURES:append:rk-rauc-demo = " 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 ''}"

I don't understand why this is in a recipe bbclass, the one in conf/machine/include/rockchip-rauc.inc should already be enough?

Good catch! That wasn't supposed to be there, it must have snuck in with all the rebasing I was doing late at night.

Quoted 14 lines

[...]

Quoted 9 lines
conf/machine/include/rockchip-rauc.inc new file +3 -0
new file mode 100644
index 000000000000..a6f79503076b
@@ -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 ''}"

[...]

Quoted 11 lines

conf/machine/include/rockchip-rauc.inc

Quoted 6 lines
conf/machine/include/rockchip-rauc.inc new file +6 -0
+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
+

Richard has said today he'd prefer we don't use UNPACKDIR for that kind of
things, c.f. https://lore.kernel.org/openembedded-core/[email protected]/T/#md4b10cea4af07c1a2e5be43e4ee8c8b1fbc6e420
(though we "agreed" later in the thread to use ${B} instead of the
originally suggested ${WORKDIR}).

Alright.

Quoted 30 lines

[...]

Quoted 28 lines
dynamic-layers/rk-rauc-demo/recipes-core/rauc/files/system.conf new file +17 -0
new file mode 100644
index 000000000000..4945c67345c4
@@ -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 +0 -0
new file mode 100644
index 000000000000..281eb2c4de91
Quoted 8 lines

dynamic-layers/rk-rauc-demo/recipes-core/rauc/rauc-conf.bbappend line 4

Quoted 5 lines
dynamic-layers/rk-rauc-demo/recipes-core/rauc/rauc-conf.bbappend new file +4 -0
@@ -0,0 +1,7 @@
+inherit rk-rauc-demo-features-check
+
+FILESEXTRAPATHS:prepend:rk-rauc-demo := "${THISDIR}/files:"
+

I would recommend renaming the directory to rauc-conf here, but that's just up to one's preference.

Hmm... the rauc-conf recipe is in the rauc diretory in meta-rauc so I followed how the parent layer was doing it. I think I prefer it this way; makes it slightly easier to find the thing the bbappend is appending when both the parent and child layers use the same directory structure.

Quoted 15 lines

Looking good otherwise :)

Cheers,
Quentin

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#381): https://lists.yoctoproject.org/g/yocto-patches/message/381
Mute This Topic: https://lists.yoctoproject.org/mt/106889680/900817
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto-patches/leave/13168745/900817/63955952/xyzzy [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#3 lore raw
Quoted 161 lines · Trevor Woerner
Quoted 122 lines · Quentin Schulz via lists.yoctoproject.org

Hi Trevor,

Quoted 119 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 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.

---
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       |  8 ++
  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, 410 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
index 6003e7c652fe..8ff006e942b9 100644
@@ -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 +3 -0
new file mode 100644
index 000000000000..946091802f8d
@@ -0,0 +1,8 @@
+inherit features_check
+
+REQUIRED_DISTRO_FEATURES:append:rk-rauc-demo = " systemd rauc"
Quoted 8 lines

classes-recipe/rk-rauc-demo-features-check.bbclass line 8

Quoted 5 lines
classes-recipe/rk-rauc-demo-features-check.bbclass new file +5 -0
+REQUIRED_MACHINE_FEATURES:append:rk-rauc-demo = " 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 ''}"

I don't understand why this is in a recipe bbclass, the one in conf/machine/include/rockchip-rauc.inc should already be enough?

Good catch! That wasn't supposed to be there, it must have snuck in with all the rebasing I was doing late at night.

Quoted 14 lines

[...]

Quoted 9 lines
conf/machine/include/rockchip-rauc.inc new file +3 -0
new file mode 100644
index 000000000000..a6f79503076b
@@ -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 ''}"

[...]

Quoted 11 lines

conf/machine/include/rockchip-rauc.inc

Quoted 6 lines
conf/machine/include/rockchip-rauc.inc new file +6 -0
+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
+

Richard has said today he'd prefer we don't use UNPACKDIR for that kind of
things, c.f. https://lore.kernel.org/openembedded-core/[email protected]/T/#md4b10cea4af07c1a2e5be43e4ee8c8b1fbc6e420
(though we "agreed" later in the thread to use ${B} instead of the
originally suggested ${WORKDIR}).

Quoted 1 line

Alright.

Actually... I have to do it that way so that the parent u-boot recipe picks up this file "automatically". See the "install" line in u-boot.inc in oe-core.

Are our other uses of UNPACKDIR in meta-rockchip okay? If not I could submit another patch to fix them up (and fixup any of the ones related to this patch as part of a v4).

Quoted 59 lines
Quoted 30 lines

[...]

Quoted 28 lines
dynamic-layers/rk-rauc-demo/recipes-core/rauc/files/system.conf new file +17 -0
new file mode 100644
index 000000000000..4945c67345c4
@@ -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 +0 -0
new file mode 100644
index 000000000000..281eb2c4de91
Quoted 8 lines

dynamic-layers/rk-rauc-demo/recipes-core/rauc/rauc-conf.bbappend line 4

Quoted 5 lines
dynamic-layers/rk-rauc-demo/recipes-core/rauc/rauc-conf.bbappend new file +4 -0
@@ -0,0 +1,7 @@
+inherit rk-rauc-demo-features-check
+
+FILESEXTRAPATHS:prepend:rk-rauc-demo := "${THISDIR}/files:"
+

I would recommend renaming the directory to rauc-conf here, but that's just up to one's preference.

Hmm... the rauc-conf recipe is in the rauc diretory in meta-rauc so I followed how the parent layer was doing it. I think I prefer it this way; makes it slightly easier to find the thing the bbappend is appending when both the parent and child layers use the same directory structure.

Quoted 15 lines

Looking good otherwise :)

Cheers,
Quentin

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#381): https://lists.yoctoproject.org/g/yocto-patches/message/381
Mute This Topic: https://lists.yoctoproject.org/mt/106889680/900817
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto-patches/leave/13168745/900817/63955952/xyzzy [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#4 lore raw

Hi Trevor,

Quoted 5 lines · Trevor Woerner via lists.yoctoproject.org
Quoted 4 lines · Trevor Woerner
Quoted 3 lines · Quentin Schulz via lists.yoctoproject.org

Hi Trevor,

On 6/26/24 3:56 PM, Trevor Woerner via lists.yoctoproject.org wrote:

[...]

Quoted 12 lines
Quoted 12 lines
Quoted 11 lines

dynamic-layers/rk-rauc-demo/recipes-bsp/u-boot/u-boot_%.bbappend line 16

Quoted 6 lines
dynamic-layers/rk-rauc-demo/recipes-bsp/u-boot/u-boot_%.bbappend new file +6 -0
+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
+

Richard has said today he'd prefer we don't use UNPACKDIR for that kind of
things, c.f. https://lore.kernel.org/openembedded-core/[email protected]/T/#md4b10cea4af07c1a2e5be43e4ee8c8b1fbc6e420
(though we "agreed" later in the thread to use ${B} instead of the
originally suggested ${WORKDIR}).

Quoted 5 lines
Quoted 1 line

Alright.

Actually... I have to do it that way so that the parent u-boot recipe picks up this file "automatically". See the "install" line in u-boot.inc in oe-core.

I only see it using UNPACKDIR for fw_env.config and I don't think we're writing this here in this patch? Though we do write it in rk_generate_env already (in a previous patch)...

I think meta-rockchip is fine for now due to this code path only being run whenever rk-u-boot-env OVERRIDE is there AND the fact that we have an append for this OVERRIDE in SRC_URI. Which means if we unset it, do_fetch will run again, and it should delete UNPACKDIR then. So no poisoning **today**.

It is an interesting question though... I'm wondering if recipes shouldn't copy their files from UNPACKDIR to S/B before using them instead of directly getting them from UNPACKDIR, so they could be overridden by bbappend without poisoning UNPACKDIR between builds. It feels like this WORKDIR->UNPACKDIR migration fixed one issue (patches in SRC_URI being removed but still being applied) but not everything. I don't have a suggestion right now though :/

Quoted 4 lines

Are our other uses of UNPACKDIR in meta-rockchip okay? If not I could submit another patch to fix them up (and fixup any of the ones related to this patch as part of a v4).

In the current state, I think it's fine. We should rather fix the upstream u-boot recipe to fix the use of UNPACKDIR for getting fw_env.config?

[...]

Quoted 14 lines
Quoted 14 lines
Quoted 13 lines

dynamic-layers/rk-rauc-demo/recipes-core/rauc/rauc-conf.bbappend line 4

Quoted 10 lines
dynamic-layers/rk-rauc-demo/recipes-core/rauc/rauc-conf.bbappend new file +4 -0
new file mode 100644
index 000000000000..281eb2c4de91
@@ -0,0 +1,7 @@
+inherit rk-rauc-demo-features-check
+
+FILESEXTRAPATHS:prepend:rk-rauc-demo := "${THISDIR}/files:"
+

I would recommend renaming the directory to rauc-conf here, but that's just up to one's preference.

Quoted 5 lines
Quoted 5 lines

Hmm... the rauc-conf recipe is in the rauc diretory in meta-rauc so I followed how the parent layer was doing it. I think I prefer it this way; makes it slightly easier to find the thing the bbappend is appending when both the parent and child layers use the same directory structure.

I usually try to avoid using files/ except when I want two recipes or bbappends for different recipes to share the same files. But matching the original recipe layout is a good justification :)

Cheers,
Quentin