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

Wolfgang Denk wd at denx.de
Sat Oct 26 22:26:11 CEST 2013


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.

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?

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?

...

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

> +	# 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 guess this needs more work - but then - why define a new format at
all?  Why not use what U-Boot uses itself?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
One essential to success is that you desire be an all-obsessing  one,
your thoughts and aims be co-ordinated, and your energy be concentra-
ted and applied without letup.


More information about the U-Boot mailing list