mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
spi_flash: fix erase_range for block erase check
Erase in block (64k) as much as possible, before falling back to sector (4k) erase. Signed-off-by: Mahavir Jain <mahavir@espressif.com>
This commit is contained in:
parent
1cbdfcc493
commit
401c940434
@ -218,7 +218,7 @@ esp_err_t IRAM_ATTR spi_flash_erase_range(uint32_t start_addr, uint32_t size)
|
|||||||
if (rc == ESP_ROM_SPIFLASH_RESULT_OK) {
|
if (rc == ESP_ROM_SPIFLASH_RESULT_OK) {
|
||||||
for (size_t sector = start; sector != end && rc == ESP_ROM_SPIFLASH_RESULT_OK; ) {
|
for (size_t sector = start; sector != end && rc == ESP_ROM_SPIFLASH_RESULT_OK; ) {
|
||||||
spi_flash_guard_start();
|
spi_flash_guard_start();
|
||||||
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user