|
|
@@ -128,37 +128,49 @@ static uint8_t sector_buf[4096];
|
|
|
|
|
|
typedef void (*flash_test_func_t)(const esp_partition_t *part);
|
|
|
|
|
|
-/* Use FLASH_TEST_CASE for SPI flash tests that only use the main SPI flash chip
|
|
|
+/* Use TEST_CASE_FLASH for SPI flash tests that only use the main SPI flash chip
|
|
|
*/
|
|
|
-#define FLASH_TEST_CASE(STR, FUNC_TO_RUN) \
|
|
|
+#define TEST_CASE_FLASH(STR, FUNC_TO_RUN) \
|
|
|
TEST_CASE(STR, "[esp_flash]") {flash_test_func(FUNC_TO_RUN, 1 /* first index reserved for main flash */ );}
|
|
|
|
|
|
-#define FLASH_TEST_CASE_IGNORE(STR, FUNC_TO_RUN) \
|
|
|
+#define TEST_CASE_FLASH_IGNORE(STR, FUNC_TO_RUN) \
|
|
|
TEST_CASE(STR, "[esp_flash][ignore]") {flash_test_func(FUNC_TO_RUN, 1 /* first index reserved for main flash */ );}
|
|
|
|
|
|
-/* Use FLASH_TEST_CASE_3 for tests which also run on external flash, which sits in the place of PSRAM
|
|
|
+/* Use TEST_CASE_MULTI_FLASH for tests which also run on external flash, which sits in the place of PSRAM
|
|
|
(these tests are incompatible with PSRAM)
|
|
|
|
|
|
These tests run for all the flash chip configs shown in config_list, below (internal and external).
|
|
|
*/
|
|
|
+
|
|
|
+
|
|
|
#if defined(CONFIG_SPIRAM)
|
|
|
-#define FLASH_TEST_CASE_3(STR, FUNCT_TO_RUN)
|
|
|
-#define FLASH_TEST_CASE_3_IGNORE(STR, FUNCT_TO_RUN)
|
|
|
-#else //CONFIG_SPIRAM
|
|
|
-#if !CONFIG_IDF_TARGET_ESP32C3
|
|
|
-#define FLASH_TEST_CASE_3(STR, FUNC_TO_RUN) \
|
|
|
- TEST_CASE(STR", 3 chips", "[esp_flash_3][test_env=UT_T1_ESP_FLASH][timeout=35]") {flash_test_func(FUNC_TO_RUN, TEST_CONFIG_NUM);}
|
|
|
+//SPI1 CS1 occupied by PSRAM
|
|
|
+#define BYPASS_MULTIPLE_CHIP 1
|
|
|
+#elif TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2)
|
|
|
+//IDF-5049
|
|
|
+#define BYPASS_MULTIPLE_CHIP 1
|
|
|
+#endif
|
|
|
|
|
|
-#define FLASH_TEST_CASE_3_IGNORE(STR, FUNC_TO_RUN) \
|
|
|
- TEST_CASE(STR", 3 chips", "[esp_flash_3][test_env=UT_T1_ESP_FLASH][ignore]") {flash_test_func(FUNC_TO_RUN, TEST_CONFIG_NUM);}
|
|
|
-#else //CONFIG_IDF_TARGET_ESP32C3
|
|
|
-#define FLASH_TEST_CASE_3(STR, FUNC_TO_RUN) \
|
|
|
- TEST_CASE(STR", 2 chips", "[esp_flash_2][test_env=UT_T1_ESP_FLASH]") {flash_test_func(FUNC_TO_RUN, TEST_CONFIG_NUM);}
|
|
|
+#if CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3
|
|
|
+//chips without PSRAM
|
|
|
+#define TEST_CHIP_NUM 2
|
|
|
+#elif CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
|
|
+#define TEST_CHIP_NUM 3
|
|
|
+#endif
|
|
|
+
|
|
|
+#define _STRINGIFY(s) #s
|
|
|
+#define STRINGIFY(s) _STRINGIFY(s)
|
|
|
+#define TEST_CHIP_NUM_STR STRINGIFY(TEST_CHIP_NUM)
|
|
|
|
|
|
-#define FLASH_TEST_CASE_3_IGNORE(STR, FUNC_TO_RUN) \
|
|
|
- TEST_CASE(STR", 2 chips", "[esp_flash_2][test_env=UT_T1_ESP_FLASH][ignore]") {flash_test_func(FUNC_TO_RUN, TEST_CONFIG_NUM);}
|
|
|
-#endif // !CONFIG_IDF_TARGET_ESP32C3
|
|
|
-#endif //CONFIG_SPIRAM
|
|
|
+#if BYPASS_MULTIPLE_CHIP
|
|
|
+#define TEST_CASE_MULTI_FLASH TEST_CASE_MULTI_FLASH_IGNORE
|
|
|
+#else
|
|
|
+#define TEST_CASE_MULTI_FLASH(STR, FUNC_TO_RUN) \
|
|
|
+ TEST_CASE(STR", "TEST_CHIP_NUM_STR" chips", "[esp_flash_3][test_env=UT_T1_ESP_FLASH][timeout=35]") {flash_test_func(FUNC_TO_RUN, TEST_CONFIG_NUM);}
|
|
|
+#endif
|
|
|
+
|
|
|
+#define TEST_CASE_MULTI_FLASH_IGNORE(STR, FUNC_TO_RUN) \
|
|
|
+ TEST_CASE(STR", "TEST_CHIP_NUM_STR" chips", "[esp_flash_3][test_env=UT_T1_ESP_FLASH][ignore]") {flash_test_func(FUNC_TO_RUN, TEST_CONFIG_NUM);}
|
|
|
|
|
|
|
|
|
//currently all the configs are the same with esp_flash_spi_device_config_t, no more information required
|
|
|
@@ -461,8 +473,8 @@ static void test_metadata(const esp_partition_t* part)
|
|
|
printf("Flash ID %08x detected size %d bytes\n", id, size);
|
|
|
}
|
|
|
|
|
|
-FLASH_TEST_CASE("SPI flash metadata functions", test_metadata);
|
|
|
-FLASH_TEST_CASE_3("SPI flash metadata functions", test_metadata);
|
|
|
+TEST_CASE_FLASH("SPI flash metadata functions", test_metadata);
|
|
|
+TEST_CASE_MULTI_FLASH("SPI flash metadata functions", test_metadata);
|
|
|
|
|
|
static uint32_t erase_test_region(const esp_partition_t *part, int num_sectors)
|
|
|
{
|
|
|
@@ -521,8 +533,8 @@ void test_simple_read_write(const esp_partition_t* part)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-FLASH_TEST_CASE("SPI flash simple read/write", test_simple_read_write);
|
|
|
-FLASH_TEST_CASE_3("SPI flash simple read/write", test_simple_read_write);
|
|
|
+TEST_CASE_FLASH("SPI flash simple read/write", test_simple_read_write);
|
|
|
+TEST_CASE_MULTI_FLASH("SPI flash simple read/write", test_simple_read_write);
|
|
|
|
|
|
void test_unaligned_read_write(const esp_partition_t* part)
|
|
|
{
|
|
|
@@ -542,8 +554,8 @@ void test_unaligned_read_write(const esp_partition_t* part)
|
|
|
TEST_ASSERT(memcmp(buf, msg, strlen(msg) + 1) == 0);
|
|
|
}
|
|
|
|
|
|
-FLASH_TEST_CASE("SPI flash unaligned read/write", test_unaligned_read_write);
|
|
|
-FLASH_TEST_CASE_3("SPI flash unaligned read/write", test_unaligned_read_write);
|
|
|
+TEST_CASE_FLASH("SPI flash unaligned read/write", test_unaligned_read_write);
|
|
|
+TEST_CASE_MULTI_FLASH("SPI flash unaligned read/write", test_unaligned_read_write);
|
|
|
|
|
|
void test_single_read_write(const esp_partition_t* part)
|
|
|
{
|
|
|
@@ -566,8 +578,8 @@ void test_single_read_write(const esp_partition_t* part)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-FLASH_TEST_CASE("SPI flash single byte reads/writes", test_single_read_write);
|
|
|
-FLASH_TEST_CASE_3("SPI flash single byte reads/writes", test_single_read_write);
|
|
|
+TEST_CASE_FLASH("SPI flash single byte reads/writes", test_single_read_write);
|
|
|
+TEST_CASE_MULTI_FLASH("SPI flash single byte reads/writes", test_single_read_write);
|
|
|
|
|
|
|
|
|
/* this test is notable because it generates a lot of unaligned reads/writes,
|
|
|
@@ -596,8 +608,8 @@ void test_three_byte_read_write(const esp_partition_t* part)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-FLASH_TEST_CASE("SPI flash three byte reads/writes", test_three_byte_read_write);
|
|
|
-FLASH_TEST_CASE_3("SPI flash three byte reads/writes", test_three_byte_read_write);
|
|
|
+TEST_CASE_FLASH("SPI flash three byte reads/writes", test_three_byte_read_write);
|
|
|
+TEST_CASE_MULTI_FLASH("SPI flash three byte reads/writes", test_three_byte_read_write);
|
|
|
|
|
|
void test_erase_large_region(const esp_partition_t *part)
|
|
|
{
|
|
|
@@ -634,8 +646,8 @@ void test_erase_large_region(const esp_partition_t *part)
|
|
|
TEST_ASSERT_EQUAL_HEX32(0xFFFFFFFF, readback);
|
|
|
}
|
|
|
|
|
|
-FLASH_TEST_CASE("SPI flash erase large region", test_erase_large_region);
|
|
|
-FLASH_TEST_CASE_3("SPI flash erase large region", test_erase_large_region);
|
|
|
+TEST_CASE_FLASH("SPI flash erase large region", test_erase_large_region);
|
|
|
+TEST_CASE_MULTI_FLASH("SPI flash erase large region", test_erase_large_region);
|
|
|
|
|
|
#if CONFIG_SPI_FLASH_AUTO_SUSPEND
|
|
|
void esp_test_for_suspend(void)
|
|
|
@@ -707,8 +719,8 @@ static void test_write_protection(const esp_partition_t* part)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-FLASH_TEST_CASE("Test esp_flash can enable/disable write protetion", test_write_protection);
|
|
|
-FLASH_TEST_CASE_3("Test esp_flash can enable/disable write protetion", test_write_protection);
|
|
|
+TEST_CASE_FLASH("Test esp_flash can enable/disable write protetion", test_write_protection);
|
|
|
+TEST_CASE_MULTI_FLASH("Test esp_flash can enable/disable write protetion", test_write_protection);
|
|
|
|
|
|
static const uint8_t large_const_buffer[16400] = {
|
|
|
203, // first byte
|
|
|
@@ -799,8 +811,8 @@ IRAM_ATTR NOINLINE_ATTR static void test_toggle_qe(const esp_partition_t* part)
|
|
|
// These tests show whether the QE is permanent or not for the chip tested.
|
|
|
// To test the behaviour of a new SPI flash chip, enable force_check flag in generic driver
|
|
|
// `spi_flash_common_set_io_mode` and then run this test.
|
|
|
-FLASH_TEST_CASE_IGNORE("Test esp_flash_write can toggle QE bit", test_toggle_qe);
|
|
|
-FLASH_TEST_CASE_3_IGNORE("Test esp_flash_write can toggle QE bit", test_toggle_qe);
|
|
|
+TEST_CASE_FLASH_IGNORE("Test esp_flash_write can toggle QE bit", test_toggle_qe);
|
|
|
+TEST_CASE_MULTI_FLASH_IGNORE("Test esp_flash_write can toggle QE bit", test_toggle_qe);
|
|
|
#endif //CONFIG_ESPTOOLPY_OCT_FLASH
|
|
|
|
|
|
// This table could be chip specific in the future.
|
|
|
@@ -911,6 +923,8 @@ TEST_CASE("SPI flash test reading with all speed/mode permutations", "[esp_flash
|
|
|
}
|
|
|
|
|
|
#ifndef CONFIG_SPIRAM
|
|
|
+#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2)
|
|
|
+//IDF-5049
|
|
|
TEST_CASE("SPI flash test reading with all speed/mode permutations, 3 chips", "[esp_flash_3][test_env=UT_T1_ESP_FLASH]")
|
|
|
{
|
|
|
for (int i = 0; i < TEST_CONFIG_NUM; i++) {
|
|
|
@@ -918,6 +932,7 @@ TEST_CASE("SPI flash test reading with all speed/mode permutations, 3 chips", "[
|
|
|
}
|
|
|
}
|
|
|
#endif
|
|
|
+#endif
|
|
|
|
|
|
|
|
|
static void test_write_large_const_buffer(const esp_partition_t* part)
|
|
|
@@ -925,8 +940,8 @@ static void test_write_large_const_buffer(const esp_partition_t* part)
|
|
|
test_write_large_buffer(part, large_const_buffer, sizeof(large_const_buffer));
|
|
|
}
|
|
|
|
|
|
-FLASH_TEST_CASE("Test esp_flash_write large const buffer", test_write_large_const_buffer);
|
|
|
-FLASH_TEST_CASE_3("Test esp_flash_write large const buffer", test_write_large_const_buffer);
|
|
|
+TEST_CASE_FLASH("Test esp_flash_write large const buffer", test_write_large_const_buffer);
|
|
|
+TEST_CASE_MULTI_FLASH("Test esp_flash_write large const buffer", test_write_large_const_buffer);
|
|
|
|
|
|
static void test_write_large_ram_buffer(const esp_partition_t* part)
|
|
|
{
|
|
|
@@ -938,8 +953,8 @@ static void test_write_large_ram_buffer(const esp_partition_t* part)
|
|
|
free(source_buf);
|
|
|
}
|
|
|
|
|
|
-FLASH_TEST_CASE("Test esp_flash_write large RAM buffer", test_write_large_ram_buffer);
|
|
|
-FLASH_TEST_CASE_3("Test esp_flash_write large RAM buffer", test_write_large_ram_buffer);
|
|
|
+TEST_CASE_FLASH("Test esp_flash_write large RAM buffer", test_write_large_ram_buffer);
|
|
|
+TEST_CASE_MULTI_FLASH("Test esp_flash_write large RAM buffer", test_write_large_ram_buffer);
|
|
|
|
|
|
static void write_large_buffer(const esp_partition_t *part, const uint8_t *source, size_t length)
|
|
|
{
|
|
|
@@ -985,8 +1000,6 @@ static void test_write_large_buffer(const esp_partition_t* part, const uint8_t *
|
|
|
read_and_check(part, source, length);
|
|
|
}
|
|
|
|
|
|
-#if !CONFIG_SPIRAM
|
|
|
-
|
|
|
typedef struct {
|
|
|
uint32_t us_start;
|
|
|
size_t len;
|
|
|
@@ -1157,12 +1170,12 @@ static void test_flash_read_write_performance(const esp_partition_t *part)
|
|
|
free(data_read);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+#if !BYPASS_MULTIPLE_CHIP
|
|
|
+//To make performance data stable, needs to run on special runner
|
|
|
TEST_CASE("Test esp_flash read/write performance", "[esp_flash][test_env=UT_T1_ESP_FLASH]") {flash_test_func(test_flash_read_write_performance, 1);}
|
|
|
+#endif
|
|
|
|
|
|
-#endif // !CONFIG_SPIRAM
|
|
|
-FLASH_TEST_CASE_3("Test esp_flash read/write performance"", 3 chips", test_flash_read_write_performance);
|
|
|
+TEST_CASE_MULTI_FLASH("Test esp_flash read/write performance", test_flash_read_write_performance);
|
|
|
|
|
|
#ifdef CONFIG_SPIRAM_USE_MALLOC
|
|
|
|
|
|
@@ -1200,7 +1213,7 @@ static void test_flash_read_large_psram_buffer(const esp_partition_t *part)
|
|
|
free(buf);
|
|
|
}
|
|
|
|
|
|
-FLASH_TEST_CASE("esp_flash_read large PSRAM buffer", test_flash_read_large_psram_buffer);
|
|
|
+TEST_CASE_FLASH("esp_flash_read large PSRAM buffer", test_flash_read_large_psram_buffer);
|
|
|
|
|
|
|
|
|
/* similar to above test, but perform it under memory pressure */
|
|
|
@@ -1229,7 +1242,7 @@ static void test_flash_read_large_psram_buffer_low_internal_mem(const esp_partit
|
|
|
free(buf);
|
|
|
}
|
|
|
|
|
|
-FLASH_TEST_CASE("esp_flash_read large PSRAM buffer low memory", test_flash_read_large_psram_buffer_low_internal_mem);
|
|
|
+TEST_CASE_FLASH("esp_flash_read large PSRAM buffer low memory", test_flash_read_large_psram_buffer_low_internal_mem);
|
|
|
|
|
|
|
|
|
#endif
|