Skip to content

Commit e814268

Browse files
de-nordicnvlsianpu
authored andcommitted
[nrf fromtree] zephyr: Add Kconfig and configuration for SHA on storage
Adds CONFIG_BOOT_IMG_HASH_DIRECTLY_ON_STORAGE, which enables MCUBOOT_HASH_STORAGE_DIRECTLY for Zephyr. Signed-off-by: Dominik Ermel <[email protected]> (cherry picked from commit 96f01aa)
1 parent 29818ad commit e814268

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

boot/zephyr/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,22 @@ config BOOT_IMG_HASH_ALG_SHA512_ALLOW
9191
help
9292
Hidden option set by configurations that allow SHA512
9393

94+
config BOOT_IMG_HASH_DIRECTLY_ON_STORAGE
95+
bool "Hash calculation functions access storage through address space"
96+
depends on !BOOT_ENCRYPT_IMAGE
97+
help
98+
When possible to map storage device, at least for read operations,
99+
to address space or RAM area, enabling this option allows hash
100+
calculation functions to directly access the storage through that address
101+
space or using its own DMA. This reduces flash read overhead done
102+
by MCUboot.
103+
Notes:
104+
- not supported when encrypted images are in use, because calculating
105+
SHA requires image to be decrypted first, which is done in RAM.
106+
- currently only supported on internal storage of devices; this
107+
option will not work with devices that use external storage for
108+
either of the image slots.
109+
94110
choice BOOT_IMG_HASH_ALG
95111
prompt "Selected image hash algorithm"
96112
default BOOT_IMG_HASH_ALG_SHA256 if BOOT_IMG_HASH_ALG_SHA256_ALLOW

boot/zephyr/include/mcuboot_config/mcuboot_config.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@
148148
#define MCUBOOT_DECOMPRESS_IMAGES
149149
#endif
150150

151+
/* Invoke hashing functions directly on storage device. This requires the device
152+
* be able to map storage to address space or RAM.
153+
*/
154+
#ifdef CONFIG_BOOT_IMG_HASH_DIRECTLY_ON_STORAGE
155+
#define MCUBOOT_HASH_STORAGE_DIRECTLY
156+
#endif
157+
151158
#ifdef CONFIG_BOOT_BOOTSTRAP
152159
#define MCUBOOT_BOOTSTRAP 1
153160
#endif

0 commit comments

Comments
 (0)