On Thu, Sep 10, 2026 at 07:49:29AM +0200, Carlo Caione wrote:

> Boards may need to select the boot partition using on-device metadata,
> such as A/B slot state. The existing partition hook runs before MMC
> initialization, so it cannot read that metadata.
> 
> A separate dynamic-partition mode makes this policy explicit while
> preserving fixed-partition selection and explicit requests to load other
> firmware.
> 
> Signed-off-by: Carlo Caione <[email protected]>
> ---
>  common/spl/Kconfig   |  9 +++++++
>  common/spl/spl_mmc.c | 67 
> +++++++++++++++++++++++++++++++++++++---------------
>  include/part.h       |  3 ++-
>  include/spl.h        | 21 ++++++++++++++++
>  4 files changed, 80 insertions(+), 20 deletions(-)
> 
> diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> index 0618f42c941..f5904af3ed2 100644
> --- a/common/spl/Kconfig
> +++ b/common/spl/Kconfig
> @@ -574,6 +574,15 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE
>         raw mode. U-Boot will be loaded from the first partition of this
>         type to be found.
>  
> +config SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_DYNAMIC
> +     bool "MMC raw mode: by board-selected partition"
> +     select SPL_LOAD_BLOCK
> +     depends on SPL_PARTITIONS
> +     help
> +       Use a partition selected by the board at runtime for loading
> +       U-Boot when using MMC/SD in raw mode.
> +       Override spl_mmc_get_uboot_raw_partition() to select the partition.

This seems interesting. But, looking at the resulting code, it was
already a little bit of a mess for
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION vs
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE and it doesn't make
sense I assume to enable both at once, and now a 3rd option. So, can you
please think about if any of these would help?
- Turn the current two options in to a choice, then see about
  simplifying / clarifying the code. Then add your new option, and
  hopefully keep the newly gained clarity.
- Restructure things so that we can have a __weak function and override
  it already, as I imagine the metadata here will end up being fairly
  implementation-specific.
- Move up the mmc initialization to be earlier.

Thanks!

-- 
Tom

Attachment: signature.asc
Description: PGP signature

Reply via email to