[U-Boot] [PATCH] env: mmc/fat/ext4: make sure that the MMC sub-system is initialized before using it

Faiz Abbas faiz_abbas at ti.com
Fri Feb 2 09:47:55 UTC 2018


When booting from a non-MMC device, the MMC sub-system may not be
initialized when the environment is first accessed.
We need to make sure that the MMC sub-system is ready in even a non-MMC
boot case.

Therefore, initialize mmc during .init() of environment.

Signed-off-by: Faiz Abbas <faiz_abbas at ti.com>
---
 env/ext4.c | 9 +++++++++
 env/fat.c  | 9 +++++++++
 env/mmc.c  | 8 ++++++++
 3 files changed, 26 insertions(+)

diff --git a/env/ext4.c b/env/ext4.c
index 9cdf28e..ba93e5b 100644
--- a/env/ext4.c
+++ b/env/ext4.c
@@ -123,9 +123,18 @@ err_env_relocate:
 	return -EIO;
 }
 
+static int env_ext4_init(void)
+{
+	if (!strcmp(CONFIG_ENV_FAT_INTERFACE, "mmc"))
+		mmc_initialize(NULL);
+
+	return 0;
+}
+
 U_BOOT_ENV_LOCATION(ext4) = {
 	.location	= ENVL_EXT4,
 	ENV_NAME("EXT4")
 	.load		= env_ext4_load,
 	.save		= env_save_ptr(env_ext4_save),
+	.init		= env_ext4_init,
 };
diff --git a/env/fat.c b/env/fat.c
index ec49c39..9f147ee 100644
--- a/env/fat.c
+++ b/env/fat.c
@@ -112,6 +112,14 @@ err_env_relocate:
 }
 #endif /* LOADENV */
 
+static int env_fat_init(void)
+{
+	if (!strcmp(CONFIG_ENV_FAT_INTERFACE, "mmc"))
+		mmc_initialize(NULL);
+
+	return 0;
+}
+
 U_BOOT_ENV_LOCATION(fat) = {
 	.location	= ENVL_FAT,
 	ENV_NAME("FAT")
@@ -121,4 +129,5 @@ U_BOOT_ENV_LOCATION(fat) = {
 #ifdef CMD_SAVEENV
 	.save		= env_save_ptr(env_fat_save),
 #endif
+	.init		= env_fat_init,
 };
diff --git a/env/mmc.c b/env/mmc.c
index ed7bcf1..714a073 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -365,6 +365,13 @@ err:
 }
 #endif /* CONFIG_ENV_OFFSET_REDUND */
 
+static int env_mmc_init(void)
+{
+	mmc_initialize(NULL);
+
+	return 0;
+}
+
 U_BOOT_ENV_LOCATION(mmc) = {
 	.location	= ENVL_MMC,
 	ENV_NAME("MMC")
@@ -372,4 +379,5 @@ U_BOOT_ENV_LOCATION(mmc) = {
 #ifndef CONFIG_SPL_BUILD
 	.save		= env_save_ptr(env_mmc_save),
 #endif
+	.init		= env_mmc_init,
 };
-- 
2.7.4



More information about the U-Boot mailing list