On Sat, Oct 3, 2026 at 5:31 AM Dave Klotz <[email protected]> wrote:
>
> spl_boot_device() derives the boot device from BootROM state: the SD
> API pointer the BootROM leaves in SRAM, the boot flag register, and the
> boot strap. Not every BootROM path is covered by that. On the OrangePi
> R2S, for example, the BootROM probes a card first ("try sd...") and only
> then loads the FSBL from eMMC, and on the OrangePi RV2 it falls back
> from the card to SPI NOR. If the detection names a device that holds no
> image, the SPL stops with "failed to boot from all boot devices".
>
> Provide board_boot_order(): the detected device first, then the other
> MMC controller and SPI NOR when this SPL can read them.
>
> Signed-off-by: Dave Klotz <[email protected]>
> ---
>  board/spacemit/k1/spl.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
>
> diff --git a/board/spacemit/k1/spl.c b/board/spacemit/k1/spl.c
> index 96ee4449c4..cc0e26bb02 100644
> --- a/board/spacemit/k1/spl.c
> +++ b/board/spacemit/k1/spl.c
> @@ -498,6 +498,32 @@ u32 spl_boot_device(void)
>         return ret;
>  }
>
> +/*
> + * Try the device the BootROM booted from first, then the other storage
> + * this SPL can read. The boot-mode detection relies on BootROM state; if
> + * it names a device that holds no image (the BootROM probed a card before
> + * falling back to eMMC, say), the SPL still finds U-Boot instead of
> + * stopping at "failed to boot from all boot devices".
> + */
> +void board_boot_order(u32 *spl_boot_list)
> +{
> +       u32 fallbacks[3];
> +       int i, n = 0, m = 0;
> +
> +       if (CONFIG_IS_ENABLED(MMC)) {
> +               fallbacks[m++] = BOOT_DEVICE_MMC1;
> +               fallbacks[m++] = BOOT_DEVICE_MMC2;
> +       }
> +       if (CONFIG_IS_ENABLED(SPI_LOAD))
> +               fallbacks[m++] = BOOT_DEVICE_SPI;
> +
> +       spl_boot_list[n++] = spl_boot_device();
> +       for (i = 0; i < m; i++)
> +               if (fallbacks[i] != spl_boot_list[0])
> +                       spl_boot_list[n++] = fallbacks[i];
> +       spl_boot_list[n] = BOOT_DEVICE_NONE;
> +}
> +
>  void spl_board_init(void)
>  {
>  }
> --
> 2.55.0
>
>

Reviewed-by: Eric Chung <[email protected]>

Reply via email to