Skip to contentSkip to conversation

fsl, powerpc: Fix SPD read and appended DTB alignment

PATCH In review Josef Schlehofer 2 participants 5 messages Sep 28 – Sep 29 PowerPC

lore
Share & tools
lore
#0 lore raw

cover fsl, powerpc: Fix SPD read and appended DTB alignment

Three generic fixes found while bringing up mainline U-Boot on a CZ.NIC Turris 1.1. Patch 1 fixes the DDR code used by NXP boards that read SPD over legacy I2C. Patches 2 and 3 fix linker scripts for mpc85xx and the two CS GROUP boards.

Patch 1 restores the legacy I2C SPD read that commit 98dfa70f84f0 ("fsl: mxc: Drop legacy I2c") turned into a stub. Boards using this path otherwise get an all-zero SPD and either fail with "Error: No valid SPD detected." or fall back to built-in timings.

Patches 2 and 3 move the _end alignment padding into the last output section with content, so the appended device tree lands at _end, where fdtdec_setup() looks for it. They also remove the alignment immediately before _end, allowing the existing ASSERT to catch a misaligned image. The padding fix is split because mpc85xx and the CS GROUP boards are handled by different custodian trees.

On main (6c246142f39) built with Debian GCC 14.2, the appended device tree starts 4 bytes before _end on turris_1x_nor, P1010RDB-PB_NAND, T2080RDB_NAND, MCR3000 and CMPC885, and on turris_1x_nor also with the kernel.org GCC 14.2.0 used by CI. With the patches it is exactly at _end in all of these builds.

All 83 PowerPC boards build with the series. For the NXP Layerscape reference boards, patch 1 changes only the six configurations that use legacy I2C for SPD; the other 54 produce identical U-Boot and SPL binaries.

On a Turris 1.1, patch 1 makes the SD card SPL built from main (v2026.10-rc2) initialize DDR and start U-Boot, where it failed with "Error: No valid SPD detected." before. turris_1x_nor built from main with the series booted from NOR and started OpenWrt from the SD card. That boot also needs "mtd: rawnand: fsl_elbc: Select NAND_ECC_BCH" from the LTO series for next. Without it, turris_1x_nor on main stops at the NAND probe with or without this series. The other boards are build tested only.

If this is too late for v2026.10, next is fine too.

Josef Schlehofer (3):
ddr: fsl: Fix SPD read when legacy I2C is used
powerpc: mpc85xx: Move alignment padding into __u_boot_list section
board: cssi: Move alignment padding into __u_boot_list section

 arch/powerpc/cpu/mpc85xx/u-boot.lds | 2 +-
 board/cssi/cmpc885/u-boot.lds       | 2 +-
 board/cssi/mcr3000/u-boot.lds       | 2 +-
 drivers/ddr/fsl/main.c              | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

base-commit: 6c246142f39fe0b406a730010010a66e6e926cbc

Signature · 1 line
2.54.0 (Apple Git-157)
#1 lore raw

PATCH 1/3 ddr: fsl: Fix SPD read when legacy I2C is used

Commit 98dfa70f84f0 ("fsl: mxc: Drop legacy I2c") replaced the legacy I2C branch of ddr_i2c_read() with a stub that returns 0 without reading anything. The legacy branch is taken whenever the phase that initializes DDR does not enable DM_I2C, so those boards get an all-zero SPD and either stop with "Error: No valid SPD detected." or fall back to raw timings.

Restore the legacy read.

Tested on CZ.NIC Turris 1.1 (SD boot).

Fixes 98dfa70f84f0 ("fsl: mxc: Drop legacy I2c")
Cc Simon Glass <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Priyanka Jain <[email protected]>
Cc Peng Fan <[email protected]>

---
The i2c_set_bus_num() call that the same commit removed is not needed:
every phase that reaches this code calls i2c_init_all(), which selects CONFIG_SYS_SPD_BUS_NUM, right before dram_init(). Converting these SPLs to DM_I2C is left for later.

The SD card SPL built from main (v2026.10-rc2) set up DDR with this patch and stopped with "Error: No valid SPD detected." without it. A full SD boot needs "mtd: rawnand: fsl_elbc: Select NAND_ECC_BCH" from the LTO series for next, and was tested with that series.

---
 drivers/ddr/fsl/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ddr/fsl/main.c +1 -1
index 2b879c63b5f..bf471ca97dc 100644
@@ -111,7 +111,7 @@ static int ddr_i2c_read(DEV_TYPE *dev, unsigned int addr,
 #if CONFIG_IS_ENABLED(DM_I2C)
 	ret = dm_i2c_read(dev, 0, buf, len);
 #else
-	ret = 0;
+	ret = i2c_read(dev->chip, addr, alen, buf, len);
 #endif
 
 	return ret;
Signature · 1 line
2.54.0 (Apple Git-157)
#2 lore raw

PATCH 2/3 powerpc: mpc85xx: Move alignment padding into __u_boot_list section

In reply to Josef Schlehofer

The alignment of _end sits outside the last output section, so objcopy does not put the padding into u-boot-nodtb.bin. Depending on the toolchain and configuration, the appended device tree then starts 4 bytes before _end, while fdtdec_setup() looks for it at _end. An LTO build of turris_1x_sdcard (with the LTO series for next) stopped with:

No valid device tree binary found at 110f1488 initcall_run_f(): initcall fdtdec_setup() failed

Pad inside the __u_boot_list section, the last one with content, as commit 74f5e3ef30dd ("powerpc/mpc83xx: Move alignment padding into __u_boot_list section") did for mpc83xx. Also drop the alignment right before _end, which made the ASSERT on _end pass by construction.

Tested on CZ.NIC Turris 1.1.

Fixes 87d3780ebc24 ("powerpc: Update linker scripts to ensure appended device tree is aligned")
Cc Marek Behún <[email protected]>

---
Tested from NOR on main together with "mtd: rawnand: fsl_elbc: Select NAND_ECC_BCH" from the LTO series for next, without which U-Boot stops at the NAND probe, and from NOR and SD card on next with the LTO series.

---
 arch/powerpc/cpu/mpc85xx/u-boot.lds | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/cpu/mpc85xx/u-boot.lds +1 -1
index 3c9959bef09..bedd2d47472 100644
@@ -67,6 +67,7 @@ SECTIONS
   . = ALIGN(4);
   __u_boot_list : {
 	KEEP(*(SORT(__u_boot_list*)));
+	. = ALIGN(8);
   }
 
   . = .;
@@ -78,7 +79,6 @@ SECTIONS
   __init_begin = .;
   .text.init : { *(.text.init) }
   .data.init : { *(.data.init) }
-  . = ALIGN(8);
   __init_end = .;
   _end = .;
 
Signature · 1 line
2.54.0 (Apple Git-157)
#3 lore raw

PATCH 3/3 board: cssi: Move alignment padding into __u_boot_list section

In reply to Josef Schlehofer

The MCR3000 and CMPC885 linker scripts align _end outside the last output section, so the appended device tree can start 4 bytes before _end, where fdtdec_setup() does not find it.

Move the alignment into __u_boot_list, the last output section with content.

Build tested.

Fixes 87d3780ebc24 ("powerpc: Update linker scripts to ensure appended device tree is aligned")
Cc Christophe Leroy <[email protected]>
---
 board/cssi/cmpc885/u-boot.lds | 2 +-
 board/cssi/mcr3000/u-boot.lds | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
board/cssi/cmpc885/u-boot.lds +1 -1
index da9cff64d46..2c0d9eb0594 100644
@@ -61,6 +61,7 @@ SECTIONS
 	. = ALIGN(4);
 	__u_boot_list : {
 		KEEP(*(SORT(__u_boot_list*)));
+		. = ALIGN(8);
 	}
 
 	. = .;
@@ -72,7 +73,6 @@ SECTIONS
 	 * _end - This is end of u-boot.bin image.
 	 * dtb will be appended here to make u-boot-dtb.bin
 	 */
-	. = ALIGN(8);
 	_end = .;
 
 	. = ALIGN(4096);
board/cssi/mcr3000/u-boot.lds +1 -1
index 1fd98726b2a..acf34ecadfd 100644
@@ -61,6 +61,7 @@ SECTIONS
 	. = ALIGN(4);
 	__u_boot_list : {
 		KEEP(*(SORT(__u_boot_list*)));
+		. = ALIGN(8);
 	}
 
 	. = .;
@@ -72,7 +73,6 @@ SECTIONS
 	 * _end - This is end of u-boot.bin image.
 	 * dtb will be appended here to make u-boot-dtb.bin
 	 */
-	. = ALIGN(8);
 	_end = .;
 
 	. = ALIGN(4096);
Signature · 1 line
2.54.0 (Apple Git-157)
#4 lore raw
In reply to Josef Schlehofer
Quoted 11 lines · Josef Schlehofer

Three generic fixes found while bringing up mainline U-Boot on a CZ.NIC Turris 1.1. Patch 1 fixes the DDR code used by NXP boards that read SPD over legacy I2C. Patches 2 and 3 fix linker scripts for mpc85xx and the two CS GROUP boards.

Patch 1 restores the legacy I2C SPD read that commit 98dfa70f84f0 ("fsl: mxc: Drop legacy I2c") turned into a stub. Boards using this path otherwise get an all-zero SPD and either fail with "Error: No valid SPD detected." or fall back to built-in timings.

[...]

Applied to u-boot/main, thanks!

[1/3] ddr: fsl: Fix SPD read when legacy I2C is used

      commit: 0384dd3d2ec30d910b6138b78fc0f41950b1b52c
[2/3] powerpc: mpc85xx: Move alignment padding into __u_boot_list section
      commit: b9cefbcab172d735d53d82e36b8b26d76a77f12e
[3/3] board: cssi: Move alignment padding into __u_boot_list section
      commit: dbe089661477b379e26a82335f31003d68ea9c61
Signature · 1 line
Tom