[U-Boot] [PATCH 4/6] sunxi: When we've both mmc0 and mmc2, detect from which one we're booting

Ian Campbell ijc at hellion.org.uk
Sat Oct 4 10:35:54 CEST 2014


On Fri, 2014-10-03 at 17:05 +0200, Hans de Goede wrote:
> sunxi SOCs can boot from both mmc0 and mmc2, detect from which one we're
> booting, and make that one "mmc dev 0" so that a single u-boot binary can
> be used for both the onboard eMMC and for external sdcards.

Where does the dependency on dev 0 being the boot device come from? Is
it just the env via CONFIG_SYS_MMC_ENV_DEV?

If it's just that then is it allowable to define CONFIG_SYS_MMC_ENV_DEV
as a call to a function which returns the appropriate number?

Or maybe mmc->block_dev.dev already doesn't correspond to the h/w
controller number? So dev==0 is completely arbitrary?

> +#if CONFIG_MMC_SUNXI_SLOT == 0 && CONFIG_MMC_SUNXI_SLOT_EXTRA == 2
> +	/*
> +	 * Both mmc0 and mmc2 are bootable, figure out where we're booting
> +	 * from. Try mmc0 first, just like the brom does.
> +	 */
> +	if (mmc_getcd(mmc0) && mmc_init(mmc0) == 0 &&
> +	    mmc0->block_dev.block_read(0, 16, 1, buf) == 1) {
> +		buf[12] = 0;
> +		if (strcmp(&buf[4], "eGON.BT0") == 0)
> +			return 0;

This just checks if the mmc is bootable, not necessarily that we booted
from it, does it? Or is "just like the brom does" implying that the
bootrom would always have booted mmc0 if this signature was there? is
that check sufficient or does the brom check other stuff, e.g.
signatures etc or have a fallback path if mmc0 fails to boot somehow?

Ian.



More information about the U-Boot mailing list