diff --git a/README.rst b/README.rst index 6c8a58a0..af4b19be 100644 --- a/README.rst +++ b/README.rst @@ -16,6 +16,8 @@ differ in some aspects. Currently available meta layers are: +* `meta-rauc-beaglebone `_: + RAUC demo layer for BeagleBoard devices such BeagleBone Black and PocketBeagle 2 (meta-ti) * `meta-rauc-nxp `_: RAUC demo layer for NXP hardware (meta-freescale) * `meta-rauc-qemuarm `_: diff --git a/meta-rauc-beaglebone/README.rst b/meta-rauc-beaglebone/README.rst index 5afb75c2..5de905dc 100644 --- a/meta-rauc-beaglebone/README.rst +++ b/meta-rauc-beaglebone/README.rst @@ -28,6 +28,13 @@ a much different RAUC/bootloader/system configuration. Also note that this layer is for demo purpose only and does not care about migratability between different layer revision. +Currently layer meta-rauc-beaglebone supports: + +- BeagleBone Black (machine beaglebone-yocto from meta-yocto-bsp) +- BeagleBone AI-64 (machine beaglebone-ai64 from meta-ti/meta-beagle) +- PocketBeagle (machine beaglebone from meta-ti/meta-beagle) +- PocketBeagle 2 (machine pocketbeagle2 from meta-ti/meta-beagle) + I. Adding the meta-rauc-beaglebone layer to your build ======================================================= @@ -63,18 +70,18 @@ It is also recommended, but not strictly necessary, to enable 'systemd':: Build the minimal system image:: - $ bitbake core-image-minimal + $ bitbake core-image-base III. Flash & Run The Demo System ================================ You can either flash using bmaptool (recommended):: - $ bmaptool copy /path/to/core-image-minimal-beaglebone-yocto.wic.xz /dev/sdX + $ bmaptool copy /path/to/core-image-base-beaglebone-yocto.wic.xz /dev/sdX or bzcat:: - $ bzcat /path/to/core-image-minimal-beaglebone-yocto.wic.xz | dd of=/dev/sdb + $ bzcat /path/to/core-image-base-beaglebone-yocto.wic.xz | dd of=/dev/sdb Then power-on the board and log in. To see that RAUC is configured correctly and can interact with the bootloader, diff --git a/meta-rauc-beaglebone/conf/layer.conf b/meta-rauc-beaglebone/conf/layer.conf index 3bf35621..10612296 100644 --- a/meta-rauc-beaglebone/conf/layer.conf +++ b/meta-rauc-beaglebone/conf/layer.conf @@ -7,7 +7,7 @@ BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ BBFILE_COLLECTIONS += "meta-rauc-beaglebone" BBFILE_PATTERN_meta-rauc-beaglebone = "^${LAYERDIR}/" -BBFILE_PRIORITY_meta-rauc-beaglebone = "6" +BBFILE_PRIORITY_meta-rauc-beaglebone = "7" LAYERDEPENDS_meta-rauc-beaglebone = "core rauc yoctobsp" LAYERSERIES_COMPAT_meta-rauc-beaglebone = "whinlatter" diff --git a/meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone-ai64/boot.cmd b/meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone-ai64/boot.cmd new file mode 100644 index 00000000..7f727063 --- /dev/null +++ b/meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone-ai64/boot.cmd @@ -0,0 +1,59 @@ +test -n "${BOOT_ORDER}" || env set BOOT_ORDER "A B" +test -n "${BOOT_A_LEFT}" || env set BOOT_A_LEFT 3 +test -n "${BOOT_B_LEFT}" || env set BOOT_B_LEFT 3 + +env set bootpart +env set bootdev +env set raucslot + +for BOOT_SLOT in "${BOOT_ORDER}"; do + if test "x${bootpart}" != "x"; then + # stop checking after selecting a slot + + elif test "x${BOOT_SLOT}" = "xA"; then + if itest ${BOOT_A_LEFT} -gt 0; then + setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1 + echo "Booting RAUC slot A" + + setenv bootpart "/dev/mmcblk1p2" + setenv raucslot "A" + setenv bootdev "mmc 1:2" + fi + + elif test "x${BOOT_SLOT}" = "xB"; then + if itest ${BOOT_B_LEFT} -gt 0; then + setexpr BOOT_B_LEFT ${BOOT_B_LEFT} - 1 + echo "Booting RAUC slot B" + + setenv bootpart "/dev/mmcblk1p3" + setenv raucslot "B" + setenv bootdev "mmc 1:3" + fi + fi +done + + +if test -n "${bootpart}"; then + setenv bootargs "console=${console} ${optargs} root=${bootpart} rw rootfstype=ext4 rootwait fixrtc rauc.slot=${raucslot}" + saveenv +else + echo "No valid RAUC slot found. Resetting attempts to 3" + setenv BOOT_A_LEFT 3 + setenv BOOT_B_LEFT 3 + saveenv + reset +fi + + +if mmc dev 1; then + + if test ! -e mmc 1:1 /uboot.env; then saveenv; fi; + + part uuid ${bootdev} uuid + load ${bootdev} ${loadaddr} /boot/Image + load ${bootdev} ${fdtaddr} /boot/dtb/${fdtfile} + booti ${loadaddr} - ${fdtaddr} +else + echo "Could not find mmc 1" + reset +fi diff --git a/meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone-ai64/bootcmd-ti-mmc.cfg b/meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone-ai64/bootcmd-ti-mmc.cfg new file mode 100644 index 00000000..f27f9bba --- /dev/null +++ b/meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone-ai64/bootcmd-ti-mmc.cfg @@ -0,0 +1,14 @@ +CONFIG_CMD_SETEXPR=y +CONFIG_LEGACY_IMAGE_FORMAT=y +CONFIG_CMD_SETEXPR=y +# CONFIG_ENV_REDUNDANT is not set +CONFIG_ENV_EXT4_INTERFACE="mmc" +CONFIG_ENV_EXT4_DEVICE_AND_PART="1:1" +CONFIG_ENV_EXT4_FILE="/boot/uboot.env" +CONFIG_ENV_OFFSET=0x0000 +# CONFIG_ENV_IS_NOWHERE is not set +CONFIG_ENV_IS_IN_FAT=y +CONFIG_ENV_FAT_INTERFACE="mmc" +CONFIG_ENV_FAT_DEVICE_AND_PART="1:1" +CONFIG_ENV_FAT_FILE="uboot.env" +CONFIG_BOOTCOMMAND="load mmc 1:1 $loadaddr boot.scr; source $loadaddr" diff --git a/meta-rauc-beaglebone/recipes-bsp/u-boot/files/fw_env.config b/meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone-ai64/fw_env.config similarity index 100% rename from meta-rauc-beaglebone/recipes-bsp/u-boot/files/fw_env.config rename to meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone-ai64/fw_env.config diff --git a/meta-rauc-beaglebone/recipes-bsp/u-boot/files/0001-am335x_evm_defconfig-rauc.patch b/meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone-yocto/0001-am335x_evm_defconfig-rauc.patch similarity index 100% rename from meta-rauc-beaglebone/recipes-bsp/u-boot/files/0001-am335x_evm_defconfig-rauc.patch rename to meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone-yocto/0001-am335x_evm_defconfig-rauc.patch diff --git a/meta-rauc-beaglebone/recipes-bsp/u-boot/files/boot.cmd b/meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone-yocto/boot.cmd similarity index 100% rename from meta-rauc-beaglebone/recipes-bsp/u-boot/files/boot.cmd rename to meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone-yocto/boot.cmd diff --git a/meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone-yocto/fw_env.config b/meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone-yocto/fw_env.config new file mode 100644 index 00000000..5d91d24e --- /dev/null +++ b/meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone-yocto/fw_env.config @@ -0,0 +1 @@ +/boot/uboot.env 0x0000 0x20000 diff --git a/meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone/boot.cmd b/meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone/boot.cmd new file mode 100644 index 00000000..b5bd0c02 --- /dev/null +++ b/meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone/boot.cmd @@ -0,0 +1,61 @@ +run findfdt; + +test -n "${BOOT_ORDER}" || env set BOOT_ORDER "A B" +test -n "${BOOT_A_LEFT}" || env set BOOT_A_LEFT 3 +test -n "${BOOT_B_LEFT}" || env set BOOT_B_LEFT 3 + +env set bootpart +env set bootdev +env set raucslot + +for BOOT_SLOT in "${BOOT_ORDER}"; do + if test "x${bootpart}" != "x"; then + # stop checking after selecting a slot + + elif test "x${BOOT_SLOT}" = "xA"; then + if itest ${BOOT_A_LEFT} -gt 0; then + setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1 + echo "Booting RAUC slot A" + + setenv bootpart "/dev/mmcblk0p2" + setenv raucslot "A" + setenv bootdev "mmc 0:2" + fi + + elif test "x${BOOT_SLOT}" = "xB"; then + if itest ${BOOT_B_LEFT} -gt 0; then + setexpr BOOT_B_LEFT ${BOOT_B_LEFT} - 1 + echo "Booting RAUC slot B" + + setenv bootpart "/dev/mmcblk0p3" + setenv raucslot "B" + setenv bootdev "mmc 0:3" + fi + fi +done + + +if test -n "${bootpart}"; then + setenv bootargs "console=${console} ${optargs} root=${bootpart} rw rootfstype=ext4 rootwait fixrtc rauc.slot=${raucslot}" + saveenv +else + echo "No valid RAUC slot found. Resetting attempts to 3" + setenv BOOT_A_LEFT 3 + setenv BOOT_B_LEFT 3 + saveenv + reset +fi + + +if mmc dev 0; then + + if test ! -e mmc 0:1 ${bootdir}/uboot.env; then saveenv; fi; + + part uuid ${bootdev} uuid + load mmc 0:1 ${loadaddr} ${bootdir}/zImage + load mmc 0:1 ${fdtaddr} ${bootdir}/${fdtfile} + bootz ${loadaddr} - ${fdtaddr} +else + echo "Could not find mmc 0" + reset +fi diff --git a/meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone/bootcmd-ti-mmc.cfg b/meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone/bootcmd-ti-mmc.cfg new file mode 100644 index 00000000..924c08b4 --- /dev/null +++ b/meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone/bootcmd-ti-mmc.cfg @@ -0,0 +1,3 @@ +CONFIG_CMD_SETEXPR=y +CONFIG_LEGACY_IMAGE_FORMAT=y +CONFIG_BOOTCOMMAND="load mmc 0:1 $loadaddr boot.scr; source $loadaddr" diff --git a/meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone/fw_env.config b/meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone/fw_env.config new file mode 100644 index 00000000..5d91d24e --- /dev/null +++ b/meta-rauc-beaglebone/recipes-bsp/u-boot/files/beaglebone/fw_env.config @@ -0,0 +1 @@ +/boot/uboot.env 0x0000 0x20000 diff --git a/meta-rauc-beaglebone/recipes-bsp/u-boot/files/pocketbeagle2/boot.cmd b/meta-rauc-beaglebone/recipes-bsp/u-boot/files/pocketbeagle2/boot.cmd new file mode 100644 index 00000000..74dcbca9 --- /dev/null +++ b/meta-rauc-beaglebone/recipes-bsp/u-boot/files/pocketbeagle2/boot.cmd @@ -0,0 +1,56 @@ +run findfdt; + +test -n "${BOOT_ORDER}" || env set BOOT_ORDER "A B" +test -n "${BOOT_A_LEFT}" || env set BOOT_A_LEFT 3 +test -n "${BOOT_B_LEFT}" || env set BOOT_B_LEFT 3 + +env set rootpart +env set bootdev +env set raucslot + +for BOOT_SLOT in "${BOOT_ORDER}"; do + if test "x${rootpart}" != "x"; then + # stop checking after selecting a slot + + elif test "x${BOOT_SLOT}" = "xA"; then + if itest ${BOOT_A_LEFT} -gt 0; then + setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1 + echo "Booting RAUC slot A" + + setenv rootpart "/dev/mmcblk1p2" + setenv raucslot "A" + setenv bootdev "mmc 1:2" + fi + + elif test "x${BOOT_SLOT}" = "xB"; then + if itest ${BOOT_B_LEFT} -gt 0; then + setexpr BOOT_B_LEFT ${BOOT_B_LEFT} - 1 + echo "Booting RAUC slot B" + + setenv rootpart "/dev/mmcblk1p3" + setenv raucslot "B" + setenv bootdev "mmc 1:3" + fi + fi +done + + +if test -n "${rootpart}"; then + setenv args_mmc "run finduuid;setenv bootargs console=${console} ${optargs} root=${rootpart} rauc.slot=${raucslot} rw rootfstype=${mmcrootfstype}" + saveenv +else + echo "No valid RAUC slot found. Resetting attempts to 3" + setenv BOOT_A_LEFT 3 + setenv BOOT_B_LEFT 3 + saveenv + reset +fi + + +if mmc dev 1; then + if test ! -e mmc 1:1 ${bootdir}/uboot.env; then saveenv; fi; + run bootcmd_ti_mmc +else + echo "Could not find mmc 1" + reset +fi diff --git a/meta-rauc-beaglebone/recipes-bsp/u-boot/files/pocketbeagle2/bootcmd-ti-mmc.cfg b/meta-rauc-beaglebone/recipes-bsp/u-boot/files/pocketbeagle2/bootcmd-ti-mmc.cfg new file mode 100644 index 00000000..62b68f16 --- /dev/null +++ b/meta-rauc-beaglebone/recipes-bsp/u-boot/files/pocketbeagle2/bootcmd-ti-mmc.cfg @@ -0,0 +1,13 @@ +CONFIG_BOOTDELAY=3 +CONFIG_CMD_SETEXPR=y +CONFIG_ENV_EXT4_INTERFACE="mmc" +CONFIG_ENV_EXT4_DEVICE_AND_PART="1:1" +CONFIG_ENV_EXT4_FILE="/boot/uboot.env" +CONFIG_LEGACY_IMAGE_FORMAT=y +CONFIG_ENV_OFFSET=0x0000 +# CONFIG_ENV_IS_NOWHERE is not set +CONFIG_ENV_IS_IN_FAT=y +CONFIG_ENV_FAT_INTERFACE="mmc" +CONFIG_ENV_FAT_DEVICE_AND_PART="1:1" +CONFIG_ENV_FAT_FILE="uboot.env" +CONFIG_BOOTCOMMAND="load mmc 1:1 $loadaddr boot.scr; source $loadaddr" diff --git a/meta-rauc-beaglebone/recipes-bsp/u-boot/files/pocketbeagle2/fw_env.config b/meta-rauc-beaglebone/recipes-bsp/u-boot/files/pocketbeagle2/fw_env.config new file mode 100644 index 00000000..e35b9274 --- /dev/null +++ b/meta-rauc-beaglebone/recipes-bsp/u-boot/files/pocketbeagle2/fw_env.config @@ -0,0 +1 @@ +/boot/uboot.env 0x0000 0x1f000 diff --git a/meta-rauc-beaglebone/recipes-bsp/u-boot/u-boot-bb.org_%.bbappend b/meta-rauc-beaglebone/recipes-bsp/u-boot/u-boot-bb.org_%.bbappend new file mode 100644 index 00000000..46b39bd1 --- /dev/null +++ b/meta-rauc-beaglebone/recipes-bsp/u-boot/u-boot-bb.org_%.bbappend @@ -0,0 +1,48 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/files:" + +# Explicitly set SRC_URI and UBOOT_ENV variables for supported machines +# to avoid issues caused by meta-ti and MACHINE:append = "-k3r5" that +# result in "No such file or directory" and similar errors. + +SRC_URI:append:pocketbeagle2 = " \ + file://fw_env.config \ + file://boot.cmd \ +" + +SRC_URI:append:beaglebone-ai64 = " \ + file://fw_env.config \ + file://boot.cmd \ + file://bootcmd-ti-mmc.cfg \ +" + +SRC_URI:append:beaglebone = " \ + file://fw_env.config \ + file://boot.cmd \ + file://bootcmd-ti-mmc.cfg \ +" + +# The UBOOT_ENV_SUFFIX and UBOOT_ENV are mandatory in order to run the +# uboot-mkimage command from poky/meta/recipes-bsp/u-boot/u-boot.inc +UBOOT_ENV_SUFFIX:beaglebone = "scr" +UBOOT_ENV:beaglebone = "boot" +UBOOT_ENV_SUFFIX:pocketbeagle2 = "scr" +UBOOT_ENV:pocketbeagle2 = "boot" +UBOOT_ENV_SUFFIX:beaglebone-ai64 = "scr" +UBOOT_ENV:beaglebone-ai64 = "boot" + +do_install_fw_env_config() { + install -d ${D}${sysconfdir} + install -m 0644 ${UNPACKDIR}/fw_env.config ${D}${sysconfdir}/fw_env.config +} + +do_install:append:beaglebone() { + do_install_fw_env_config +} + +do_install:append:pocketbeagle2() { + do_install_fw_env_config +} + +do_install:append:beaglebone-ai64() { + do_install_fw_env_config +} diff --git a/meta-rauc-beaglebone/recipes-core/base-files/files/beaglebone-ai64/fstab b/meta-rauc-beaglebone/recipes-core/base-files/files/beaglebone-ai64/fstab new file mode 100644 index 00000000..29d6836d --- /dev/null +++ b/meta-rauc-beaglebone/recipes-core/base-files/files/beaglebone-ai64/fstab @@ -0,0 +1,13 @@ +# stock fstab - you probably want to override this with a machine specific one + +/dev/root / auto defaults 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 + +# uncomment this if your device has a SD/MMC/Transflash slot +#/dev/mmcblk0p1 /media/card auto defaults,sync,noauto 0 0 + +/dev/mmcblk1p1 /boot vfat defaults 0 0 +/dev/mmcblk1p4 /data ext4 defaults 0 0 diff --git a/meta-rauc-beaglebone/recipes-core/base-files/files/fstab b/meta-rauc-beaglebone/recipes-core/base-files/files/beaglebone-yocto/fstab similarity index 100% rename from meta-rauc-beaglebone/recipes-core/base-files/files/fstab rename to meta-rauc-beaglebone/recipes-core/base-files/files/beaglebone-yocto/fstab diff --git a/meta-rauc-beaglebone/recipes-core/base-files/files/beaglebone/fstab b/meta-rauc-beaglebone/recipes-core/base-files/files/beaglebone/fstab new file mode 100644 index 00000000..2a13c691 --- /dev/null +++ b/meta-rauc-beaglebone/recipes-core/base-files/files/beaglebone/fstab @@ -0,0 +1,13 @@ +# stock fstab - you probably want to override this with a machine specific one + +/dev/root / auto defaults 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 + +# uncomment this if your device has a SD/MMC/Transflash slot +#/dev/mmcblk0p1 /media/card auto defaults,sync,noauto 0 0 + +/dev/mmcblk0p1 /boot vfat defaults 0 0 +/dev/mmcblk0p4 /data ext4 defaults 0 0 diff --git a/meta-rauc-beaglebone/recipes-core/base-files/files/pocketbeagle2/fstab b/meta-rauc-beaglebone/recipes-core/base-files/files/pocketbeagle2/fstab new file mode 100644 index 00000000..29d6836d --- /dev/null +++ b/meta-rauc-beaglebone/recipes-core/base-files/files/pocketbeagle2/fstab @@ -0,0 +1,13 @@ +# stock fstab - you probably want to override this with a machine specific one + +/dev/root / auto defaults 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 + +# uncomment this if your device has a SD/MMC/Transflash slot +#/dev/mmcblk0p1 /media/card auto defaults,sync,noauto 0 0 + +/dev/mmcblk1p1 /boot vfat defaults 0 0 +/dev/mmcblk1p4 /data ext4 defaults 0 0 diff --git a/meta-rauc-beaglebone/recipes-core/bundles/update-bundle.bb b/meta-rauc-beaglebone/recipes-core/bundles/update-bundle.bb index ea814863..69753ed3 100644 --- a/meta-rauc-beaglebone/recipes-core/bundles/update-bundle.bb +++ b/meta-rauc-beaglebone/recipes-core/bundles/update-bundle.bb @@ -8,9 +8,9 @@ LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda RAUC_BUNDLE_FORMAT = "verity" -RAUC_BUNDLE_COMPATIBLE = "BeagleBoneBlack" -RAUC_BUNDLE_VERSION = "v20240123" +RAUC_BUNDLE_COMPATIBLE = "${MACHINE}" +RAUC_BUNDLE_VERSION = "v20260306" RAUC_BUNDLE_DESCRIPTION = "RAUC demonstration bundle" RAUC_BUNDLE_SLOTS = "rootfs" -RAUC_SLOT_rootfs = "core-image-minimal" +RAUC_SLOT_rootfs = "core-image-base" RAUC_SLOT_rootfs[fstype] = "ext4" diff --git a/meta-rauc-beaglebone/recipes-core/images/core-image-base.bbappend b/meta-rauc-beaglebone/recipes-core/images/core-image-base.bbappend new file mode 100644 index 00000000..cbff1589 --- /dev/null +++ b/meta-rauc-beaglebone/recipes-core/images/core-image-base.bbappend @@ -0,0 +1 @@ +require rauc-image.inc diff --git a/meta-rauc-beaglebone/recipes-core/images/core-image-minimal.bbappend b/meta-rauc-beaglebone/recipes-core/images/core-image-minimal.bbappend index f1873e5f..cbff1589 100644 --- a/meta-rauc-beaglebone/recipes-core/images/core-image-minimal.bbappend +++ b/meta-rauc-beaglebone/recipes-core/images/core-image-minimal.bbappend @@ -1,9 +1 @@ -IMAGE_FSTYPES += "wic wic.xz wic.bmap ext4" -WKS_FILE = "beaglebone-yocto-dual.wks.in" -IMAGE_BOOT_FILES += " boot.scr" - -# Optimizations for RAUC adaptive method 'block-hash-index' -# rootfs image size must to be 4K-aligned -IMAGE_ROOTFS_ALIGNMENT = "4" -# ext4 block and inode size should be set to 4K -EXTRA_IMAGECMD:ext4 = "-i 4096 -b 4096" +require rauc-image.inc diff --git a/meta-rauc-beaglebone/recipes-core/images/rauc-image.inc b/meta-rauc-beaglebone/recipes-core/images/rauc-image.inc new file mode 100644 index 00000000..98a9934d --- /dev/null +++ b/meta-rauc-beaglebone/recipes-core/images/rauc-image.inc @@ -0,0 +1,14 @@ +IMAGE_FSTYPES += "wic wic.xz wic.bmap ext4" +WKS_FILE:beaglebone-yocto = "beaglebone-yocto-dual.wks.in" +WKS_FILE:beaglebone = "beaglebone-yocto-dual.wks.in" +WKS_FILE:pocketbeagle2 = "sdimage-2part-efi-dual.wks.in" +WKS_FILE:beaglebone-ai64 = "sdimage-2part-efi-dual.wks.in" +IMAGE_BOOT_FILES += "boot.scr" + +# Optimizations for RAUC adaptive method 'block-hash-index' +# rootfs image size must to be 4K-aligned +IMAGE_ROOTFS_ALIGNMENT = "4" +# ext4 block and inode size should be set to 4K +EXTRA_IMAGECMD:ext4 = "-i 4096 -b 4096" + +IMAGE_OVERHEAD_FACTOR = "1.2" diff --git a/meta-rauc-beaglebone/recipes-core/rauc/files/beaglebone-ai64/system.conf b/meta-rauc-beaglebone/recipes-core/rauc/files/beaglebone-ai64/system.conf new file mode 100644 index 00000000..07711ef3 --- /dev/null +++ b/meta-rauc-beaglebone/recipes-core/rauc/files/beaglebone-ai64/system.conf @@ -0,0 +1,17 @@ +[system] +compatible=@@MACHINE@@ +bootloader=uboot +data-directory=/data/ + +[keyring] +path=/etc/rauc/ca.cert.pem + +[slot.rootfs.0] +device=/dev/mmcblk1p2 +type=ext4 +bootname=A + +[slot.rootfs.1] +device=/dev/mmcblk1p3 +type=ext4 +bootname=B diff --git a/meta-rauc-beaglebone/recipes-core/rauc/files/system.conf b/meta-rauc-beaglebone/recipes-core/rauc/files/beaglebone-yocto/system.conf similarity index 88% rename from meta-rauc-beaglebone/recipes-core/rauc/files/system.conf rename to meta-rauc-beaglebone/recipes-core/rauc/files/beaglebone-yocto/system.conf index 5f8c0bc2..bd8568b2 100644 --- a/meta-rauc-beaglebone/recipes-core/rauc/files/system.conf +++ b/meta-rauc-beaglebone/recipes-core/rauc/files/beaglebone-yocto/system.conf @@ -1,5 +1,5 @@ [system] -compatible=BeagleBoneBlack +compatible=@@MACHINE@@ bootloader=uboot data-directory=/data/ diff --git a/meta-rauc-beaglebone/recipes-core/rauc/files/beaglebone/system.conf b/meta-rauc-beaglebone/recipes-core/rauc/files/beaglebone/system.conf new file mode 100644 index 00000000..bd8568b2 --- /dev/null +++ b/meta-rauc-beaglebone/recipes-core/rauc/files/beaglebone/system.conf @@ -0,0 +1,17 @@ +[system] +compatible=@@MACHINE@@ +bootloader=uboot +data-directory=/data/ + +[keyring] +path=/etc/rauc/ca.cert.pem + +[slot.rootfs.0] +device=/dev/mmcblk0p2 +type=ext4 +bootname=A + +[slot.rootfs.1] +device=/dev/mmcblk0p3 +type=ext4 +bootname=B diff --git a/meta-rauc-beaglebone/recipes-core/rauc/files/grow-data-partition.sh b/meta-rauc-beaglebone/recipes-core/rauc/files/grow-data-partition.sh new file mode 100644 index 00000000..c859886d --- /dev/null +++ b/meta-rauc-beaglebone/recipes-core/rauc/files/grow-data-partition.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +total_disk_size=$(cat /sys/block/@@DATADEV@@/size) + +data_part_size=$(cat /sys/block/@@DATADEV@@/@@DATADEV@@p4/size) +data_part_start=$(cat /sys/block/@@DATADEV@@/@@DATADEV@@p4/start) + +if [ -z "${total_disk_size}" ] || [ -z "${data_part_size}" ] || [ -z "${data_part_start}" ]; then + echo "Failed to read disk sizes. Aborting..." + exit 1 +fi + +data_part_end=$(expr ${data_part_start} + ${data_part_size}) + +# expr returns 1 (error) if the result is 0, which terminates the script +# because of 'set -e'. Silence this error +free_space=$(expr ${total_disk_size} - ${data_part_end} || true) + +# If there is less than 8196 blocks = 4 MiB free unused space, we consider +# the disk as already resized. After resizing, some disk space may still +# have been left unused. +if [ ${free_space} -lt 8196 ]; then + echo "Disk has already been resized." + exit 0 +fi + +/usr/bin/umount /dev/@@DATADEV@@p4 +/usr/sbin/sgdisk /dev/@@DATADEV@@ -e +/usr/sbin/partprobe +/usr/sbin/parted --script /dev/@@DATADEV@@ resizepart 4 100% +/usr/sbin/resize2fs /dev/@@DATADEV@@p4 +/usr/bin/umount /dev/@@DATADEV@@p4 +/usr/sbin/e2fsck -fp /dev/@@DATADEV@@p4 +/usr/bin/mount /dev/@@DATADEV@@p4 /data/ + +echo "Disk resized." +exit 0 diff --git a/meta-rauc-beaglebone/recipes-core/rauc/files/pocketbeagle2/system.conf b/meta-rauc-beaglebone/recipes-core/rauc/files/pocketbeagle2/system.conf new file mode 100644 index 00000000..9c64726a --- /dev/null +++ b/meta-rauc-beaglebone/recipes-core/rauc/files/pocketbeagle2/system.conf @@ -0,0 +1,17 @@ +[system] +compatible=@@MACHINE@@ +bootloader=uboot +data-directory=/data/ + +[keyring] +path=/etc/rauc/ca.cert.pem + +[slot.rootfs.0] +device=/dev/mmcblk1p2 +type=ext4 +bootname=A + +[slot.rootfs.1] +device=/dev/mmcblk1p3 +type=ext4 +bootname=B diff --git a/meta-rauc-beaglebone/recipes-core/rauc/files/rauc-grow-data-partition.service b/meta-rauc-beaglebone/recipes-core/rauc/files/rauc-grow-data-partition.service index bcba29bd..4e621103 100644 --- a/meta-rauc-beaglebone/recipes-core/rauc/files/rauc-grow-data-partition.service +++ b/meta-rauc-beaglebone/recipes-core/rauc/files/rauc-grow-data-partition.service @@ -1,12 +1,12 @@ [Unit] Description=Service to grow data partition size DefaultDependencies=no -Before=home.mount +Before=data.mount [Service] Type=oneshot RemainAfterExit=yes -ExecStart=/usr/sbin/parted --script /dev/mmcblk0 resizepart 4 100% +ExecStart=/usr/bin/grow-data-partition.sh [Install] -WantedBy=home.mount +WantedBy=data.mount diff --git a/meta-rauc-beaglebone/recipes-core/rauc/rauc-conf.bbappend b/meta-rauc-beaglebone/recipes-core/rauc/rauc-conf.bbappend index 8802adbb..adc3d795 100644 --- a/meta-rauc-beaglebone/recipes-core/rauc/rauc-conf.bbappend +++ b/meta-rauc-beaglebone/recipes-core/rauc/rauc-conf.bbappend @@ -1 +1,5 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/files:" + +do_install:prepend() { + sed -i "s/@@MACHINE@@/${MACHINE}/g" ${UNPACKDIR}/system.conf +} diff --git a/meta-rauc-beaglebone/recipes-core/rauc/rauc_%.bbappend b/meta-rauc-beaglebone/recipes-core/rauc/rauc_%.bbappend index 52157db4..ee6b5e2e 100644 --- a/meta-rauc-beaglebone/recipes-core/rauc/rauc_%.bbappend +++ b/meta-rauc-beaglebone/recipes-core/rauc/rauc_%.bbappend @@ -1,10 +1,17 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/files:" -SRC_URI:append := " \ + +SRC_URI:append = " \ file://rauc-grow-data-partition.service \ + file://grow-data-partition.sh \ " # additional dependencies required to run RAUC on the target -RDEPENDS:${PN} += "u-boot-fw-utils u-boot-env" +RDEPENDS:${PN} += "u-boot-fw-utils" + +RDEPENDS:${PN}:append:beaglebone-yocto = " u-boot-env" +RDEPENDS:${PN}:append:beaglebone = " u-boot-bb.org-env" +RDEPENDS:${PN}:append:pocketbeagle2 = " u-boot-bb.org-env" +RDEPENDS:${PN}:append:beaglebone-ai64 = " u-boot-bb.org-env" inherit systemd @@ -13,9 +20,19 @@ SYSTEMD_SERVICE:${PN}-grow-data-part = "rauc-grow-data-partition.service" PACKAGES += "rauc-grow-data-part" -RDEPENDS:${PN}-grow-data-part += "parted" +RDEPENDS:${PN}-grow-data-part += "parted e2fsprogs-resize2fs gptfdisk" + +DATADEV:beaglebone-yocto = "mmcblk0" +DATADEV:beaglebone = "mmcblk0" +DATADEV:pocketbeagle2 = "mmcblk1" +DATADEV:beaglebone-ai64 = "mmcblk1" do_install:append() { + sed -i "s/@@DATADEV@@/${DATADEV}/g" ${UNPACKDIR}/grow-data-partition.sh + install -d ${D}${systemd_unitdir}/system/ install -m 0644 ${UNPACKDIR}/rauc-grow-data-partition.service ${D}${systemd_unitdir}/system/ + + install -d ${D}/${bindir} + install -m 0755 ${UNPACKDIR}/grow-data-partition.sh ${D}/${bindir} } diff --git a/meta-rauc-beaglebone/recipes-kernel/linux/files/rauc.cfg b/meta-rauc-beaglebone/recipes-kernel/linux/files/rauc.cfg new file mode 100644 index 00000000..84fd168d --- /dev/null +++ b/meta-rauc-beaglebone/recipes-kernel/linux/files/rauc.cfg @@ -0,0 +1,8 @@ +CONFIG_BLK_DEV_DM=y +CONFIG_BLK_DEV_LOOP=y +CONFIG_DM_VERITY=y +CONFIG_SQUASHFS=y +CONFIG_CRYPTO_SHA256=y +# For bundle streaming +CONFIG_BLK_DEV_NBD=y + diff --git a/meta-rauc-beaglebone/recipes-kernel/linux/linux-bb.org_%.bbappend b/meta-rauc-beaglebone/recipes-kernel/linux/linux-bb.org_%.bbappend new file mode 100644 index 00000000..22c39c80 --- /dev/null +++ b/meta-rauc-beaglebone/recipes-kernel/linux/linux-bb.org_%.bbappend @@ -0,0 +1,5 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/files:" + +SRC_URI += "file://rauc.cfg" + +KERNEL_CONFIG_FRAGMENTS += "${UNPACKDIR}/rauc.cfg" diff --git a/meta-rauc-beaglebone/wic/sdimage-2part-efi-dual.wks.in b/meta-rauc-beaglebone/wic/sdimage-2part-efi-dual.wks.in new file mode 100644 index 00000000..a9c8f25c --- /dev/null +++ b/meta-rauc-beaglebone/wic/sdimage-2part-efi-dual.wks.in @@ -0,0 +1,10 @@ +# short-description: Create SD card image with A/B partitions and EFI support +# long-description: Creates a partitioned SD card image for TI platforms that +# supports EFI. Boot files are located in the first vfat partition with extra +# reserved space. We cannot use a GPT here. + +bootloader --timeout=3 --append="rootfstype=ext4 ${TI_WKS_BOOTLOADER_APPEND}" +part --source bootimg-efi --sourceparams="loader=${EFI_PROVIDER}${TI_WKS_INITRAMFS}" --fstype=vfat --label boot --active --align 1024 --use-uuid --fixed-size 128M +part / --source rootfs --fstype=ext4 --label root_A --align 1024 --use-uuid +part / --source rootfs --fstype=ext4 --label root_B --align 1024 --use-uuid +part /data --fixed-size 100M --fstype=ext4 --label data --align 1024