sunxi: Select environment MMC based on boot device
authorSamuel Holland <samuel@sholland.org>
Mon, 19 Apr 2021 03:16:21 +0000 (22:16 -0500)
committerAndre Przywara <andre.przywara@arm.com>
Sat, 31 Jul 2021 23:11:34 +0000 (00:11 +0100)
Currently, the environment is always stored in eMMC if eMMC is enabled
in the config. This means images written to SD and eMMC will cross-
contaminate their environments unless the configuration is changed.

By dropping the device number from the environment location string and
implementing mmc_get_env_dev, we will always use the environment from
the boot device when booting from SD/eMMC.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
board/sunxi/board.c
env/Kconfig

index 67acc01..1a46100 100644 (file)
@@ -636,6 +636,20 @@ int board_mmc_init(struct bd_info *bis)
 
        return 0;
 }
+
+#if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1
+int mmc_get_env_dev(void)
+{
+       switch (sunxi_get_boot_device()) {
+       case BOOT_DEVICE_MMC1:
+               return 0;
+       case BOOT_DEVICE_MMC2:
+               return 1;
+       default:
+               return CONFIG_SYS_MMC_ENV_DEV;
+       }
+}
+#endif
 #endif
 
 #ifdef CONFIG_SPL_BUILD
index 691f4d4..67ff172 100644 (file)
@@ -446,8 +446,7 @@ config ENV_FAT_DEVICE_AND_PART
        depends on ENV_IS_IN_FAT
        default "0:1" if TI_COMMON_CMD_OPTIONS
        default "0:auto" if ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_VERSAL
-       default "0:auto" if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1
-       default "1:auto" if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1
+       default ":auto" if ARCH_SUNXI
        default "0" if ARCH_AT91
        help
          Define this to a string to specify the partition of the device. It can