[U-Boot] [PATCH] sunxi: add an environment variable for boot media
Maxime Ripard
maxime.ripard at free-electrons.com
Thu Dec 22 16:20:33 CET 2016
On Thu, Dec 22, 2016 at 05:53:26AM +0800, Icenowy Zheng wrote:
> 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;
> + }
There's really nothing really sunxi-specific about that. This is
something that should be made generic, and is kind of redundant with
spl_boot_device. I think a good solution could reuse that function to
set that variable.
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161222/cff2cece/attachment.sig>
More information about the U-Boot
mailing list