test(spi_flash): Flash suspend test evolution

This commit is contained in:
C.S.M
2025-03-07 15:13:56 +08:00
parent 6c3d67b234
commit 9aba44a2d9
14 changed files with 42 additions and 14 deletions

View File

@@ -34,6 +34,10 @@ if(CONFIG_SOC_I2C_SUPPORT_SLAVE)
endif() endif()
endif() endif()
if(NOT CONFIG_I2C_MASTER_ISR_HANDLER_IN_IRAM)
list(APPEND srcs "test_i2c_flash_text.c")
endif()
idf_component_register(SRCS ${srcs} idf_component_register(SRCS ${srcs}
PRIV_REQUIRES unity driver test_utils PRIV_REQUIRES unity driver test_utils
WHOLE_ARCHIVE) WHOLE_ARCHIVE)

View File

@@ -32,7 +32,7 @@ void spi_flash_suspend_test_task(void *arg)
{ {
spi_flash_test_context_t *context = (spi_flash_test_context_t *)arg; spi_flash_test_context_t *context = (spi_flash_test_context_t *)arg;
uint32_t cnt = 200; uint32_t cnt = 20;
while (cnt--) { while (cnt--) {
if (context->flash_handle->suspend_times != 0) { if (context->flash_handle->suspend_times != 0) {
break; break;
@@ -120,7 +120,7 @@ TEST_CASE("Flash suspend support on i2c", "[i2c]")
// Quit when suspend is triggered. // Quit when suspend is triggered.
xTaskCreatePinnedToCore(spi_flash_suspend_test_task, "flash_task", 4096, context, 2, NULL, 0); xTaskCreatePinnedToCore(spi_flash_suspend_test_task, "flash_task", 4096, context, 2, NULL, 0);
xSemaphoreTake(context->sem, pdMS_TO_TICKS(5000)); // We don't always wait the semaphore xSemaphoreTake(context->sem, portMAX_DELAY);
printf("test finishes, suspend for %ld times\n", context->flash_handle->suspend_times); printf("test finishes, suspend for %ld times\n", context->flash_handle->suspend_times);
TEST_ASSERT_NOT_EQUAL(0, context->flash_handle->suspend_times); TEST_ASSERT_NOT_EQUAL(0, context->flash_handle->suspend_times);

View File

@@ -51,3 +51,20 @@ def test_i2c_multi_device(case_tester) -> None: # type: ignore
for case in case_tester.test_menu: for case in case_tester.test_menu:
if case.attributes.get('test_env', 'generic_multi_device') == 'generic_multi_device': if case.attributes.get('test_env', 'generic_multi_device') == 'generic_multi_device':
case_tester.run_multi_dev_case(case=case, reset=True) case_tester.run_multi_dev_case(case=case, reset=True)
@pytest.mark.flash_suspend
@pytest.mark.parametrize(
'config',
[
'i2c_isr_flash',
],
indirect=True,
)
@idf_parametrize(
'target',
['esp32c3'],
indirect=['target'],
)
def test_flash_auto_suspend_for_i2c(dut: Dut) -> None:
dut.run_all_single_board_cases(timeout=30)

View File

@@ -0,0 +1,4 @@
CONFIG_I2C_MASTER_ISR_HANDLER_IN_IRAM=n
CONFIG_SPI_FLASH_AUTO_SUSPEND=y
# Now the runners are massively using xmc-c chips, to be removed when xmc-d goes massive production.
CONFIG_SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND=y

View File

@@ -124,8 +124,8 @@ menu "Main Flash configuration"
bool "Enable chip suspend feature on c6 or h2 anyway (DO NOT ENABLE FOR NEW USERS OR APPLICATIONS)" bool "Enable chip suspend feature on c6 or h2 anyway (DO NOT ENABLE FOR NEW USERS OR APPLICATIONS)"
default n default n
help help
Flash suspend has defect on ESP32C6 until v0.2 and ESP32H2 until v1.2. If you already use suspend Flash suspend has a defect on ESP32C6 until v0.2 and ESP32H2 until v1.2. If you already use suspend
feature for massive protection, you can enable this for bypassing check after knowing the risk. feature for mass production, you can enable this for bypassing check after knowing the risk.
But if you are new users, or developing new applications, or producing a new batch, But if you are new users, or developing new applications, or producing a new batch,
please DO NOT enable this config option. please DO NOT enable this config option.

View File

@@ -2,3 +2,5 @@
CONFIG_IDF_TARGET="esp32c3" CONFIG_IDF_TARGET="esp32c3"
CONFIG_SPI_FLASH_AUTO_SUSPEND=y CONFIG_SPI_FLASH_AUTO_SUSPEND=y
# Now the runners are massively using xmc-c chips, to be removed when xmc-d goes massive production.
CONFIG_SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND=y

View File

@@ -1,12 +1,6 @@
set(srcs "test_app_main.c" set(srcs "test_app_main.c"
"test_flash_suspend.c") "test_flash_suspend.c")
if(NOT CONFIG_I2C_MASTER_ISR_HANDLER_IN_IRAM)
list(APPEND srcs "test_i2c_flash_text.c")
endif()
# In order for the cases defined by `TEST_CASE` to be linked into the final elf, # In order for the cases defined by `TEST_CASE` to be linked into the final elf,
# the component can be registered as WHOLE_ARCHIVE # the component can be registered as WHOLE_ARCHIVE
idf_component_register(SRCS ${srcs} idf_component_register(SRCS ${srcs}

View File

@@ -9,7 +9,7 @@
#include "esp_heap_caps.h" #include "esp_heap_caps.h"
// Some resources are lazy allocated, the threshold is left for that case // Some resources are lazy allocated, the threshold is left for that case
#define TEST_MEMORY_LEAK_THRESHOLD (1000) #define TEST_MEMORY_LEAK_THRESHOLD (1200)
static size_t before_free_8bit; static size_t before_free_8bit;
static size_t before_free_32bit; static size_t before_free_32bit;

View File

@@ -1 +0,0 @@
CONFIG_I2C_MASTER_ISR_HANDLER_IN_IRAM=n

View File

@@ -1,5 +1,7 @@
CONFIG_ESP_TASK_WDT=n CONFIG_ESP_TASK_WDT_EN=n
CONFIG_SPI_FLASH_AUTO_SUSPEND=y CONFIG_SPI_FLASH_AUTO_SUSPEND=y
CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
# Now the runners are massively using xmc-c chips, to be removed when xmc-d goes massive production.
CONFIG_SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND=y

View File

@@ -1,2 +1,4 @@
CONFIG_SPI_FLASH_AUTO_SUSPEND=y CONFIG_SPI_FLASH_AUTO_SUSPEND=y
CONFIG_SPI_FLASH_PLACE_FUNCTIONS_IN_IRAM=n CONFIG_SPI_FLASH_PLACE_FUNCTIONS_IN_IRAM=n
# Now the runners are massively using xmc-c chips, to be removed when xmc-d goes massive production.
CONFIG_SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND=y

View File

@@ -1,4 +1,6 @@
CONFIG_ESP_TASK_WDT=n CONFIG_ESP_TASK_WDT_EN=n
CONFIG_SPI_FLASH_AUTO_SUSPEND=y CONFIG_SPI_FLASH_AUTO_SUSPEND=y
CONFIG_PARTITION_TABLE_CUSTOM=y CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
# Now the runners are massively using xmc-c chips, to be removed when xmc-d goes massive production.
CONFIG_SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND=y

View File

@@ -2,3 +2,5 @@ CONFIG_SPI_FLASH_AUTO_SUSPEND=y
CONFIG_PARTITION_TABLE_CUSTOM=y CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
# Now the runners are massively using xmc-c chips, to be removed when xmc-d goes massive production.
CONFIG_SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND=y