Skip to contentSkip to conversation

ARM: imx9: support env in fat and ext4

PATCH In review Oleksandr Suvorov 3 participants 3 messages Apr 11, 2023 – Jul 11, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: imx9: support env in fat and ext4

Change boot device logic to also allow environment stored in fat and in ext4 when booting from SD or eMMC.

As the boot device check for SD and for eMMC was depending on ENV_IS_IN_MMC being defined, change the ifdef blocks at env_get_location to use IS_ENABLED instead for all modes, returning NOWHERE when no valid mode is found.

This solution is based on (with added SPL support):

---

 arch/arm/mach-imx/imx9/soc.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)
arch/arm/mach-imx/imx9/soc.c +12 -16
index a16e22ea6bb..2dfce1492bb 100644
@@ -286,35 +286,31 @@ int timer_init(void)
 enum env_location env_get_location(enum env_operation op, int prio)
 {
 	enum boot_device dev = get_boot_device();
-	enum env_location env_loc = ENVL_UNKNOWN;
 
 	if (prio)
-		return env_loc;
+		return ENVL_UNKNOWN;
 
 	switch (dev) {
-#if defined(CONFIG_ENV_IS_IN_SPI_FLASH)
 	case QSPI_BOOT:
-		env_loc = ENVL_SPI_FLASH;
-		break;
-#endif
-#if defined(CONFIG_ENV_IS_IN_MMC)
+		if (CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH))
+			return ENVL_SPI_FLASH;
+		return ENVL_NOWHERE;
 	case SD1_BOOT:
 	case SD2_BOOT:
 	case SD3_BOOT:
 	case MMC1_BOOT:
 	case MMC2_BOOT:
 	case MMC3_BOOT:
-		env_loc =  ENVL_MMC;
-		break;
-#endif
+		if (CONFIG_IS_ENABLED(ENV_IS_IN_MMC))
+			return ENVL_MMC;
+		else if (CONFIG_IS_ENABLED(ENV_IS_IN_EXT4))
+			return ENVL_EXT4;
+		else if (CONFIG_IS_ENABLED(ENV_IS_IN_FAT))
+			return ENVL_FAT;
+		return ENVL_NOWHERE;
 	default:
-#if defined(CONFIG_ENV_IS_NOWHERE)
-		env_loc = ENVL_NOWHERE;
-#endif
-		break;
+		return ENVL_NOWHERE;
 	}
-
-	return env_loc;
 }
 
 static int mix_power_init(enum mix_power_domain pd)
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Oleksandr Suvorov

Change boot device logic to also allow environment stored in fat and in ext4 when booting from SD or eMMC.

As the boot device check for SD and for eMMC was depending on ENV_IS_IN_MMC being defined, change the ifdef blocks at env_get_location to use IS_ENABLED instead for all modes, returning NOWHERE when no valid mode is found.

This solution is based on (with added SPL support):

Quoted 57 lines

---

  arch/arm/mach-imx/imx9/soc.c | 28 ++++++++++++----------------
  1 file changed, 12 insertions(+), 16 deletions(-)
arch/arm/mach-imx/imx9/soc.c +12 -16
index a16e22ea6bb..2dfce1492bb 100644
@@ -286,35 +286,31 @@ int timer_init(void)
  enum env_location env_get_location(enum env_operation op, int prio)
  {
  	enum boot_device dev = get_boot_device();
-	enum env_location env_loc = ENVL_UNKNOWN;
 
  	if (prio)
-		return env_loc;
+		return ENVL_UNKNOWN;
 
  	switch (dev) {
-#if defined(CONFIG_ENV_IS_IN_SPI_FLASH)
  	case QSPI_BOOT:
-		env_loc = ENVL_SPI_FLASH;
-		break;
-#endif
-#if defined(CONFIG_ENV_IS_IN_MMC)
+		if (CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH))
+			return ENVL_SPI_FLASH;
+		return ENVL_NOWHERE;
  	case SD1_BOOT:
  	case SD2_BOOT:
  	case SD3_BOOT:
  	case MMC1_BOOT:
  	case MMC2_BOOT:
  	case MMC3_BOOT:
-		env_loc =  ENVL_MMC;
-		break;
-#endif
+		if (CONFIG_IS_ENABLED(ENV_IS_IN_MMC))
+			return ENVL_MMC;
+		else if (CONFIG_IS_ENABLED(ENV_IS_IN_EXT4))
+			return ENVL_EXT4;
+		else if (CONFIG_IS_ENABLED(ENV_IS_IN_FAT))
+			return ENVL_FAT;
+		return ENVL_NOWHERE;
  	default:
-#if defined(CONFIG_ENV_IS_NOWHERE)
-		env_loc = ENVL_NOWHERE;
-#endif
-		break;
+		return ENVL_NOWHERE;
  	}
-
-	return env_loc;
  }
 
  static int mix_power_init(enum mix_power_domain pd)
#2 lore raw

PATCH 1/1 ARM: imx9: support env in fat and ext4

In reply to Oleksandr Suvorov
Quoted 10 lines

Change boot device logic to also allow environment stored in fat and in ext4 when booting from SD or eMMC.
As the boot device check for SD and for eMMC was depending on ENV_IS_IN_MMC being defined, change the ifdef blocks at env_get_location to use IS_ENABLED instead for all modes, returning NOWHERE when no valid mode is found.
This solution is based on (with added SPL support):

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================