aboutsummaryrefslogtreecommitdiff
path: root/env
diff options
context:
space:
mode:
authorPatrick Delaunay <patrick.delaunay@foss.st.com>2022-11-10 11:49:01 +0100
committerTom Rini <trini@konsulko.com>2023-01-10 12:37:09 -0500
commitd2103e20a9f6cf92b689c1399c8a432365f94899 (patch)
treedf199bc5b8e6aa131fb2b7d779241d8e16e5b448 /env
parent8566050e247bacb734a57a2529f49139f2c63dce (diff)
downloadu-boot-d2103e20a9f6cf92b689c1399c8a432365f94899.zip
u-boot-d2103e20a9f6cf92b689c1399c8a432365f94899.tar.gz
u-boot-d2103e20a9f6cf92b689c1399c8a432365f94899.tar.bz2
env: mmc: add CONFIG_ENV_MMC_USE_DT
Add a new config CONFIG_ENV_MMC_USE_DT to force configuration of the U-Boot environment offset with device tree config node. This patch avoids issues when several CONFIG_ENV_IS_IN_XXX are activated, the defconfig file uses the same value for CONFIG_ENV_OFFSET or CONFIG_ENV_OFFSET_REDUND for the several ENV backends (SPI_FLASH, EEPROM NAND, SATA, MMC). After this patch a bad offset value is not possible when the selected partition in device tree is not found. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Diffstat (limited to 'env')
-rw-r--r--env/Kconfig16
-rw-r--r--env/mmc.c7
2 files changed, 23 insertions, 0 deletions
diff --git a/env/Kconfig b/env/Kconfig
index f73f0b8..c409ea7 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -244,6 +244,13 @@ config ENV_IS_IN_MMC
This value is also in units of bytes, but must also be aligned to
an MMC sector boundary.
+ CONFIG_ENV_MMC_USE_DT (optional):
+
+ These define forces the configuration by the config node in device
+ tree with partition name: "u-boot,mmc-env-partition" or with
+ offset: "u-boot,mmc-env-offset", "u-boot,mmc-env-offset-redundant".
+ CONFIG_ENV_OFFSET and CONFIG_ENV_OFFSET_REDUND are not used.
+
config ENV_IS_IN_NAND
bool "Environment in a NAND device"
depends on !CHAIN_OF_TRUST
@@ -652,6 +659,15 @@ config SYS_MMC_ENV_PART
partition 0 or the first boot partition, which is 1 or some other defined
partition.
+config ENV_MMC_USE_DT
+ bool "Read partition name and offset in DT"
+ depends on ENV_IS_IN_MMC && OF_CONTROL
+ help
+ Only use the device tree to get the environment location in MMC
+ device, with partition name or with offset.
+ The 2 defines CONFIG_ENV_OFFSET, CONFIG_ENV_OFFSET_REDUND
+ are not used as fallback.
+
config USE_DEFAULT_ENV_FILE
bool "Create default environment from file"
help
diff --git a/env/mmc.c b/env/mmc.c
index 661a268..1894b64 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -26,6 +26,12 @@
#define ENV_MMC_INVALID_OFFSET ((s64)-1)
+#if defined(CONFIG_ENV_MMC_USE_DT)
+/* ENV offset is invalid when not defined in Device Tree */
+#define ENV_MMC_OFFSET ENV_MMC_INVALID_OFFSET
+#define ENV_MMC_OFFSET_REDUND ENV_MMC_INVALID_OFFSET
+
+#else
/* Default ENV offset when not defined in Device Tree */
#define ENV_MMC_OFFSET CONFIG_ENV_OFFSET
@@ -34,6 +40,7 @@
#else
#define ENV_MMC_OFFSET_REDUND ENV_MMC_INVALID_OFFSET
#endif
+#endif
DECLARE_GLOBAL_DATA_PTR;