Skip to content

Conversation

@tomchy
Copy link
Contributor

@tomchy tomchy commented Dec 8, 2025

The FW loader reports and manages exactly two slots:

  • slot 0: this is the slot for the application code to update
  • slot 1: this is the slot, in which the FW loader is placed

The slot 1 is reported, so tools can fetch metadata about the FW loader installed on the device.
Unfortunately, currently SMP-based FW loader allows to issue slot erase command for the slot 1, effectively erasing the FW loader code that is being executed.

This change correctly identifies the slot 1 as an active one, marking it as used and blocking erase operation on that slot.

Ref: NCSDK-36684

Copilot AI review requested due to automatic review settings December 8, 2025 16:17
@tomchy tomchy requested review from a team as code owners December 8, 2025 16:17
@tomchy tomchy added this to the 3.2.0 milestone Dec 8, 2025
@NordicBuilder NordicBuilder added manifest changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. labels Dec 8, 2025
@tomchy tomchy added bugfix Fixes a known bug backport v3.2-branch and removed manifest changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. labels Dec 8, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR prevents the firmware loader from erasing itself by correctly identifying its own slot (slot 1) as active and in-use. Previously, the firmware loader would allow erase commands on slot 1, which would destroy the running firmware loader code.

  • Removes the early return that always reported slot 1 as unused in firmware updater mode
  • Adds CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER to the conditional logic that determines if a slot is in use
  • Updates the Zephyr revision to incorporate related changes

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
west.yml Updates Zephyr revision to pull/3617/head to integrate upstream changes
subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c Fixes slot-in-use detection for firmware updater mode by restructuring preprocessor conditionals

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@NordicBuilder
Copy link
Contributor

NordicBuilder commented Dec 8, 2025

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

Name Old Revision New Revision Diff
zephyr nrfconnect/sdk-zephyr@c09c6ab nrfconnect/sdk-zephyr@6a9f0de (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 Dec 8, 2025

CI Information

To view the history of this post, click the 'edited' button above
Build number: 4

Inputs:

Sources:

sdk-nrf: PR head: 788d542e1e901f762e37068576a378287678265e
zephyr: PR head: 6a9f0debe2cb0d47328b26f109b09649b74ab269

more details

sdk-nrf:

PR head: 788d542e1e901f762e37068576a378287678265e
merge base: 6756485f1f0184a6420ffc90bfd228fc533335ab
target head (main): 6756485f1f0184a6420ffc90bfd228fc533335ab
Diff

zephyr:

PR head: 6a9f0debe2cb0d47328b26f109b09649b74ab269
merge base: c09c6abd11695d6b9c2ea24c4e88822eee9ff3f9
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 (5)
subsys
│  ├── mgmt
│  │  ├── mcumgr
│  │  │  ├── grp
│  │  │  │  ├── img_mgmt
│  │  │  │  │  ├── src
│  │  │  │  │  │  │ img_mgmt_state.c
west.yml
zephyr
│  ├── soc
│  │  ├── nordic
│  │  │  ├── common
│  │  │  │  ├── uicr
│  │  │  │  │  ├── periphconf
│  │  │  │  │  │  │ builder.py
│  │  │  ├── nrf54h
│  │  │  │  ├── bicr
│  │  │  │  │  │ bicrgen.py
│  ├── subsys
│  │  ├── mgmt
│  │  │  ├── mcumgr
│  │  │  │  ├── grp
│  │  │  │  │  ├── img_mgmt
│  │  │  │  │  │  ├── src
│  │  │  │  │  │  │  │ img_mgmt_state.c

Outputs:

Toolchain

Version:
Build docker image:

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

  • ◻️ Toolchain
  • ◻️ Build twister
  • ◻️ Integration tests
    • ◻️ test-sdk-audio
    • ◻️ test_ble_nrf_config
    • ◻️ test-fw-nrfconnect-chip
    • ◻️ test-fw-nrfconnect-nfc
    • ◻️ test-fw-nrfconnect-nrf-iot_cloud
    • ◻️ test-fw-nrfconnect-rs
    • ◻️ test-fw-nrfconnect-fem
    • ◻️ test-fw-nrfconnect-thread-main
    • ◻️ test-sdk-find-my
    • ◻️ test-sdk-mcuboot
    • ◻️ test-sdk-dfu
Disabled integration tests
    • test-fw-nrfconnect-nrf_lrcs_mosh
    • test-fw-nrfconnect-nrf_lrcs_positioning
    • desktop52_verification
    • test-fw-nrfconnect-apps
    • test-fw-nrfconnect-ble_mesh
    • test-fw-nrfconnect-ble_samples
    • test-fw-nrfconnect-nrf-iot_libmodem-nrf
    • test-fw-nrfconnect-nrf-iot_lwm2m
    • test-fw-nrfconnect-nrf-iot_samples
    • test-fw-nrfconnect-nrf-iot_thingy91
    • test-fw-nrfconnect-nrf-iot_zephyr_lwm2m
    • test-fw-nrfconnect-nrf_crypto
    • test-fw-nrfconnect-ps-main
    • test-fw-nrfconnect-rpc
    • test-fw-nrfconnect-tfm
    • test-low-level
    • test-sdk-wifi
    • test-secdom-samples-public

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

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

You can find the documentation preview for this PR here.

@tomchy tomchy modified the milestones: 3.2.0, 3.2.1 Dec 9, 2025
@tomchy tomchy removed the DNM label Dec 9, 2025
@tomchy
Copy link
Contributor Author

tomchy commented Dec 9, 2025

This PR can be merged - the backport PR should receive the DNM until the NCS v3.2.0 release tag is created.

The FW loader reports and manages exactly two slots:
 - slot 0: this is the slot for the application code to update
 - slot 1: this is the slot, in which the FW loader is placed

The slot 1 is reported, so tools can fetch metadata about the FW loader
installed on the device.
Unfortunately, currently SMP-based FW loader allows to issue slot erase
command for the slot 1, effectively erasing the FW loader code that is
being executed.

This change correctly identifies the slot 1 as an active one, marking
it as used and blocking erase operation on that slot.

Ref: NCSDK-36684

Signed-off-by: Tomasz Chyrowicz <[email protected]>
@tomchy tomchy force-pushed the bugfix/smp/NCSDK-36684_FW_loader_self_destruction_nrf branch from 98aaab7 to 788d542 Compare December 9, 2025 14:30
@NordicBuilder NordicBuilder added the changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. label Dec 9, 2025
@tomchy tomchy merged commit 53d0c75 into nrfconnect:main Dec 9, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport v3.2-branch bugfix Fixes a known bug changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. manifest manifest-zephyr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants