Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
flash_map.h File Reference

Public API for flash map. More...

#include <zephyr/types.h>
#include <stddef.h>
#include <sys/types.h>
#include <zephyr/device.h>
#include <zephyr/devicetree.h>

Go to the source code of this file.

Data Structures

struct  flash_area
 Flash partition. More...
 
struct  flash_sector
 Structure for transfer flash sector boundaries. More...
 

Macros

#define SOC_FLASH_0_ID   0
 Provided for compatibility with MCUboot.
 
#define SPI_FLASH_0_ID   1
 Provided for compatibility with MCUboot.
 
#define FIXED_PARTITION_EXISTS(label)   DT_FIXED_PARTITION_EXISTS(DT_NODELABEL(label))
 Returns non-0 value if fixed-partition of given DTS node label exists.
 
#define FIXED_PARTITION_ID(label)   DT_FIXED_PARTITION_ID(DT_NODELABEL(label))
 Get flash area ID from fixed-partition DTS node label.
 
#define FIXED_PARTITION_OFFSET(label)   DT_REG_ADDR(DT_NODELABEL(label))
 Get fixed-partition offset from DTS node label.
 
#define FIXED_PARTITION_NODE_OFFSET(node)   DT_REG_ADDR(node)
 Get fixed-partition offset from DTS node.
 
#define FIXED_PARTITION_SIZE(label)   DT_REG_SIZE(DT_NODELABEL(label))
 Get fixed-partition size for DTS node label.
 
#define FIXED_PARTITION_NODE_SIZE(node)   DT_REG_SIZE(node)
 Get fixed-partition size for DTS node.
 
#define FLASH_AREA_DEVICE(label)    DEVICE_DT_GET(DT_MTD_FROM_FIXED_PARTITION(DT_NODE_BY_FIXED_PARTITION_LABEL(label)))
 Get device pointer for device the area/partition resides on.
 
#define FIXED_PARTITION_DEVICE(label)    DEVICE_DT_GET(DT_MTD_FROM_FIXED_PARTITION(DT_NODELABEL(label)))
 Get device pointer for device the area/partition resides on.
 
#define FIXED_PARTITION_NODE_DEVICE(node)    DEVICE_DT_GET(DT_MTD_FROM_FIXED_PARTITION(node))
 Get device pointer for device the area/partition resides on.
 

Typedefs

typedef void(* flash_area_cb_t) (const struct flash_area *fa, void *user_data)
 Flash map iteration callback.
 

Functions

int flash_area_open (uint8_t id, const struct flash_area **fa)
 Retrieve partitions flash area from the flash_map.
 
void flash_area_close (const struct flash_area *fa)
 Close flash_area.
 
int flash_area_read (const struct flash_area *fa, off_t off, void *dst, size_t len)
 Read flash area data.
 
int flash_area_write (const struct flash_area *fa, off_t off, const void *src, size_t len)
 Write data to flash area.
 
int flash_area_erase (const struct flash_area *fa, off_t off, size_t len)
 Erase flash area.
 
int flash_area_flatten (const struct flash_area *fa, off_t off, size_t len)
 Erase flash area or fill with erase-value.
 
uint32_t flash_area_align (const struct flash_area *fa)
 Get write block size of the flash area.
 
int flash_area_get_sectors (int fa_id, uint32_t *count, struct flash_sector *sectors)
 Retrieve info about sectors within the area.
 
void flash_area_foreach (flash_area_cb_t user_cb, void *user_data)
 Iterate over flash map.
 
int flash_area_has_driver (const struct flash_area *fa)
 Check whether given flash area has supporting flash driver in the system.
 
const struct deviceflash_area_get_device (const struct flash_area *fa)
 Get driver for given flash area.
 
uint8_t flash_area_erased_val (const struct flash_area *fa)
 Get the value expected to be read when accessing any erased flash byte.
 

Detailed Description

Public API for flash map.