public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Adam Ford <aford173@gmail.com>
To: u-boot@lists.denx.de
Cc: aford@beaconembedded.com, lukma@denx.de,
	Adam Ford <aford173@gmail.com>, Stefano Babic <sbabic@denx.de>,
	Fabio Estevam <festevam@gmail.com>,
	"NXP i.MX U-Boot Team" <uboot-imx@nxp.com>,
	Tom Rini <trini@konsulko.com>, Marek Vasut <marex@denx.de>,
	Tim Harvey <tharvey@gateworks.com>, Peng Fan <peng.fan@nxp.com>,
	Sean Anderson <seanga2@gmail.com>, Simon Glass <sjg@chromium.org>,
	Quentin Schulz <quentin.schulz@cherry.de>
Subject: [PATCH 1/4] arm64: dts: imx8mn: Fix FSPI booting
Date: Sat,  9 Nov 2024 14:06:02 -0600	[thread overview]
Message-ID: <20241109200610.1615430-2-aford173@gmail.com> (raw)
In-Reply-To: <20241109200610.1615430-1-aford173@gmail.com>

When FSPI_CONF_HEADER is set, the binary needs to be built such
that there is a configuration file located at 0x400 and 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 a standard image as if it were to boot from
eMMC or SD, then use that image as the input for a second image
which adds this FSPI header at 0x400, and then places the standard
image at offset 0x1000.  This also has the benefit of being able
to create both SD/eMMC image at the same time as a fspi image
called flexspi.bin.

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/imx8mn-u-boot.dtsi | 266 +++++++++++++++++---------------
 1 file changed, 138 insertions(+), 128 deletions(-)

diff --git a/arch/arm/dts/imx8mn-u-boot.dtsi b/arch/arm/dts/imx8mn-u-boot.dtsi
index 6875c6d44f..157e6b9a26 100644
--- a/arch/arm/dts/imx8mn-u-boot.dtsi
+++ b/arch/arm/dts/imx8mn-u-boot.dtsi
@@ -91,185 +91,195 @@
 };
 
 &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";
-			offset = <0x400>;
-		};
-#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 = <2>;
+			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 {
-					filename = "u-boot-spl-ddr.bin";
-					pad-byte = <0xff>;
-					align-size = <4>;
-					align = <4>;
-
-					u-boot-spl {
-						align-end = <4>;
-						filename = "u-boot-spl.bin";
-					};
+				binman_imx_spl: nxp-imx8mimage {
+					filename = "u-boot-spl-mkimage.bin";
+					nxp,boot-from = "sd";
+					nxp,rom-version = <2>;
+					nxp,loader-address = <CONFIG_SPL_TEXT_BASE>;
+					args;	/* Needed by mkimage etype superclass */
+
+					section {
+						filename = "u-boot-spl-ddr.bin";
+						pad-byte = <0xff>;
+						align-size = <4>;
+						align = <4>;
+
+						u-boot-spl {
+							align-end = <4>;
+							filename = "u-boot-spl.bin";
+						};
 
-					ddr-1d-imem-fw {
+						ddr-1d-imem-fw {
 #ifdef CONFIG_IMX8M_LPDDR4
-						filename = "lpddr4_pmu_train_1d_imem.bin";
+							filename = "lpddr4_pmu_train_1d_imem.bin";
 #elif CONFIG_IMX8M_DDR4
-						filename = "ddr4_imem_1d_201810.bin";
+							filename = "ddr4_imem_1d_201810.bin";
 #else
-						filename = "ddr3_imem_1d.bin";
+							filename = "ddr3_imem_1d.bin";
 #endif
-						type = "blob-ext";
-						align-end = <4>;
-					};
+							type = "blob-ext";
+							align-end = <4>;
+						};
 
-					ddr-1d-dmem-fw {
+						ddr-1d-dmem-fw {
 #ifdef CONFIG_IMX8M_LPDDR4
-						filename = "lpddr4_pmu_train_1d_dmem.bin";
+							filename = "lpddr4_pmu_train_1d_dmem.bin";
 #elif CONFIG_IMX8M_DDR4
-						filename = "ddr4_dmem_1d_201810.bin";
+							filename = "ddr4_dmem_1d_201810.bin";
 #else
-						filename = "ddr3_dmem_1d.bin";
+							filename = "ddr3_dmem_1d.bin";
 #endif
-						type = "blob-ext";
-						align-end = <4>;
-					};
+							type = "blob-ext";
+							align-end = <4>;
+						};
 
 #if defined(CONFIG_IMX8M_LPDDR4) || defined(CONFIG_IMX8M_DDR4)
-					ddr-2d-imem-fw {
+						ddr-2d-imem-fw {
 #ifdef CONFIG_IMX8M_LPDDR4
-						filename = "lpddr4_pmu_train_2d_imem.bin";
+							filename = "lpddr4_pmu_train_2d_imem.bin";
 #else
-						filename = "ddr4_imem_2d_201810.bin";
+							filename = "ddr4_imem_2d_201810.bin";
 #endif
-						type = "blob-ext";
-						align-end = <4>;
-					};
+							type = "blob-ext";
+							align-end = <4>;
+						};
 
-					ddr-2d-dmem-fw {
+						ddr-2d-dmem-fw {
 #ifdef CONFIG_IMX8M_LPDDR4
-						filename = "lpddr4_pmu_train_2d_dmem.bin";
+							filename = "lpddr4_pmu_train_2d_dmem.bin";
 #else
-						filename = "ddr4_dmem_2d_201810.bin";
+							filename = "ddr4_dmem_2d_201810.bin";
 #endif
-						type = "blob-ext";
-						align-end = <4>;
-					};
+							type = "blob-ext";
+							align-end = <4>;
+						};
 #endif
+					};
 				};
-			};
 
 #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 = <0x59000>;
-#else
-			offset = <0x58000>;
-#endif
-			args;	/* Needed by mkimage etype superclass */
+			nxp-imx8mcst@1 {
+				filename = "u-boot-fit.signed.bin";
+				nxp,loader-address = <CONFIG_SPL_LOAD_FIT_ADDRESS>;
+				offset = <0x58000>;
+				args;	/* Needed by mkimage etype superclass */
 #endif
 
-			binman_imx_fit: fit {
-				description = "Configuration to load ATF before U-Boot";
-				filename = "u-boot.itb";
+				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>;
+					fit,external-offset = <CONFIG_FIT_EXTERNAL_OFFSET>;
 #endif
-				fit,fdt-list = "of-list";
-				#address-cells = <1>;
-#ifdef CONFIG_FSPI_CONF_HEADER
-				offset = <0x59000>;
-#else
-				offset = <0x58000>;
-#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";
+					fit,fdt-list = "of-list";
+					#address-cells = <1>;
+					offset = <0x58000>;
+
+					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 = <0x960000>;
-						load = <0x960000>;
-						type = "firmware";
-
-						atf-blob {
-							filename = "bl31.bin";
-							type = "atf-bl31";
+						atf {
+							arch = "arm64";
+							compression = "none";
+							description = "ARM Trusted Firmware";
+							entry = <0x960000>;
+							load = <0x960000>;
+							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";
+				offset = <0x400>;
+			};
+
+			flashbin {
+				filename = "flash.bin";
+				type = "blob-ext";
+				offset = <0x1000>;
+			};
+		};
+
 	};
+#endif
 };
-- 
2.45.2


  reply	other threads:[~2024-11-09 20:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-09 20:06 [PATCH 0/4] Fix FSPI booting on i.MX8M Mini and Nano Adam Ford
2024-11-09 20:06 ` Adam Ford [this message]
2024-11-10  1:29   ` [PATCH 1/4] arm64: dts: imx8mn: Fix FSPI booting Marek Vasut
2024-11-10 13:15     ` Adam Ford
2024-11-10 16:33       ` Marek Vasut
2024-11-10 17:21         ` Adam Ford
2024-11-11  0:45           ` Marek Vasut
2024-11-11  1:46             ` Adam Ford
2024-11-11 10:23               ` Marek Vasut
2024-11-09 20:06 ` [PATCH 2/4] configs: imx8mn_beacon: Enable FSPI_CONF_HEADER Adam Ford
2024-11-09 20:06 ` [PATCH 3/4] configs: imx8mn_beacon: Remove imx8mn_beacon_fspi_defconfig Adam Ford
2024-11-09 20:06 ` [PATCH 4/4] arm64: dts: imx8mm: Fix FSPI booting Adam Ford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241109200610.1615430-2-aford173@gmail.com \
    --to=aford173@gmail.com \
    --cc=aford@beaconembedded.com \
    --cc=festevam@gmail.com \
    --cc=lukma@denx.de \
    --cc=marex@denx.de \
    --cc=peng.fan@nxp.com \
    --cc=quentin.schulz@cherry.de \
    --cc=sbabic@denx.de \
    --cc=seanga2@gmail.com \
    --cc=sjg@chromium.org \
    --cc=tharvey@gateworks.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=uboot-imx@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox