Zephyr API Documentation 4.4.0-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
flash area Interface

Abstraction over flash partitions/areas and their drivers. More...

Data Structures

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

Macros

#define PARTITION_EXISTS(label)
 Returns non-0 value if partition of given DTS node label exists.
#define FIXED_PARTITION_EXISTS(label)
 Deprecated macro, replace with PARTITION_EXISTS(), this cannot use __DEPRECATED_MACRO as it causes usage of the macro to fail with compiler errors.
#define PARTITION_ID(label)
 Get flash area ID from partition DTS node label.
#define FIXED_PARTITION_ID(label)
 Deprecated macro, replace with PARTITION_ID().
#define PARTITION_OFFSET(label)
 Get partition offset from DTS node label.
#define FIXED_PARTITION_OFFSET(label)
 Deprecated macro, replace with PARTITION_OFFSET().
#define PARTITION_ADDRESS(label)
 Get partition address from DTS node label.
#define FIXED_PARTITION_ADDRESS(label)
 Deprecated macro, replace with PARTITION_ADDRESS().
#define PARTITION_NODE_ADDRESS(node)
 Get partition address from DTS node.
#define FIXED_PARTITION_NODE_ADDRESS(node)
 Deprecated macro, replace with PARTITION_NODE_ADDRESS().
#define PARTITION_NODE_OFFSET(node)
 Get partition offset from DTS node.
#define FIXED_PARTITION_NODE_OFFSET(label)
 Deprecated macro, replace with PARTITION_NODE_OFFSET().
#define PARTITION_SIZE(label)
 Get partition size for DTS node label.
#define FIXED_PARTITION_SIZE(label)
 Deprecated macro, replace with PARTITION_SIZE().
#define PARTITION_NODE_SIZE(node)
 Get fixed-partition size for DTS node.
#define FIXED_PARTITION_NODE_SIZE(node)
 Deprecated macro, replace with PARTITION_NODE_SIZE().
#define FLASH_AREA_DEVICE(label)
 Get device pointer for device the area/partition resides on.
#define PARTITION_DEVICE(label)
 Get device pointer for device the area/partition resides on.
#define FIXED_PARTITION_DEVICE(label)
 Deprecated macro, replace with PARTITION_DEVICE().
#define PARTITION_NODE_DEVICE(node)
 Get device pointer for device the area/partition resides on.
#define FIXED_PARTITION_NODE_DEVICE(node)
 Deprecated macro, replace with PARTITION_NODE_DEVICE().
#define PARTITION_MTD(label)
 Get the node identifier of the flash controller the area/partition resides on.
#define FIXED_PARTITION_MTD(label)
 Deprecated macro, replace with PARTITION_OFFSET().
#define PARTITION_NODE_MTD(node)
 Get the node identifier of the flash controller the area/partition resides on.
#define FIXED_PARTITION_NODE_MTD(node)
 Deprecated macro, replace with PARTITION_NODE_MTD().
#define PARTITION(label)
 Get pointer to flash_area object by partition label.
#define FIXED_PARTITION(label)
 Deprecated macro, replace with PARTITION().
#define PARTITION_BY_NODE(node)
 Get pointer to flash_area object by partition node in DTS.
#define FIXED_PARTITION_BY_NODE(node)
 Deprecated macro, replace with PARTITION_OFFSET().

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.
static ALWAYS_INLINE bool flash_area_device_is_ready (const struct flash_area *fa)
 Verify that a device assigned to flash area is ready for use.
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_copy (const struct flash_area *src_fa, off_t src_off, const struct flash_area *dst_fa, off_t dst_off, off_t len, uint8_t *buf, size_t buf_size)
 Copy flash memory from one flash area to another.
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.
int flash_area_sectors (const struct flash_area *fa, 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

Abstraction over flash partitions/areas and their drivers.

Since
1.11
Version
1.1.1

Macro Definition Documentation

◆ FIXED_PARTITION

#define FIXED_PARTITION ( label)

#include <zephyr/storage/flash_map.h>

Value:
PARTITION(label) __DEPRECATED_MACRO
#define PARTITION(label)
Get pointer to flash_area object by partition label.
Definition flash_map.h:556

Deprecated macro, replace with PARTITION().

◆ FIXED_PARTITION_ADDRESS

#define FIXED_PARTITION_ADDRESS ( label)

#include <zephyr/storage/flash_map.h>

Value:
PARTITION_ADDRESS(label) __DEPRECATED_MACRO
#define PARTITION_ADDRESS(label)
Get partition address from DTS node label.
Definition flash_map.h:409

Deprecated macro, replace with PARTITION_ADDRESS().

◆ FIXED_PARTITION_BY_NODE

#define FIXED_PARTITION_BY_NODE ( node)

#include <zephyr/storage/flash_map.h>

Value:
PARTITION_BY_NODE(node) __DEPRECATED_MACRO
#define PARTITION_BY_NODE(node)
Get pointer to flash_area object by partition node in DTS.
Definition flash_map.h:568

Deprecated macro, replace with PARTITION_OFFSET().

◆ FIXED_PARTITION_DEVICE

#define FIXED_PARTITION_DEVICE ( label)

#include <zephyr/storage/flash_map.h>

Value:
PARTITION_DEVICE(label) __DEPRECATED_MACRO
#define PARTITION_DEVICE(label)
Get device pointer for device the area/partition resides on.
Definition flash_map.h:498

Deprecated macro, replace with PARTITION_DEVICE().

◆ FIXED_PARTITION_EXISTS

#define FIXED_PARTITION_EXISTS ( label)

#include <zephyr/storage/flash_map.h>

Value:
#define PARTITION_EXISTS(label)
Returns non-0 value if partition of given DTS node label exists.
Definition flash_map.h:362

Deprecated macro, replace with PARTITION_EXISTS(), this cannot use __DEPRECATED_MACRO as it causes usage of the macro to fail with compiler errors.

◆ FIXED_PARTITION_ID

#define FIXED_PARTITION_ID ( label)

#include <zephyr/storage/flash_map.h>

Value:
PARTITION_ID(label) __DEPRECATED_MACRO
#define PARTITION_ID(label)
Get flash area ID from partition DTS node label.
Definition flash_map.h:377

Deprecated macro, replace with PARTITION_ID().

◆ FIXED_PARTITION_MTD

#define FIXED_PARTITION_MTD ( label)

#include <zephyr/storage/flash_map.h>

Value:
PARTITION_MTD(label) __DEPRECATED_MACRO
#define PARTITION_MTD(label)
Get the node identifier of the flash controller the area/partition resides on.
Definition flash_map.h:527

Deprecated macro, replace with PARTITION_OFFSET().

◆ FIXED_PARTITION_NODE_ADDRESS

#define FIXED_PARTITION_NODE_ADDRESS ( node)

#include <zephyr/storage/flash_map.h>

Value:
PARTITION_NODE_ADDRESS(node) __DEPRECATED_MACRO
#define PARTITION_NODE_ADDRESS(node)
Get partition address from DTS node.
Definition flash_map.h:421

Deprecated macro, replace with PARTITION_NODE_ADDRESS().

◆ FIXED_PARTITION_NODE_DEVICE

#define FIXED_PARTITION_NODE_DEVICE ( node)

#include <zephyr/storage/flash_map.h>

Value:
PARTITION_NODE_DEVICE(node) __DEPRECATED_MACRO
#define PARTITION_NODE_DEVICE(node)
Get device pointer for device the area/partition resides on.
Definition flash_map.h:510

Deprecated macro, replace with PARTITION_NODE_DEVICE().

◆ FIXED_PARTITION_NODE_MTD

#define FIXED_PARTITION_NODE_MTD ( node)

#include <zephyr/storage/flash_map.h>

Value:
PARTITION_NODE_MTD(node) __DEPRECATED_MACRO
#define PARTITION_NODE_MTD(node)
Get the node identifier of the flash controller the area/partition resides on.
Definition flash_map.h:539

Deprecated macro, replace with PARTITION_NODE_MTD().

◆ FIXED_PARTITION_NODE_OFFSET

#define FIXED_PARTITION_NODE_OFFSET ( label)

#include <zephyr/storage/flash_map.h>

Value:
PARTITION_NODE_OFFSET(label) __DEPRECATED_MACRO
#define PARTITION_NODE_OFFSET(node)
Get partition offset from DTS node.
Definition flash_map.h:443

Deprecated macro, replace with PARTITION_NODE_OFFSET().

◆ FIXED_PARTITION_NODE_SIZE

#define FIXED_PARTITION_NODE_SIZE ( node)

#include <zephyr/storage/flash_map.h>

Value:
PARTITION_NODE_SIZE(node) __DEPRECATED_MACRO
#define PARTITION_NODE_SIZE(node)
Get fixed-partition size for DTS node.
Definition flash_map.h:472

Deprecated macro, replace with PARTITION_NODE_SIZE().

◆ FIXED_PARTITION_OFFSET

#define FIXED_PARTITION_OFFSET ( label)

#include <zephyr/storage/flash_map.h>

Value:
PARTITION_OFFSET(label) __DEPRECATED_MACRO
#define PARTITION_OFFSET(label)
Get partition offset from DTS node label.
Definition flash_map.h:397

Deprecated macro, replace with PARTITION_OFFSET().

◆ FIXED_PARTITION_SIZE

#define FIXED_PARTITION_SIZE ( label)

#include <zephyr/storage/flash_map.h>

Value:
PARTITION_SIZE(label) __DEPRECATED_MACRO
#define PARTITION_SIZE(label)
Get partition size for DTS node label.
Definition flash_map.h:460

Deprecated macro, replace with PARTITION_SIZE().

◆ FLASH_AREA_DEVICE

#define FLASH_AREA_DEVICE ( label)

#include <zephyr/storage/flash_map.h>

Value:
COND_CODE_1(DT_NODE_HAS_COMPAT(DT_NODELABEL(label), zephyr_mapped_partition), \
#define DEVICE_DT_GET(node_id)
Get a device reference from a devicetree node identifier.
Definition device.h:317
#define DT_MTD_FROM_FIXED_PARTITION(node_id)
Get the node identifier of the flash controller for a partition.
Definition fixed-partitions.h:96
#define DT_NODE_BY_FIXED_PARTITION_LABEL(label)
Get a node identifier for a fixed partition with a given label property.
Definition fixed-partitions.h:52
#define DT_NODE_HAS_COMPAT(node_id, compat)
Does a devicetree node match a compatible?
Definition devicetree.h:3936
#define DT_NODELABEL(label)
Get a node identifier for a node label.
Definition devicetree.h:197
#define DT_MTD_FROM_MAPPED_PARTITION(node_id)
Get the node identifier of the NVM controller for a partition.
Definition mapped-partition.h:105
#define DT_NODE_BY_MAPPED_PARTITION_LABEL(label)
Get a node identifier for a mapped partition with a given label property.
Definition mapped-partition.h:62
#define COND_CODE_1(_flag, _if_1_code, _else_code)
Insert code depending on whether _flag expands to 1 or not.
Definition util_macro.h:209

Get device pointer for device the area/partition resides on.

Parameters
labelDTS node label of a partition
Returns
const struct device type pointer

◆ PARTITION

#define PARTITION ( label)

#include <zephyr/storage/flash_map.h>

Value:

Get pointer to flash_area object by partition label.

Parameters
labelDTS node label of a partition
Returns
Pointer to flash_area type object representing partition

◆ PARTITION_ADDRESS

#define PARTITION_ADDRESS ( label)

#include <zephyr/storage/flash_map.h>

Value:

Get partition address from DTS node label.

Parameters
labelDTS node label of a partition
Returns
address, as defined for the partition in DTS.

◆ PARTITION_BY_NODE

#define PARTITION_BY_NODE ( node)

#include <zephyr/storage/flash_map.h>

Value:
COND_CODE_1(DT_NODE_HAS_COMPAT(node, zephyr_mapped_partition), \
(MAPPED_PARTITION_1(node)), \
(FIXED_PARTITION_1(node)))

Get pointer to flash_area object by partition node in DTS.

Parameters
nodeDTS node of a partition
Returns
Pointer to flash_area type object representing partition

◆ PARTITION_DEVICE

#define PARTITION_DEVICE ( label)

#include <zephyr/storage/flash_map.h>

Value:

Get device pointer for device the area/partition resides on.

Parameters
labelDTS node label of a partition
Returns
Pointer to a device.

◆ PARTITION_EXISTS

#define PARTITION_EXISTS ( label)

#include <zephyr/storage/flash_map.h>

Value:
#define DT_PARTITION_EXISTS(node_id)
Test if zephyr,mapped-partition, fixed-partitions or fixed-subpartitions compatible node exists.
Definition partitions.h:57

Returns non-0 value if partition of given DTS node label exists.

Parameters
labelDTS node label
Returns
non-0 if partition node exists and is enabled; 0 if node does not exist, is not enabled or is not partition.

◆ PARTITION_ID

#define PARTITION_ID ( label)

#include <zephyr/storage/flash_map.h>

Value:
COND_CODE_1(DT_NODE_HAS_COMPAT(DT_NODELABEL(label), zephyr_mapped_partition), \
#define DT_FIXED_PARTITION_ID(node_id)
Get a numeric identifier for a fixed partition.
Definition fixed-partitions.h:78
#define DT_MAPPED_PARTITION_ID(node_id)
Get a numeric identifier for a mapped partition.
Definition mapped-partition.h:86

Get flash area ID from partition DTS node label.

Parameters
labelDTS node label of a partition
Returns
flash area ID

◆ PARTITION_MTD

#define PARTITION_MTD ( label)

#include <zephyr/storage/flash_map.h>

Value:

Get the node identifier of the flash controller the area/partition resides on.

Parameters
labelDTS node label of a partition
Returns
Pointer to a device.

◆ PARTITION_NODE_ADDRESS

#define PARTITION_NODE_ADDRESS ( node)

#include <zephyr/storage/flash_map.h>

Value:
COND_CODE_1(DT_NODE_HAS_COMPAT(node, zephyr_mapped_partition), \
#define DT_FIXED_SUBPARTITION_EXISTS(node_id)
Test if fixed-subpartitions compatible node exists.
Definition fixed-partitions.h:142
#define DT_FIXED_SUBPARTITION_ADDR(node_id)
Get the absolute address of a fixed subpartition.
Definition fixed-partitions.h:209
#define DT_FIXED_PARTITION_ADDR(node_id)
Get the absolute address of a fixed partition.
Definition fixed-partitions.h:133
#define DT_MAPPED_PARTITION_ADDR(node_id)
Get the absolute address of a mapped partition.
Definition mapped-partition.h:141

Get partition address from DTS node.

Parameters
nodeDTS node of a partition
Returns
address, as defined for the partition in DTS.

◆ PARTITION_NODE_DEVICE

#define PARTITION_NODE_DEVICE ( node)

#include <zephyr/storage/flash_map.h>

Value:
COND_CODE_1(DT_NODE_HAS_COMPAT(node, zephyr_mapped_partition), \
#define DT_MTD_FROM_FIXED_SUBPARTITION(node_id)
Get the node identifier of the flash controller for a subpartition.
Definition fixed-partitions.h:161

Get device pointer for device the area/partition resides on.

Parameters
nodeDTS node of a partition
Returns
Pointer to a device.

◆ PARTITION_NODE_MTD

#define PARTITION_NODE_MTD ( node)

#include <zephyr/storage/flash_map.h>

Value:

Get the node identifier of the flash controller the area/partition resides on.

Parameters
nodeDTS node of a partition
Returns
Pointer to a device.

◆ PARTITION_NODE_OFFSET

#define PARTITION_NODE_OFFSET ( node)

#include <zephyr/storage/flash_map.h>

Value:
COND_CASE_1(DT_NODE_HAS_COMPAT(node, zephyr_mapped_partition), \
(DT_PROP_BY_IDX(DT_PARENT(node), reg, 0) + DT_PROP_BY_IDX(node, reg, 0)), \
((DT_PROP_BY_IDX(node, reg, 0))))
#define DT_PARENT(node_id)
Get a node identifier for a parent node.
Definition devicetree.h:375
#define DT_PROP_BY_IDX(node_id, prop, idx)
Get the value at index idx in an array type property.
Definition devicetree.h:944
#define DT_MAPPED_PARTITION_OFFSET(node_id)
Get the offset address of a mapped partition from the NVM node.
Definition mapped-partition.h:177
#define COND_CASE_1(...)
Evaluate a list of COND_CODE_1-style cases.
Definition util_macro.h:250

Get partition offset from DTS node.

Note: This only works from a top level fixed-partitions node, top level fixed-subpartitions node or fixed-partitions node inside of 1 layer of a fixed-subpartitions node, it will not work for multiple layers of fixed-subpartitions nodes, though this works on all instances of zephyr,mapped-partition nodes.

Parameters
nodeDTS node of a partition
Returns
offset, as defined for the partition in DTS.

◆ PARTITION_NODE_SIZE

#define PARTITION_NODE_SIZE ( node)

#include <zephyr/storage/flash_map.h>

Value:
#define DT_REG_SIZE(node_id)
Get a node's (only) register block size.
Definition devicetree.h:2530

Get fixed-partition size for DTS node.

Parameters
nodeDTS node of a partition
Returns
size, as defined for the partition in DTS.

◆ PARTITION_OFFSET

#define PARTITION_OFFSET ( label)

#include <zephyr/storage/flash_map.h>

Value:

Get partition offset from DTS node label.

Note: This only works from a top level fixed-partitions node, top level fixed-subpartitions node or fixed-partitions node inside of 1 layer of a fixed-subpartitions node, it will not work for multiple layers of fixed-subpartitions nodes, though this works on all instances of zephyr,mapped-partition nodes.

Parameters
labelDTS node label of a partition
Returns
offset, as defined for the partition in DTS.

◆ PARTITION_SIZE

#define PARTITION_SIZE ( label)

#include <zephyr/storage/flash_map.h>

Value:

Get partition size for DTS node label.

Parameters
labelDTS node label
Returns
size, as defined for the partition in DTS.

Typedef Documentation

◆ flash_area_cb_t

typedef void(* flash_area_cb_t) (const struct flash_area *fa, void *user_data)

#include <zephyr/storage/flash_map.h>

Flash map iteration callback.

Parameters
faflash area
user_dataUser supplied data

Function Documentation

◆ flash_area_align()

uint32_t flash_area_align ( const struct flash_area * fa)

#include <zephyr/storage/flash_map.h>

Get write block size of the flash area.

Currently write block size might be treated as read block size, although most of drivers supports unaligned readout.

Parameters
[in]faFlash area
Returns
Alignment restriction for flash writes in [B].

◆ flash_area_close()

void flash_area_close ( const struct flash_area * fa)

#include <zephyr/storage/flash_map.h>

Close flash_area.

Reserved for future usage and external projects compatibility reason. Currently is NOP.

Parameters
[in]faFlash area to be closed.

◆ flash_area_copy()

int flash_area_copy ( const struct flash_area * src_fa,
off_t src_off,
const struct flash_area * dst_fa,
off_t dst_off,
off_t len,
uint8_t * buf,
size_t buf_size )

#include <zephyr/storage/flash_map.h>

Copy flash memory from one flash area to another.

Copy data to flash area. Area boundaries are asserted before copy request.

For more information, see flash_copy().

Parameters
[in]src_faSource Flash area
[in]src_offOffset relative from beginning of source flash area.
[in]dst_faDestination Flash area
[in]dst_offOffset relative from beginning of destination flash area.
[in]lenNumber of bytes to copy, in bytes.
[out]bufPointer to a buffer of size buf_size.
[in]buf_sizeSize of the buffer pointed to by buf.
Returns
0 on success, negative errno code on fail.

◆ flash_area_device_is_ready()

ALWAYS_INLINE bool flash_area_device_is_ready ( const struct flash_area * fa)
static

#include <zephyr/storage/flash_map.h>

Verify that a device assigned to flash area is ready for use.

Indicates whether the provided flash area has a device known to be in a state where it can be used with Flash Map API.

This can be used with struct flash_area pointers captured from PARTITION(). At minimum this means that the device has been successfully initialized.

Parameters
fapointer to flash_area object to check.
Return values
trueIf the device is ready for use.
falseIf the device is not ready for use or if a NULL pointer is passed as flash area pointer or device pointer within flash area object is NULL.

◆ flash_area_erase()

int flash_area_erase ( const struct flash_area * fa,
off_t off,
size_t len )

#include <zephyr/storage/flash_map.h>

Erase flash area.

Erase given flash area range. Area boundaries are asserted before erase request. API has the same limitation regard erase-block alignment and size as wrapped flash driver.

Parameters
[in]faFlash area
[in]offOffset relative from beginning of flash area.
[in]lenNumber of bytes to be erase
Returns
0 on success, negative errno code on fail.

◆ flash_area_erased_val()

uint8_t flash_area_erased_val ( const struct flash_area * fa)

#include <zephyr/storage/flash_map.h>

Get the value expected to be read when accessing any erased flash byte.

This API is compatible with the MCUBoot's porting layer.

Parameters
faFlash area.
Returns
Byte value of erase memory.

◆ flash_area_flatten()

int flash_area_flatten ( const struct flash_area * fa,
off_t off,
size_t len )

#include <zephyr/storage/flash_map.h>

Erase flash area or fill with erase-value.

On program-erase devices this function behaves exactly like flash_area_erase. On RAM non-volatile device it will call erase, if driver provides such callback, or will fill given range with erase-value defined by driver. This function should be only used by code that has not been written to directly support devices that do not require erase and rely on device being erased prior to some operations. Note that emulated erase, on devices that do not require, is done via write, which affects endurance of device.

See also
flash_area_erase()
flash_flatten()
Parameters
[in]faFlash area
[in]offOffset relative from beginning of flash area.
[in]lenNumber of bytes to be erase
Returns
0 on success, negative errno code on fail.

◆ flash_area_foreach()

void flash_area_foreach ( flash_area_cb_t user_cb,
void * user_data )

#include <zephyr/storage/flash_map.h>

Iterate over flash map.

Parameters
user_cbUser callback
user_dataUser supplied data

◆ flash_area_get_device()

const struct device * flash_area_get_device ( const struct flash_area * fa)

#include <zephyr/storage/flash_map.h>

Get driver for given flash area.

Parameters
[in]faFlash area.
Returns
device driver.

◆ flash_area_get_sectors()

int flash_area_get_sectors ( int fa_id,
uint32_t * count,
struct flash_sector * sectors )

#include <zephyr/storage/flash_map.h>

Retrieve info about sectors within the area.

Parameters
[in]fa_idGiven flash area ID
[in,out]countOn input Capacity of sectors, on output number of sectors Retrieved.
[out]sectorsbuffer for sectors data
Returns
0 on success, negative errno code on fail. Especially returns -ENOMEM if There are too many flash pages on the flash_area to fit in the array.

◆ flash_area_has_driver()

int flash_area_has_driver ( const struct flash_area * fa)

#include <zephyr/storage/flash_map.h>

Check whether given flash area has supporting flash driver in the system.

Parameters
[in]faFlash area.
Returns
1 On success. -ENODEV if no driver match.

◆ flash_area_open()

int flash_area_open ( uint8_t id,
const struct flash_area ** fa )

#include <zephyr/storage/flash_map.h>

Retrieve partitions flash area from the flash_map.

Function Retrieves flash_area from flash_map for given partition.

Parameters
[in]idID of the flash partition.
[out]faPointer which has to reference flash_area. If ID is unknown, it will be NULL on output.
Returns
0 on success, -EACCES if the flash_map is not available , -ENOENT if ID is unknown, -ENODEV if there is no driver attached to the area.

◆ flash_area_read()

int flash_area_read ( const struct flash_area * fa,
off_t off,
void * dst,
size_t len )

#include <zephyr/storage/flash_map.h>

Read flash area data.

Read data from flash area. Area readout boundaries are asserted before read request. API has the same limitation regard read-block alignment and size as wrapped flash driver.

Parameters
[in]faFlash area
[in]offOffset relative from beginning of flash area to read
[out]dstBuffer to store read data
[in]lenNumber of bytes to read
Returns
0 on success, negative errno code on fail.

◆ flash_area_sectors()

int flash_area_sectors ( const struct flash_area * fa,
uint32_t * count,
struct flash_sector * sectors )

#include <zephyr/storage/flash_map.h>

Retrieve info about sectors within the area.

Parameters
[in]fapointer to flash area object.
[in,out]countOn input Capacity of sectors, on output number of sectors retrieved.
[out]sectorsbuffer for sectors data
Returns
0 on success, negative errno code on fail. Especially returns -ENOMEM if There are too many flash pages on the flash_area to fit in the array.

◆ flash_area_write()

int flash_area_write ( const struct flash_area * fa,
off_t off,
const void * src,
size_t len )

#include <zephyr/storage/flash_map.h>

Write data to flash area.

Write data to flash area. Area write boundaries are asserted before write request. API has the same limitation regard write-block alignment and size as wrapped flash driver.

Parameters
[in]faFlash area
[in]offOffset relative from beginning of flash area to write
[in]srcBuffer with data to be written
[in]lenNumber of bytes to write
Returns
0 on success, negative errno code on fail.