zephyr/subsys/storage/flash_map/flash_map_default.c
Findlay Feng 69c15f0ed1 dts: flash_map: Automatically generate of the list of flash area
This Patch add functionality for automatic generation of the flash map
using DTS description. Automatic generation allows to replace
C-hardcoded flash_map.

We generate a set of defines based on the index of a partiion:
	#define DT_FLASH_AREA_<IDX>_OFFSET	0
	#define DT_FLASH_AREA_<IDX>_SIZE	131072
	#define DT_FLASH_AREA_<IDX>_DEV		"FLASH_CTRL"
	#define DT_FLASH_AREA_<IDX>_LABEL	MCUBOOT

Additionally we also define:
	#define DT_FLASH_AREA_NUM		4

and:
	#define DT_FLASH_AREA_<PARTNAME>_ID	0

Signed-off-by: Findlay Feng <i@fengch.me>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-07 10:31:27 -06:00

23 lines
579 B
C

/*
* Copyright (c) 2017 Nordic Semiconductor ASA
* Copyright (c) 2015 Runtime Inc
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include <flash_map.h>
#define FLASH_AREA_FOO(i, _) \
{.fa_id = i, \
.fa_off = DT_FLASH_AREA_##i##_OFFSET, \
.fa_dev_name = DT_FLASH_AREA_##i##_DEV, \
.fa_size = DT_FLASH_AREA_##i##_SIZE,},
const struct flash_area default_flash_map[] = {
UTIL_LISTIFY(DT_FLASH_AREA_NUM, FLASH_AREA_FOO, ~)
};
const int flash_map_entries = ARRAY_SIZE(default_flash_map);
const struct flash_area *flash_map = default_flash_map;