[U-Boot] [RFC] Exporting defaul environment

Simon Glass sjg at chromium.org
Wed May 2 19:32:51 UTC 2018


Hi Stefano,

On 2 May 2018 at 02:48, Stefano Babic <sbabic at denx.de> wrote:
>
> Hi,
>
> I am thinking about how it is possible to export in a clean way the
> default environment from u-boot. The general use case happens when the
> environment must be changed from user space (via fw_setenv or whatever)
> and no environment was still stored - board boots with default environment.
>
> Up now, the trick is to compile the environment tools (u-boot-fw-utils
> in Yocto) with exactly the same U-Boot sources. This works, but it is
> error prone when a new Yocto version is delivered (and maybe with a
> different u-boot-fw-utils) or even if the bootloader is updated. I am
> searching for an alterntive method.
>
> The code in tools/env is really generic, but it becomes board specific
> just for the default environment. If the default environment can read in
> a reliable way from u-boot itslef (its binary), the tool can search for
> the default environment instead of linking again, and tools/env becomes
> "distro capable" - one binary that works on all boards.
>
> I have some thoughts and I would like to share, maybe some of you has
> better ideas. So what I would like to get directly from the binary is
> the offset of "default_environment" (default_environment)
> CONFIG_SYS_TEXT_BASE:
>
> - put this offset in the .img header. Yes, it works just for SPL /
> u-boot.img (drawback).

How about putting the default environment in a FIT? That is typically
easy to find using the magic word.

>
> - surround default environment with some easy to recognize magic number.
> Offset is not known, but user space can find it, like
>
>         magic (long string)
>         ...
>         default_environment
>         end default environment (long string)
>

Seems like FIT would take care of this for you.

> - adding a section in the linker. I think we tried something in the
> past, see __UBOOT_ENV_SECTION__ (it replaced __PPCENV__ from the old
> good mpc8xx times..) that is currently unused. I do not like this
> approach, it can increase (due to alignment) footprint in SPL, where I
> am starting to have issues for smaller i.MX.

Also I wonder if compression might be useful? FIT supports that fairly easily.

>
> - export the deafult environment with such a tool. This dump can be
> passed as input to the program in user space. Well, it could be done,
> but I still suffer if something is changed (sync is required to have
> always the correct dump, I do not see improvement here).
>
> Any thought ?

Regards,
Simon


More information about the U-Boot mailing list