All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] allow control DTB to double as "FIT image"
@ 2026-05-12 16:16 Rasmus Villemoes
  2026-05-12 16:16 ` [PATCH 1/2] image-board.c: exempt gd->fdt_blob from fit_check_format() check Rasmus Villemoes
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Rasmus Villemoes @ 2026-05-12 16:16 UTC (permalink / raw)
  To: u-boot; +Cc: Tom Rini, Simon Glass, Quentin Schulz, Rasmus Villemoes

The commit message for patch 1 explains what it is I'd like to be able
to do, but here's some more background:

For a long time, we've embedded the boot script in the U-Boot binary
by building a bootscript.itb, and using a .dtsi like

  / {
          config {
                 bootscript = /incbin/("/path/to/bootscript.itb");
          };
  };

which in turn is mentioned in CONFIG_DEVICE_TREE_INCLUDES, that
bootscript.itb FIT image has been embedded in U-Boot's control
dtb. Running that was then a matter of doing

  fdt addr ${fdtcontroladdr} && fdt get addr bsaddr /config bootscript && source ${bsaddr}

There are a couple of advantage of having the bootscript (and other
script logic) embedded in the U-Boot binary. First, there's no need to
figure out some separate partition to store the script in, and making
sure that gets updated whenever the bootloader itself does. Second,
one doesn't need to worry about verifying the script; whatever steps
one needs to take to implement secure boot for U-Boot itself will by
necessity also cover the control dtb (if nothing else then because
that's where the public key for the kernel verification lives).

Now with the stricter requirements of libfdt starting from v2026.04,
the above command no longer worked, or only half the time, because the
embedded FIT image may not land on an 8-byte aligned address. So that
line had to be changed a little (line breaks added)

  fdt addr ${fdtcontroladdr}
    && fdt get addr bsaddr /config bootscript
    && fdt get size bssize /config bootscript
    && cp.b ${bsaddr} ${loadaddr} ${bssize}
    && source ${loadaddr}

which is getting quite unwieldy.

Then it struck me that one could perhaps simplify all of this quite a
lot: Cut out the intermediate bootscript.itb, just create a .dtsi
which directly puts a /images node inside the control dtb

/ {
  	images {
		default = "bootscript";
		bootscript {
			description = "Boot script";
			data = /incbin/("/path/to/bootscript.sh");
			type = "script";
			compression = "none";
		};
	};
};

and treat the control dtb itself as a FIT image; so the command to put
in $bootcmd becomes simply

  source ${fdtcontroladdr}:bootscript

and embedding other pieces of callable scripts is quite trivial.

And that almost works out-of-the-box, except for the fit_check_format() sanity check.

I realize this is a bit of a hack, but I do think it's somewhat
elegant, and avoids inventing a whole lot of extra infrastructure for
allowing one to embed larger scripts and invoke them from the shell. I
am of course happy to put this exemption for gd->fdt_blob under a
CONFIG_ knob if that is deemed necessary.

CI is half-way through (and past the sandbox testing that would
exercise this) and seems happy:
https://github.com/u-boot/u-boot/pull/969

Rasmus Villemoes (2):
  image-board.c: exempt gd->fdt_blob from fit_check_format() check
  test: hook up test of allowing control DTB to act as FIT image

 arch/sandbox/dts/sandbox-test1.sh     |  4 ++++
 arch/sandbox/dts/sandbox-test2.sh     |  4 ++++
 arch/sandbox/dts/sandbox_scripts.dtsi | 18 ++++++++++++++++++
 boot/image-board.c                    |  2 +-
 configs/sandbox_defconfig             |  1 +
 test/py/tests/test_source.py          | 12 ++++++++++++
 6 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 arch/sandbox/dts/sandbox-test1.sh
 create mode 100644 arch/sandbox/dts/sandbox-test2.sh
 create mode 100644 arch/sandbox/dts/sandbox_scripts.dtsi

-- 
2.54.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-05-15 13:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-12 16:16 [PATCH 0/2] allow control DTB to double as "FIT image" Rasmus Villemoes
2026-05-12 16:16 ` [PATCH 1/2] image-board.c: exempt gd->fdt_blob from fit_check_format() check Rasmus Villemoes
2026-05-15 13:06   ` Simon Glass
2026-05-12 16:16 ` [PATCH 2/2] test: hook up test of allowing control DTB to act as FIT image Rasmus Villemoes
2026-05-15 13:06   ` Simon Glass
2026-05-12 16:39 ` [PATCH 0/2] allow control DTB to double as "FIT image" Quentin Schulz
2026-05-13  8:03   ` Rasmus Villemoes
2026-05-15 13:33 ` [0/2] " Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.