[U-Boot] [PATCH] sunxi: add an environment variable for boot media
Icenowy Zheng
icenowy at aosc.xyz
Wed Dec 21 22:53:26 CET 2016
Some board features different medias available for boot, for example, a
MicroSD slot and an eMMC or two MicroSD slots.
Add an environment variable which indicates the boot media during boot,
so that the boot script can choose the kernel parameter, device tree
property, etc. according to this environment variable.
Tested on Lichee Pi One, which features two MicroSD slots (MMC0 and
MMC2)
Signed-off-by: Icenowy Zheng <icenowy at aosc.xyz>
---
board/sunxi/board.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 53656383d5..81ca27e16b 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -694,8 +694,26 @@ int misc_init_r(void)
/* determine if we are running in FEL mode */
if (!is_boot0_magic(SPL_ADDR + 4)) { /* eGON.BT0 */
setenv("fel_booted", "1");
+ setenv("boot_media", "fel");
parse_spl_header(SPL_ADDR);
}
+ else switch (readb(SPL_ADDR + 0x28)) {
+ case SUNXI_BOOTED_FROM_MMC0:
+ setenv("boot_media", "mmc0");
+ break;
+ case SUNXI_BOOTED_FROM_NAND:
+ setenv("boot_media", "nand");
+ break;
+ case SUNXI_BOOTED_FROM_MMC2:
+ setenv("boot_media", "mmc2");
+ break;
+ case SUNXI_BOOTED_FROM_SPI:
+ setenv("boot_media", "spi");
+ break;
+ default:
+ setenv("boot_media", "unknown");
+ break;
+ }
setup_environment(gd->fdt_blob);
--
2.11.0
More information about the U-Boot
mailing list