From 305366246868bc3348373a09e17b3df23746e5ef Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 19 Nov 2025 10:15:14 +0100 Subject: [PATCH 01/20] infix.mk: Define artifact name in one place A bunch of different artifacts should follow the same naming scheme, depending on a bunch of config settings + whether we're building a release or not. Therefore, provide a single definition of this that we can reuse to name disk images, upgrade packages, etc. --- infix.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/infix.mk b/infix.mk index dfed3a39..788134c7 100644 --- a/infix.mk +++ b/infix.mk @@ -8,5 +8,6 @@ INFIX_TOPDIR = $(if $(oem-dir),$(oem-dir),$(BR2_EXTERNAL_INFIX_PATH)) # release is being built. export INFIX_BUILD_ID ?= $(shell git -C $(INFIX_TOPDIR) describe --dirty --always --tags) export INFIX_VERSION = $(if $(INFIX_RELEASE),$(INFIX_RELEASE),$(INFIX_BUILD_ID)) +export INFIX_ARTIFACT = $(call qstrip,$(INFIX_IMAGE_ID)$(if $(INFIX_RELEASE),-$(INFIX_RELEASE))) INFIX_CFLAGS:=-Wall -Werror -Wextra -Wno-unused-parameter -Wformat=2 -Wformat-overflow=2 -Winit-self -Wstrict-overflow=4 -Wno-format-truncation -Wno-format-nonliteral From 218cf5ccdbbff8bc98baba23d4d0cb439b6db480 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 19 Nov 2025 16:42:44 +0100 Subject: [PATCH 02/20] board: Defer Makefile fragment inclusion to each architecture The board/*/*/*.mk is very broad, intended to hit all board specific definitions, but may also cause duplicate inclusions, e.g., in board/common. Let each architecture do the inclusion instead. --- board/aarch64/board.mk | 1 + board/board.mk | 3 ++- board/riscv64/board.mk | 1 + external.mk | 2 -- 4 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 board/riscv64/board.mk diff --git a/board/aarch64/board.mk b/board/aarch64/board.mk index d825ceb7..9b6c82a9 100644 --- a/board/aarch64/board.mk +++ b/board/aarch64/board.mk @@ -1,3 +1,4 @@ +include $(sort $(wildcard $(BR2_EXTERNAL_INFIX_PATH)/board/aarch64/*/*.mk)) .PHONY: board-enable-qemu-uboot board-enable-qemu-uboot: diff --git a/board/board.mk b/board/board.mk index a87a8715..8208e16f 100644 --- a/board/board.mk +++ b/board/board.mk @@ -1,2 +1,3 @@ +include $(BR2_EXTERNAL_INFIX_PATH)/board/common/common.mk include $(BR2_EXTERNAL_INFIX_PATH)/board/ix-board.mk -include $(sort $(wildcard $(BR2_EXTERNAL_INFIX_PATH)/board/*/*/*.mk)) +-include $(BR2_EXTERNAL_INFIX_PATH)/board/$(patsubst "%",%,$(BR2_ARCH))/board.mk diff --git a/board/riscv64/board.mk b/board/riscv64/board.mk new file mode 100644 index 00000000..87bae895 --- /dev/null +++ b/board/riscv64/board.mk @@ -0,0 +1 @@ +include $(sort $(wildcard $(BR2_EXTERNAL_INFIX_PATH)/board/riscv64/*/*.mk)) diff --git a/external.mk b/external.mk index 2a4a4874..54fdd6e4 100644 --- a/external.mk +++ b/external.mk @@ -1,8 +1,6 @@ include $(BR2_EXTERNAL_INFIX_PATH)/infix.mk include $(sort $(wildcard $(BR2_EXTERNAL_INFIX_PATH)/package/*/*.mk)) -include $(BR2_EXTERNAL_INFIX_PATH)/board/common/common.mk include $(BR2_EXTERNAL_INFIX_PATH)/board/board.mk --include $(BR2_EXTERNAL_INFIX_PATH)/board/$(patsubst "%",%,$(BR2_ARCH))/board.mk include $(BR2_EXTERNAL_INFIX_PATH)/test/test.mk .PHONY: local.mk From f0d56691c7e6a26d0ec3dfc839e1454fe239e898 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 19 Nov 2025 21:28:21 +0100 Subject: [PATCH 03/20] board/common: Fix trusted key installation logic Rather than using the creation of a signed image as a proxy for whether the trusted keys should be installed RAUC/U-Boot's trust stores, use the dedicated option. --- board/common/common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/common/common.mk b/board/common/common.mk index 4fa482bb..7beecade 100644 --- a/board/common/common.mk +++ b/board/common/common.mk @@ -1,4 +1,4 @@ -ifeq ($(SIGN_ENABLED),y) +ifeq ($(TRUSTED_KEYS),y) include $(BR2_EXTERNAL_INFIX_PATH)/board/common/uboot/uboot.mk TRUSTED_KEYS=$(TRUSTED_KEYS_DEVELOPMENT_PATH) $(TRUSTED_KEYS_EXTRA_PATH) From 7cebc36ab2fa5281c06089be5c5ecfd039c0a111 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Thu, 20 Nov 2025 10:29:45 +0100 Subject: [PATCH 04/20] board/common: Add common macro for image generation Add scaffolding for breaking out image generation to separate make targets. --- board/common/common.mk | 2 ++ board/common/image/image.mk | 2 ++ board/common/image/ix-image.mk | 25 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 board/common/image/image.mk create mode 100644 board/common/image/ix-image.mk diff --git a/board/common/common.mk b/board/common/common.mk index 7beecade..8cbf082f 100644 --- a/board/common/common.mk +++ b/board/common/common.mk @@ -1,3 +1,5 @@ +include $(BR2_EXTERNAL_INFIX_PATH)/board/common/image/image.mk + ifeq ($(TRUSTED_KEYS),y) include $(BR2_EXTERNAL_INFIX_PATH)/board/common/uboot/uboot.mk diff --git a/board/common/image/image.mk b/board/common/image/image.mk new file mode 100644 index 00000000..c6d4fb80 --- /dev/null +++ b/board/common/image/image.mk @@ -0,0 +1,2 @@ +include $(BR2_EXTERNAL_INFIX_PATH)/board/common/image/ix-image.mk +include $(sort $(wildcard $(BR2_EXTERNAL_INFIX_PATH)/board/common/image/*/*.mk)) diff --git a/board/common/image/ix-image.mk b/board/common/image/ix-image.mk new file mode 100644 index 00000000..d20894cd --- /dev/null +++ b/board/common/image/ix-image.mk @@ -0,0 +1,25 @@ +define inner-ix-image + +$(2)_DIR := $$(pkgdir) + +$(1): $$($(2)_DEPENDENCIES) + @$$(call IXMSG,"$$(if $$($(2)_MESSAGE),$$($(2)_MESSAGE),Creating $(1))") + @mkdir -p $$(BUILD_DIR)/$(1) + @ \ + PATH=$$(BR_PATH) \ + PKGDIR=$$($(2)_DIR) \ + WORKDIR=$$(BUILD_DIR)/$(1) \ + BINARIES_DIR=$$(BINARIES_DIR) \ + ARTIFACT=$$(INFIX_ARTIFACT) \ + COMPATIBLE=$$(INFIX_COMPATIBLE) \ + VERSION=$$(INFIX_VERSION) \ + $$(foreach var,$$($(2)_CONFIG_VARS),$$(var)=$$($(2)_$$(var)) ) \ + $$($(2)_DIR)/generate.sh $$($(2)_OPTS) + +ifeq ($$($(2)),y) +TARGETS_ROOTFS += $(1) +endif + +endef + +ix-image = $(call inner-ix-image,$(pkgname),$(call UPPERCASE,$(pkgname))) From bf1a431692896ae2e5721fe7c8b3dc856e83a691 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Mon, 10 Nov 2025 16:55:21 +0100 Subject: [PATCH 05/20] board/common: Move rootfs.itb/itbh creation to separate make target --- board/common/Config.in | 7 ++ board/common/image/image-itb-rootfs/Config.in | 20 ++++++ .../common/image/image-itb-rootfs/generate.sh | 71 +++++++++++++++++++ .../image-itb-rootfs/image-itb-rootfs.mk | 10 +++ board/common/post-image.sh | 3 - board/common/rootfs.its | 28 -------- board/common/sign.sh | 13 ---- 7 files changed, 108 insertions(+), 44 deletions(-) create mode 100644 board/common/image/image-itb-rootfs/Config.in create mode 100755 board/common/image/image-itb-rootfs/generate.sh create mode 100644 board/common/image/image-itb-rootfs/image-itb-rootfs.mk delete mode 100644 board/common/rootfs.its delete mode 100755 board/common/sign.sh diff --git a/board/common/Config.in b/board/common/Config.in index 70891198..5ce1e8e8 100644 --- a/board/common/Config.in +++ b/board/common/Config.in @@ -1,3 +1,9 @@ +menu "Images" + +source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-rootfs/Config.in" + +endmenu + menuconfig SIGN_ENABLED bool "Image Signing" default y @@ -166,3 +172,4 @@ config SDCARD_AUX help Create and populate aux.ext4 with rootfs.itbh and rauc.status For use with a static genimage.cfg for, e.g., SD-cards. + diff --git a/board/common/image/image-itb-rootfs/Config.in b/board/common/image/image-itb-rootfs/Config.in new file mode 100644 index 00000000..fbb04d8d --- /dev/null +++ b/board/common/image/image-itb-rootfs/Config.in @@ -0,0 +1,20 @@ +menuconfig IMAGE_ITB_ROOTFS + bool "rootfs.itb+.itbh" + select BR2_TARGET_ROOTFS_SQUASHFS + select BR2_PACKAGE_HOST_UBOOT_TOOLS + help + Create a signed ITB image containing a SquashFS of rootfs + and extract detached header (.itbh) for U-Boot based + targets. + +config IMAGE_ITB_ROOTFS_KEY + string "signing key" + depends on IMAGE_ITB_ROOTFS + default "${BR2_EXTERNAL_INFIX_PATH}/board/common/signing-keys/development/infix.key" + help + Path to the private RSA key, in PKCS#8 format, used to sign + the root filesystem. + + If the path is prefixed with ":", then that used as + the "key-name-hint" in the resulting ITB, otherwise the + basename of the path, with any extension removed, is used. diff --git a/board/common/image/image-itb-rootfs/generate.sh b/board/common/image/image-itb-rootfs/generate.sh new file mode 100755 index 00000000..ca0c81cb --- /dev/null +++ b/board/common/image/image-itb-rootfs/generate.sh @@ -0,0 +1,71 @@ +#!/bin/sh + +set -e + +squash="${BINARIES_DIR}"/rootfs.squashfs + +itb="${BINARIES_DIR}"/rootfs.itb +itbh_size=0x1000 + +IFS=: +set ${KEY} +case $# in + 1) + keyfile="$1" + hint=$(basename ${keyfile%.*}) + ;; + 2) + keyfile="$2" + hint="$1" + ;; + *) + echo "INVALID KEY" >&2 + exit 1 + ;; +esac + +rsanibbles=$(openssl rsa -in "${KEY}" -noout -modulus | \ + sed -e 's/^Modulus=//' | tr -d '\n' | wc -c) +if [ "${rsanibbles}" -le 0 ]; then + echo "ONLY RSA KEYS ARE SUPPORTED" >&2 + exit 1 +fi + +cat >"${WORKDIR}"/rootfs.its <; + + images { + rootfs { + description = "rootfs"; + type = "ramdisk"; + os = "linux"; + compression = "none"; + data = /incbin/("${squash}"); + signature-1 { + algo = "sha256,rsa$((rsanibbles << 2))"; + key-name-hint = "${hint}"; + }; + }; + }; + + configurations { + default = "verity"; + verity { + ramdisk = "rootfs"; + }; + }; +}; + +EOF + +mkimage -E -p $itbh_size -B $itbh_size \ + -f "${WORKDIR}"/rootfs.its \ + -g "${hint}" -G "${keyfile}" \ + "${itb}" + +dd if="${itb}" bs=$((itbh_size)) count=1 of="${itb}h" status=none diff --git a/board/common/image/image-itb-rootfs/image-itb-rootfs.mk b/board/common/image/image-itb-rootfs/image-itb-rootfs.mk new file mode 100644 index 00000000..ca288d10 --- /dev/null +++ b/board/common/image/image-itb-rootfs/image-itb-rootfs.mk @@ -0,0 +1,10 @@ +################################################################################ +# +# image-itb-rootfs +# +################################################################################ + +IMAGE_ITB_ROOTFS_DEPENDENCIES := rootfs-squashfs +IMAGE_ITB_ROOTFS_CONFIG_VARS := KEY + +$(eval $(ix-image)) diff --git a/board/common/post-image.sh b/board/common/post-image.sh index 5e273a88..00b84fcc 100755 --- a/board/common/post-image.sh +++ b/board/common/post-image.sh @@ -38,9 +38,6 @@ if [ "$SIGN_ENABLED" = "y" ]; then load_cfg BR2_ARCH load_cfg SIGN_KEY - ixmsg "Signing SquashFS Image" - $common/sign.sh $BR2_ARCH $SIGN_KEY - ixmsg "Creating RAUC Update Bundle" $common/mkrauc.sh "$NAME$(ver)" $INFIX_COMPATIBLE $SIGN_KEY fi diff --git a/board/common/rootfs.its b/board/common/rootfs.its deleted file mode 100644 index a826694e..00000000 --- a/board/common/rootfs.its +++ /dev/null @@ -1,28 +0,0 @@ -/dts-v1/; - -/ { - description = "Infix"; - creator = "infix"; - #address-cells = <0x1>; - - images { - rootfs { - description = "Infix"; - type = "ramdisk"; - os = "linux"; - compression = "none"; - data = /incbin/("rootfs.squashfs"); - signature-1 { - algo = "sha256,rsa4096"; - key-name-hint = "infix"; - }; - }; - }; - - configurations { - default = "verity"; - verity { - ramdisk = "rootfs"; - }; - }; -}; diff --git a/board/common/sign.sh b/board/common/sign.sh deleted file mode 100755 index 0eb37db6..00000000 --- a/board/common/sign.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -set -e - -common=$(dirname $(readlink -f "$0")) - -cd $BINARIES_DIR -cp $common/rootfs.its . - -mkimage -E -p 0x1000 -B 0x1000 -k $2 -f rootfs.its rootfs.itb - -cp rootfs.itb rootfs.itbh -truncate -s $((0x1000)) rootfs.itbh From dd98c57bc716a53055666776343f9de0430c4b01 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Tue, 11 Nov 2025 23:39:39 +0100 Subject: [PATCH 06/20] board/common: Move RAUC bundle creation to separate make target --- board/common/Config.in | 25 +---------- board/common/image/image-itb-rauc/Config.in | 27 ++++++++++++ board/common/image/image-itb-rauc/generate.sh | 35 +++++++++++++++ .../image-itb-rauc/hooks.sh} | 0 .../image/image-itb-rauc/image-itb-rauc.mk | 10 +++++ board/common/mkrauc.sh | 43 ------------------- board/common/post-image.sh | 9 ---- 7 files changed, 73 insertions(+), 76 deletions(-) create mode 100644 board/common/image/image-itb-rauc/Config.in create mode 100755 board/common/image/image-itb-rauc/generate.sh rename board/common/{rauc-hooks.sh => image/image-itb-rauc/hooks.sh} (100%) create mode 100644 board/common/image/image-itb-rauc/image-itb-rauc.mk delete mode 100755 board/common/mkrauc.sh diff --git a/board/common/Config.in b/board/common/Config.in index 5ce1e8e8..60904edd 100644 --- a/board/common/Config.in +++ b/board/common/Config.in @@ -1,38 +1,15 @@ menu "Images" source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-rootfs/Config.in" +source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-rauc/Config.in" endmenu -menuconfig SIGN_ENABLED - bool "Image Signing" - default y - -choice - prompt "Signing key source" - depends on SIGN_ENABLED - default SIGN_SRC_DIR - -config SIGN_SRC_DIR - bool "Directory" - -config SIGN_SRC_PKCS11 - bool "PKCS#11 URL" - -endchoice - -config SIGN_KEY - string "Signing key" - depends on SIGN_ENABLED - default "${BR2_EXTERNAL_INFIX_PATH}/board/common/signing-keys/development" if SIGN_SRC_DIR - menuconfig TRUSTED_KEYS bool "Trusted keys for image" - depends on SIGN_ENABLED help Keys that will be accepted for this image - config TRUSTED_KEYS_DEVELOPMENT bool "Development key" depends on TRUSTED_KEYS diff --git a/board/common/image/image-itb-rauc/Config.in b/board/common/image/image-itb-rauc/Config.in new file mode 100644 index 00000000..27f7017d --- /dev/null +++ b/board/common/image/image-itb-rauc/Config.in @@ -0,0 +1,27 @@ +menuconfig IMAGE_ITB_RAUC + bool "RAUC upgrade bundle (ITB)" + select IMAGE_ITB_ROOTFS + select BR2_PACKAGE_HOST_RAUC + help + Create RAUC upgrade bundle, for targets using ITB images, + that can be used to upgrade a running system to this version + of Infix. + +config IMAGE_ITB_RAUC_KEY + string "signing key" + depends on IMAGE_ITB_RAUC + default "${BR2_EXTERNAL_INFIX_PATH}/board/common/signing-keys/development/infix.key" + help + Path to the private key, in PKCS#8 format, used to sign + the RAUC bundle; or a PKCS#11 URI. + +config IMAGE_ITB_RAUC_CERT + string "signing certificate" + depends on IMAGE_ITB_RAUC + default "${BR2_EXTERNAL_INFIX_PATH}/board/common/signing-keys/development/infix.crt" + help + Path to the X509 certificate which will be associated with + the bundle signature. + + NOTE: This cert MUST be included in the trust store of the + system on which this bundle is to be installed. diff --git a/board/common/image/image-itb-rauc/generate.sh b/board/common/image/image-itb-rauc/generate.sh new file mode 100755 index 00000000..8552402c --- /dev/null +++ b/board/common/image/image-itb-rauc/generate.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +set -e + +squash="${BINARIES_DIR}"/rootfs.squashfs +itbh="${BINARIES_DIR}"/rootfs.itbh +pkg="${BINARIES_DIR}"/"${ARTIFACT}.pkg" + +cp -f "${PKGDIR}"/hooks.sh "${WORKDIR}"/hooks.sh + +# RAUC internally uses the file extension to find a suitable install +# handler, hence the name must be .img +cp -f "${squash}" "${WORKDIR}"/rootfs.img +cp -f "${itbh}" "${WORKDIR}"/rootfs.itbh + +cat >"${WORKDIR}"/manifest.raucm <"$work/manifest.raucm" < Date: Thu, 13 Nov 2025 22:36:28 +0100 Subject: [PATCH 07/20] board/common: Consolidate aux.ext4 generation Add a generic image target to build aux.ext4, which can be used both when creating target-specific SD-card images, and when creating regular disk images. While we're here, make sure that we don't need a RAUC bundle in order to generate aux.ext4 (which mkrauc-status.sh did). This saves us time on _every_ incremental build. --- board/common/Config.in | 7 +- board/common/image/image-itb-aux/Config.in | 10 +++ board/common/image/image-itb-aux/generate.sh | 85 +++++++++++++++++++ board/common/image/image-itb-aux/grub.cfg | 80 +++++++++++++++++ board/common/image/image-itb-aux/grubenv | 10 +++ .../image/image-itb-aux/image-itb-aux.mk | 10 +++ board/common/mkaux.sh | 40 --------- board/common/post-image.sh | 8 -- configs/riscv64_defconfig | 2 +- 9 files changed, 197 insertions(+), 55 deletions(-) create mode 100644 board/common/image/image-itb-aux/Config.in create mode 100755 board/common/image/image-itb-aux/generate.sh create mode 100644 board/common/image/image-itb-aux/grub.cfg create mode 100644 board/common/image/image-itb-aux/grubenv create mode 100644 board/common/image/image-itb-aux/image-itb-aux.mk delete mode 100755 board/common/mkaux.sh diff --git a/board/common/Config.in b/board/common/Config.in index 60904edd..a484572b 100644 --- a/board/common/Config.in +++ b/board/common/Config.in @@ -1,6 +1,7 @@ menu "Images" source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-rootfs/Config.in" +source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-aux/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-rauc/Config.in" endmenu @@ -144,9 +145,3 @@ config FIT_KERNEL_LOAD_ADDR string "Kernel load address" depends on FIT_IMAGE -config SDCARD_AUX - bool "Create SD-card aux partition" - help - Create and populate aux.ext4 with rootfs.itbh and rauc.status - For use with a static genimage.cfg for, e.g., SD-cards. - diff --git a/board/common/image/image-itb-aux/Config.in b/board/common/image/image-itb-aux/Config.in new file mode 100644 index 00000000..4cda6cd6 --- /dev/null +++ b/board/common/image/image-itb-aux/Config.in @@ -0,0 +1,10 @@ +config IMAGE_ITB_AUX + bool "aux partition" + depends on IMAGE_ITB_ROOTFS + select BR2_PACKAGE_HOST_UBOOT_TOOLS + select BR2_PACKAGE_HOST_GENIMAGE + help + Create and populate auxiliary partition, aux.ext4, with + metadata needed by U-Boot and RAUC to operate properly on + systems using ITB images. This may then be included as a + partition in a larger disk image. diff --git a/board/common/image/image-itb-aux/generate.sh b/board/common/image/image-itb-aux/generate.sh new file mode 100755 index 00000000..127535b3 --- /dev/null +++ b/board/common/image/image-itb-aux/generate.sh @@ -0,0 +1,85 @@ +#!/bin/sh + +set -e + +boot="${1}" +squash="${BINARIES_DIR}"/rootfs.squashfs +itbh="${BINARIES_DIR}"/rootfs.itbh +aux="${BINARIES_DIR}"/aux.ext4 + +mkdir -p "${WORKDIR}"/aux +rm -rf "${WORKDIR}"/tmp +mkdir -p "${WORKDIR}"/tmp + +cp -f "${itbh}" "${WORKDIR}"/aux/primary.itbh +cp -f "${itbh}" "${WORKDIR}"/aux/secondary.itbh + +tstamp=$(date -u +%FT%TZ) +rootsha=$(sha256sum "${squash}" | cut -d" " -f1) +rootsize=$(stat -c %s "${squash}") +cat <"${WORKDIR}"/aux/rauc.status +[slot.rootfs.0] +bundle.compatible=${COMPATIBLE} +bundle.version=${VERSION} +status=ok +sha256=${rootsha} +size=${rootsize} +installed.timestamp=$tstamp +installed.count=1 +activated.timestamp=$tstamp +activated.count=1 + +[slot.rootfs.1] +bundle.compatible=${COMPATIBLE} +bundle.version=${VERSION} +status=ok +sha256=${rootsha} +size=${rootsize} +installed.timestamp=$tstamp +installed.count=1 +activated.timestamp=$tstamp +activated.count=1 +EOF + +case "${boot}" in + uboot) + cat <&2 + exit 1 +esac + +cat <"${WORKDIR}"/genimage.cfg +image $(basename ${aux}) { + mountpoint = "/" + size = 8M + + ext4 { + label = "aux" + use-mke2fs = true + features = "^metadata_csum,^metadata_csum_seed,uninit_bg" + extraargs = "-m 0 -i 4096" + } +} + +# Silence genimage warnings +config {} +EOF + +genimage \ + --loglevel 1 \ + --tmppath "${WORKDIR}"/tmp \ + --rootpath "${WORKDIR}"/aux \ + --inputpath "${WORKDIR}" \ + --outputpath "$(dirname ${aux})" \ + --config "${WORKDIR}"/genimage.cfg diff --git a/board/common/image/image-itb-aux/grub.cfg b/board/common/image/image-itb-aux/grub.cfg new file mode 100644 index 00000000..c62114e1 --- /dev/null +++ b/board/common/image/image-itb-aux/grub.cfg @@ -0,0 +1,80 @@ +set timeout="1" + +load_env ORDER DEBUG + +if [ -z "$ORDER" ]; then + set ORDER="primary secondary" +fi + +set ORDER="$ORDER reboot" + +for slot in $ORDER; do + if [ -z "$default" ]; then + set default="$slot" + else + # Contrary to what the documentation says, GRUB (2.06) does + # not support using titles or IDs in the fallback variable, so + # we translate to indices. + if [ "$slot" = "primary" ]; then + set fallback="$fallback 0" + elif [ "$slot" = "secondary" ]; then + set fallback="$fallback 1" + elif [ "$slot" = "net" ]; then + set fallback="$fallback 2" + elif [ "$slot" = "reboot" ]; then + set fallback="$fallback 3" + fi + fi +done + +if [ "$DEBUG" ]; then + set log="debug" +else + set log="loglevel=4" +fi + +# From board/common/rootfs/etc/partition-uuid +search -p 107ae911-a97b-4380-975c-7ce1a2dde1e0 --set primary +search -p 352bd9b2-2ca9-44e2-bdc7-edbc87ba1e02 --set secondary + +export primary +export secondary + +submenu "primary" "$log" { + set slot="$1" + set append="console=ttyS0 console=hvc0 usbcore.authorized_default=2 root=PARTLABEL=$slot $2" + set root="($primary)" + source /boot/grub/grub.cfg +} + +submenu "secondary" "$log" { + set slot="$1" + set append="console=ttyS0 console=hvc0 usbcore.authorized_default=2 root=PARTLABEL=$slot $2" + set root="($secondary)" + source /boot/grub/grub.cfg +} + +submenu "net" "$log" { + net_dhcp + + if [ "$net_efinet0_dhcp_next_server" -a "$net_efinet0_dhcp_boot_file" ]; then + set initrd=(tftp,$net_efinet0_dhcp_next_server)/$net_efinet0_dhcp_boot_file + loopback initrd $initrd + set root=(initrd) + + set slot="$1" + set append="console=ttyS0 console=hvc0 usbcore.authorized_default=2 qroot=/dev/ram0 ramdisk_size=65536 $2" + source /boot/grub/grub.cfg + else + if [ -z "$net_efinet0_dhcp_next_server" ]; then + echo "No TFTP server supplied in DHCP response" + fi + if [ -z "$net_efinet0_dhcp_boot_file" ]; then + echo "No bootfile supplied in DHCP response" + fi + fi +} + +submenu "reboot" { + reboot +} diff --git a/board/common/image/image-itb-aux/grubenv b/board/common/image/image-itb-aux/grubenv new file mode 100644 index 00000000..b1eb67d3 --- /dev/null +++ b/board/common/image/image-itb-aux/grubenv @@ -0,0 +1,10 @@ +# GRUB Environment Block +# WARNING: Do not edit this file by tools other than grub-editenv!!! +ORDER=primary secondary net +primary_OK=1 +secondary_OK=1 +net_OK=1 +primary_TRY=0 +secondary_TRY=0 +net_TRY=0 +######################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################### \ No newline at end of file diff --git a/board/common/image/image-itb-aux/image-itb-aux.mk b/board/common/image/image-itb-aux/image-itb-aux.mk new file mode 100644 index 00000000..69458924 --- /dev/null +++ b/board/common/image/image-itb-aux/image-itb-aux.mk @@ -0,0 +1,10 @@ +################################################################################ +# +# image-itb-aux +# +################################################################################ + +IMAGE_ITB_AUX_DEPENDENCIES := host-uboot-tools host-genimage image-itb-rootfs +IMAGE_ITB_AUX_OPTS := $(if $(BR2_TARGET_GRUB2),grub,uboot) + +$(eval $(ix-image)) diff --git a/board/common/mkaux.sh b/board/common/mkaux.sh deleted file mode 100755 index 0adf9f0f..00000000 --- a/board/common/mkaux.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh - -rootdir=$BUILD_DIR/genimage.root -tempdir=$BUILD_DIR/genimage.tmp - -cat < /tmp/mkaux.cfg -image aux.ext4 { - mountpoint = "/aux" - size = 16M - - ext4 { - label = "aux" - use-mke2fs = true - features = "^metadata_csum,^metadata_csum_seed,uninit_bg" - extraargs = "-m 0 -i 4096" - } -} - -# Silence genimage warnings -config {} -EOF - -rm -rf "$rootdir/aux" -mkdir -p "$rootdir/aux" -cp -f "$BINARIES_DIR/rootfs.itbh" "$rootdir/aux/primary.itbh" -cp -f "$BINARIES_DIR/rootfs.itbh" "$rootdir/aux/secondary.itbh" -cp -f "$BINARIES_DIR/rauc.status" "$rootdir/aux/rauc.status" - -mkenvimage -s 0x4000 -o "$rootdir/aux/uboot.env" \ - "$BR2_EXTERNAL_INFIX_PATH/board/common/uboot/aux-env.txt" - -rm -rf "$BINARIES_DIR/aux.ext4" -rm -rf "$tempdir" - -genimage \ - --rootpath "$rootdir" \ - --tmppath "$tempdir" \ - --inputpath "$BINARIES_DIR" \ - --outputpath "$BINARIES_DIR" \ - --config "/tmp/mkaux.cfg" diff --git a/board/common/post-image.sh b/board/common/post-image.sh index 69983242..8f6d3cb4 100755 --- a/board/common/post-image.sh +++ b/board/common/post-image.sh @@ -54,14 +54,6 @@ if [ "$DISK_IMAGE" = "y" ]; then $common/mkdisk.sh -a $BR2_ARCH -n $diskimg -s $DISK_IMAGE_SIZE $bootcfg fi -load_cfg SDCARD_AUX -if [ "$SDCARD_AUX" = "y" ]; then - ixmsg "Creating initial rauc.status" - $common/mkrauc-status.sh "$BINARIES_DIR/${NAME}.pkg" >"$BINARIES_DIR/rauc.status" - ixmsg "Creating aux.ext4 for sdcard.img" - $common/mkaux.sh -fi - load_cfg GNS3_APPLIANCE if [ "$GNS3_APPLIANCE" = "y" ]; then ixmsg "Creating GNS3 Appliance, $GNS3_APPLIANCE_RAM MiB with $GNS3_APPLIANCE_IFNUM ports" diff --git a/configs/riscv64_defconfig b/configs/riscv64_defconfig index 198cd002..b4278cb8 100644 --- a/configs/riscv64_defconfig +++ b/configs/riscv64_defconfig @@ -204,7 +204,7 @@ BR2_PACKAGE_TETRIS=y BR2_PACKAGE_ROUSETTE=y BR2_PACKAGE_RAUC_INSTALLATION_STATUS=y BR2_PACKAGE_HOST_PYTHON_YANGDOC=y +IMAGE_ITB_AUX=y TRUSTED_KEYS=y TRUSTED_KEYS_DEVELOPMENT=y # GNS3_APPLIANCE is not set -SDCARD_AUX=y From aee053c94bd6d895c7cb0ceced02f900d8f43a11 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Tue, 18 Nov 2025 20:02:34 +0100 Subject: [PATCH 08/20] board/common: Move QEMU disk creation to separate make target --- board/common/Config.in | 78 +---------- board/common/image/image-itb-qcow/Config.in | 80 +++++++++++ .../image-itb-qcow/generate.sh} | 132 ++++++------------ .../image-itb-qcow}/genimage.cfg.in | 24 ++-- .../image/image-itb-qcow/image-itb-qcow.mk | 10 ++ board/common/image/ix-image.mk | 1 + board/common/mkrauc-status.sh | 35 ----- board/common/post-image.sh | 23 +-- test/env | 20 +-- test/test.mk | 8 +- test/virt/quad/topology.dot.in | 2 +- 11 files changed, 160 insertions(+), 253 deletions(-) create mode 100644 board/common/image/image-itb-qcow/Config.in rename board/common/{mkdisk.sh => image/image-itb-qcow/generate.sh} (50%) rename board/common/{ => image/image-itb-qcow}/genimage.cfg.in (86%) create mode 100644 board/common/image/image-itb-qcow/image-itb-qcow.mk delete mode 100755 board/common/mkrauc-status.sh diff --git a/board/common/Config.in b/board/common/Config.in index a484572b..3d77fef1 100644 --- a/board/common/Config.in +++ b/board/common/Config.in @@ -2,6 +2,7 @@ menu "Images" source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-rootfs/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-aux/Config.in" +source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-qcow/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-rauc/Config.in" endmenu @@ -24,83 +25,6 @@ config TRUSTED_KEYS_EXTRA_PATH string "Path to extra keys to include in image" depends on TRUSTED_KEYS -menuconfig DISK_IMAGE - bool "Disk image" - help - Compose a full disk image with redundant Linux OS partitions, - configuration partition, etc. - - This is useful when: - - Bringing up a blank system during manufacturing - - Creating a GNS3 appliance - - Developing/debugging issues in the boot process in QEMU - -menuconfig DISK_IMAGE_SIZE - string "Image size" - depends on DISK_IMAGE - default "512M" - help - Create a disk image of this size. A K/M/G suffix may be used - to multiply by powers of 1024. Suffixes like KB/MB/GB may be - used to multiply by powers of 1000. The image will be split - proportionally to fit the two rootfs, a kernel, a writable - /cfg and /var partiotions. - - Minimum supported size is 512M. - -choice - prompt "Bootloader" - depends on DISK_IMAGE - default DISK_IMAGE_BOOT_EFI if BR2_x86_64 - default DISK_IMAGE_BOOT_NONE - -config DISK_IMAGE_BOOT_NONE - bool "None" - help - Do not create any bootloader partition in the disk image. - -config DISK_IMAGE_BOOT_EFI - bool "EFI" - help - Create a boot partition from a directory containing an EFI - boot application, e.g. GRUB. - -config DISK_IMAGE_BOOT_BIN - bool "Binary" - help - Create a boot partition from a raw image containing the boot - application, e.g. U-Boot. - -endchoice - -config DISK_IMAGE_BOOT_DATA - string "Bootloader data" - depends on DISK_IMAGE - depends on DISK_IMAGE_BOOT_EFI || DISK_IMAGE_BOOT_BIN - default "${BINARIES_DIR}/efi-part/EFI" if BR2_x86_64 - help - Path to the directory or file holding the bootloader data. - -config DISK_IMAGE_BOOT_OFFSET - hex "Bootloader offset" - depends on DISK_IMAGE - depends on DISK_IMAGE_BOOT_EFI || DISK_IMAGE_BOOT_BIN - default 0x8000 - help - Offset at which the bootloader partition is placed. Remember - to make sure that the GPT still fits at the start of the - image. - -config DISK_IMAGE_RELEASE_URL - string "Infix URL" - depends on DISK_IMAGE - depends on !BR2_TARGET_ROOTFS_SQUASHFS - default "https://github.com/kernelkit/infix/releases/download/latest/infix-${BR2_ARCH}.tar.gz" - help - In situations where Infix itself is not being built, but a - disk image is, i.e. when building a bootloader: place this - Infix release in the primary and secondary partitions. - menuconfig GNS3_APPLIANCE bool "GNS3 Appliance" select DISK_IMAGE diff --git a/board/common/image/image-itb-qcow/Config.in b/board/common/image/image-itb-qcow/Config.in new file mode 100644 index 00000000..c8c55945 --- /dev/null +++ b/board/common/image/image-itb-qcow/Config.in @@ -0,0 +1,80 @@ +menuconfig IMAGE_ITB_QCOW + bool "QEMU disk image (ITB)" + default y + select IMAGE_ITB_ROOTFS + select IMAGE_ITB_AUX + select BR2_PACKAGE_HOST_GENIMAGE + help + Compose a full disk image with redundant Linux OS partitions, + configuration partition, etc., for systems using ITB images. + + This is useful when: + - Bringing up a blank system during manufacturing + - Creating a GNS3 appliance + - Developing/debugging issues in the boot process in QEMU + +menuconfig IMAGE_ITB_QCOW_SIZE + string "Image size" + depends on IMAGE_ITB_QCOW + default "512M" + help + Create a disk image of this size. A K/M/G suffix may be used + to multiply by powers of 1024. Suffixes like KB/MB/GB may be + used to multiply by powers of 1000. The image will be split + proportionally to fit the two rootfs, a kernel, a writable + /cfg and /var partiotions. + + Minimum supported size is 512M. + +choice + prompt "Bootloader" + depends on IMAGE_ITB_QCOW + default IMAGE_ITB_QCOW_BOOT_EFI if BR2_x86_64 + default IMAGE_ITB_QCOW_BOOT_NONE + +config IMAGE_ITB_QCOW_BOOT_NONE + bool "None" + help + Do not create any bootloader partition in the disk image. + +config IMAGE_ITB_QCOW_BOOT_EFI + bool "EFI" + help + Create a boot partition from a directory containing an EFI + boot application, e.g. GRUB. + +config IMAGE_ITB_QCOW_BOOT_BIN + bool "Binary" + help + Create a boot partition from a raw image containing the boot + application, e.g. U-Boot. + +endchoice + +config IMAGE_ITB_QCOW_BOOT_DATA + string "Bootloader data" + depends on IMAGE_ITB_QCOW + depends on IMAGE_ITB_QCOW_BOOT_EFI || IMAGE_ITB_QCOW_BOOT_BIN + default "${BINARIES_DIR}/efi-part/EFI" if BR2_x86_64 + help + Path to the directory or file holding the bootloader data. + +config IMAGE_ITB_QCOW_BOOT_OFFSET + hex "Bootloader offset" + depends on IMAGE_ITB_QCOW + depends on IMAGE_ITB_QCOW_BOOT_EFI || IMAGE_ITB_QCOW_BOOT_BIN + default 0x8000 + help + Offset at which the bootloader partition is placed. Remember + to make sure that the GPT still fits at the start of the + image. + +config IMAGE_ITB_QCOW_RELEASE_URL + string "Infix URL" + depends on IMAGE_ITB_QCOW + depends on !BR2_TARGET_ROOTFS_SQUASHFS + default "https://github.com/kernelkit/infix/releases/download/latest/infix-${BR2_ARCH}.tar.gz" + help + In situations where Infix itself is not being built, but a + disk image is, i.e. when building a bootloader: place this + Infix release in the primary and secondary partitions. diff --git a/board/common/mkdisk.sh b/board/common/image/image-itb-qcow/generate.sh similarity index 50% rename from board/common/mkdisk.sh rename to board/common/image/image-itb-qcow/generate.sh index dfb472b3..3969d554 100755 --- a/board/common/mkdisk.sh +++ b/board/common/image/image-itb-qcow/generate.sh @@ -1,8 +1,6 @@ #!/bin/sh set -e -. $BR2_EXTERNAL_INFIX_PATH/board/common/rootfs/etc/partition-uuid - K=10 M=20 G=30 @@ -47,43 +45,32 @@ dimension() exit 1 fi - # Size var to fit whatever is left over. Also reserve another 32K - # at the end to make room for the backup GPT. - varsize=$(($total - $auxsize - 2 * $imgsize - $cfgsize)) - if [ "$bootoffs" ]; then - varsize=$(($varsize - $bootsize)) - fi - varsize=$(($varsize - (32 << K))) + # Place aux right after the GPT... + auxoffs=$((32 << K)) if [ "$bootoffs" ]; then - # Align the end of the boot partition to an even MiB. E.g. if - # boot was dimensioned to 4M, and bootoffs is 32K, then the - # final bootsize becomes 4M - 32K, meaning aux will start on - # exactly 4M. - auxoffs=$bootsize - bootsize=$(($bootsize - $bootoffs)) - else - # No bootloader, place aux after GPT, resize it to end on an - # even MiB (as is done for boot above). - auxoffs=$((32 << K)) - auxsize=$(($auxsize - $auxoffs)) - fi -} + if [ $((bootoffs)) -lt $((32 << K)) ]; then + echo "Boot partition collides with GPT" + exit 1 + fi -probeboot() -{ - # If we have built an EFI app, typically grub, make sure to - # include it. - if [ -d $BINARIES_DIR/efi-part/EFI ]; then - bootoffs=$((32 << K)) + # ...unless we have a boot partition, in which case we place + # it after that. + auxoffs=$((auxoffs + bootsize)) fi + + # Finally, size var to fit whatever is left over by subtracting + # all other images, plus another 32K at the end for the backup + # GPT. + varsize=$((total - auxoffs - auxsize - 2 * imgsize - cfgsize - (32 << K))) } genboot() { if [ -d "$bootdata" ]; then bootimg=$(cat <$root/genimage.cfg - -mkdir -p $root/aux -cp -f $BINARIES_DIR/rootfs.itbh $root/aux/primary.itbh -cp -f $BINARIES_DIR/rootfs.itbh $root/aux/secondary.itbh -cp -f $BINARIES_DIR/rauc.status $root/aux/rauc.status - -case "$arch" in - aarch64) - mkenvimage -s 0x4000 -o "$root/aux/uboot.env" \ - "$BR2_EXTERNAL_INFIX_PATH/board/common/uboot/aux-env.txt" - ;; - x86_64) - mkdir -p "$root/aux/grub" - cp -f "$BR2_EXTERNAL_INFIX_PATH/board/$arch/grub.cfg" \ - "$BR2_EXTERNAL_INFIX_PATH/board/$arch/grubenv" \ - "$root/aux/grub/" - ;; - *) - ;; -esac - -rm -rf "$tmp" + < $PKGDIR/genimage.cfg.in >$WORKDIR/genimage.cfg genimage \ - --rootpath "$root" \ - --tmppath "$tmp" \ - --inputpath "$BINARIES_DIR" \ - --config "$root/genimage.cfg" - -qemu-img convert -c -O qcow2 "$tmpimage" "$BINARIES_DIR/$diskimg" -rm "$tmpimage" + --tmppath "${WORKDIR}"/tmp \ + --rootpath "${WORKDIR}"/root \ + --inputpath "$BINARIES_DIR" \ + --outputpath "$BINARIES_DIR" \ + --config "${WORKDIR}"/genimage.cfg diff --git a/board/common/genimage.cfg.in b/board/common/image/image-itb-qcow/genimage.cfg.in similarity index 86% rename from board/common/genimage.cfg.in rename to board/common/image/image-itb-qcow/genimage.cfg.in index 20cba95c..864b09ff 100644 --- a/board/common/genimage.cfg.in +++ b/board/common/image/image-itb-qcow/genimage.cfg.in @@ -1,16 +1,5 @@ @BOOTIMG@ -image aux.ext4 { - mountpoint = "/aux" - temporary = true - size = @AUXSIZE@ - - ext4 { - label = "aux" - use-mke2fs = true - } -} - image cfg.ext4 { empty = true temporary = true @@ -33,7 +22,8 @@ image var.ext4 { } } -image @DISKIMG@ { +image disk.img { + temporary = true size = @TOTALSIZE@ hdimage { partition-table-type = "gpt" @@ -68,5 +58,15 @@ image @DISKIMG@ { } } +image @QCOWIMG@ { + qemu { + format = "qcow2" + } + + partition disk { + image = "disk.img" + } +} + # Silence genimage warnings config {} diff --git a/board/common/image/image-itb-qcow/image-itb-qcow.mk b/board/common/image/image-itb-qcow/image-itb-qcow.mk new file mode 100644 index 00000000..98e5d05e --- /dev/null +++ b/board/common/image/image-itb-qcow/image-itb-qcow.mk @@ -0,0 +1,10 @@ +################################################################################ +# +# image-itb-qcow +# +################################################################################ + +IMAGE_ITB_QCOW_DEPENDENCIES := host-genimage image-itb-rootfs image-itb-aux +IMAGE_ITB_QCOW_CONFIG_VARS := BOOT_DATA BOOT_OFFSET SIZE + +$(eval $(ix-image)) diff --git a/board/common/image/ix-image.mk b/board/common/image/ix-image.mk index d20894cd..2da7cc2f 100644 --- a/board/common/image/ix-image.mk +++ b/board/common/image/ix-image.mk @@ -10,6 +10,7 @@ $(1): $$($(2)_DEPENDENCIES) PKGDIR=$$($(2)_DIR) \ WORKDIR=$$(BUILD_DIR)/$(1) \ BINARIES_DIR=$$(BINARIES_DIR) \ + BR2_EXTERNAL_INFIX_PATH=$$(BR2_EXTERNAL_INFIX_PATH) \ ARTIFACT=$$(INFIX_ARTIFACT) \ COMPATIBLE=$$(INFIX_COMPATIBLE) \ VERSION=$$(INFIX_VERSION) \ diff --git a/board/common/mkrauc-status.sh b/board/common/mkrauc-status.sh deleted file mode 100755 index 0560e79c..00000000 --- a/board/common/mkrauc-status.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh - -set -e - -# Bootstrap a RAUC status file showing the newly created image -# installed to both the primary and secondary slots. This then bundled -# in the aux partition in mkdisk.sh, so that RAUC (on the target) can -# always report the installed versions. -rauc info --no-verify --output-format=shell $1 >/tmp/rauc-$$.info -. /tmp/rauc-$$.info -rm /tmp/rauc-$$.info -tstamp=$(date -u +%FT%TZ) -cat <"$BINARIES_DIR/rauc.status" - $common/mkdisk.sh -a $BR2_ARCH -n $diskimg -s $DISK_IMAGE_SIZE $bootcfg -fi +diskimg="${NAME}$(ver).qcow2" load_cfg GNS3_APPLIANCE if [ "$GNS3_APPLIANCE" = "y" ]; then diff --git a/test/env b/test/env index b89e21ea..56fca5ef 100755 --- a/test/env +++ b/test/env @@ -74,7 +74,7 @@ get_base_img() { local files="$1" local base_img_file - base_img_file=$(echo "$files" | tr ' ' '\n' | grep -- '-disk.qcow2$') + base_img_file=$(echo "$files" | tr ' ' '\n' | grep -- '.qcow2$') echo "$envdir/qeneth/$(basename "$base_img_file")" } @@ -95,16 +95,16 @@ start_topology() ln -sf "$file" "$envdir/qeneth/$filename" done - base_img=$(get_base_img "$files") - test_img_name="${base_img%-disk.qcow2}-disk-test" - base_img_name="${base_img%-disk.qcow2}-disk" - test_img_raw="${test_img_name}.img" - base_img_raw="${base_img_name}.img" - test_img_qcow2="${test_img_name}.qcow2" + base_img_qcow2=$(get_base_img "$files") + base_img_disk="${base_img_qcow2%.qcow2}.disk" + + test_img_disk="${base_img_qcow2%.qcow2}-test.disk" + test_img_qcow2="${test_img_disk%.disk}.qcow2" + + qemu-img convert -f qcow2 -O raw "$base_img_qcow2" "$base_img_disk" + $testdir/inject-test-mode -b "$base_img_disk" -o "$test_img_disk" + qemu-img convert -f raw -O qcow2 "$test_img_disk" "$test_img_qcow2" - qemu-img convert -f qcow2 -O raw "$base_img" "$base_img_raw" - $testdir/inject-test-mode -b "$base_img_raw" -o "$test_img_raw" - qemu-img convert -f raw -O qcow2 "$test_img_raw" "$test_img_qcow2" img_name=$(basename $test_img_qcow2) sed -i "s/qn_image=\".*\"/qn_image=\"$img_name\"/" "$envdir/qeneth/topology.dot.in" diff --git a/test/test.mk b/test/test.mk index 85f3f4bb..ba4b7293 100644 --- a/test/test.mk +++ b/test/test.mk @@ -17,11 +17,11 @@ mode-qeneth := -q $(test-dir)/virt/quad mode-host := -t $(or $(TOPOLOGY),/etc/infamy.dot) mode-run := -t $(BINARIES_DIR)/qemu.dot mode := $(mode-$(TEST_MODE)) -INFIX_IMAGE_ID := $(call qstrip,$(INFIX_IMAGE_ID)) -binaries-$(ARCH) := $(addprefix $(INFIX_IMAGE_ID),.img -disk.qcow2) -pkg-$(ARCH) := -p $(O)/images/$(addprefix $(INFIX_IMAGE_ID),.pkg) + +pkg-$(ARCH) := -p $(O)/images/$(INFIX_ARTIFACT).pkg +binaries-$(ARCH) := $(INFIX_ARTIFACT).qcow2 binaries-x86_64 += OVMF.fd -binaries := $(foreach bin,$(binaries-$(ARCH)),-f $(BINARIES_DIR)/$(bin)) +binaries := $(foreach bin,$(binaries-$(ARCH)),-f $(BINARIES_DIR)/$(bin)) # Common transport override for minimal defconfigs ifneq ($(BR2_PACKAGE_ROUSETTE),y) diff --git a/test/virt/quad/topology.dot.in b/test/virt/quad/topology.dot.in index 549456d4..1242b0ea 100644 --- a/test/virt/quad/topology.dot.in +++ b/test/virt/quad/topology.dot.in @@ -9,7 +9,7 @@ graph "quad" { edge [color="cornflowerblue", penwidth="2"]; qn_template="infix-bios-x86_64"; - qn_image="infix-x86_64-disk-test.qcow2" + qn_image="infix-x86_64-test.qcow2" qn_oui="00:a0:85"; qn_append="quiet"; From 046a736dc9e79aa3ebd35831227ff0b1f84efcce Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Tue, 18 Nov 2025 20:40:57 +0100 Subject: [PATCH 09/20] board/common: Remove broken "Traditional FIT image" We have not installed .dtb:s to $O/images/ for quite some time, and nobody cared. That goes to show that this is not really used. The image is still useful at times, so if it needed in the future, then we can resurrect it from the logs and refactor it to an image package. --- board/aarch64/board.mk | 7 --- board/common/Config.in | 21 ------- board/common/mkfit.sh | 118 ------------------------------------- board/common/post-image.sh | 6 -- 4 files changed, 152 deletions(-) delete mode 100755 board/common/mkfit.sh diff --git a/board/aarch64/board.mk b/board/aarch64/board.mk index 9b6c82a9..287d9b41 100644 --- a/board/aarch64/board.mk +++ b/board/aarch64/board.mk @@ -20,13 +20,6 @@ board-enable-qemu-uboot: '$$(BR2_EXTERNAL_INFIX_PATH)/board/common/uboot/extras.config' \ --enable TARGET_UBOOT_FORMAT_DTB -.PHONY: board-enable-sparx-fit -board-enable-sparx-fit: - @$(call IXMSG,"Enabling SparX-5i compatible FIT options") - @BR2_PREFIX= ./utils/config --file $(BR2_CONFIG) \ - --enable FIT_IMAGE \ - --set-str FIT_KERNEL_LOAD_ADDR "0x7 0x00000000" - .PHONY: board-sparx-flash-uboot board-sparx-flash-uboot: $(BINARIES_DIR)/u-boot.bin @grep -q 'BR2_TARGET_UBOOT_BOARD_DEFCONFIG="mscc_fireant_pcb135_emmc"' $(BR2_CONFIG) || \ diff --git a/board/common/Config.in b/board/common/Config.in index 3d77fef1..de3521cd 100644 --- a/board/common/Config.in +++ b/board/common/Config.in @@ -48,24 +48,3 @@ config GNS3_APPLIANCE_IFNUM default "1" help Number of Ethernet interfaces to create for an appliance instance. - -menuconfig FIT_IMAGE - bool "Traditional FIT image" - help - Create a "regular" FIT image where the kernel and DTBs are - stored in the FIT rather than inside the rootfs (like it - normally is in Infix). - - This is useful when trying out Infix on targets whose - bootloader might not be capable of booting a raw Squash, but - is able to handle an FIT. - -config FIT_ARCH - string - depends on FIT_IMAGE - default "arm64" if BR2_aarch64 - -config FIT_KERNEL_LOAD_ADDR - string "Kernel load address" - depends on FIT_IMAGE - diff --git a/board/common/mkfit.sh b/board/common/mkfit.sh deleted file mode 100755 index c0e132ad..00000000 --- a/board/common/mkfit.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/sh - -die() -{ - echo "$@" >&2 - exit 1 -} - -load_cfg() -{ - local tmp=$(mktemp -p /tmp) - - grep ^FIT_ $BR2_CONFIG >$tmp - . $tmp - rm $tmp -} - -load_cfg -[ "$FIT_IMAGE" = "y" ] || exit 0 - -work=$BUILD_DIR/fit-image-local -dtbs=$(find $BINARIES_DIR -name '*.dtb') -kernel=$(find $BINARIES_DIR -name '*Image' | head -n1) -squash=$BINARIES_DIR/rootfs.squashfs - -mkdir -p $work -gzip <$kernel >$work/Image.gz -kernel=$work/Image.gz - -rm -rf $work/rootfs -unsquashfs -f -d $work/rootfs $squash -rm -f $work/rootfs/boot/*Image - -squash=$work/rootfs-no-kernel.squashfs -rm -f $squash -mksquashfs $work/rootfs $squash - -# mkimage will only align images to 4 bytes, but U-Boot will leave -# both DTB and ramdisk in place when starting the kernel. So we pad -# all components up to a 4k boundary. -truncate -s %4k $kernel $dtbs - -: >$work/dtbs.itsi -: >$work/cfgs.itsi -for dtb in $dtbs; do - name=$(basename $dtb .dtb) - - cat <>$work/dtbs.itsi - $name-dtb { - description = "$name"; - type = "flat_dt"; - arch = "$FIT_ARCH"; - compression = "none"; - data = /incbin/("$dtb"); - }; -EOF - cat <>$work/cfgs.itsi - $name { - description = "$name"; - kernel = "kernel"; - ramdisk = "ramdisk"; - fdt = "$name-dtb"; - }; -EOF -done - -: >$work/kernel-load.itsi -if [ "$FIT_KERNEL_LOAD_ADDR" ]; then - cat <$work/kernel-load.itsi - load = <$FIT_KERNEL_LOAD_ADDR>; - entry = <$FIT_KERNEL_LOAD_ADDR>; -EOF -fi - -cat <$work/infix.its -/dts-v1/; - -/ { - timestamp = <$(date +%s)>; - description = "Infix ($FIT_ARCH)"; - creator = "infix"; - #address-cells = <0x1>; - - images { - - kernel { - description = "Linux"; - type = "kernel"; - arch = "$FIT_ARCH"; - os = "linux"; -$(cat $work/kernel-load.itsi) - compression = "gzip"; - data = /incbin/("$kernel"); - }; - - ramdisk { - description = "Infix"; - type = "ramdisk"; - os = "linux"; - arch = "$FIT_ARCH"; - compression = "none"; - data = /incbin/("$squash"); - }; - -$(cat $work/dtbs.itsi) - - }; - - configurations { -$(cat $work/cfgs.itsi) - }; -}; -EOF - -mkimage \ - -E -p 0x1000 \ - -f $work/infix.its $BINARIES_DIR/infix.itb \ - || die "Unable to create FIT image" diff --git a/board/common/post-image.sh b/board/common/post-image.sh index d4420062..be4c9c62 100755 --- a/board/common/post-image.sh +++ b/board/common/post-image.sh @@ -39,12 +39,6 @@ if [ "$GNS3_APPLIANCE" = "y" ]; then $common/mkgns3a.sh $BR2_ARCH $NAME $diskimg $GNS3_APPLIANCE_RAM $GNS3_APPLIANCE_IFNUM fi -load_cfg FIT_IMAGE -if [ "$FIT_IMAGE" = "y" ]; then - ixmsg "Creating Traditional FIT Image" - $common/mkfit.sh -fi - # Only for regular builds, not bootloader-only builds if [ "$BR2_TARGET_ROOTFS_SQUASHFS" = "y" ]; then rel=$(ver) From 065c1312853f009954cef817c08d567b86b712f2 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Tue, 18 Nov 2025 22:44:40 +0100 Subject: [PATCH 10/20] board/common: Move GNS3 appliance creation to separate make target Limit support to x86, like we do on the "official" appliances on the marketplace. Aarch64 has never really been used AFAIK. Avoid the os-release import, since all that info is not important now that these appliance files are only for development scenarios. In all other cases, the official one, based on a proper release, should be used. --- board/common/Config.in | 25 +---- board/common/image/image-itb-gns3a/Config.in | 23 ++++ .../common/image/image-itb-gns3a/generate.sh | 59 ++++++++++ .../image/image-itb-gns3a/image-itb-gns3a.mk | 10 ++ board/common/mkgns3a.sh | 103 ------------------ board/common/post-image.sh | 6 - 6 files changed, 93 insertions(+), 133 deletions(-) create mode 100644 board/common/image/image-itb-gns3a/Config.in create mode 100755 board/common/image/image-itb-gns3a/generate.sh create mode 100644 board/common/image/image-itb-gns3a/image-itb-gns3a.mk delete mode 100755 board/common/mkgns3a.sh diff --git a/board/common/Config.in b/board/common/Config.in index de3521cd..3af7c388 100644 --- a/board/common/Config.in +++ b/board/common/Config.in @@ -3,6 +3,7 @@ menu "Images" source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-rootfs/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-aux/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-qcow/Config.in" +source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-gns3a/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-rauc/Config.in" endmenu @@ -24,27 +25,3 @@ config TRUSTED_KEYS_DEVELOPMENT_PATH config TRUSTED_KEYS_EXTRA_PATH string "Path to extra keys to include in image" depends on TRUSTED_KEYS - -menuconfig GNS3_APPLIANCE - bool "GNS3 Appliance" - select DISK_IMAGE - default y - help - Create a GNS3 appliance description that, together with the - disk image, can be imported into GNS3. - -config GNS3_APPLIANCE_RAM - int "Reserved RAM (MiB)" - depends on GNS3_APPLIANCE - default "192" - help - Amount of host RAM reserved for an appliance instance. - - Minimum supported size is 192M. - -config GNS3_APPLIANCE_IFNUM - int "Number of interfaces" - depends on GNS3_APPLIANCE - default "1" - help - Number of Ethernet interfaces to create for an appliance instance. diff --git a/board/common/image/image-itb-gns3a/Config.in b/board/common/image/image-itb-gns3a/Config.in new file mode 100644 index 00000000..5afe2392 --- /dev/null +++ b/board/common/image/image-itb-gns3a/Config.in @@ -0,0 +1,23 @@ +menuconfig IMAGE_ITB_GNS3A + bool "GNS3 Appliance (ITB)" + depends on BR2_x86_64 + select IMAGE_ITB_QCOW + help + Create a GNS3 appliance description that, together with the + disk image, can be imported into GNS3. + +config IMAGE_ITB_GNS3A_RAM + int "Reserved RAM (MiB)" + depends on IMAGE_ITB_GNS3A + default "192" + help + Amount of host RAM reserved for an appliance instance. + + Minimum supported size is 192M. + +config IMAGE_ITB_GNS3A_IFNUM + int "Number of interfaces" + depends on IMAGE_ITB_GNS3A + default "1" + help + Number of Ethernet interfaces to create for an appliance instance. diff --git a/board/common/image/image-itb-gns3a/generate.sh b/board/common/image/image-itb-gns3a/generate.sh new file mode 100755 index 00000000..ada7ce95 --- /dev/null +++ b/board/common/image/image-itb-gns3a/generate.sh @@ -0,0 +1,59 @@ +#!/bin/sh + +set -e + +bios="${BINARIES_DIR}"/OVMF.fd +qcow="${BINARIES_DIR}"/"${ARTIFACT}".qcow2 +gns3a="${BINARIES_DIR}"/"${ARTIFACT}".gns3a + +cat <"${gns3a}" +{ + "name": "${ARTIFACT} devel", + "category": "router", + "description": "${ARTIFACT} development appliance", + "vendor_name": "Kernelkit", + "vendor_url": "https://kernelkit.org", + "product_name": "${ARTIFACT} devel", + "registry_version": 6, + "status": "experimental", + "maintainer": "Kernelkit", + "maintainer_email": "null@kernelkit.org", + "usage": "Default login, user/pass: admin/admin\n\nType 'cli' (and Enter) followed by 'help' for an overview of commands and relevant configuration files.", + "port_name_format": "eth{0}", + "linked_clone": true, + "qemu": { + "adapter_type": "virtio-net-pci", + "adapters": ${IFNUM}, + "ram": ${RAM}, + "cpus": 1, + "hda_disk_interface": "virtio", + "arch": "x86_64", + "console_type": "telnet", + "bios_image": "$(basename ${bios})", + "kvm": "allow" + }, + "images": [ + { + "filename": "$(basename "${bios}")", + "filesize": $(stat --printf='%s' "${bios}"), + "md5sum": "$(md5sum "${bios}" | awk '{print $1}')", + "version": "0.0" + }, + { + "filename": "$(basename "${qcow}")", + "filesize": $(stat --printf='%s' "${qcow}"), + "md5sum": "$(md5sum "${qcow}" | awk '{print $1}')", + "version": "${VERSION}" + } + ], + "versions": [ + { + "name": "${VERSION}", + "images": { + "bios_image": "$(basename ${bios})", + "hda_disk_image": "$(basename ${qcow})" + } + } + ] +} +EOF diff --git a/board/common/image/image-itb-gns3a/image-itb-gns3a.mk b/board/common/image/image-itb-gns3a/image-itb-gns3a.mk new file mode 100644 index 00000000..d4598a0f --- /dev/null +++ b/board/common/image/image-itb-gns3a/image-itb-gns3a.mk @@ -0,0 +1,10 @@ +################################################################################ +# +# image-itb-gns3a +# +################################################################################ + +IMAGE_ITB_GNS3A_DEPENDENCIES := image-itb-qcow +IMAGE_ITB_GNS3A_CONFIG_VARS := IFNUM RAM + +$(eval $(ix-image)) diff --git a/board/common/mkgns3a.sh b/board/common/mkgns3a.sh deleted file mode 100755 index 35d46d81..00000000 --- a/board/common/mkgns3a.sh +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/sh -# shellcheck disable=SC1091 -. "$TARGET_DIR/etc/os-release" - -if [ -n "$INFIX_RELEASE" ]; then - rel="-${INFIX_RELEASE}" -fi - -ARCH=$1 -NM="${2:-custom}${rel}" -DISK=$3 -RAM=${4:-512} -IFNUM=${5:-1} - -# The aarch64 build currently has no "loader" but instead starts Linux -# directly, so we need to add a basic cmdline. -loader_args() -{ - if [ "$ARCH" = "aarch64" ]; then - cat <> Disk image MD5: $(md5sum "$BINARIES_DIR/$DISK" | awk '{print $1}')" - -cat <"$BINARIES_DIR/${NM}.gns3a" -{ - "name": "$NM", - "category": "router", - "description": "$INFIX_DESC", - "vendor_name": "$VENDOR_NAME", - "vendor_url": "$VENDOR_HOME", - "product_name": "$NAME", - "registry_version": 6, - "status": "stable", - "maintainer": "$VENDOR_NAME", - "maintainer_email": "${SUPPORT_URL#mailto:}", - "usage": "Default login, user/pass: admin/admin\n\nType 'cli' (and Enter) followed by 'help' for an overview of commands and relevant configuration files.", - "port_name_format": "eth{0}", - "linked_clone": true, - "qemu": { - "adapter_type": "virtio-net-pci", - "adapters": ${IFNUM}, - "ram": ${RAM}, - "cpus": 1, - "hda_disk_interface": "virtio", - "arch": "$ARCH", - "console_type": "telnet", - $(loader_img) - $(loader_args) - "kvm": "$accel", - "options": "$opts" - }, - "images": [ - { - "filename": "$loader", - "filesize": $(stat --printf='%s' "$BINARIES_DIR/$loader"), - "md5sum": "$(md5sum "$BINARIES_DIR/$loader" | awk '{print $1}')", - "version": "0.0" - }, - { - "filename": "$DISK", - "filesize": $(stat --printf='%s' "$BINARIES_DIR/$DISK"), - "md5sum": "$(md5sum "$BINARIES_DIR/$DISK" | awk '{print $1}')", - "version": "0.0" - } - ], - "versions": [ - { - "name": "0.0", - "images": { - $(loader_img) - "hda_disk_image": "$DISK" - } - } - ] -} -EOF diff --git a/board/common/post-image.sh b/board/common/post-image.sh index be4c9c62..e6795eae 100755 --- a/board/common/post-image.sh +++ b/board/common/post-image.sh @@ -33,12 +33,6 @@ ver() diskimg="${NAME}$(ver).qcow2" -load_cfg GNS3_APPLIANCE -if [ "$GNS3_APPLIANCE" = "y" ]; then - ixmsg "Creating GNS3 Appliance, $GNS3_APPLIANCE_RAM MiB with $GNS3_APPLIANCE_IFNUM ports" - $common/mkgns3a.sh $BR2_ARCH $NAME $diskimg $GNS3_APPLIANCE_RAM $GNS3_APPLIANCE_IFNUM -fi - # Only for regular builds, not bootloader-only builds if [ "$BR2_TARGET_ROOTFS_SQUASHFS" = "y" ]; then rel=$(ver) From 516313b48947106720819768cde7fb4a37f0f98d Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 19 Nov 2025 16:46:41 +0100 Subject: [PATCH 11/20] board/common: Move QEMU script generation to separate make target --- board/common/Config.in | 8 +++++ board/common/common.mk | 1 + board/common/post-image.sh | 11 ------- board/common/qemu/Config.in.in | 12 +++---- board/common/qemu/qemu.mk | 45 +++++++++++++++++++++++++++ board/common/qemu/{qemu.sh => run.sh} | 31 ++++++------------ external.mk | 9 ------ 7 files changed, 70 insertions(+), 47 deletions(-) create mode 100644 board/common/qemu/qemu.mk rename board/common/qemu/{qemu.sh => run.sh} (95%) diff --git a/board/common/Config.in b/board/common/Config.in index 3af7c388..ce3fe125 100644 --- a/board/common/Config.in +++ b/board/common/Config.in @@ -8,6 +8,14 @@ source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-rauc/Config.in" endmenu +config QEMU_SCRIPTS + bool "QEMU scripts" + default y + help + Install QEMU scripts and related files in the images + directory, which can be used to launch virtual Infix + instances. + menuconfig TRUSTED_KEYS bool "Trusted keys for image" help diff --git a/board/common/common.mk b/board/common/common.mk index 8cbf082f..2fcfe2d4 100644 --- a/board/common/common.mk +++ b/board/common/common.mk @@ -1,4 +1,5 @@ include $(BR2_EXTERNAL_INFIX_PATH)/board/common/image/image.mk +include $(BR2_EXTERNAL_INFIX_PATH)/board/common/qemu/qemu.mk ifeq ($(TRUSTED_KEYS),y) include $(BR2_EXTERNAL_INFIX_PATH)/board/common/uboot/uboot.mk diff --git a/board/common/post-image.sh b/board/common/post-image.sh index e6795eae..86c82c86 100755 --- a/board/common/post-image.sh +++ b/board/common/post-image.sh @@ -43,17 +43,6 @@ if [ "$BR2_TARGET_ROOTFS_SQUASHFS" = "y" ]; then cp "$BR2_EXTERNAL_INFIX_PATH/board/common/rootfs/usr/bin/onieprom" "$BINARIES_DIR/" - # Menuconfig support for modifying Qemu args in release tarballs - cp "$BR2_EXTERNAL_INFIX_PATH/board/common/qemu/qemu.sh" "$BINARIES_DIR/" - sed -e "s/@ARCH@/QEMU_$BR2_ARCH/" \ - -e "s/@DISK_IMG@/$diskimg/" \ - < "$BR2_EXTERNAL_INFIX_PATH/board/common/qemu/Config.in.in" \ - > "$BINARIES_DIR/Config.in" - rm -f "$BINARIES_DIR/qemu.cfg" - CONFIG_="CONFIG_" BR2_CONFIG="$BINARIES_DIR/qemu.cfg" \ - "$O/build/buildroot-config/conf" --olddefconfig "$BINARIES_DIR/Config.in" - rm -f "$BINARIES_DIR/qemu.cfg.old" "$BINARIES_DIR/.config.old" - # Quick intro for beginners, with links to more information cp "$BR2_EXTERNAL_INFIX_PATH/board/common/README.txt" "$BINARIES_DIR/" fi diff --git a/board/common/qemu/Config.in.in b/board/common/qemu/Config.in.in index e105b98d..4c4356d9 100644 --- a/board/common/qemu/Config.in.in +++ b/board/common/qemu/Config.in.in @@ -99,20 +99,20 @@ config QEMU_MACHINE_RAM config QEMU_KERNEL string depends on QEMU_LOADER_KERNEL - default "zImage" if QEMU_arm - default "Image" if QEMU_aarch64 - default "bzImage" if QEMU_x86_64 + default "../zImage" if QEMU_arm + default "../Image" if QEMU_aarch64 + default "../bzImage" if QEMU_x86_64 config QEMU_BIOS string depends on !QEMU_LOADER_KERNEL - default "u-boot.bin" if QEMU_LOADER_UBOOT - default "OVMF.fd" if QEMU_LOADER_OVMF + default "../u-boot.bin" if QEMU_LOADER_UBOOT + default "../OVMF.fd" if QEMU_LOADER_OVMF config QEMU_ROOTFS string default "@DISK_IMG@" if !QEMU_ROOTFS_INITRD - default "rootfs.squashfs" if QEMU_ROOTFS_INITRD + default "../rootfs.squashfs" if QEMU_ROOTFS_INITRD config QEMU_DTB_EXTEND bool diff --git a/board/common/qemu/qemu.mk b/board/common/qemu/qemu.mk new file mode 100644 index 00000000..336507aa --- /dev/null +++ b/board/common/qemu/qemu.mk @@ -0,0 +1,45 @@ +################################################################################ +# +# qemu-scripts +# +################################################################################ + +QEMU_SCRIPTS_DIR := $(pkgdir) +qemu-kconfig = \ + CONFIG_="CONFIG_" \ + BR2_CONFIG="$(BINARIES_DIR)/qemu/.config" \ + $(BUILD_DIR)/buildroot-config/$(1) $(2) "$(BINARIES_DIR)/qemu/Config.in" + +ifeq ($(QEMU_SCRIPTS),y) + +.PHONY: run +run: + @$(BINARIES_DIR)/qemu/run.sh + +.PHONY: run-menuconfig +run-menuconfig: $(BUILD_DIR)/buildroot-config/mconf + @$(call qemu-kconfig,mconf) + +qemu-scripts: \ + $(BINARIES_DIR)/qemu/run.sh \ + $(BINARIES_DIR)/qemu/Config.in \ + $(BINARIES_DIR)/qemu/.config + +$(BINARIES_DIR)/qemu/run.sh: $(QEMU_SCRIPTS_DIR)/run.sh + @$(call IXMSG,"Installing QEMU scripts") + @mkdir -p $(dir $@) + @cp $< $@ + +$(BINARIES_DIR)/qemu/Config.in: $(QEMU_SCRIPTS_DIR)/Config.in.in + @mkdir -p $(dir $@) + @sed \ + -e "s:@ARCH@:QEMU_$(BR2_ARCH):" \ + -e "s:@DISK_IMG@:../$(INFIX_ARTIFACT).qcow2:" \ + < $< >$@ + +$(BINARIES_DIR)/qemu/.config: $(BINARIES_DIR)/qemu/Config.in + @$(call qemu-kconfig,conf,--olddefconfig) + @rm -f $@.old + +TARGETS_ROOTFS += qemu-scripts +endif diff --git a/board/common/qemu/qemu.sh b/board/common/qemu/run.sh similarity index 95% rename from board/common/qemu/qemu.sh rename to board/common/qemu/run.sh index 9deb2c4c..48052c53 100755 --- a/board/common/qemu/qemu.sh +++ b/board/common/qemu/run.sh @@ -19,8 +19,8 @@ # # shellcheck disable=SC3037 -# Local variables -imgdir=$(readlink -f "$(dirname "$0")") +qdir=$(dirname "$(readlink -f "$0")") +imgdir=$(readlink -f "${qdir}/..") prognm=$(basename "$0") usage() @@ -56,12 +56,8 @@ die() load_qemucfg() { - tmp=$(mktemp -p /tmp) - - grep ^CONFIG_QEMU_ "$1" >"$tmp" # shellcheck disable=SC1090 - . "$tmp" - rm "$tmp" + . "./.config" [ "$CONFIG_QEMU_MACHINE" ] || die "Missing QEMU_MACHINE" [ "$CONFIG_QEMU_ROOTFS" ] || die "Missing QEMU_ROOTFS" @@ -247,7 +243,7 @@ rocker_port_args() net_args() { # Infix will pick up this file via fwcfg and install it to /etc - mactab=${imgdir}/mactab + mactab=${qdir}/mactab :> "$mactab" echo -n "-fw_cfg name=opt/mactab,file=$mactab " @@ -286,7 +282,7 @@ vpd_args() { [ "$CONFIG_QEMU_VPD" = "y" ] || return - vpd_file="${imgdir}/vpd" + vpd_file="${qdir}/vpd" if ! [ -f "$vpd_file" ]; then onieprom="${imgdir}/onieprom" @@ -430,7 +426,7 @@ dtb_args() # Extend it with the environment and signing information in # u-boot.dtb. - echo "qemu.dtb u-boot.dtb" | \ + echo "qemu.dtb ../u-boot.dtb" | \ xargs -n 1 dtc -I dtb -O dts | \ { echo "/dts-v1/;"; sed -e 's:/dts-v[0-9]\+/;::'; } | \ dtc >qemu-extended.dtb 2>/dev/null @@ -439,7 +435,7 @@ dtb_args() echo -n "-dtb qemu-extended.dtb " else # Otherwise we just use the unmodified one - echo -n "-dtb u-boot.dtb " + echo -n "-dtb ../u-boot.dtb " fi } @@ -485,13 +481,12 @@ EOF menuconfig() { - grep -q QEMU_MACHINE Config.in || die "$prognm: must be run from the output/images directory" + grep -q QEMU_MACHINE Config.in || die "$prognm: must be run from the $$O/images/qemu directory" command -v kconfig-mconf >/dev/null || die "$prognm: cannot find kconfig-mconf for menuconfig" exec kconfig-mconf Config.in } -scriptdir=$(dirname "$(readlink -f "$0")") -cd "$scriptdir" || (echo "Failed cd to $scriptdir"; exit 1) +cd "$qdir" || (echo "Failed cd to $qdir"; exit 1) while [ "$1" != "" ]; do case $1 in @@ -510,13 +505,7 @@ while [ "$1" != "" ]; do shift done -if [ -f .config ]; then - # Customized settings from 'qemu.sh -c' - load_qemucfg .config -else - # Shipped defaults from release tarball - load_qemucfg qemu.cfg -fi +load_qemucfg if [ -z "$QEMU_EXTRA_APPEND" ]; then QEMU_EXTRA_APPEND="$*" diff --git a/external.mk b/external.mk index 54fdd6e4..20d65312 100644 --- a/external.mk +++ b/external.mk @@ -8,15 +8,6 @@ local.mk: @$(call IXMSG,"Installing local override for certain packages") @(cd $O && ln -s $(BR2_EXTERNAL_INFIX_PATH)/local.mk .) -.PHONY: run -run: - @$(BINARIES_DIR)/qemu.sh - -.PHONY: run-menuconfig -run-menuconfig: $(BUILD_DIR)/buildroot-config/mconf - CONFIG_="CONFIG_" BR2_CONFIG="$(BINARIES_DIR)/.config" \ - $(BUILD_DIR)/buildroot-config/mconf $(BINARIES_DIR)/Config.in - # # Buildroot package extensions # From 6e485ccb53176f41244e565d8728fcc8c93db127 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 19 Nov 2025 16:49:59 +0100 Subject: [PATCH 12/20] board/common: Skip unused infix-branded symlink to rootfs.squashfs This is an internal artifact, so there is no need to give it a branded name. --- board/common/post-image.sh | 39 -------------------------------------- 1 file changed, 39 deletions(-) diff --git a/board/common/post-image.sh b/board/common/post-image.sh index 86c82c86..b226b484 100755 --- a/board/common/post-image.sh +++ b/board/common/post-image.sh @@ -1,46 +1,7 @@ #!/bin/sh -# shellcheck disable=SC2086 - -common=$(dirname "$(readlink -f "$0")") -. "$common/lib.sh" - -# shellcheck disable=SC1091 -. "$TARGET_DIR/etc/os-release" - -# The INFIX_* variables may be composed from BR2_* variables, -# so we source them last. -load_cfg BR2_ARCH -load_cfg BR2_DEFCONFIG -load_cfg BR2_EXTERNAL_INFIX_PATH -load_cfg BR2_TARGET_ROOTFS -load_cfg INFIX_ID - -# The default IMAGE_ID is infix-$BR2_ARCH but can be overridden -# for imaage names, and compat strings, like infix-r2s -if [ -n "$IMAGE_ID" ]; then - NAME="$IMAGE_ID" -else - NAME="$INFIX_ID"-$(echo "$BR2_ARCH" | tr _ - | sed 's/x86-64/x86_64/') -fi - -ver() -{ - if [ -n "$INFIX_RELEASE" ]; then - printf -- "-%s" "${INFIX_RELEASE#v}" - return - fi -} - -diskimg="${NAME}$(ver).qcow2" # Only for regular builds, not bootloader-only builds if [ "$BR2_TARGET_ROOTFS_SQUASHFS" = "y" ]; then - rel=$(ver) - ln -sf rootfs.squashfs "$BINARIES_DIR/${NAME}${rel}.img" - if [ -n "$rel" ]; then - ln -sf "${NAME}${rel}.img" "$BINARIES_DIR/${NAME}.img" - fi - cp "$BR2_EXTERNAL_INFIX_PATH/board/common/rootfs/usr/bin/onieprom" "$BINARIES_DIR/" # Quick intro for beginners, with links to more information From ceb9c0bb6f4b18f6818a99d4538bbe8052c087fe Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 19 Nov 2025 16:56:17 +0100 Subject: [PATCH 13/20] board/common: Remove unused MMC image creation script Remnants from the olde country. --- board/common/mkmmc.sh | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100755 board/common/mkmmc.sh diff --git a/board/common/mkmmc.sh b/board/common/mkmmc.sh deleted file mode 100755 index 88549630..00000000 --- a/board/common/mkmmc.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -set -e - -common=$(dirname $(readlink -f "$0")) -root=$BUILD_DIR/genimage.root -tmp=$BUILD_DIR/genimage.tmp - - -mkdir -p $root/aux -cp -f $BINARIES_DIR/uboot-env.bin $root/aux/uboot.env -cp -f $BINARIES_DIR/rootfs.itbh $root/aux/primary.itbh -cp -f $BINARIES_DIR/rootfs.itbh $root/aux/secondary.itbh - -rm -rf $tmp - -genimage \ - --rootpath $root \ - --tmppath $tmp \ - --inputpath $BINARIES_DIR \ - --outputpath $BINARIES_DIR \ - --config $common/genimage.cfg From 94f5463504def94b695574f148a926f4f578f10b Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 19 Nov 2025 20:32:28 +0100 Subject: [PATCH 14/20] onieprom: Create proper package --- board/common/post-image.sh | 2 - .../rootfs/usr/libexec/infix/init.d/00-probe | 4 +- package/Config.in | 1 + package/onieprom/Config.in | 15 + package/onieprom/onieprom | 4 + package/onieprom/onieprom.mk | 15 + src/onieprom/COPYING | 339 ++++++++++++++++++ src/onieprom/onieprom/__init__.py | 2 + src/onieprom/onieprom/__main__.py | 38 ++ .../onieprom => src/onieprom/onieprom/tlv.py | 38 -- src/onieprom/pyproject.toml | 18 + 11 files changed, 434 insertions(+), 42 deletions(-) create mode 100644 package/onieprom/Config.in create mode 100755 package/onieprom/onieprom create mode 100644 package/onieprom/onieprom.mk create mode 100644 src/onieprom/COPYING create mode 100644 src/onieprom/onieprom/__init__.py create mode 100644 src/onieprom/onieprom/__main__.py rename board/common/rootfs/usr/bin/onieprom => src/onieprom/onieprom/tlv.py (80%) mode change 100755 => 100644 create mode 100644 src/onieprom/pyproject.toml diff --git a/board/common/post-image.sh b/board/common/post-image.sh index b226b484..bc36026a 100755 --- a/board/common/post-image.sh +++ b/board/common/post-image.sh @@ -2,8 +2,6 @@ # Only for regular builds, not bootloader-only builds if [ "$BR2_TARGET_ROOTFS_SQUASHFS" = "y" ]; then - cp "$BR2_EXTERNAL_INFIX_PATH/board/common/rootfs/usr/bin/onieprom" "$BINARIES_DIR/" - # Quick intro for beginners, with links to more information cp "$BR2_EXTERNAL_INFIX_PATH/board/common/README.txt" "$BINARIES_DIR/" fi diff --git a/board/common/rootfs/usr/libexec/infix/init.d/00-probe b/board/common/rootfs/usr/libexec/infix/init.d/00-probe index 221ca0bd..d7067127 100755 --- a/board/common/rootfs/usr/libexec/infix/init.d/00-probe +++ b/board/common/rootfs/usr/libexec/infix/init.d/00-probe @@ -1,13 +1,13 @@ #!/usr/bin/env python3 -import importlib.machinery + import json +import onieprom import os import shutil import struct import subprocess import sys -onieprom = importlib.machinery.SourceFileLoader("onieprom", "/bin/onieprom").load_module() SYSTEM_JSON = "/run/system.json" KKIT_IANA_PEM = 61046 diff --git a/package/Config.in b/package/Config.in index e9de36d7..b0e9a8c5 100644 --- a/package/Config.in +++ b/package/Config.in @@ -29,6 +29,7 @@ source "$BR2_EXTERNAL_INFIX_PATH/package/lowdown/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/mcd/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/mdns-alias/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/netbrowse/Config.in" +source "$BR2_EXTERNAL_INFIX_PATH/package/onieprom/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/podman/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/python-libyang/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/python-statd/Config.in" diff --git a/package/onieprom/Config.in b/package/onieprom/Config.in new file mode 100644 index 00000000..2c1ace6b --- /dev/null +++ b/package/onieprom/Config.in @@ -0,0 +1,15 @@ +menuconfig BR2_PACKAGE_ONIEPROM + bool "onieprom" + select BR2_PACKAGE_HOST_PYTHON3 + help + ONIE EEPROM parser/generator + +config BR2_PACKAGE_ONIEPROM_INSTALL_IMAGES + bool "install onieprom in images" + depends on BR2_PACKAGE_ONIEPROM + default y + help + Install the onieprom script in the images direcory. Useful + when the release is destined for someone who will have to + create ONIE EEPROM binaries for deployment during + manufacturing. diff --git a/package/onieprom/onieprom b/package/onieprom/onieprom new file mode 100755 index 00000000..31db43f1 --- /dev/null +++ b/package/onieprom/onieprom @@ -0,0 +1,4 @@ +#!/bin/sh + +PYTHONPATH=$(readlink -f $(dirname $0)/..) \ + exec python3 -m onieprom "$@" diff --git a/package/onieprom/onieprom.mk b/package/onieprom/onieprom.mk new file mode 100644 index 00000000..3077681b --- /dev/null +++ b/package/onieprom/onieprom.mk @@ -0,0 +1,15 @@ +ONIEPROM_VERSION = 1.0 +ONIEPROM_SITE_METHOD = local +ONIEPROM_SITE = $(BR2_EXTERNAL_INFIX_PATH)/src/onieprom +ONIEPROM_LICENSE = GPLv2 +ONIEPROM_LICENSE_FILES = COPYING +ONIEPROM_DEPENDENCIES = host-python3 python3 host-python-poetry-core +ONIEPROM_SETUP_TYPE = pep517 # poetry +ONIEPROM_INSTALL_IMAGES = $(if $(BR2_PACKAGE_ONIEPROM_INSTALL_IMAGES),YES,NO) + +define ONIEPROM_INSTALL_IMAGES_CMDS + @cp -a $(@D)/onieprom $(BINARIES_DIR)/onieprom + @cp $(ONIEPROM_PKGDIR)/onieprom $(BINARIES_DIR)/onieprom/ +endef + +$(eval $(python-package)) diff --git a/src/onieprom/COPYING b/src/onieprom/COPYING new file mode 100644 index 00000000..d511905c --- /dev/null +++ b/src/onieprom/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/src/onieprom/onieprom/__init__.py b/src/onieprom/onieprom/__init__.py new file mode 100644 index 00000000..de51f381 --- /dev/null +++ b/src/onieprom/onieprom/__init__.py @@ -0,0 +1,2 @@ + +from .tlv import into_tlv, from_tlv diff --git a/src/onieprom/onieprom/__main__.py b/src/onieprom/onieprom/__main__.py new file mode 100644 index 00000000..f3d581b4 --- /dev/null +++ b/src/onieprom/onieprom/__main__.py @@ -0,0 +1,38 @@ +def main(): + import argparse + import json + import os + import sys + + parser = argparse.ArgumentParser(prog='onieprom') + + parser.add_argument("infile", nargs="?", default=sys.stdin, type=argparse.FileType("rb", 0)) + parser.add_argument("outfile", nargs="?", default=sys.stdout, type=argparse.FileType("wb")) + + parser.add_argument("-e", "--encode", default=False, action="store_true", + help="Encode JSON input to binary output") + + parser.add_argument("-d", "--decode", default=False, action="store_true", + help="Decode binary input to JSON output") + + args = parser.parse_args() + + if (not args.encode) and (not args.decode): + c = args.infile.read(1) + args.infile.seek(0, 0) + + if c == b"{": + args.encode = True + elif c == b"T": + args.decode = True + else: + sys.stderr.write("Neither encode nor decode specified, and could not infer operation from input") + sys.exit(1) + + if args.encode: + args.outfile.buffer.write(into_tlv(json.load(args.infile))) + else: + args.outfile.write(json.dumps(from_tlv(args.infile))) + +if __name__ == "__main__": + main() diff --git a/board/common/rootfs/usr/bin/onieprom b/src/onieprom/onieprom/tlv.py old mode 100755 new mode 100644 similarity index 80% rename from board/common/rootfs/usr/bin/onieprom rename to src/onieprom/onieprom/tlv.py index c99e8b45..1540c40f --- a/board/common/rootfs/usr/bin/onieprom +++ b/src/onieprom/onieprom/tlv.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python3 - import binascii import struct @@ -180,39 +178,3 @@ def from_tlv(f): d[info["name"]] = unpack(v) return d - -if __name__ == "__main__": - import argparse - import json - import os - import sys - - parser = argparse.ArgumentParser(prog='onieprom') - - parser.add_argument("infile", nargs="?", default=sys.stdin, type=argparse.FileType("rb", 0)) - parser.add_argument("outfile", nargs="?", default=sys.stdout, type=argparse.FileType("wb")) - - parser.add_argument("-e", "--encode", default=False, action="store_true", - help="Encode JSON input to binary output") - - parser.add_argument("-d", "--decode", default=False, action="store_true", - help="Decode binary input to JSON output") - - args = parser.parse_args() - - if (not args.encode) and (not args.decode): - c = args.infile.read(1) - args.infile.seek(0, 0) - - if c == b"{": - args.encode = True - elif c == b"T": - args.decode = True - else: - sys.stderr.write("Neither encode nor decode specified, and could not infer operation from input") - sys.exit(1) - - if args.encode: - args.outfile.buffer.write(into_tlv(json.load(args.infile))) - else: - args.outfile.write(json.dumps(from_tlv(args.infile))) diff --git a/src/onieprom/pyproject.toml b/src/onieprom/pyproject.toml new file mode 100644 index 00000000..11a44e93 --- /dev/null +++ b/src/onieprom/pyproject.toml @@ -0,0 +1,18 @@ +[tool.poetry] +name = "infix-onieprom" +version = "1.0" +description = "ONIE EEPROM parser/generator" +license = "GPLv2" +authors = [ + "KernelKit developers" +] +packages = [ + { include = "onieprom" } +] + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" + +[tool.poetry.scripts] +onieprom = "onieprom.__main__:main" From 696d41d2638729ed61d831c64655ca9d0613018e Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 19 Nov 2025 21:03:33 +0100 Subject: [PATCH 15/20] board/common: Move README.md installation to separate make target --- board/common/Config.in | 1 + board/common/image/image-readme/Config.in | 6 ++++++ .../image-readme/README.md} | 0 .../common/image/image-readme/image-readme.mk | 18 ++++++++++++++++++ board/common/post-image.sh | 6 ------ 5 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 board/common/image/image-readme/Config.in rename board/common/{README.txt => image/image-readme/README.md} (100%) create mode 100644 board/common/image/image-readme/image-readme.mk diff --git a/board/common/Config.in b/board/common/Config.in index ce3fe125..c73e1d3d 100644 --- a/board/common/Config.in +++ b/board/common/Config.in @@ -5,6 +5,7 @@ source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-aux/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-qcow/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-gns3a/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-rauc/Config.in" +source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-readme/Config.in" endmenu diff --git a/board/common/image/image-readme/Config.in b/board/common/image/image-readme/Config.in new file mode 100644 index 00000000..293d12bc --- /dev/null +++ b/board/common/image/image-readme/Config.in @@ -0,0 +1,6 @@ +config IMAGE_README + bool "Install README.md in images" + help + Install a README.md with useful information about getting + started with Infix in the images directory (thereby also + including it in the resulting release tarball). diff --git a/board/common/README.txt b/board/common/image/image-readme/README.md similarity index 100% rename from board/common/README.txt rename to board/common/image/image-readme/README.md diff --git a/board/common/image/image-readme/image-readme.mk b/board/common/image/image-readme/image-readme.mk new file mode 100644 index 00000000..f567989b --- /dev/null +++ b/board/common/image/image-readme/image-readme.mk @@ -0,0 +1,18 @@ +################################################################################ +# +# image-readme +# +################################################################################ + +IMAGE_README_DIR := $(pkgdir) + +image-readme: $(BINARIES_DIR)/README.md + +$(BINARIES_DIR)/README.md: $(IMAGE_README_DIR)/README.md + @$(call IXMSG,"Installing README.md") + @mkdir -p $(BINARIES_DIR) + @cp $< $@ + +ifeq ($(IMAGE_README),y) +TARGETS_ROOTFS += image-readme +endif diff --git a/board/common/post-image.sh b/board/common/post-image.sh index bc36026a..1a248525 100755 --- a/board/common/post-image.sh +++ b/board/common/post-image.sh @@ -1,7 +1 @@ #!/bin/sh - -# Only for regular builds, not bootloader-only builds -if [ "$BR2_TARGET_ROOTFS_SQUASHFS" = "y" ]; then - # Quick intro for beginners, with links to more information - cp "$BR2_EXTERNAL_INFIX_PATH/board/common/README.txt" "$BINARIES_DIR/" -fi From 04e33c0f1599c5c4d91cc90f820731169abe2b16 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 19 Nov 2025 21:11:02 +0100 Subject: [PATCH 16/20] board/common: Remove post-image.sh Now that all components are generated from their own fragments, we have no need for post-image.sh anymore. --- board/common/post-image.sh | 1 - configs/aarch64_defconfig | 1 - configs/aarch64_minimal_defconfig | 1 - configs/aarch64_qemu_boot_defconfig | 1 - configs/cn9130_crb_boot_defconfig | 1 - configs/riscv64_defconfig | 2 +- configs/rpi64_boot_defconfig | 1 - configs/x86_64_defconfig | 1 - configs/x86_64_minimal_defconfig | 1 - 9 files changed, 1 insertion(+), 9 deletions(-) delete mode 100755 board/common/post-image.sh diff --git a/board/common/post-image.sh b/board/common/post-image.sh deleted file mode 100755 index 1a248525..00000000 --- a/board/common/post-image.sh +++ /dev/null @@ -1 +0,0 @@ -#!/bin/sh diff --git a/configs/aarch64_defconfig b/configs/aarch64_defconfig index d4694c33..70ea4a09 100644 --- a/configs/aarch64_defconfig +++ b/configs/aarch64_defconfig @@ -25,7 +25,6 @@ BR2_GENERATE_LOCALE="en_US en_CA C.UTF-8" BR2_TARGET_TZ_INFO=y BR2_ROOTFS_OVERLAY="${BR2_EXTERNAL_INFIX_PATH}/board/common/rootfs ${BR2_EXTERNAL_INFIX_PATH}/board/aarch64/rootfs" BR2_ROOTFS_POST_BUILD_SCRIPT="${BR2_EXTERNAL_INFIX_PATH}/board/common/post-build.sh" -BR2_ROOTFS_POST_IMAGE_SCRIPT="${BR2_EXTERNAL_INFIX_PATH}/board/common/post-image.sh" BR2_LINUX_KERNEL=y BR2_LINUX_KERNEL_CUSTOM_VERSION=y BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.12.60" diff --git a/configs/aarch64_minimal_defconfig b/configs/aarch64_minimal_defconfig index 15306e14..7664bc29 100644 --- a/configs/aarch64_minimal_defconfig +++ b/configs/aarch64_minimal_defconfig @@ -24,7 +24,6 @@ BR2_GENERATE_LOCALE="en_US en_CA C.UTF-8" BR2_TARGET_TZ_INFO=y BR2_ROOTFS_OVERLAY="${BR2_EXTERNAL_INFIX_PATH}/board/common/rootfs ${BR2_EXTERNAL_INFIX_PATH}/board/aarch64/rootfs" BR2_ROOTFS_POST_BUILD_SCRIPT="${BR2_EXTERNAL_INFIX_PATH}/board/common/post-build.sh" -BR2_ROOTFS_POST_IMAGE_SCRIPT="${BR2_EXTERNAL_INFIX_PATH}/board/common/post-image.sh" BR2_LINUX_KERNEL=y BR2_LINUX_KERNEL_CUSTOM_VERSION=y BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.12.60" diff --git a/configs/aarch64_qemu_boot_defconfig b/configs/aarch64_qemu_boot_defconfig index b82879cf..6cacf47b 100644 --- a/configs/aarch64_qemu_boot_defconfig +++ b/configs/aarch64_qemu_boot_defconfig @@ -11,7 +11,6 @@ BR2_GLOBAL_PATCH_DIR="$(BR2_EXTERNAL_INFIX_PATH)/patches" BR2_SSP_NONE=y BR2_INIT_NONE=y BR2_SYSTEM_BIN_SH_NONE=y -BR2_ROOTFS_POST_IMAGE_SCRIPT="${BR2_EXTERNAL_INFIX_PATH}/board/common/post-image.sh" # BR2_PACKAGE_BUSYBOX is not set # BR2_PACKAGE_IFUPDOWN_SCRIPTS is not set # BR2_TARGET_ROOTFS_TAR is not set diff --git a/configs/cn9130_crb_boot_defconfig b/configs/cn9130_crb_boot_defconfig index ef4807b3..74f5ac83 100644 --- a/configs/cn9130_crb_boot_defconfig +++ b/configs/cn9130_crb_boot_defconfig @@ -11,7 +11,6 @@ BR2_GLOBAL_PATCH_DIR="$(BR2_EXTERNAL_INFIX_PATH)/patches" BR2_SSP_NONE=y BR2_INIT_NONE=y BR2_SYSTEM_BIN_SH_NONE=y -BR2_ROOTFS_POST_IMAGE_SCRIPT="${BR2_EXTERNAL_INFIX_PATH}/board/common/post-image.sh" # BR2_PACKAGE_BUSYBOX is not set # BR2_PACKAGE_IFUPDOWN_SCRIPTS is not set # BR2_TARGET_ROOTFS_TAR is not set diff --git a/configs/riscv64_defconfig b/configs/riscv64_defconfig index b4278cb8..2bfc3fb3 100644 --- a/configs/riscv64_defconfig +++ b/configs/riscv64_defconfig @@ -23,7 +23,7 @@ BR2_GENERATE_LOCALE="en_US en_CA C.UTF-8" BR2_TARGET_TZ_INFO=y BR2_ROOTFS_OVERLAY="${BR2_EXTERNAL_INFIX_PATH}/board/common/rootfs ${BR2_EXTERNAL_INFIX_PATH}/board/riscv64/rootfs" BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL_INFIX_PATH)/board/common/post-build.sh" -BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL_INFIX_PATH)/board/common/post-image.sh support/scripts/genimage.sh" +BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh" BR2_ROOTFS_POST_SCRIPT_ARGS="-c $(BR2_EXTERNAL_INFIX_PATH)/board/riscv64/visionfive2/genimage.cfg" BR2_LINUX_KERNEL=y BR2_LINUX_KERNEL_CUSTOM_VERSION=y diff --git a/configs/rpi64_boot_defconfig b/configs/rpi64_boot_defconfig index 3520e8ee..918f91fb 100644 --- a/configs/rpi64_boot_defconfig +++ b/configs/rpi64_boot_defconfig @@ -10,7 +10,6 @@ BR2_GLOBAL_PATCH_DIR="$(BR2_EXTERNAL_INFIX_PATH)/patches" BR2_SSP_NONE=y BR2_INIT_NONE=y BR2_SYSTEM_BIN_SH_NONE=y -BR2_ROOTFS_POST_IMAGE_SCRIPT="${BR2_EXTERNAL_INFIX_PATH}/board/common/post-image.sh" # BR2_PACKAGE_BUSYBOX is not set BR2_PACKAGE_RPI_FIRMWARE=y BR2_PACKAGE_RPI_FIRMWARE_BOOTCODE_BIN=y diff --git a/configs/x86_64_defconfig b/configs/x86_64_defconfig index 5d7d8113..25ee55d7 100644 --- a/configs/x86_64_defconfig +++ b/configs/x86_64_defconfig @@ -24,7 +24,6 @@ BR2_GENERATE_LOCALE="en_US en_CA C.UTF-8" BR2_TARGET_TZ_INFO=y BR2_ROOTFS_OVERLAY="${BR2_EXTERNAL_INFIX_PATH}/board/common/rootfs ${BR2_EXTERNAL_INFIX_PATH}/board/x86_64/rootfs" BR2_ROOTFS_POST_BUILD_SCRIPT="board/qemu/x86_64/post-build.sh ${BR2_EXTERNAL_INFIX_PATH}/board/common/post-build.sh" -BR2_ROOTFS_POST_IMAGE_SCRIPT="${BR2_EXTERNAL_INFIX_PATH}/board/common/post-image.sh" BR2_LINUX_KERNEL=y BR2_LINUX_KERNEL_CUSTOM_VERSION=y BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.12.60" diff --git a/configs/x86_64_minimal_defconfig b/configs/x86_64_minimal_defconfig index d749ced2..23b5696f 100644 --- a/configs/x86_64_minimal_defconfig +++ b/configs/x86_64_minimal_defconfig @@ -24,7 +24,6 @@ BR2_GENERATE_LOCALE="en_US en_CA C.UTF-8" BR2_TARGET_TZ_INFO=y BR2_ROOTFS_OVERLAY="${BR2_EXTERNAL_INFIX_PATH}/board/common/rootfs ${BR2_EXTERNAL_INFIX_PATH}/board/x86_64/rootfs" BR2_ROOTFS_POST_BUILD_SCRIPT="board/qemu/x86_64/post-build.sh ${BR2_EXTERNAL_INFIX_PATH}/board/common/post-build.sh" -BR2_ROOTFS_POST_IMAGE_SCRIPT="${BR2_EXTERNAL_INFIX_PATH}/board/common/post-image.sh" BR2_LINUX_KERNEL=y BR2_LINUX_KERNEL_CUSTOM_VERSION=y BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.12.60" From 87b3f9c30458a93ab9566e43fb2e37cec4c9d935 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 3 Dec 2025 14:04:07 +0100 Subject: [PATCH 17/20] board/common: Restore capability to create QEMU image from tarball Previously, post-image.sh was able to create QEMU images from an existing release tarball. This was useful when you wanted to test a new bootloader build without having to wait for a full Infix build. Restore this capability by adding a separate image target for it, and then allow image-itb-qcow to source its input images from that instead of a locally build squash+aux. --- board/common/Config.in | 1 + .../image/image-itb-dl-release/Config.in | 15 +++++++++++ .../image/image-itb-dl-release/generate.sh | 25 +++++++++++++++++++ .../image-itb-dl-release.mk | 9 +++++++ board/common/image/image-itb-qcow/Config.in | 14 +---------- .../image/image-itb-qcow/image-itb-qcow.mk | 7 +++++- 6 files changed, 57 insertions(+), 14 deletions(-) create mode 100644 board/common/image/image-itb-dl-release/Config.in create mode 100755 board/common/image/image-itb-dl-release/generate.sh create mode 100644 board/common/image/image-itb-dl-release/image-itb-dl-release.mk diff --git a/board/common/Config.in b/board/common/Config.in index c73e1d3d..ed192024 100644 --- a/board/common/Config.in +++ b/board/common/Config.in @@ -5,6 +5,7 @@ source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-aux/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-qcow/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-gns3a/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-rauc/Config.in" +source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-dl-release/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-readme/Config.in" endmenu diff --git a/board/common/image/image-itb-dl-release/Config.in b/board/common/image/image-itb-dl-release/Config.in new file mode 100644 index 00000000..0b6769e8 --- /dev/null +++ b/board/common/image/image-itb-dl-release/Config.in @@ -0,0 +1,15 @@ +menuconfig IMAGE_ITB_DL_RELEASE + bool "Download existing release" + depends on !BR2_TARGET_ROOTFS_SQUASHFS + help + This is primarily used by target specific builds, where the + bootloader artifact needs to be combined with an existing + Infix image, to create a full disk image that can be + provisioned to an SD-card or eMMC. + +config IMAGE_ITB_DL_RELEASE_URL + string "URL" + depends on IMAGE_ITB_DL_RELEASE + default "https://github.com/kernelkit/infix/releases/download/latest/infix-${BR2_ARCH}.tar.gz" + help + URL to release tarball. diff --git a/board/common/image/image-itb-dl-release/generate.sh b/board/common/image/image-itb-dl-release/generate.sh new file mode 100755 index 00000000..33841dd5 --- /dev/null +++ b/board/common/image/image-itb-dl-release/generate.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +set -e + +squash="${BINARIES_DIR}"/rootfs.squashfs +aux="${BINARIES_DIR}"/aux.ext4 + +[ -f "${squash}" ] && [ -f "${aux}" ] && exit 0 + +archive="${WORKDIR}/$(basename ${URL})" +[ -f "${archive}" ] || wget -O"${archive}" "${URL}" + +echo "Unpacking..." +tar -xa --strip-components=1 -C "${BINARIES_DIR}" -f "${archive}" + +auxsize=$(stat -c %s "${aux}") +if [ "${auxsize}" -gt $((8 << 20)) ]; then + # In older releases, 16M aux.ext4 images were generated. In order + # to keep the image-itb-qcow logic simpler, trim it 8M, which we + # always generate nowadays. + echo "WARNING: Auxiliary partition is unexpectedly large. Resizing..." + resize2fs "${aux}" 8M + truncate -s 8M "${aux}" + tune2fs -l "${aux}" +fi diff --git a/board/common/image/image-itb-dl-release/image-itb-dl-release.mk b/board/common/image/image-itb-dl-release/image-itb-dl-release.mk new file mode 100644 index 00000000..4dce031d --- /dev/null +++ b/board/common/image/image-itb-dl-release/image-itb-dl-release.mk @@ -0,0 +1,9 @@ +################################################################################ +# +# image-itb-dl-release +# +################################################################################ + +IMAGE_ITB_DL_RELEASE_CONFIG_VARS := URL + +$(eval $(ix-image)) diff --git a/board/common/image/image-itb-qcow/Config.in b/board/common/image/image-itb-qcow/Config.in index c8c55945..8262344f 100644 --- a/board/common/image/image-itb-qcow/Config.in +++ b/board/common/image/image-itb-qcow/Config.in @@ -1,8 +1,6 @@ menuconfig IMAGE_ITB_QCOW bool "QEMU disk image (ITB)" - default y - select IMAGE_ITB_ROOTFS - select IMAGE_ITB_AUX + depends on (IMAGE_ITB_ROOTFS && IMAGE_ITB_AUX) || IMAGE_ITB_DL_RELEASE select BR2_PACKAGE_HOST_GENIMAGE help Compose a full disk image with redundant Linux OS partitions, @@ -68,13 +66,3 @@ config IMAGE_ITB_QCOW_BOOT_OFFSET Offset at which the bootloader partition is placed. Remember to make sure that the GPT still fits at the start of the image. - -config IMAGE_ITB_QCOW_RELEASE_URL - string "Infix URL" - depends on IMAGE_ITB_QCOW - depends on !BR2_TARGET_ROOTFS_SQUASHFS - default "https://github.com/kernelkit/infix/releases/download/latest/infix-${BR2_ARCH}.tar.gz" - help - In situations where Infix itself is not being built, but a - disk image is, i.e. when building a bootloader: place this - Infix release in the primary and secondary partitions. diff --git a/board/common/image/image-itb-qcow/image-itb-qcow.mk b/board/common/image/image-itb-qcow/image-itb-qcow.mk index 98e5d05e..be44478a 100644 --- a/board/common/image/image-itb-qcow/image-itb-qcow.mk +++ b/board/common/image/image-itb-qcow/image-itb-qcow.mk @@ -4,7 +4,12 @@ # ################################################################################ -IMAGE_ITB_QCOW_DEPENDENCIES := host-genimage image-itb-rootfs image-itb-aux +# We can source the rootfs+aux from a local build, or from a +# downloaded release; so adjust our dependencies accordingly. +IMAGE_ITB_QCOW_SRC-$(IMAGE_ITB_ROOTFS) := image-itb-rootfs image-itb-aux +IMAGE_ITB_QCOW_SRC-$(IMAGE_ITB_DL_RELEASE) := image-itb-dl-release + +IMAGE_ITB_QCOW_DEPENDENCIES := host-genimage $(IMAGE_ITB_QCOW_SRC-y) IMAGE_ITB_QCOW_CONFIG_VARS := BOOT_DATA BOOT_OFFSET SIZE $(eval $(ix-image)) From cf6e211b9132ae51d53850b3bf9ec3bf3b7b17c6 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 3 Dec 2025 14:07:04 +0100 Subject: [PATCH 18/20] board/common/qemu: Downgrade CPU to Cortex-A53 on aarch64 This CPU has less emulation overhead than `max`, which is what we mostly care about. --- board/common/qemu/Config.in.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/common/qemu/Config.in.in b/board/common/qemu/Config.in.in index 4c4356d9..ecebfd4d 100644 --- a/board/common/qemu/Config.in.in +++ b/board/common/qemu/Config.in.in @@ -78,7 +78,7 @@ endchoice config QEMU_MACHINE string "Select emulated machine" default "qemu-system-arm -M virt,accel=kvm:tcg -cpu max" if QEMU_arm - default "qemu-system-aarch64 -M virt,accel=kvm:tcg -cpu max,pauth-impdef=on" if QEMU_aarch64 + default "qemu-system-aarch64 -M virt,accel=kvm:tcg -cpu cortex-a53" if QEMU_aarch64 default "qemu-system-x86_64 -M pc,accel=kvm:tcg -cpu max" if QEMU_x86_64 help You should not have to change this setting, although you may From 0fe59649098321b5762f047abf9381a99f9a02c8 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 3 Dec 2025 13:58:42 +0100 Subject: [PATCH 19/20] aarch64_qemu_boot: Restore build after removing post-image.sh Use the new image-itb-dl-release to compose a QCOW with Infix and U-Boot, in the same way that we previously did in post-image.sh. --- configs/aarch64_qemu_boot_defconfig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/configs/aarch64_qemu_boot_defconfig b/configs/aarch64_qemu_boot_defconfig index 6cacf47b..9884a55c 100644 --- a/configs/aarch64_qemu_boot_defconfig +++ b/configs/aarch64_qemu_boot_defconfig @@ -21,9 +21,10 @@ BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2023.07.02" BR2_TARGET_UBOOT_BOARD_DEFCONFIG="qemu_arm64" BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_INFIX_PATH)/board/common/uboot/extras.config $(BR2_EXTERNAL_INFIX_PATH)/board/aarch64/qemu-uboot/extras.config" BR2_TARGET_UBOOT_FORMAT_DTB=y -BR2_PACKAGE_HOST_GENIMAGE=y -BR2_PACKAGE_HOST_RAUC=y BR2_PACKAGE_HOST_UBOOT_TOOLS=y BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SUPPORT=y BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SIGNATURE_SUPPORT=y -# GNS3_APPLIANCE is not set +IMAGE_ITB_QCOW=y +IMAGE_ITB_DL_RELEASE=y +TRUSTED_KEYS=y +TRUSTED_KEYS_DEVELOPMENT=y From bac11dad0f8c4b8412d495243a8640bd4e57a0ba Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 3 Dec 2025 14:21:53 +0100 Subject: [PATCH 20/20] defconfig: Update all architectures to use new image types --- configs/aarch32_defconfig | 11 +++++------ configs/aarch32_minimal_defconfig | 11 +++++------ configs/aarch64_defconfig | 12 +++++------- configs/aarch64_minimal_defconfig | 12 +++++------- configs/riscv64_defconfig | 9 ++++----- configs/x86_64_defconfig | 11 +++++------ configs/x86_64_minimal_defconfig | 11 +++++------ 7 files changed, 34 insertions(+), 43 deletions(-) diff --git a/configs/aarch32_defconfig b/configs/aarch32_defconfig index 73a54cd0..de0dc71f 100644 --- a/configs/aarch32_defconfig +++ b/configs/aarch32_defconfig @@ -98,17 +98,14 @@ BR2_PACKAGE_WATCHDOGD=y BR2_PACKAGE_LESS=y BR2_PACKAGE_MG=y BR2_PACKAGE_NANO=y -BR2_TARGET_ROOTFS_SQUASHFS=y # BR2_TARGET_ROOTFS_TAR is not set BR2_PACKAGE_HOST_BMAP_TOOLS=y BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y BR2_PACKAGE_HOST_ENVIRONMENT_SETUP=y BR2_PACKAGE_HOST_GENEXT2FS=y -BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_KMOD_XZ=y BR2_PACKAGE_HOST_MTOOLS=y -BR2_PACKAGE_HOST_RAUC=y BR2_PACKAGE_RASPBERRYPI_RPI2=y INFIX_VENDOR_HOME="https://kernelkit.org" INFIX_DESC="Infix is an immutable, friendly, and secure operating system that turns any ARM or x86 device into a powerful, manageable network appliance. Deploy on anything from $35 Raspberry Pi boards to enterprise switches as routers, IoT gateways, or edge devices. Infix models Linux networking features using YANG so you can manage your devices using NETCONF/RESTCONF APIs and focus on your business logic running in isolated containers." @@ -135,11 +132,13 @@ BR2_PACKAGE_KLISH_PLUGIN_INFIX=y BR2_PACKAGE_LOWDOWN=y BR2_PACKAGE_MCD=y BR2_PACKAGE_MDNS_ALIAS=y +BR2_PACKAGE_ONIEPROM=y BR2_PACKAGE_SHOW=y BR2_PACKAGE_ROUSETTE=y BR2_PACKAGE_RAUC_INSTALLATION_STATUS=y +IMAGE_ITB_AUX=y +IMAGE_ITB_QCOW=y +IMAGE_ITB_RAUC=y +IMAGE_README=y TRUSTED_KEYS=y TRUSTED_KEYS_DEVELOPMENT=y -DISK_IMAGE_BOOT_BIN=y -GNS3_APPLIANCE_RAM=512 -GNS3_APPLIANCE_IFNUM=10 diff --git a/configs/aarch32_minimal_defconfig b/configs/aarch32_minimal_defconfig index 628fcea0..e58516ec 100644 --- a/configs/aarch32_minimal_defconfig +++ b/configs/aarch32_minimal_defconfig @@ -98,17 +98,14 @@ BR2_PACKAGE_WATCHDOGD=y BR2_PACKAGE_LESS=y BR2_PACKAGE_MG=y BR2_PACKAGE_NANO=y -BR2_TARGET_ROOTFS_SQUASHFS=y # BR2_TARGET_ROOTFS_TAR is not set BR2_PACKAGE_HOST_BMAP_TOOLS=y BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y BR2_PACKAGE_HOST_ENVIRONMENT_SETUP=y BR2_PACKAGE_HOST_GENEXT2FS=y -BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_KMOD_XZ=y BR2_PACKAGE_HOST_MTOOLS=y -BR2_PACKAGE_HOST_RAUC=y BR2_PACKAGE_RASPBERRYPI_RPI2=y INFIX_VENDOR_HOME="https://kernelkit.org" INFIX_DESC="Infix is an immutable, friendly, and secure operating system that turns any ARM or x86 device into a powerful, manageable network appliance. Deploy on anything from $35 Raspberry Pi boards to enterprise switches as routers, IoT gateways, or edge devices. Infix models Linux networking features using YANG so you can manage your devices using NETCONF/RESTCONF APIs and focus on your business logic running in isolated containers." @@ -135,11 +132,13 @@ BR2_PACKAGE_KLISH_PLUGIN_INFIX=y BR2_PACKAGE_LOWDOWN=y BR2_PACKAGE_MCD=y BR2_PACKAGE_MDNS_ALIAS=y +BR2_PACKAGE_ONIEPROM=y BR2_PACKAGE_SHOW=y BR2_PACKAGE_ROUSETTE=y BR2_PACKAGE_RAUC_INSTALLATION_STATUS=y +IMAGE_ITB_AUX=y +IMAGE_ITB_QCOW=y +IMAGE_ITB_RAUC=y +IMAGE_README=y TRUSTED_KEYS=y TRUSTED_KEYS_DEVELOPMENT=y -DISK_IMAGE_BOOT_BIN=y -GNS3_APPLIANCE_RAM=512 -GNS3_APPLIANCE_IFNUM=10 diff --git a/configs/aarch64_defconfig b/configs/aarch64_defconfig index 70ea4a09..698fabee 100644 --- a/configs/aarch64_defconfig +++ b/configs/aarch64_defconfig @@ -122,16 +122,12 @@ BR2_PACKAGE_WATCHDOGD=y BR2_PACKAGE_LESS=y BR2_PACKAGE_MG=y BR2_PACKAGE_NANO=y -BR2_TARGET_ROOTFS_SQUASHFS=y # BR2_TARGET_ROOTFS_TAR is not set BR2_PACKAGE_HOST_BMAP_TOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y BR2_PACKAGE_HOST_ENVIRONMENT_SETUP=y BR2_PACKAGE_HOST_GENEXT2FS=y -BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_GO_BIN=y -BR2_PACKAGE_HOST_RAUC=y -BR2_PACKAGE_HOST_UBOOT_TOOLS=y BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SUPPORT=y BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SIGNATURE_SUPPORT=y INFIX_VENDOR_HOME="https://kernelkit.org" @@ -170,6 +166,7 @@ BR2_PACKAGE_LOWDOWN=y BR2_PACKAGE_MCD=y BR2_PACKAGE_MDNS_ALIAS=y BR2_PACKAGE_NETBROWSE=y +BR2_PACKAGE_ONIEPROM=y BR2_PACKAGE_PODMAN=y BR2_PACKAGE_PODMAN_DRIVER_BTRFS=y BR2_PACKAGE_PODMAN_DRIVER_DEVICEMAPPER=y @@ -179,8 +176,9 @@ BR2_PACKAGE_TETRIS=y BR2_PACKAGE_ROUSETTE=y BR2_PACKAGE_RAUC_INSTALLATION_STATUS=y BR2_PACKAGE_HOST_PYTHON_YANGDOC=y +IMAGE_ITB_AUX=y +IMAGE_ITB_QCOW=y +IMAGE_ITB_RAUC=y +IMAGE_README=y TRUSTED_KEYS=y TRUSTED_KEYS_DEVELOPMENT=y -DISK_IMAGE_BOOT_BIN=y -GNS3_APPLIANCE_RAM=512 -GNS3_APPLIANCE_IFNUM=10 diff --git a/configs/aarch64_minimal_defconfig b/configs/aarch64_minimal_defconfig index 7664bc29..e37edf64 100644 --- a/configs/aarch64_minimal_defconfig +++ b/configs/aarch64_minimal_defconfig @@ -100,15 +100,11 @@ BR2_PACKAGE_WATCHDOGD=y BR2_PACKAGE_LESS=y BR2_PACKAGE_MG=y BR2_PACKAGE_NANO=y -BR2_TARGET_ROOTFS_SQUASHFS=y # BR2_TARGET_ROOTFS_TAR is not set BR2_PACKAGE_HOST_BMAP_TOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y BR2_PACKAGE_HOST_ENVIRONMENT_SETUP=y BR2_PACKAGE_HOST_GENEXT2FS=y -BR2_PACKAGE_HOST_GENIMAGE=y -BR2_PACKAGE_HOST_RAUC=y -BR2_PACKAGE_HOST_UBOOT_TOOLS=y BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SUPPORT=y BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SIGNATURE_SUPPORT=y INFIX_VENDOR_HOME="https://kernelkit.org" @@ -143,13 +139,15 @@ BR2_PACKAGE_KLISH_PLUGIN_INFIX=y BR2_PACKAGE_LOWDOWN=y BR2_PACKAGE_MCD=y BR2_PACKAGE_MDNS_ALIAS=y +BR2_PACKAGE_ONIEPROM=y BR2_PACKAGE_LIBINPUT=y BR2_PACKAGE_ROUSETTE=y BR2_PACKAGE_RAUC_INSTALLATION_STATUS=y BR2_DOWNLOAD_FORCE_CHECK_HASHES=y BR2_PACKAGE_GETENT=y -DISK_IMAGE_BOOT_BIN=y +IMAGE_ITB_AUX=y +IMAGE_ITB_QCOW=y +IMAGE_ITB_RAUC=y +IMAGE_README=y TRUSTED_KEYS=y TRUSTED_KEYS_DEVELOPMENT=y -GNS3_APPLIANCE_RAM=512 -GNS3_APPLIANCE_IFNUM=10 diff --git a/configs/riscv64_defconfig b/configs/riscv64_defconfig index 2bfc3fb3..9b2fc3d3 100644 --- a/configs/riscv64_defconfig +++ b/configs/riscv64_defconfig @@ -139,7 +139,6 @@ BR2_TARGET_ROOTFS_EXT2_4=y BR2_TARGET_ROOTFS_EXT2_SIZE="512M" BR2_TARGET_ROOTFS_EXT2_INODE_SIZE=0 BR2_TARGET_ROOTFS_EXT2_MKFS_OPTIONS="-O ^64bit,large_file,ext_attr" -BR2_TARGET_ROOTFS_SQUASHFS=y # BR2_TARGET_ROOTFS_TAR is not set BR2_TARGET_OPENSBI=y BR2_TARGET_OPENSBI_CUSTOM_VERSION=y @@ -165,9 +164,6 @@ BR2_TARGET_UBOOT_SPL=y BR2_TARGET_UBOOT_SPL_NAME="spl/u-boot-spl.bin.normal.out" BR2_TARGET_UBOOT_CUSTOM_DTS_PATH="$(BR2_EXTERNAL_INFIX_PATH)/board/riscv64/visionfive2/uboot/visionfive2-env.dtsi" BR2_PACKAGE_HOST_BMAP_TOOLS=y -BR2_PACKAGE_HOST_GENIMAGE=y -BR2_PACKAGE_HOST_RAUC=y -BR2_PACKAGE_HOST_UBOOT_TOOLS=y BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SUPPORT=y BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SIGNATURE_SUPPORT=y INFIX_VENDOR_HOME="https://kernelkit.org" @@ -195,6 +191,7 @@ BR2_PACKAGE_LOWDOWN=y BR2_PACKAGE_MCD=y BR2_PACKAGE_MDNS_ALIAS=y BR2_PACKAGE_NETBROWSE=y +BR2_PACKAGE_ONIEPROM=y BR2_PACKAGE_PODMAN=y BR2_PACKAGE_PODMAN_DRIVER_BTRFS=y BR2_PACKAGE_PODMAN_DRIVER_DEVICEMAPPER=y @@ -205,6 +202,8 @@ BR2_PACKAGE_ROUSETTE=y BR2_PACKAGE_RAUC_INSTALLATION_STATUS=y BR2_PACKAGE_HOST_PYTHON_YANGDOC=y IMAGE_ITB_AUX=y +IMAGE_ITB_QCOW=y +IMAGE_ITB_RAUC=y +IMAGE_README=y TRUSTED_KEYS=y TRUSTED_KEYS_DEVELOPMENT=y -# GNS3_APPLIANCE is not set diff --git a/configs/x86_64_defconfig b/configs/x86_64_defconfig index 25ee55d7..bbed94a3 100644 --- a/configs/x86_64_defconfig +++ b/configs/x86_64_defconfig @@ -118,7 +118,6 @@ BR2_PACKAGE_WATCHDOGD=y BR2_PACKAGE_LESS=y BR2_PACKAGE_MG=y BR2_PACKAGE_NANO=y -BR2_TARGET_ROOTFS_SQUASHFS=y # BR2_TARGET_ROOTFS_TAR is not set BR2_TARGET_EDK2=y BR2_TARGET_GRUB2=y @@ -130,11 +129,8 @@ BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y BR2_PACKAGE_HOST_ENVIRONMENT_SETUP=y BR2_PACKAGE_HOST_GENEXT2FS=y -BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_GO_BIN=y BR2_PACKAGE_HOST_MTOOLS=y -BR2_PACKAGE_HOST_RAUC=y -BR2_PACKAGE_HOST_UBOOT_TOOLS=y BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SUPPORT=y BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SIGNATURE_SUPPORT=y INFIX_VENDOR_HOME="https://kernelkit.org" @@ -167,6 +163,7 @@ BR2_PACKAGE_LOWDOWN=y BR2_PACKAGE_MCD=y BR2_PACKAGE_MDNS_ALIAS=y BR2_PACKAGE_NETBROWSE=y +BR2_PACKAGE_ONIEPROM=y BR2_PACKAGE_PODMAN=y BR2_PACKAGE_PODMAN_DRIVER_BTRFS=y BR2_PACKAGE_PODMAN_DRIVER_DEVICEMAPPER=y @@ -176,7 +173,9 @@ BR2_PACKAGE_TETRIS=y BR2_PACKAGE_ROUSETTE=y BR2_PACKAGE_RAUC_INSTALLATION_STATUS=y BR2_PACKAGE_HOST_PYTHON_YANGDOC=y +IMAGE_ITB_AUX=y +IMAGE_ITB_QCOW=y +IMAGE_ITB_RAUC=y +IMAGE_README=y TRUSTED_KEYS=y TRUSTED_KEYS_DEVELOPMENT=y -GNS3_APPLIANCE_RAM=512 -GNS3_APPLIANCE_IFNUM=10 diff --git a/configs/x86_64_minimal_defconfig b/configs/x86_64_minimal_defconfig index 23b5696f..264b7435 100644 --- a/configs/x86_64_minimal_defconfig +++ b/configs/x86_64_minimal_defconfig @@ -96,7 +96,6 @@ BR2_PACKAGE_WATCHDOGD=y BR2_PACKAGE_LESS=y BR2_PACKAGE_MG=y BR2_PACKAGE_NANO=y -BR2_TARGET_ROOTFS_SQUASHFS=y # BR2_TARGET_ROOTFS_TAR is not set BR2_TARGET_EDK2=y BR2_TARGET_GRUB2=y @@ -108,10 +107,7 @@ BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y BR2_PACKAGE_HOST_ENVIRONMENT_SETUP=y BR2_PACKAGE_HOST_GENEXT2FS=y -BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_MTOOLS=y -BR2_PACKAGE_HOST_RAUC=y -BR2_PACKAGE_HOST_UBOOT_TOOLS=y BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SUPPORT=y BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SIGNATURE_SUPPORT=y INFIX_VENDOR_HOME="https://kernelkit.org" @@ -138,10 +134,13 @@ BR2_PACKAGE_KLISH_PLUGIN_INFIX=y BR2_PACKAGE_LOWDOWN=y BR2_PACKAGE_MCD=y BR2_PACKAGE_MDNS_ALIAS=y +BR2_PACKAGE_ONIEPROM=y BR2_PACKAGE_SHOW=y BR2_PACKAGE_ROUSETTE=y BR2_PACKAGE_RAUC_INSTALLATION_STATUS=y +IMAGE_ITB_AUX=y +IMAGE_ITB_QCOW=y +IMAGE_ITB_RAUC=y +IMAGE_README=y TRUSTED_KEYS=y TRUSTED_KEYS_DEVELOPMENT=y -GNS3_APPLIANCE_RAM=512 -GNS3_APPLIANCE_IFNUM=10