Skip to content

Commit

Permalink
Merge branch 'feature/spi_flash_auto_suspend_default_on_c3' into 'mas…
Browse files Browse the repository at this point in the history
…ter'

spi_flash: make the auto_suspend default y on C3

See merge request espressif/esp-idf!12233
  • Loading branch information
ginkgm committed Feb 9, 2021
2 parents b88ec36 + b1d3d0a commit 2c0962f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
16 changes: 10 additions & 6 deletions components/spi_flash/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ menu "SPI Flash driver"
If making this as "y" in your project, you will increase free IRAM.
But you may miss out on some flash features and support for new flash chips.

Currently the ROM cannot support the following features:

- SPI_FLASH_AUTO_SUSPEND (C3, S3)

choice SPI_FLASH_DANGEROUS_WRITE
bool "Writing to dangerous flash regions"
default SPI_FLASH_DANGEROUS_WRITE_ABORTS
Expand Down Expand Up @@ -145,14 +149,14 @@ menu "SPI Flash driver"

config SPI_FLASH_AUTO_SUSPEND
bool "Auto suspend long erase/write operations"
default n
default n if !IDF_TARGET_ESP32C3
default y if IDF_TARGET_ESP32C3
depends on IDF_TARGET_ESP32C3 && !SPI_FLASH_USE_LEGACY_IMPL && !SPI_FLASH_ROM_IMPL
help
This is made default n, because this needs bootloader support.
This feature needs special bootloader support.
If you want to OTA to a image with this feature
(e.g. turn on this config option for OTA image), please make
sure the bootloader has the support for it. (above IDF v4.3)
This option is default n before ESP32-C3, because it needs bootloader support.

CAUTION: If you want to OTA to an app with this feature turned on, please make
sure the bootloader has the support for it. (later than IDF v4.3)

config SPI_FLASH_WRITE_CHUNK_SIZE
int "Flash write chunk size"
Expand Down
13 changes: 6 additions & 7 deletions components/spi_flash/test/test_esp_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,10 +638,12 @@ void esp_test_for_suspend(void)
printf("aaaaa bbbbb zzzzz fffff qqqqq ccccc\n");
}

static volatile bool task_erase_end, task_suspend_end = false;
void task_erase_large_region(void *arg)
{
esp_partition_t *part = (esp_partition_t *)arg;
test_erase_large_region(part);
task_erase_end = true;
vTaskDelete(NULL);
}

Expand All @@ -650,20 +652,17 @@ void task_request_suspend(void *arg)
vTaskDelay(2);
ESP_LOGI(TAG, "flash go into suspend");
esp_test_for_suspend();
vTaskDelete(NULL);
}

void task_delay(void *arg)
{
esp_rom_delay_us(2000000);
task_suspend_end = true;
vTaskDelete(NULL);
}

static void test_flash_suspend_resume(const esp_partition_t* part)
{
xTaskCreatePinnedToCore(task_request_suspend, "suspend", 2048, (void *)"test_for_suspend", UNITY_FREERTOS_PRIORITY + 3, NULL, 0);
xTaskCreatePinnedToCore(task_erase_large_region, "test", 2048, (void *)part, UNITY_FREERTOS_PRIORITY + 2, NULL, 0);
xTaskCreatePinnedToCore(task_delay, "task_delay", 1024, (void *)"task_delay", UNITY_FREERTOS_PRIORITY + 1, NULL, 0);
while (!task_erase_end || !task_suspend_end) {
}
vTaskDelay(200);
}

FLASH_TEST_CASE("SPI flash suspend and resume test", test_flash_suspend_resume);
Expand Down

0 comments on commit 2c0962f

Please sign in to comment.