nRF Connect SDK API 2.8.99
Loading...
Searching...
No Matches
flash_map_pm.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef FLASH_MAP_PM_H_
8#define FLASH_MAP_PM_H_
9
10#include <pm_config.h>
11#include <zephyr/sys/util.h>
12#include <zephyr/devicetree.h>
13
14/* Aliases for zephyr - mcuboot/ncs style naming */
15#define image_0 mcuboot_primary
16#define slot0_partition mcuboot_primary
17#define image_1 mcuboot_secondary
18#define slot1_partition mcuboot_secondary
19#define image_0_nonsecure mcuboot_primary
20#define slot0_ns_partition mcuboot_primary
21#define image_1_nonsecure mcuboot_secondary
22#define slot1_ns_partition mcuboot_secondary
23#define image_2 mcuboot_primary_1
24#define image_3 mcuboot_secondary_1
25#define slot2_partition mcuboot_primary_1
26#define slot3_partition mcuboot_secondary_1
27#define slot4_partition mcuboot_primary_2
28#define slot5_partition mcuboot_secondary_2
29#define image_scratch mcuboot_scratch
30#define image_scratch mcuboot_scratch
31
32#if (CONFIG_SETTINGS_FCB || CONFIG_SETTINGS_NVS || defined(PM_SETTINGS_STORAGE_ID) ||\
33 CONFIG_SETTINGS_ZMS)
34#define storage settings_storage
35#define storage_partition settings_storage
36#elif CONFIG_FILE_SYSTEM_LITTLEFS
37#define storage littlefs_storage
38#define storage_partition littlefs_storage
39#elif CONFIG_NVS
40#define storage nvs_storage
41#define storage_partition nvs_storage
42#elif CONFIG_ZMS
43#define storage zms_storage
44#define storage_partition zms_storage
45#endif
46
47#define PM_ID(label) PM_##label##_ID
48#define PM_IS_ENABLED(label) PM_##label##_IS_ENABLED
49
50#define FLASH_AREA_LABEL_STR(label) #label
51
52#define FIXED_PARTITION_ID(label) PM_ID(label)
53#define FLASH_AREA_ID(label) FIXED_PARTITION_ID(label)
54
55#define FIXED_PARTITION_DATA_FIELD(label, x) \
56 UTIL_CAT(PM_, UTIL_CAT(UTIL_CAT(PM_, UTIL_CAT(PM_ID(label), _LABEL)), x))
57#define FLASH_DATA_FIELD(label, x) FIXED_PARTITION_DATA_FIELD(label, x)
58
59#define FIXED_PARTITION_OFFSET(label) FIXED_PARTITION_DATA_FIELD(label, _OFFSET)
60#define FLASH_AREA_OFFSET(label) FIXED_PARTITION_OFFSET(label)
61
62#define FIXED_PARTITION_SIZE(label) FIXED_PARTITION_DATA_FIELD(label, _SIZE)
63#define FLASH_AREA_SIZE(label) FIXED_PARTITION_SIZE(label)
64
65#define FIXED_PARTITION_DEVICE(label) \
66 COND_CODE_1(DT_NODE_EXISTS(FIXED_PARTITION_DATA_FIELD(label, _DEV)), \
67 (DEVICE_DT_GET_OR_NULL(FIXED_PARTITION_DATA_FIELD(label, _DEV))), \
68 (DEVICE_DT_GET_OR_NULL(DT_NODELABEL(FIXED_PARTITION_DATA_FIELD(label, _DEV)))))
69#define FLASH_AREA_DEVICE(label) FIXED_PARTITION_DEVICE(label)
70
71#define FIXED_PARTITION_EXISTS(label) IS_ENABLED(PM_IS_ENABLED(label))
72#define FLASH_AREA_LABEL_EXISTS(label) FIXED_PARTITION_EXISTS(label)
73
74#endif /* FLASH_MAP_PM_H_*/