[PATCH] binman: Add a temporary hack for duplicate phandles

Simon Glass sjg at chromium.org
Sun Aug 6 16:59:30 CEST 2023


Hi Pali,

On Sun, 6 Aug 2023 at 04:55, Pali Rohár <pali at kernel.org> wrote:
>
> Why you are sending me this change? I'm not responsible for binman, have
> not asked to be and I'm not going to review it.

Due to the Makefile change. We do rely on contributors to review code
otherwise nothing would get accepted.

Regards,
Simon

>
> On Wednesday 02 August 2023 09:23:13 Simon Glass wrote:
> > Three boards use a phandle in a FIT generator and the maintainer is
> > away. For now, add a hack to allow this.
> >
> > Signed-off-by: Simon Glass <sjg at chromium.org>
> > ---
> >
> >  Makefile                |  6 ++++++
> >  tools/binman/cmdline.py |  2 ++
> >  tools/binman/control.py |  5 +++++
> >  tools/dtoc/fdt.py       | 12 ++++++++----
> >  4 files changed, 21 insertions(+), 4 deletions(-)
> >
> > diff --git a/Makefile b/Makefile
> > index 41f37714f7e4..b8a9ed818a88 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -1328,6 +1328,11 @@ u-boot.ldr:    u-boot
> >  # Use 'make BINMAN_VERBOSE=3' to set vebosity level
> >  default_dt := $(if $(DEVICE_TREE),$(DEVICE_TREE),$(CONFIG_DEFAULT_DEVICE_TREE))
> >
> > +# Temporary workaround for Venice boards
> > +ifneq ($(CONFIG_TARGET_IMX8MM_VENICE),$(CONFIG_TARGET_IMX8MN_VENICE),$(CONFIG_TARGET_IMX8MP_VENICE),)
> > +ignore_dups := --ignore-dup-phandles
> > +endif
> > +
> >  quiet_cmd_binman = BINMAN  $@
> >  cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \
> >               $(foreach f,$(BINMAN_TOOLPATHS),--toolpath $(f)) \
> > @@ -1349,6 +1354,7 @@ cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \
> >               -a spl-dtb=$(CONFIG_SPL_OF_REAL) \
> >               -a tpl-dtb=$(CONFIG_TPL_OF_REAL) \
> >               -a pre-load-key-path=${PRE_LOAD_KEY_PATH} \
> > +             $(ignore_dups) \
> >               $(BINMAN_$(@F))
> >
> >  OBJCOPYFLAGS_u-boot.ldr.hex := -I binary -O ihex
> > diff --git a/tools/binman/cmdline.py b/tools/binman/cmdline.py
> > index 9632ec115e5d..39c61c2c0322 100644
> > --- a/tools/binman/cmdline.py
> > +++ b/tools/binman/cmdline.py
> > @@ -126,6 +126,8 @@ controlled by a description in the board device tree.'''
> >              help='Comma-separated list of bintools to consider missing (for testing)')
> >      build_parser.add_argument('-i', '--image', type=str, action='append',
> >              help='Image filename to build (if not specified, build all)')
> > +    build_parser.add_argument('--ignore-dup-phandles', action='store_true',
> > +            help='Temporary option to ignore duplicate phandles')
> >      build_parser.add_argument('-I', '--indir', action='append',
> >              help='Add a path to the list of directories to use for input files')
> >      build_parser.add_argument('-m', '--map', action='store_true',
> > diff --git a/tools/binman/control.py b/tools/binman/control.py
> > index c6d3205b8c25..459489558125 100644
> > --- a/tools/binman/control.py
> > +++ b/tools/binman/control.py
> > @@ -22,6 +22,7 @@ from binman import bintool
> >  from binman import cbfs_util
> >  from binman import elf
> >  from binman import entry
> > +from dtoc import fdt
> >  from dtoc import fdt_util
> >  from u_boot_pylib import command
> >  from u_boot_pylib import tools
> > @@ -816,6 +817,10 @@ def Binman(args):
> >          cbfs_util.VERBOSE = args.verbosity > 2
> >          state.use_fake_dtb = args.fake_dtb
> >
> > +        # Temporary hack
> > +        if args.ignore_dup_phandles: # pragma: no cover
> > +            fdt.IGNORE_DUP_PHANDLES = True
> > +
> >          # Normally we replace the 'u-boot' etype with 'u-boot-expanded', etc.
> >          # When running tests this can be disabled using this flag. When not
> >          # updating the FDT in image, it is not needed by binman, but we use it
> > diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
> > index 5963925146a5..0b20d52f3136 100644
> > --- a/tools/dtoc/fdt.py
> > +++ b/tools/dtoc/fdt.py
> > @@ -15,6 +15,9 @@ from libfdt import QUIET_NOTFOUND
> >  from u_boot_pylib import tools
> >  from u_boot_pylib import tout
> >
> > +# Temporary hack
> > +IGNORE_DUP_PHANDLES = False
> > +
> >  # This deals with a device tree, presenting it as an assortment of Node and
> >  # Prop objects, representing nodes and properties, respectively. This file
> >  # contains the base classes and defines the high-level API. You can use
> > @@ -339,10 +342,11 @@ class Node:
> >          if phandle:
> >              dup = self._fdt.phandle_to_node.get(phandle)
> >              if dup:
> > -                raise ValueError(
> > -                    f'Duplicate phandle {phandle} in nodes {dup.path} and {self.path}')
> > -
> > -            self._fdt.phandle_to_node[phandle] = self
> > +                if not IGNORE_DUP_PHANDLES:
> > +                    raise ValueError(
> > +                        f'Duplicate phandle {phandle} in nodes {dup.path} and {self.path}')
> > +            else:
> > +                self._fdt.phandle_to_node[phandle] = self
> >
> >          offset = fdt_obj.first_subnode(self.Offset(), QUIET_NOTFOUND)
> >          while offset >= 0:
> > --
> > 2.41.0.585.gd2178a4bd4-goog
> >


More information about the U-Boot mailing list