Skip to content

Conversation

nordicjm
Copy link
Contributor

Allows usage of KMU in MCUboot for the signature verification and copies the KMU provisioning script from NCS with changes for BM

@nordicjm nordicjm requested review from a team as code owners September 12, 2025 07:52
@nordicjm nordicjm added the DNM Do not merge label Sep 12, 2025
@github-actions github-actions bot added the changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. label Sep 12, 2025
@github-actions
Copy link

You can find the documentation preview for this PR here.

@nordicjm nordicjm requested a review from a team September 15, 2025 10:25
@nordicjm nordicjm requested a review from a team as a code owner September 15, 2025 10:25
@github-actions github-actions bot added the doc-required PR must not be merged without tech writer approval. label Sep 15, 2025
@nordicjm nordicjm removed the DNM Do not merge label Sep 22, 2025
@nordicjm
Copy link
Contributor Author

@nvlsianpu @michalek-no please review

Copy link
Contributor

@nvlsianpu nvlsianpu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, although can't build without patching.

Copy link
Contributor

Choose a reason for hiding this comment

The 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,

config BM_BOOTLOADER_MCUBOOT_SIGNATURE_USING_KMU
bool "Use KMU stored keys for signature verification"
depends on SOC_SERIES_NRF54LX
depends on BOOT_SIGNATURE_TYPE_ED25519
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't be depend on BM_BOOTLOADER_MCUBOOT_SIGNATURE_TYPE_ED25519 instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good shout, yes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


config BM_BOOTLOADER_MCUBOOT_GENERATE_DEFAULT_KMU_KEYFILE
bool "Generate default keyfile for provisioning during build"
depends on MCUBOOT_SIGNATURE_USING_KMU
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't be depend on above property?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@nvlsianpu
Copy link
Contributor

nvlsianpu commented Sep 23, 2025

With patches this PR will make provisioning working:

-- runners.nrfutil: Flashing file: /home/anpu/BM/nrf-bm/samples/boot/mcuboot_recovery_entry/build/mcuboot/zephyr/zephyr_signed_softdevice_flash_metadata.hex
-- runners.nrfutil: Provisioning key file: /home/anpu/BM/nrf-bm/samples/boot/mcuboot_recovery_entry/build/keyfile.json
-- runners.nrfutil: Erasing non-volatile memory (ERASEALL)
-- runners.nrfutil: Programming image
-- runners.nrfutil: Verifying image
-- runners.nrfutil: KEY Provision
-- runners.nrfutil: Board(s) with serial number(s) 1057721615 flashed successfully.
-- west flash: using runner nrfutil

althought application isn't booted

*** Booting MCUboot v2.1.0-dev-ecc13ac1b033 ***
*** Using nRF Connect SDK Bare Metal v0.8.99-9bd75658ed8d ***
I: Starting bootloader
E: Error: no bootable configuration found
E: Unable to find bootable image

I've used samples/boot/mcuboot_recovery_entry
@michalek-no Can you help with the issue?

@nordicjm
Copy link
Contributor Author

nordicjm commented Sep 24, 2025

With patches this PR will make provisioning working:

-- runners.nrfutil: Flashing file: /home/anpu/BM/nrf-bm/samples/boot/mcuboot_recovery_entry/build/mcuboot/zephyr/zephyr_signed_softdevice_flash_metadata.hex
-- runners.nrfutil: Provisioning key file: /home/anpu/BM/nrf-bm/samples/boot/mcuboot_recovery_entry/build/keyfile.json
-- runners.nrfutil: Erasing non-volatile memory (ERASEALL)
-- runners.nrfutil: Programming image
-- runners.nrfutil: Verifying image
-- runners.nrfutil: KEY Provision
-- runners.nrfutil: Board(s) with serial number(s) 1057721615 flashed successfully.
-- west flash: using runner nrfutil

althought application isn't booted

*** Booting MCUboot v2.1.0-dev-ecc13ac1b033 ***
*** Using nRF Connect SDK Bare Metal v0.8.99-9bd75658ed8d ***
I: Starting bootloader
E: Error: no bootable configuration found
E: Unable to find bootable image

I've used samples/boot/mcuboot_recovery_entry @michalek-no Can you help with the issue?

It won't boot because it programs UROT key and needs the sdk-mcuboot PR to be usable with the correct slot (think it was BTT or Frank that requested MCUboot use UROT key slots when b0 is not present). Have added manifest update

@NordicBuilder
Copy link

NordicBuilder commented Sep 24, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
nrf nrfconnect/sdk-nrf@b1f505f nrfconnect/sdk-nrf@f0af8f2 nrfconnect/[email protected]

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@nvlsianpu
Copy link
Contributor

nvlsianpu commented Sep 24, 2025

It won't boot because it programs UROT key and needs the sdk-mcuboot PR to be usable with the correct slot (think it was BTT or Frank that requested MCUboot use UROT key slots when b0 is not present). Have added manifest update

No, I checked that we hardcoded sdk-mcuboot to use URTO_PUBKEY.
BTW.: I did testing with both option BL/UROT_PUBKEY.

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The device needs to be provisioned with proper set of keys.
The device needs to be provisioned with the proper set of keys.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

This is now needed by sdk-zephyr

Signed-off-by: Jamie McCrae <[email protected]>
Includes an sdk-mcuboot update to fix the slot IDs for KMU usage

Signed-off-by: Jamie McCrae <[email protected]>
@NordicBuilder NordicBuilder removed the DNM Do not merge label Oct 7, 2025
slot0_partition: partition@a000 {
label = "slot0";
reg = <0x0000b000 DT_SIZE_K(282)>;
reg = <0x000a000 DT_SIZE_K(286)>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The board yaml files must be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@eivindj-nordic
Copy link
Contributor

Changelog entry?

@eivindj-nordic
Copy link
Contributor

eivindj-nordic commented Oct 8, 2025

What about the non-MCUboot board variants?
Never mind...

@nordicjm nordicjm force-pushed the kmuprovision branch 2 times, most recently from c555c2a to 0ac9ddd Compare October 9, 2025 06:32
.. _ug_bootloader_keys_using:

Using a key in a project
------------------------
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please change this and previous header underlines to asterisks (except for the main title of course)

Suggested change
------------------------
*************************

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Allows usage of KMU in MCUboot for the signature verification and
copies the KMU provisioning script from NCS with changes for BM

Signed-off-by: Jamie McCrae <[email protected]>
Enables storing the key in KMU. This means existing images from
previous versions of BM are not compatible with the new
configuration and must be manually changed to be compatile by using
the built-in key instead, but KMU offers much greater protection of
the key data and enhances security

Signed-off-by: Jamie McCrae <[email protected]>
Adds a non-KMU (built-in key) build of this sample, which
used to be the default in previous versions of BM

Signed-off-by: Jamie McCrae <[email protected]>
Adds a section on how to use the KMU

Signed-off-by: Jamie McCrae <[email protected]>
Disables some options including system clock support for MCUboot
to reduce the size of the application as they are not needed

Signed-off-by: Jamie McCrae <[email protected]>
Due to optimisations applied to MCUboot configuration, the size of
the partition can be reduced to 31KiB which allows memory protection
to be applied to the section using a single protection region, and
even with logs enabled there is still spare space available in the
slot

Signed-off-by: Jamie McCrae <[email protected]>
The minimum sizes for release builds are now smaller

Signed-off-by: Jamie McCrae <[email protected]>
Adds the recent changes to DFU to the documentation

Signed-off-by: Jamie McCrae <[email protected]>
@eivindj-nordic eivindj-nordic merged commit fe98516 into nrfconnect:main Oct 9, 2025
10 checks passed
@nordicjm nordicjm deleted the kmuprovision branch October 13, 2025 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. doc-required PR must not be merged without tech writer approval. manifest manifest-nrf

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants