Flash¶
Overview¶
API Reference¶
-
group
flash_interface
FLASH Interface.
Typedefs
Functions
-
int
flash_read
(struct device *dev, off_t offset, void *data, size_t len)¶ Read data from flash.
- Return
- 0 on success, negative errno code on fail.
- Parameters
dev
: : flash devoffset
: : Offset (byte aligned) to readdata
: : Buffer to store read datalen
: : Number of bytes to read.
-
int
flash_write
(struct device *dev, off_t offset, const void *data, size_t len)¶ Write buffer into flash memory.
Prior to the invocation of this API, the flash_write_protection_set needs to be called first to disable the write protection.
- Return
- 0 on success, negative errno code on fail.
- Parameters
dev
: : flash deviceoffset
: : starting offset for the writedata
: : data to writelen
: : Number of bytes to write
-
int
flash_erase
(struct device *dev, off_t offset, size_t size)¶ 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.
Prior to the invocation of this API, the flash_write_protection_set needs to be called first to disable the write protection.
- Return
- 0 on success, negative errno code on fail.
- See
- flash_get_page_info_by_offs()
- See
- flash_get_page_info_by_idx()
- Parameters
dev
: : flash deviceoffset
: : erase area starting offsetsize
: : size of area to be erased
-
int
flash_write_protection_set
(struct device *dev, bool enable)¶ Enable or disable write protection for a flash memory.
This API is required to be called before the invocation of write or erase API. Please note that on some flash components, the write protection is automatically turned on again by the device after the completion of each write or erase calls. Therefore, on those flash parts, write protection needs to be disabled before each invocation of the write or erase API. Please refer to the sub-driver API or the data sheet of the flash component to get details on the write protection behavior.
- Return
- 0 on success, negative errno code on fail.
- Parameters
dev
: : flash deviceenable
: : enable or disable flash write protection
-
size_t
flash_get_write_block_size
(struct device *dev)¶ 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.
- Return
- write block size in bytes.
- Parameters
dev
: flash device
-
int