[U-Boot] [PATCH] Allow U-Boot scripts to be placed in a .env file

Simon Glass sjg at chromium.org
Wed Apr 24 04:36:26 CEST 2013


Hi Otavio,

On Tue, Apr 23, 2013 at 7:14 PM, Otavio Salvador
<otavio at ossystems.com.br> wrote:
> On Tue, Apr 23, 2013 at 9:29 PM, Simon Glass <sjg at chromium.org> wrote:
>> Hi Tom,
>>
>> On Tue, Apr 23, 2013 at 4:33 PM, Tom Rini <trini at ti.com> wrote:
>>> On Tue, Apr 23, 2013 at 02:32:00PM -0700, Simon Glass wrote:
>>>> Hi Wolfgang,
>>>>
>>>> On Tue, Apr 16, 2013 at 10:44 PM, Wolfgang Denk <wd at denx.de> wrote:
>>>> > Dear Simon Glass,
>>>> >
>>>> > In message <1366155414-6525-1-git-send-email-sjg at chromium.org> you wrote:
>>>> >> At present U-Boot environment variables, and thus scripts, are defined
>>>> >> by CONFIG_EXTRA_ENV_SETTINGS. It is painful to add large amounts of text
>>>> >> to this file and dealing with quoting and newlines is harder than it
>>>> >> should be. It would be better if we could just type the script into a
>>>> >> text file and have it included by U-Boot.
>>>> >>
>>>> >> Add a feature that brings in a .env file associated with the board
>>>> >> config, if present. To use it, create a file in include/configs
>>>> >> with the same name as you could board config file, except with a
>>>> >> .env extension instead of a .h extension. The variables should be
>>>> >> separated by \0. Comments are permitted, using # as the first character
>>>> >> in a line.
>>>> >
>>>> > Please do not litter the include/configs/ directory with such stuff.
>>>> > It's more than big enough already.  Please put such files into the
>>>> > respective board directories.
>>>>
>>>> OK.
>>>>
>>>> >
>>>> > And if you do something like this, then please go the way to the end.
>>>> > Forget about the \0 termination, make it a plain text file instead,
>>>> > something that can be used with "env import -t" as well (or created
>>>> > with "env export -t").
>>>>
>>>> I'm not sure how to do this. Doesn't this mean that we cannot add
>>>> multi-line scripts to the environment? That was part of my aim. But if
>>>> I put a 0x0a in the script then it will think we are starting a new
>>>> variable.
>>>
>>> The first thing that pops to mind is:
>>> 1) embedded the text file into a linker-known spot
>>> 2) Make part of the default env setup process be to env import -t that
>>> location in memory.
>>
>> Well I have a working implementation - my concern was more about how
>> to deal with newlines. I would like to be able to handle a script just
>> written out over multiple lines in a text file. This is really nice
>> because we can have proper indenting, comments, etc. As soon as we
>> have to use 0x0a as the separator between each environment variable
>> that is no longer possible.
>>
>> My current scheme requires the .env file to have \0 separating
>> environment variables which is obviously not ideal. I am hoping we can
>> find another way which is more textfile-friendly without losing the
>> benefits.
>
> What about using \ as continuous line indicator and otherwise finish
> the line, when parsing, wiht \0?

Thanks for the suggestion. But that, along with the need for quotes,
is one of the reasons I would like to provide a way to enter scripts
naturally.

Adding \ at the end of each line is error-prone and gets in the way.
Python and C don't have this requirement - so why should U-Boot
scripts?

I wonder if we could define that 'xxx=' at the start of a line
delineates a new variable?

Regards,
Simon

>
> --
> Otavio Salvador                             O.S. Systems
> E-mail: otavio at ossystems.com.br  http://www.ossystems.com.br
> Mobile: +55 53 9981-7854              http://projetos.ossystems.com.br


More information about the U-Boot mailing list