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

You can find the documentation preview for this PR here.

@nordicjm nordicjm requested review from a team as code owners 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

@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.

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

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

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

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@693f67d nrfconnect/sdk-nrf#24511 nrfconnect/sdk-nrf#24511/files

DNM label due to: 1 project with PR revision

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

@nvlsianpu
Copy link

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.

};

slot0_partition: partition@b000 {
slot0_partition: partition@9c00 {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not able to boot the application with this partition address. If I change the address to 0xa000 it starts fine.

I think the problem is that 0x9c00 is not 2KiB aligned. So assuming an image header of 2KiB, the interrupt table at the start of application is not properly aligned.

Same for L05 and L10.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah that might explain a problem then, I must have not rebuild and ran after reducing the sizes, will fix

*************************

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.
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
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.
In order to boot images when the KMU feature is enabled, the MCUboot signing key must be programmed to the KMU prior to loading the firmware or the device will be unable to boot.

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]>
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]>
Adds a KMU build of this sample

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]>
};

slot0_partition: partition@b000 {
/* Area from 0x9c00 to 0xa000 is unused due to alignment */
Copy link
Contributor

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?

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. DNM Do not merge 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.

7 participants