Skip to content

Commit 69d16c6

Browse files
committed
img_mgmt: Use absolute address in active partition
Use absolute addresses while determining a running application partition. Signed-off-by: Tomasz Chyrowicz <[email protected]>
1 parent 5918fc8 commit 69d16c6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@
4343

4444
#if !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD)
4545

46+
#ifdef CONFIG_USE_DT_CODE_PARTITION
47+
#define FIXED_PARTITION_ADDRESS(label) \
48+
(DT_REG_ADDR(DT_NODELABEL(label)) + \
49+
DT_REG_ADDR(COND_CODE_1(DT_FIXED_SUBPARTITION_EXISTS(DT_NODELABEL(label)), \
50+
(DT_GPARENT(DT_PARENT(DT_NODELABEL(label)))), \
51+
(DT_GPARENT(DT_NODELABEL(label))))))
52+
#define FLASH_LOAD_ADDRESS \
53+
(DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition)) + \
54+
DT_REG_ADDR(COND_CODE_1(DT_FIXED_SUBPARTITION_EXISTS(DT_CHOSEN(zephyr_code_partition)), \
55+
(DT_GPARENT(DT_PARENT(DT_CHOSEN(zephyr_code_partition)))), \
56+
(DT_GPARENT(DT_CHOSEN(zephyr_code_partition))))))
57+
#define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \
58+
(FIXED_PARTITION_ADDRESS(label) <= FLASH_LOAD_ADDRESS && \
59+
FIXED_PARTITION_ADDRESS(label) + DT_REG_SIZE(DT_NODELABEL(label)) > FLASH_LOAD_ADDRESS)
60+
#else
4661
#ifndef CONFIG_FLASH_LOAD_OFFSET
4762
#error MCUmgr requires application to be built with CONFIG_FLASH_LOAD_OFFSET set \
4863
to be able to figure out application running slot.
@@ -51,6 +66,7 @@
5166
#define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \
5267
(FIXED_PARTITION_OFFSET(label) <= CONFIG_FLASH_LOAD_OFFSET && \
5368
FIXED_PARTITION_OFFSET(label) + FIXED_PARTITION_SIZE(label) > CONFIG_FLASH_LOAD_OFFSET)
69+
#endif
5470

5571
BUILD_ASSERT(sizeof(struct image_header) == IMAGE_HEADER_SIZE,
5672
"struct image_header not required size");

0 commit comments

Comments
 (0)