diff options
author | Simon Glass <sjg@chromium.org> | 2021-10-21 21:08:46 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-11-16 14:35:08 -0500 |
commit | 86b9c3e4e48ba47ef28781d06b97846aca74bc8e (patch) | |
tree | bd000f2e8969f1e35a7e245d700d7d9f3d95f301 /env | |
parent | ea754aa5658f395200a2b9a2573291a03c63bc77 (diff) | |
download | u-boot-86b9c3e4e48ba47ef28781d06b97846aca74bc8e.tar.gz u-boot-86b9c3e4e48ba47ef28781d06b97846aca74bc8e.tar.bz2 u-boot-86b9c3e4e48ba47ef28781d06b97846aca74bc8e.zip |
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>
Diffstat (limited to 'env')
-rw-r--r-- | env/Kconfig | 18 | ||||
-rw-r--r-- | env/embedded.c | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/env/Kconfig b/env/Kconfig index 06d72bad1d..24966f8c37 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -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 diff --git a/env/embedded.c b/env/embedded.c index 208553e6af..9f26e6cad9 100644 --- a/env/embedded.c +++ b/env/embedded.c @@ -66,6 +66,7 @@ #endif #define DEFAULT_ENV_INSTANCE_EMBEDDED +#include <config.h> #include <env_default.h> #ifdef CONFIG_ENV_ADDR_REDUND |