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:
KonstantinKondrashov
2020-04-24 02:09:15 +08:00
parent 0f6fe0c8e9
commit 304f67e42a
2 changed files with 12 additions and 1 deletions

View File

@@ -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();
#endif
spi_flash_guard_start();
#ifndef CONFIG_SPI_FLASH_BYPASS_BLOCK_ERASE
if (sector % sectors_per_block == 0 && end - sector >= sectors_per_block) {
rc = esp_rom_spiflash_erase_block(sector / sectors_per_block);
sector += sectors_per_block;
COUNTER_ADD_BYTES(erase, sectors_per_block * SPI_FLASH_SEC_SIZE);
} else {
} else
#endif
{
rc = esp_rom_spiflash_erase_sector(sector);
++sector;
COUNTER_ADD_BYTES(erase, SPI_FLASH_SEC_SIZE);