Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
'
Expand Down
8 changes: 0 additions & 8 deletions build/conf/local.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
25 changes: 25 additions & 0 deletions build/meta-bsp/recipes-bsp/bsp/files/bsp_arm_common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,27 @@
# from IB_TARGET_ITS: <its-without-_avz>_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
Expand All @@ -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)
Expand All @@ -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"])

Expand Down
13 changes: 5 additions & 8 deletions build/meta-bsp/recipes-bsp/bsp/files/bsp_virt64.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down
39 changes: 35 additions & 4 deletions build/meta-bsp/recipes-bsp/linux/bsp-linux_1.0.bb
Original file line number Diff line number Diff line change
Expand Up @@ -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:<plat> 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 <plat>${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

Expand Down Expand Up @@ -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 = []
Expand Down
77 changes: 36 additions & 41 deletions build/meta-bsp/recipes-bsp/linux/files/its/virt32.its
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2014-2023 Daniel Rossier <daniel.rossier@heig-vd.ch>
* Copyright (C) 2014-2026 Daniel Rossier <daniel.rossier@heig-vd.ch>
*
* 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
Expand All @@ -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: <plat>.its = standalone Linux, <plat>_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";
};
};

};
8 changes: 7 additions & 1 deletion build/meta-bsp/recipes-bsp/linux/files/its/virt64.its
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
};
};
Expand Down
1 change: 1 addition & 0 deletions build/meta-filesystem/classes/filesystem.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down
5 changes: 3 additions & 2 deletions build/meta-filesystem/classes/fs_arm_common.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions build/meta-filesystem/classes/fs_verdin-imx8mp.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion build/meta-filesystem/classes/fs_x86-qemu.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions build/meta-linux/classes/linux.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
Loading
Loading