[PATCH v9 3/7] env: Allow U-Boot scripts to be placed in a .env file

Rasmus Villemoes rasmus.villemoes at prevas.dk
Mon Oct 25 21:52:07 CEST 2021


On 25/10/2021 17.18, Simon Glass wrote:
> Hi Rasmus,
> 
> On Mon, 25 Oct 2021 at 01:06, Rasmus Villemoes
> <rasmus.villemoes at prevas.dk> wrote:

>> Exactly, there's really never any case where that would be sensible. But
>> I would probably go a bit further and simply restrict varnames to the
>> usual alphanumerics plus [_.+-] - in particular, exclude single and
>> double quotes and backslash. That leaves the door open for somebody to
>> later support "arbitrary" variable names by defining what it would mean
>> to say e.g.
>>
>> "abc \n'\"\tfoo" = hahaha
>>
>> or whatever syntax they'd propose, but there's absolutely no point in
>> implementing anything like that initially.
>>
>>> But how do I do this?
>>>
>>> bootargs=console=fred
>>> #ifdef SOMETHING
>>> bootargs+= dm-verity=...
>>> #endif
>>>
>>> We need the space between the bootargs.
>>
>> Exactly like that, and for the case where you want to append something
>> _without_ an extra space there's the .= operator I also suggested.
> 
> Do you have a link to the docs for that?
>

https://docs.yoctoproject.org/bitbake/bitbake-user-manual/bitbake-user-manual-metadata.html#appending-and-prepending-with-spaces

As I said, it will be familiar to anyone who has ever dealt with
Yocto/bitbake, and the behaviour of += (of adding the RHS with a space
prepended) is known from Make. I think there are uses for both, and it
shouldn't be very hard to support both operators.
of the current assignment.

>> I don't think I've seen it addressed, but how do you deal with CONFIG_
>> string items? In the config.h file, the macro definition includes the
>> double quotes, but I don't think one wants that in the env values.
>>
>> conf = CONFIG_DEFAULT_CONF
>> bootcmd = bootm $loadaddr#$conf
>>
>> would attempt to boot e.g. 0x12340000#"foo", and while one can do
>> de-quotification in U-Boot shell, it's rather cumbersome.
> 
> Badly. I really don't like the stringify stuff so we don't have that
> problem, but we have this one.
> 
> I would much prefer it be automatic, if possible. This needs some
> thought...e.g. I wonder what the default behaviour should be?

I think it should be the value without quotes, if that is at all
possible. But, it's not completely trivial, because cpp won't do macro
expansion inside what it sees as a string literal, so if one wants a
CONFIG string inside double quotes, one can't do

  foo = "CONFIG_FOO"

Dunno, I think it needs some more thought.

Rasmus


More information about the U-Boot mailing list