[U-Boot] [RFC] Exporting defaul environment

Stefano Babic sbabic at denx.de
Wed May 2 08:48:32 UTC 2018


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).

- 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)

- 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.

- 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 ?

Best regards,
Stefano


-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================


More information about the U-Boot mailing list