From 62e471b5f9b49902f64287a97c4ae06502908dd5 Mon Sep 17 00:00:00 2001 From: Daniel Rossier Date: Sat, 7 Nov 2026 12:54:38 +0100 Subject: [PATCH 01/12] musl-toolchain: move to musl 1.2.6 with the 2026 CVE patches The pinned musl-cross-make built musl 1.2.5, which is affected by CVE-2026-107891 (regcomp integer overflows, out-of-bounds heap writes on an untrusted regex), CVE-2026-40200 (qsort stack overflow on 32-bit archs) and CVE-2026-6042 (iconv GB18030 denial of service). There is no musl 1.2.7 yet: the fix is 1.2.6 plus the upstream patches, which musl-cross-make 5e8042e carries. Moving SRCREV alone changes nothing on an existing tree: stamps are not hashed, do_build skips as soon as a compiler is installed, and the per-target build directory still links to the old sources. Bump PR to refetch, and record the SRCREV next to the toolchain so that each arch rebuilds once. The applications are statically linked and the build does not track libc.a, so usr-so3 now wipes its build directory when that record changes, or they would keep the vulnerable libc. Built on virt64 and virt32 from an existing tree, booted to the shell on virt64. --- .github/workflows/build.yml | 2 +- .../recipes-toolchain/musl/files/config.mak | 3 +- .../musl/musl-toolchain_1.0.bb | 29 +++++++++++++------ build/meta-usr/recipes-usr/so3/usr-so3_1.0.bb | 10 +++++++ 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4551a110b1..b717d82dba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,7 +42,7 @@ jobs: build.sh -x usr-so3 || { rc=$? echo "=== build failed (rc=$rc); tail of musl-toolchain do_build log ===" - tail -n 120 build/tmp/work/musl-toolchain-1.0-r0/temp/log.do_build* 2>/dev/null || true + tail -n 120 build/tmp/work/musl-toolchain-1.0-r*/temp/log.do_build* 2>/dev/null || true exit $rc } ' diff --git a/build/meta-toolchain/recipes-toolchain/musl/files/config.mak b/build/meta-toolchain/recipes-toolchain/musl/files/config.mak index 35971340ef..039b89465d 100644 --- a/build/meta-toolchain/recipes-toolchain/musl/files/config.mak +++ b/build/meta-toolchain/recipes-toolchain/musl/files/config.mak @@ -26,8 +26,7 @@ DL_CMD = wget -c --tries=5 --waitretry=10 --timeout=30 -O # helps. Fetch it from the MacPorts distfiles mirror, which carries the exact # upstream tarball. musl-cross-make checks every download against # hashes/.sha1, so a mirror serving anything else fails the build loudly -# rather than silently building something different (verified: the mirrored -# musl-1.2.5.tar.gz matches hashes/musl-1.2.5.tar.gz.sha1). +# rather than silently building something different. MUSL_SITE = https://distfiles.macports.org/musl BINUTILS_VER = 2.44 diff --git a/build/meta-toolchain/recipes-toolchain/musl/musl-toolchain_1.0.bb b/build/meta-toolchain/recipes-toolchain/musl/musl-toolchain_1.0.bb index d477f63afc..e2043db1a3 100644 --- a/build/meta-toolchain/recipes-toolchain/musl/musl-toolchain_1.0.bb +++ b/build/meta-toolchain/recipes-toolchain/musl/musl-toolchain_1.0.bb @@ -7,13 +7,15 @@ configured platform CPU (local.conf) is built." LICENSE = "GPLv2 & MIT" # Release and version -PR = "r0" +PR = "r1" PV = "1.0" -# musl-cross-make pinned commit (was GIT_COMMIT=3635262 in the old -# toolchains/build-toolchain.sh). +# musl-cross-make pinned commit. It selects the musl release (MUSL_VER) +# and carries the security patches in patches/musl-/. Bump PR along +# with SRCREV: stamps are not hashed, only PR makes existing trees refetch. + SRC_URI = "git://github.com/richfelker/musl-cross-make;protocol=https;nobranch=1" -SRCREV = "3635262e4524c991552789af6f36211a335a77b3" +SRCREV = "5e8042e63de29f8473fc3b0b831a587ba284e1a8" # The common config.mak shipped alongside this recipe. FILESPATH:prepend = "${THISDIR}/files:" @@ -28,6 +30,7 @@ SRC_URI += "file://config.mak" # (IB_MUSL_TOOLCHAIN_DIR is defined in local.conf). IB_TARGET = "${IB_MUSL_TOOLCHAIN_DIR}/musl-cross-make" IB_MUSL_OUTPUT = "${IB_MUSL_TOOLCHAIN_DIR}/${IB_MUSL_TARGET}" +IB_MUSL_STAMP = "${IB_MUSL_OUTPUT}/.ib_srcrev" do_configure[nostamp] = "1" do_configure () { @@ -42,19 +45,27 @@ do_configure () { # do_configure is nostamp (it re-pins TARGET/OUTPUT in config.mak per arch), # which forces this do_build to re-run on every build that depends on # musl-toolchain:do_build (e.g. `build.sh -x usr-so3`). Guard against that: -# if the compiler for the current IB_MUSL_TARGET is already installed, skip -# the (very long) binutils/gcc/musl build. A different arch yields a different -# IB_MUSL_OUTPUT path, so it still builds; `do_clean` wipes the output to force -# a rebuild. +# if the compiler for the current IB_MUSL_TARGET is already installed from +# this SRCREV, skip the (very long) binutils/gcc/musl build. A different arch +# yields a different IB_MUSL_OUTPUT path, so it still builds; `do_clean` wipes +# the output to force a rebuild. + do_build () { - if [ -x "${IB_MUSL_OUTPUT}/bin/${IB_MUSL_TARGET}-gcc" ]; then + if [ -x "${IB_MUSL_OUTPUT}/bin/${IB_MUSL_TARGET}-gcc" ] && \ + [ "$(cat ${IB_MUSL_STAMP} 2>/dev/null)" = "${SRCREV}" ]; then echo "musl cross toolchain '${IB_MUSL_TARGET}' already built — skipping." else echo "Building musl cross toolchain '${IB_MUSL_TARGET}' — this downloads and compiles binutils/gcc/musl, expect a long first build..." cd ${IB_TARGET} + + # The per-target build dir links to the sources of the previous musl. + + rm -rf ${IB_MUSL_OUTPUT} build/local/${IB_MUSL_TARGET} + make -j${CORES} make install + echo "${SRCREV}" > ${IB_MUSL_STAMP} fi } diff --git a/build/meta-usr/recipes-usr/so3/usr-so3_1.0.bb b/build/meta-usr/recipes-usr/so3/usr-so3_1.0.bb index f2cb159422..edefd80a5f 100644 --- a/build/meta-usr/recipes-usr/so3/usr-so3_1.0.bb +++ b/build/meta-usr/recipes-usr/so3/usr-so3_1.0.bb @@ -48,6 +48,16 @@ do_build[depends] += "musl-toolchain:do_build" do_build:prepend () { export PATH="${IB_MUSL_TOOLCHAIN_DIR}/${IB_MUSL_TARGET}/bin:$PATH" + # The binaries are static and the build does not track libc.a, so an + # incremental build would keep the libc of the previous toolchain. + + _tc_rev="$(cat ${IB_MUSL_TOOLCHAIN_DIR}/${IB_MUSL_TARGET}/.ib_srcrev 2>/dev/null || true)" + _tc_marker="${IB_TARGET}/.ib_last_toolchain" + if [ "$(cat $_tc_marker 2>/dev/null || true)" != "$_tc_rev" ]; then + echo "SO3 usr toolchain changed; wiping build/" + rm -rf ${IB_TARGET}/build + fi + echo "$_tc_rev" > "$_tc_marker" } # Make sure so3 has been installed correctly to fetch other components if required From d698b1dac9db1782ccce802eb4ba1df82ab1e9a5 Mon Sep 17 00:00:00 2001 From: Daniel Rossier Date: Sat, 14 Nov 2026 14:36:21 +0100 Subject: [PATCH 02/12] updiff: exclude the generated kernel and U-Boot sources Both trees are built in place, and their builds leave generated sources next to the real ones that the generic excludes do not cover: updiff turned a plain kernel or U-Boot build into a series of bogus patches. Taken from Infrabase 1.1.0. --- build/meta-linux/classes/linux.bbclass | 13 +++++++++++++ build/meta-uboot/classes/uboot.bbclass | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/build/meta-linux/classes/linux.bbclass b/build/meta-linux/classes/linux.bbclass index 5548202b44..0c3fcbaab0 100644 --- a/build/meta-linux/classes/linux.bbclass +++ b/build/meta-linux/classes/linux.bbclass @@ -5,6 +5,19 @@ IB_LINUX_PATH = "${IB_DIR}/linux/linux" +# The kernel is built in place, and kbuild leaves generated sources next to the +# real ones that patch.bbclass's generic excludes do not cover; without these, +# updiff turns a plain `build.sh linux` into two dozen bogus patches. All are +# absent from the upstream tarball (drivers/s390/char/defkeymap.c aside, which +# matches by basename only and is irrelevant to the ARM targets of this tree). +IB_UPDIFF_EXCLUDE ??= "dtbs-list vdso.lds *.asn1.c *.asn1.h *.dtb.S \ + scsi_devinfo_tbl.c consolemap_deftbl.c defkeymap.c logo_*.c \ + utsversion-tmp.h bounds.s crc32table.h crc64table.h oid_registry_data.c \ + vdso32.lds hyp.lds hyp-reloc.S hyp-constants.s hyp_constants.h \ + sha256-core.S sha512-core.S rq-offsets.s \ + ucs_fallback_table.h ucs_recompose_table.h ucs_width_table.h \ + *.gen.S shipped-certs.c" + def __do_clean(d): diff --git a/build/meta-uboot/classes/uboot.bbclass b/build/meta-uboot/classes/uboot.bbclass index 91d8531f5a..a37346c627 100644 --- a/build/meta-uboot/classes/uboot.bbclass +++ b/build/meta-uboot/classes/uboot.bbclass @@ -4,4 +4,14 @@ IB_UBOOT_PATH = "${IB_DIR}/u-boot" +# Generated by the U-Boot build next to the real sources, so updiff would take +# them for new files. The entries named by path have a real namesake in the +# tree: arch/*/include/asm/config.h, arch/*/u-boot-spl.lds, arch/u-boot-elf.lds. + +IB_UPDIFF_EXCLUDE ??= "u_boot_logo.S bmp_logo.h bmp_logo_data.h \ + helloworld_efi.S generated_defconfig include/config.h \ + image.map keep-syms-lto.c libfdt.i libfdt.py libfdt_wrap.c \ + nxp.imx8mimage.cfg.section.* flash.bin.inputs.sha256 \ + spl/u-boot-spl.* /u-boot-elf.lds" + From 0ca2d277c16beb6cb26d118fd1b9483ad031f36c Mon Sep 17 00:00:00 2001 From: Daniel Rossier Date: Sat, 14 Nov 2026 14:36:21 +0100 Subject: [PATCH 03/12] buildroot: skip the make while nothing it consumes has changed make re-runs target-finalize and the image steps every time, and regenerates rootfs.cpio. Hash the platform, the .config, the attach manifest and the board tree, and skip the make while they are unchanged. build.sh -c buildroot still forces it. Taken from Infrabase 1.1.0. --- .../buildroot/buildroot_2024.11.bb | 60 ++++++++++++++++++- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/build/meta-rootfs/recipes-rootfs/buildroot/buildroot_2024.11.bb b/build/meta-rootfs/recipes-rootfs/buildroot/buildroot_2024.11.bb index 57d48093d5..d70b7f7af8 100644 --- a/build/meta-rootfs/recipes-rootfs/buildroot/buildroot_2024.11.bb +++ b/build/meta-rootfs/recipes-rootfs/buildroot/buildroot_2024.11.bb @@ -83,13 +83,52 @@ do_build[nostamp] = "1" do_build[depends] += "rootfs-linux:do_attach_infrabase" +# Content-hash guard, same pattern as bsp-linux:do_prepare_initrd. +# +# The task stays nostamp, since bitbake cannot see what buildroot consumes. +# But make is not free when nothing changed: buildroot re-runs target-finalize +# and the image steps every time, and regenerates rootfs.cpio, discarding +# anything injected into it after the build. So hash what buildroot consumes +# and skip the make while it is unchanged: +# +# IB_PLATFORM a platform switch always rebuilds +# .config the resolved configuration +# buildroot.attach.sha256 the manifest standing for the patched source +# board/ the BR2_EXTERNAL tree, both its git-tracked source +# and the working copy rootfs-linux attaches, minus +# the artefacts the build writes there +# +# Content rather than mtimes: the attach and the mount/umount cycle rewrite +# files without changing them. `build.sh -c buildroot` still forces a make. + +IB_BUILDROOT_GUARD = "${WORKDIR}/buildroot_inputs.sha256" +IB_BUILDROOT_SRC_BOARD := "${THISDIR}/../linux/files/board" + +# find -L: ${IB_ROOTFS_PATH}/board is a symlink, which find would not enter. +# Each element ends in "|| echo ": under set -e one failing command +# would abort the group and turn the hash into a constant that never changes. + +buildroot_hash_tree() { + find -L "$1" -type f \ + ! -name '*.cpio' ! -name '*.cpio.gz' ! -name '*.srchash' \ + ! -name '*.backup' ! -name '*.sha256' \ + -exec sha256sum {} + 2>/dev/null | sort || echo "no-tree:$1" +} + +buildroot_inputs_hash() { + { echo "${IB_PLATFORM}" + cat "${IB_ROOTFS_PATH}/.config" 2>/dev/null || echo "no-config" + cat "${IB_ROOTFS_PATH}/buildroot.attach.sha256" 2>/dev/null || echo "no-manifest" + buildroot_hash_tree "${IB_BUILDROOT_SRC_BOARD}" + buildroot_hash_tree "${IB_ROOTFS_PATH}/board" + } | sha256sum | cut -d' ' -f1 +} + # For convenience, images/ also shows the platform's static initrd.cpio next # to rootfs.cpio. The link targets the git-tracked source, the file that # mount.sh -i / umount.sh -i edit and the next build embeds, so it is never # stale. It goes away with images/. -IB_BUILDROOT_SRC_BOARD := "${THISDIR}/../linux/files/board" - buildroot_link_initrd() { if [ -f ${IB_BUILDROOT_SRC_BOARD}/${IB_PLATFORM}/initrd.cpio ]; then ln -sfnr ${IB_BUILDROOT_SRC_BOARD}/${IB_PLATFORM}/initrd.cpio \ @@ -100,10 +139,22 @@ buildroot_link_initrd() { do_build () { bbnote "Building buildroot based rootfs..." + if [ -f "${IB_BUILDROOT_GUARD}" ] && \ + [ "$(cat ${IB_BUILDROOT_GUARD})" = "$(buildroot_inputs_hash)" ] && \ + [ -f "${IB_ROOTFS_PATH}/board/${IB_PLATFORM}/rootfs.cpio" ]; then + bbplain "buildroot: inputs unchanged, rootfs.cpio present — skipping (build.sh -c buildroot forces it)" + return 0 + fi + cd ${IB_TARGET} make O=${IB_ROOTFS_PATH} BR2_DL_DIR="${IB_BUILDROOT_DL_DIR}" --no-print-directory buildroot_link_initrd + + # Recorded only after a successful make, and re-hashed since the make may + # touch its own inputs (.config normalisation, for one). + + buildroot_inputs_hash > "${IB_BUILDROOT_GUARD}" } do_clean[nostamp] = "1" @@ -119,6 +170,11 @@ do_clean () { rm -rf ${IB_ROOTFS_PATH}/staging rm -f ${TMPDIR}/stamps/buildroot* + + # The guard goes with the output it vouches for: board//rootfs.cpio + # survives this task, so a kept guard would skip the make next time. + + rm -f ${IB_BUILDROOT_GUARD} } addtask do_clean From 99784f951bf2398e329456c8f9c27a89a35c6eae Mon Sep 17 00:00:00 2001 From: Daniel Rossier Date: Sat, 14 Nov 2026 14:36:21 +0100 Subject: [PATCH 04/12] linux: build the 32-bit kernels and modules with ARCH=arm The kernel Makefile patch pins ARCH=arm64 and the aarch64 toolchain, which is wrong for virt32. Command-line assignments beat Makefile ones, so pass both on 32-bit, for the kernel and for the modules usr-linux builds against it. Taken from Infrabase 1.1.0. --- .../recipes-linux/linux/linux_6.12-rpi4.bb | 18 ++++++++++++++--- .../recipes-linux/linux/linux_6.12.bb | 20 ++++++++++++------- .../recipes-usr/linux/usr-linux_1.0.bb | 11 +++++++--- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/build/meta-linux/recipes-linux/linux/linux_6.12-rpi4.bb b/build/meta-linux/recipes-linux/linux/linux_6.12-rpi4.bb index ec09418e74..1c38b26699 100644 --- a/build/meta-linux/recipes-linux/linux/linux_6.12-rpi4.bb +++ b/build/meta-linux/recipes-linux/linux/linux_6.12-rpi4.bb @@ -24,13 +24,18 @@ FILESPATH:prepend = "${THISDIR}/files/0001-${PF}:" require files/0001-${PF}-patches.inc require linux-deploy.inc +# The fork's Makefile patch pins ARCH ?= arm64 (weak): right for rpi4_64, +# overridden from the command line for the 32-bit rpi4 — same scheme as +# linux_6.12.bb. +IB_KMAKE_ARGS = "${@'ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-' if (d.getVar('IB_PLAT_CPU') or '') == 'arm' else ''}" + # Where the working directory will be placed in infrabase root dir IB_TARGET = "${IB_LINUX_PATH}" do_configure[nostamp] = "1" do_configure () { cd ${IB_TARGET} - make ${IB_CONFIG} + make ${IB_KMAKE_ARGS} ${IB_CONFIG} } do_build () { @@ -38,10 +43,17 @@ do_build () { cd ${IB_TARGET} - make -j${CORES} Image + make ${IB_KMAKE_ARGS} -j${CORES} Image + + # On 32-bit also produce the self-relocating zImage: a raw arm32 Image is + # position-dependent and any load-address mistake boots to dead silence, + # while the zImage decompressor places itself (AUTO_ZRELADDR). + if [ "${IB_PLAT_CPU}" = "arm" ]; then + make ${IB_KMAKE_ARGS} -j${CORES} zImage + fi # Compile the device tree files - make dtbs + make ${IB_KMAKE_ARGS} dtbs } diff --git a/build/meta-linux/recipes-linux/linux/linux_6.12.bb b/build/meta-linux/recipes-linux/linux/linux_6.12.bb index 9291ced10b..e42e41e4e6 100644 --- a/build/meta-linux/recipes-linux/linux/linux_6.12.bb +++ b/build/meta-linux/recipes-linux/linux/linux_6.12.bb @@ -27,29 +27,35 @@ require linux-deploy.inc # Where the working directory will be placed in infrabase root dir IB_TARGET = "${IB_LINUX_PATH}" +# The 0011 Makefile patch pins ARCH=arm64/aarch64-none-linux-gnu- in the kernel +# top Makefile — right for the 64-bit platforms, wrong for virt32. Command-line +# assignments beat Makefile ones, so pass both explicitly on 32-bit; elsewhere +# the pinned values keep applying and nothing changes. +IB_KMAKE_ARGS = "${@'ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-' if (d.getVar('IB_PLAT_CPU') or '') == 'arm' else ''}" + do_configure[nostamp] = "1" do_configure () { cd ${IB_TARGET} - make ${IB_CONFIG} + make ${IB_KMAKE_ARGS} ${IB_CONFIG} } do_build () { echo "Building Linux with ${CORES} cores..." - + cd ${IB_TARGET} - + if [ "${IB_PLATFORM}" = "x86-qemu" -o "${IB_PLATFORM}" = "x86-pc" ]; then make -j${CORES} bzImage else - + if [ "${IB_PLATFORM}" = "bbb" ]; then make -j${CORES} zImage else - make -j${CORES} Image + make ${IB_KMAKE_ARGS} -j${CORES} Image fi - + # Compile the device tree files - make dtbs + make ${IB_KMAKE_ARGS} dtbs fi } diff --git a/build/meta-usr/recipes-usr/linux/usr-linux_1.0.bb b/build/meta-usr/recipes-usr/linux/usr-linux_1.0.bb index e38becdb4f..675f61cdb7 100644 --- a/build/meta-usr/recipes-usr/linux/usr-linux_1.0.bb +++ b/build/meta-usr/recipes-usr/linux/usr-linux_1.0.bb @@ -158,6 +158,11 @@ python do_deploy() { addtask do_deploy +# The kernel top Makefile is patched with ARCH=arm64/aarch64 pinned (0011); +# right for the 64-bit platforms, wrong for virt32. Command-line assignments +# beat Makefile ones — same fix as in linux_6.12.bb. +IB_KMAKE_ARGS = "${@'ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-' if (d.getVar('IB_PLAT_CPU') or '') == 'arm' else ''}" + # Build extra components which is not in src/ directory like modules do_build:prepend () { @@ -165,11 +170,11 @@ do_build:prepend () { if [ ! -f ${IB_LINUX_PATH}/Module.symvers ]; then echo "Generating Module.symvers..." ; - make -j${CORES} -C ${IB_LINUX_PATH} modules ; - make INSTALL_MOD_PATH=${IB_ROOTFS_PATH}/target -C ${IB_LINUX_PATH} modules_install ; \ + make ${IB_KMAKE_ARGS} -j${CORES} -C ${IB_LINUX_PATH} modules ; + make ${IB_KMAKE_ARGS} INSTALL_MOD_PATH=${IB_ROOTFS_PATH}/target -C ${IB_LINUX_PATH} modules_install ; \ fi - make -C ${IB_LINUX_PATH} M=${IB_TARGET}/src/modules modules IB_PLATFORM=${IB_PLATFORM} + make ${IB_KMAKE_ARGS} -C ${IB_LINUX_PATH} M=${IB_TARGET}/src/modules modules IB_PLATFORM=${IB_PLATFORM} } # Installing usr apps mean to move the binary and all files which need to From e5b63ef2c12d380d80ef04474dac62d646aec16c Mon Sep 17 00:00:00 2001 From: Daniel Rossier Date: Sat, 14 Nov 2026 14:36:21 +0100 Subject: [PATCH 05/12] filesystem: create filesystem/ in the tree on a fresh checkout The work symlink and the storage image link went into a filesystem/ directory nothing created. Taken from Infrabase 1.1.0. --- build/meta-filesystem/classes/filesystem.bbclass | 1 + build/meta-filesystem/classes/fs_arm_common.bbclass | 5 +++-- build/meta-filesystem/classes/fs_verdin-imx8mp.bbclass | 1 + build/meta-filesystem/classes/fs_x86-qemu.bbclass | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/build/meta-filesystem/classes/filesystem.bbclass b/build/meta-filesystem/classes/filesystem.bbclass index 3b0af785b7..f76ae13320 100644 --- a/build/meta-filesystem/classes/filesystem.bbclass +++ b/build/meta-filesystem/classes/filesystem.bbclass @@ -63,6 +63,7 @@ def __do_fs_init_storage(d): # Finally create a symlink to the workdir to be able # to mount/umount more conveniently target_link = os.path.join(d.getVar('IB_DIR'), "filesystem/work") + os.makedirs(os.path.dirname(target_link), exist_ok=True) # Replace whatever sits at filesystem/work with a fresh symlink. # diff --git a/build/meta-filesystem/classes/fs_arm_common.bbclass b/build/meta-filesystem/classes/fs_arm_common.bbclass index 644d82b236..6c304d346a 100644 --- a/build/meta-filesystem/classes/fs_arm_common.bbclass +++ b/build/meta-filesystem/classes/fs_arm_common.bbclass @@ -3,7 +3,7 @@ # Storage layout for ARM platforms (sdcard.img, IB_ROOTFS_SIZE total). # # Two partitions: -# - p1, FAT, 128 MiB — boot partition +# - p1, FAT, IB_BOOT_PARTITION_SIZE (256 MiB by default) — boot partition # uEnv.txt, AVZ ITB (small), legacy firmware artefacts # - p2, ext4, ~rest of IB_ROOTFS_SIZE — rootfs partition (label "rootfs1") # / — Linux rootfs proper (deployed by rootfs-linux). @@ -63,7 +63,7 @@ def __platform_init_storage(d): print("Linking the storage image", IB_DIR) - os.makedirs(os.path.join(WORKDIR, "filesystem"), exist_ok=True) + os.makedirs(os.path.join(IB_DIR, "filesystem"), exist_ok=True) target_link = os.path.join(IB_DIR, f"filesystem/{store_filename}") source_link = store_path @@ -195,6 +195,7 @@ def __do_fs_init_storage(d): # Finally create a symlink to the workdir to be able # to mount/umount more conveniently target_link = os.path.join(d.getVar('IB_DIR'), "filesystem/work") + os.makedirs(os.path.dirname(target_link), exist_ok=True) # Check if the symbolic link already exists if os.path.islink(target_link): diff --git a/build/meta-filesystem/classes/fs_verdin-imx8mp.bbclass b/build/meta-filesystem/classes/fs_verdin-imx8mp.bbclass index 80f274e9eb..a576fb9e77 100644 --- a/build/meta-filesystem/classes/fs_verdin-imx8mp.bbclass +++ b/build/meta-filesystem/classes/fs_verdin-imx8mp.bbclass @@ -73,6 +73,7 @@ def __do_fs_init_storage(d): # Finally create a symlink to the workdir to be able # to mount/umount more conveniently target_link = os.path.join(d.getVar('IB_DIR'), "filesystem/work") + os.makedirs(os.path.dirname(target_link), exist_ok=True) # Check if the symbolic link already exists if os.path.islink(target_link): diff --git a/build/meta-filesystem/classes/fs_x86-qemu.bbclass b/build/meta-filesystem/classes/fs_x86-qemu.bbclass index 8d35e4a36f..ead0466f19 100644 --- a/build/meta-filesystem/classes/fs_x86-qemu.bbclass +++ b/build/meta-filesystem/classes/fs_x86-qemu.bbclass @@ -41,7 +41,7 @@ def do_filesystem_platform_init_storage(d): print("Linking the storage image", IB_DIR) - os.makedirs(os.path.join(WORKDIR, "filesystem"), exist_ok=True) + os.makedirs(os.path.join(IB_DIR, "filesystem"), exist_ok=True) target_link = os.path.join(IB_DIR, "filesystem/"+store_filename) source_link = os.path.join(WORKDIR, store_filename) From fd0d8dc15176dc8d25349f53b5e8e90abce1a05a Mon Sep 17 00:00:00 2001 From: Daniel Rossier Date: Sat, 14 Nov 2026 14:36:21 +0100 Subject: [PATCH 06/12] build: clear stale ITBs off p1, and order the rootfs deploy after its build Switching between the standalone and the AVZ boot shapes left the other shape's ITBs on the boot partition; with Linux ITBs those alone fill it. __deploy_arm_common now removes them first. rootfs-linux:do_deploy depends on the rootfs generator again. Nothing else orders it after buildroot, so cpio could read a rootfs.cpio still being written and abort with exit 2. The buildroot content guard makes the extra dependency free on an unchanged tree. Both taken from Infrabase 1.1.0. --- .../recipes-bsp/bsp/files/bsp_arm_common.inc | 25 ++++++++++++++++++ .../recipes-rootfs/linux/rootfs-linux_1.0.bb | 26 +++++++++++++------ 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/build/meta-bsp/recipes-bsp/bsp/files/bsp_arm_common.inc b/build/meta-bsp/recipes-bsp/bsp/files/bsp_arm_common.inc index 74ee6ac3aa..6a09605592 100644 --- a/build/meta-bsp/recipes-bsp/bsp/files/bsp_arm_common.inc +++ b/build/meta-bsp/recipes-bsp/bsp/files/bsp_arm_common.inc @@ -10,6 +10,27 @@ # from IB_TARGET_ITS: _so3_guest.itb. # * Single-ITB bootm (any other ITS): the standalone SO3 / Linux image. +# ITBs the previous deploy may have left on p1. The two boot shapes use +# different names, so switching between them (IB_HYPERVISOR none <-> avz) +# otherwise accumulates both sets: on a Linux BSP each ITB carries a kernel +# plus an initramfs and runs to tens of megabytes, so the leftovers alone +# fill the FAT boot partition and the copy below fails with a bare +# "cp: returned exit status 1" — or, worse, succeeds against a partially +# written file. Cleaning first also means p1 always describes exactly one +# boot shape, which is what someone inspecting the card expects to see. + +def __clean_stale_itbs(p1, plat, keep): + import os + + for name in (f"{plat}.itb", f"{plat}_avz.itb", f"{plat}_guest.itb"): + if name in keep: + continue + path = os.path.join(p1, name) + if os.path.isfile(path): + bb.note(f"removing stale {name} from the boot partition") + os.remove(path) + + def __deploy_arm_common(d): import os import subprocess @@ -32,6 +53,8 @@ def __deploy_arm_common(d): if not os.path.isfile(f): bb.fatal(f + " is missing ...") + __clean_stale_itbs(p1, plat, keep=(f"{plat}_avz.itb", f"{plat}_guest.itb")) + subprocess.run(['cp', avz_uenv, p1 + "/uEnv.txt"], check=True) subprocess.run(['cp', avz_itb, f"{p1}/{plat}_avz.itb"], check=True) subprocess.run(['cp', guest_itb, f"{p1}/{plat}_guest.itb"], check=True) @@ -48,6 +71,8 @@ def __deploy_arm_common(d): if not os.path.isfile(itb_path): bb.fatal(itb_path + " is missing ...") + __clean_stale_itbs(p1, plat, keep=(f"{plat}.itb",)) + # The target ITB loaded by U-boot has the name of the target platform subprocess.run(['cp', itb_path, p1 + "/" + plat + ".itb"]) diff --git a/build/meta-rootfs/recipes-rootfs/linux/rootfs-linux_1.0.bb b/build/meta-rootfs/recipes-rootfs/linux/rootfs-linux_1.0.bb index c4542fabe3..c8595a305b 100644 --- a/build/meta-rootfs/recipes-rootfs/linux/rootfs-linux_1.0.bb +++ b/build/meta-rootfs/recipes-rootfs/linux/rootfs-linux_1.0.bb @@ -22,14 +22,24 @@ do_configure[noexec] = "1" do_build[depends] = "${IB_ROOTFS_METHOD}:do_build" do_build[depends] += "linux:do_build" -# do_deploy is a pure DEPLOY step: it extracts the already-built rootfs.cpio -# onto p2 (usr apps already inside when IB_RAMFS_SOURCE = "rootfs", copied -# on top by usr-linux:do_deploy otherwise). It must -# NOT pull ${IB_ROOTFS_METHOD}:do_build — that would rebuild buildroot on -# every `deploy.sh`. The workflow is edit -> build.sh (produces rootfs.cpio) -# -> deploy.sh; a deploy with no prior build fails clearly in -# __do_rootfs_mount (missing rootfs.cpio) rather than silently rebuilding. -do_deploy[depends] += "filesystem:do_fs_check" +# do_deploy extracts rootfs.cpio, copies it onto p2 and repacks it. The usr +# apps are either already in rootfs.cpio (IB_RAMFS_SOURCE = "rootfs") or +# copied on top afterwards by usr-linux:do_deploy. +# +# It DOES depend on ${IB_ROOTFS_METHOD}:do_build, and that dependency is +# load-bearing rather than a leftover: nothing else orders this task after +# the rootfs generator, and usr-linux:do_deploy pulls it into the *build* +# graph too (usr-linux:do_deploy[depends] = rootfs-linux:do_deploy). Without +# it, bitbake is free to run this task while buildroot is still writing +# board//rootfs.cpio, and `cpio -id` then reads a truncated archive and +# aborts with exit status 2 — an intermittent build failure whose message +# says nothing about a race. It also covers the fresh-checkout case, where +# there is no cached cpio at all. +# +# The cost is one `make` in an already-built buildroot on a standalone +# deploy (do_build is nostamp), which is a no-op in practice — cheap next to +# a racy deploy. Do not "simplify" this dependency away. +do_deploy[depends] += "filesystem:do_fs_check ${IB_ROOTFS_METHOD}:do_build" do_build[nostamp] = "1" do_build () { From 9a4442f55b567dd5310d572e0140e04d19c85396 Mon Sep 17 00:00:00 2001 From: Daniel Rossier Date: Sat, 14 Nov 2026 14:36:21 +0100 Subject: [PATCH 07/12] bsp-linux: say which variable selects the ITS and what is available An unset IB_TARGET_ITS and a missing template are now two messages, both naming the variable and listing the templates of the platform. virt32.its is standalone Linux, like virt64.its, and neither declares a compression for the ramdisk, which only earned a warning at boot. Taken from Infrabase 1.1.0. --- .../recipes-bsp/linux/bsp-linux_1.0.bb | 39 +++++++++- .../recipes-bsp/linux/files/its/virt32.its | 77 +++++++++---------- .../recipes-bsp/linux/files/its/virt64.its | 8 +- 3 files changed, 78 insertions(+), 46 deletions(-) diff --git a/build/meta-bsp/recipes-bsp/linux/bsp-linux_1.0.bb b/build/meta-bsp/recipes-bsp/linux/bsp-linux_1.0.bb index 81d69d705f..252f8efa95 100644 --- a/build/meta-bsp/recipes-bsp/linux/bsp-linux_1.0.bb +++ b/build/meta-bsp/recipes-bsp/linux/bsp-linux_1.0.bb @@ -51,11 +51,37 @@ do_itb () { # ITS are rendered into IB_ITB_PATH by the shared do_render_its (before # do_itb); this task only mkimage's them. The boot shape is selected by - # the ITS name (mirroring bsp-so3 and __deploy_arm_common), NOT by - # IB_BOOT_CHAIN — AVZ boots fine on the bare U-Boot chain (EL2 via - # QEMU virtualization=on), ATF/OP-TEE is an independent choice. + # the ITS name (as in __deploy_arm_common), NOT by IB_BOOT_CHAIN — AVZ + # boots fine on the bare U-Boot chain (EL2 via QEMU virtualization=on), + # and a secure world is equally useful under a plain Linux. That is the + # whole point of keeping IB_HYPERVISOR and IB_BOOT_CHAIN orthogonal. + # + # Two failures, two messages. "IB_TARGET_ITS is unset" and "its template + # is missing" are different problems, and the former is the common one: + # every IB_TARGET_ITS:linux: line in local.conf commented out is + # enough, and the message has to name the variable and its values. + # Plain $its_avail, no braces: bitbake expands every ${...} at parse + # time, so a braced shell variable would go through its expander first. + # The ${IB_GUEST_SUFFIX} template is dropped from the list: it is + # the guest ITB auto-derived from a *_avz selection, never something to + # put in local.conf. + its_avail=$(cd "${IB_ITS_SRC}" 2>/dev/null && \ + ls -1 ${IB_PLATFORM}.its ${IB_PLATFORM}_*.its 2>/dev/null | \ + sed -e 's/\.its$//' -e '/${IB_GUEST_SUFFIX}$/d' | \ + tr '\n' ' ' | sed 's/ *$//') + [ -n "$its_avail" ] || its_avail="none for this platform" + + if [ -z "${IB_TARGET_ITS}" ]; then + bbfatal "No ITS selected for platform '${IB_PLATFORM}': set" \ + "IB_TARGET_ITS:linux:${IB_PLATFORM} in build/conf/local.conf" \ + "(available: $its_avail)" + fi + if [ ! -f ${IB_ITB_PATH}/${IB_TARGET_ITS}.its ]; then - bbfatal "No corresponding ITS found (${IB_TARGET_ITS})" + bbfatal "ITS '${IB_TARGET_ITS}' selected by" \ + "IB_TARGET_ITS:linux:${IB_PLATFORM} has no template" \ + "${IB_ITS_SRC}/${IB_TARGET_ITS}.its" \ + "(available: $its_avail)" fi mkimage -f ${IB_ITB_PATH}/${IB_TARGET_ITS}.its ${IB_ITB_PATH}/${IB_TARGET_ITS}.itb @@ -238,6 +264,11 @@ python do_deploy_boot() { addtask do_deploy_boot do_clean[depends] = "usr-linux:do_clean rootfs-linux:do_clean linux:do_clean uboot:do_clean" + +# Clean whatever the current axes actually pulled into the build. Gating on +# the chain/hypervisor rather than on the platform keeps `build.sh -c` from +# failing on a platform where atf/optee/avz were never built (their do_clean +# is harmless but the recipes may be skipped by COMPATIBLE_PLATFORM). python () { hyp = d.getVar('IB_HYPERVISOR') or "none" extra = [] diff --git a/build/meta-bsp/recipes-bsp/linux/files/its/virt32.its b/build/meta-bsp/recipes-bsp/linux/files/its/virt32.its index e7ef4ffe9a..0862936cca 100644 --- a/build/meta-bsp/recipes-bsp/linux/files/its/virt32.its +++ b/build/meta-bsp/recipes-bsp/linux/files/its/virt32.its @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Daniel Rossier + * Copyright (C) 2014-2026 Daniel Rossier * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -14,78 +14,73 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * + * Standalone Linux on the virt32 (armv7) QEMU machine, the 32-bit twin of + * virt64.its. This file used to be a third copy of the Linux-on-AVZ ITS + * (virt32_avz.its, which remains the AVZ flavour); the naming now matches + * the virt64 pair: .its = standalone Linux, _avz.its = on AVZ. */ /dts-v1/; / { - description = "Linx running on AVZ in virt32 environment"; + description = "Kernel and rootfs components for virt32 (armv7) environment"; images { - avz { - description = "AVZ Hypervisor (32-bit) Polymorphic SO3"; - data = /incbin/("${IB_AVZ_PATH}/so3.bin"); + linux { + description = "Linux kernel"; + data = /incbin/("${IB_LINUX_PATH}/arch/arm/boot/Image"); type = "kernel"; - os = "linux"; arch = "arm"; + os = "linux"; compression = "none"; + + /* + * RAM base 0x40000000 + the arm32 0x8000 text offset: a raw + * (uncompressed) 32-bit Image is not relocatable — unlike the + * arm64 Image, whose header lets U-Boot place it, and unlike a + * zImage. Loading it anywhere else hangs right after + * "Starting kernel ...". + */ load = <0x40008000>; entry = <0x40008000>; }; - avz_dt { - description = "Flattened Device Tree blob"; - data = /incbin/("${IB_AVZ_PATH}/dts/virt32_avz.dtb"); - type = "avz_dt"; - arch = "arm"; - compression = "none"; - load = <0x40f00000>; - }; - - linux { - description = "Linux kernel"; - data = /incbin/("${IB_LINUX_PATH}/linux/arch/arm/boot/Image"); - type = "avz"; - arch = "arm"; - os = "linux"; - compression = "none"; - load = <0x41008000>; - entry = <0x41008000>; - }; - fdt_linux { description = "Linux device tree blob"; - data = /incbin/("${IB_LINUX_PATH}/linux/arch/arm/boot/dts/virt32.dtb"); + data = /incbin/("${IB_LINUX_PATH}/arch/arm/boot/dts/arm/${IB_PLATFORM}.dtb"); type = "flat_dt"; arch = "arm"; compression = "none"; - load = <0x5a000000>; + load = <0x50000000>; }; initrd { description = "Initial rootfs (initrd)"; - data = /incbin/("${IB_ROOTFS_PATH}/board/virt32/initrd.cpio.gz"); + data = /incbin/("${IB_ROOTFS_PATH}/board/${IB_PLATFORM}/initrd.cpio.gz"); type = "ramdisk"; arch = "arm"; - os = "linux"; + os = "linux"; + /* + * "none": U-Boot never decompresses ramdisks (the kernel + * unpacks the gzip'd initramfs itself), and declaring a + * compression here is deprecated — it only earns a WARNING + * at boot. + */ compression = "none"; load = <0x50c00000>; }; }; - - configurations { - default = "conf_linux_avz"; - conf_linux_avz { - description = "Linux/AVZ on virt32"; - kernel = "avz"; - fdt = "fdt_linux"; - loadables = "avz_dt", "linux"; - ramdisk = "initrd"; - }; + configurations { + default = "conf_linux"; + conf_linux { + description = "Linux on virt32"; + kernel = "linux"; + fdt = "fdt_linux"; + ramdisk = "initrd"; + }; }; - }; diff --git a/build/meta-bsp/recipes-bsp/linux/files/its/virt64.its b/build/meta-bsp/recipes-bsp/linux/files/its/virt64.its index e466e888a1..d98dcfe7d7 100644 --- a/build/meta-bsp/recipes-bsp/linux/files/its/virt64.its +++ b/build/meta-bsp/recipes-bsp/linux/files/its/virt64.its @@ -66,7 +66,13 @@ type = "ramdisk"; arch = "arm64"; os = "linux"; - compression = "gzip"; + /* + * "none": U-Boot never decompresses ramdisks (the kernel + * unpacks the gzip'd initramfs itself), and declaring a + * compression here is deprecated — it only earns a WARNING + * at boot. + */ + compression = "none"; load = <0x50c00000>; }; }; From 71a9a146860191b9a530669d74871e5040366b89 Mon Sep 17 00:00:00 2001 From: Daniel Rossier Date: Sat, 14 Nov 2026 14:36:21 +0100 Subject: [PATCH 08/12] uboot: stay at the prompt when no OS has been deployed, and honour the chain on verdin With no uEnv.txt on p1, the bootcmd imported whatever lay at the load address and failed on "run start"; it now says so and stays at the prompt, on QEMU and on the Raspberry Pi. On verdin, flash.bin took TEE=./tee.bin on every chain although the recipe computed TEE_ARG per chain; it now uses it, and the chain is part of the rebuild hash. Taken from Infrabase 1.1.0. --- .../0022-qemu-arm.h.patch | 12 +++++++++-- .../0001-uboot-2022.04-r0/0023-rpi.h.patch | 9 +++++++-- .../recipes-uboot/uboot/uboot_2024.07.bb | 20 +++++++++++-------- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/build/meta-uboot/recipes-uboot/uboot/files/0001-uboot-2022.04-r0/0022-qemu-arm.h.patch b/build/meta-uboot/recipes-uboot/uboot/files/0001-uboot-2022.04-r0/0022-qemu-arm.h.patch index b051e04668..2c092f1434 100644 --- a/build/meta-uboot/recipes-uboot/uboot/files/0001-uboot-2022.04-r0/0022-qemu-arm.h.patch +++ b/build/meta-uboot/recipes-uboot/uboot/files/0001-uboot-2022.04-r0/0022-qemu-arm.h.patch @@ -9,14 +9,22 @@ #define BOOT_TARGET_DEVICES(func) \ BOOT_TARGET_USB(func) \ BOOT_TARGET_SCSI(func) \ -@@ -62,6 +64,10 @@ +@@ -62,6 +64,18 @@ "kernel_addr_r=0x40400000\0" \ "ramdisk_addr_r=0x44000000\0" \ BOOTENV +#endif /* 0 */ + ++/* ++ * uEnv.txt is only on p1 once an OS has been deployed; with U-Boot alone ++ * there is nothing to import or run, so stay at the prompt instead of ++ * importing whatever lies at the load address and failing on "run start". ++ * The import takes an explicit format and length, as on rpi (see rpi.h). ++ */ +#define CONFIG_BOOTCOMMAND \ -+ "load virtio 0 0x40000000 uEnv.txt; env import 0x40000000; run start\0" ++ "if load virtio 0 0x40000000 uEnv.txt; then " \ ++ "env import -t 0x40000000 ${filesize}; run start; " \ ++ "else echo No uEnv.txt on the boot partition, no OS to boot; fi\0" #define CONFIG_SYS_CBSIZE 512 diff --git a/build/meta-uboot/recipes-uboot/uboot/files/0001-uboot-2022.04-r0/0023-rpi.h.patch b/build/meta-uboot/recipes-uboot/uboot/files/0001-uboot-2022.04-r0/0023-rpi.h.patch index 003b175626..2185428663 100644 --- a/build/meta-uboot/recipes-uboot/uboot/files/0001-uboot-2022.04-r0/0023-rpi.h.patch +++ b/build/meta-uboot/recipes-uboot/uboot/files/0001-uboot-2022.04-r0/0023-rpi.h.patch @@ -22,7 +22,7 @@ #define ENV_MEM_LAYOUT_SETTINGS \ "fdt_high=" FDT_HIGH "\0" \ "initrd_high=" INITRD_HIGH "\0" \ -@@ -168,12 +173,30 @@ +@@ -168,12 +173,35 @@ #include @@ -36,9 +36,14 @@ + * errno 22. It only appeared to work on arm64 because the byte after the file + * happened to be NUL. fatload sets ${filesize}, so use it, and state -t rather + * than lean on the "defaulting to text format" warning. ++ * ++ * uEnv.txt is only on p1 once an OS has been deployed; with U-Boot alone ++ * there is nothing to import or run, so stay at the prompt. + */ +#define CONFIG_BOOTCOMMAND \ -+ "fatload mmc 0 0x02000000 uEnv.txt; env import -t 0x02000000 ${filesize}; run start\0\0" \ ++ "if fatload mmc 0 0x02000000 uEnv.txt; then " \ ++ "env import -t 0x02000000 ${filesize}; run start; " \ ++ "else echo No uEnv.txt on the boot partition, no OS to boot; fi\0\0" \ + "bootdelay=0\0" + + diff --git a/build/meta-uboot/recipes-uboot/uboot/uboot_2024.07.bb b/build/meta-uboot/recipes-uboot/uboot/uboot_2024.07.bb index 068f413a2f..718b76b28c 100644 --- a/build/meta-uboot/recipes-uboot/uboot/uboot_2024.07.bb +++ b/build/meta-uboot/recipes-uboot/uboot/uboot_2024.07.bb @@ -29,12 +29,16 @@ IB_TARGET = "${IB_UBOOT_PATH}" # Future enhancement with ATF do_configure[depends] += "atf:do_build" -# Verdin's do_configure shells out to OP-TEE's gen_tee_bin.py and -# consumes tee.elf to produce ./tee.bin embedded in flash.bin. Optee -# must be built (and its source attached at ${IB_OPTEE_PATH}) first. -# Gated on platform via anonymous python because the optee path is -# wrapped in `if [ "${IB_PLATFORM}" = "verdin-imx8mp" ]` below — virt64 -# and other targets don't touch optee here. +# On the secure-world chain, verdin's do_configure shells out to OP-TEE's +# gen_tee_bin.py and consumes tee.elf to produce ./tee.bin, which the SPL +# then embeds in flash.bin. OP-TEE must be built (and its source attached at +# ${IB_OPTEE_PATH}) first. +# +# Gated on BOTH platform and chain: the optee path below is wrapped in +# `if [ "${IB_PLATFORM}" = "verdin-imx8mp" ]` (virt64 assembles its FIP +# elsewhere, in bsp_virt64.inc), and on "atf+uboot" the iMX8MP boots +# SPL -> BL31 -> U-Boot with no secure world at all, so pulling OP-TEE in +# would build a binary nothing consumes. python () { if (d.getVar('IB_PLATFORM') == 'verdin-imx8mp' and d.getVar('IB_CHAIN_HAS_OPTEE')): @@ -108,11 +112,11 @@ do_build () { fi HASH_FILE="flash.bin.inputs.sha256" - CURRENT_HASH="$(sha256sum "$BL31" "$TEE_ELF" 2>/dev/null | sha256sum | cut -d' ' -f1)" + CURRENT_HASH="$(printf '%s\n%s' "${IB_BOOT_CHAIN}" "$HASH_INPUTS" | sha256sum | cut -d' ' -f1)" if [ -f flash.bin ] && [ -f "$HASH_FILE" ] && [ "$(cat $HASH_FILE)" = "$CURRENT_HASH" ]; then echo "U-Boot flash.bin is up to date, skipping rebuild" else - make CROSS_COMPILE=${IB_TOOLCHAIN}- TEE=./tee.bin -j${CORES} + make CROSS_COMPILE=${IB_TOOLCHAIN}- $TEE_ARG -j${CORES} echo "$CURRENT_HASH" > "$HASH_FILE" fi else From 3fa4ecf27b04d7b824e5872ece113ec3d8cfc365 Mon Sep 17 00:00:00 2001 From: Daniel Rossier Date: Sat, 14 Nov 2026 14:36:21 +0100 Subject: [PATCH 09/12] qemu: take Infrabase's virt machine patch, boot ROM included Infrabase 1.1.0 merged the SO3 devices of the virt machine (LAN9118, absolute pointer) with its boot ROM emulation. With that patch the first stage is read off the card again, so the IB_FIRST_STAGE_FROM_CARD override that kept U-Boot on -kernel goes away. --- build/conf/local.conf | 8 - .../recipes-bsp/bsp/files/bsp_virt64.inc | 13 +- .../0001-qemu-8.2.2-r0/0001-virt.c.patch | 258 +++++++++++++++++- .../0001-qemu-8.2.2-r0/0002-virt.h.patch | 18 ++ 4 files changed, 274 insertions(+), 23 deletions(-) diff --git a/build/conf/local.conf b/build/conf/local.conf index da6c406ce7..c4d666646f 100644 --- a/build/conf/local.conf +++ b/build/conf/local.conf @@ -136,14 +136,6 @@ IB_CONFIG:avz:verdin-imx8mp ?= "verdin-imx8mp_avz_defconfig" IB_BOOT_CHAIN ?= "uboot" -# This tree's QEMU virt.c patch carries SO3's own additions (the LAN9118, the -# absolute pointer, PL111/PL050) and has not been regenerated with the -# bootrom-* machine properties infrabase added. Without them QEMU cannot read -# a first stage off the medium, so U-Boot keeps being handed to it as an ELF. -# Set this to "1" once the patch has been regenerated with `bitbake qemu -c -# updiff` against a tree carrying virt_bootrom_setup(). -IB_FIRST_STAGE_FROM_CARD = "0" - # ATF / OP-TEE platform identifiers for QEMU virt (used on the chains that # carry them). Mirrors edgem1's virt64 settings. diff --git a/build/meta-bsp/recipes-bsp/bsp/files/bsp_virt64.inc b/build/meta-bsp/recipes-bsp/bsp/files/bsp_virt64.inc index f185a499c5..e94a701c72 100644 --- a/build/meta-bsp/recipes-bsp/bsp/files/bsp_virt64.inc +++ b/build/meta-bsp/recipes-bsp/bsp/files/bsp_virt64.inc @@ -3,8 +3,7 @@ # virt64 (QEMU armv8) platform glue. The ITB and uEnv.txt are copied onto # the boot partition (p1) by __deploy_arm_common (bsp_arm_common.inc). # __do_platform_boot_chain assembles the optional ATF/OP-TEE firmware -# (flash0.img) — generic and product-agnostic. Any capsule/OSTree -# specifics live in a downstream layer, not here. +# (flash0.img) — generic and product-agnostic. require bsp_arm_common.inc @@ -119,10 +118,8 @@ def __do_platform_boot_chain(d): # MCUboot always is. U-Boot depends on how it was configured: this tree # always builds ${IB_PLATFORM}_defconfig (see uboot_2022.04.bb), linked at # a RAM address, which can be read off the card like any other first - # stage. Infrabase takes upstream qemu_arm64_defconfig on the bare "uboot" - # chain instead — position-independent with a text base of 0, an image - # meant to execute in place from flash — and the check below keeps such a - # U-Boot on -kernel, should a tree build one. + # stage. The check below keeps a position-independent U-Boot, with a text + # base of 0, on -kernel, should a tree build one. # # The ELF entry point is what says which: zero means "wherever flash is". uboot_entry = 0 @@ -208,8 +205,8 @@ def __do_platform_boot_chain(d): "-kernel u-boot/u-boot") return - # ATF chains: build flash0.img. "atf+uboot" and "full" differ only by - # whether the FIP carries the OP-TEE (BL32) entries. + # ATF chains: build flash0.img. "atf+uboot" and "atf+optee+uboot" + # differ only by whether the FIP carries the OP-TEE (BL32) entries. atf_path = d.getVar('IB_ATF_PATH') atf_release = f"{atf_path}/build/qemu/release" subprocess.run(['cp', f"{atf_release}/bl31.bin", diff --git a/build/meta-qemu/recipes-qemu/qemu/files/0001-qemu-8.2.2-r0/0001-virt.c.patch b/build/meta-qemu/recipes-qemu/qemu/files/0001-qemu-8.2.2-r0/0001-virt.c.patch index 0b049dc709..cb64e49c20 100644 --- a/build/meta-qemu/recipes-qemu/qemu/files/0001-qemu-8.2.2-r0/0001-virt.c.patch +++ b/build/meta-qemu/recipes-qemu/qemu/files/0001-qemu-8.2.2-r0/0001-virt.c.patch @@ -8,7 +8,16 @@ #include "sysemu/device_tree.h" #include "sysemu/numa.h" #include "sysemu/runstate.h" -@@ -82,6 +83,10 @@ +@@ -68,6 +69,8 @@ + #include "kvm_arm.h" + #include "hw/firmware/smbios.h" + #include "qapi/visitor.h" ++#include "sysemu/block-backend.h" ++#include "sysemu/blockdev.h" + #include "qapi/qapi-visit-common.h" + #include "qapi/qmp/qlist.h" + #include "standard-headers/linux/input.h" +@@ -82,6 +85,10 @@ #include "hw/char/pl011.h" #include "qemu/guest-random.h" @@ -19,7 +28,7 @@ #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ void *data) \ -@@ -145,6 +150,20 @@ +@@ -145,6 +152,20 @@ [VIRT_GIC_ITS] = { 0x08080000, 0x00020000 }, /* This redistributor space allows up to 2*64kB*123 CPUs */ [VIRT_GIC_REDIST] = { 0x080A0000, 0x00F60000 }, @@ -40,7 +49,7 @@ [VIRT_UART] = { 0x09000000, 0x00001000 }, [VIRT_RTC] = { 0x09010000, 0x00001000 }, [VIRT_FW_CFG] = { 0x09020000, 0x00000018 }, -@@ -199,6 +218,12 @@ +@@ -199,6 +220,12 @@ [VIRT_SECURE_UART] = 8, [VIRT_ACPI_GED] = 9, [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */ @@ -53,7 +62,88 @@ [VIRT_GIC_V2M] = 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */ [VIRT_SMMU] = 74, /* ...to 74 + NUM_SMMU_IRQS - 1 */ [VIRT_PLATFORM_BUS] = 112, /* ...to 112 + PLATFORM_BUS_NUM_IRQS -1 */ -@@ -1487,6 +1512,12 @@ +@@ -1230,6 +1257,80 @@ + } + } + ++/* ++ * Boot ROM emulation. ++ * ++ * A real SoC starts by running a mask ROM that reads the first stage from ++ * whatever medium the board boots from — a raw offset of the eMMC or SD card, ++ * before any partition — and jumps into it. "virt" has no such ROM: QEMU ++ * either maps firmware into flash at address 0 or -kernel-loads an image into ++ * RAM, and in both cases the first stage comes from a host file rather than ++ * from the storage the guest can see. ++ * ++ * This reproduces the ROM's effect rather than the ROM itself, which is what ++ * QEMU already does for the Allwinner SoCs whose ROM boots from SD — see ++ * allwinner_h3_bootrom_setup() in hw/arm/allwinner-h3.c, which this follows. ++ * The bytes come off the drive, so a card carrying its own first stage boots ++ * here exactly as it does on hardware. ++ * ++ * Returns true when a first stage was loaded, in which case the caller starts ++ * the CPU at bootrom_load. ++ */ ++static bool virt_bootrom_setup(VirtMachineState *vms) ++{ ++ g_autofree uint8_t *buffer = NULL; ++ BlockBackend *blk; ++ int64_t len; ++ ++ if (!vms->bootrom_drive) { ++ return false; ++ } ++ ++ if (!vms->bootrom_load) { ++ error_report("bootrom-drive needs bootrom-load: the ROM has to be " ++ "told where to put the first stage"); ++ exit(1); ++ } ++ ++ blk = blk_by_name(vms->bootrom_drive); ++ if (!blk) { ++ error_report("bootrom-drive=%s: no such drive", vms->bootrom_drive); ++ exit(1); ++ } ++ ++ len = blk_getlength(blk); ++ if (len < 0 || (uint64_t)len < vms->bootrom_offset + vms->bootrom_size) { ++ error_report("bootrom-drive=%s: too small to hold %" PRIu64 ++ " bytes at offset %" PRIu64, ++ vms->bootrom_drive, vms->bootrom_size, ++ vms->bootrom_offset); ++ exit(1); ++ } ++ ++ /* ++ * The drive is declared with if=none and claimed by a -device created ++ * after machine init, so nothing holds permissions on it yet. Take a ++ * read for the length of this function and give it straight back, so ++ * that device can still claim the drive as it expects to. ++ */ ++ if (blk_set_perm(blk, BLK_PERM_CONSISTENT_READ, BLK_PERM_ALL, NULL) < 0) { ++ error_report("bootrom-drive=%s: cannot be read", vms->bootrom_drive); ++ exit(1); ++ } ++ ++ buffer = g_malloc0(vms->bootrom_size); ++ if (blk_pread(blk, vms->bootrom_offset, vms->bootrom_size, buffer, 0) < 0) { ++ error_report("bootrom-drive=%s: read failed", vms->bootrom_drive); ++ exit(1); ++ } ++ ++ blk_set_perm(blk, 0, BLK_PERM_ALL, NULL); ++ ++ rom_add_blob("virt.bootrom", buffer, vms->bootrom_size, vms->bootrom_size, ++ vms->bootrom_load, NULL, NULL, NULL, NULL, false); ++ return true; ++} ++ + static bool virt_firmware_init(VirtMachineState *vms, + MemoryRegion *sysmem, + MemoryRegion *secure_sysmem) +@@ -1487,6 +1588,12 @@ vms->bus = pci->bus; if (vms->bus) { for (i = 0; i < nb_nics; i++) { @@ -66,7 +156,7 @@ pci_nic_init_nofail(&nd_table[i], pci->bus, mc->default_nic, NULL); } } -@@ -2022,6 +2053,109 @@ +@@ -2022,6 +2129,109 @@ } } @@ -176,7 +266,15 @@ static void machvirt_init(MachineState *machine) { VirtMachineState *vms = VIRT_MACHINE(machine); -@@ -2287,6 +2421,25 @@ +@@ -2034,6 +2244,7 @@ + MemoryRegion *secure_tag_sysmem = NULL; + int n, virt_max_cpus; + bool firmware_loaded; ++ bool bootrom_loaded; + bool aarch64 = true; + bool has_ged = !vmc->no_ged; + unsigned int smp_cpus = machine->smp.cpus; +@@ -2287,6 +2498,25 @@ create_rtc(vms); @@ -202,7 +300,7 @@ create_pcie(vms); if (has_ged && aarch64 && firmware_loaded && virt_is_acpi_enabled(vms)) { -@@ -2326,6 +2479,51 @@ +@@ -2326,6 +2556,53 @@ vms->fw_cfg, OBJECT(vms)); } @@ -250,7 +348,153 @@ + } + + } ++ ++ bootrom_loaded = virt_bootrom_setup(vms); + vms->bootinfo.ram_size = machine->ram_size; vms->bootinfo.board_id = -1; vms->bootinfo.loader_start = vms->memmap[VIRT_MEM].base; +@@ -2335,10 +2612,91 @@ + vms->bootinfo.psci_conduit = vms->psci_conduit; + arm_load_kernel(ARM_CPU(first_cpu), machine, &vms->bootinfo); + ++ /* ++ * Start the CPU in what the ROM loaded. ++ * ++ * do_cpu_reset() sets the PC from bootinfo.entry, but only ever sees ++ * bootinfo at all on the direct -kernel path: arm_setup_direct_kernel_boot() ++ * is what assigns env.boot_info, and arm_setup_firmware_boot() — the path ++ * taken when there is no -kernel — does not. Left alone the CPU comes out ++ * of reset at address 0, which is flash, which in this configuration is ++ * empty. So the wiring is done here rather than in hw/arm/boot.c, where it ++ * would change every board that boots firmware. ++ * ++ * Every CPU gets it, and only the primary acts on it: the secondaries are ++ * start-powered-off whenever PSCI is on, which it is on virt, and they ++ * come up through PSCI CPU_ON at whatever address the guest asks for. ++ */ ++ if (bootrom_loaded) { ++ CPUState *cs; ++ ++ vms->bootinfo.entry = vms->bootrom_load; ++ vms->bootinfo.is_linux = false; ++ ++ for (cs = first_cpu; cs; cs = CPU_NEXT(cs)) { ++ ARM_CPU(cs)->env.boot_info = &vms->bootinfo; ++ } ++ } ++ + vms->machine_done.notify = virt_machine_done; + qemu_add_machine_init_done_notifier(&vms->machine_done); + } + ++static char *virt_get_bootrom_drive(Object *obj, Error **errp) ++{ ++ return g_strdup(VIRT_MACHINE(obj)->bootrom_drive); ++} ++ ++static void virt_set_bootrom_drive(Object *obj, const char *value, Error **errp) ++{ ++ VirtMachineState *vms = VIRT_MACHINE(obj); ++ ++ g_free(vms->bootrom_drive); ++ vms->bootrom_drive = g_strdup(value); ++} ++ ++static void virt_get_bootrom_offset(Object *obj, Visitor *v, const char *name, ++ void *opaque, Error **errp) ++{ ++ uint64_t value = VIRT_MACHINE(obj)->bootrom_offset; ++ ++ visit_type_size(v, name, &value, errp); ++} ++ ++static void virt_set_bootrom_offset(Object *obj, Visitor *v, const char *name, ++ void *opaque, Error **errp) ++{ ++ visit_type_size(v, name, &VIRT_MACHINE(obj)->bootrom_offset, errp); ++} ++ ++static void virt_get_bootrom_load(Object *obj, Visitor *v, const char *name, ++ void *opaque, Error **errp) ++{ ++ uint64_t value = VIRT_MACHINE(obj)->bootrom_load; ++ ++ visit_type_size(v, name, &value, errp); ++} ++ ++static void virt_set_bootrom_load(Object *obj, Visitor *v, const char *name, ++ void *opaque, Error **errp) ++{ ++ visit_type_size(v, name, &VIRT_MACHINE(obj)->bootrom_load, errp); ++} ++ ++static void virt_get_bootrom_size(Object *obj, Visitor *v, const char *name, ++ void *opaque, Error **errp) ++{ ++ uint64_t value = VIRT_MACHINE(obj)->bootrom_size; ++ ++ visit_type_size(v, name, &value, errp); ++} ++ ++static void virt_set_bootrom_size(Object *obj, Visitor *v, const char *name, ++ void *opaque, Error **errp) ++{ ++ visit_type_size(v, name, &VIRT_MACHINE(obj)->bootrom_size, errp); ++} ++ + static bool virt_get_secure(Object *obj, Error **errp) + { + VirtMachineState *vms = VIRT_MACHINE(obj); +@@ -2985,6 +3343,32 @@ + NULL, NULL); + object_class_property_set_description(oc, "acpi", + "Enable ACPI"); ++ object_class_property_add_str(oc, "bootrom-drive", virt_get_bootrom_drive, ++ virt_set_bootrom_drive); ++ object_class_property_set_description(oc, "bootrom-drive", ++ "Read the first stage from this " ++ "drive instead of from flash or " ++ "-kernel (id of a -drive)"); ++ object_class_property_add(oc, "bootrom-offset", "size", ++ virt_get_bootrom_offset, ++ virt_set_bootrom_offset, NULL, NULL); ++ object_class_property_set_description(oc, "bootrom-offset", ++ "Byte offset of the first stage on " ++ "that drive (default 8K)"); ++ object_class_property_add(oc, "bootrom-load", "size", ++ virt_get_bootrom_load, ++ virt_set_bootrom_load, NULL, NULL); ++ object_class_property_set_description(oc, "bootrom-load", ++ "Address the first stage is copied " ++ "to and entered at"); ++ object_class_property_add(oc, "bootrom-size", "size", ++ virt_get_bootrom_size, ++ virt_set_bootrom_size, NULL, NULL); ++ object_class_property_set_description(oc, "bootrom-size", ++ "How much to copy; a window that " ++ "has to cover the first stage, not " ++ "its exact length (default 1M)"); ++ + object_class_property_add_bool(oc, "secure", virt_get_secure, + virt_set_secure); + object_class_property_set_description(oc, "secure", +@@ -3115,6 +3499,18 @@ + /* EL2 is also disabled by default, for similar reasons */ + vms->virt = false; + ++ /* ++ * No boot ROM unless a drive is named: virt keeps booting from flash or ++ * -kernel. 8K is where the Allwinner ROM looks for its first stage and ++ * leaves a partition table room to live above it; the window is a ++ * megabyte because that is the gap a DOS label conventionally leaves ++ * before the first partition. ++ */ ++ vms->bootrom_drive = NULL; ++ vms->bootrom_offset = 8 * KiB; ++ vms->bootrom_load = 0; ++ vms->bootrom_size = 1 * MiB; ++ + /* High memory is enabled by default */ + vms->highmem = true; + vms->highmem_compact = !vmc->no_highmem_compact; diff --git a/build/meta-qemu/recipes-qemu/qemu/files/0001-qemu-8.2.2-r0/0002-virt.h.patch b/build/meta-qemu/recipes-qemu/qemu/files/0001-qemu-8.2.2-r0/0002-virt.h.patch index 4bc2f97580..e80d884467 100644 --- a/build/meta-qemu/recipes-qemu/qemu/files/0001-qemu-8.2.2-r0/0002-virt.h.patch +++ b/build/meta-qemu/recipes-qemu/qemu/files/0001-qemu-8.2.2-r0/0002-virt.h.patch @@ -14,3 +14,21 @@ VIRT_SMMU, VIRT_UART, VIRT_MMIO, +@@ -148,6 +155,17 @@ + bool tcg_its; + bool virt; + bool ras; ++ ++ /* ++ * Boot ROM emulation. When bootrom_drive names a drive, the machine ++ * copies bootrom_size bytes from bootrom_offset of that drive to ++ * bootrom_load and starts the CPU there — what a real SoC ROM does with ++ * the medium it boots from. See virt_bootrom_setup(). ++ */ ++ char *bootrom_drive; ++ uint64_t bootrom_offset; ++ uint64_t bootrom_load; ++ uint64_t bootrom_size; + bool mte; + bool dtb_randomness; + OnOffAuto acpi; From c9cc1107d49063f50298eb4107379f18f7d132f8 Mon Sep 17 00:00:00 2001 From: Daniel Rossier Date: Sat, 14 Nov 2026 14:36:21 +0100 Subject: [PATCH 10/12] usr-so3 (lvgl): restore the base tree on clean A clean now recognises a tree attached with the lvgl series whatever the overrides say, restores the files the series replaced from the lvgl-free base, and finds that base from IB_TARGET. Taken from Infrabase 1.1.0. --- .../recipes-usr/lvgl/usr-so3_1.0.bbappend | 52 ++++++++++++++----- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/build/meta-usr/recipes-usr/lvgl/usr-so3_1.0.bbappend b/build/meta-usr/recipes-usr/lvgl/usr-so3_1.0.bbappend index 1be107b065..c2ca680833 100644 --- a/build/meta-usr/recipes-usr/lvgl/usr-so3_1.0.bbappend +++ b/build/meta-usr/recipes-usr/lvgl/usr-so3_1.0.bbappend @@ -70,24 +70,29 @@ python do_handle_fetch_git() { # bitbake owns WORKDIR; we only purge the fetched lvgl tree. python do_clean:append() { import os, shutil, subprocess - if 'lvgl' not in (d.getVar('OVERRIDES') or '').split(':'): + + # The tree holds the lvgl series if it was attached with it, whatever the + # overrides say now. Any other tree is left alone: a clean keeps local edits. + + series = {os.path.basename(u) for u in (d.getVar('LVGL_PATCHES') or '').split()} + if 'lvgl' not in (d.getVar('OVERRIDES') or '').split(':') \ + and not series & (ib_attached_series(d) or set()): return target = d.getVar('IB_TARGET') s = d.getVar('S') ib_dir = d.getVar('IB_DIR') - # Everything the :lvgl override creates in the committed-but-build-mutated - # usr/ tree (lib/slv, lib/lvgl, lib/lv_conf.h, the lvgl_*.elf sources and - # fillfb.c). do_attach_infrabase mirrors the patched ${S} back into - # IB_TARGET, so these end up in BOTH; remove from both so the next :lvgl - # build re-applies the creation patches onto a clean base instead of - # failing with "already exists" (idempotent :lvgl rebuilds). + # Everything the :lvgl override creates or replaces. do_attach_infrabase + # mirrors the patched ${S} back into IB_TARGET, so these end up in BOTH. + created = [ 'lib/lvgl', 'lib/slv', 'lib/lv_conf.h', 'src/lib', 'src/fillfb.c', 'src/lvgl_demo.c', 'src/lvgl_perf.c', 'src/lvgl_benchmark.c', 'src/lvgl_widgets.c', ] + cmakelists = ['lib/CMakeLists.txt', 'src/CMakeLists.txt'] + for base in (target, s): if not base: continue @@ -101,11 +106,32 @@ python do_clean:append() { except OSError: pass - # The lvgl CMakeLists blocks are added by the :lvgl patches to the tracked - # lib/CMakeLists.txt and src/CMakeLists.txt; restore them to the committed - # lvgl-free base (git index) so the tree fully matches the base again. - if ib_dir and os.path.isdir(os.path.join(ib_dir, '.git')): - for rel in ('lib/CMakeLists.txt', 'src/CMakeLists.txt'): + # usr/ belongs to the so3 recipe, so its ${S} is the lvgl-free base, some of + # these files included. Without a fetched so3, usr/ is under git. + + usr = None + try: + with open(os.path.dirname(target) + '.attach.pf') as f: + pf = f.read().strip() + usr = os.path.join(d.getVar('TMPDIR'), 'work', pf, pf.rsplit('-', 1)[0], 'usr') + except OSError: + pass + + if usr and os.path.isdir(usr): + for rel in created + cmakelists: + src = os.path.join(usr, rel) + dst = os.path.join(target, rel) + if os.path.isdir(src): + shutil.copytree(src, dst, symlinks=True) + elif os.path.isfile(src): + shutil.copyfile(src, dst) + elif ib_dir and os.path.isdir(os.path.join(ib_dir, '.git')): + for rel in cmakelists: subprocess.run(['git', '-C', ib_dir, 'checkout', '--', os.path.join(target, rel)], check=False) -} \ No newline at end of file + + try: + os.remove(target + '.attach.series') + except OSError: + pass +} From 974ba127cc17f3c118b050f8c00b6e68a8351c99 Mon Sep 17 00:00:00 2001 From: Daniel Rossier Date: Sat, 14 Nov 2026 14:36:21 +0100 Subject: [PATCH 11/12] scripts: help for mount.sh and umount.sh, and their cpio modes -h prints the usage without the tree-switch prompt, and ramfs|rootfs unpacks or repacks a rootfs recipe's cpio. Taken from Infrabase 1.1.0. --- scripts/mount.sh | 76 +++++++++++++++++++++++++++++++++++++++++++++-- scripts/umount.sh | 66 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 136 insertions(+), 6 deletions(-) diff --git a/scripts/mount.sh b/scripts/mount.sh index c374435884..e52ae4a06f 100755 --- a/scripts/mount.sh +++ b/scripts/mount.sh @@ -6,12 +6,55 @@ # recipe internally invokes mount/losetup via `sudo -n` against the # timestamp opened here. -# Resolve project root from this script's own location, cd there, and -# source env.sh — prompting the user first if the parent shell points -# at a different tree. See scripts/common/setup_env.sh for details. # Release banner, once per invocation (see scripts/common/banner.sh). . "$(cd "$(dirname "$(command -v -- "$0")")" && pwd)/common/banner.sh" +progname=$(basename "$0") + +pr_usage() +{ + printf "Open the target storage, or a cpio archive, for editing\n\n" + printf "Usage: %s [-h] [-i [platform]] [ramfs|rootfs [recipe]] [bitbake option]\n\n" "$progname" + printf " (no option) Mount the two partitions of the storage selected by\n" + printf " IB_PLATFORM / IB_STORAGE_MODE in build/conf/local.conf:\n" + printf " soft the loopback image filesystem/sdcard.img.\n" + printf " hard the real device named by IB_STORAGE_DEVICE\n" + printf " They show up as filesystem/p1 (boot, FAT) and\n" + printf " filesystem/p2 (rootfs, ext4).\n" + printf " -i [platform] Leave the storage alone: extract board//initrd.cpio\n" + printf " into filesystem/p1 so it can be edited. Under fakeroot —\n" + printf " no sudo, no bitbake. Defaults to the active IB_PLATFORM.\n" + printf " Repack it with 'umount.sh -i'.\n" + printf " ramfs|rootfs [r] Unpack a rootfs recipe's board//{initrd,rootfs}.cpio\n" + printf " into that recipe's WORKDIR, with /fs\n" + printf " pointing at it. Goes through bitbake and needs root\n" + printf " ('cpio -id' restores device nodes). The recipe defaults\n" + printf " to rootfs-linux; pass rootfs-so3 or buildroot as [r].\n" + printf " Repack with the matching 'umount.sh'.\n" + printf " -h Print this help\n\n" + printf "For a plain initrd edit prefer -i: same archive, without sudo or bitbake.\n" + printf "'rootfs' has no such alternative.\n\n" + printf "Any other argument is passed on to bitbake (e.g. -v).\n\n" + printf "Unmount before redeploying: deploy.sh reuses an existing mount instead of\n" + printf "making a fresh one.\n\n" + printf "In the build container a mount lives only as long as the container that made\n" + printf "it: 'dbuild.sh %s' mounts inside its own mount namespace, and the mount is\n" "$progname" + printf "gone once the command returns. Run the mount and whatever uses it in the SAME\n" + printf "container — typically from an interactive 'dbuild.sh' shell.\n" +} + +# Handled before setup_env.sh: printing the help should not trigger the +# tree-switch prompt that sourcing the environment can raise. +case "$1" in + -h|--help) + pr_usage + exit 0 + ;; +esac + +# Resolve project root from this script's own location, cd there, and +# source env.sh — prompting the user first if the parent shell points +# at a different tree. See scripts/common/setup_env.sh for details. . "$(cd "$(dirname "$(command -v -- "$0")")" && pwd)/common/setup_env.sh" # `mount.sh -i [platform]` extracts board//initrd.cpio for editing @@ -23,6 +66,33 @@ if [ "$1" = "-i" ] || [ "$1" = "initrd" ]; then exit $? fi +# `mount.sh ramfs|rootfs [recipe]` unpacks a rootfs recipe's cpio +# (board//{initrd,rootfs}.cpio) into that recipe's WORKDIR and +# symlinks /fs at it, so the tree can be edited in +# place. Repack with the matching `umount.sh ramfs|rootfs`. +# +# The recipe defaults to rootfs-linux; pass another one (rootfs-so3, +# buildroot) as the second argument. +# +# This is the bitbake path (do_{ramfs,rootfs}_mount) and needs root — +# `cpio -id` restores device nodes — hence the sudo session below. +# NB `-i` above reaches the same initrd.cpio through fakeroot, without +# sudo or bitbake; prefer it for a plain initrd edit. `rootfs` has no +# such alternative. +case "$1" in + ramfs|rootfs) + _ib_mode=$1 + _ib_recipe=${2:-rootfs-linux} + + . ./scripts/common/sudo_session.sh + + sudo_session_start || exit 1 + + cd "$BUILDDIR" + exec ./bitbake/bin/bitbake "$_ib_recipe" -c "${_ib_mode}_mount" + ;; +esac + . ./scripts/common/sudo_session.sh sudo_session_start || exit 1 diff --git a/scripts/umount.sh b/scripts/umount.sh index 62b782470e..ed29cf3e8e 100755 --- a/scripts/umount.sh +++ b/scripts/umount.sh @@ -6,12 +6,49 @@ # recipe internally invokes umount/losetup via `sudo -n` against the # timestamp opened here. -# Resolve project root from this script's own location, cd there, and -# source env.sh — prompting the user first if the parent shell points -# at a different tree. See scripts/common/setup_env.sh for details. # Release banner, once per invocation (see scripts/common/banner.sh). . "$(cd "$(dirname "$(command -v -- "$0")")" && pwd)/common/banner.sh" +progname=$(basename "$0") + +pr_usage() +{ + printf "Close what 'mount.sh' opened: the storage, or a cpio archive\n\n" + printf "Usage: %s [-h] [-i [platform]] [ramfs|rootfs [recipe]] [bitbake option]\n\n" "$progname" + printf " (no option) Unmount filesystem/p1 and filesystem/p2 — the partitions\n" + printf " mounted by 'mount.sh' from the storage selected by\n" + printf " IB_PLATFORM / IB_STORAGE_MODE (loopback image in soft\n" + printf " mode, real device in hard mode).\n" + printf " -i [platform] Repack the tree extracted by 'mount.sh -i' back into\n" + printf " board//initrd.cpio, preserving root ownership via\n" + printf " fakeroot. Defaults to the active IB_PLATFORM.\n" + printf " ramfs|rootfs [r] Repack the tree unpacked by the matching 'mount.sh' back\n" + printf " into board//{initrd,rootfs}.cpio, after copying the\n" + printf " previous archive to .cpio.backup. The repack is\n" + printf " content-deterministic, so an unmodified round trip leaves\n" + printf " the archive byte-identical. Same recipe default\n" + printf " (rootfs-linux) and same need for root as the mount side.\n" + printf " -h Print this help\n\n" + printf "Any other argument is passed on to bitbake (e.g. -v).\n\n" + printf "Always unmount before redeploying, and before unplugging a card: deploy.sh\n" + printf "reuses an existing mount, and an unmounted card may still hold unwritten data.\n\n" + printf "In the build container a mount lives only as long as the container that made\n" + printf "it, so a mount made in one 'dbuild.sh' invocation is already gone by the next\n" + printf "one — there is then nothing for this script to unmount.\n" +} + +# Handled before setup_env.sh: printing the help should not trigger the +# tree-switch prompt that sourcing the environment can raise. +case "$1" in + -h|--help) + pr_usage + exit 0 + ;; +esac + +# Resolve project root from this script's own location, cd there, and +# source env.sh — prompting the user first if the parent shell points +# at a different tree. See scripts/common/setup_env.sh for details. . "$(cd "$(dirname "$(command -v -- "$0")")" && pwd)/common/setup_env.sh" # `umount.sh -i [platform]` repacks the tree extracted by `mount.sh -i` @@ -23,6 +60,29 @@ if [ "$1" = "-i" ] || [ "$1" = "initrd" ]; then exit $? fi +# `umount.sh ramfs|rootfs [recipe]` repacks the tree unpacked by the +# matching `mount.sh` back into board//{initrd,rootfs}.cpio, after +# copying the previous archive to .cpio.backup. The repack is +# content-deterministic (sorted, --reproducible, mtimes zeroed), so an +# unmodified round trip leaves the archive byte-identical. The extracted +# tree and the /fs symlink are left in place — the next +# mount replaces them. Same recipe default and same privilege +# requirement as the mount side. + +case "$1" in + ramfs|rootfs) + _ib_mode=$1 + _ib_recipe=${2:-rootfs-linux} + + . ./scripts/common/sudo_session.sh + + sudo_session_start || exit 1 + + cd "$BUILDDIR" + exec ./bitbake/bin/bitbake "$_ib_recipe" -c "${_ib_mode}_umount" + ;; +esac + . ./scripts/common/sudo_session.sh sudo_session_start || exit 1 From 9fc17f6957e225135e96308c8c7213d4aa8e1078 Mon Sep 17 00:00:00 2001 From: Daniel Rossier Date: Sat, 14 Nov 2026 14:36:21 +0100 Subject: [PATCH 12/12] build: aligned on Infrabase 1.1.0 --- build/meta-so3/classes/avz.bbclass | 3 +-- scripts/ibversion.sh | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/build/meta-so3/classes/avz.bbclass b/build/meta-so3/classes/avz.bbclass index 7a3f1eec73..6a3f2815ac 100644 --- a/build/meta-so3/classes/avz.bbclass +++ b/build/meta-so3/classes/avz.bbclass @@ -1,6 +1,5 @@ # Copyright (c) 2025-2026 EDGEMTech SA -# Class for building SO3 in infrabase +# Class for building the AVZ hypervisor in infrabase IB_AVZ_PATH = "${IB_DIR}/avz" - diff --git a/scripts/ibversion.sh b/scripts/ibversion.sh index 97eb201e4e..570e0474fe 100755 --- a/scripts/ibversion.sh +++ b/scripts/ibversion.sh @@ -14,6 +14,6 @@ # # Usage: ibversion.sh -IB_VERSION="1.0.0" +IB_VERSION="1.1.0" printf '%s\n' "$IB_VERSION"