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

Jonas Karlman jonas at kwiboo.se
Thu Apr 10 23:44:56 CEST 2025


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.

Signed-off-by: Jonas Karlman <jonas at kwiboo.se>
Reviewed-by: Kever Yang <kever.yang at rock-chips.com>
---
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(-)

diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
index f60cc31fb1a6..18accef8bd44 100644
--- a/arch/arm/dts/rockchip-u-boot.dtsi
+++ b/arch/arm/dts/rockchip-u-boot.dtsi
@@ -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
 			};
-- 
2.49.0



More information about the U-Boot mailing list