Skip to content

Commit 21bf7b3

Browse files
committed
sysbuild: Add option to use original KMU keyslots for MCUboot
Adds a sysbuild Kconfig option for this, sets it in the target MCUboot image and updates the keyfile generation file to output for the correct slot Signed-off-by: Jamie McCrae <[email protected]>
1 parent 162b79f commit 21bf7b3

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

cmake/sysbuild/generate_default_keyfile.cmake

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
set(kmu_json_commands "")
99
set(kmu_json_dependencies "")
1010

11-
# First command: Generate keyfile for BL_PUBKEY
11+
# First command: Generate keyfile for b0 (BL_PUBKEY)
1212
if(SB_CONFIG_SECURE_BOOT_GENERATE_DEFAULT_KMU_KEYFILE)
1313
# --- Determine the signing key file to use ---
1414
set(signature_private_key_file "") # Initialize
@@ -39,12 +39,18 @@ if(SB_CONFIG_SECURE_BOOT_GENERATE_DEFAULT_KMU_KEYFILE)
3939
list(APPEND kmu_json_dependencies ${signature_private_key_file})
4040
endif()
4141

42-
# Second command (conditional): Update keyfile for UROT_PUBKEY
42+
# Second command (conditional): Update keyfile for MCUboot (UROT_PUBKEY or BL_PUBKEY)
4343
if(SB_CONFIG_MCUBOOT_GENERATE_DEFAULT_KMU_KEYFILE)
4444
string(CONFIGURE "${SB_CONFIG_BOOT_SIGNATURE_KEY_FILE}" mcuboot_signature_key_file)
45+
set(mcuboot_kmu_keyname UROT_PUBKEY)
46+
47+
if(NOT SB_CONFIG_MCUBOOT_SIGNATURE_KMU_ORIGINAL_MAPPING AND NOT SB_CONFIG_SECURE_BOOT_APPCORE)
48+
set(mcuboot_kmu_keyname BL_PUBKEY)
49+
endif()
50+
4551
list(APPEND kmu_json_commands
4652
COMMAND ${Python3_EXECUTABLE} -m west ncs-provision upload
47-
--keyname UROT_PUBKEY
53+
--keyname ${mcuboot_kmu_keyname}
4854
--key ${mcuboot_signature_key_file}
4955
--build-dir ${CMAKE_BINARY_DIR}
5056
--dry-run

sysbuild/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,12 @@ function(${SYSBUILD_CURRENT_MODULE_NAME}_pre_cmake)
238238

239239
if(SB_CONFIG_MCUBOOT_SIGNATURE_USING_KMU)
240240
set_config_bool(mcuboot CONFIG_BOOT_SIGNATURE_USING_KMU y)
241+
242+
if(SB_CONFIG_MCUBOOT_SIGNATURE_KMU_ORIGINAL_MAPPING)
243+
set_config_bool(mcuboot CONFIG_NCS_BOOT_SIGNATURE_KMU_ORIGINAL_MAPPING y)
244+
else()
245+
set_config_bool(mcuboot CONFIG_NCS_BOOT_SIGNATURE_KMU_ORIGINAL_MAPPING n)
246+
endif()
241247
else()
242248
set_config_bool(mcuboot CONFIG_BOOT_SIGNATURE_USING_KMU n)
243249
endif()

sysbuild/Kconfig.mcuboot

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,18 @@ config MCUBOOT_SIGNATURE_USING_KMU
183183
help
184184
The device needs to be provisioned with proper set of keys.
185185

186+
config MCUBOOT_SIGNATURE_KMU_ORIGINAL_MAPPING
187+
bool "Use original KMU key mapping [DEPRECATED]"
188+
depends on MCUBOOT_SIGNATURE_USING_KMU
189+
depends on SOC_SERIES_NRF54LX
190+
depends on !SECURE_BOOT_APPCORE
191+
select DEPRECATED
192+
help
193+
When this option is enabled, it will use the previous key slot IDs for the MCUboot image
194+
which are assigned for the non-immutable bootloader IDs, otherwise it will use the key
195+
set for the mode that MCUboot is used in (non-immutable slots when b0 is enabled, or
196+
immutable slots when b0 is not enabled).
197+
186198
config MCUBOOT_SIGNATURE_USING_ITS
187199
bool "Use ITS stored keys for signature verification [EXPERIMENTAL]"
188200
depends on SOC_SERIES_NRF54HX

0 commit comments

Comments
 (0)