sunxi: Select environment MMC based on boot device
Samuel Holland
maintainerPATCH 1/1 sunxi: Select environment MMC based on boot device
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.
--- board/sunxi/board.c | 14 ++++++++++++++ env/Kconfig | 3 +-- 2 files changed, 15 insertions(+), 2 deletions(-)
board/sunxi/board.c +14 -0
@@ -624,6 +624,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
env/Kconfig +1 -2
@@ -430,10 +430,9 @@ config ENV_FAT_INTERFACE config ENV_FAT_DEVICE_AND_PART string "Device and partition for where to store the environemt in FAT" depends on ENV_IS_IN_FAT + default ":auto" if ARCH_SUNXI default "0:1" if TI_COMMON_CMD_OPTIONS default "0:auto" if ARCH_ZYNQ || ARCH_ZYNQMP - default "0:auto" if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1 - default "1:auto" if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1 default "0" if ARCH_AT91 help Define this to a string to specify the partition of the device. It can
Signature · 1 line
2.26.3
PATCH 1/1 sunxi: Select environment MMC based on boot device
On Sun, 18 Apr 2021 22:16:21 -0500
Samuel Holland <[email protected]> wrote:
(CC:ing Maxime)
Hi,
Quoted 7 lines
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.
Yeah, indeed, thanks for sending this. I will have a closer look and test tonight.
AFAIR Maxime had reservations towards this approach in the past, he mentioned that this fixed environment location had a use case?
Maxime, can you comment whether this is still needed? I think being able to just "dd" (or "mmc write" in U-Boot) the very same image to an eMMC is a very compelling use case, to install firmware from a bootable SD card. I have patches to a similar effect, including loading the env from SPI when booting from SPI, and a U-Boot menu to make this user friendly, so would like to know whether we can push this forward.
Cheers,
Andre.
Quoted 48 lines
Signed-off-by Samuel Holland <[email protected]>--- board/sunxi/board.c | 14 ++++++++++++++ env/Kconfig | 3 +-- 2 files changed, 15 insertions(+), 2 deletions(-)board/sunxi/board.c +14
-0@@ -624,6 +624,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 env/Kconfig +1
-2@@ -430,10 +430,9 @@ config ENV_FAT_INTERFACE config ENV_FAT_DEVICE_AND_PART string "Device and partition for where to store the environemt in FAT" depends on ENV_IS_IN_FAT + default ":auto" if ARCH_SUNXI default "0:1" if TI_COMMON_CMD_OPTIONS default "0:auto" if ARCH_ZYNQ || ARCH_ZYNQMP - default "0:auto" if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1 - default "1:auto" if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1 default "0" if ARCH_AT91 help Define this to a string to specify the partition of the device. It can
PATCH 1/1 sunxi: Select environment MMC based on boot device
Hi,
Quoted 21 lines · Andre Przywara
On Sun, 18 Apr 2021 22:16:21 -0500
Samuel Holland <[email protected]> wrote:(CC:ing Maxime)
Hi,
Quoted 7 lines
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.Yeah, indeed, thanks for sending this. I will have a closer look and test tonight.
AFAIR Maxime had reservations towards this approach in the past, he mentioned that this fixed environment location had a use case?
Quoted 6 lines
Maxime, can you comment whether this is still needed? I think being able to just "dd" (or "mmc write" in U-Boot) the very same image to an eMMC is a very compelling use case, to install firmware from a bootable SD card. I have patches to a similar effect, including loading the env from SPI when booting from SPI, and a U-Boot menu to make this user friendly, so would like to know whether we can push this forward.
I don't recall, really, and it's really a matter of policy. If you want to change it please go ahead, you're in charge now ;)
The only thing that would be great to keep as is would be fastboot (or at least until we have some way to select which device we want to flash).
Maxime
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210426/7773ec06/attachment.sig>