Skip to content

Commit 22eec45

Browse files
committed
[nrf noup] dfu: boot: mcuboot: Fix selecting wrong active slot
fixup! [nrf noup] dfu/boot/mcuboot: fix confirmation in case of USE_PARTITION_MANAGER Fixes this code to correctly check which slot is active, albeit without firmware loader support Signed-off-by: Jamie McCrae <[email protected]> (cherry picked from commit d99f13e)
1 parent 3ba0b73 commit 22eec45

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

subsys/dfu/boot/mcuboot.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,42 @@
3737
#if USE_PARTITION_MANAGER
3838
#include <pm_config.h>
3939

40+
#if CONFIG_MCUBOOT_APPLICATION_IMAGE_NUMBER != -1
41+
/* Sysbuild */
42+
#ifdef CONFIG_MCUBOOT
43+
/* lib is part of MCUboot -> operate on the primary application slot */
44+
#define ACTIVE_SLOT_FLASH_AREA_ID PM_MCUBOOT_PRIMARY_ID
45+
#else
46+
/* TODO: Add firmware loader support */
47+
/* lib is part of the app -> operate on active slot */
48+
#if defined(CONFIG_NCS_IS_VARIANT_IMAGE)
49+
#define ACTIVE_SLOT_FLASH_AREA_ID PM_MCUBOOT_SECONDARY_ID
50+
#else
51+
#define ACTIVE_SLOT_FLASH_AREA_ID PM_MCUBOOT_PRIMARY_ID
52+
#endif
53+
#endif /* CONFIG_MCUBOOT */
54+
#else
55+
/* Legacy child/parent */
4056
#if CONFIG_BUILD_WITH_TFM
4157
#define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE + PM_TFM_SIZE)
4258
#else
4359
#define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE)
4460
#endif
4561

4662
#ifdef CONFIG_MCUBOOT
47-
/* lib is part of MCUboot -> operate on the primart application slot */
48-
#define ACTIVE_SLOT_ID PM_MCUBOOT_PRIMARY_ID
63+
/* lib is part of MCUboot -> operate on the primary application slot */
64+
#define ACTIVE_SLOT_FLASH_AREA_ID PM_MCUBOOT_PRIMARY_ID
4965
#else
5066
/* lib is part of the App -> operate on active slot */
5167
#if (PM_ADDRESS - PM_ADDRESS_OFFSET) == PM_MCUBOOT_PRIMARY_ADDRESS
52-
#define ACTIVE_SLOT_ID PM_MCUBOOT_PRIMARY_ID
68+
#define ACTIVE_SLOT_FLASH_AREA_ID PM_MCUBOOT_PRIMARY_ID
5369
#elif (PM_ADDRESS - PM_ADDRESS_OFFSET) == PM_MCUBOOT_SECONDARY_ADDRESS
54-
#define ACTIVE_SLOT_ID PM_MCUBOOT_SECONDARY_ID
70+
#define ACTIVE_SLOT_FLASH_AREA_ID PM_MCUBOOT_SECONDARY_ID
5571
#else
5672
#error Missing partition definitions.
5773
#endif
5874
#endif /* CONFIG_MCUBOOT */
59-
60-
#define ACTIVE_SLOT_FLASH_AREA_ID ACTIVE_SLOT_ID
75+
#endif /* CONFIG_MCUBOOT_APPLICATION_IMAGE_NUMBER != -1 */
6176
#else
6277
/* Get active partition. zephyr,code-partition chosen node must be defined */
6378
#define ACTIVE_SLOT_FLASH_AREA_ID DT_FIXED_PARTITION_ID(DT_CHOSEN(zephyr_code_partition))

0 commit comments

Comments
 (0)