env: Allow U-Boot scripts to be placed in a .env file

Tom Rini trini at konsulko.com
Tue Oct 17 17:50:02 CEST 2023


On Tue, Oct 17, 2023 at 10:14:13AM +0200, Wojciech Niziński wrote:
> Hello.
> 
> Very nice feature was introduced in commit:
> 
>     86b9c3e4e48ba47ef28781d06b97846aca74bc8e|
>     env: Allow U-Boot scripts to be placed in a .env file
> 
> This feature works as extension for old CFG_EXTRA_ENV_SETTINGS and make me
> confused why it doesn't work for configured default env file.
> 
> Now in U-Boot config we have two features related to external environment
> file:
> 
> 1st feature (introduced by mentioned commit):
> 
>     CONFIG_ENV_SOURCE_FILE "Environment file to use"
> 
> 2nd feature
> 
>     CONFIG_USE_DEFAULT_ENV_FILE "Create default environment from file"
> 
>     CONFIG_DEFAULT_ENV_FILE "Path to default environment file"
> 
> In 1st feature only basename of .env file can be specified. So env file can
> be located only in board dir which is a limitation for this nice feature:
> 
>     "The file must be in the board directory and have a .env extension, so
>     the resulting filename is typically
> board/<vendor>/<board>/<CONFIG_ENV_SOURCE_FILE>.env"
> 
> In 2nd feature I can specify default env file as full path so it can be
> located everywhere - even outside U-Boot source - which is very nice when
> U-Boot is built by Buildroot. I can easily set path as system environment
> variable and it works:
> 
>     CONFIG_USE_DEFAULT_ENV_FILE=y
> CONFIG_DEFAULT_ENV_FILE="$(BR2_EXTERNAL_FOO_PATH)/board/foo/u-boot.env"
> 
> Unfortunately I cannot do the same for 1st feature without patching U-Boot
> sources to put my custom env file into board dir.
> 
> I can see two way of improving features:
>  1st: to extend 1st feature with ability to specify full patch to env file,
> or
>  2nd one: run the same parsing mechanism also for 2nd feature (default env
> file).

Your analysis of how things work is correct.  The intention is that, as
you noted, is that the plain text environment and CONFIG_ENV_SOURCE_FILE
replace the older default environment found in include/env_default.h and
often augmented by the board.h file via (formerly CONFIG now CFG)
EXTRA_ENV_SETTINGS and CONFIG_USE_DEFAULT_ENV_FILE to be the complete
replacement of the environment option.  So I think the next reasonable
step would be to be able to have plain text environment style files work
for CONFIG_USE_DEFAULT_ENV_FILE which I think you're saying doesn't
today.  But I think that yes, a patch to parse the new-style plain text
files for CONFIG_USE_DEFAULT_ENV_FILE would be good, and I suspect
buildroot has enough users of that feature that any corner cases with
trying to parse older files could be caught and fixed?

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20231017/5faa6474/attachment.sig>


More information about the U-Boot mailing list