-
Notifications
You must be signed in to change notification settings - Fork 19
sysbuild: Add KMU provisioning and allow KMU usage #357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ba54fde
58d2e4a
d3c7d3b
d15c1a0
b5e5191
74b1c7c
301f821
0836419
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright (c) 2025 Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
|
||
# This script defines a CMake target 'generate_kmu_keyfile_json' to create keyfile.json | ||
# using 'west ncs-provision upload --dry-run'. | ||
|
||
# --- Construct the list of commands and dependencies --- | ||
set(kmu_json_commands "") | ||
set(kmu_json_dependencies "") | ||
|
||
# Update keyfile for BL_PUBKEY | ||
string(CONFIGURE "${SB_CONFIG_BM_BOOTLOADER_MCUBOOT_SIGNATURE_KEY_FILE}" mcuboot_signature_key_file) | ||
list(APPEND kmu_json_commands | ||
COMMAND ${Python3_EXECUTABLE} -m west ncs-provision upload | ||
--keyname BL_PUBKEY | ||
--key ${mcuboot_signature_key_file} | ||
--build-dir ${CMAKE_BINARY_DIR} | ||
--dry-run | ||
) | ||
list(APPEND kmu_json_dependencies ${mcuboot_signature_key_file}) | ||
|
||
# --- Add custom command to generate/update keyfile.json --- | ||
if(NOT kmu_json_commands STREQUAL "") | ||
add_custom_command( | ||
OUTPUT ${CMAKE_BINARY_DIR}/keyfile.json | ||
${kmu_json_commands} # Expands to one or more COMMAND clauses | ||
DEPENDS ${kmu_json_dependencies} | ||
COMMENT "Generating/Updating KMU keyfile JSON (${CMAKE_BINARY_DIR}/keyfile.json)" | ||
VERBATIM | ||
) | ||
|
||
# --- Add custom target to trigger the generation --- | ||
add_custom_target( | ||
generate_kmu_keyfile_json ALL | ||
DEPENDS ${CMAKE_BINARY_DIR}/keyfile.json | ||
) | ||
endif() |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doc is fine - can be tweaked by the writes based on NCS doc content, |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -38,3 +38,12 @@ Using a key in a project | |||||
------------------------ | ||||||
|
||||||
Once a key has been generated, it can be used in a project by setting the :kconfig:option:`SB_CONFIG_BM_BOOTLOADER_MCUBOOT_SIGNATURE_KEY_FILE` sysbuild Kconfig option to the absolute path of the generated ``.pem`` key file. | ||||||
|
||||||
.. _ug_bootloader_kmu: | ||||||
|
||||||
KMU (Key Management Unit) | ||||||
************************* | ||||||
|
||||||
The nRF54L series of SoCs contain a KMU - key management unit, this on-die peripheral can be used by CRACEN to securely store and use keys without allowing the contents to be read out. | ||||||
In order to boot images when the KMU feature is enabled, the MCUboot singing key must be programmed to the KMU prior to loading the firmware or the device will be unable to boot. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
This feature can be enabled with :kconfig:option:`SB_CONFIG_BM_BOOTLOADER_MCUBOOT_SIGNATURE_USING_KMU`, another sysbuild Kconfig is used to determine if the public key file should be automatically programmed to boards when ``west flash`` is used with the ``--erase`` or ``--recover`` arguments, when :kconfig:option:`SB_CONFIG_BM_BOOTLOADER_MCUBOOT_GENERATE_DEFAULT_KMU_KEYFILE` is enabled (it is enabled by default) then this process is enabled and should be the first command used after building the project to set the board up for development. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ setuptools | |
wheel | ||
west | ||
gitlint | ||
python-dotenv |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -51,6 +51,19 @@ config BM_BOOTLOADER_MCUBOOT_SIGNATURE_KEY_FILE | |||||
help | ||||||
Absolute path to signing key file to use with MCUBoot. | ||||||
|
||||||
config BM_BOOTLOADER_MCUBOOT_SIGNATURE_USING_KMU | ||||||
bool "Use KMU stored keys for signature verification" | ||||||
depends on SOC_SERIES_NRF54LX && BM_BOOTLOADER_MCUBOOT_SIGNATURE_TYPE_ED25519 | ||||||
help | ||||||
The device needs to be provisioned with proper set of keys. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
config BM_BOOTLOADER_MCUBOOT_GENERATE_DEFAULT_KMU_KEYFILE | ||||||
bool "Generate default keyfile for provisioning during build" | ||||||
depends on BM_BOOTLOADER_MCUBOOT_SIGNATURE_USING_KMU | ||||||
default y | ||||||
help | ||||||
If enabled, the build system will generate keyfile.json file in the build directory. | ||||||
|
||||||
menu "Firmware loader entrance modes" | ||||||
depends on !BM_FIRMWARE_LOADER_NONE | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CONFIG_KERNEL_MEM_POOL=n | ||
CONFIG_CURRENT_THREAD_USE_TLS=n | ||
CONFIG_ERRNO=n | ||
CONFIG_FP16=n | ||
CONFIG_HW_STACK_PROTECTION=n | ||
CONFIG_BUILTIN_STACK_GUARD=n | ||
CONFIG_TIMEOUT_64BIT=n | ||
CONFIG_SYS_CLOCK_EXISTS=n | ||
CONFIG_NRF_GRTC_START_SYSCOUNTER=n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add this to storage? E.g. as a 1k storage1_partition?
Or is there no point as we expect the boot_partition size to be further reduced?