[2/3] binman: Generate the preload header and sign the data only once

Simon Glass sjg at chromium.org
Thu Apr 2 02:17:31 CEST 2026


Hi Paul,

On 2026-04-01T15:35:23, yan wang <yan.wang at softathome.com> wrote:
> binman: Generate the preload header and sign the data only once
> binman: Generate the preload header and sign the data only once
>
> To optimize the preload generation, the header and signatures are
> only generated once all data have been collected. This avoids to
> sign multiple times.
>
> Signed-off-by: Paul HENRYS <paul.henrys_ext at softathome.com>

> diff --git a/tools/binman/etype/pre_load.py b/tools/binman/etype/pre_load.py
> @@ -152,14 +152,12 @@ class Entry_pre_load(Entry_collection):
> +    def ObtainContents(self):
> +        """Do nothing here.
> +        The data will be obtained and handled in ProcessContents
> +        """
> +        return True

Since ObtainContents() no longer calls SetContents(), contents_size
remains 0 during Pack(). This forces an extra packing pass when
ProcessContentsUpdate() detects the size change from 0 to header_size.

Since header_size is known upfront (from __init__), you could set
contents_size here to avoid the re-pack:

    def ObtainContents(self):
        self.contents_size = self.header_size
        return True

This would allow Pack() to reserve the correct space immediately.

> diff --git a/tools/binman/etype/pre_load.py b/tools/binman/etype/pre_load.py
> @@ -152,14 +152,12 @@ class Entry_pre_load(Entry_collection):
> +    def ProcessContents(self):
> +        self.image = self.GetContents(True)
> +        data = self._CreateHeader()
> +        return self.ProcessContentsUpdate(data)

Looking at the series as a whole, patch 3/3 adds the build_done
marking in GetContents() which prevents referenced entries from being
rebuilt. However, this patch calls GetContents() unconditionally with
required=True. If the referenced entry's data somehow becomes
unavailable between passes, this would raise an exception rather than
returning gracefully.

I suspect this is fine since ProcessContents() runs after
ObtainContents() has succeeded for all entries, but please confirm
this is the intended behaviour.

Regards,
Simon


More information about the U-Boot mailing list