@@ -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"
@@ -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
@@ -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,
};
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@free-electrons.com> --- env/Kconfig | 12 ++---------- env/common.c | 2 +- env/nowhere.c | 8 +++++++- 3 files changed, 10 insertions(+), 12 deletions(-)