[U-Boot] [PATCH 04/11] env: make nowhere an env medium like the others
Quentin Schulz
quentin.schulz at free-electrons.com
Fri Dec 22 21:13:38 UTC 2017
Since we now allow the loading of different environment media by
priority, we can mimic the current fallback system with nowhere medium
by adding a load function to the nowhere driver (and make it the medium
with the lowest priority).
Nowhere then becomes a valid environment medium.
This also makes it possible to either enforce the value of some
variables by using nowhere medium when using it as secondary environment
or to completely enforce all the environment variables except a few from
a secondary environment when using it as base environment.
Signed-off-by: Quentin Schulz <quentin.schulz at free-electrons.com>
---
env/Kconfig | 12 ++----------
env/common.c | 2 +-
env/nowhere.c | 8 +++++++-
3 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/env/Kconfig b/env/Kconfig
index d57594d..f99a701 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -2,16 +2,6 @@ menu "Environment"
config ENV_IS_NOWHERE
bool "Environment is not stored"
- depends on !ENV_IS_IN_EEPROM
- depends on !ENV_IS_IN_FAT
- depends on !ENV_IS_IN_FLASH
- depends on !ENV_IS_IN_MMC
- depends on !ENV_IS_IN_NAND
- depends on !ENV_IS_IN_NVRAM
- depends on !ENV_IS_IN_ONENAND
- depends on !ENV_IS_IN_REMOTE
- depends on !ENV_IS_IN_SPI_FLASH
- depends on !ENV_IS_IN_UBI
default y
help
Define this if you don't want to or can't have an environment stored
@@ -19,6 +9,8 @@ config ENV_IS_NOWHERE
while U-Boot is running, but once U-Boot exits it will not be
stored. U-Boot will therefore always start up with a default
environment.
+ When whitelisting is enabled, define this to be able to use the
+ default environment as either base or secondary environment.
config ENV_IS_IN_EEPROM
bool "Environment in EEPROM"
diff --git a/env/common.c b/env/common.c
index 00c454d..c8d8993 100644
--- a/env/common.c
+++ b/env/common.c
@@ -279,7 +279,7 @@ void env_relocate(void)
env_htab.change_ok += gd->reloc_off;
#endif
if (gd->env_valid == ENV_INVALID) {
-#if defined(CONFIG_ENV_IS_NOWHERE) || defined(CONFIG_SPL_BUILD)
+#if defined(CONFIG_SPL_BUILD)
/* Environment not changable */
set_default_env(NULL);
#else
diff --git a/env/nowhere.c b/env/nowhere.c
index f654883..7a37909 100644
--- a/env/nowhere.c
+++ b/env/nowhere.c
@@ -15,6 +15,11 @@
DECLARE_GLOBAL_DATA_PTR;
+static int env_nowhere_load(void)
+{
+ return !env_import((char *)default_environment, 0);
+}
+
/*
* Because we only ever have the default environment available we must mark
* it as invalid.
@@ -22,7 +27,7 @@ DECLARE_GLOBAL_DATA_PTR;
static int env_nowhere_init(void)
{
gd->env_addr = (ulong)&default_environment[0];
- gd->env_valid = ENV_INVALID;
+ gd->env_valid = ENV_VALID;
return 0;
}
@@ -31,4 +36,5 @@ U_BOOT_ENV_LOCATION(nowhere) = {
.location = ENVL_NOWHERE,
.init = env_nowhere_init,
ENV_NAME("nowhere")
+ .load = env_nowhere_load,
};
--
git-series 0.9.1
More information about the U-Boot
mailing list