From bc50bd2806d4485d7d4917fbc0b6892a81dbe9b8 Mon Sep 17 00:00:00 2001 From: KonstantinKondrashov Date: Fri, 24 Apr 2020 02:13:17 +0800 Subject: [PATCH] spi_flash(new driver): Add a Kconfig option - Bypass a block erase and always do sector erase Closes: IDF-1561 --- components/spi_flash/esp_flash_api.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/spi_flash/esp_flash_api.c b/components/spi_flash/esp_flash_api.c index 3dd70b4bf6..5bcdc20b0e 100644 --- a/components/spi_flash/esp_flash_api.c +++ b/components/spi_flash/esp_flash_api.c @@ -351,13 +351,15 @@ esp_err_t IRAM_ATTR esp_flash_erase_region(esp_flash_t *chip, uint32_t start, ui return err; } +#ifndef CONFIG_SPI_FLASH_BYPASS_BLOCK_ERASE // If possible erase an entire multi-sector block if (block_erase_size > 0 && len >= block_erase_size && (start % block_erase_size) == 0) { err = chip->chip_drv->erase_block(chip, start); start += block_erase_size; len -= block_erase_size; - } - else { + } else +#endif + { // Otherwise erase individual sector only err = chip->chip_drv->erase_sector(chip, start); start += sector_size;