public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: Simon Glass <sjg@chromium.org>
Cc: "U-Boot Mailing List" <u-boot@lists.denx.de>,
	"Tom Rini" <trini@konsulko.com>, "Bin Meng" <bmeng.cn@gmail.com>,
	"Joe Hershberger" <joe.hershberger@ni.com>,
	"Marek Behún" <marek.behun@nic.cz>,
	"Pali Rohár" <pali@kernel.org>
Subject: Re: [PATCH v4 3/5] env: Allow U-Boot scripts to be placed in a .env file
Date: Mon, 20 Sep 2021 14:30:57 +0200	[thread overview]
Message-ID: <1819736.1632141057@gemini.denx.de> (raw)
In-Reply-To: <20210919125937.v4.3.If789ba3e2667c46c03eda3386ca84a863baeda55@changeid>

Dear Simon,

In message <20210919125937.v4.3.If789ba3e2667c46c03eda3386ca84a863baeda55@changeid> you wrote:
>
...
> +It is also possible to create an environment file with the name
> +`board/<vendor>/env/<board>.env` for your board. If that file is not present
> +then U-Boot will look for `oard/<vendor>/env/common.env` so that you can

a/oard/board/

> +have a common environment for all vendor boards.

Actually it would be nice to look for `board/<vendor>/env/common.env`
first, and then for `board/<vendor>/env/<board>.env` - and if both
exost, they should be concatenated, so a vendor can keep all common
definitions in the common.env, and have only board specific
definitions in the <board>.env files - otherwise he would have to
repeat everything in the board files, and the common file makes
little sense.

> +This is a plain text file where you can type your environment variables in
> +the form `var=value`. Blank lines and multi-line variables are supported.
> +The conversion script looks for a line that starts with a letter or number
> +and has an equals sign immediately afterwards. Spaces before the = are not
> +permitted. It is a good idea to indent your scripts so that only the 'var='
> +appears at the start of a line.

This is not correct.  Variable names can be more complex:

	=> setenv _foo 1
	=> setenv ,bar 2
	=> setenv /baz 3

etc.

> +For example, for snapper9260 you would create a text file called
> +`board/bluewater/env/snapper9260.env` containing the environment text.
> +
> +Example::
> +
> +    stdout=serial
> +    #ifdef CONFIG_LCD
> +    stdout+=,lcd

Is that a new feature?  I didn't see it documented anywhere?

> +    #endif
> +    bootcmd=
> +        /* U-Boot script for booting */
> +
> +        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=
> +        /* Print a message when boot fails */
> +        echo CONFIG_SYS_BOARD boot failed - please check your image
> +        echo Load address is CONFIG_SYS_LOAD_ADDR

You _must_ define a clear syntax for the file, including indentation
rules.  Otherwise there is plenty chance for incorrect arsing.


> +	# Is this the start of a new environment variable?
> +	if (match($0, "^([^ =][^ =]*)=(.*)", arr)) {

This is not what you document above.

> +		if (length(env) != 0) {
> +			# Record the value of the variable now completed
> +			vars[var] = env
> +		}

What in case of length == 0 ?


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
Imitation is the sincerest form of plagarism.

  reply	other threads:[~2021-09-20 12:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-19 18:59 [PATCH v4 0/5] env: Allow environment in text files Simon Glass
2021-09-19 18:59 ` [PATCH v4 1/5] sandbox: Drop distro_boot Simon Glass
2021-09-19 18:59 ` [PATCH v4 2/5] doc: Move environment documentation to rST Simon Glass
2021-09-20 12:18   ` Wolfgang Denk
2021-09-19 18:59 ` [PATCH v4 3/5] env: Allow U-Boot scripts to be placed in a .env file Simon Glass
2021-09-20 12:30   ` Wolfgang Denk [this message]
2021-09-19 18:59 ` [PATCH v4 4/5] env: Allow environment files to use the C preprocessor Simon Glass
2021-09-20 12:35   ` Wolfgang Denk
2021-09-19 18:59 ` [PATCH v4 5/5] sandbox: Use a text-based environment Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1819736.1632141057@gemini.denx.de \
    --to=wd@denx.de \
    --cc=bmeng.cn@gmail.com \
    --cc=joe.hershberger@ni.com \
    --cc=marek.behun@nic.cz \
    --cc=pali@kernel.org \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox