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: hid_configurator: Support pure ED25519 signature #19238

Merged
merged 1 commit into from
Dec 4, 2024

Conversation

MarekPieta
Copy link
Contributor

Change adds support for pure ED25519 signature (used by nRF54L based devices that enable MCUboot hardware cryptography). imgtool from MCUboot upstream repository does not support this configuration, a dedicated imgtool version from sdk-mcuboot repository must be used.

Jira: NCSDK-30745

@MarekPieta MarekPieta added this to the 2.9.0 milestone Dec 4, 2024
@MarekPieta MarekPieta requested review from a team as code owners December 4, 2024 08:18
@github-actions github-actions bot added the doc-required PR must not be merged without tech writer approval. label Dec 4, 2024
@NordicBuilder
Copy link
Contributor

NordicBuilder commented Dec 4, 2024

CI Information

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

Inputs:

Sources:

sdk-nrf: PR head: 275c003822ce9d5d9a9930f3cef0807f41a1f26b

more details

sdk-nrf:

PR head: 275c003822ce9d5d9a9930f3cef0807f41a1f26b
merge base: cf777d12ccf26adb208b7d63fa157b7bb243d1dd
target head (main): 584e1c85cd2f058ee69b802bfd913b823e315b2c
Diff

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 (2)
scripts
│  ├── hid_configurator
│  │  ├── README.rst
│  │  ├── modules
│  │  │  │ dfu.py

Outputs:

Toolchain

Version: b77d8c1312
Build docker image: docker-dtr.nordicsemi.no/sw-production/ncs-build:b77d8c1312_912848a074

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

  • ◻️ Toolchain - Skipped: existing toolchain is used
  • ✅ Build twister
    • sdk-nrf test count: 87
  • ✅ Integration tests
    • ✅ desktop52_verification
Disabled integration tests
    • doc-internal
    • test_ble_nrf_config
    • test-fw-nrfconnect-apps
    • test-fw-nrfconnect-ble_mesh
    • test-fw-nrfconnect-ble_samples
    • test-fw-nrfconnect-boot
    • test-fw-nrfconnect-chip
    • test-fw-nrfconnect-fem
    • test-fw-nrfconnect-nfc
    • test-fw-nrfconnect-nrf-iot_libmodem-nrf
    • test-fw-nrfconnect-nrf-iot_lwm2m
    • test-fw-nrfconnect-nrf-iot_mosh
    • test-fw-nrfconnect-nrf-iot_nrf_provisioning
    • test-fw-nrfconnect-nrf-iot_positioning
    • test-fw-nrfconnect-nrf-iot_samples
    • test-fw-nrfconnect-nrf-iot_serial_lte_modem
    • test-fw-nrfconnect-nrf-iot_thingy91
    • test-fw-nrfconnect-nrf-iot_zephyr_lwm2m
    • test-fw-nrfconnect-nrf_crypto
    • test-fw-nrfconnect-ps
    • test-fw-nrfconnect-rpc
    • test-fw-nrfconnect-rs
    • test-fw-nrfconnect-tfm
    • test-fw-nrfconnect-thread
    • test-fw-nrfconnect-zigbee
    • test-low-level
    • test-sdk-audio
    • test-sdk-dfu
    • test-sdk-find-my
    • test-sdk-mcuboot
    • test-sdk-pmic-samples
    • test-sdk-sidewalk
    • test-sdk-wifi
    • test-secdom-samples-public

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

@NordicBuilder
Copy link
Contributor

You can find the documentation preview for this PR at this link. It will be updated about 10 minutes after the documentation build succeeds.

Note: This comment is automatically posted by the Documentation Publish GitHub Action.

Comment on lines +100 to +104
.. parsed-literal::
:class: highlight

py -3 -m pip install -r requirements.txt
py -3 -m pip install .
Copy link
Contributor

Choose a reason for hiding this comment

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

not that I know about python but why can't it do as the build system does and use the in-tree version until a proper updated version is released? See https://github.com/nrfconnect/sdk-nrf/blob/main/cmake/sysbuild/image_signing.cmake#L52

Copy link
Contributor Author

@MarekPieta MarekPieta Dec 4, 2024

Choose a reason for hiding this comment

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

This step actually installs the in-tree version of imgtool instead of version from PyPI. Python script by itself has no knowledge where sdk-mcuboot repository sources are on host computer - that's why I decided to install proper imgtool through pip. HID configurator scripts could be moved, so using a relative path might be problematic too.

Copy link
Contributor

@kapi-no kapi-no Dec 4, 2024

Choose a reason for hiding this comment

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

The user should already have the correct version if they follow the NCS installation guide correctly. We could minimize this note and notify the user to double-check if they have the correct version of imgtool.

We can also add a reference to the NCS install documentation that covers how to install this tool:

https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/installation/install_ncs.html#system-wide_installation
(Step 4)

Copy link
Contributor

Choose a reason for hiding this comment

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

Which people should not be doing, the toolchain comes with a specific version of the tool, sure it's not the version that includes this but this will then pollute the version used by the toolchain going forward? Have asked some others if there is a better way of doing this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The nRF54L MCuboot's pure ED25519 signature requires custom imgtool version (not from PyPI; needs to be installed from source using sdk-mcuboot repo). Unless I missed something, the custom imgtool version is not installed together with our official toolchain. I am not sure if there is better way of using the custom imgtool in this context than manually installing from source (as currently suggested). Please propose alternative solutions if anything better comes to your mind.

I hope that this is only a temporary workaround and could be removed when mcu-tools/mcuboot#2063 is introduced to imgtool from PyPI. @de-nordic and @nvlsianpu, do you think there is a better way of doing it for now?

Copy link
Contributor

Choose a reason for hiding this comment

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

See how it is done e.g.

doc/internal/conf.py:sys.path.insert(0, str(NRF_BASE / "doc" / "_utils"))
doc/internal/conf.py:sys.path.insert(0, str(ZEPHYR_BASE / "doc" / "_extensions"))
doc/internal/conf.py:sys.path.insert(0, str(NRF_BASE / "doc" / "_extensions"))
doc/kconfig/conf.py:sys.path.insert(0, str(NRF_BASE / "doc" / "_utils"))
doc/kconfig/conf.py:sys.path.insert(0, str(ZEPHYR_BASE / "doc" / "_extensions"))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then we need to know NRF_BASE/ZEPHYR_BASE in scope of the script (it might become problematic e.g. if someone would like to use script outside of the nRF Connect SDK as a standalone tool). Also, the sdk-mcuboot's imgtool's scripts would need to be located in a known place.

Please keep in mind that we use use image class exposed by the imgtool package (we do not call imgtool through CLI). Because of that, IMHO relying on packages might be cleaner approach - we build a SUIT-related package from source and install it manually already too.

Also please keep in mind that targets other than nRF54L do not use pure ED25519 signature, so they may still rely on the default imgtool version (extra step from the note could be basically skipped). Maybe we could explicitly comment on that and stick with using package built from source as a temporary workaround (we will use imgtool from PyPI as soon as it starts supporting the pure signature)?

Copy link
Contributor

Choose a reason for hiding this comment

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

@MarekPieta , I don't see @nordicjm blocking the change. I value input from various reviewers but this area is not his responsibility. Please keep that in mind.

I personally think that provided toolchain should cover all things needed. If it does not we should request it from team responsible for toolchain - check if we or pluto have a ticket. In the end this tool is not only our problem.

Since the timing is short I expect having the workaround is valid. It will require user interaction and is part of nrf_desktop tools doc only.

Copy link

@fundakol fundakol Dec 4, 2024

Choose a reason for hiding this comment

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

@MarekPieta, @nordicjm, command pip install . just installs Python's package from a source code, if that is what you want it is fine for me. I would only add a link to the repository where is imgtool (I don't see it in the readme file, and user may not know how to find it).

Also you can install directly from a git repository like so:
pip install git+ssh://[email protected]/myuser/foo.git@branch_or_tag#subdirectory=stackoverflow
Which could be more convenient for users.

Another thing, command like this could be more precise:

python -m pip install path/to/SomeProject

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I provided source directory path starting from nRF Connect SDK root directory (should be straightforward to find it for an NCS user). I do not provide a complete path in command here as I cannot provide absolute path and relative path might change in case user moves HID configurator scripts locally. Would this approach be ok?

@MarekPieta MarekPieta force-pushed the hid_configurator_nrf54l_fix branch from cba5d47 to f8b2a38 Compare December 4, 2024 10:07
Comment on lines +100 to +104
.. parsed-literal::
:class: highlight

py -3 -m pip install -r requirements.txt
py -3 -m pip install .
Copy link
Contributor

@kapi-no kapi-no Dec 4, 2024

Choose a reason for hiding this comment

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

The user should already have the correct version if they follow the NCS installation guide correctly. We could minimize this note and notify the user to double-check if they have the correct version of imgtool.

We can also add a reference to the NCS install documentation that covers how to install this tool:

https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/installation/install_ncs.html#system-wide_installation
(Step 4)

scripts/hid_configurator/modules/dfu.py Show resolved Hide resolved
@MarekPieta MarekPieta requested a review from fundakol December 4, 2024 12:27
Comment on lines +100 to +104
.. parsed-literal::
:class: highlight

py -3 -m pip install -r requirements.txt
py -3 -m pip install .
Copy link
Contributor

Choose a reason for hiding this comment

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

@MarekPieta , I don't see @nordicjm blocking the change. I value input from various reviewers but this area is not his responsibility. Please keep that in mind.

I personally think that provided toolchain should cover all things needed. If it does not we should request it from team responsible for toolchain - check if we or pluto have a ticket. In the end this tool is not only our problem.

Since the timing is short I expect having the workaround is valid. It will require user interaction and is part of nrf_desktop tools doc only.

@MarekPieta MarekPieta force-pushed the hid_configurator_nrf54l_fix branch from f8b2a38 to c7f1b9a Compare December 4, 2024 14:54
@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 Dec 4, 2024
@MarekPieta MarekPieta removed the changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. label Dec 4, 2024
peknis
peknis previously requested changes Dec 4, 2024
scripts/hid_configurator/README.rst Outdated Show resolved Hide resolved
scripts/hid_configurator/README.rst Outdated Show resolved Hide resolved
scripts/hid_configurator/README.rst Outdated Show resolved Hide resolved
scripts/hid_configurator/README.rst Outdated Show resolved Hide resolved
@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 Dec 4, 2024
@MarekPieta MarekPieta force-pushed the hid_configurator_nrf54l_fix branch from 1c1876a to 5cc3f5c Compare December 4, 2024 15:29
@MarekPieta MarekPieta requested a review from peknis December 4, 2024 15:29
@MarekPieta MarekPieta removed the changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. label Dec 4, 2024
@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 Dec 4, 2024
@MarekPieta MarekPieta removed the changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. label Dec 4, 2024
scripts/hid_configurator/README.rst Outdated Show resolved Hide resolved
scripts/hid_configurator/README.rst Outdated Show resolved Hide resolved
scripts/hid_configurator/README.rst Outdated Show resolved Hide resolved
@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 Dec 4, 2024
Change adds support for pure ED25519 signature (used by nRF54L-based
devices that enable MCUboot hardware cryptography). imgtool from MCUboot
upstream repository does not support this configuration, a dedicated
imgtool version from sdk-mcuboot repository must be used.

Jira: NCSDK-30745

Signed-off-by: Marek Pieta <[email protected]>
Signed-off-by: Pekka Niskanen <[email protected]>
Signed-off-by: Divya Pillai <[email protected]>
@MarekPieta MarekPieta force-pushed the hid_configurator_nrf54l_fix branch from 979b951 to 275c003 Compare December 4, 2024 15:55
@carlescufi carlescufi merged commit 6f444f7 into nrfconnect:main Dec 4, 2024
13 checks passed
@MarekPieta MarekPieta deleted the hid_configurator_nrf54l_fix branch December 4, 2024 23:20
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants