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

Quentin Schulz quentin.schulz at cherry.de
Fri Apr 11 12:37:48 CEST 2025


Hi Jonas,

On 4/10/25 11:44 PM, Jonas Karlman wrote:
> 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
> +

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,

Reviewed-by: Quentin Schulz <quentin.schulz at cherry.de>

Thanks!
Quentin


More information about the U-Boot mailing list