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

Simon Glass sjg at chromium.org
Fri Oct 29 05:17:41 CEST 2021


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.

Regards,
Simon


More information about the U-Boot mailing list