Skip to content

Commit 418b6fe

Browse files
de-nordicjfischer-no
authored andcommitted
[nrf noup] sysflash: Move partition manager definitions to pm_sysflash.h
Making sysflash.h and pm_sysflash.h more readable. Signed-off-by: Dominik Ermel <[email protected]> (cherry picked from commit c3b33eb)
1 parent b4464ad commit 418b6fe

File tree

2 files changed

+97
-85
lines changed

2 files changed

+97
-85
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Copyright (c) 2023 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#ifndef __PM_SYSFLASH_H__
8+
#define __PM_SYSFLASH_H__
9+
/* Blocking the __SYSFLASH_H__ */
10+
#define __SYSFLASH_H__
11+
12+
#include <pm_config.h>
13+
#include <mcuboot_config/mcuboot_config.h>
14+
15+
#ifndef CONFIG_SINGLE_APPLICATION_SLOT
16+
17+
#if (MCUBOOT_IMAGE_NUMBER == 1)
18+
19+
#define FLASH_AREA_IMAGE_PRIMARY(x) PM_MCUBOOT_PRIMARY_ID
20+
#define FLASH_AREA_IMAGE_SECONDARY(x) PM_MCUBOOT_SECONDARY_ID
21+
22+
#elif (MCUBOOT_IMAGE_NUMBER == 2)
23+
24+
/* If B0 is present then two bootloaders are present, and we must use
25+
* a single secondary slot for both primary slots.
26+
*/
27+
#if defined(PM_B0_ADDRESS)
28+
extern uint32_t _image_1_primary_slot_id[];
29+
#endif
30+
#if defined(PM_B0_ADDRESS) && defined(CONFIG_NRF53_MULTI_IMAGE_UPDATE)
31+
#define FLASH_AREA_IMAGE_PRIMARY(x) \
32+
((x == 0) ? \
33+
PM_MCUBOOT_PRIMARY_ID : \
34+
(x == 1) ? \
35+
PM_MCUBOOT_PRIMARY_1_ID : \
36+
255 )
37+
38+
#define FLASH_AREA_IMAGE_SECONDARY(x) \
39+
((x == 0) ? \
40+
PM_MCUBOOT_SECONDARY_ID: \
41+
(x == 1) ? \
42+
PM_MCUBOOT_SECONDARY_1_ID: \
43+
255 )
44+
#elif defined(PM_B0_ADDRESS)
45+
46+
#define FLASH_AREA_IMAGE_PRIMARY(x) \
47+
((x == 0) ? \
48+
PM_MCUBOOT_PRIMARY_ID : \
49+
(x == 1) ? \
50+
(uint32_t)_image_1_primary_slot_id : \
51+
255 )
52+
53+
#define FLASH_AREA_IMAGE_SECONDARY(x) \
54+
((x == 0) ? \
55+
PM_MCUBOOT_SECONDARY_ID: \
56+
(x == 1) ? \
57+
PM_MCUBOOT_SECONDARY_ID: \
58+
255 )
59+
#else
60+
61+
#define FLASH_AREA_IMAGE_PRIMARY(x) \
62+
((x == 0) ? \
63+
PM_MCUBOOT_PRIMARY_ID : \
64+
(x == 1) ? \
65+
PM_MCUBOOT_PRIMARY_1_ID : \
66+
255 )
67+
68+
#define FLASH_AREA_IMAGE_SECONDARY(x) \
69+
((x == 0) ? \
70+
PM_MCUBOOT_SECONDARY_ID: \
71+
(x == 1) ? \
72+
PM_MCUBOOT_SECONDARY_1_ID: \
73+
255 )
74+
75+
#endif /* PM_B0_ADDRESS */
76+
77+
#endif
78+
#define FLASH_AREA_IMAGE_SCRATCH PM_MCUBOOT_SCRATCH_ID
79+
80+
#else /* CONFIG_SINGLE_APPLICATION_SLOT */
81+
82+
#define FLASH_AREA_IMAGE_PRIMARY(x) PM_MCUBOOT_PRIMARY_ID
83+
#define FLASH_AREA_IMAGE_SECONDARY(x) PM_MCUBOOT_PRIMARY_ID
84+
/* NOTE: Scratch parition is not used by single image DFU but some of
85+
* functions in common files reference it, so the definitions has been
86+
* provided to allow compilation of common units.
87+
*/
88+
#define FLASH_AREA_IMAGE_SCRATCH 0
89+
90+
#endif /* CONFIG_SINGLE_APPLICATION_SLOT */
91+
92+
#endif /* __PM_SYSFLASH_H__ */

boot/zephyr/include/sysflash/sysflash.h

Lines changed: 5 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -4,93 +4,15 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#ifndef __SYSFLASH_H__
8-
#define __SYSFLASH_H__
9-
107
#if USE_PARTITION_MANAGER
11-
#include <pm_config.h>
12-
#include <mcuboot_config/mcuboot_config.h>
13-
14-
#ifndef CONFIG_SINGLE_APPLICATION_SLOT
15-
16-
#if (MCUBOOT_IMAGE_NUMBER == 1)
17-
18-
#define FLASH_AREA_IMAGE_PRIMARY(x) PM_MCUBOOT_PRIMARY_ID
19-
#define FLASH_AREA_IMAGE_SECONDARY(x) PM_MCUBOOT_SECONDARY_ID
20-
21-
#elif (MCUBOOT_IMAGE_NUMBER == 2)
22-
23-
/* If B0 is present then two bootloaders are present, and we must use
24-
* a single secondary slot for both primary slots.
25-
*/
26-
#if defined(PM_B0_ADDRESS)
27-
extern uint32_t _image_1_primary_slot_id[];
28-
#endif
29-
#if defined(PM_B0_ADDRESS) && defined(CONFIG_NRF53_MULTI_IMAGE_UPDATE)
30-
#define FLASH_AREA_IMAGE_PRIMARY(x) \
31-
((x == 0) ? \
32-
PM_MCUBOOT_PRIMARY_ID : \
33-
(x == 1) ? \
34-
PM_MCUBOOT_PRIMARY_1_ID : \
35-
255 )
36-
37-
#define FLASH_AREA_IMAGE_SECONDARY(x) \
38-
((x == 0) ? \
39-
PM_MCUBOOT_SECONDARY_ID: \
40-
(x == 1) ? \
41-
PM_MCUBOOT_SECONDARY_1_ID: \
42-
255 )
43-
#elif defined(PM_B0_ADDRESS)
44-
45-
#define FLASH_AREA_IMAGE_PRIMARY(x) \
46-
((x == 0) ? \
47-
PM_MCUBOOT_PRIMARY_ID : \
48-
(x == 1) ? \
49-
(uint32_t)_image_1_primary_slot_id : \
50-
255 )
51-
52-
#define FLASH_AREA_IMAGE_SECONDARY(x) \
53-
((x == 0) ? \
54-
PM_MCUBOOT_SECONDARY_ID: \
55-
(x == 1) ? \
56-
PM_MCUBOOT_SECONDARY_ID: \
57-
255 )
58-
#else
59-
60-
#define FLASH_AREA_IMAGE_PRIMARY(x) \
61-
((x == 0) ? \
62-
PM_MCUBOOT_PRIMARY_ID : \
63-
(x == 1) ? \
64-
PM_MCUBOOT_PRIMARY_1_ID : \
65-
255 )
66-
67-
#define FLASH_AREA_IMAGE_SECONDARY(x) \
68-
((x == 0) ? \
69-
PM_MCUBOOT_SECONDARY_ID: \
70-
(x == 1) ? \
71-
PM_MCUBOOT_SECONDARY_1_ID: \
72-
255 )
73-
74-
#endif /* PM_B0_ADDRESS */
75-
8+
/* Blocking the rest of the file */
9+
#define __SYSFLASH_H__
10+
#include <sysflash/pm_sysflash.h>
7611
#endif
77-
#define FLASH_AREA_IMAGE_SCRATCH PM_MCUBOOT_SCRATCH_ID
78-
79-
#else /* CONFIG_SINGLE_APPLICATION_SLOT */
8012

81-
#define FLASH_AREA_IMAGE_PRIMARY(x) PM_MCUBOOT_PRIMARY_ID
82-
#define FLASH_AREA_IMAGE_SECONDARY(x) PM_MCUBOOT_PRIMARY_ID
83-
/* NOTE: Scratch parition is not used by single image DFU but some of
84-
* functions in common files reference it, so the definitions has been
85-
* provided to allow compilation of common units.
86-
*/
87-
#define FLASH_AREA_IMAGE_SCRATCH 0
88-
89-
#endif /* CONFIG_SINGLE_APPLICATION_SLOT */
90-
91-
#else
13+
#ifndef __SYSFLASH_H__
14+
#define __SYSFLASH_H__
9215

93-
#include <zephyr/devicetree.h>
9416
#include <mcuboot_config/mcuboot_config.h>
9517
#include <zephyr/devicetree.h>
9618
#include <zephyr/storage/flash_map.h>
@@ -141,6 +63,4 @@ static inline uint32_t __flash_area_ids_for_slot(int img, int slot)
14163

14264
#endif /* CONFIG_SINGLE_APPLICATION_SLOT */
14365

144-
#endif /* USE_PARTITION_MANAGER */
145-
14666
#endif /* __SYSFLASH_H__ */

0 commit comments

Comments
 (0)