[PATCH 1/8] spacemit: k1: select boot device via config registers
Eric Chung
eric.chung at riscstar.com
Wed Jun 24 09:25:43 CEST 2026
On Wed, Jun 24, 2026 at 12:36 PM Yao Zi <me at ziyao.cc> wrote:
>
> On Wed, Jun 24, 2026 at 08:46:40AM +0800, Eric Chung wrote:
> > On Sat, Jun 13, 2026 at 11:51 AM 'Yao Zi' via uboot <uboot at riscstar.com> wrote:
> > >
> > > On Fri, Jun 12, 2026 at 04:18:54PM -0400, Raymond Mao wrote:
> > > > From: Guodong Xu <guodong at riscstar.com>
> > > >
> > > > Add logic to determine the current boot device by reading the
> > > > SoC's configuration registers, rather than using a hardcoded
> > > > default.
> > > >
> > > > Signed-off-by: Guodong Xu <guodong at riscstar.com>
> > > > Signed-off-by: Raymond Mao <raymond.mao at riscstar.com>
> > > > ---
> > > > board/spacemit/k1/spl.c | 77 ++++++++++++++++++++++++++++++++++++++++-
> > > > 1 file changed, 76 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/board/spacemit/k1/spl.c b/board/spacemit/k1/spl.c
> > > > index 0db362130e4..d5e87d79fa2 100644
> > > > --- a/board/spacemit/k1/spl.c
> > > > +++ b/board/spacemit/k1/spl.c
> > >
> > > ...
> > > > + switch (sel) {
> > > > + case BOOT_STRAP_MODE_EMMC:
> > > > + mode = BOOT_MODE_EMMC;
> > > > + break;
> > > > + case BOOT_STRAP_MODE_NAND:
> > > > + mode = BOOT_MODE_NAND;
> > > > + break;
> > > > + case BOOT_STRAP_MODE_SPI:
> > > > + mode = BOOT_MODE_SPI;
> > > > + break;
> > > > + case BOOT_STRAP_MODE_SD:
> > > > + default:
> > > > + mode = BOOT_MODE_SD;
> > > > + break;
> > > > + }
> > > > + }
> > > > + /* TODO:
> > > > + * The current upstream DTS file only contains the eMMC node. When
> > > > + * the SD node is added via an overlay, the eMMC device ends up as
> > > > + * MMC1 in SPL.
> > >
> > > Why not fix this with an extra alias in the overlay dt?
> > >
> >
> > That approach doesn't really help — with the alias, mmc0 and mmc1 get
> > swapped, which ultimately breaks ABI consistency.
>
> Sorry I didn't read you correctly, I'm not sure which you are trying to
> keep consistency with.
>
> I did a check in Linux next-20260623, and the aliases for bananapi-f3
> look like,
>
> aliases {
> ethernet0 = ð0;
> ethernet1 = ð1;
> serial0 = &uart0;
> spi3 = &spi3;
> i2c2 = &i2c2;
> i2c8 = &i2c8;
> mmc0 = &emmc;
> mmc1 = &sdhci0;
> };
>
> and for musepi-pro,
>
> aliases {
> ethernet0 = ð0;
> serial0 = &uart0;
> i2c2 = &i2c2;
> i2c8 = &i2c8;
> mmc0 = &emmc;
> mmc1 = &sdhci0;
> };
>
> So both of them assign emmc to mmc0 and sdhci0 (SD) to mmc1.
>
> As a summary of the situation,
>
> - Linux before SD card support is merged: emmc becomes mmc0 (without
> other hotpluggable devices present), no SD card
> - Linux after SD card support is merged: emmc becomes mmc0, SD becomes
> mmc1
>
Because I don't know there's a new alias in upstream DTS.
OK. I can use the alias in uboot.
> But PATCH 3 in the series assigns SD to mmc0 and emmc to MMC1, this
> instead looks like an ABI breakage, and would go away as long as you
> change the aliases? At the same time the comment here could be dropped.
>
> > The hack on MMC1 only affects its role in SPL and doesn't impact the
> > ABI in the devicetree. It's just a workaround. Eventually, both the
> > overlay and the hack will be removed once the upstream DTS is robust
> > enough.
> >
> >
> > > > + * However, the SD device should be the first device (MMC1).
> > > > + * This sequence needs to be corrected once the SD node is merged
> > > > + * into the upstream U-Boot DTS file.
> > > > + */
> > > > + switch (mode) {
> > > > + case BOOT_MODE_EMMC:
> > > > + ret = BOOT_DEVICE_MMC1;
> > > > + break;
> > > > + case BOOT_MODE_NAND:
> > > > + ret = BOOT_DEVICE_NAND;
> > > > + break;
> > > > + case BOOT_MODE_SPI:
> > > > + ret = BOOT_DEVICE_SPI;
> > > > + break;
> > > > + case BOOT_MODE_USB:
> > > > + ret = BOOT_DEVICE_USB;
> > > > + break;
> > > > + case BOOT_MODE_SD:
> > > > + ret = BOOT_DEVICE_MMC2;
> > > > + break;
> > > > + default:
> > > > + ret = BOOT_DEVICE_MMC1;
> > > > + break;
> > > > + }
> > > > + return ret;
> > > > }
> > > >
> > > > void spl_board_init(void)
> > > > --
> > > > 2.25.1
> > > >
> > >
> > > Regards,
> > > Yao Zi
>
> Regards,
> Yao Zi
More information about the U-Boot
mailing list