Skip to content

Commit

Permalink
zephyr: Add Kconfig and configuration for SHA on storage
Browse files Browse the repository at this point in the history
Adds CONFIG_BOOT_IMG_HASH_DIRECTLY_ON_STORAGE, which
enables MCUBOOT_HASH_STORAGE_DIRECTLY for Zephyr.

Signed-off-by: Dominik Ermel <[email protected]>
  • Loading branch information
de-nordic committed Oct 11, 2024
1 parent 4eb04b1 commit 20c3dab
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
16 changes: 16 additions & 0 deletions boot/zephyr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ config BOOT_IMG_HASH_ALG_SHA512_ALLOW
help
Hidden option set by configurations that allow SHA512

config BOOT_IMG_HASH_DIRECTLY_ON_STORAGE
bool "Hash calculation functions access storage through address space"
depends on !BOOT_ENCRYPT_IMAGE
help
When possible to map storage device, at least for read operations,
to address space or RAM area, enabling this option allows hash
calculation functions to directly access the storage through that address
space or using its own DMA. This reduces flash read overhead done
by MCUboot.
Notes:
- not supported when encrypted images are in use, because calculating
SHA requires image to be decrypted first, which is done in RAM.
- currently only supported on internal storage of devices; this
option will not work with devices that use external storage for
either of the image slots.

choice BOOT_IMG_HASH_ALG
prompt "Selected image hash algorithm"
default BOOT_IMG_HASH_ALG_SHA256 if BOOT_IMG_HASH_ALG_SHA256_ALLOW
Expand Down
7 changes: 7 additions & 0 deletions boot/zephyr/include/mcuboot_config/mcuboot_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@
#define MCUBOOT_DECOMPRESS_IMAGES
#endif

/* Invoke hashing functions directly on storage device. This requires the device
* be able to map storage to address space or RAM.
*/
#ifdef CONFIG_BOOT_IMG_HASH_DIRECTLY_ON_STORAGE
#define MCUBOOT_HASH_STORAGE_DIRECTLY
#endif

#ifdef CONFIG_BOOT_BOOTSTRAP
#define MCUBOOT_BOOTSTRAP 1
#endif
Expand Down

0 comments on commit 20c3dab

Please sign in to comment.