nRF Connect SDK API 0.1.0
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#define storage settings_storage
34#define storage_partition settings_storage
35#elif CONFIG_FILE_SYSTEM_LITTLEFS
36#define storage littlefs_storage
37#define storage_partition littlefs_storage
38#elif CONFIG_NVS
39#define storage nvs_storage
40#define storage_partition nvs_storage
41#endif
42
43#define PM_ID(label) PM_##label##_ID
44#define PM_IS_ENABLED(label) PM_##label##_IS_ENABLED
45
46#define FLASH_AREA_LABEL_STR(label) #label
47
48#define FIXED_PARTITION_ID(label) PM_ID(label)
49#define FLASH_AREA_ID(label) FIXED_PARTITION_ID(label)
50
51#define FIXED_PARTITION_DATA_FIELD(label, x) \
52 UTIL_CAT(PM_, UTIL_CAT(UTIL_CAT(PM_, UTIL_CAT(PM_ID(label), _LABEL)), x))
53#define FLASH_DATA_FIELD(label, x) FIXED_PARTITION_DATA_FIELD(label, x)
54
55#define FIXED_PARTITION_OFFSET(label) FIXED_PARTITION_DATA_FIELD(label, _OFFSET)
56#define FLASH_AREA_OFFSET(label) FIXED_PARTITION_OFFSET(label)
57
58#define FIXED_PARTITION_SIZE(label) FIXED_PARTITION_DATA_FIELD(label, _SIZE)
59#define FLASH_AREA_SIZE(label) FIXED_PARTITION_SIZE(label)
60
61#define FIXED_PARTITION_DEVICE(label) \
62 COND_CODE_1(DT_NODE_EXISTS(FIXED_PARTITION_DATA_FIELD(label, _DEV)), \
63 (DEVICE_DT_GET_OR_NULL(FIXED_PARTITION_DATA_FIELD(label, _DEV))), \
64 (DEVICE_DT_GET_OR_NULL(DT_NODELABEL(FIXED_PARTITION_DATA_FIELD(label, _DEV)))))
65#define FLASH_AREA_DEVICE(label) FIXED_PARTITION_DEVICE(label)
66
67#define FIXED_PARTITION_EXISTS(label) IS_ENABLED(PM_IS_ENABLED(label))
68#define FLASH_AREA_LABEL_EXISTS(label) FIXED_PARTITION_EXISTS(label)
69
70#endif /* FLASH_MAP_PM_H_*/