[U-Boot] [PATCH v3 3/5] Allow U-Boot scripts to be placed in a .env file
Simon Glass
sjg at chromium.org
Mon Oct 28 21:24:56 CET 2013
Hi Wolfgang,
On Sat, Oct 26, 2013 at 2:26 PM, Wolfgang Denk <wd at denx.de> wrote:
> Dear Simon,
>
> In message <1382763695-2849-4-git-send-email-sjg at chromium.org> you wrote:
>>
>> +For example, for snapper9260 you would create a text file called
>> +board/bluewater/env/snapper9260.env containing the environment text.
>> +
>> +>>>
>> +bootcmd=
>> + if [ -z ${tftpserverip} ]; then
>> + echo "Use 'setenv tftpserverip a.b.c.d' to set IP address."
>> + fi
>> +
>> + usb start; setenv autoload n; bootp;
>> + tftpboot ${tftpserverip}:
>> + bootm
>> +failed=
>> + echo boot failed - please check your image
>> +<<<
>> +
>> +The resulting environment can be exported and importing using the
>> +'env export/import -t' commands.
>
> I think this statement is misleading. It reads as if thois text coul
> actually be imported using "env import -t", which is not correct. And
> the result of an "env export -t" of equivalent command settings will
> look pretty much different, too.
The point here is that it is possible to export the default
environment that has been created at build time. Agreed this should be
worded better.
>
> I can see why you like such a "beautified" text format, but I don;t
> think you are doing anybody a favour here. Can we not rather use
> _exactly_ the same text format as U-Boot uses with it's import /
> export commands?
That would be nice, but how to we handle newlines? Some scripts are
quite long. Do we need to put \ at the end of every line? That feels a
bit painful to me.
Also how do we handle #define? Without it I don't think this feature
is useful, since the existing build system often sticks CONFIG
variables into the environment.
>
> This would make it _much_ easier to experiment on a system and modify
> the environment until it fits all the requirements and passes all
> tests, and then export it as a text file and use this directly
> (without editing) for the input needed here?
I believe that is already possible - you should be able to take the
output of 'env export -t' and put it in the .env file. I have not
tried it though.
>
> ...
>
>> --- /dev/null
>> +++ b/tools/scripts/env2string.awk
>> @@ -0,0 +1,48 @@
>> +#
>> +# (C) Copyright 2013 Google, Inc
>> +#
>> +# SPDX-License-Identifier: GPL-2.0+
>> +#
>> +# Sed script to parse a text file containing an environment and convert it
>> +# to a C string which can be compiled into U-Boot.
>
> That doesn't look like sed to me, looks more like awk :-)
Hmm, yes I gave up on sed after a while. Will fix.
>
>> + # Is this the start of a new environment variable?
>> + if (match($0, "^([^ =][^ =]*)=(.*)", arr)) {
>
> I think this is a bit naive...
>
> Example (using notation as exported by U-Boot using "env export -t"):
>
> foo=setenv xxx\
> one=1;setenv yyy\
> two=2;setenv zzz\
> three=3
>
>> + # Print out all the variables
>> + for (var in vars) {
>> + print var "=" vars[var] "\\0";
>> + }
>
> I think it should not be difficult to find examples that would result
> incorrect output.
I will take a look at this - here it is the \ at the end of line which
needs to be handled.
>
> I guess this needs more work - but then - why define a new format at
> all? Why not use what U-Boot uses itself?
See above, would be good to resolve this issue before going any further.
Regards,
Simon
More information about the U-Boot
mailing list