MLK-22279-2 env: Add a config to enable nowhere as default location
authorYe Li <ye.li@nxp.com>
Tue, 16 Jul 2019 09:06:10 +0000 (02:06 -0700)
committerYe Li <ye.li@nxp.com>
Wed, 17 Jul 2019 07:19:54 +0000 (00:19 -0700)
When booting from USB there is no place to store the environment and
should use default env. However CONFIG_ENV_IS_NOWHERE has dependence
with other env storage config. If we enable multiple storages, NOWHERE
can't be enabled. And saveenv won't be built if NOWHERE is set.

This patch introduces a new CONFIG_ENV_DEFAULT_NOWHERE, that can enable
NOWHERE as a default env location when other storage are not avaliable.
And allow to build saveenv.

Signed-off-by: Ye Li <ye.li@nxp.com>
(cherry picked from commit 64c02d26555491eb7cb758f58511620c1590c378)

env/Kconfig
env/Makefile
env/common.c
env/env.c

index 0843104..4406f64 100644 (file)
@@ -22,6 +22,13 @@ config ENV_IS_NOWHERE
          stored. U-Boot will therefore always start up with a default
          environment.
 
+config ENV_DEFAULT_NOWHERE
+       depends on !ENV_IS_NOWHERE
+       bool "Environment is not stored if no matched location"
+       help
+         Define this when multiple ENV locations are defined and use nowhere as
+         default when no storage medium is matched.
+
 config ENV_IS_IN_EEPROM
        bool "Environment in EEPROM"
        depends on !CHAIN_OF_TRUST
index 90144d6..7ea875f 100644 (file)
@@ -19,6 +19,7 @@ obj-$(CONFIG_ENV_IS_IN_ONENAND) += onenand.o
 obj-$(CONFIG_ENV_IS_IN_SATA) += sata.o
 obj-$(CONFIG_ENV_IS_IN_REMOTE) += remote.o
 obj-$(CONFIG_ENV_IS_IN_UBI) += ubi.o
+obj-$(CONFIG_ENV_DEFAULT_NOWHERE) += nowhere.o
 else
 obj-$(CONFIG_$(SPL_TPL_)ENV_SUPPORT) += attr.o
 obj-$(CONFIG_$(SPL_TPL_)ENV_SUPPORT) += flags.o
index 324502e..d79f416 100644 (file)
@@ -228,7 +228,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_ENV_IS_NOWHERE) || defined(CONFIG_ENV_DEFAULT_NOWHERE) || defined(CONFIG_SPL_BUILD)
                /* Environment not changable */
                set_default_env(NULL, 0);
 #else
index c47ca99..3e17c69 100644 (file)
--- a/env/env.c
+++ b/env/env.c
@@ -80,7 +80,7 @@ static enum env_location env_locations[] = {
 #ifdef CONFIG_ENV_IS_IN_UBI
        ENVL_UBI,
 #endif
-#ifdef CONFIG_ENV_IS_NOWHERE
+#if defined(CONFIG_ENV_IS_NOWHERE) || defined(CONFIG_ENV_DEFAULT_NOWHERE)
        ENVL_NOWHERE,
 #endif
 };