[PATCH 14/24] binman: Support a list of strings with the mkimage etype

Simon Glass sjg at chromium.org
Wed Feb 23 23:59:00 CET 2022


Hi Alper,

On Tue, 15 Feb 2022 at 04:53, Alper Nebi Yasak <alpernebiyasak at gmail.com> wrote:
>
> On 08/02/2022 21:49, Simon Glass wrote:
> > At present the 'args' property of the mkimage entry type is a string. This
> > makes it difficult to include CONFIG options in that property. In
> > particular, this does not work:
> >
> >    args = "-n CONFIG_SYS_SOC -E"
> >
> > since the preprocessor does not operate within strings, nor does this:
> >
> >    args = "-n" CONFIG_SYS_SOC" "-E"
> >
> > since the device tree compiler does not understand string concatenation.
>
> Fun fact, I got something like this roughly working:
>
> #define _QUOTE(x) #x
> #define QUOTE(x) _QUOTE(x)
>
> #define MKIMAGE_ARGS QUOTE( \
>        -A arm -T kernel -C none -O linux -n U-Boot \
>        -a CONFIG_SYS_TEXT_BASE -e CONFIG_SYS_TEXT_BASE \
> )
>
> But obviously a string list is the better choice.

:-)

>
> >
> > With this new feature, we can do:
> >
> >    args = "-n", CONFIG_SYS_SOC, "-E";
> >
> > Signed-off-by: Simon Glass <sjg at chromium.org>
> > ---
> >
> >  tools/binman/entries.rst      | 11 +++++++++++
> >  tools/binman/etype/mkimage.py | 13 ++++++++++++-
> >  2 files changed, 23 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
> > index 0fb6d56296..b32dc58933 100644
> > --- a/tools/binman/entries.rst
> > +++ b/tools/binman/entries.rst
> > @@ -931,6 +931,17 @@ This calls mkimage to create an imximage with u-boot-spl.bin as the input
> >  file. The output from mkimage then becomes part of the image produced by
> >  binman.
> >
> > +To use CONFIG options in the arguments, use a string list instead, as in
> > +this example which also produces four arguments::
> > +
> > +    mkimage {
> > +        args = "-n", CONFIG_SYS_SOC, "-T imximage";
> > +
> > +        u-boot-spl {
> > +        };
> > +    };
> > +
> > +
> >
> >
> >  Entry: op-tee: Open Portable Trusted Execution Environment (OP-TEE) blob
> > diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py
> > index 201ee4b569..9ecd1c2548 100644
> > --- a/tools/binman/etype/mkimage.py
> > +++ b/tools/binman/etype/mkimage.py
> > @@ -31,10 +31,21 @@ class Entry_mkimage(Entry):
> >      This calls mkimage to create an imximage with u-boot-spl.bin as the input
> >      file. The output from mkimage then becomes part of the image produced by
> >      binman.
> > +
> > +    To use CONFIG options in the arguments, use a string list instead, as in
> > +    this example which also produces four arguments::
> > +
> > +        mkimage {
> > +            args = "-n", CONFIG_SYS_SOC, "-T imximage";
> > +
> > +            u-boot-spl {
> > +            };
> > +        };
> > +
> >      """
> >      def __init__(self, section, etype, node):
> >          super().__init__(section, etype, node)
> > -        self._args = fdt_util.GetString(self._node, 'args').split(' ')
> > +        self._args = fdt_util.GetArgs(self._node, 'args')
>
> If you're OK with each string being a single argument, I think you could
> use GetStringList(default=[]) and shlex.join() here instead.

See what you think of what I have come up with here. The arg is not
optional, actually.

>
> >          self._mkimage_entries = OrderedDict()
> >          self.align_default = None
> >          self.ReadEntries()

Regards,
Simon


More information about the U-Boot mailing list