Linux reads a boot configuration (bootconfig) from the end of the initrd:
kernel command line parameters (kernel.*), parameters for init (init.*)
and the setup of boot-time tracing (ftrace.*), in a structured text
format. Normally tools/bootconfig appends it to the initrd file when that
is built. This series lets barebox append it at boot time, so it can be
chosen per boot without rebuilding the initrd or changing the boot entry.
The bootconfig is a plain text file, given by global.bootm.bootconfig,
bootm -b, the boot override bootm.bootconfig or devboot_bootconfig.
barebox chains it as the last loadable behind all initrds, adds the
footer (size, checksum, magic) and puts "bootconfig" on the kernel
command line. Without an initrd, the bootconfig alone is passed as one.
For example tracing for a single boot with devboot or a boot override:
# /mnt/tftp/trace.bconf
ftrace.event.sched.sched_switch.enable
kernel.trace_buf_size = 4M
boot -o bootm.bootconfig=/mnt/tftp/trace.bconf mmc
The format follows Linux v7.3, the result is byte-identical to
tools/bootconfig -a. barebox does not parse the bootconfig, the kernel
checks the syntax and reports errors. Importing the parser from Linux
(lib/bootconfig.c) for a command that shows or checks a bootconfig could
follow if that is wanted.
Patch 1 adds loadable_from_buf(), a memory loadable that owns its buffer,
for the bootconfig built at boot time. Patch 2 is the bootm part, patch 3
the boot override, patch 4 the devboot variable.
Tested on QEMU aarch64 virt with dry runs (bootm -d, boot -d, devboot):
with and without an initrd, from global.bootm.bootconfig, bootm -b and
the override, the override replacing the variable and an empty override
removing it; the initrd in memory compared with tools/bootconfig -a of
Linux v7.3 byte for byte. The series builds with and without
CONFIG_BOOTM_BOOTCONFIG.
Example test run:
barebox@ARM QEMU virt64:/ devboot
Sourcing /mnt/tftp/str-devboot-virt64
boot -o bootm.image=str-linux-virt64 -o
bootm.bootconfig=str-bootconfig-virt64
Booting entry 'NixOS 26.05.20261021.da6dc0e (virt64)
(/mnt/9p/boot/loader/entries/virt64.conf)'
blspec: booting NixOS 26.05.20261021.da6dc0e (virt64) from none
NOTICE: [bootm override active] replacement OS: File(str-linux-virt64)
NOTICE: [bootm override active] replacement bootconfig:
str-bootconfig-virt64
Loading ARM aarch64 Linux/EFI image 'str-linux-virt64'
commandline: console=ttyAMA0,115200n8
init=/nix/store/3kb5cxkdbi7w0pzdk5dn5pd97y20b76i-nixos-system-virt64-26.05.20261021.da6dc0e/init
console=ttyAMA0,115200 root=fstab loglevel=7 lsm=landlock,yama,bpf
bootconfig
(...)
[ 0.000000] Load bootconfig: 69 bytes 8 nodes
(...)
bash-5.3# cat /proc/bootconfig
ftrace.event.sched.sched_switch.enable = ""
kernel.trace_buf_size = "4M"
# Parameters from bootloader:
# console=ttyAMA0,115200n8
init=/nix/store/71kswz7n3yn5xyhymbvryj4lsds2bqpq-nixos-system-virt64-26.05.20261021.da6dc0e/init
console=ttyAMA0,115200 ip=dhcp root=fstab loglevel=7 lsm=landlock,yama,bpf
bootconfig
Signed-off-by: Steffen Trumtrar <[email protected]>
---
Steffen Trumtrar (4):
loadable: add loadable_from_buf()
bootm: append a Linux bootconfig to the initrd
boot: add bootm.bootconfig override
defaultenv: devboot: add devboot_bootconfig
Documentation/user/booting-linux.rst | 19 +++++
Documentation/user/devboot.rst | 22 ++++++
commands/boot.c | 5 +-
commands/bootm.c | 18 ++++-
common/Kconfig | 15 ++++
common/Makefile | 1 +
common/bootconfig.c | 129 +++++++++++++++++++++++++++++++
common/bootm-overrides.c | 23 +++++-
common/bootm.c | 48 +++++++++++-
defaultenv/defaultenv-2-base/bin/devboot | 6 +-
include/bootconfig.h | 27 +++++++
include/bootm-overrides.h | 3 +
include/bootm.h | 6 ++
include/loadable.h | 5 ++
lib/loadable-mem.c | 24 ++++++
lib/loadable.c | 2 +
16 files changed, 345 insertions(+), 8 deletions(-)
---
base-commit: 5c46c205c8d1a7c57b9dbaa5e516758a6c0a4d80
change-id: 20261027-v2026-10-0-topic-bootconfig-6e815125a5c9
Best regards,
--
Steffen Trumtrar <[email protected]>