[U-Boot] Default environment file

Rasmus Villemoes rasmus.villemoes at prevas.dk
Wed Jun 12 09:17:32 UTC 2019


On 12/06/2019 10.43, Stefano Babic wrote:
> Hi Pascal,
> 
> On 12/06/19 10:20, Linder Pascal wrote:
>> Hi everyone,
>>
>>
>> I am currently moving the configurations of the KM boards from header files to Kconfig. But for the customly defined environment variables I did not found a decent solution until I have come across the default environment file, which seems very interesting to me.
>>
>>
>> To this day, nevertheless, it appears that noone made use of the CONFIG_USE_DEFAULT_ENV_FILE configuration defined in env/Kconfig. Does anyone still have an example for this kind of environment definition or knows how to create it?
>>
>>
>> In my opinion, this could be highly relevant for the transition away from the header files in include/configs.
>>
> 
> Fully agree. Rather, I do not think there is a relevant example. But the
> environment is something like data and should not be part of the header
> file as it is for histoical reason. I added some times ago a way to
> extract the environment from the header and make the transition easy
> (see make u-boot-initial-env). And if the environment is split from the
> header as CONFIG_USE_DEFAULT_ENV_FILE allows, it is also easier to set
> an own environment via OE BSP layer without pushing for each small
> change to U-Boot. Not only, environments often conflict, and what is
> good for a project becomes evil for another one.

Yup. FWIW, here's a small snippet from our Yocto recipe that creates the
default env file:

ENV_INPUT = "common.txt board.txt"
ENV_INPUT_append_basic-test = " testctrl.txt"

python do_configure() {
    import fileinput
    with open("uboot.txt", "w") as out:
        for line in fileinput.input(files=d.getVar("ENV_INPUT").split()):
            line = d.expand(line)
            # Strip backslash-newline
            if line.endswith("\\\n"):
                line = line[:-2]
            out.write(line)
}

The line = d.expand(line) allows us to use ${SOME_BITBAKE_VARIABLE} in
the input files and have them replaced appropriately - this can be quite
useful to e.g. configure a tftp server address differently.

Rasmus


More information about the U-Boot mailing list