[PATCH 4/5] env: Add support for board specific special default environment

Simon Glass sjg at chromium.org
Sun Oct 31 14:07:45 CET 2021


Hi Marek,

On Fri, 29 Oct 2021 at 02:58, Marek Behún <kabel at kernel.org> wrote:
>
> On Thu, 28 Oct 2021 21:17:41 -0600
> Simon Glass <sjg at chromium.org> wrote:
>
> > Hi Marek,
> >
> > On Wed, 27 Oct 2021 at 21:28, Marek Behún <kabel at kernel.org> wrote:
> > >
> > > From: Marek Behún <marek.behun at nic.cz>
> > >
> > > The default_environment[] buffer is built at compile time, but sometimes
> > > it makes sense for some default environment variables to be determined
> > > at runtime, for example:
> > > - one board code may support different boards, and needs that
> > >     fdtfile, board, board_name
> > >   are set appropriately when command
> > >     env default -a
> > >   is executed
> > > - some boards may want to prohibit the
> > >     env default -a
> > >   command to remove device MAC addresses stored in
> > >     ethaddr, ethNaddr.
> > >   This is the case for the ESPRESSObin board code, for example, where
> > >   currently the board_late_init() function rewrites the default
> > >   environment array to achieve this.
> > >
> > > Add a new board specific function,
> > >
> > >   const char *board_special_default_env(unsigned i, const char **name);
> > >
> > > which returns the value of i-th board special default environemnt
> > > variable, while storing it's name to *name.
> > >
> > > Add default weak implementation of this functions returning NULL.
> > >
> > > Add code to default environemnt handlers in env/common.c, which iterate
> > > these special board default environment variables and get it's values in
> > > precedence to values in the default_environment[] buffer.
> > >
> > > Signed-off-by: Marek Behún <marek.behun at nic.cz>
> > > ---
> > >  env/common.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++--
> > >  1 file changed, 96 insertions(+), 3 deletions(-)
> >
> > What do you think about using a sysinfo driver for this? There are
> > already a lot of weak functions in U-Boot.
>
> I confess I am looking at sysinfo API for the first time just now. It
> seems like a reasonable thing, but how to combine with default
> environment for this?
>
> The thing is that Pali's code for ESPRESSObin needs to prohibit
> deleting the ethaddrs from env with "env default -a", because there
> were issues with the mac address being lost...

The way you have done it seems reasonable to me, i.e. calling an
iterator function to get the strings. Could it be done with sysinfo's
get_str()? Perhaps we should add get_str_list() as a new method that
takes and id and also an index?

Regards,
Simon


More information about the U-Boot mailing list