Re: [RFC PATCH 4/7] arm64: boot: Support building image.fit from a specified FIT_ITS script

From: Simon Glass

Date: Sat Oct 24 2026 - 04:19:02 EST


Hi Doug,

On 2026-10-20T15:35:18, Douglas Anderson <dianders@xxxxxxxxxxxx> wrote:
> arm64: boot: Support building image.fit from a specified FIT_ITS script

Most of this patch is generic kbuild rather than arm64: the top-level
Makefile clean pattern, cmd_lz4_frame, the compressed .dtb rules, the
dtb-y filtering in Makefile.dtbs and the FIT_ITS handling in
Makefile.lib. Please can you split the lz4-frame and compressed-DTB
rules into their own 'kbuild:' patch, with the kbuild maintainers on
Cc?

>
> Allow passing `FIT_ITS=<path>` on the make command line (relative to
> either `$(srctree)` or `arch/arm64/boot/dts/`) when building `image.fit`
> to assemble the FIT image from a checked-in `.its` script via `mkimage`
> instead of auto-generating a FIT image with `scripts/make_fit.py`. When
> `FIT_ITS` is not specified, `image.fit` continues to be built using
> `scripts/make_fit.py` as before.
>
> Supporting a checked-in `.its` script includes:
> - Adding `cmd_lz4_frame` (`Image-framed.lz4` and `%.dtb.lz4`) for
> standard LZ4 frame compression (magic `0x184d2204`) expected by FIT
> bootloaders such as U-Boot and depthcharge, plus generic compressed
> DTB rules (`bz2`, `gz`, `lz4`, `lzma`, `lzo`, `zst`, `xz`) in
> `scripts/Makefile.dtbs`.
> - Restricting `$(dtb-y)` to the DTBs referenced via `/incbin/(...)` in
> `$(FIT_ITS)` and automatically building the referenced kernel image
> target (e.g. `Image-framed.lz4`) and any compressed `.dtb.<ext>`
> blobs.
> - Populating any omitted `compatible` property on
> [...]
>
> Makefile | 2 +-
> arch/arm64/Makefile | 3 +++
> arch/arm64/boot/Makefile | 9 +++++---
> scripts/Makefile.dtbs | 43 ++++++++++++++++++++++++++++++++++-
> scripts/Makefile.lib | 59 ++++++++++++++++++++++++++++++++++++++++++++++++
> 5 files changed, 111 insertions(+), 5 deletions(-)

> diff --git a/scripts/Makefile.dtbs b/scripts/Makefile.dtbs
> @@ -5,6 +5,26 @@ all-dtb := $(dtb-y) $(dtb-)
> +ifdef FIT_ITS_FILE
> +ifneq ($(filter arch/$(SRCARCH)/boot/dts%, $(obj)),)
> +its-dtb-files := $(notdir $(shell $(call fit_its_incbin,\.dtb)))

Just to check, is it intended that this also restricts 'make dtbs' and
'make dtbs_install' whenever FIT_ITS is set, not just image.fit? If
so, please say so in the commit message. Also, matching on notdir
means a DTB with the same name in another vendor directory would be
built too. There are no such duplicates today, but comparing the
directory with $(obj) would be more robust.

> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> @@ -429,6 +436,58 @@ quiet_cmd_fit = FIT $@
> + fdt=$$(fdtget $@ $$conf fdt); \
> + inc=$$($(call fit_its_incbin,\.dtb,$$fdt)); \
> + dtb="$(objtree)/$${inc%.dtb*}.dtb"; \
> + compat=$$(fdtget -ts "$$dtb" / compatible); \

A FIT configuration can list more than one fdt (a base followed by
overlays, e.g. fdt = 'fdt-1', 'fdt-2'). Then $$fdt is 'fdt-1 fdt-2',
the sed range never matches, $$inc is empty and fdtget fails on
'$(objtree)/.dtb', breaking the build. Please can you use only the
first word here, since the base DTB carries the root compatible?

> + configs=$$(fdtget -l $@ /configurations); \
> + for c in $$configs; do \

BTW, adding 'compatible' to the configuration nodes after mkimage runs
would break any configuration signature, since the properties of a
signed config node are hashed. mkimage isn't given -k here, so signing
isn't supported anyway, but a comment would stop someone adding
signing later without noticing.

Regards,
Simon