Skip to contentSkip to conversation

Fixes for CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION* and for SOCFPGA

PATCH Superseded Jan Kiszka 4 participants 29 messages Nov 14, 2025 – Nov 27, 2025 2 messages not in the archive

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

cover Fixes for CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION* and for SOCFPGA

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).

Jan

Jan Kiszka (4):
spl: mmc: Respect sector value passed to mmc_load_image_raw_partition
spl: mmc: Account for SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE
being a choice
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          |  9 +++++++++
 common/spl/Kconfig                     |  1 +
 common/spl/spl_mmc.c                   | 20 ++++++++------------
 configs/socfpga_de0_nano_soc_defconfig |  1 +
 include/part.h                         |  3 ++-
 5 files changed, 21 insertions(+), 13 deletions(-)
Signature · 1 line
2.51.0
author
#1 lore raw

PATCH 1/4 spl: mmc: Respect sector value passed to mmc_load_image_raw_partition

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 d8ce3a84614..467114f8d9a 100644
@@ -136,11 +136,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
#2 lore raw

Re: [PATCH 1/4] spl: mmc: Respect sector value passed to mmc_load_image_raw_partition

Quoted 21 lines · 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 -0
index d8ce3a84614..467114f8d9a 100644

common/spl/spl_mmc.c static int mmc_load_image_raw_partition(struct spl_image_info *spl_image, · line 143

Quoted 8 lines
common/spl/spl_mmc.c +0 -4
@@ -136,11 +136,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

Could it be, that what you need are two Kconfig options -- one sector offset for raw mode (default to 0) and one sector offset for partition (default to 0) ?

author
#3 lore raw

Re: [PATCH 1/4] spl: mmc: Respect sector value passed to mmc_load_image_raw_partition

Quoted 28 lines · Marek Vasut
Quoted 27 lines · 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 -0
index d8ce3a84614..467114f8d9a 100644
@@ -136,11 +136,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);

Quoted 8 lines
Quoted 4 lines

-#else
-    return mmc_load_image_raw_sector(spl_image, bootdev, mmc, info.start);
-#endif

Could it be, that what you need are two Kconfig options -- one sector offset for raw mode (default to 0) and one sector offset for partition (default to 0) ?

As the modes are now exclusive-or, I don't see that need. You configure an offset, and that is relative to the different baselines. But use sector mode only makes sense when a romloader forces you to hard offset anyway. The SOCFPGA uses magic partitions, thus does not come with such a limitation.

Jan

Signature · 2 lines
Siemens AG, Foundational Technologies
Linux Expert Center
author
#4 lore raw

PATCH 2/4 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.

We also need to explicitly select SPL_LOAD_BLOCK when UES_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 +
 common/spl/spl_mmc.c | 16 ++++++++--------
 include/part.h       |  3 ++-
 3 files changed, 11 insertions(+), 9 deletions(-)
common/spl/Kconfig +1 -0
index 8dade2b501e..d24466b0c66 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
common/spl/spl_mmc.c +8 -8
index 467114f8d9a..09e881c464c 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,
@@ -415,19 +416,18 @@ 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;
+#else
+		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
#5 lore raw

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

Hi Jan,

Quoted 53 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.

We also need to explicitly select SPL_LOAD_BLOCK when UES_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 +
  common/spl/spl_mmc.c | 16 ++++++++--------
  include/part.h       |  3 ++-
  3 files changed, 11 insertions(+), 9 deletions(-)
common/spl/Kconfig +1 -0
index 8dade2b501e..d24466b0c66 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
common/spl/spl_mmc.c +2 -5
index 467114f8d9a..09e881c464c 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,
@@ -415,19 +416,18 @@ 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);

common/spl/spl_mmc.c int spl_mmc_load(struct spl_image_info *spl_image, · line 425

Quoted 10 lines
common/spl/spl_mmc.c +1 -3
-               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;
+#else

There is a build issue when CONFIG_SYS_MMCSD_RAW_MODE is disabled.

common/spl/spl_mmc.c: In function ‘spl_mmc_load’: common/spl/spl_mmc.c:426:9: error: implicit declaration of function ‘mmc_load_image_raw_partition’; did you mean ‘mmc_load_image_raw_sector’? [-Werror=implicit-function-declaration] ret = mmc_load_image_raw_partition(spl_image, bootdev, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ mmc_load_image_raw_sector cc1: some warnings being treated as errors make[2]: *** [scripts/Makefile.build:297: spl/common/spl/spl_mmc.o] Error 1 make[2]: *** Waiting for unfinished jobs....

In spl_mmc.c, the block currently guarded by #else should instead be:

#elif defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION) || \
      defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE)

Otherwise, mmc_load_image_raw_partition() becomes visible only in that branch, leading to:

error: implicit declaration of function ‘mmc_load_image_raw_partition’

This happens when both USE_SECTOR and USE_PARTITION{,_TYPE} are turned off.

Correcting the #else to #elif resolves the compilation error.

Thanks,
Tien Fong

author
#6 lore raw

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

Quoted 68 lines · Tien Fong

Hi Jan,

Quoted 65 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.

We also need to explicitly select SPL_LOAD_BLOCK when UES_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 +
  common/spl/spl_mmc.c | 16 ++++++++--------
  include/part.h       |  3 ++-

  3 files changed, 11 insertions(+), 9 deletions(-)
common/spl/Kconfig +0 -0
index 8dade2b501e..d24466b0c66 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

common/spl/spl_mmc.c +2 -1
index 467114f8d9a..09e881c464c 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,

common/spl/spl_mmc.c +0 -7
@@ -415,19 +416,18 @@ 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 +

Quoted 9 lines
Quoted 5 lines


spl_mmc_raw_uboot_offset(part));
                 if (!ret)
                         return 0;
+#else

There is a build issue when CONFIG_SYS_MMCSD_RAW_MODE is disabled.

Let me check, but if you can disable CONFIG_SYS_MMCSD_RAW_MODE but leave any of CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_* enabled, we had more problems here.

Jan

Signature · 2 lines
Siemens AG, Foundational Technologies
Linux Expert Center
#7 lore raw

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

Hi Jan,

Quoted 79 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.]

Quoted 69 lines · Tien Fong

Hi Jan,

Quoted 66 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.

We also need to explicitly select SPL_LOAD_BLOCK when UES_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 +
   common/spl/spl_mmc.c | 16 ++++++++--------
   include/part.h       |  3 ++-
   3 files changed, 11 insertions(+), 9 deletions(-)
common/spl/Kconfig +1 -0
index 8dade2b501e..d24466b0c66 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

common/spl/spl_mmc.c +2 -1
index 467114f8d9a..09e881c464c 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,

common/spl/spl_mmc.c +0 -7
@@ -415,19 +416,18 @@ 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 +
 
Quoted 7 lines

common/spl/spl_mmc.c int spl_mmc_load(struct spl_image_info *spl_image, · line 425

Quoted 4 lines
common/spl/spl_mmc.c +1 -0
 spl_mmc_raw_uboot_offset(part));
                  if (!ret)
                          return 0;
+#else

There is a build issue when CONFIG_SYS_MMCSD_RAW_MODE is disabled.

Quoted 3 lines

Let me check, but if you can disable CONFIG_SYS_MMCSD_RAW_MODE but leave any of CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_* enabled, we had more problems here.

We discovered this compilation issue when we disabled CONFIG_SYS_MMCSD_RAW_MODE while testing U-Boot proper loading from FAT32 on Cyclone V. In this setup, none of the sub-options -> _USE_PARTITION, _USE_PARTITION_TYPE, or _USE_SECTOR, should be used or enabled, as SPL simply loads U-Boot proper from FAT32. The raw/partition offsets are not relevant in this case, ensuring a clean, consistent MMC layout across our devkits.

Thanks.

Tien Fong

#8 lore raw

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

In reply to Jan Kiszka
Quoted 8 lines · 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.

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

s@UES@USE@ . Ideally this part should be separate fix .

author
#9 lore raw

PATCH 3/4 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 | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm/mach-socfpga/board.c +9 -0
index 28554b7a109..d756f7381fb 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,11 @@ void lmb_arch_add_memory(void)
 	}
 }
 #endif
+
+#ifdef CONFIG_SPL
+unsigned long board_spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
+						 unsigned long raw_sect)
+{
+	return (CONFIG_SPL_PAD_TO * 4) / 512 + raw_sect;
+}
+#endif
Signature · 1 line
2.51.0
#10 lore raw

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

Hi Jan,

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]>

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 | 9 +++++++++
  1 file changed, 9 insertions(+)
arch/arm/mach-socfpga/board.c +1 -0
index 28554b7a109..d756f7381fb 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>

arch/arm/mach-socfpga/board.c void lmb_arch_add_memory(void) · line 214

Quoted 5 lines
arch/arm/mach-socfpga/board.c +2 -0
@@ -209,3 +210,11 @@ void lmb_arch_add_memory(void)
         }
  }
  #endif
+
+#ifdef CONFIG_SPL

The guard should be CONFIG_XPL_BUILD instead of CONFIG_SPL to correctly control SPL-specific behavior

arch/arm/mach-socfpga/board.c void lmb_arch_add_memory(void) · line 220

Quoted 6 lines
arch/arm/mach-socfpga/board.c +6 -0
+unsigned long board_spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
+                                                unsigned long raw_sect)
+{
+       return (CONFIG_SPL_PAD_TO * 4) / 512 + raw_sect;
+}
+#endif

Global impact:
Applying board_spl_mmc_get_uboot_raw_sector() to all SoCFPGA boards could be risky. Older platforms such as Arria 10 and SoC63 devices use different layouts, and soon U-Boot proper will be moved into FAT32 partitions for cyclone V.

Offset calculation:
(CONFIG_SPL_PAD_TO * 4) / 512 + raw_sect assumes a specific SPL layout. It may conflict with the default 0x200 sector (https://github.com/u-boot/u-boot/blob/c5e6d2ab7eba68cbfb600cdc131c0c375ced2ec9/common/spl/Kconfig#L592 which eventually assigned to raw_sect above) used for SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR on some boards, so this calculation is not universal.

Suggestion: Consider gating this behind a board-specific Kconfig option, or limit the change to boards that actually require this offset. This will avoid potential regressions while supporting existing platforms.

Please let us know your thoughts.

Thanks,
Tien Fong

#11 lore raw

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

Quoted 2 lines

SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR on some boards, so this calculation is not universal.

Use setup like my handoff scripts for GEN5. xxx.mk Preserve a offset variable on that.

https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Flexible enough and allow user to control when required.
But please first wait the patch is completely pushed to mainstream first. And also documentation can be done to explain a bit.

Brian

author
#12 lore raw

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

In reply to Chee, Tien Fong
Quoted 68 lines · Tien Fong

Hi Jan,

Quoted 32 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 | 9 +++++++++

  1 file changed, 9 insertions(+)
arch/arm/mach-socfpga/ renamed from arch/arm/mach-socfpga/board.c +0 -0

board.c
index 28554b7a109..d756f7381fb 100644

arch/arm/mach-socfpga/board.c +1 -0
@@ -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>

arch/arm/mach-socfpga/board.c void lmb_arch_add_memory(void) · line 214

Quoted 5 lines
arch/arm/mach-socfpga/board.c +2 -0
@@ -209,3 +210,11 @@ void lmb_arch_add_memory(void)
          }
   }
   #endif
+
+#ifdef CONFIG_SPL

The guard should be CONFIG_XPL_BUILD instead of CONFIG_SPL to correctly control SPL-specific behavior

arch/arm/mach-socfpga/board.c void lmb_arch_add_memory(void) · line 220

Quoted 6 lines
arch/arm/mach-socfpga/board.c +6 -0
+unsigned long board_spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
+                                                unsigned long raw_sect)
+{
+       return (CONFIG_SPL_PAD_TO * 4) / 512 + raw_sect;
+}
+#endif

Global impact:
Applying board_spl_mmc_get_uboot_raw_sector() to all SoCFPGA boards could be risky. Older platforms such as Arria 10 and SoC63 devices use different layouts, and soon U-Boot proper will be moved into FAT32 partitions for cyclone V.

Offset calculation:
(CONFIG_SPL_PAD_TO * 4) / 512 + raw_sect assumes a specific SPL layout. It may conflict with the default 0x200 sector (https://github.com/u-
boot/u-boot/blob/c5e6d2ab7eba68cbfb600cdc131c0c375ced2ec9/common/spl/ Kconfig#L592 which eventually assigned to raw_sect above) used for SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR on some boards, so this calculation is not universal.

Quoted 4 lines

Suggestion: Consider gating this behind a board-specific Kconfig option, or limit the change to boards that actually require this offset. This will avoid potential regressions while supporting existing platforms.

I dislike more magics here. This is surely not board specific, it's rather partition specific (raw vs. fat part) as you pointed out above. Probably the romloader version plays a role as well in supporting one or both, thus the chip generation. Let's encode that into Kconfig, rather than magics.

Are there more modes to tell apart?

Jan

Signature · 2 lines
Siemens AG, Foundational Technologies
Linux Expert Center
#13 lore raw

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

Quoted 6 lines
Quoted 6 lines

arch/arm/mach-socfpga/board.c void lmb_arch_add_memory(void) · line 220

Quoted 6 lines
arch/arm/mach-socfpga/board.c +6 -0
+unsigned long board_spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
+                                                unsigned long raw_sect)
+{
+       return (CONFIG_SPL_PAD_TO * 4) / 512 + raw_sect;
+}
+#endif

Hi Jan

I am not sure what this is trying to fix btw.
But A2 partition might not be located at 0x200 it can place to the end of the MMC.
It is very personal and really nothing to do with board but only some socfpga.

But what this actually trying to fix or improve from first place? Maybe Jan you can explain a bit?

Do the RAW referring to A2 partition if so really not always. Correct me if not, and current three settings on
1) partition #
2) offset
3) partition type
aren't enough to make things work?
Not sure getting this right.

Brian

author
#14 lore raw

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

Quoted 17 lines · Sune Brian
Quoted 6 lines
Quoted 6 lines

arch/arm/mach-socfpga/board.c void lmb_arch_add_memory(void) · line 220

Quoted 6 lines
arch/arm/mach-socfpga/board.c +6 -0
+unsigned long board_spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
+                                                unsigned long raw_sect)
+{
+       return (CONFIG_SPL_PAD_TO * 4) / 512 + raw_sect;
+}
+#endif

Hi Jan

I am not sure what this is trying to fix btw.
But A2 partition might not be located at 0x200 it can place to the end of the MMC.
It is very personal and really nothing to do with board but only some socfpga.

But what this actually trying to fix or improve from first place? Maybe Jan you can explain a bit?

Quoted 7 lines

Do the RAW referring to A2 partition if so really not always. Correct me if not, and current three settings on
1) partition #
2) offset
3) partition type
aren't enough to make things work?
Not sure getting this right.

We are booting the DE0 Nano SoC from SD card, just like we did for almost a decade. A fresh integration for Debian trixie and UEFI is at [1][2].

But that boot approach fell apart after the refactorings of raw mode mmc loading and now starts to work again with my patches. Not saying they are perfect, but at least the board defconfig gives something that runs.

Jan

[1] https://patchwork.kernel.org/project/cip-dev/list/?series=1024655
[1]
https://gitlab.com/cip-project/cip-core/isar-cip-core/-/commits/next?ref_type=heads

Signature · 2 lines
Siemens AG, Foundational Technologies
Linux Expert Center
#15 lore raw

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

Quoted 3 lines

But that boot approach fell apart after the refactorings of raw mode mmc loading and now starts to work again with my patches. Not saying they are perfect, but at least the board defconfig gives something that runs.

Hi Jan,

No it did not.

My latest since 2025.07 built on Uboot not even used what the hard code setups.

grep -r "SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR" .config # CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR is not set

I simply used the A2 partition settings on SPL and it booted properly w/o issue. All you need is to split the u-boot.img to fat partition.
I build this and boot almost w/o any major issue since the changes from mixed setup to 3 individual setups boot by "offset", "#", and "Type". Still not sure what you have trouble with in the first place?
So I really dont understand what this is trying to fix.

Maybe T.F. can have more better comment but u-boot after 2025.07 no issue on boot by type=A2. I did not try boot by#, b.c. raw type must be sought from first.

Brian

author
#16 lore raw

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

Quoted 4 lines · Sune Brian
Quoted 3 lines

But that boot approach fell apart after the refactorings of raw mode mmc loading and now starts to work again with my patches. Not saying they are perfect, but at least the board defconfig gives something that runs.

Quoted 8 lines

Hi Jan,

No it did not.

My latest since 2025.07 built on Uboot not even used what the hard code setups.

grep -r "SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR" .config # CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR is not set

That's because it never used that (intentionally). We always booted from a partition ID, but the old versions had all methods enabled, and that papered over the fact that they were mangled into something that was supposed to use partition ID but used bits from the other paths as well to compensate mistakes.

Quoted 2 lines

I simply used the A2 partition settings on SPL and it booted properly w/o issue.

At least for the CycloneV with DE0 Nano SoC, this was broken. Maybe your setup was lucky to still work, but I doubt that was by design - see all the changes I had to made.

Quoted 10 lines

All you need is to split the u-boot.img to fat partition.
I build this and boot almost w/o any major issue since the changes from mixed setup to 3 individual setups boot by "offset", "#", and "Type". Still not sure what you have trouble with in the first place? So I really dont understand what this is trying to fix.

Maybe T.F. can have more better comment but u-boot after 2025.07 no issue on boot by type=A2. I did not try boot by#, b.c. raw type must be sought from first.

Just study my series to see all the breakages. It was never clean, though, and that may explain working setups by luck.

Jan

Signature · 2 lines
Siemens AG, Foundational Technologies
Linux Expert Center
#17 lore raw

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

Quoted 5 lines

That's because it never used that (intentionally). We always booted from a partition ID, but the old versions had all methods enabled, and that papered over the fact that they were mangled into something that was supposed to use partition ID but used bits from the other paths as well to compensate mistakes.

Are you using the mainstream or Altera U-Boot trunk from the beginning? Why does it sound like we are not on the same page?

It is not even allowed to select two settings since early 2025 major changes on the detection of the boot method.

[*] Use raw reads to locate the next boot phase

                                           │ │
  │ │                                                 Method for
locating next phase of boot (e.g. U-Boot) (MMC raw mode: by partition
type)  --->                │ │
  │ │                                           (0xa2) Partition Type

on the MMC to load U-Boot from

How can you select two at a time?

Quoted 3 lines

Just study my series to see all the breakages. It was never clean, though, and that may explain working setups by luck.

I am using a custom board na socfpga on Cyclone V SoC. There are no such things about luck. Either it works or fails.

Completely lost on your case and the patch.

Brian

author
#18 lore raw

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

Quoted 7 lines · Sune Brian
Quoted 5 lines

That's because it never used that (intentionally). We always booted from a partition ID, but the old versions had all methods enabled, and that papered over the fact that they were mangled into something that was supposed to use partition ID but used bits from the other paths as well to compensate mistakes.

Are you using the mainstream or Altera U-Boot trunk from the beginning?

We never used downstream.

Quoted 1 line

Why does it sound like we are not on the same page?

Different boards.

Quoted 5 lines

It is not even allowed to select two settings since early 2025 major changes on the detection of the boot method.

[*] Use raw reads to locate the next boot phase

Quoted 8 lines
                                           │ │
  │ │                                                 Method for
locating next phase of boot (e.g. U-Boot) (MMC raw mode: by partition
type)  --->                │ │
  │ │                                           (0xa2) Partition Type

on the MMC to load U-Boot from

How can you select two at a time?

I was referred to the time before the cleanup attempts.

Quoted 9 lines
Quoted 4 lines

Just study my series to see all the breakages. It was never clean, though, and that may explain working setups by luck.

I am using a custom board na socfpga on Cyclone V SoC. There are no such things about luck. Either it works or fails.

Completely lost on your case and the patch.

Your defconfig may compensate the bugs then. I was not lucky in finding a reasonable way to adjust the de0 config to make things work again.

Jan

Signature · 2 lines
Siemens AG, Foundational Technologies
Linux Expert Center
#19 lore raw

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

Hi Jan,

To be honest, it has nothing to do with the board.

Quoted 1 line

Different boards.

deconfig itself also requires alteration from first place. As of early this year the boot detection, so any sync patch had been pushed?
The detection is completely universal on cyclone V HPS. Unless you have the power to reload the HPS bootloader.

But long story short, I did not have any issue on
Cyclone V socdk
Custom board two variants on size.
"小梅哥SOC Cyclone V" by china vendor.
Which this board is a clone of DE0 nano

So I cannot see how DE0 can have such power to defer. So long story short this patch is not really a must.

Brian

author
#20 lore raw

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

Quoted 11 lines · Sune Brian

Hi Jan,

To be honest, it has nothing to do with the board.

Quoted 1 line

Different boards.

deconfig itself also requires alteration from first place. As of early this year the boot detection, so any sync patch had been pushed?
The detection is completely universal on cyclone V HPS. Unless you have the power to reload the HPS bootloader.

Quoted 5 lines

But long story short, I did not have any issue on
Cyclone V socdk
Custom board two variants on size.
"小梅哥SOC Cyclone V" by china vendor.
Which this board is a clone of DE0 nano

Strange that it booted then. Maybe you happen to work around the wrong offsets by adjusting your partition layout, rather than by teaching the SPL to load according to the actual layout.

Quoted 4 lines

So I cannot see how DE0 can have such power to defer. So long story short this patch is not really a must.

The whole series seems to look for new owners if I read [1] (even if that patch is incomplete yet) - though it contains valid fixed IMHO.

Jan

[1]
https://lore.kernel.org/u-boot/[email protected]/T/#u

Signature · 2 lines
Siemens AG, Foundational Technologies
Linux Expert Center

A message that is not in the archive (sent off-list or not yet received): CAN7C2SAFJzJpmm7pTS3GjZQhR9FzeB=sgVquHEJ3BHcxqz4tcQ@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

#23 lore raw

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

Quoted 4 lines

https://gitlab.com/cip-project/cip-core/isar-cip-core/-/blob/next/wic/de0-nano-soc.wks?ref_type=heads

Jan

If I used that I will mentioned from beginning. That is wks which is a way to pack a complete image. Possible yocoto build flow.

I did not happen to use any these kind of build very pure dd if=u-boot-with-spl.sfp of=/dev/sdb1 bs=64k conv=fsync I did not encountered any issue.
Otherwise I won't even push patches and raised other issue.

Let T.F. debug a bit, but cannot see this patch is a must.

Brian

#24 lore raw

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

In reply to Jan Kiszka

Hi Jan,

Quoted 73 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.]

Quoted 66 lines · Tien Fong

Hi Jan,

Quoted 32 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 | 9 +++++++++
   1 file changed, 9 insertions(+)
arch/arm/mach-socfpga/ renamed from arch/arm/mach-socfpga/board.c +0 -0

board.c
index 28554b7a109..d756f7381fb 100644

arch/arm/mach-socfpga/board.c +1 -0
@@ -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>

arch/arm/mach-socfpga/board.c void lmb_arch_add_memory(void) · line 214

Quoted 5 lines
arch/arm/mach-socfpga/board.c +2 -0
@@ -209,3 +210,11 @@ void lmb_arch_add_memory(void)
          }
   }
   #endif
+
+#ifdef CONFIG_SPL

The guard should be CONFIG_XPL_BUILD instead of CONFIG_SPL to correctly control SPL-specific behavior

arch/arm/mach-socfpga/board.c void lmb_arch_add_memory(void) · line 220

Quoted 6 lines
arch/arm/mach-socfpga/board.c +6 -0
+unsigned long board_spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
+                                                unsigned long raw_sect)
+{
+       return (CONFIG_SPL_PAD_TO * 4) / 512 + raw_sect;
+}
+#endif

Global impact:
Applying board_spl_mmc_get_uboot_raw_sector() to all SoCFPGA boards could be risky. Older platforms such as Arria 10 and SoC63 devices use different layouts, and soon U-Boot proper will be moved into FAT32 partitions for cyclone V.

Offset calculation:
(CONFIG_SPL_PAD_TO * 4) / 512 + raw_sect assumes a specific SPL layout. It may conflict with the default 0x200 sector (https://github.com/u-
boot/u-boot/blob/c5e6d2ab7eba68cbfb600cdc131c0c375ced2ec9/common/spl/ Kconfig#L592 which eventually assigned to raw_sect above) used for SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR on some boards, so this calculation is not universal.

Quoted 4 lines

Suggestion: Consider gating this behind a board-specific Kconfig option, or limit the change to boards that actually require this offset. This will avoid potential regressions while supporting existing platforms.

Quoted 7 lines

I dislike more magics here. This is surely not board specific, it's rather partition specific (raw vs. fat part) as you pointed out above. Probably the romloader version plays a role as well in supporting one or both, thus the chip generation. Let's encode that into Kconfig, rather than magics.

Are there more modes to tell apart?

Thanks for your feedback. I’d like to clarify the current status and our recent POC regarding SPL and U-Boot proper loading on Cyclone V.

Cyclone V (Gen5 – ROM-based boot) - ROM supports SPL loading in two modes:
  1. Raw mode – from LBA 0
  2. Partition mode (0xA2) – from a dedicated A2 partition

Our POC confirms that this restriction applies to SPL only. Once SPL is running from OCRAM, it can load U-Boot proper from FAT32 without issue. This reduces OCRAM usage, simplifies the MMC layout, and preserves FAT32 benefits.

Arria 10
 1. ROM loads SPL from its fixed boot source. SPL already loads U-Boot proper from FAT32 today.

SoC64 (Agilex / Agilex 5)
  1. SPL is embedded in the FPGA bitstream and loaded by SDM. SPL is never on MMC; only U-Boot proper can be on MMC, and all boards use FAT32.

Conclusion on required modes
  1. ROM loads SPL from raw (Gen5, A10)
  2. ROM loads SPL from A2 partition (Gen5, A10)
  3. SDM loads SPL from bitstream (SoC64 Agilex, Agilex7m, S10 and etc.. )

U-Boot proper loaded from FAT32 — this reflects the standard Altera devkit MMC layout. Other boards, partners, or vendors may still use raw partitions, so this is not universal.

Implication
  There is no single offset calculation that is portable across all generations. Our POC shows that moving U-Boot proper to FAT32 is safe for devkits, reduces OCRAM usage, and aligns with long-term MMC layout consistency, while older raw modes remain supported where needed.

Please let me know your thoughts on this approach and whether you see any corner cases we might have missed.

Thanks,
Tien Fong

#25 lore raw

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

Quoted 4 lines

Our POC confirms that this restriction applies to SPL only. Once SPL is running from OCRAM, it can load U-Boot proper from FAT32 without issue. This reduces OCRAM usage, simplifies the MMC layout, and preserves FAT32 benefits.

Hi T.F.

Can you confirm or recap a bit.

First I had no issue since the new update from mixed seek to three individual seek methods, TYPE, PAR#, OFFSET.

But what my best guest Jan is trying to fix does not exist from the beginning. There are no need to follow old days combined splx4+uboot to A2 but simply spl on A2 and uboot in FAT.

To confirm --->
For u-boot-with-spl.sfp simply dd using old method aka early like 2025.05 or before will not require the uboot to exist in FAT32 and simply all combined and flashed to A2. But using such will only stop at SPL and the U BOOT phase never completes.
<---

Simply follow old boot or flash flow and blindly run make board_defconfig and no sync or update results in fails.

So what my comment is just a very bad naming on latest u-boot generated file "u-boot-with-spl.sfp" ?

Thanks,
Brian

author
#26 lore raw

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

In reply to Chee, Tien Fong
Quoted 93 lines · Tien Fong

Hi Jan,

Quoted 78 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.]

Quoted 68 lines · Tien Fong

Hi Jan,

Quoted 33 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 | 9 +++++++++

   1 file changed, 9 insertions(+)
arch/arm/mach-socfpga/ renamed from arch/arm/mach-socfpga/board.c +0 -0

board.c
index 28554b7a109..d756f7381fb 100644

arch/arm/mach-socfpga/board.c +1 -0
@@ -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>

arch/arm/mach-socfpga/board.c void lmb_arch_add_memory(void) · line 214

Quoted 5 lines
arch/arm/mach-socfpga/board.c +2 -0
@@ -209,3 +210,11 @@ void lmb_arch_add_memory(void)
           }
    }
    #endif
+
+#ifdef CONFIG_SPL

The guard should be CONFIG_XPL_BUILD instead of CONFIG_SPL to correctly control SPL-specific behavior

arch/arm/mach-socfpga/board.c void lmb_arch_add_memory(void) · line 220

Quoted 7 lines
arch/arm/mach-socfpga/board.c +2 -0
+unsigned long board_spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
+                                                unsigned long

raw_sect)

arch/arm/mach-socfpga/board.c +4 -0
+{
+       return (CONFIG_SPL_PAD_TO * 4) / 512 + raw_sect;
+}
+#endif

Global impact:
Applying board_spl_mmc_get_uboot_raw_sector() to all SoCFPGA boards could be risky. Older platforms such as Arria 10 and SoC63 devices use different layouts, and soon U-Boot proper will be moved into FAT32 partitions for cyclone V.

Offset calculation:
(CONFIG_SPL_PAD_TO * 4) / 512 + raw_sect assumes a specific SPL layout. It may conflict with the default 0x200 sector (https://github.com/u-
boot/u-boot/blob/c5e6d2ab7eba68cbfb600cdc131c0c375ced2ec9/common/spl/ Kconfig#L592 which eventually assigned to raw_sect above) used for SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR on some boards, so this calculation is not universal.

Quoted 4 lines

Suggestion: Consider gating this behind a board-specific Kconfig option, or limit the change to boards that actually require this offset. This will avoid potential regressions while supporting existing platforms.

Quoted 7 lines

I dislike more magics here. This is surely not board specific, it's rather partition specific (raw vs. fat part) as you pointed out above. Probably the romloader version plays a role as well in supporting one or both, thus the chip generation. Let's encode that into Kconfig, rather than magics.

Are there more modes to tell apart?

Thanks for your feedback. I’d like to clarify the current status and our recent POC regarding SPL and U-Boot proper loading on Cyclone V.

Quoted 8 lines

Cyclone V (Gen5 – ROM-based boot) - ROM supports SPL loading in two modes:
  1. Raw mode – from LBA 0
  2. Partition mode (0xA2) – from a dedicated A2 partition

Our POC confirms that this restriction applies to SPL only. Once SPL is running from OCRAM, it can load U-Boot proper from FAT32 without issue. This reduces OCRAM usage, simplifies the MMC layout, and preserves FAT32 benefits.

Right, I confused romloader constraints with the way more flexible options we have for SPL loading u-boot proper.

Quoted 25 lines

Arria 10
 1. ROM loads SPL from its fixed boot source. SPL already loads U-Boot proper from FAT32 today.

SoC64 (Agilex / Agilex 5)
  1. SPL is embedded in the FPGA bitstream and loaded by SDM. SPL is never on MMC; only U-Boot proper can be on MMC, and all boards use FAT32.

Conclusion on required modes
  1. ROM loads SPL from raw (Gen5, A10)
  2. ROM loads SPL from A2 partition (Gen5, A10)
  3. SDM loads SPL from bitstream (SoC64 Agilex, Agilex7m, S10 and etc.. )

U-Boot proper loaded from FAT32 — this reflects the standard Altera devkit MMC layout. Other boards, partners, or vendors may still use raw partitions, so this is not universal.

Implication
  There is no single offset calculation that is portable across all generations. Our POC shows that moving U-Boot proper to FAT32 is safe for devkits, reduces OCRAM usage, and aligns with long-term MMC layout consistency, while older raw modes remain supported where needed.

Quoted 3 lines

Please let me know your thoughts on this approach and whether you see any corner cases we might have missed.

I'm fine with switching our setups to FAT mode as well and adjusting the defconfigs accordingly so that people use the optimal mode by default. Still, if you want to continue supporting raw mode as option or even still as default for some boards, it should be fixed as well.

I will try to refresh my related patches with the feedback you and others provided, I just need to find some slot - and another test board (gave mines away now as we are re-balancing their distribution in the CIP test labs).

Jan

Signature · 2 lines
Siemens AG, Foundational Technologies
Linux Expert Center
#27 lore raw

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

In reply to Jan Kiszka
Quoted 26 lines · 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 | 9 +++++++++
  1 file changed, 9 insertions(+)
arch/arm/mach-socfpga/board.c +1 -0
index 28554b7a109..d756f7381fb 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>

arch/arm/mach-socfpga/board.c void lmb_arch_add_memory(void) · line 218

Quoted 9 lines
arch/arm/mach-socfpga/board.c +6 -0
@@ -209,3 +210,11 @@ void lmb_arch_add_memory(void)
  	}
  }
  #endif
+
+#ifdef CONFIG_SPL
+unsigned long board_spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
+						 unsigned long raw_sect)
+{
+	return (CONFIG_SPL_PAD_TO * 4) / 512 + raw_sect;

Please add a comment whether this is offset within a partition or within a raw block device.

Also, I see the long discussion thread, maybe it would be good to point out which commit exactly broken the DE0 board.

author
#28 lore raw

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

Quoted 31 lines · Marek Vasut
Quoted 30 lines · 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 | 9 +++++++++

  1 file changed, 9 insertions(+)
arch/arm/mach-socfpga/ renamed from arch/arm/mach-socfpga/board.c +0 -0

board.c
index 28554b7a109..d756f7381fb 100644

arch/arm/mach-socfpga/board.c +1 -0
@@ -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,11 @@ void lmb_arch_add_memory(void)
       }
   }
   #endif
Quoted 8 lines

arch/arm/mach-socfpga/board.c void lmb_arch_add_memory(void) · line 218

Quoted 6 lines
arch/arm/mach-socfpga/board.c +6 -0
+
+#ifdef CONFIG_SPL
+unsigned long board_spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
+                         unsigned long raw_sect)
+{
+    return (CONFIG_SPL_PAD_TO * 4) / 512 + raw_sect;

Please add a comment whether this is offset within a partition or within a raw block device.

Depends on the mode. It is relative to the partition when using any of those modes, otherwise relative to base sector. Will add that.

Quoted 3 lines

Also, I see the long discussion thread, maybe it would be good to point out which commit exactly broken the DE0 board.

2a00d73d081a14e7c2ecf23794b6d029268d8ca3 - though it is not completely fair to say it broke things because the code paths we took before that change were not really consistent and papered over issues which the refactoring than surfaced.

Jan

Signature · 2 lines
Siemens AG, Foundational Technologies
Linux Expert Center
#29 lore raw

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

Quoted 41 lines · Jan Kiszka
Quoted 31 lines · Marek Vasut
Quoted 30 lines · 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 | 9 +++++++++
   1 file changed, 9 insertions(+)
arch/arm/mach-socfpga/ renamed from arch/arm/mach-socfpga/board.c +0 -0

board.c
index 28554b7a109..d756f7381fb 100644

arch/arm/mach-socfpga/board.c +1 -0
@@ -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,11 @@ void lmb_arch_add_memory(void)
       }
   }
   #endif
Quoted 8 lines

arch/arm/mach-socfpga/board.c void lmb_arch_add_memory(void) · line 218

Quoted 6 lines
arch/arm/mach-socfpga/board.c +6 -0
+
+#ifdef CONFIG_SPL
+unsigned long board_spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
+                         unsigned long raw_sect)
+{
+    return (CONFIG_SPL_PAD_TO * 4) / 512 + raw_sect;

Please add a comment whether this is offset within a partition or within a raw block device.

Quoted 2 lines

Depends on the mode. It is relative to the partition when using any of those modes, otherwise relative to base sector. Will add that.

Thank you.

Quoted 7 lines
Quoted 2 lines

Also, I see the long discussion thread, maybe it would be good to point out which commit exactly broken the DE0 board.

2a00d73d081a14e7c2ecf23794b6d029268d8ca3 - though it is not completely fair to say it broke things because the code paths we took before that change were not really consistent and papered over issues which the refactoring than surfaced.

I see.

author
#30 lore raw

PATCH 4/4 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