Zephyr API Documentation
2.7.0-rc2
A Scalable Open Source RTOS
|
FLASH Interface. More...
Data Structures | |
struct | flash_parameters |
struct | flash_pages_info |
Typedefs | |
typedef bool(* | flash_page_cb) (const struct flash_pages_info *info, void *data) |
Callback type for iterating over flash pages present on a device. More... | |
Functions | |
int | flash_read (const struct device *dev, off_t offset, void *data, size_t len) |
Read data from flash. More... | |
int | flash_write (const struct device *dev, off_t offset, const void *data, size_t len) |
Write buffer into flash memory. More... | |
int | flash_erase (const struct device *dev, off_t offset, size_t size) |
Erase part or all of a flash memory. More... | |
int | flash_write_protection_set (const struct device *dev, bool enable) |
Enable or disable write protection for a flash memory. More... | |
int | flash_get_page_info_by_offs (const struct device *dev, off_t offset, struct flash_pages_info *info) |
Get the size and start offset of flash page at certain flash offset. More... | |
int | flash_get_page_info_by_idx (const struct device *dev, uint32_t page_index, struct flash_pages_info *info) |
Get the size and start offset of flash page of certain index. More... | |
size_t | flash_get_page_count (const struct device *dev) |
Get the total number of flash pages. More... | |
void | flash_page_foreach (const struct device *dev, flash_page_cb cb, void *data) |
Iterate over all flash pages on a device. More... | |
int | flash_sfdp_read (const struct device *dev, off_t offset, void *data, size_t len) |
Read data from Serial Flash Discoverable Parameters. More... | |
int | flash_read_jedec_id (const struct device *dev, uint8_t *id) |
Read the JEDEC ID from a compatible flash device. More... | |
size_t | flash_get_write_block_size (const struct device *dev) |
Get the minimum write block size supported by the driver. More... | |
const struct flash_parameters * | flash_get_parameters (const struct device *dev) |
Get pointer to flash_parameters structure. More... | |
FLASH Interface.
typedef bool(* flash_page_cb) (const struct flash_pages_info *info, void *data) |
#include <include/drivers/flash.h>
Callback type for iterating over flash pages present on a device.
The callback should return true to continue iterating, and false to halt.
info | Information for current page |
data | Private data for callback |
int flash_erase | ( | const struct device * | dev, |
off_t | offset, | ||
size_t | size | ||
) |
#include <include/drivers/flash.h>
Erase part or all of a flash memory.
Acceptable values of erase size and offset are subject to hardware-specific multiples of page size and offset. Please check the API implemented by the underlying sub driver, for example by using flash_get_page_info_by_offs() if that is supported by your flash driver.
Any necessary erase protection management is performed by the driver erase implementation itself.
dev | : flash device |
offset | : erase area starting offset |
size | : size of area to be erased |
size_t flash_get_page_count | ( | const struct device * | dev | ) |
#include <include/drivers/flash.h>
Get the total number of flash pages.
dev | flash device |
int flash_get_page_info_by_idx | ( | const struct device * | dev, |
uint32_t | page_index, | ||
struct flash_pages_info * | info | ||
) |
#include <include/drivers/flash.h>
Get the size and start offset of flash page of certain index.
dev | flash device |
page_index | Index of the page. Index are counted from 0. |
info | Page Info structure to be filled |
int flash_get_page_info_by_offs | ( | const struct device * | dev, |
off_t | offset, | ||
struct flash_pages_info * | info | ||
) |
#include <include/drivers/flash.h>
Get the size and start offset of flash page at certain flash offset.
dev | flash device |
offset | Offset within the page |
info | Page Info structure to be filled |
const struct flash_parameters * flash_get_parameters | ( | const struct device * | dev | ) |
#include <include/drivers/flash.h>
Get pointer to flash_parameters structure.
Returned pointer points to a structure that should be considered constant through a runtime, regardless if it is defined in RAM or Flash. Developer is free to cache the structure pointer or copy its contents.
size_t flash_get_write_block_size | ( | const struct device * | dev | ) |
#include <include/drivers/flash.h>
Get the minimum write block size supported by the driver.
The write block size supported by the driver might differ from the write block size of memory used because the driver might implements write-modify algorithm.
dev | flash device |
void flash_page_foreach | ( | const struct device * | dev, |
flash_page_cb | cb, | ||
void * | data | ||
) |
#include <include/drivers/flash.h>
Iterate over all flash pages on a device.
This routine iterates over all flash pages on the given device, ordered by increasing start offset. For each page, it invokes the given callback, passing it the page's information and a private data object.
dev | Device whose pages to iterate over |
cb | Callback to invoke for each flash page |
data | Private data for callback function |
#include <include/drivers/flash.h>
Read data from flash.
All flash drivers support reads without alignment restrictions on the read offset, the read size, or the destination address.
dev | : flash dev |
offset | : Offset (byte aligned) to read |
data | : Buffer to store read data |
len | : Number of bytes to read. |
#include <include/drivers/flash.h>
Read the JEDEC ID from a compatible flash device.
dev | device from which id will be read |
id | pointer to a buffer of at least 3 bytes into which id will be stored |
0 | on successful store of 3-byte JEDEC id |
-ENOTSUP | if flash driver doesn't support this function |
negative | values for other errors |
#include <include/drivers/flash.h>
Read data from Serial Flash Discoverable Parameters.
This routine reads data from a serial flash device compatible with the JEDEC JESD216 standard for encoding flash memory characteristics.
Availability of this API is conditional on selecting CONFIG_FLASH_JESD216_API
and support of that functionality in the driver underlying dev
.
dev | device from which parameters will be read |
offset | address within the SFDP region containing data of interest |
data | where the data to be read will be placed |
len | the number of bytes of data to be read |
0 | on success |
-ENOTSUP | if the flash driver does not support SFDP access |
negative | values for other errors. |
#include <include/drivers/flash.h>
Write buffer into flash memory.
All flash drivers support a source buffer located either in RAM or SoC flash, without alignment restrictions on the source address. Write size and offset must be multiples of the minimum write block size supported by the driver.
Any necessary write protection management is performed by the driver write implementation itself.
dev | : flash device |
offset | : starting offset for the write |
data | : data to write |
len | : Number of bytes to write |
#include <include/drivers/flash.h>
Enable or disable write protection for a flash memory.
This API is deprecated and will be removed in Zephyr 2.8. It will be keep as No-Operation until removal. Flash write/erase protection management has been moved to write and erase operations implementations in flash driver shims. For Out-of-tree drivers which are not updated yet flash write/erase protection management is done in flash_erase() and flash_write() using deprecated
write_protection
shim handler.
dev | : flash device |
enable | : enable or disable flash write protection |