mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/esp_flash_erase_timeout' into 'master'
esp_flash: change timeout threshold and can close timeout Closes IDF-2023 See merge request espressif/esp-idf!10138
This commit is contained in:
commit
3c167497ad
@ -149,6 +149,14 @@ menu "SPI Flash driver"
|
||||
Enable this option to override flash size with latest ESPTOOLPY_FLASHSIZE value from
|
||||
the app header if the size in the bootloader header is incorrect.
|
||||
|
||||
config SPI_FLASH_CHECK_ERASE_TIMEOUT_DISABLED
|
||||
bool "Flash timeout checkout disabled"
|
||||
depends on !SPI_FLASH_USE_LEGACY_IMPL
|
||||
default n
|
||||
help
|
||||
This option is helpful if you are using a flash chip whose timeout is quite large or unpredictable.
|
||||
|
||||
|
||||
menu "Auto-detect flash chips"
|
||||
|
||||
config SPI_FLASH_SUPPORT_ISSI_CHIP
|
||||
|
@ -188,6 +188,7 @@ esp_err_t spi_flash_chip_generic_set_write_protect(esp_flash_t *chip, bool write
|
||||
*/
|
||||
esp_err_t spi_flash_chip_generic_get_write_protect(esp_flash_t *chip, bool *out_write_protect);
|
||||
|
||||
#define ESP_FLASH_CHIP_GENERIC_NO_TIMEOUT -1
|
||||
/**
|
||||
* @brief Read flash status via the RDSR command and wait for bit 0 (write in
|
||||
* progress bit) to be cleared.
|
||||
|
@ -47,8 +47,8 @@ DRAM_ATTR flash_chip_dummy_t *rom_flash_chip_dummy = (flash_chip_dummy_t *)&defa
|
||||
|
||||
#define SPI_FLASH_DEFAULT_IDLE_TIMEOUT_MS 200
|
||||
#define SPI_FLASH_GENERIC_CHIP_ERASE_TIMEOUT_MS 4000
|
||||
#define SPI_FLASH_GENERIC_SECTOR_ERASE_TIMEOUT_MS 500 //according to GD25Q127 + 100ms
|
||||
#define SPI_FLASH_GENERIC_BLOCK_ERASE_TIMEOUT_MS 1300 //according to GD25Q127 + 100ms
|
||||
#define SPI_FLASH_GENERIC_SECTOR_ERASE_TIMEOUT_MS 600 //according to GD25Q127(125°) + 100ms
|
||||
#define SPI_FLASH_GENERIC_BLOCK_ERASE_TIMEOUT_MS 4100 //according to GD25Q127(125°) + 100ms
|
||||
#define SPI_FLASH_GENERIC_PAGE_PROGRAM_TIMEOUT_MS 500
|
||||
|
||||
#define HOST_DELAY_INTERVAL_US 1
|
||||
@ -126,7 +126,11 @@ esp_err_t spi_flash_chip_generic_erase_chip(esp_flash_t *chip)
|
||||
return err;
|
||||
}
|
||||
}
|
||||
#ifdef CONFIG_SPI_FLASH_CHECK_ERASE_TIMEOUT_DISABLED
|
||||
err = chip->chip_drv->wait_idle(chip, ESP_FLASH_CHIP_GENERIC_NO_TIMEOUT);
|
||||
#else
|
||||
err = chip->chip_drv->wait_idle(chip, chip->chip_drv->timeout->chip_erase_timeout);
|
||||
#endif
|
||||
}
|
||||
return err;
|
||||
}
|
||||
@ -146,7 +150,11 @@ esp_err_t spi_flash_chip_generic_erase_sector(esp_flash_t *chip, uint32_t start_
|
||||
return err;
|
||||
}
|
||||
}
|
||||
#ifdef CONFIG_SPI_FLASH_CHECK_ERASE_TIMEOUT_DISABLED
|
||||
err = chip->chip_drv->wait_idle(chip, ESP_FLASH_CHIP_GENERIC_NO_TIMEOUT);
|
||||
#else
|
||||
err = chip->chip_drv->wait_idle(chip, chip->chip_drv->timeout->sector_erase_timeout);
|
||||
#endif
|
||||
}
|
||||
return err;
|
||||
}
|
||||
@ -166,7 +174,11 @@ esp_err_t spi_flash_chip_generic_erase_block(esp_flash_t *chip, uint32_t start_a
|
||||
return err;
|
||||
}
|
||||
}
|
||||
#ifdef CONFIG_SPI_FLASH_CHECK_ERASE_TIMEOUT_DISABLED
|
||||
err = chip->chip_drv->wait_idle(chip, ESP_FLASH_CHIP_GENERIC_NO_TIMEOUT);
|
||||
#else
|
||||
err = chip->chip_drv->wait_idle(chip, chip->chip_drv->timeout->block_erase_timeout);
|
||||
#endif
|
||||
}
|
||||
return err;
|
||||
}
|
||||
@ -303,6 +315,10 @@ esp_err_t spi_flash_generic_wait_host_idle(esp_flash_t *chip, uint32_t *timeout_
|
||||
|
||||
esp_err_t spi_flash_chip_generic_wait_idle(esp_flash_t *chip, uint32_t timeout_us)
|
||||
{
|
||||
bool timeout_en = (timeout_us != ESP_FLASH_CHIP_GENERIC_NO_TIMEOUT);
|
||||
if (timeout_us == ESP_FLASH_CHIP_GENERIC_NO_TIMEOUT) {
|
||||
timeout_us = 0;// In order to go into while
|
||||
}
|
||||
timeout_us++; // allow at least one pass before timeout, last one has no sleep cycle
|
||||
|
||||
uint8_t status = 0;
|
||||
@ -324,7 +340,9 @@ esp_err_t spi_flash_chip_generic_wait_idle(esp_flash_t *chip, uint32_t timeout_u
|
||||
if (timeout_us > 0 && interval > 0) {
|
||||
int delay = MIN(interval, timeout_us);
|
||||
chip->os_func->delay_us(chip->os_func_data, delay);
|
||||
timeout_us -= delay;
|
||||
if (timeout_en) {
|
||||
timeout_us -= delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user