File tree Expand file tree Collapse file tree 3 files changed +62
-2
lines changed Expand file tree Collapse file tree 3 files changed +62
-2
lines changed Original file line number Diff line number Diff line change
1
+ # Copyright (c) 2025 Nordic Semiconductor ASA
2
+ # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
3
+
4
+ # This script defines a CMake target 'generate_kmu_keyfile_json' to create keyfile.json
5
+ # using 'west ncs-provision upload --dry-run'.
6
+
7
+ # --- Construct the list of commands and dependencies ---
8
+ set (kmu_json_commands "" )
9
+ set (kmu_json_dependencies "" )
10
+
11
+ # Update keyfile for UROT_PUBKEY
12
+ string (CONFIGURE "${SB_CONFIG_BM_BOOTLOADER_MCUBOOT_SIGNATURE_KEY_FILE} " mcuboot_signature_key_file)
13
+ list (APPEND kmu_json_commands
14
+ COMMAND ${Python3_EXECUTABLE} -m west ncs-provision upload
15
+ --keyname UROT_PUBKEY
16
+ --key ${mcuboot_signature_key_file}
17
+ --build -dir ${CMAKE_BINARY_DIR}
18
+ --dry-run
19
+ )
20
+ list (APPEND kmu_json_dependencies ${mcuboot_signature_key_file} )
21
+
22
+ # --- Add custom command to generate/update keyfile.json ---
23
+ if (NOT kmu_json_commands STREQUAL "" )
24
+ add_custom_command (
25
+ OUTPUT ${CMAKE_BINARY_DIR} /keyfile.json
26
+ ${kmu_json_commands} # Expands to one or more COMMAND clauses
27
+ DEPENDS ${kmu_json_dependencies}
28
+ COMMENT "Generating/Updating KMU keyfile JSON (${CMAKE_BINARY_DIR} /keyfile.json)"
29
+ VERBATIM
30
+ )
31
+
32
+ # --- Add custom target to trigger the generation ---
33
+ add_custom_target (
34
+ generate_kmu_keyfile_json ALL
35
+ DEPENDS ${CMAKE_BINARY_DIR} /keyfile.json
36
+ )
37
+ endif ()
Original file line number Diff line number Diff line change @@ -64,9 +64,15 @@ function(bm_install_setup)
64
64
set_config_bool(mcuboot CONFIG_PSA_USE_CRACEN_KEY_AGREEMENT_DRIVER n)
65
65
set_config_bool(mcuboot CONFIG_PSA_USE_CRACEN_KEY_DERIVATION_DRIVER n)
66
66
set_config_bool(mcuboot CONFIG_BOOT_HMAC_SHA512 n)
67
- set_config_bool(mcuboot CONFIG_BOOT_SIGNATURE_USING_KMU n)
68
67
set_config_bool(mcuboot CONFIG_BOOT_KEY_IMPORT_BYPASS_ASN y)
69
- set_config_bool(mcuboot CONFIG_PSA_USE_CRACEN_HASH_DRIVER y)
68
+
69
+ if (SB_CONFIG_BM_BOOTLOADER_MCUBOOT_SIGNATURE_USING_KMU)
70
+ set_config_bool(mcuboot CONFIG_BOOT_SIGNATURE_USING_KMU y)
71
+ set_config_bool(mcuboot CONFIG_PSA_USE_CRACEN_HASH_DRIVER n)
72
+ else ()
73
+ set_config_bool(mcuboot CONFIG_BOOT_SIGNATURE_USING_KMU n)
74
+ set_config_bool(mcuboot CONFIG_PSA_USE_CRACEN_HASH_DRIVER y)
75
+ endif ()
70
76
endif ()
71
77
endif ()
72
78
@@ -246,6 +252,10 @@ function(${SYSBUILD_CURRENT_MODULE_NAME}_post_cmake)
246
252
ALL
247
253
DEPENDS ${CMAKE_BINARY_DIR} /production.hex
248
254
)
255
+
256
+ if (SB_CONFIG_BM_BOOTLOADER_MCUBOOT_GENERATE_DEFAULT_KMU_KEYFILE)
257
+ include (${ZEPHYR_NRF_BM_MODULE_DIR} /cmake/sysbuild/generate_default_keyfile.cmake)
258
+ endif ()
249
259
endif ()
250
260
endfunction ()
251
261
Original file line number Diff line number Diff line change @@ -51,6 +51,19 @@ config BM_BOOTLOADER_MCUBOOT_SIGNATURE_KEY_FILE
51
51
help
52
52
Absolute path to signing key file to use with MCUBoot.
53
53
54
+ config BM_BOOTLOADER_MCUBOOT_SIGNATURE_USING_KMU
55
+ bool "Use KMU stored keys for signature verification"
56
+ depends on SOC_SERIES_NRF54LX && BM_BOOTLOADER_MCUBOOT_SIGNATURE_TYPE_ED25519
57
+ help
58
+ The device needs to be provisioned with proper set of keys.
59
+
60
+ config BM_BOOTLOADER_MCUBOOT_GENERATE_DEFAULT_KMU_KEYFILE
61
+ bool "Generate default keyfile for provisioning during build"
62
+ depends on BM_BOOTLOADER_MCUBOOT_SIGNATURE_USING_KMU
63
+ default y
64
+ help
65
+ If enabled, the build system will generate keyfile.json file in the build directory.
66
+
54
67
menu "Firmware loader entrance modes"
55
68
depends on !BM_FIRMWARE_LOADER_NONE
56
69
You can’t perform that action at this time.
0 commit comments