env/ext4.c: allow loading from an EXT4 partition on the MMC boot device
authorDavid Woodhouse <dwmw2@infradead.org>
Tue, 4 Aug 2020 09:05:47 +0000 (10:05 +0100)
committerTom Rini <trini@konsulko.com>
Wed, 14 Oct 2020 15:16:34 +0000 (11:16 -0400)
This parallels what I added for FAT in commit 6731bef6966, allowing the
environment to be found in a specific partition on the device that the
board's mmc_get_env_dev() returns. On the Banana Pi R2 that means the
device that U-Boot was loaded from; either the internal eMMC or an SD
card.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
env/Kconfig
env/ext4.c

index c6ba08878d672d9e608fef0f4151df7a89365abb..aa63fae021e94fbf11b26c33a66b94343279de0b 100644 (file)
@@ -477,6 +477,10 @@ config ENV_EXT4_DEVICE_AND_PART
                           If none, first valid partition in device D. If no
                           partition table then means device D.
 
+         If ENV_EXT4_INTERFACE is set to "mmc" then device 'D' can be omitted,
+         leaving the string starting with a colon, and the boot device will
+         be used.
+
 config ENV_EXT4_FILE
        string "Name of the EXT4 file to use for the environment"
        depends on ENV_IS_IN_EXT4
index f823b694099bbe95e056f0cc462a912a0e15c409..e666f7b9455ad3d3abd561fcd913a51afec8f2dd 100644 (file)
@@ -41,7 +41,21 @@ __weak const char *env_ext4_get_intf(void)
 
 __weak const char *env_ext4_get_dev_part(void)
 {
+#ifdef CONFIG_MMC
+       static char *part_str;
+
+       if (!part_str) {
+               part_str = CONFIG_ENV_EXT4_DEVICE_AND_PART;
+               if (!strcmp(CONFIG_ENV_EXT4_INTERFACE, "mmc") && part_str[0] == ':') {
+                       part_str = "0" CONFIG_ENV_EXT4_DEVICE_AND_PART;
+                       part_str[0] += mmc_get_env_dev();
+               }
+       }
+
+       return part_str;
+#else
        return (const char *)CONFIG_ENV_EXT4_DEVICE_AND_PART;
+#endif
 }
 
 static int env_ext4_save_buffer(env_t *env_new)