Skip to content

Commit 53d0c75

Browse files
committed
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 <[email protected]>
1 parent edc4023 commit 53d0c75

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,15 +420,13 @@ img_mgmt_state_any_pending(void)
420420
int
421421
img_mgmt_slot_in_use(int slot)
422422
{
423-
#if defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER)
424-
return 0;
425-
#else
426423
int image = img_mgmt_slot_to_image(slot);
427424
int active_slot = img_mgmt_active_slot(image);
428425

429426
#if !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP) && \
430427
!defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD) && \
431-
!defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD_WITH_REVERT)
428+
!defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD_WITH_REVERT) && \
429+
!defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER)
432430
enum img_mgmt_next_boot_type type = NEXT_BOOT_TYPE_NORMAL;
433431
int nbs = img_mgmt_get_next_boot_slot(image, &type);
434432

@@ -450,7 +448,6 @@ img_mgmt_slot_in_use(int slot)
450448
#endif
451449

452450
return (active_slot == slot);
453-
#endif /* !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER) */
454451
}
455452

456453
/**

west.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ manifest:
6464
# https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/modules.html
6565
- name: zephyr
6666
repo-path: sdk-zephyr
67-
revision: c09c6abd11695d6b9c2ea24c4e88822eee9ff3f9
67+
revision: 6a9f0debe2cb0d47328b26f109b09649b74ab269
6868
import:
6969
# In addition to the zephyr repository itself, NCS also
7070
# imports the contents of zephyr/west.yml at the above

0 commit comments

Comments
 (0)