[PATCH 1/1] spl: allow loading via partition type GUID
Heinrich Schuchardt
heinrich.schuchardt at canonical.com
Thu Feb 16 16:08:59 CET 2023
Some boards provide main U-Boot as a dedicated partition to SPL.
Currently we can define either a fixed partition number or an MBR
partition type to define which partition is to be used.
Partition numbers tend to conflict with established partitioning schemes
of Linux distros. MBR partitioning is more and more replaced by GPT
partitioning.
Allow defining a partition type GUID identifying the partition to load
main U-Boot from.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
common/spl/Kconfig | 33 +++++++++++++++++++++++++++------
common/spl/spl_mmc.c | 13 +++++++++++++
2 files changed, 40 insertions(+), 6 deletions(-)
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 3c2af453ab..29166d8b98 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -513,20 +513,41 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION
Partition on the MMC to load U-Boot from when the MMC is being
used in raw mode
+if SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
+
config SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE
- bool "MMC raw mode: by partition type"
- depends on DOS_PARTITION && SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
+ bool "MMC raw mode: by MBR partition type"
+ depends on DOS_PARTITION
help
- Use partition type for specifying U-Boot partition on MMC/SD in
+ Use MBR partition type for specifying U-Boot partition on MMC/SD in
raw mode. U-Boot will be loaded from the first partition of this
type to be found.
config SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_TYPE
- hex "Partition Type on the MMC to load U-Boot from"
+ hex "MBR Partition Type on the MMC to load U-Boot from"
depends on SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE
help
- Partition Type on the MMC to load U-Boot from, when the MMC is being
- used in raw mode.
+ MBR Partition Type on the MMC to load U-Boot from, when the MMC is
+ being used in raw mode.
+
+config SYS_MMCSD_RAW_MODE_U_BOOT_USE_GPT_PARTITION_TYPE
+ bool "MMC raw mode: GPT by partition type"
+ depends on PARTITION_TYPE_GUID
+ help
+ Use GPT partition type for specifying U-Boot partition on MMC/SD in
+ raw mode. U-Boot will be loaded from the first partition of this
+ type to be found.
+
+config SYS_MMCSD_RAW_MODE_U_BOOT_GPT_PARTITION_TYPE
+ string "GPT Partition Type on the MMC to load U-Boot from"
+ depends on SYS_MMCSD_RAW_MODE_U_BOOT_USE_GPT_PARTITION_TYPE
+ default d2f002f8-e4e7-4269-b8ac-3bb6fabeaff6
+ help
+ GPT Partition Type on the MMC to load U-Boot from, when the MMC is
+ being used in raw mode. The GUID must be lower case, low endian,
+ and formatted like d2f002f8-e4e7-4269-b8ac-3bb6fabeaff6.
+
+endif
config SUPPORT_EMMC_BOOT_OVERRIDE_PART_CONFIG
bool "Override eMMC EXT_CSC_PART_CONFIG by user defined partition"
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index e4135b2048..69bf1d6e98 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -191,6 +191,19 @@ static int mmc_load_image_raw_partition(struct spl_image_info *spl_image,
struct disk_partition info;
int err;
+#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_GPT_PARTITION_TYPE
+ for (int i = 1; i <= MAX_SEARCH_PARTITIONS; ++i) {
+ err = part_get_info(mmc_get_blk_desc(mmc), i, &info);
+ if (err)
+ continue;
+ if (!strncmp(info.type_guid,
+ CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_GPT_PARTITION_TYPE,
+ UUID_STR_LEN)) {
+ partition = i;
+ break;
+ }
+ }
+#endif
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE
int type_part;
/* Only support MBR so DOS_ENTRY_NUMBERS */
--
2.38.1
More information about the U-Boot
mailing list