[U-Boot] [PATCH 4/4] sunxi: Remove the MMC index hack

Chen-Yu Tsai wens at csie.org
Thu Aug 24 04:05:29 UTC 2017


On Wed, Aug 23, 2017 at 7:41 PM, Maxime Ripard
<maxime.ripard at free-electrons.com> wrote:
> The current code, if there's both an eMMC and an MMC slot available on the
> board, will swap the MMC indices based on whether we booted from the eMMC
> or the MMC. This way, the MMC we're supposed to boot on will always have
> the index 0.
>
> However, this causes various issues, for example when using other
> components that base their behaviour on the MMC index, such as fastboot.
>
> Let's remove that hack, and take the opposite approach. The MMC will always
> have the same index, but the bootcmd will pick the same device than the one
> we booted from. This is done through the introduction of the mmc_bootdev
> environment variable that will be filled by the board code based on the
> boot device informations we can get from the SoC.
>
> In order to not introduce regressions, we also need to adjust the fastboot
> MMC device and the environment device in order to set it to the eMMC, over
> the MMC, like it used to be the case.
>
> Signed-off-by: Maxime Ripard <maxime.ripard at free-electrons.com>
> ---
>  board/sunxi/board.c            | 20 ++++++--------------
>  include/configs/sunxi-common.h | 36 ++++++++++++++++++++++++++++++------
>  2 files changed, 36 insertions(+), 20 deletions(-)
>
> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> index e1d48140878f..664c7d2d8126 100644
> --- a/board/sunxi/board.c
> +++ b/board/sunxi/board.c
> @@ -492,20 +492,6 @@ int board_mmc_init(bd_t *bis)
>                 return -1;
>  #endif
>
> -#if !defined(CONFIG_SPL_BUILD) && CONFIG_MMC_SUNXI_SLOT_EXTRA == 2
> -       /*
> -        * On systems with an emmc (mmc2), figure out if we are booting from
> -        * the emmc and if we are make it "mmc dev 0" so that boot.scr, etc.
> -        * are searched there first. Note we only do this for u-boot proper,
> -        * not for the SPL, see spl_boot_device().
> -        */
> -       if (readb(SPL_ADDR + 0x28) == SUNXI_BOOTED_FROM_MMC2) {
> -               /* Booting from emmc / mmc2, swap */
> -               mmc0->block_dev.devnum = 1;
> -               mmc1->block_dev.devnum = 0;
> -       }
> -#endif
> -
>         return 0;
>  }
>  #endif
> @@ -725,12 +711,18 @@ int misc_init_r(void)
>
>         setenv("fel_booted", NULL);
>         setenv("fel_scriptaddr", NULL);
> +       setenv("mmc_bootdev", NULL);

This doesn't apply on master due to commit 382bee57f19b
("env: Rename setenv() to env_set()").

Works as advertised once fixed and applied.

Tested-by: Chen-Yu Tsai <wens at csie.org>


More information about the U-Boot mailing list