summaryrefslogtreecommitdiff
path: root/env
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2021-11-16 20:55:12 -0500
committerTom Rini <[email protected]>2021-11-16 20:55:12 -0500
commitf299171c1dd8fb77b56b317adf80f7c60627d64f (patch)
tree9e86d3aeaf5e46cd0e23bbb8bfc0e6e5406617e0 /env
parent9272805139a104c83dff8230e03e9626dd9bc195 (diff)
parent78398652723b6fe743751ffb19d8256b7e3e0a4e (diff)
Merge branch '2021-11-16-env-rework' into next
To quote Simon: One barrier to completing the 7-year-long Kconfig migration is that the default environment is implemented using ad-hoc CONFIG options. At present U-Boot environment variables, and thus scripts, are defined by CONFIG_EXTRA_ENV_SETTINGS. It is not really feasible to move the environment to Kconfig as it is hundreds of lines of text in some cases. Even considering the current situation, it is painful to add large amounts of text to the config-header 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. This is already supported by the CONFIG_USE_DEFAULT_ENV_FILE feature. But that does not support use of CONFIG options or comments, so is best suited for use by other build systems wanting to define the U-Boot environment. Add a feature that brings in a .env file associated with the board config, if present. To use it, create a file board/<vendor>/<board>.env or use CONFIG_ENV_SOURCE_FILE to set a filename. The environment variables should be of the form "var=value". Values can extend to multiple lines. This series converts the existing environment documentation to rST and updates it to explain how to use this.
Diffstat (limited to 'env')
-rw-r--r--env/Kconfig18
-rw-r--r--env/common.c5
-rw-r--r--env/embedded.c1
3 files changed, 24 insertions, 0 deletions
diff --git a/env/Kconfig b/env/Kconfig
index 06d72bad1dc..24966f8c373 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/common.c b/env/common.c
index 208e2adaa01..ee957c0a8c0 100644
--- a/env/common.c
+++ b/env/common.c
@@ -235,6 +235,11 @@ int env_get_yesno(const char *var)
1 : 0;
}
+bool env_get_autostart(void)
+{
+ return env_get_yesno("autostart") == 1;
+}
+
/*
* Look up the variable from the default environment
*/
diff --git a/env/embedded.c b/env/embedded.c
index 208553e6af1..9f26e6cad9c 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