17
17
#include <string.h>
18
18
19
19
#include <zephyr/kernel.h>
20
+ #ifdef CONFIG_PARTITION_MANAGER_ENABLED
20
21
#include <pm_config.h>
22
+ #else
23
+ #include <zephyr/storage/flash_map.h>
24
+ #endif
21
25
#include <zephyr/logging/log.h>
22
26
#include <zephyr/dfu/mcuboot.h>
23
27
#include <dfu/dfu_target.h>
@@ -31,6 +35,8 @@ LOG_MODULE_REGISTER(dfu_target_mcuboot, CONFIG_DFU_TARGET_LOG_LEVEL);
31
35
32
36
#define IS_ALIGNED_32 (POINTER ) (((uintptr_t)(const void *)(POINTER)) % 4 == 0)
33
37
38
+ #ifdef CONFIG_PARTITION_MANAGER_ENABLED
39
+
34
40
#define _MB_SEC_PAT (i , x ) PM_MCUBOOT_SECONDARY_ ## i ## _ ## x
35
41
36
42
#define _MB_SEC_PAT_STRING (i , x ) STRINGIFY(PM_MCUBOOT_SECONDARY_ ## i ## _ ## x)
@@ -44,8 +50,6 @@ LOG_MODULE_REGISTER(dfu_target_mcuboot, CONFIG_DFU_TARGET_LOG_LEVEL);
44
50
45
51
#define _MB_SEC_LA (i , _ ) _H_MB_SEC_LA(i)
46
52
47
- #define _STR_TARGET_NAME (i , _ ) STRINGIFY(MCUBOOT##i)
48
-
49
53
#ifdef PM_MCUBOOT_SECONDARY_2_ID
50
54
#define TARGET_IMAGE_COUNT 3
51
55
#elif defined(PM_MCUBOOT_SECONDARY_1_ID )
@@ -62,6 +66,36 @@ LOG_MODULE_REGISTER(dfu_target_mcuboot, CONFIG_DFU_TARGET_LOG_LEVEL);
62
66
#define PM_MCUBOOT_SECONDARY_0_NAME STRINGIFY(PM_MCUBOOT_SECONDARY_NAME)
63
67
#define PM_MCUBOOT_SECONDARY_0_DEV PM_MCUBOOT_SECONDARY_DEV
64
68
69
+ #else /* CONFIG_PARTITION_MANAGER_ENABLED */
70
+
71
+ /**
72
+ * These definitions are named to align with those used when Partition Manager
73
+ * is enabled, ensuring compatibility for use in the array definitions below.
74
+ */
75
+
76
+ /**
77
+ * The labels are defined: slot1_partition for image 0, slot3_partition for image 1, etc.
78
+ */
79
+ #define SEC_PAT_NODELABEL (i ) UTIL_CAT(slot, UTIL_CAT(UTIL_INC(UTIL_X2(i)), _partition))
80
+
81
+ #define SEC_PAT_ADDRESS (i ) FIXED_PARTITION_OFFSET(SEC_PAT_NODELABEL(i))
82
+
83
+ #define SEC_PAT_SIZE (i ) FIXED_PARTITION_SIZE(SEC_PAT_NODELABEL(i))
84
+
85
+ #define _MB_SEC_PAT (i , x ) UTIL_CAT(SEC_PAT_, x)(i)
86
+
87
+ /* Ignore the 'x' parameter, it is needed for compatibility with Partition Manager scenarios. */
88
+ #define _MB_SEC_PAT_DEV (i , x ) FIXED_PARTITION_DEVICE(SEC_PAT_NODELABEL(i))
89
+
90
+ /* Ignore the 'x' parameter, it is needed for compatibility with Partition Manager scenarios. */
91
+ #define _MB_SEC_PAT_STRING (i , x ) STRINGIFY(SEC_PAT_NODELABEL(i))
92
+
93
+ #define TARGET_IMAGE_COUNT CONFIG_UPDATEABLE_IMAGE_NUMBER
94
+
95
+ #endif /* CONFIG_PARTITION_MANAGER_ENABLED */
96
+
97
+ #define _STR_TARGET_NAME (i , _ ) STRINGIFY(MCUBOOT##i)
98
+
65
99
static const size_t secondary_size [] = {
66
100
LIST_DROP_EMPTY (LISTIFY (TARGET_IMAGE_COUNT , _MB_SEC_PAT , (,), SIZE ))
67
101
};
0 commit comments