Skip to contentSkip to conversation

board: toradex: verdin-imx8mm: adjust U-Boot proper offset for eMMC fastboot

PATCH Superseded Sergio Prado 3 participants 4 messages Nov 17 – Nov 18

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 board: toradex: verdin-imx8mm: adjust U-Boot proper offset for eMMC fastboot

The Verdin iMX8MM boots from the eMMC boot partitions with the eMMC fast boot fuse enabled, so the boot ROM loads flash.bin from offset 1 KiB instead of the usual 33 KiB. The SPL loads U-Boot proper from the fixed sector CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR, so the board device tree moved the FIT in flash.bin to 0x5fc00 to compensate.

That override only works while the fit node is placed directly in the binman section. With CONFIG_IMX_HAB, imx8mm-u-boot.dtsi wraps the FIT in an nxp-imx8mcst node with its own offset of 0x57c00, which takes precedence, so a signed flash.bin has the FIT at 0x57c00. When booting from eMMC, the SPL does not find the FIT at the expected sector, treats the data there as a raw U-Boot image and fails to authenticate it:

Authenticate image from DDR location 0x40200000... bad magic magic=0x75 length=0x206d version=0x63 bad length magic=0x75 length=0x206d version=0x63 bad version magic=0x75 length=0x206d version=0x63
Error: Invalid IVT structure

Adjust the sector in the SPL instead, as the Kontron SL i.MX8MM does, by checking the fast boot fuse and the boot partition, and drop the FIT offset override. The FIT is then at the default 0x57c00 for every boot medium, with or without HAB. This also applies to the MX8Menlo, which reuses the Verdin SPL code and U-Boot device tree.

---
Tested on a Verdin iMX8MM with the eMMC fast boot fuse set, booting from eMMC boot0:
- without CONFIG_IMX_HAB, on this tree;
- with CONFIG_IMX_HAB and a signed flash.bin, on v2026.07 with this patch applied, on an open device with no HAB events.

 .../dts/imx8mm-verdin-wifi-dev-u-boot.dtsi    |  4 ----
 board/toradex/verdin-imx8mm/spl.c             | 20 +++++++++++++++++++
 2 files changed, 20 insertions(+), 4 deletions(-)
arch/arm/dts/imx8mm-verdin-wifi-dev-u-boot.dtsi +0 -4
index 183de46f66a8..2dd80338c0c0 100644
@@ -35,10 +35,6 @@
 	bootph-pre-ram;
 };
 
-&binman_imx_fit {
-	offset = <0x5fc00>;
-};
-
 &gpio1 {
 	bootph-pre-ram;
 };
board/toradex/verdin-imx8mm/spl.c +20 -0
index 10b9991e3bf9..d340286e4bbc 100644
@@ -43,6 +43,26 @@ int spl_board_boot_device(enum boot_device boot_dev_spl)
 	}
 }
 
+unsigned long board_spl_mmc_get_uboot_raw_sector(struct mmc *mmc, unsigned long raw_sect)
+{
+	/*
+	 * The image offset on SD/MMC devices is 33 KiB, except for eMMC boot if
+	 * fastboot is enabled. In this case it is 1 KiB. In order to make the
+	 * bootloader universal, check the fastboot OTP boot fuse and adjust
+	 * the offset.
+	 */
+	if (!IS_SD(mmc) && (readl(OCOTP_BASE_ADDR + 0x470) & 0x80)) {
+		switch (EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config)) {
+		case EMMC_BOOT_PART_BOOT1:
+		case EMMC_BOOT_PART_BOOT2:
+			raw_sect -= 32 * 2;
+			break;
+		}
+	}
+
+	return raw_sect;
+}
+
 void spl_dram_init(void)
 {
 	ddr_init(&dram_timing);
Signature · 1 line
2.34.1
#1 lore raw

Hello Sergio,
thanks for the patch.

Quoted 26 lines · Sergio Prado

The Verdin iMX8MM boots from the eMMC boot partitions with the eMMC fast boot fuse enabled, so the boot ROM loads flash.bin from offset 1 KiB instead of the usual 33 KiB. The SPL loads U-Boot proper from the fixed sector CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR, so the board device tree moved the FIT in flash.bin to 0x5fc00 to compensate.

That override only works while the fit node is placed directly in the binman section. With CONFIG_IMX_HAB, imx8mm-u-boot.dtsi wraps the FIT in an nxp-imx8mcst node with its own offset of 0x57c00, which takes precedence, so a signed flash.bin has the FIT at 0x57c00. When booting from eMMC, the SPL does not find the FIT at the expected sector, treats the data there as a raw U-Boot image and fails to authenticate it:

Authenticate image from DDR location 0x40200000... bad magic magic=0x75 length=0x206d version=0x63 bad length magic=0x75 length=0x206d version=0x63 bad version magic=0x75 length=0x206d version=0x63
Error: Invalid IVT structure

Adjust the sector in the SPL instead, as the Kontron SL i.MX8MM does, by checking the fast boot fuse and the boot partition, and drop the FIT offset override. The FIT is then at the default 0x57c00 for every boot medium, with or without HAB. This also applies to the MX8Menlo, which reuses the Verdin SPL code and U-Boot device tree.

...

Quoted 6 lines
board/toradex/verdin-imx8mm/spl.c +6 -0
+unsigned long board_spl_mmc_get_uboot_raw_sector(struct mmc *mmc, unsigned long raw_sect)
+{
+	/*
+	 * The image offset on SD/MMC devices is 33 KiB, except for eMMC boot if
+	 * fastboot is enabled. In this case it is 1 KiB. In order to make the
+	 * bootloader universal, check the fastboot OTP boot fuse and adjust

board/toradex/verdin-imx8mm/spl.c int spl_board_boot_device(enum boot_device boot_dev_spl) · line 61

Quoted 10 lines
board/toradex/verdin-imx8mm/spl.c +10 -0
+	 * the offset.
+	 */
+	if (!IS_SD(mmc) && (readl(OCOTP_BASE_ADDR + 0x470) & 0x80)) {
+		switch (EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config)) {
+		case EMMC_BOOT_PART_BOOT1:
+		case EMMC_BOOT_PART_BOOT2:
+			raw_sect -= 32 * 2;
+			break;
+		}
+	}

Why do we need the runtime check on the fuses? verdin imx8mm can boot only from eMMC and with fastboot enabled, so this runtime check is redundant, everything is known at build-time.

Francesco

#2 lore raw
Quoted 45 lines · Francesco Dolcini

Hello Sergio,
thanks for the patch.

Quoted 26 lines · Sergio Prado

The Verdin iMX8MM boots from the eMMC boot partitions with the eMMC fast boot fuse enabled, so the boot ROM loads flash.bin from offset 1 KiB instead of the usual 33 KiB. The SPL loads U-Boot proper from the fixed sector CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR, so the board device tree moved the FIT in flash.bin to 0x5fc00 to compensate.

That override only works while the fit node is placed directly in the binman section. With CONFIG_IMX_HAB, imx8mm-u-boot.dtsi wraps the FIT in an nxp-imx8mcst node with its own offset of 0x57c00, which takes precedence, so a signed flash.bin has the FIT at 0x57c00. When booting from eMMC, the SPL does not find the FIT at the expected sector, treats the data there as a raw U-Boot image and fails to authenticate it:

Authenticate image from DDR location 0x40200000... bad magic magic=0x75 length=0x206d version=0x63 bad length magic=0x75 length=0x206d version=0x63 bad version magic=0x75 length=0x206d version=0x63
Error: Invalid IVT structure

Adjust the sector in the SPL instead, as the Kontron SL i.MX8MM does, by checking the fast boot fuse and the boot partition, and drop the FIT offset override. The FIT is then at the default 0x57c00 for every boot medium, with or without HAB. This also applies to the MX8Menlo, which reuses the Verdin SPL code and U-Boot device tree.

...

Quoted 12 lines
board/toradex/verdin-imx8mm/spl.c +12 -0
+unsigned long board_spl_mmc_get_uboot_raw_sector(struct mmc *mmc, unsigned long raw_sect)
+{
+	/*
+	 * The image offset on SD/MMC devices is 33 KiB, except for eMMC boot if
+	 * fastboot is enabled. In this case it is 1 KiB. In order to make the
+	 * bootloader universal, check the fastboot OTP boot fuse and adjust
+	 * the offset.
+	 */
+	if (!IS_SD(mmc) && (readl(OCOTP_BASE_ADDR + 0x470) & 0x80)) {
+		switch (EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config)) {
+		case EMMC_BOOT_PART_BOOT1:
+		case EMMC_BOOT_PART_BOOT2:
Quoted 8 lines

board/toradex/verdin-imx8mm/spl.c int spl_board_boot_device(enum boot_device boot_dev_spl) · line 61

Quoted 4 lines
board/toradex/verdin-imx8mm/spl.c +4 -0
+			raw_sect -= 32 * 2;
+			break;
+		}
+	}

Why do we need the runtime check on the fuses? verdin imx8mm can boot only from eMMC and with fastboot enabled, so this runtime check is redundant, everything is known at build-time.

Maybe remove the override in the dtsi and set CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x2c0 (check also menlo)?

Francesco

#3 lore raw
In reply to Francesco Dolcini

Hello Francesco,

Thanks for reviewing.

Em ter., 17 de nov. de 2026 às 08:28, Francesco Dolcini <[email protected]> escreveu:

Quoted 9 lines

board/toradex/verdin-imx8mm/spl.c int spl_board_boot_device(enum boot_device boot_dev_spl) · line 61

Quoted 8 lines
board/toradex/verdin-imx8mm/spl.c +8 -0
+     if (!IS_SD(mmc) && (readl(OCOTP_BASE_ADDR + 0x470) & 0x80)) {
+             switch (EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config)) {
+             case EMMC_BOOT_PART_BOOT1:
+             case EMMC_BOOT_PART_BOOT2:
+                     raw_sect -= 32 * 2;
+                     break;
+             }
+     }
Quoted 3 lines

Why do we need the runtime check on the fuses? verdin imx8mm can boot only from eMMC and with fastboot enabled, so this runtime check is redundant, everything is known at build-time.

Indeed, the runtime check is not needed. And since the offset is fixed on the Verdin iMX8MM, setting CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR to 0x2c0, as you suggested, is simpler. I am sending v2.

Regards,

Sergio Prado