From a0573f5b9f51bca1b5675851c3866c4112658333 Mon Sep 17 00:00:00 2001 From: "Michael (XIAO Xufeng)" Date: Tue, 2 Feb 2021 12:34:28 +0800 Subject: [PATCH 1/2] spi_flash: make the auto_suspend default y on C3 --- components/spi_flash/Kconfig | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/components/spi_flash/Kconfig b/components/spi_flash/Kconfig index 4ca5742be6..1853d0cc6c 100644 --- a/components/spi_flash/Kconfig +++ b/components/spi_flash/Kconfig @@ -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 @@ -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" From b1d3d0ac744ecd72765f9cd102758dcb21c2a9ff Mon Sep 17 00:00:00 2001 From: Cao Sen Miao Date: Tue, 2 Feb 2021 16:46:55 +0800 Subject: [PATCH 2/2] suspend_test: delay more time for erase --- components/spi_flash/test/test_esp_flash.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/components/spi_flash/test/test_esp_flash.c b/components/spi_flash/test/test_esp_flash.c index 94810e3963..fef787ebbf 100644 --- a/components/spi_flash/test/test_esp_flash.c +++ b/components/spi_flash/test/test_esp_flash.c @@ -628,10 +628,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); } @@ -640,12 +642,7 @@ 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); } @@ -653,7 +650,9 @@ 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);