[PATCH] ARM: socfpga: fix dead guard on board_spl_mmc_get_uboot_raw_sector()

Mahmoud Komaiha <[email protected]> Mon, 3 Aug 2026 21:38:58 -0400
Newsgroups gmane.comp.boot-loaders.u-boot
Message-ID <[email protected]>
From: Mahmoud Komaiha <[email protected]>

board_spl_mmc_get_uboot_raw_sector() is guarded on
CONFIG_TARGET_SOCFPGA_ARRIA10 and CONFIG_TARGET_SOCFPGA_GEN5. Neither
symbol exists in Kconfig: the family symbols are ARCH_SOCFPGA_ARRIA10 and
ARCH_SOCFPGA_GEN5, while the per-board symbols are of the form
TARGET_SOCFPGA_ARRIA10_SOCDK / TARGET_SOCFPGA_TERASIC_DE10_NANO. These two
lines are the only references to either symbol in the tree.

The guard is therefore never true and the function is dead code on every
SoCFPGA board, so the offset of u-boot proper inside u-boot-with-spl.sfp
is never applied.

When SPL loads u-boot proper from the 0xa2 partition
(SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE) the resulting load address
is the start of that partition, which holds SPL itself rather than u-boot
proper. SPL then hangs with no diagnostic after printing
"spl: mmc boot mode: raw".

Observed on a Terasic DE10-Nano (Cyclone V, GEN5) booting from SD with the
standard layout (0xa2 partition at sector 1024). Instrumenting
mmc_load_image_raw_partition() showed the computed load sector as 1024
instead of 1536. With the guard corrected the offset is applied, the load
sector becomes 1536, and the board boots to the U-Boot prompt.

Signed-off-by: Mahmoud Komaiha <[email protected]>
---
 arch/arm/mach-socfpga/board.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-socfpga/board.c b/arch/arm/mach-socfpga/board.c
index 4d7f0b9a..fd7f15b3 100644
--- a/arch/arm/mach-socfpga/board.c
+++ b/arch/arm/mach-socfpga/board.c
@@ -211,8 +211,8 @@ void lmb_arch_add_memory(void)
 }
 #endif
 
-#if (defined(CONFIG_TARGET_SOCFPGA_ARRIA10) || \
-     defined(CONFIG_TARGET_SOCFPGA_GEN5)) && defined(CONFIG_XPL_BUILD)
+#if (defined(CONFIG_ARCH_SOCFPGA_ARRIA10) || \
+     defined(CONFIG_ARCH_SOCFPGA_GEN5)) && defined(CONFIG_XPL_BUILD)
 unsigned long board_spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
 						 unsigned long raw_sect)
 {
-- 
2.50.1 (Apple Git-155)