1 /* 2 * Copyright (c) 2017 Nordic Semiconductor ASA 3 * Copyright (c) 2015 Runtime Inc 4 * Copyright (c) 2023 Sensorfy B.V. 5 * 6 * SPDX-License-Identifier: Apache-2.0 7 */ 8 9 #define DT_DRV_COMPAT fixed_partitions 10 11 #include <zephyr/device.h> 12 #include <zephyr/kernel.h> 13 #include <zephyr/storage/flash_map.h> 14 15 #if CONFIG_FLASH_MAP_LABELS 16 #define FLASH_AREA_FOO(part) \ 17 {.fa_id = DT_FIXED_PARTITION_ID(part), \ 18 .fa_off = DT_REG_ADDR(part), \ 19 .fa_dev = DEVICE_DT_GET_OR_NULL(DT_MTD_FROM_FIXED_PARTITION(part)), \ 20 .fa_size = DT_REG_SIZE(part), \ 21 .fa_label = DT_PROP_OR(part, label, NULL), }, 22 #else 23 #define FLASH_AREA_FOO(part) \ 24 {.fa_id = DT_FIXED_PARTITION_ID(part), \ 25 .fa_off = DT_REG_ADDR(part), \ 26 .fa_dev = DEVICE_DT_GET_OR_NULL(DT_MTD_FROM_FIXED_PARTITION(part)), \ 27 .fa_size = DT_REG_SIZE(part), }, 28 #endif 29 30 #define FOREACH_PARTITION(n) DT_FOREACH_CHILD(DT_DRV_INST(n), FLASH_AREA_FOO) 31 32 /* We iterate over all compatible 'fixed-partitions' nodes and 33 * use DT_FOREACH_CHILD to iterate over all the partitions for that 34 * 'fixed-partitions' node. This way we build a global partition map 35 */ 36 const struct flash_area default_flash_map[] = { 37 DT_INST_FOREACH_STATUS_OKAY(FOREACH_PARTITION) 38 }; 39 40 const int flash_map_entries = ARRAY_SIZE(default_flash_map); 41 const struct flash_area *flash_map = default_flash_map; 42