From 788d542e1e901f762e37068576a378287678265e Mon Sep 17 00:00:00 2001 From: Tomasz Chyrowicz Date: Mon, 8 Dec 2025 17:15:32 +0100 Subject: [PATCH] mcumgr: Prevent FW loader from self-destruction 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 --- subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c | 7 ++----- west.yml | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c index 5642e80cdaa8..36b78a33314e 100644 --- a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c +++ b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c @@ -420,15 +420,13 @@ img_mgmt_state_any_pending(void) int img_mgmt_slot_in_use(int slot) { -#if defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER) - return 0; -#else int image = img_mgmt_slot_to_image(slot); int active_slot = img_mgmt_active_slot(image); #if !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP) && \ !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD) && \ - !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD_WITH_REVERT) + !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD_WITH_REVERT) && \ + !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER) enum img_mgmt_next_boot_type type = NEXT_BOOT_TYPE_NORMAL; int nbs = img_mgmt_get_next_boot_slot(image, &type); @@ -450,7 +448,6 @@ img_mgmt_slot_in_use(int slot) #endif return (active_slot == slot); -#endif /* !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER) */ } /** diff --git a/west.yml b/west.yml index 0bd39ac11cf1..fcfc5dcfd4e0 100644 --- a/west.yml +++ b/west.yml @@ -64,7 +64,7 @@ manifest: # https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/modules.html - name: zephyr repo-path: sdk-zephyr - revision: c09c6abd11695d6b9c2ea24c4e88822eee9ff3f9 + revision: 6a9f0debe2cb0d47328b26f109b09649b74ab269 import: # In addition to the zephyr repository itself, NCS also # imports the contents of zephyr/west.yml at the above