Skip to content

Conversation

@ahasztag
Copy link
Contributor

This commit fixes a couple of issues regarding B0 and MCUBoot region protection for nRF54L. It also adds some tests verifying that the issues are no longer present.

Also, support for region and BOOTCONF protection is added for nRF54LM20 and nRF54LV10 platforms.

Note: due nRF54LM20 and nRF54LV10 devices being shipped in the TEST mode, the BOOTCONF configuration is not copied to the appropriate REGION[n].CONFIG register and is not automatically applied at startup.
Thus, the BOOTCONF configuration does not work with the shipped devices. However, all the code needed for
that is present.

@ahasztag ahasztag requested review from a team as code owners October 14, 2025 11:22
@NordicBuilder NordicBuilder added manifest changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. labels Oct 14, 2025
@NordicBuilder
Copy link
Contributor

NordicBuilder commented Oct 14, 2025

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

Name Old Revision New Revision Diff
mcuboot nrfconnect/sdk-mcuboot@92b8fd3 nrfconnect/sdk-mcuboot@697ca33 (main) nrfconnect/[email protected]

All manifest checks OK

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

@NordicBuilder
Copy link
Contributor

NordicBuilder commented Oct 14, 2025

CI Information

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

Inputs:

Sources:

sdk-nrf: PR head: 83929910bfe1e246ca5ac0cf5e48cb044954c928
mcuboot: PR head: 6fb2bab3b609b31910af897f36879f3aaaa54067

more details

sdk-nrf:

PR head: 83929910bfe1e246ca5ac0cf5e48cb044954c928
merge base: be08637aa6961388fbe8e80ec936356fb71c6dde
target head (main): fcef5e5a116c6df850a7c021239e3230e4ceb260
Diff

mcuboot:

PR head: 6fb2bab3b609b31910af897f36879f3aaaa54067
merge base: 92b8fd3308f968da0143cbee1d6bb2cfa440f73b
target head (main): 92b8fd3308f968da0143cbee1d6bb2cfa440f73b
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 (16)
bootloader
│  ├── mcuboot
│  │  ├── boot
│  │  │  ├── zephyr
│  │  │  │  ├── Kconfig
│  │  │  │  │ main.c
cmake
│  ├── sysbuild
│  │  │ bootconf.cmake
scripts
│  │ reglock.py
subsys
│  ├── bootloader
│  │  ├── Kconfig
│  │  ├── bl_boot
│  │  │  │ bl_boot.c
sysbuild
│  │ Kconfig.secureboot
tests
│  ├── subsys
│  │  ├── bootloader
│  │  │  ├── b0_lock_rwx
│  │  │  │  ├── Kconfig
│  │  │  │  ├── modules
│  │  │  │  │  ├── run_from_s1
│  │  │  │  │  │  ├── zephyr
│  │  │  │  │  │  │  ├── CMakeLists.txt
│  │  │  │  │  │  │  ├── Kconfig
│  │  │  │  │  │  │  ├── module.yml
│  │  │  │  │  │  │  ├── src
│  │  │  │  │  │  │  │  │ run_from_s1.c
│  │  │  │  ├── src
│  │  │  │  │  │ main.c
│  │  │  │  ├── sysbuild.cmake
│  │  │  │  │ testcase.yaml
west.yml

Outputs:

Toolchain

Version: 46667c6630
Build docker image: docker-dtr.nordicsemi.no/sw-production/ncs-build:46667c6630_bba2ea5f2e

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-apps - Error: Error starting job: null
    • ❌ test_ble_nrf_config - Error: Error starting job: null
    • ❌ test-fw-nrfconnect-ble_mesh - Error: Error starting job: null
    • ❌ test-fw-nrfconnect-ble_samples - Error: Error starting job: null
    • ✅ test-fw-nrfconnect-chip
    • ❌ test-fw-nrfconnect-nfc - Error: Error starting job: null
    • ❌ 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 - Error: Error starting job: null
    • ❌ test-fw-nrfconnect-nrf-iot_thingy91 - Error: Error starting job: null
    • ❌ test-fw-nrfconnect-nrf_crypto - Error: Error starting job: null
    • ✅ test-fw-nrfconnect-proprietary_esb
    • ✅ test-fw-nrfconnect-rpc
    • ✅ test-fw-nrfconnect-rs
    • ✅ test-fw-nrfconnect-fem
    • ❌ test-fw-nrfconnect-tfm - Error: Error starting job: null
    • ✅ test-fw-nrfconnect-thread-main
    • ✅ test-sdk-find-my
    • ❌ test-sdk-wifi
    • ✅ test-low-level
    • ✅ test-sdk-pmic-samples
    • ❌ test-sdk-mcuboot - Error: Error starting job: null
    • ❌ test-sdk-dfu - Error: Error starting job: null
    • ✅ test-fw-nrfconnect-ps-main
    • ✅ test-secdom-samples-public
    • ⚠️ test-fw-nrfconnect-nrf-iot_cloud

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

@github-actions
Copy link

You can find the documentation preview for this PR here.

@NordicBuilder
Copy link
Contributor

NordicBuilder commented Oct 14, 2025

Memory footprint analysis revealed the following potential issues

applications.hpf.gpio.icmsg[nrf54l15dk/nrf54l15/cpuflpr]: High RAM usage: 9102[B] - link (cc: @nrfconnect/ncs-ll-ursus)
applications.hpf.gpio.icmsg[nrf54l15dk/nrf54l15/cpuflpr]: High ROM usage: 5858[B] - link (cc: @nrfconnect/ncs-ll-ursus)
applications.hpf.gpio.icbmsg[nrf54l15dk/nrf54l15/cpuflpr]: High RAM usage: 12744[B] - link (cc: @nrfconnect/ncs-ll-ursus)
applications.hpf.gpio.icbmsg[nrf54l15dk/nrf54l15/cpuflpr]: High ROM usage: 9492[B] - link (cc: @nrfconnect/ncs-ll-ursus)

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

@nordicjm
Copy link
Contributor

when opening PRs in e.g. sdk-mcuboot and you are creating your own manifest PR, use the skip manifest PR tag so it doesn't create duplicate #25024 manifest updates which wastes CI resources

{
printk("Region %d\n", RRAMC_REGION_FOR_TEST);
uint32_t protected_end_address = 1024 * config.size_kb;
uint32_t protected_end_address = config.address + (1024 * config.size_kb);
volatile uint32_t *unprotected_word = (volatile uint32_t *)protected_end_address;
volatile uint32_t *protected_word =
(volatile uint32_t *)protected_end_address - sizeof(uint32_t);
Copy link
Contributor

Choose a reason for hiding this comment

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

additional check? something like that:

uint32_t tmp = nrf_rramc_region_config_raw_get(NRF_RRAMC, RRAMC_REGION_FOR_TEST);
.
.
.
zassert_equal(nrf_rramc_region_config_raw_get(NRF_RRAMC, RRAMC_REGION_FOR_TEST) !=
tmp, "error, managed to change permissions")

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 idea, added

@ahasztag ahasztag force-pushed the NCSDK-35695_bootconf_n54lm_lv_adjustments branch from f5f8868 to bff6074 Compare October 16, 2025 06:55
@NordicBuilder NordicBuilder requested review from a team October 16, 2025 06:55
@ahasztag ahasztag force-pushed the NCSDK-35695_bootconf_n54lm_lv_adjustments branch from bff6074 to 2545db6 Compare October 16, 2025 10:34
@NordicBuilder NordicBuilder requested a review from a team October 16, 2025 10:34
if soc not in ["nrf54ls05b"]:
value |= SECURE

size = size // 1024
Copy link
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Contributor

Choose a reason for hiding this comment

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

was there before (Artur just moved that line).
Can we have a comment or better a constant dewfinition?

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've changed one of the variable names to size_kb - maybe this will clear things out. I do not see a point of defining a constant for 1024

Comment on lines +63 to +67
/* Note: the protection is only applied to the image itself, not the header (pad).
* When building with MCUBoot, applying protection to the header is not needed, as the
* header is only used during DFU and is only left for compatibility. Without MCUBoot, the
* header is not present.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

so doesn't that theoretically mean there is a possible attacker entry point if there is some data they can put in this completely unprotected location that causes MCUboot to do something undefined?

Copy link
Contributor

@nvlsianpu nvlsianpu Oct 17, 2025

Choose a reason for hiding this comment

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

So, looked into ./cmake/sysbuild/sign.cmake, I saw that material for signature is has over built binary(like set(slot_hex ${${slot}_image_dir}/zephyr/${${slot}_kernel_name}.hex), which doesn't contains this area.
For NSIB is waisted area. Active MCUboot instance doesn't parse it as well.

Copy link
Contributor Author

@ahasztag ahasztag Oct 20, 2025

Choose a reason for hiding this comment

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

To be clear: this is NOT something introduced by this PR, it was already there, this PR only adds a comment which only explains why it is not a great concern and why we do not need to fix it immediately.
This will be solved soon, we plan to remove the s0_pad/s1_pad for the NSIB+MCUBoot configuration - the issue will be non-existent then.

cmake_minimum_required(VERSION 3.20.0)

if (CONFIG_TEST_B0_LOCK_USE_S1)

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

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


zephyr_library()
zephyr_library_sources(src/run_from_s1.c)

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

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

Comment on lines 11 to 12
zephyr_library()
zephyr_library_sources(src/run_from_s1.c)
Copy link
Contributor

Choose a reason for hiding this comment

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

cmake indent is 2 spaces

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@carlescufi can you please enable some automatic check for it?


cmake_minimum_required(VERSION 3.20.0)

if (CONFIG_TEST_B0_LOCK_USE_S1)
Copy link
Contributor

Choose a reason for hiding this comment

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

there's also no spaces between if and brackets in cmake... I have your name firmly in my mind because I'm pretty sure I've told you all of this many times now and I'm still seeing it in PRs

Copy link
Contributor Author

@ahasztag ahasztag Oct 20, 2025

Choose a reason for hiding this comment

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

I'm not doing this on purpose, my brain keeps ignoring these spaces.
I've actually tried to ask AI locally to create a script to detect such mistakes, but it turned out to be no good. A script for detecting such changes would be useful. I'll try to be more careful next time and improve my personal script

Copy link
Contributor

Choose a reason for hiding this comment

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

@carlescufi can you please enable some automatic check for it?

Copy link
Contributor

Choose a reason for hiding this comment

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

@nordicjm can you please point out written rules describing it?

Copy link
Contributor

Choose a reason for hiding this comment

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

@maciejpietras yes, I think this is ongoing upstream, so I will follow-up.
Regarding the rules, they are here:
https://docs.zephyrproject.org/latest/contribute/style/cmake.html
or, more in general, you can find them all here:
https://docs.zephyrproject.org/latest/contribute/style/index.html

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 news, I am aware of this rule, however single spaces are easy to miss, especially due to the reflex out of C, where the space is present, an automatic check would be of great help

Copy link
Contributor

@maciejpietras maciejpietras Oct 31, 2025

Choose a reason for hiding this comment

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

@carlescufi @nordicjm while contributors shall follow the contributor guideline I will appreciate following reviewers rules as well https://github.com/zephyrproject-rtos/zephyr/blob/main/CODE_OF_CONDUCT.md e.g.

  • _Demonstrating empathy and kindness toward other people
  • Being respectful of differing opinions, viewpoints, and experiences
  • Giving and gracefully accepting constructive feedback
  • Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience_

if soc not in ["nrf54ls05b"]:
value |= SECURE

size = size // 1024
Copy link
Contributor

Choose a reason for hiding this comment

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

was there before (Artur just moved that line).
Can we have a comment or better a constant dewfinition?

Comment on lines +63 to +67
/* Note: the protection is only applied to the image itself, not the header (pad).
* When building with MCUBoot, applying protection to the header is not needed, as the
* header is only used during DFU and is only left for compatibility. Without MCUBoot, the
* header is not present.
*/
Copy link
Contributor

@nvlsianpu nvlsianpu Oct 17, 2025

Choose a reason for hiding this comment

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

So, looked into ./cmake/sysbuild/sign.cmake, I saw that material for signature is has over built binary(like set(slot_hex ${${slot}_image_dir}/zephyr/${${slot}_kernel_name}.hex), which doesn't contains this area.
For NSIB is waisted area. Active MCUboot instance doesn't parse it as well.

@ahasztag ahasztag force-pushed the NCSDK-35695_bootconf_n54lm_lv_adjustments branch from 2545db6 to a860fda Compare October 20, 2025 07:36
@NordicBuilder NordicBuilder requested review from a team October 20, 2025 07:36
@NordicBuilder NordicBuilder requested a review from a team October 20, 2025 07:36
@ahasztag ahasztag force-pushed the NCSDK-35695_bootconf_n54lm_lv_adjustments branch from a860fda to ea429ae Compare October 20, 2025 07:39
@ahasztag ahasztag requested a review from nordicjm October 20, 2025 07:46
@ahasztag ahasztag force-pushed the NCSDK-35695_bootconf_n54lm_lv_adjustments branch from ea429ae to 8392991 Compare October 21, 2025 07:39
This commit fixes a couple of issues regarding B0 and
MCUBoot region protection for nRF54L. It also adds some tests
verifying that the issues are no longer present.

Also, support for region and BOOTCONF protection is added for
nRF54LM20 and nRF54LV10 platforms.

Note: due nRF54LM20 and nRF54LV10 devices being shipped
in the TEST mode, the BOOTCONF configuration is not copied
to the appropriate REGION[n].CONFIG register and is not
automatically applied at startup.
Thus, the BOOTCONF configuration does not work with the
shipped devices. However, all the code needed for
that is present.

Signed-off-by: Artur Hadasz <[email protected]>
@ahasztag ahasztag force-pushed the NCSDK-35695_bootconf_n54lm_lv_adjustments branch from 8392991 to 3f5bf0f Compare October 21, 2025 09:46
@NordicBuilder NordicBuilder requested review from a team October 21, 2025 09:47
@NordicBuilder NordicBuilder removed the DNM label Oct 21, 2025
@tomchy tomchy merged commit acf5d75 into nrfconnect:main Oct 21, 2025
23 of 24 checks passed
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. manifest manifest-mcuboot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants