Skip to content
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

scripts: Update ncs-provision west command to use nrfutil for uploading keys #20172

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fundakol
Copy link
Contributor

@fundakol fundakol commented Feb 4, 2025

nrfutil provides a command to upload public keys to KMU. This PR replaces nrfprovision script with nrfutil in west ncs-provision command .

Example usage:

west ncs-provision upload --soc nrf54l15 --key ./bootloader/mcuboot/root-ed25519.pem --dev-id 1057748769

Additional options:

  • --dry-run - generate JSON keyfile without executing upload
  • --build-dir=Path - path where keyfile will be saved
  • --input=Path - path to a YAML file with list of keys to upload, example:
    - keyname: UROT_PUBKEY
      keys: ["private_key1.pem"]
      policy: lock
    - keyname: APP_PUBKEY
      keys: ["private_key2.pem"]
      policy: lock

To write some unit tests for this module
it has to be importable.

Signed-off-by: Lukasz Fundakowski <[email protected]>
@NordicBuilder
Copy link
Contributor

NordicBuilder commented Feb 4, 2025

CI Information

To view the history of this post, clich the 'edited' button above
Build number: 9

Inputs:

Sources:

more details

Github labels

Enabled Name Description
ci-disabled Disable the ci execution
ci-all-test Run all of ci, no test spec filtering will be done
ci-force-downstream Force execution of downstream even if twister fails
ci-run-twister Force run twister
ci-run-zephyr-twister Force run zephyr twister
List of changed files detected by CI (0)

Outputs:

Toolchain

Version:
Build docker image:

Test Spec & Results: ✅ Success; ❌ Failure; 🟠 Queued; 🟡 Progress; ◻️ Skipped; ⚠️ Quarantine

  • ❌ Toolchain
  • ❌ Build twister
  • ❌ Integration tests

Note: This message is automatically posted and updated by the CI

@fundakol fundakol force-pushed the nrf-provision-move-to-nrfutil branch 5 times, most recently from 1882474 to e16136e Compare February 5, 2025 12:30
@fundakol fundakol force-pushed the nrf-provision-move-to-nrfutil branch 2 times, most recently from fd67dac to 0b841db Compare February 6, 2025 08:24
nrfutil provides a command to upload public keys to KMU.
West ncs-provision command should use nrfutil instead of
nrfprovision python library.

Signed-off-by: Lukasz Fundakowski <[email protected]>
@fundakol fundakol force-pushed the nrf-provision-move-to-nrfutil branch from 0b841db to 37c0b83 Compare February 6, 2025 10:18
Copy link
Contributor

@gchwier gchwier left a comment

Choose a reason for hiding this comment

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

I've run our internal tests on that PR and surprisingly all tests passed.
Version of nrfutil device on the CI is 2.7.8 (I thought that in 2.7.13 KMU keys provissioning was added to nrfutil).
I've checked it locally, and it is working also on nrfutil 2.7.8

nrfutil install --force device=2.7.8
nrfutil device x-provision-nrf54l-keys --key-file /tmp/nrfutil_22pv6_t3/keyfile.json --verify --serial-number xxx

to run with Twister:

$ZEPHYR_BASE/scripts/twister -T tests/subsys/kmu/hello_for_kmu --device-testing --hardware-map hardware_map.yml --west-flash=--recover -vv --no-clean -s mcuboot.kmu.west.provision.default_key --pytest-args='-k test_kmu_use_key_from_config'

where command:

west ncs-provision upload --soc nrf54l15 --key /home/grch/ncs/bootloader/mcuboot/root-ed25519.pem --dev-id 001057755847

is called to provision KMU keys.

Scripts looks OK, and if nrfutil supports KMU keys provisioning in 2.7.8 version, it can be integrated (should not fail any regression tests)

Dependency to nrfprovision package can be removed from requirements-extra.txt and from kmu_provision.rst:
https://github.com/nrfconnect/sdk-nrf/blob/main/doc/nrf/app_dev/device_guides/nrf54l/kmu_provision.rst#L20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants