Skip to content

Commit 09eb172

Browse files
nvlsianpurlubos
authored andcommitted
[nrf noup] dfu/boot/mcuboot: fix confirmation in case of USE_PARTITION_MANAGER
Active partition ID need to be extracted basing on PARTITION_MANAGER products. ref.:NCSDK-26693 Signed-off-by: Andrzej Puzdrowski <[email protected]>
1 parent 93f8406 commit 09eb172

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

subsys/dfu/boot/mcuboot.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,34 @@
3434
#define BOOT_HEADER_MAGIC_V1 0x96f3b83d
3535
#define BOOT_HEADER_SIZE_V1 32
3636

37+
#if USE_PARTITION_MANAGER
38+
#include <pm_config.h>
39+
40+
#if CONFIG_BUILD_WITH_TFM
41+
#define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE + PM_TFM_SIZE)
42+
#else
43+
#define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE)
44+
#endif
45+
46+
#ifdef CONFIG_MCUBOOT
47+
/* lib is part of MCUboot -> operate on the primart application slot */
48+
#define ACTIVE_SLOT_ID PM_MCUBOOT_PRIMARY_ID
49+
#else
50+
/* lib is part of the App -> operate on active slot */
51+
#if (PM_ADDRESS - PM_ADDRESS_OFFSET) == PM_MCUBOOT_PRIMARY_ADDRESS
52+
#define ACTIVE_SLOT_ID PM_MCUBOOT_PRIMARY_ID
53+
#elif (PM_ADDRESS - PM_ADDRESS_OFFSET) == PM_MCUBOOT_SECONDARY_ADDRESS
54+
#define ACTIVE_SLOT_ID PM_MCUBOOT_SECONDARY_ID
55+
#else
56+
#error Missing partition definitions.
57+
#endif
58+
#endif /* CONFIG_MCUBOOT */
59+
60+
#define ACTIVE_SLOT_FLASH_AREA_ID ACTIVE_SLOT_ID
61+
#else
3762
/* Get active partition. zephyr,code-partition chosen node must be defined */
3863
#define ACTIVE_SLOT_FLASH_AREA_ID DT_FIXED_PARTITION_ID(DT_CHOSEN(zephyr_code_partition))
64+
#endif /* USE_PARTITION_MANAGER */
3965

4066
/*
4167
* Raw (on-flash) representation of the v1 image header.

0 commit comments

Comments
 (0)