env: Allow U-Boot scripts to be placed in a .env file
At present U-Boot environment variables, and thus scripts, are defined by CONFIG_EXTRA_ENV_SETTINGS. It is painful to add large amounts of text to this file and dealing with quoting and newlines is harder than it should be. It would be better if we could just type the script into a text file and have it included by U-Boot. Add a feature that brings in a .env file associated with the board config, if present. To use it, create a file in a board/<vendor> directory, typically called <board>.env and controlled by the CONFIG_ENV_SOURCE_FILE option. The environment variables should be of the form "var=value". Values can extend to multiple lines. See the README under 'Environment Variables:' for more information and an example. In many cases environment variables need access to the U-Boot CONFIG variables to select different options. Enable this so that the environment scripts can be as useful as the ones currently in the board config files. This uses the C preprocessor, means that comments can be included in the environment using /* ... */ Also support += to allow variables to be appended to. This is needed when using the preprocessor. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Tested-by: Marek Behún <marek.behun@nic.cz>
This commit is contained in:
18
env/Kconfig
vendored
18
env/Kconfig
vendored
@@ -3,6 +3,24 @@ menu "Environment"
|
||||
config ENV_SUPPORT
|
||||
def_bool y
|
||||
|
||||
config ENV_SOURCE_FILE
|
||||
string "Environment file to use"
|
||||
default ""
|
||||
help
|
||||
This sets the basename to use to generate the default environment.
|
||||
This a text file as described in doc/usage/environment.rst
|
||||
|
||||
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
|
||||
|
||||
If the file is not present, an error is produced.
|
||||
|
||||
If this CONFIG is empty, U-Boot uses CONFIG SYS_BOARD as a default, if
|
||||
the file board/<vendor>/<board>/<SYS_BOARD>.env exists. Otherwise the
|
||||
environment is assumed to come from the ad-hoc
|
||||
CONFIG_EXTRA_ENV_SETTINGS #define
|
||||
|
||||
config SAVEENV
|
||||
def_bool y if CMD_SAVEENV
|
||||
|
||||
|
||||
Reference in New Issue
Block a user