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

cmake: sysbuild: Fix image signing alignment not using write size #18888

Merged
merged 1 commit into from
Nov 15, 2024

Conversation

nordicjm
Copy link
Contributor

@nordicjm nordicjm commented Nov 14, 2024

Fixes an issue whereby the alignment was fixed to 4 bytes and not taken from DTS where the write block size alignment is stored

ref.: NCSDK-30263

Fixes an issue whereby the alignment was fixed to 4 bytes and not
taken from DTS where the write block size alignment is stored

Signed-off-by: Jamie McCrae <[email protected]>
@nordicjm nordicjm requested a review from a team as a code owner November 14, 2024 10:42
@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 Nov 14, 2024
@NordicBuilder
Copy link
Contributor

NordicBuilder commented Nov 14, 2024

CI Information

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

Inputs:

Sources:

sdk-nrf: PR head: cdc5d0ee9abfda2d1c9b14715a9ee78e74957435

more details

sdk-nrf:

PR head: cdc5d0ee9abfda2d1c9b14715a9ee78e74957435
merge base: b1cd30327a9145c0742a7c128b42916327daeed4
target head (main): d839e3cda69a64e0f3de12cea337aef824512bcb
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 (4)
cmake
│  ├── sysbuild
│  │  ├── image_signing.cmake
│  │  ├── image_signing_firmware_loader.cmake
│  │  ├── image_signing_nrf700x.cmake
│  │  │ image_signing_split.cmake

Outputs:

Toolchain

Version: f51bdba1d9
Build docker image: docker-dtr.nordicsemi.no/sw-production/ncs-build:f51bdba1d9_912848a074

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

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

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

Comment on lines +83 to +86
if(NOT write_block_size)
set(write_block_size 4)
message(WARNING "slot0_partition write block size devicetree parameter is missing, assuming write block size is 4")
endif()
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO this should not be done this way.
This should be MCUboot Kconfig option that is either set by SoC configuration Kconfg and the SoC Kconfig may pick that from DTS controller, eventually.
Directly poking at DTS here crosses through module boundaries and entangles, directly, imgtool invocation with DTS definition of Flash partition/controller, and that definitions should belong to driver only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

MCUboot does the exact same thing here: https://github.com/mcu-tools/mcuboot/blob/main/boot/zephyr/CMakeLists.txt#L417 it is a hardware property, it should not be in Kconfig. Now there is a problem with devices that have variable sector(/erase) sizes and that can't be represented in dts, in fact I don't really see a way of supporting them

Copy link
Contributor

Choose a reason for hiding this comment

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

I know there is precedence for that, and I do not like it either. MCUboot is poking at something that does not belong to it, that is hardware property for a driver not a software stack above it.
This injects property of a subsystem into a driver and makes it impossible to independently modify driver without affecting system.
This is one of Flash problems in Zephyr that it is not accessed via common interface but rather through directly poking at internals, and gets impossible to move forward because patterns are repeated and suddenly every device has to have write-block-size or erase-block-size, because other subsystems expect it, even though these can vary at run-time (like in STM32 device, where write block size may change with voltage level applied to device).
Alignment here is a software property, not a hardware property. You can set here N * write-block-size (N is int > 1)) of a device and it will work; the hardware property is here constrain for software.

@NordicBuilder
Copy link
Contributor

Memory footprint analysis revealed the following potential issues

sample.matter.template.release[nrf7002dk/nrf5340/cpuapp]: High ROM usage: 811902[B] - link (cc: @kkasperczyk-no @ArekBalysNordic @markaj-nordic)

Note: This message is automatically posted and updated by the CI (latest/sdk-nrf/PR-18888/1)

Copy link
Contributor

@de-nordic de-nordic left a comment

Choose a reason for hiding this comment

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

OK, fixes the problem, but I still believe that we should fix that in Zephyr, by addressing the https://github.com/nrfconnect/sdk-nrf/pull/18888/files#r1842078803, and bring it in.
ACK as is.

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.

tested quarantined scenarios from test-sdk-mcuboot CI (mcuboot.direct_xip.with_revert), fix works

@nordicjm nordicjm added backport v2.8-branch auto-create a PR with same commits to v2.8-branch and removed changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. labels Nov 15, 2024
@nordicjm nordicjm merged commit ff0e8fa into nrfconnect:main Nov 15, 2024
16 checks passed
@nordicjm nordicjm deleted the fixmcusigningalignment branch November 19, 2024 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport v2.8-branch auto-create a PR with same commits to v2.8-branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants