2017-12-08 18:50:46 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2017 Nordic Semiconductor ASA
|
|
|
|
* Copyright (c) 2015 Runtime Inc
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2020-05-07 12:12:11 +08:00
|
|
|
#define DT_DRV_COMPAT fixed_partitions
|
|
|
|
|
2017-12-08 18:50:46 +08:00
|
|
|
#include <zephyr.h>
|
2019-06-26 00:05:42 +08:00
|
|
|
#include <storage/flash_map.h>
|
2017-12-08 18:50:46 +08:00
|
|
|
|
2020-11-01 04:43:34 +08:00
|
|
|
#define FLASH_AREA_FOO(part) \
|
|
|
|
{.fa_id = DT_FIXED_PARTITION_ID(part), \
|
|
|
|
.fa_off = DT_REG_ADDR(part), \
|
|
|
|
.fa_dev_name = DT_LABEL(DT_MTD_FROM_FIXED_PARTITION(part)), \
|
2020-05-07 12:12:11 +08:00
|
|
|
.fa_size = DT_REG_SIZE(part),},
|
|
|
|
|
2020-09-21 21:48:49 +08:00
|
|
|
#define FOREACH_PARTITION(n) DT_FOREACH_CHILD(DT_DRV_INST(n), FLASH_AREA_FOO)
|
2020-05-07 12:12:11 +08:00
|
|
|
|
|
|
|
/* We iterate over all compatible 'fixed-partions' nodes and
|
|
|
|
* use DT_FOREACH_CHILD to iterate over all the partitions for that
|
|
|
|
* 'fixed-partions' node. This way we build a global partition map
|
|
|
|
*/
|
2017-12-08 18:50:46 +08:00
|
|
|
const struct flash_area default_flash_map[] = {
|
2020-09-21 21:48:49 +08:00
|
|
|
DT_INST_FOREACH_STATUS_OKAY(FOREACH_PARTITION)
|
2017-12-08 18:50:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const int flash_map_entries = ARRAY_SIZE(default_flash_map);
|
|
|
|
const struct flash_area *flash_map = default_flash_map;
|