[PATCH 5/5] binman: Update image positions of FIT subentries

Simon Glass sjg at chromium.org
Mon Feb 7 21:22:29 CET 2022


Hi Alper,

On Sun, 6 Feb 2022 at 14:03, Alper Nebi Yasak <alpernebiyasak at gmail.com> wrote:
>
> Binman keeps track of positions of each entry in the final image, but
> currently this data is wrong for things included in FIT entries,
> especially since a previous patch makes FIT a subclass of Section and
> inherit its implementation.
>
> There are three ways to put data into a FIT image. It can be directly
> included as a "data" property, or it can be external to the FIT image
> represented by an offset-size pair of properties. This external offset
> is either "data-position" from the start of the FIT or "data-offset"
> from the end of the FIT, and the size is "data-size" for both. However,
> binman doesn't use the "data-offset" method while building FIT entries.
>
> According to the Section docstring, its subclasses should calculate and
> set the correct offsets and sizes in SetImagePos() method. Do this for
> FIT subentries for the three ways mentioned above, and add tests for the
> two ways binman can pack them in.
>
> Signed-off-by: Alper Nebi Yasak <alpernebiyasak at gmail.com>
> ---
>
>  tools/binman/etype/fit.py |  51 +++++++++++++++++
>  tools/binman/ftest.py     | 112 ++++++++++++++++++++++++++++++++++++++
>  2 files changed, 163 insertions(+)
>

Reviewed-by: Simon Glass <sjg at chromium.org>

But please see below

> diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
> index 0f8c88a9720e..a66ddce095e1 100644
> --- a/tools/binman/etype/fit.py
> +++ b/tools/binman/etype/fit.py
> @@ -291,6 +291,57 @@ def _BuildInput(self, fdt):
>          data = fdt.GetContents()
>          return data
>
> +    def SetImagePos(self, image_pos):
> +        """Set the position in the image
> +
> +        This sets each subentry's offsets, sizes and positions-in-image
> +        according to where they ended up in the packed FIT file.
> +
> +        Args:
> +            image_pos: Position of this entry in the image
> +        """
> +        super().SetImagePos(image_pos)
> +
> +        try:
> +            fdt = Fdt.FromData(self.GetData())
> +            fdt.Scan()
> +        except libfdt.FdtException:
> +            # If mkimage is missing we'll have empty data,
> +            # which will cause a FDT_ERR_BADMAGIC error
> +            return

Is it possible to check the 'missing' or missing_bintools properties
to see whether mkimage is missing?

I don't like the idea of returning here for what looks like an
unrelated exception.

Regards,
Simon


More information about the U-Boot mailing list