[PATCH 1/3] rockchip: binman: template all of simple-bin

Quentin Schulz foss+uboot at 0leil.net
Mon Oct 27 16:51:22 CET 2025


From: Quentin Schulz <quentin.schulz at cherry.de>

We may generate two different "simple-bin", one for MMC and one for SPI
flashes, respectively named u-boot-rockchip.bin and
u-boot-rockchip-spi.bin.

There aren't many differences between the two, namely:
- the TPL+SPL called "idbloader" has (for some SoCs) a different type
  to pass to mkimage arguments, namely rksd vs rkspi,
- because of the above, two images are generated, idbloader.img for MMC
  and idbloader-spi.img for SPI,
- we cannot install twice the same file, so even though the content of
  the FIT is the same for both MMC and SPI, we only expose one to the
  user (u-boot.itb filename),
- the FIT can be stored at different offsets for MMC and SPI, the former
  is typically controlled by CONFIG_SPL_PAD_TO but for the latter it
  typically is from CONFIG_SYS_SPI_U_BOOT_OFFS,

binman templating allows to override or supplement templates from the
inserter side, so let's just do that to remove even more duplication.

Signed-off-by: Quentin Schulz <quentin.schulz at cherry.de>
---
 arch/arm/dts/rockchip-u-boot.dtsi | 284 +++++++++++++++++++-------------------
 1 file changed, 140 insertions(+), 144 deletions(-)

diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
index cc2feed6464..736f3598539 100644
--- a/arch/arm/dts/rockchip-u-boot.dtsi
+++ b/arch/arm/dts/rockchip-u-boot.dtsi
@@ -43,132 +43,10 @@
 
 #ifdef CONFIG_SPL
 &binman {
-#ifdef HAS_FIT
-	fit_template: template-1 {
-		type = "fit";
-#ifdef CONFIG_ARM64
-		description = "FIT image for U-Boot with bl31 (TF-A)";
-#else
-		description = "FIT image with OP-TEE";
-#endif
-		#address-cells = <1>;
-		fit,fdt-list = "of-list";
-		fit,external-offset = <CONFIG_FIT_EXTERNAL_OFFSET>;
-		fit,align = <512>;
-		images {
-			u-boot {
-				description = "U-Boot";
-				type = "standalone";
-				os = "u-boot";
-				arch = FIT_ARCH;
-				compression = FIT_UBOOT_COMP;
-				load = <CONFIG_TEXT_BASE>;
-				entry = <CONFIG_TEXT_BASE>;
-				u-boot-nodtb {
-					compress = FIT_UBOOT_COMP;
-				};
-#ifdef FIT_HASH_ALGO
-				hash {
-					algo = FIT_HASH_ALGO;
-				};
-#endif
-			};
-
-#ifdef CONFIG_ARM64
-			@atf-SEQ {
-				fit,operation = "split-elf";
-				description = "ARM Trusted Firmware";
-				type = "firmware";
-				arch = FIT_ARCH;
-				os = "arm-trusted-firmware";
-				compression = "none";
-				fit,load;
-				fit,entry;
-				fit,data;
-
-				atf-bl31 {
-				};
-#ifdef FIT_HASH_ALGO
-				hash {
-					algo = FIT_HASH_ALGO;
-				};
-#endif
-			};
-			@tee-SEQ {
-				fit,operation = "split-elf";
-				description = "TEE";
-				type = "tee";
-				arch = FIT_ARCH;
-				os = "tee";
-				compression = "none";
-				fit,load;
-				fit,entry;
-				fit,data;
-
-				tee-os {
-					optional;
-				};
-#ifdef FIT_HASH_ALGO
-				hash {
-					algo = FIT_HASH_ALGO;
-				};
-#endif
-			};
-#else /* !CONFIG_ARM64 */
-			op-tee {
-				description = "OP-TEE";
-				type = "tee";
-				arch = FIT_ARCH;
-				os = "tee";
-				compression = "none";
-				load = <(CFG_SYS_SDRAM_BASE + 0x8400000)>;
-				entry = <(CFG_SYS_SDRAM_BASE + 0x8400000)>;
-
-				tee-os {
-				};
-#ifdef FIT_HASH_ALGO
-				hash {
-					algo = FIT_HASH_ALGO;
-				};
-#endif
-			};
-#endif /* CONFIG_ARM64 */
-
-			@fdt-SEQ {
-				description = "fdt-NAME";
-				compression = "none";
-				type = "flat_dt";
-#ifdef FIT_HASH_ALGO
-				hash {
-					algo = FIT_HASH_ALGO;
-				};
-#endif
-			};
-		};
-
-		configurations {
-			default = "@config-DEFAULT-SEQ";
-			@config-SEQ {
-				description = "NAME.dtb";
-				fdt = "fdt-SEQ";
-#ifdef CONFIG_ARM64
-				fit,firmware = "atf-1", "u-boot";
-#else
-				fit,firmware = "op-tee", "u-boot";
-#endif
-				fit,loadables;
-				fit,compatible;
-			};
-		};
-	};
-#endif /* HAS_FIT */
-
-	simple-bin {
-		filename = "u-boot-rockchip.bin";
+	simple_bin_template: template-1 {
 		pad-byte = <0xff>;
 
 		mkimage {
-			filename = "idbloader.img";
 			args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
 			multiple-data-files;
 
@@ -185,39 +63,157 @@
 
 #ifdef HAS_FIT
 		fit {
-			filename = "u-boot.itb";
-			insert-template = <&fit_template>;
+			type = "fit";
+#ifdef CONFIG_ARM64
+			description = "FIT image for U-Boot with bl31 (TF-A)";
+#else
+			description = "FIT image with OP-TEE";
+#endif
+			#address-cells = <1>;
+			fit,fdt-list = "of-list";
+			fit,external-offset = <CONFIG_FIT_EXTERNAL_OFFSET>;
+			fit,align = <512>;
+			offset = <CONFIG_SPL_PAD_TO>;
+			images {
+				u-boot {
+					description = "U-Boot";
+					type = "standalone";
+					os = "u-boot";
+					arch = FIT_ARCH;
+					compression = FIT_UBOOT_COMP;
+					load = <CONFIG_TEXT_BASE>;
+					entry = <CONFIG_TEXT_BASE>;
+					u-boot-nodtb {
+						compress = FIT_UBOOT_COMP;
+					};
+#ifdef FIT_HASH_ALGO
+					hash {
+						algo = FIT_HASH_ALGO;
+					};
+#endif
+				};
+
+#ifdef CONFIG_ARM64
+				@atf-SEQ {
+					fit,operation = "split-elf";
+					description = "ARM Trusted Firmware";
+					type = "firmware";
+					arch = FIT_ARCH;
+					os = "arm-trusted-firmware";
+					compression = "none";
+					fit,load;
+					fit,entry;
+					fit,data;
+
+					atf-bl31 {
+					};
+#ifdef FIT_HASH_ALGO
+					hash {
+						algo = FIT_HASH_ALGO;
+					};
+#endif
+				};
+				@tee-SEQ {
+					fit,operation = "split-elf";
+					description = "TEE";
+					type = "tee";
+					arch = FIT_ARCH;
+					os = "tee";
+					compression = "none";
+					fit,load;
+					fit,entry;
+					fit,data;
+
+					tee-os {
+						optional;
+					};
+#ifdef FIT_HASH_ALGO
+					hash {
+						algo = FIT_HASH_ALGO;
+					};
+#endif
+				};
+#else /* !CONFIG_ARM64 */
+				op-tee {
+					description = "OP-TEE";
+					type = "tee";
+					arch = FIT_ARCH;
+					os = "tee";
+					compression = "none";
+					load = <(CFG_SYS_SDRAM_BASE + 0x8400000)>;
+					entry = <(CFG_SYS_SDRAM_BASE + 0x8400000)>;
+
+					tee-os {
+					};
+#ifdef FIT_HASH_ALGO
+					hash {
+						algo = FIT_HASH_ALGO;
+					};
+#endif
+				};
+#endif /* CONFIG_ARM64 */
+
+				@fdt-SEQ {
+					description = "fdt-NAME";
+					compression = "none";
+					type = "flat_dt";
+#ifdef FIT_HASH_ALGO
+					hash {
+						algo = FIT_HASH_ALGO;
+					};
+#endif
+				};
+			};
+
+			configurations {
+				default = "@config-DEFAULT-SEQ";
+				@config-SEQ {
+					description = "NAME.dtb";
+					fdt = "fdt-SEQ";
+#ifdef CONFIG_ARM64
+					fit,firmware = "atf-1", "u-boot";
+#else
+					fit,firmware = "op-tee", "u-boot";
+#endif
+					fit,loadables;
+					fit,compatible;
+				};
+			};
+		};
 #else
 		u-boot-img {
-#endif
 			offset = <CONFIG_SPL_PAD_TO>;
 		};
+#endif
 	};
 
-#ifdef CONFIG_ROCKCHIP_SPI_IMAGE
-	simple-bin-spi {
-		filename = "u-boot-rockchip-spi.bin";
-		pad-byte = <0xff>;
+	simple-bin {
+		insert-template = <&simple_bin_template>;
+		filename = "u-boot-rockchip.bin";
 
 		mkimage {
-			filename = "idbloader-spi.img";
-			args = "-n", CONFIG_SYS_SOC, "-T", "rkspi";
-			multiple-data-files;
-
-#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL
-			rockchip-tpl {
-			};
-#elif defined(CONFIG_TPL)
-			u-boot-tpl {
-			};
-#endif
-			u-boot-spl {
-			};
+			filename = "idbloader.img";
+		};
+
+#ifdef HAS_FIT
+		fit {
+			filename = "u-boot.itb";
+		};
+#endif
+	};
+
+#ifdef CONFIG_ROCKCHIP_SPI_IMAGE
+	simple-bin-spi {
+		insert-template = <&simple_bin_template>;
+		filename = "u-boot-rockchip-spi.bin";
+
+		mkimage {
+			filename = "idbloader-spi.img";
+			args = "-n", CONFIG_SYS_SOC, "-T", "rkspi";
 		};
 
 #ifdef HAS_FIT
 		fit {
-			insert-template = <&fit_template>;
 #else
 		u-boot-img {
 #endif

-- 
2.51.0



More information about the U-Boot mailing list