Skip to contentSkip to conversation

Fixes for CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION* and for SOCFPGA

PATCH In review Jan Kiszka 2 participants 11 messages Dec 11, 2025 – Dec 15, 2025

Subsystems (3)
lore
Share & tools
lore
author
#5 lore raw

PATCH v3 3/5 spl: mmc: Respect sector value passed to mmc_load_image_raw_partition

In reply to Jan Kiszka

From: Jan Kiszka <[email protected]>

This function and the sector parameter evolved over the time. By now, sector is influenced by spl_mmc_get_uboot_raw_sector which allows to adjust the read sector with an offset that U-Boot proper may have inside the partition. That used to work by chance if both CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR and CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION were enabled. Since 2a00d73d081a they are a choice, and we need to drop the condition to maintain this feature.

---
 common/spl/spl_mmc.c | 4 ----
 1 file changed, 4 deletions(-)
common/spl/spl_mmc.c +0 -4
index 1942e417075..47cfe4aef58 100644
@@ -137,11 +137,7 @@ static int mmc_load_image_raw_partition(struct spl_image_info *spl_image,
 		return ret;
 	}
 
-#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
 	return mmc_load_image_raw_sector(spl_image, bootdev, mmc, info.start + sector);
-#else
-	return mmc_load_image_raw_sector(spl_image, bootdev, mmc, info.start);
-#endif
 }
 #endif
 
Signature · 1 line
2.51.0
author
#9 lore raw

PATCH v3 5/5 configs: socfpga: Fix de0_nano_soc boot

In reply to Jan Kiszka

From: Jan Kiszka <[email protected]>

By default, the de0_nano_soc used raw sectors, but the address became invalid due the raw-mode refactorings. With loading via partition type fixed, we can switch to that mode which is in line with what the ROM loader does.

Fixes 2a00d73d081a ("spl: mmc: Try to clean up raw-mode options")
---
 configs/socfpga_de0_nano_soc_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/socfpga_de0_nano_soc_defconfig +1 -0
index 32cdf6d3a6c..6564cbd03c6 100644
@@ -28,6 +28,7 @@ CONFIG_SPL_NO_BSS_LIMIT=y
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
 # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set
 CONFIG_SPL_HAVE_INIT_STACK=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x40000
 CONFIG_SYS_MAXARGS=32
Signature · 1 line
2.51.0
author
#3 lore raw

PATCH v3 2/5 spl: mmc: Account for SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE being a choice

In reply to Jan Kiszka

From: Jan Kiszka <[email protected]>

Add SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE as condition where so far SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION was enough - though often by chance as both options were enabled.

Reorder the #ifdef blocks at this chance to follow the order in the Kconfig menu.

Fixes 2a00d73d081a ("spl: mmc: Try to clean up raw-mode options")
---
 common/spl/spl_mmc.c | 17 +++++++++--------
 include/part.h       |  3 ++-
 2 files changed, 11 insertions(+), 9 deletions(-)
common/spl/spl_mmc.c +9 -8
index d8ce3a84614..1942e417075 100644
@@ -106,7 +106,8 @@ static int spl_mmc_find_device(struct mmc **mmcp, int mmc_dev)
 	return 0;
 }
 
-#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
+#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION) || \
+    defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE)
 static int mmc_load_image_raw_partition(struct spl_image_info *spl_image,
 					struct spl_boot_device *bootdev,
 					struct mmc *mmc, int partition,
@@ -419,19 +420,19 @@ int spl_mmc_load(struct spl_image_info *spl_image,
 
 		raw_sect = spl_mmc_get_uboot_raw_sector(mmc, raw_sect);
 
-#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
-		ret = mmc_load_image_raw_partition(spl_image, bootdev,
-						   mmc, raw_part,
-						   raw_sect);
-		if (!ret)
-			return 0;
-#endif
 #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
 		ret = mmc_load_image_raw_sector(spl_image, bootdev, mmc,
 						raw_sect +
 						spl_mmc_raw_uboot_offset(part));
 		if (!ret)
 			return 0;
+#elif defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION) || \
+      defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE)
+		ret = mmc_load_image_raw_partition(spl_image, bootdev,
+						   mmc, raw_part,
+						   raw_sect);
+		if (!ret)
+			return 0;
 #endif
 		/* If RAW mode fails, try FS mode. */
 		fallthrough;
include/part.h +2 -1
index 6caaa6526aa..ba4a63ddc75 100644
@@ -461,7 +461,8 @@ ulong disk_blk_erase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt);
 #ifdef CONFIG_XPL_BUILD
 # define part_print_ptr(x)	NULL
 # if defined(CONFIG_SPL_FS_EXT4) || defined(CONFIG_SPL_FS_FAT) || \
-	defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION)
+	defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION) || \
+	defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE)
 #  define part_get_info_ptr(x)	x
 # else
 #  define part_get_info_ptr(x)	NULL
Signature · 1 line
2.51.0
author
#7 lore raw

PATCH v3 4/5 arch: arm: mach-socfpga: Adjust a raw sectors for MMC loading of U-Boot from SPL

In reply to Jan Kiszka

From: Jan Kiszka <[email protected]>

If U-Boot is located on MMC, SPL and U-Boot proper are glued together. More precisely, SPL is stored 4 times. Take this and its padding into account and adjust sector number via board_spl_mmc_get_uboot_raw_sector. This allows loading from a partition, without the need to hard-code the offset via SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR

---
 arch/arm/mach-socfpga/board.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
arch/arm/mach-socfpga/board.c +11 -0
index 28554b7a109..7f65aed4540 100644
@@ -14,6 +14,7 @@
 #include <hang.h>
 #include <handoff.h>
 #include <image.h>
+#include <spl.h>
 #include <usb.h>
 #include <usb/dwc2_udc.h>
 #include <asm/global_data.h>
@@ -209,3 +210,13 @@ void lmb_arch_add_memory(void)
 	}
 }
 #endif
+
+#if (defined(CONFIG_TARGET_SOCFPGA_ARRIA10) || \
+     defined(CONFIG_TARGET_SOCFPGA_GEN5)) && defined(CONFIG_XPL_BUILD)
+unsigned long board_spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
+						 unsigned long raw_sect)
+{
+	/* offset of u-boot proper inside u-boot-with-spl.sfp image */
+	return (CONFIG_SPL_PAD_TO * 4) / 512 + raw_sect;
+}
+#endif
Signature · 1 line
2.51.0

Jan Kiszka

author
#0 lore raw

v3 cover Fixes for CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION* and for SOCFPGA

Changes in v3:
- improve commit message of patch 2
- fix #ifdef condition in patch 4

Changes in v2:
- split off "select SPL_LOAD_BLOCK" change
- address build breakage with CONFIG_SPL_SYS_MMCSD_RAW_MODE off
- fix build condition and add comment to mach-socfpga/board.c patch

Several fixes needed after the mmc raw-mode was consolidated a while ago. Not all the fallouts can be blamed to that refactoring. It also looks to me like booting from mmc just worked by chance before.

This series now permits U-Boot proper loading from SPL via partition type, at least on the DE0-Nano-SoC (other boards not available for testing).

Note that even if the socfpga specific changes should not be accepted due to switching to fat mode booting, the first two patches are generic fixes, affecting all RAW_MODE_U_BOOT_USE_PARTITION_TYPE user - of which we have none in-tree, though.

Jan

Jan Kiszka (5):
spl: Kconfig: Add missing SPL_LOAD_BLOCK for
SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE
spl: mmc: Account for SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE
being a choice
spl: mmc: Respect sector value passed to mmc_load_image_raw_partition
arch: arm: mach-socfpga: Adjust a raw sectors for MMC loading of
U-Boot from SPL
configs: socfpga: Fix de0_nano_soc boot

 arch/arm/mach-socfpga/board.c          | 11 +++++++++++
 common/spl/Kconfig                     |  1 +
 common/spl/spl_mmc.c                   | 21 +++++++++------------
 configs/socfpga_de0_nano_soc_defconfig |  1 +
 include/part.h                         |  3 ++-
 5 files changed, 24 insertions(+), 13 deletions(-)
Signature · 1 line
2.51.0
author
#1 lore raw

PATCH v3 1/5 spl: Kconfig: Add missing SPL_LOAD_BLOCK for SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE

From: Jan Kiszka <[email protected]>

We need to explicitly select SPL_LOAD_BLOCK when USE_PARTITION_TYPE is enabled, just like the other choices do.

Fixes 2a00d73d081a ("spl: mmc: Try to clean up raw-mode options")
---
 common/spl/Kconfig | 1 +
 1 file changed, 1 insertion(+)
common/spl/Kconfig +1 -0
index 3b7b6cafef8..142cdb34cd5 100644
@@ -573,6 +573,7 @@ config 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"
+	select SPL_LOAD_BLOCK
 	depends on DOS_PARTITION
 	help
 	  Use partition type for specifying U-Boot partition on MMC/SD in
Signature · 1 line
2.51.0
Reviewed-by Tien Fong Chee on v3 1/5
#2 lore raw

Re: [PATCH v3 1/5] spl: Kconfig: Add missing SPL_LOAD_BLOCK for SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE

Quoted 26 lines · Jan Kiszka

[CAUTION: This email is from outside your organization. Unless you trust the sender, do not click on links or open attachments as it may be a fraudulent email attempting to steal your information and/or compromise your computer.]

From: Jan Kiszka <[email protected]>

We need to explicitly select SPL_LOAD_BLOCK when USE_PARTITION_TYPE is enabled, just like the other choices do.

Fixes 2a00d73d081a ("spl: mmc: Try to clean up raw-mode options")
---
  common/spl/Kconfig | 1 +
  1 file changed, 1 insertion(+)
common/spl/Kconfig +1 -1
index 3b7b6cafef8..142cdb34cd5 100644
@@ -573,6 +573,7 @@ config 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"
+       select SPL_LOAD_BLOCK
         depends on DOS_PARTITION
         help
           Use partition type for specifying U-Boot partition on MMC/SD in
--
Quoted 1 line

2.51.0

Best regards,
Tien Fong

Reviewed-by Tien Fong Chee on v3 2/5
#4 lore raw

Re: [PATCH v3 2/5] spl: mmc: Account for SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE being a choice

In reply to Jan Kiszka
Quoted 74 lines · Jan Kiszka

[CAUTION: This email is from outside your organization. Unless you trust the sender, do not click on links or open attachments as it may be a fraudulent email attempting to steal your information and/or compromise your computer.]

From: Jan Kiszka <[email protected]>

Add SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE as condition where so far SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION was enough - though often by chance as both options were enabled.

Reorder the #ifdef blocks at this chance to follow the order in the Kconfig menu.

Fixes 2a00d73d081a ("spl: mmc: Try to clean up raw-mode options")
---
  common/spl/spl_mmc.c | 17 +++++++++--------
  include/part.h       |  3 ++-
  2 files changed, 11 insertions(+), 9 deletions(-)
common/spl/spl_mmc.c +9 -8
index d8ce3a84614..1942e417075 100644
@@ -106,7 +106,8 @@ static int spl_mmc_find_device(struct mmc **mmcp, int mmc_dev)
         return 0;
  }
 
-#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
+#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION) || \
+    defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE)
  static int mmc_load_image_raw_partition(struct spl_image_info *spl_image,
                                         struct spl_boot_device *bootdev,
                                         struct mmc *mmc, int partition,
@@ -419,19 +420,19 @@ int spl_mmc_load(struct spl_image_info *spl_image,
 
                 raw_sect = spl_mmc_get_uboot_raw_sector(mmc, raw_sect);
 
-#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
-               ret = mmc_load_image_raw_partition(spl_image, bootdev,
-                                                  mmc, raw_part,
-                                                  raw_sect);
-               if (!ret)
-                       return 0;
-#endif
  #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
                 ret = mmc_load_image_raw_sector(spl_image, bootdev, mmc,
                                                 raw_sect +
                                                 spl_mmc_raw_uboot_offset(part));
                 if (!ret)
                         return 0;
+#elif defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION) || \
+      defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE)
+               ret = mmc_load_image_raw_partition(spl_image, bootdev,
+                                                  mmc, raw_part,
+                                                  raw_sect);
+               if (!ret)
+                       return 0;
  #endif
                 /* If RAW mode fails, try FS mode. */
                 fallthrough;
include/part.h +2 -2
index 6caaa6526aa..ba4a63ddc75 100644
@@ -461,7 +461,8 @@ ulong disk_blk_erase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt);
  #ifdef CONFIG_XPL_BUILD
  # define part_print_ptr(x)     NULL
  # if defined(CONFIG_SPL_FS_EXT4) || defined(CONFIG_SPL_FS_FAT) || \
-       defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION)
+       defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION) || \
+       defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE)
  #  define part_get_info_ptr(x) x
  # else
  #  define part_get_info_ptr(x) NULL
--
Quoted 1 line

2.51.0

Best regards,
Tien Fong

Reviewed-by Tien Fong Chee on v3 3/5
#6 lore raw

Re: [PATCH v3 3/5] spl: mmc: Respect sector value passed to mmc_load_image_raw_partition

In reply to Jan Kiszka
Quoted 35 lines · Jan Kiszka

[CAUTION: This email is from outside your organization. Unless you trust the sender, do not click on links or open attachments as it may be a fraudulent email attempting to steal your information and/or compromise your computer.]

From: Jan Kiszka <[email protected]>

This function and the sector parameter evolved over the time. By now, sector is influenced by spl_mmc_get_uboot_raw_sector which allows to adjust the read sector with an offset that U-Boot proper may have inside the partition. That used to work by chance if both CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR and CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION were enabled. Since 2a00d73d081a they are a choice, and we need to drop the condition to maintain this feature.

---
  common/spl/spl_mmc.c | 4 ----
  1 file changed, 4 deletions(-)
common/spl/spl_mmc.c +0 -5
index 1942e417075..47cfe4aef58 100644
@@ -137,11 +137,7 @@ static int mmc_load_image_raw_partition(struct spl_image_info *spl_image,
                 return ret;
         }
 
-#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
         return mmc_load_image_raw_sector(spl_image, bootdev, mmc, info.start + sector);
-#else
-       return mmc_load_image_raw_sector(spl_image, bootdev, mmc, info.start);
-#endif
  }
  #endif
 
--
Quoted 1 line

2.51.0

Best regards,
Tien Fong

Reviewed-by Tien Fong Chee on v3 4/5
#8 lore raw

Re: [PATCH v3 4/5] arch: arm: mach-socfpga: Adjust a raw sectors for MMC loading of U-Boot from SPL

In reply to Jan Kiszka
Quoted 42 lines · Jan Kiszka

[CAUTION: This email is from outside your organization. Unless you trust the sender, do not click on links or open attachments as it may be a fraudulent email attempting to steal your information and/or compromise your computer.]

From: Jan Kiszka <[email protected]>

If U-Boot is located on MMC, SPL and U-Boot proper are glued together. More precisely, SPL is stored 4 times. Take this and its padding into account and adjust sector number via board_spl_mmc_get_uboot_raw_sector. This allows loading from a partition, without the need to hard-code the offset via SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR

---
  arch/arm/mach-socfpga/board.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
arch/arm/mach-socfpga/board.c +11 -1
index 28554b7a109..7f65aed4540 100644
@@ -14,6 +14,7 @@
  #include <hang.h>
  #include <handoff.h>
  #include <image.h>
+#include <spl.h>
  #include <usb.h>
  #include <usb/dwc2_udc.h>
  #include <asm/global_data.h>
@@ -209,3 +210,13 @@ void lmb_arch_add_memory(void)
         }
  }
  #endif
+
+#if (defined(CONFIG_TARGET_SOCFPGA_ARRIA10) || \
+     defined(CONFIG_TARGET_SOCFPGA_GEN5)) && defined(CONFIG_XPL_BUILD)
+unsigned long board_spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
+                                                unsigned long raw_sect)
+{
+       /* offset of u-boot proper inside u-boot-with-spl.sfp image */
+       return (CONFIG_SPL_PAD_TO * 4) / 512 + raw_sect;
+}
+#endif
--
Quoted 1 line

2.51.0

Best regards,
Tien Fong

Reviewed-by Tien Fong Chee on v3 5/5
#10 lore raw

Re: [PATCH v3 5/5] configs: socfpga: Fix de0_nano_soc boot

In reply to Jan Kiszka
Quoted 28 lines · Jan Kiszka

[CAUTION: This email is from outside your organization. Unless you trust the sender, do not click on links or open attachments as it may be a fraudulent email attempting to steal your information and/or compromise your computer.]

From: Jan Kiszka <[email protected]>

By default, the de0_nano_soc used raw sectors, but the address became invalid due the raw-mode refactorings. With loading via partition type fixed, we can switch to that mode which is in line with what the ROM loader does.

Fixes 2a00d73d081a ("spl: mmc: Try to clean up raw-mode options")
---
  configs/socfpga_de0_nano_soc_defconfig | 1 +
  1 file changed, 1 insertion(+)
configs/socfpga_de0_nano_soc_defconfig +1 -1
index 32cdf6d3a6c..6564cbd03c6 100644
@@ -28,6 +28,7 @@ CONFIG_SPL_NO_BSS_LIMIT=y
  # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
  # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set
  CONFIG_SPL_HAVE_INIT_STACK=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE=y
  CONFIG_SPL_SPI_LOAD=y
  CONFIG_SYS_SPI_U_BOOT_OFFS=0x40000
  CONFIG_SYS_MAXARGS=32
--
Quoted 1 line

2.51.0

Best regards,
Tien Fong