Skip to content

Commit a9c8895

Browse files
committed
esp_flash: refactor to be compatible with the latest ROM
Including: 1. Change the write bytes/read bytes parameter in the host driver into slicers to meet the requirements of complicated cases. 2. Refactor the esp_flash_api code a bit so that we can use the code in the ROM laster 3. Provide get_temp_buffer and release_temp_buffer in the os_functions when the buffer passed by application cannot be used directly. 4. Make timeout of operations configurable in the chip_driver. 5. Make dummy number configurable.
1 parent 9d21b17 commit a9c8895

13 files changed

+390
-168
lines changed

components/soc/include/hal/spi_flash_types.h

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,36 @@ struct spi_flash_host_driver_t {
115115
* Program a page of the flash. Check ``max_write_bytes`` for the maximum allowed writing length.
116116
*/
117117
void (*program_page)(spi_flash_host_driver_t *driver, const void *buffer, uint32_t address, uint32_t length);
118-
/** Check whether need to allocate new buffer to write */
118+
/** Check whether given buffer can be directly used to write */
119119
bool (*supports_direct_write)(spi_flash_host_driver_t *driver, const void *p);
120-
/** Check whether need to allocate new buffer to read */
121-
bool (*supports_direct_read)(spi_flash_host_driver_t *driver, const void *p);
122-
/** maximum length of program_page */
123-
int max_write_bytes;
120+
/**
121+
* Slicer for write data. The `program_page` should be called iteratively with the return value
122+
* of this function.
123+
*
124+
* @param address Beginning flash address to write
125+
* @param len Length request to write
126+
* @param align_addr Output of the aligned address to write to
127+
* @param page_size Physical page size of the flash chip
128+
* @return Length that can be actually written in one `program_page` call
129+
*/
130+
int (*write_data_slicer)(uint32_t address, uint32_t len, uint32_t *align_addr, uint32_t page_size);
124131
/**
125132
* Read data from the flash. Check ``max_read_bytes`` for the maximum allowed reading length.
126133
*/
127134
esp_err_t (*read)(spi_flash_host_driver_t *driver, void *buffer, uint32_t address, uint32_t read_len);
128-
/** maximum length of read */
129-
int max_read_bytes;
135+
/** Check whether given buffer can be directly used to read */
136+
bool (*supports_direct_read)(spi_flash_host_driver_t *driver, const void *p);
137+
/**
138+
* Slicer for read data. The `read` should be called iteratively with the return value
139+
* of this function.
140+
*
141+
* @param address Beginning flash address to read
142+
* @param len Length request to read
143+
* @param align_addr Output of the aligned address to read
144+
* @param page_size Physical page size of the flash chip
145+
* @return Length that can be actually read in one `read` call
146+
*/
147+
int (*read_data_slicer)(uint32_t address, uint32_t len, uint32_t *align_addr, uint32_t page_size);
130148
/**
131149
* Check whether the host is idle to perform new operations.
132150
*/

0 commit comments

Comments
 (0)