Skip to content

Commit a7e1fd6

Browse files
MarekPietajfischer-no
authored andcommitted
[nrf noup] mcumgr: img_mgmt: Fix check for chosen code partition
The "zephyr-code-partition" chosen DTS node cannot be used when build uses Partition Manager. In that case, mcumgr must rely on the definitions provided by the Partition Manager. Jira: NCSDK-21381 Signed-off-by: Marek Pieta <[email protected]> Signed-off-by: Dominik Ermel <[email protected]> (cherry picked from commit acd8871)
1 parent ed3f003 commit a7e1fd6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,31 @@
3333
#include <zephyr/mgmt/mcumgr/mgmt/callbacks.h>
3434
#endif
3535

36+
#if USE_PARTITION_MANAGER
37+
#include <flash_map_pm.h>
38+
39+
#ifdef PM_MCUBOOT_SECONDARY_PAD_SIZE
40+
BUILD_ASSERT(PM_MCUBOOT_PAD_SIZE == PM_MCUBOOT_SECONDARY_PAD_SIZE);
41+
#endif
42+
43+
#if CONFIG_BUILD_WITH_TFM
44+
#define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE + PM_TFM_SIZE)
45+
#else
46+
#define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE)
47+
#endif
48+
49+
#define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \
50+
(FIXED_PARTITION_OFFSET(label) == (PM_ADDRESS - PM_ADDRESS_OFFSET))
51+
52+
#else /* ! USE_PARTITION_MANAGER */
3653
#ifndef CONFIG_FLASH_LOAD_OFFSET
3754
#error MCUmgr requires application to be built with CONFIG_FLASH_LOAD_OFFSET set \
3855
to be able to figure out application running slot.
3956
#endif
4057

4158
#define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \
4259
(FIXED_PARTITION_OFFSET(label) == CONFIG_FLASH_LOAD_OFFSET)
60+
#endif /* USE_PARTITION_MANAGER */
4361

4462
BUILD_ASSERT(sizeof(struct image_header) == IMAGE_HEADER_SIZE,
4563
"struct image_header not required size");

0 commit comments

Comments
 (0)