Skip to contentSkip to conversation

rockchip: binman: Use a template for FIT and other improvements

PATCH Superseded Jonas Karlman 2 participants 10 messages Apr 10, 2025 – Apr 11, 2025

Subsystems (2)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover rockchip: binman: Use a template for FIT and other improvements

This series split out generic Rockchip binman image related commits from Simons "VBE serial part H: Implement VBE on Rockchip RK3399" [1] series.

These are generic binman image patches fixing an existing issue [2][3] and that other series [4] already depends on.

They are being split out to ease continued work for other U-Boot developers as the main parts of the VBE series have not yet been tested using the mainline U-Boot tree, so cannot yet be seen as ready.

Changes in v5:
- Rename ARCH to FIT_ARCH and COMP to FIT_UBOOT_COMP
- Merge change to use template in spi image with addition of template
- Reorder patches: fixes, none functional changes, functional changes
- Drop two patches related to skip-at-start and fdtmap
- Update commit messages
- Collect r-b tags

Changes in v4:
- Patch 1-7 matches corresponding patch in Simons series, possible with minor updates in commit messages.
- Patch 8 drops changes to defconfig-files.
- Patch 9 adds support for using crc32 as checksum algo.
- Patch 10 adds a default value for SPL_PAD_TO.

This series holds off on any defconfig changes to let it be handled by next "configs: Resync with savedefconfig". Changing SPL_PAD_TO to be storage media relative has also been held off and is something that can be picked up in a series for a future release after this has landed in a release.

See [5] for a copy of this series on top of patch 1-2 from [3]. This series does not depend on those two patches, but are related for a full cleanup of use of u-boot.itb in Rockchip binman images.

[1] https://lore.kernel.org/u-boot/[email protected]/
[2] https://lore.kernel.org/u-boot/[email protected]/
[3] https://lore.kernel.org/u-boot/20250220-has_rom-u-boot-rockchip-spi-bin-v2-3-d1768ee87808@cherry.de/
[4] https://lore.kernel.org/u-boot/[email protected]/
[5] https://source.denx.de/u-boot/contributors/kwiboo/u-boot/-/commits/binman-v5

Jonas Karlman (2):
rockchip: Add SPL_PAD_TO Kconfig default value
rockchip: binman: Support use of crc32 hash for FIT images

Simon Glass (5):
rockchip: binman: Correct the OS prop for U-Boot
rockchip: binman: Factor out arch and compression
rockchip: binman: Create a template for the FIT
rockchip: binman: Un-indent the FIT template
rockchip: binman: Include a compatible string in each configuration

 arch/arm/dts/rockchip-u-boot.dtsi | 293 ++++++++++++++++--------------
 common/spl/Kconfig                |   1 +
 2 files changed, 159 insertions(+), 135 deletions(-)
Signature · 1 line
2.49.0
#1 lore raw

PATCH v5 1/7 rockchip: binman: Correct the OS prop for U-Boot

From: Simon Glass <[email protected]>

The U-Boot image is currently being identified as an invalid OS in spl_fit_image_get_os() due to case sensitive compare.

Use the correct lower-case value to fix this.

Fixes e0c0efff2a02 ("rockchip: Support building the all output files in binman")

---
Changes in v5:
- Collect r-b tag

Changes in v4:
- Update commit message
- Split from "VBE serial part H: Implement VBE on Rockchip RK3399"

---
 arch/arm/dts/rockchip-u-boot.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/dts/rockchip-u-boot.dtsi +1 -1
index c8c928c7e508..e9ed1d4b5738 100644
@@ -50,7 +50,7 @@
 				u-boot {
 					description = "U-Boot";
 					type = "standalone";
-					os = "U-Boot";
+					os = "u-boot";
 #ifdef CONFIG_ARM64
 					arch = "arm64";
 #else
Signature · 1 line
2.49.0
Reviewed-by on v5 1/7
#2 lore raw

Re: [PATCH v5 1/7] rockchip: binman: Correct the OS prop for U-Boot

Hi Jonas,

Quoted 11 lines · Jonas Karlman

From: Simon Glass <[email protected]>

The U-Boot image is currently being identified as an invalid OS in spl_fit_image_get_os() due to case sensitive compare.

Use the correct lower-case value to fix this.

Fixes e0c0efff2a02 ("rockchip: Support building the all output files in binman")

Thanks!
Quentin

#3 lore raw

PATCH v5 2/7 rockchip: binman: Factor out arch and compression

In reply to Jonas Karlman

From: Simon Glass <[email protected]>

Declare arch and compression at the top of the file to avoid needing ifdefs in every usage.

Add a few comments to help with the remaining #ifdefs.

---
Changes in v5:
- Rename ARCH to FIT_ARCH
- Rename COMP to FIT_UBOOT_COMP
- Collect r-b tag

Changes in v4:
- Split from "VBE serial part H: Implement VBE on Rockchip RK3399"

---
 arch/arm/dts/rockchip-u-boot.dtsi | 44 +++++++++++++++----------------
 1 file changed, 22 insertions(+), 22 deletions(-)
arch/arm/dts/rockchip-u-boot.dtsi +22 -22
index e9ed1d4b5738..943d7d87a068 100644
@@ -5,6 +5,20 @@
 
 #include <config.h>
 
+#ifdef CONFIG_ARM64
+#define FIT_ARCH		"arm64"
+#else
+#define FIT_ARCH		"arm"
+#endif
+
+#if defined(CONFIG_SPL_GZIP)
+#define FIT_UBOOT_COMP		"gzip"
+#elif defined(CONFIG_SPL_LZMA)
+#define FIT_UBOOT_COMP		"lzma"
+#else
+#define FIT_UBOOT_COMP		"none"
+#endif
+
 / {
 	binman: binman {
 		multiple-images;
@@ -51,26 +65,12 @@
 					description = "U-Boot";
 					type = "standalone";
 					os = "u-boot";
-#ifdef CONFIG_ARM64
-					arch = "arm64";
-#else
-					arch = "arm";
-#endif
-#if defined(CONFIG_SPL_GZIP)
-					compression = "gzip";
-#elif defined(CONFIG_SPL_LZMA)
-					compression = "lzma";
-#else
-					compression = "none";
-#endif
+					arch = FIT_ARCH;
+					compression = FIT_UBOOT_COMP;
 					load = <CONFIG_TEXT_BASE>;
 					entry = <CONFIG_TEXT_BASE>;
 					u-boot-nodtb {
-#if defined(CONFIG_SPL_GZIP)
-					compress = "gzip";
-#elif defined(CONFIG_SPL_LZMA)
-					compress = "lzma";
-#endif
+					compress = FIT_UBOOT_COMP;
 					};
 #ifdef CONFIG_SPL_FIT_SIGNATURE
 					hash {
@@ -84,7 +84,7 @@
 					fit,operation = "split-elf";
 					description = "ARM Trusted Firmware";
 					type = "firmware";
-					arch = "arm64";
+					arch = FIT_ARCH;
 					os = "arm-trusted-firmware";
 					compression = "none";
 					fit,load;
@@ -103,7 +103,7 @@
 					fit,operation = "split-elf";
 					description = "TEE";
 					type = "tee";
-					arch = "arm64";
+					arch = FIT_ARCH;
 					os = "tee";
 					compression = "none";
 					fit,load;
@@ -119,11 +119,11 @@
 					};
 #endif
 				};
-#else
+#else /* !CONFIG_ARM64 */
 				op-tee {
 					description = "OP-TEE";
 					type = "tee";
-					arch = "arm";
+					arch = FIT_ARCH;
 					os = "tee";
 					compression = "none";
 					load = <(CFG_SYS_SDRAM_BASE + 0x8400000)>;
@@ -137,7 +137,7 @@
 					};
 #endif
 				};
-#endif
+#endif /* CONFIG_ARM64 */
 
 				@fdt-SEQ {
 					description = "fdt-NAME";
Signature · 1 line
2.49.0
#4 lore raw

PATCH v5 3/7 rockchip: binman: Create a template for the FIT

In reply to Jonas Karlman

From: Simon Glass <[email protected]>

Move the FIT description into a template so that it can be used in both the simple-bin and the simple-bin-spi images.

---
Changes in v5:
- Merge patch to use template for simple-bin-spi image
- Collect r-b tags

Changes in v4:
- Rename template label to fit_template
- Split from "VBE serial part H: Implement VBE on Rockchip RK3399"

Changes in v3:
- Use HAS_FIT for the SPI node also
- Leave fit { node open within #ifdef HAS_FIT
- Move placement of CONFIG_SPL_PAD_TO
- Keep the FIT filename

---
 arch/arm/dts/rockchip-u-boot.dtsi | 64 +++++++++++++++++--------------
 1 file changed, 36 insertions(+), 28 deletions(-)
arch/arm/dts/rockchip-u-boot.dtsi +36 -28
index 943d7d87a068..0c074c0ec6b9 100644
@@ -19,6 +19,10 @@
 #define FIT_UBOOT_COMP		"none"
 #endif
 
+#if defined(CONFIG_SPL_FIT) && (defined(CONFIG_ARM64) || defined(CONFIG_SPL_OPTEE_IMAGE))
+#define HAS_FIT
+#endif
+
 / {
 	binman: binman {
 		multiple-images;
@@ -27,28 +31,9 @@
 
 #ifdef CONFIG_SPL
 &binman {
-	simple-bin {
-		filename = "u-boot-rockchip.bin";
-		pad-byte = <0xff>;
-
-		mkimage {
-			filename = "idbloader.img";
-			args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
-			multiple-data-files;
-
-#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL
-			rockchip-tpl {
-			};
-#elif defined(CONFIG_TPL)
-			u-boot-tpl {
-			};
-#endif
-			u-boot-spl {
-			};
-		};
-
-#if defined(CONFIG_SPL_FIT) && (defined(CONFIG_ARM64) || defined(CONFIG_SPL_OPTEE_IMAGE))
-		fit: fit {
+#ifdef HAS_FIT
+	fit_template: template-1 {
+			type = "fit";
 #ifdef CONFIG_ARM64
 			description = "FIT image for U-Boot with bl31 (TF-A)";
 #else
@@ -56,10 +41,8 @@
 #endif
 			#address-cells = <1>;
 			fit,fdt-list = "of-list";
-			filename = "u-boot.itb";
 			fit,external-offset = <CONFIG_FIT_EXTERNAL_OFFSET>;
 			fit,align = <512>;
-			offset = <CONFIG_SPL_PAD_TO>;
 			images {
 				u-boot {
 					description = "U-Boot";
@@ -164,12 +147,38 @@
 					fit,loadables;
 				};
 			};
+	};
+#endif /* HAS_FIT */
+
+	simple-bin {
+		filename = "u-boot-rockchip.bin";
+		pad-byte = <0xff>;
+
+		mkimage {
+			filename = "idbloader.img";
+			args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
+			multiple-data-files;
+
+#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL
+			rockchip-tpl {
+			};
+#elif defined(CONFIG_TPL)
+			u-boot-tpl {
+			};
+#endif
+			u-boot-spl {
+			};
 		};
+
+#ifdef HAS_FIT
+		fit {
+			filename = "u-boot.itb";
+			insert-template = <&fit_template>;
 #else
 		u-boot-img {
+#endif
 			offset = <CONFIG_SPL_PAD_TO>;
 		};
-#endif
 	};
 
 #ifdef CONFIG_ROCKCHIP_SPI_IMAGE
@@ -193,10 +202,9 @@
 			};
 		};
 
-#if defined(CONFIG_ARM64) || defined(CONFIG_SPL_OPTEE_IMAGE)
+#ifdef HAS_FIT
 		fit {
-			type = "blob";
-			filename = "u-boot.itb";
+			insert-template = <&fit_template>;
 #else
 		u-boot-img {
 #endif
Signature · 1 line
2.49.0
#5 lore raw

PATCH v5 4/7 rockchip: binman: Un-indent the FIT template

In reply to Jonas Karlman

From: Simon Glass <[email protected]>

Fix the indentation on the template. This is done in a separate patch so that it is easier to review.

---
Changes in v5:
- Collect r-b tags

Changes in v4:
- Split from "VBE serial part H: Implement VBE on Rockchip RK3399"

---
 arch/arm/dts/rockchip-u-boot.dtsi | 176 +++++++++++++++---------------
 1 file changed, 88 insertions(+), 88 deletions(-)
arch/arm/dts/rockchip-u-boot.dtsi +88 -88
index 0c074c0ec6b9..e97e9d23834c 100644
@@ -33,120 +33,120 @@
 &binman {
 #ifdef HAS_FIT
 	fit_template: template-1 {
-			type = "fit";
+		type = "fit";
 #ifdef CONFIG_ARM64
-			description = "FIT image for U-Boot with bl31 (TF-A)";
+		description = "FIT image for U-Boot with bl31 (TF-A)";
 #else
-			description = "FIT image with OP-TEE";
+		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 {
+		#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 CONFIG_SPL_FIT_SIGNATURE
-					hash {
-						algo = "sha256";
-					};
-#endif
+				hash {
+					algo = "sha256";
 				};
+#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 {
-					};
+			@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 CONFIG_SPL_FIT_SIGNATURE
-					hash {
-						algo = "sha256";
-					};
+				hash {
+					algo = "sha256";
+				};
 #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;
 				};
-				@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 CONFIG_SPL_FIT_SIGNATURE
-					hash {
-						algo = "sha256";
-					};
-#endif
+				hash {
+					algo = "sha256";
 				};
+#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 {
-					};
+			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 CONFIG_SPL_FIT_SIGNATURE
-					hash {
-						algo = "sha256";
-					};
-#endif
+				hash {
+					algo = "sha256";
 				};
+#endif
+			};
 #endif /* CONFIG_ARM64 */
 
-				@fdt-SEQ {
-					description = "fdt-NAME";
-					compression = "none";
-					type = "flat_dt";
+			@fdt-SEQ {
+				description = "fdt-NAME";
+				compression = "none";
+				type = "flat_dt";
 #ifdef CONFIG_SPL_FIT_SIGNATURE
-					hash {
-						algo = "sha256";
-					};
-#endif
+				hash {
+					algo = "sha256";
 				};
+#endif
 			};
+		};
 
-			configurations {
-				default = "@config-DEFAULT-SEQ";
-				@config-SEQ {
-					description = "NAME.dtb";
-					fdt = "fdt-SEQ";
+		configurations {
+			default = "@config-DEFAULT-SEQ";
+			@config-SEQ {
+				description = "NAME.dtb";
+				fdt = "fdt-SEQ";
 #ifdef CONFIG_ARM64
-					fit,firmware = "atf-1", "u-boot";
+				fit,firmware = "atf-1", "u-boot";
 #else
-					fit,firmware = "op-tee", "u-boot";
+				fit,firmware = "op-tee", "u-boot";
 #endif
-					fit,loadables;
-				};
+				fit,loadables;
 			};
+		};
 	};
 #endif /* HAS_FIT */
 
Signature · 1 line
2.49.0
#6 lore raw

PATCH v5 5/7 rockchip: Add SPL_PAD_TO Kconfig default value

In reply to Jonas Karlman

Almost all Rockchip boards use the same Kconfig value for SPL_PAD_TO, 0x7f8000.

u-boot-rockchip.bin is typically written to offset 64S (32KiB) of MMC media. u-boot.itb (or u-boot.img) is typically expected at offset 16384S (8MiB) of MMC media (SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x4000).

SPL_PAD_TO is used as the offset for u-boot.itb (or u-boot.img) in the generated simple-bin binman image, and can be calculated as:

SPL_PAD_TO = (16384S - 64S) * 512 = 0x7f8000

Add this value as a default value for ARCH_ROCKCHIP.

---
Changes in v5:
- Update commit message
- Collect r-b tags

Changes in v4:
- New patch

This patch does not drop SPL_PAD_TO from existing defconfigs that would be affected by this change, something that can wait until next "configs:
Resync with savedefconfig".

Following boards does not set a SPL_PAD_TO due to not using SPL:
- elgin-rv1108_defconfig
- evb-rk3128_defconfig
- evb-rv1108_defconfig
- geekbox_defconfig
- sheep-rk3368_defconfig

---
 common/spl/Kconfig | 1 +
 1 file changed, 1 insertion(+)
common/spl/Kconfig +1 -0
index c08045f9c8d7..3f8d24e8d0f5 100644
@@ -96,6 +96,7 @@ config SPL_MAX_SIZE
 
 config SPL_PAD_TO
 	hex "Offset to which the SPL should be padded before appending the SPL payload"
+	default 0x7f8000 if ARCH_ROCKCHIP
 	default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
 	default 0x11000 if ARCH_MX7 || (ARCH_MX6 && !MX6_OCRAM_256KB)
 	default 0x10000 if ARCH_KEYSTONE
Signature · 1 line
2.49.0
#7 lore raw

PATCH v5 6/7 rockchip: binman: Include a compatible string in each configuration

In reply to Jonas Karlman

From: Simon Glass <[email protected]>

Provide a compatible string in the config nodes that U-Boot can use to help decide which configuration to use with SPL_LOAD_FIT_FULL=y and FIT_BEST_MATCH=y.

---
Changes in v5:
- Update commit message
- Collect r-b tags

Changes in v4:
- Split from "VBE serial part H: Implement VBE on Rockchip RK3399"

---
 arch/arm/dts/rockchip-u-boot.dtsi | 1 +
 1 file changed, 1 insertion(+)
arch/arm/dts/rockchip-u-boot.dtsi +1 -0
index e97e9d23834c..f60cc31fb1a6 100644
@@ -145,6 +145,7 @@
 				fit,firmware = "op-tee", "u-boot";
 #endif
 				fit,loadables;
+				fit,compatible;
 			};
 		};
 	};
Signature · 1 line
2.49.0
#8 lore raw

PATCH v5 7/7 rockchip: binman: Support use of crc32 hash for FIT images

In reply to Jonas Karlman

Use of SHA256 checksum validation on ARMv7 SoCs can be very time consuming compared to when used on a ARMv8 SoC with Crypto Extensions.

Add support for use of the much faster CRC32 hash algo when SHA256 is not supported in SPL. Also use a HAS_FIT_HASH to simplify the ifdefs when no known hash algo has been compiled.

---
Changes in v5:
- Update commit message and add comment that CRC32 hash algo should only be used for basic checksum validation.
- Collect r-b tag

Changes in v4:
- New patch

This patch can be skipped in case there is any objection against adding crc32 as a checksum fallback algo, something that will be usefull in a future rk3228 related series.

---
 arch/arm/dts/rockchip-u-boot.dtsi | 34 ++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 10 deletions(-)
arch/arm/dts/rockchip-u-boot.dtsi +24 -10
index f60cc31fb1a6..18accef8bd44 100644
@@ -19,10 +19,24 @@
 #define FIT_UBOOT_COMP		"none"
 #endif
 
+/*
+ * SHA256 should be enabled in SPL when signature validation is involved,
+ * CRC32 should only be used for basic checksum validation of FIT images.
+ */
+#if defined(CONFIG_SPL_SHA256)
+#define FIT_HASH_ALGO		"sha256"
+#elif defined(CONFIG_SPL_CRC32)
+#define FIT_HASH_ALGO		"crc32"
+#endif
+
 #if defined(CONFIG_SPL_FIT) && (defined(CONFIG_ARM64) || defined(CONFIG_SPL_OPTEE_IMAGE))
 #define HAS_FIT
 #endif
 
+#if defined(CONFIG_SPL_FIT_SIGNATURE) && defined(FIT_HASH_ALGO)
+#define HAS_FIT_HASH
+#endif
+
 / {
 	binman: binman {
 		multiple-images;
@@ -55,9 +69,9 @@
 				u-boot-nodtb {
 					compress = FIT_UBOOT_COMP;
 				};
-#ifdef CONFIG_SPL_FIT_SIGNATURE
+#ifdef HAS_FIT_HASH
 				hash {
-					algo = "sha256";
+					algo = FIT_HASH_ALGO;
 				};
 #endif
 			};
@@ -76,9 +90,9 @@
 
 				atf-bl31 {
 				};
-#ifdef CONFIG_SPL_FIT_SIGNATURE
+#ifdef HAS_FIT_HASH
 				hash {
-					algo = "sha256";
+					algo = FIT_HASH_ALGO;
 				};
 #endif
 			};
@@ -96,9 +110,9 @@
 				tee-os {
 					optional;
 				};
-#ifdef CONFIG_SPL_FIT_SIGNATURE
+#ifdef HAS_FIT_HASH
 				hash {
-					algo = "sha256";
+					algo = FIT_HASH_ALGO;
 				};
 #endif
 			};
@@ -114,9 +128,9 @@
 
 				tee-os {
 				};
-#ifdef CONFIG_SPL_FIT_SIGNATURE
+#ifdef HAS_FIT_HASH
 				hash {
-					algo = "sha256";
+					algo = FIT_HASH_ALGO;
 				};
 #endif
 			};
@@ -126,9 +140,9 @@
 				description = "fdt-NAME";
 				compression = "none";
 				type = "flat_dt";
-#ifdef CONFIG_SPL_FIT_SIGNATURE
+#ifdef HAS_FIT_HASH
 				hash {
-					algo = "sha256";
+					algo = FIT_HASH_ALGO;
 				};
 #endif
 			};
Signature · 1 line
2.49.0
Reviewed-by on v5 7/7
#9 lore raw

Re: [PATCH v5 7/7] rockchip: binman: Support use of crc32 hash for FIT images

Hi Jonas,

Quoted 41 lines · Jonas Karlman

Use of SHA256 checksum validation on ARMv7 SoCs can be very time consuming compared to when used on a ARMv8 SoC with Crypto Extensions.

Add support for use of the much faster CRC32 hash algo when SHA256 is not supported in SPL. Also use a HAS_FIT_HASH to simplify the ifdefs when no known hash algo has been compiled.

---
Changes in v5:
- Update commit message and add comment that CRC32 hash algo should only be used for basic checksum validation.
- Collect r-b tag

Changes in v4:
- New patch

This patch can be skipped in case there is any objection against adding crc32 as a checksum fallback algo, something that will be usefull in a future rk3228 related series.

---
  arch/arm/dts/rockchip-u-boot.dtsi | 34 ++++++++++++++++++++++---------
  1 file changed, 24 insertions(+), 10 deletions(-)
arch/arm/dts/rockchip-u-boot.dtsi +8 -0
index f60cc31fb1a6..18accef8bd44 100644
@@ -19,10 +19,24 @@
  #define FIT_UBOOT_COMP		"none"
  #endif
 
+/*
+ * SHA256 should be enabled in SPL when signature validation is involved,
+ * CRC32 should only be used for basic checksum validation of FIT images.
+ */
+#if defined(CONFIG_SPL_SHA256)
+#define FIT_HASH_ALGO		"sha256"
+#elif defined(CONFIG_SPL_CRC32)
+#define FIT_HASH_ALGO		"crc32"

arch/arm/dts/rockchip-u-boot.dtsi line 39

Quoted 10 lines
arch/arm/dts/rockchip-u-boot.dtsi +6 -0
+#endif
+
  #if defined(CONFIG_SPL_FIT) && (defined(CONFIG_ARM64) || defined(CONFIG_SPL_OPTEE_IMAGE))
  #define HAS_FIT
  #endif
 
+#if defined(CONFIG_SPL_FIT_SIGNATURE) && defined(FIT_HASH_ALGO)
+#define HAS_FIT_HASH
+#endif
+

We could spare a constant (HAS_FIT_HASH) by simply reusing FIT_HASH_ALGO.

Something like:

"""
#if defined(CONFIG_SPL_FIT_SIGNATURE)
#if defined(CONFIG_SPL_SHA256)
#define FIT_HASH_ALGO "sha256"
#elif defined(CONFIG_SPL_CRC32)
#define FIT_HASH_ALGO "crc32"
#endif
#endif

[...]

#ifdef FIT_HASH_ALGO

hash {
    algo = FIT_HASH_ALGO;
};

"""

In any case,

Thanks!
Quentin