mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
spi_flash(LEGACY_IMPL): Add a Kconfig option - Bypass a block erase and always do sector erase
Closes: IDF-1561
This commit is contained in:
parent
0f6fe0c8e9
commit
304f67e42a
@ -100,6 +100,14 @@ menu "SPI Flash driver"
|
|||||||
this option, and the lock will be bypassed on SPI1 bus. Otherwise if extra devices
|
this option, and the lock will be bypassed on SPI1 bus. Otherwise if extra devices
|
||||||
are needed to attach to SPI1 bus, enable this option.
|
are needed to attach to SPI1 bus, enable this option.
|
||||||
|
|
||||||
|
config SPI_FLASH_BYPASS_BLOCK_ERASE
|
||||||
|
bool "Bypass a block erase and always do sector erase"
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
Some flash chips can have very high "max" erase times, especially for block erase (32KB or 64KB).
|
||||||
|
This option allows to bypass "block erase" and always do sector erase commands.
|
||||||
|
This will be much slower overall in most cases, but improves latency for other code to run.
|
||||||
|
|
||||||
config SPI_FLASH_YIELD_DURING_ERASE
|
config SPI_FLASH_YIELD_DURING_ERASE
|
||||||
bool "Enables yield operation during flash erase"
|
bool "Enables yield operation during flash erase"
|
||||||
default y
|
default y
|
||||||
|
@ -247,11 +247,14 @@ esp_err_t IRAM_ATTR spi_flash_erase_range(size_t start_addr, size_t size)
|
|||||||
int64_t start_time_us = esp_timer_get_time();
|
int64_t start_time_us = esp_timer_get_time();
|
||||||
#endif
|
#endif
|
||||||
spi_flash_guard_start();
|
spi_flash_guard_start();
|
||||||
|
#ifndef CONFIG_SPI_FLASH_BYPASS_BLOCK_ERASE
|
||||||
if (sector % sectors_per_block == 0 && end - sector >= sectors_per_block) {
|
if (sector % sectors_per_block == 0 && end - sector >= sectors_per_block) {
|
||||||
rc = esp_rom_spiflash_erase_block(sector / sectors_per_block);
|
rc = esp_rom_spiflash_erase_block(sector / sectors_per_block);
|
||||||
sector += sectors_per_block;
|
sector += sectors_per_block;
|
||||||
COUNTER_ADD_BYTES(erase, sectors_per_block * SPI_FLASH_SEC_SIZE);
|
COUNTER_ADD_BYTES(erase, sectors_per_block * SPI_FLASH_SEC_SIZE);
|
||||||
} else {
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
rc = esp_rom_spiflash_erase_sector(sector);
|
rc = esp_rom_spiflash_erase_sector(sector);
|
||||||
++sector;
|
++sector;
|
||||||
COUNTER_ADD_BYTES(erase, SPI_FLASH_SEC_SIZE);
|
COUNTER_ADD_BYTES(erase, SPI_FLASH_SEC_SIZE);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user