mbox series

[RFC,0/4] Add support for bootconfig on initramfs and FIT images

Message ID 20260319-bootconfig-v1-0-a4d467c3f0ba@valla.it
Headers show
Series Add support for bootconfig on initramfs and FIT images | expand

Message

Francesco Valla March 18, 2026, 11:30 p.m. UTC
Hello,

this patchset introduces support for attaching a bootconfig block both
to plain initramfs images and inside FIT images. The bootconfig source
can be configured globally or per-image.

== Introduction to bootconfig ==

A bootconfig is a small footer that can be added to an initramfs image
and is read by the kernel at startup if the CONFIG_BOOT_CONFIG option is
set. Its content can be used to expand the kernel command line even
beyond its canonical size limit.

An interesting point about the bootconfig mechanism is that the
initramfs image does *not* need to be there for the bootconfig to be
read, as its presence is always checked starting from the bottom of the
declared initramfs area.

More details on the bootconfig concept can be found at [0]. 

== Patchset walkthrough == 

Patch 1 adds a new recipe to compile the tool used for bootconfig
management; being this part of the Linux kernel source code, it is
compiled from the kernel shared workdir.

Patch 2 adds a new image conversion type to add the bootconfig to an
image. While today only a cpio (plain or compressed) or an ext2 image
would make sense here as a base for such operation, this is not strictly
enforced as new usecases may arise in the future. A new bbclass
containing the relevant configuration variables for this operation is
also introduced in this patch.

Patche 3 adds a test recipe containing a bootconfig that can be used for
tests; this recipe will then be used by patch 4.

Patch 4 adds support for adding a bootconfig inside a FIT image. Since
the bootconfig is always read from the end of an initramfs memory area
(even if the initramfs isn“t really there!), two forms of support are
added here, both enabled by the FIT_INCLUDE_BOOTCONFIG variable:

 - if INITRAMFS_IMAGE is set, the .bootconfig image is searched to be
   included as ramdisk section;
 - if INITRAMFS_IMAGE is not set, a dummy/empty initramfs artifact is
   created and the bootconfig block is added there; the resulting binary
   is then added as ramdisk section.

It should be noted that if INITRAMFS_IMAGE_BUNDLE the bootconfig will
NOT be included inside the FIT image and a warning will be displayed.

== Usecases ==

The main usecases I can think of are:

 - (the one driving the work) initramfs-less dm-verity setup starting
   from a bootconfig included inside the FIT image and verified as part
   of the FIT verification; I have a working PoC for this based on a
   modified version of image_types_verity from meta-openembedded;
 - complex tracing setups where the classic kernel command line is not
   sufficient (bootconfig is e.g. indicated as boot-time tracing
   mechanism [1]);
 - debug flexibility: no need to modify the kernel nor the bootloader
   setup to pass debug arguments to the kernel.

Bonus track: the first usecase was featured in Francesco Castagnotto's
podcast "I use Yocto btw", with me explaining it (in italian) [2].

== Open points == 

Following points are still open, with probable room for improvements:

 - the BOOTCONFIG_TASK mechanism feels legacy, but I couldn't think of
   a better one;
 - I'm not sure if and how the INITRAMFS_IMAGE_BUNDLE case should be
   managed (maybe bundling also the bootconfig itself?);
 - should an example bootconfig recipe be added?

Thank you in advance for any feedback on this!

Best regards,
Francesco

[0] https://docs.kernel.org/admin-guide/bootconfig.html
[1] https://docs.kernel.org/trace/boottime-trace.html
[2] https://open.spotify.com/episode/0qR6lzm0nz4uylt0lCBfYQ

Signed-off-by: Francesco Valla <francesco@valla.it>
---
Francesco Valla (4):
      bootconfig: add recipe
      image_types: add bootconfig conversion type
      recipes-test: add bootconfig-test recipe
      kernel-fit-image: add bootconfig support

 .../recipes-test/bootconfig/bootconfig-test.bb     | 20 +++++++
 .../bootconfig/bootconfig-test/bootconfig-test.txt |  6 +++
 meta/classes-recipe/bootconfig-config.bbclass      | 12 +++++
 meta/classes-recipe/image_types.bbclass            | 15 +++++-
 meta/classes-recipe/kernel-fit-image.bbclass       | 44 +++++++++++++--
 meta/conf/image-fitimage.conf                      |  3 ++
 meta/lib/oeqa/selftest/cases/fitimage.py           | 63 +++++++++++++++++++---
 meta/recipes-kernel/bootconfig/bootconfig.bb       | 44 +++++++++++++++
 8 files changed, 193 insertions(+), 14 deletions(-)
---
base-commit: 531f87111d83430615f2e20dd41a3dd5fc25c7ab
change-id: 20260318-bootconfig-47ebc0231153

Best regards,