[PATCH 1/4] scripts/make_fit: factor dtb file name into configuration name

Uwe Kleine-König uwe at kleine-koenig.org
Tue Mar 18 04:03:18 PDT 2025


Hello Ahmad,

On Tue, Mar 18, 2025 at 09:25:04AM +0100, Ahmad Fatoum wrote:
> Bootloaders often support booting a specific FIT configuration by name.
> This is useful when the automatic boot fails, because the bootloader's
> DT compatible differs from the upstream one included with the Linux
> device trees.
> 
> Currently, configuration are numbered sequentially requiring the user to
> dump the FIT image to determine what number the configuration has.
> 
> Improve upon this by naming configurations after the dtb name instead.
> This is what OE-core kernel-fitimage.bbclass does for example.
> 
> Cc: Uwe Kleine-König <uwe at kleine-koenig.org>
> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> ---
>  scripts/make_fit.py | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/scripts/make_fit.py b/scripts/make_fit.py
> index 075b7c258ff2..2190da4c003c 100755
> --- a/scripts/make_fit.py
> +++ b/scripts/make_fit.py
> @@ -145,11 +145,9 @@ def finish_fit(fsw, entries):
>              str: Compatible stringlist
>      """
>      fsw.end_node()
> -    seq = 0
>      with fsw.add_node('configurations'):
> -        for model, compat, files in entries:
> -            seq += 1
> -            with fsw.add_node(f'conf-{seq}'):
> +        for dtbname, model, compat, files in entries:
> +            with fsw.add_node(f'conf-{dtbname}'):

Funny/surprising semantic of fsw.add_node (i.e. fsw refers to the new
node in the with-body?)

>                  fsw.property('compatible', bytes(compat))
>                  fsw.property_string('description', model)
>                  fsw.property('fdt', bytes(''.join(f'fdt-{x}\x00' for x in files), "ascii"))
> @@ -266,6 +264,7 @@ def build_fit(args):
>      fsw = libfdt.FdtSw()
>      setup_fit(fsw, args.name)
>      entries = []
> +    dtbs_seen = set()
>      fdts = {}
>  
>      # Handle the kernel
> @@ -290,7 +289,13 @@ def build_fit(args):
>  
>          files_seq = [fdts[fn] for fn in files]
>  
> -        entries.append([model, compat, files_seq])
> +        dtbname = os.path.basename(fname)
> +        ndtbs_seen = len(dtbs_seen)
> +        dtbs_seen.add(dtbname)
> +        if len(dtbs_seen) == ndtbs_seen:
> +            raise RuntimeError(f"Duplicate file name '{dtbname}' during FIT creation")
> +
> +        entries.append([dtbname, model, compat, files_seq])

	dtbname = os.path.basename(fname)
	if dtbname in dtbs_seen:
	    raise RuntimeError(...)
	dtbs_seen.add(dtbname)
	entries.append(...)

looks more pythonic (to me).

Acked-by: Uwe Kleine-König <uwe at kleine-koenig.org>

for the idea of this patch.

Best regards
Uwe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20250318/e268c9c9/attachment.sig>


More information about the barebox mailing list