diff mbox series

[4/4] arm64: dts: imx8mm: Fix FSPI booting

Message ID 20241109200610.1615430-5-aford173@gmail.com
State Changes Requested
Delegated to: Fabio Estevam
Headers show
Series Fix FSPI booting on i.MX8M Mini and Nano | expand

Commit Message

Adam Ford Nov. 9, 2024, 8:06 p.m. UTC
When FSPI_CONF_HEADER is set, the binary needs to be built such
that there is a configuration file prepended at location 0. The
start of the file that would normally be flash.bin starts at 0x1000.
This used to be done properly until the device tree was converted to
nxp_imx8mimage.

Building these with the offsets built into the binman device tree
changes impacts how the actual image is built and the locations
of the various blobs aren't fetched properly and booting fails.

Fix this by building flash.bin as if the prepended header did not
exist, then assemble a second file called flexspi.bin which
has the contents of flash.bin starting at address 0x1000 with the
FSPI header at address 0.  Unlike Nano, which has a different rev
of the boot ROM, the "nxp,boot-from" parameter needs to be set
to fspi instead of sd.

Fixes: 37e50627efac ("ARM: dts: imx: Convert i.MX8M flash.bin image generation to binman")
Signed-off-by: Adam Ford <aford173@gmail.com>
---
 arch/arm/dts/imx8mm-u-boot.dtsi | 259 +++++++++++++++++---------------
 1 file changed, 135 insertions(+), 124 deletions(-)
diff mbox series

Patch

diff --git a/arch/arm/dts/imx8mm-u-boot.dtsi b/arch/arm/dts/imx8mm-u-boot.dtsi
index d31bc82253..83593026b0 100644
--- a/arch/arm/dts/imx8mm-u-boot.dtsi
+++ b/arch/arm/dts/imx8mm-u-boot.dtsi
@@ -42,165 +42,176 @@ 
 };
 
 &binman {
-	filename = "flash.bin";
-	section {
-		pad-byte = <0x00>;
+	multiple-images;
 
-#ifdef CONFIG_FSPI_CONF_HEADER
-		fspi_conf_block {
-			filename = CONFIG_FSPI_CONF_FILE;
-			type = "blob-ext";
-			size = <0x1000>;
-		};
-#endif
+	standard_image: image1 {
+		filename = "flash.bin";
+		section {
+			pad-byte = <0x00>;
 
 #ifdef CONFIG_IMX_HAB
-		nxp-imx8mcst@0 {
-			filename = "u-boot-spl-mkimage.signed.bin";
-			nxp,loader-address = <CONFIG_SPL_TEXT_BASE>;
-			nxp,unlock;
-			args;	/* Needed by mkimage etype superclass */
-#endif
-
-			binman_imx_spl: nxp-imx8mimage {
-				filename = "u-boot-spl-mkimage.bin";
-				nxp,boot-from = "sd";
-				nxp,rom-version = <1>;
+			nxp-imx8mcst@0 {
+				filename = "u-boot-spl-mkimage.signed.bin";
 				nxp,loader-address = <CONFIG_SPL_TEXT_BASE>;
+				nxp,unlock;
 				args;	/* Needed by mkimage etype superclass */
+#endif
 
-				section {
-					align = <4>;
-					align-size = <4>;
-					filename = "u-boot-spl-ddr.bin";
-					pad-byte = <0xff>;
-
-					u-boot-spl {
-						align-end = <4>;
-						filename = "u-boot-spl.bin";
-					};
+				binman_imx_spl: nxp-imx8mimage {
+					filename = "u-boot-spl-mkimage.bin";
+#ifdef CONFIG_FSPI_CONF_HEADER
+					nxp,boot-from = "fspi";
+#else
+					nxp,boot-from = "sd";
+#endif
+					nxp,rom-version = <1>;
+					nxp,loader-address = <CONFIG_SPL_TEXT_BASE>;
+					args;	/* Needed by mkimage etype superclass */
+
+					section {
+						align = <4>;
+						align-size = <4>;
+						filename = "u-boot-spl-ddr.bin";
+						pad-byte = <0xff>;
+
+						u-boot-spl {
+							align-end = <4>;
+							filename = "u-boot-spl.bin";
+						};
 
-					ddr-1d-imem-fw {
-						filename = "lpddr4_pmu_train_1d_imem.bin";
-						align-end = <4>;
-						type = "blob-ext";
-					};
+						ddr-1d-imem-fw {
+							filename = "lpddr4_pmu_train_1d_imem.bin";
+							align-end = <4>;
+							type = "blob-ext";
+						};
 
-					ddr-1d-dmem-fw {
-						filename = "lpddr4_pmu_train_1d_dmem.bin";
-						align-end = <4>;
-						type = "blob-ext";
-					};
+						ddr-1d-dmem-fw {
+							filename = "lpddr4_pmu_train_1d_dmem.bin";
+							align-end = <4>;
+							type = "blob-ext";
+						};
 
-					ddr-2d-imem-fw {
-						filename = "lpddr4_pmu_train_2d_imem.bin";
-						align-end = <4>;
-						type = "blob-ext";
-					};
+						ddr-2d-imem-fw {
+							filename = "lpddr4_pmu_train_2d_imem.bin";
+							align-end = <4>;
+							type = "blob-ext";
+						};
 
-					ddr-2d-dmem-fw {
-						filename = "lpddr4_pmu_train_2d_dmem.bin";
-						align-end = <4>;
-						type = "blob-ext";
+						ddr-2d-dmem-fw {
+							filename = "lpddr4_pmu_train_2d_dmem.bin";
+							align-end = <4>;
+							type = "blob-ext";
+						};
 					};
 				};
-			};
 #ifdef CONFIG_IMX_HAB
-		};
-
-		nxp-imx8mcst@1 {
-			filename = "u-boot-fit.signed.bin";
-			nxp,loader-address = <CONFIG_SPL_LOAD_FIT_ADDRESS>;
-#ifdef CONFIG_FSPI_CONF_HEADER
-			offset = <0x58C00>;
-#else
-			offset = <0x57c00>;
-#endif
-
-			args;	/* Needed by mkimage etype superclass */
-#endif
+			};
 
-			binman_imx_fit: fit {
-				description = "Configuration to load ATF before U-Boot";
-				filename = "u-boot.itb";
-#ifndef CONFIG_IMX_HAB
-				fit,external-offset = <CONFIG_FIT_EXTERNAL_OFFSET>;
-#endif
-				fit,fdt-list = "of-list";
-				#address-cells = <1>;
-#ifdef CONFIG_FSPI_CONF_HEADER
-				offset = <0x58C00>;
-#else
+			nxp-imx8mcst@1 {
+				filename = "u-boot-fit.signed.bin";
+				nxp,loader-address = <CONFIG_SPL_LOAD_FIT_ADDRESS>;
 				offset = <0x57c00>;
+				args;	/* Needed by mkimage etype superclass */
 #endif
-
-				images {
-					uboot {
-						arch = "arm64";
-						compression = "none";
-						description = "U-Boot (64-bit)";
-						load = <CONFIG_TEXT_BASE>;
-						type = "standalone";
-
-						uboot-blob {
-							filename = "u-boot-nodtb.bin";
-							type = "blob-ext";
+				binman_imx_fit: fit {
+					description = "Configuration to load ATF before U-Boot";
+					filename = "u-boot.itb";
+#ifndef CONFIG_IMX_HAB
+					fit,external-offset = <CONFIG_FIT_EXTERNAL_OFFSET>;
+	#endif
+					fit,fdt-list = "of-list";
+					#address-cells = <1>;
+					offset = <0x57c00>;
+
+					images {
+						uboot {
+							arch = "arm64";
+							compression = "none";
+							description = "U-Boot (64-bit)";
+							load = <CONFIG_TEXT_BASE>;
+							type = "standalone";
+
+							uboot-blob {
+								filename = "u-boot-nodtb.bin";
+								type = "blob-ext";
+							};
 						};
-					};
 
 #ifndef CONFIG_ARMV8_PSCI
-					atf {
-						arch = "arm64";
-						compression = "none";
-						description = "ARM Trusted Firmware";
-						entry = <0x920000>;
-						load = <0x920000>;
-						type = "firmware";
-
-						atf-blob {
-							filename = "bl31.bin";
-							type = "atf-bl31";
+						atf {
+							arch = "arm64";
+							compression = "none";
+							description = "ARM Trusted Firmware";
+							entry = <0x920000>;
+							load = <0x920000>;
+							type = "firmware";
+
+							atf-blob {
+								filename = "bl31.bin";
+								type = "atf-bl31";
+							};
 						};
-					};
 #endif
 
-					binman_fip: fip {
-						arch = "arm64";
-						compression = "none";
-						description = "Trusted Firmware FIP";
-						load = <0x40310000>;
-						type = "firmware";
-					};
+						binman_fip: fip {
+							arch = "arm64";
+							compression = "none";
+							description = "Trusted Firmware FIP";
+							load = <0x40310000>;
+							type = "firmware";
+						};
 
-					@fdt-SEQ {
-						compression = "none";
-						description = "NAME";
-						type = "flat_dt";
+						@fdt-SEQ {
+							compression = "none";
+							description = "NAME";
+							type = "flat_dt";
 
-						uboot-fdt-blob {
-							filename = "u-boot.dtb";
-							type = "blob-ext";
+							uboot-fdt-blob {
+								filename = "u-boot.dtb";
+								type = "blob-ext";
+							};
 						};
 					};
-				};
 
-				configurations {
-					default = "@config-DEFAULT-SEQ";
+					configurations {
+						default = "@config-DEFAULT-SEQ";
 
-					@config-SEQ {
-						description = "NAME";
-						fdt = "fdt-SEQ";
-						firmware = "uboot";
+						@config-SEQ {
+							description = "NAME";
+							fdt = "fdt-SEQ";
+							firmware = "uboot";
 #ifndef CONFIG_ARMV8_PSCI
-						loadables = "atf";
+							loadables = "atf";
 #endif
+						};
 					};
 				};
-			};
 #ifdef CONFIG_IMX_HAB
-		};
+			};
 #endif
+		};
 	};
+
+#ifdef CONFIG_FSPI_CONF_HEADER
+	flexspi_image: image2 {
+		filename = "flexspi.bin";
+		section {
+			pad-byte = <0x00>;
+
+			fspi_conf_block {
+				filename = CONFIG_FSPI_CONF_FILE;
+				type = "blob-ext";
+			};
+
+			flashbin {
+				filename = "flash.bin";
+				type = "blob-ext";
+				offset = <0x1000>;
+			};
+		};
+
+	};
+#endif
 };
 
 &clk {