@@ -68,17 +68,25 @@ static uint8_t sector_buf[4096];
68
68
#define VSPI_PIN_NUM_CS FSPI_PIN_NUM_CS
69
69
#endif
70
70
71
- #define ALL_TEST_NUM (sizeof(config_list)/sizeof(flashtest_config_t))
71
+ #define TEST_CONFIG_NUM (sizeof(config_list)/sizeof(flashtest_config_t))
72
+
72
73
typedef void (* flash_test_func_t )(esp_flash_t * chip );
73
74
75
+ /* Use FLASH_TEST_CASE for SPI flash tests that only use the main SPI flash chip
76
+ */
74
77
#define FLASH_TEST_CASE (STR , FUNC_TO_RUN ) \
75
- TEST_CASE(STR, "[esp_flash]") {flash_test_func(FUNC_TO_RUN, 1);}
78
+ TEST_CASE(STR, "[esp_flash]") {flash_test_func(FUNC_TO_RUN, 1 /* first index reserved for main flash */ );}
79
+
80
+ /* Use FLASH_TEST_CASE_3 for tests which also run on external flash, which sits in the place of PSRAM
81
+ (these tests are incompatible with PSRAM)
82
+
83
+ These tests run for all the flash chip configs shown in config_list, below (internal and external).
84
+ */
76
85
#if defined(CONFIG_SPIRAM_SUPPORT ) || TEMPORARY_DISABLED_FOR_TARGETS (ESP32S2BETA )
77
- // These tests needs external flash, right on the place of psram
78
86
#define FLASH_TEST_CASE_3 (STR , FUNCT_TO_RUN )
79
87
#else
80
88
#define FLASH_TEST_CASE_3 (STR , FUNC_TO_RUN ) \
81
- TEST_CASE(STR", 3 chips", "[esp_flash][test_env=UT_T1_ESP_FLASH]") {flash_test_func(FUNC_TO_RUN, ALL_TEST_NUM );}
89
+ TEST_CASE(STR", 3 chips", "[esp_flash][test_env=UT_T1_ESP_FLASH]") {flash_test_func(FUNC_TO_RUN, TEST_CONFIG_NUM );}
82
90
#endif
83
91
84
92
//currently all the configs are the same with esp_flash_spi_device_config_t, no more information required
@@ -271,12 +279,14 @@ void teardown_test_chip(esp_flash_t* chip, spi_host_device_t host)
271
279
static void flash_test_func (flash_test_func_t func , int test_num )
272
280
{
273
281
for (int i = 0 ; i < test_num ; i ++ ) {
282
+ ESP_LOGI (TAG , "Testing config %d/%d" , i , test_num );
274
283
flashtest_config_t * config = & config_list [i ];
275
284
esp_flash_t * chip ;
276
285
setup_new_chip (config , & chip );
277
286
(* func )(chip );
278
287
teardown_test_chip (chip , config -> host_id );
279
288
}
289
+ ESP_LOGI (TAG , "Completed %d configs" , test_num );
280
290
}
281
291
282
292
/* ---------- Test code start ------------*/
@@ -615,7 +625,7 @@ TEST_CASE("SPI flash test reading with all speed/mode permutations", "[esp_flash
615
625
#if !TEMPORARY_DISABLED_FOR_TARGETS (ESP32S2BETA )
616
626
TEST_CASE ("SPI flash test reading with all speed/mode permutations, 3 chips" , "[esp_flash][test_env=UT_T1_ESP_FLASH]" )
617
627
{
618
- for (int i = 0 ; i < ALL_TEST_NUM ; i ++ ) {
628
+ for (int i = 0 ; i < TEST_CONFIG_NUM ; i ++ ) {
619
629
test_permutations (& config_list [i ]);
620
630
}
621
631
}
@@ -685,4 +695,35 @@ static void test_write_large_buffer(esp_flash_t *chip, const uint8_t *source, si
685
695
686
696
write_large_buffer (chip , part , source , length );
687
697
read_and_check (chip , part , source , length );
688
- }
698
+ }
699
+
700
+ #ifdef CONFIG_SPIRAM_USE_MALLOC
701
+
702
+ static void test_flash_read_large_psram_buffer (esp_flash_t * chip )
703
+ {
704
+ const size_t BUF_SZ = 256 * 1024 ; // Too large for internal RAM
705
+ const size_t INTERNAL_BUF_SZ = 1024 ; // Should fit in internal RAM
706
+ _Static_assert (BUF_SZ % INTERNAL_BUF_SZ == 0 , "should be a multiple" );
707
+ const size_t TEST_OFFS = 0x1000 ; // Can be any offset, really
708
+
709
+ uint8_t * buf = heap_caps_malloc (BUF_SZ , MALLOC_CAP_8BIT |MALLOC_CAP_SPIRAM );
710
+ TEST_ASSERT_NOT_NULL (buf );
711
+
712
+ ESP_ERROR_CHECK ( esp_flash_read (chip , buf , TEST_OFFS , BUF_SZ ) );
713
+
714
+ // Read back the same into smaller internal memory buffer and check it all matches
715
+ uint8_t * ibuf = heap_caps_malloc (INTERNAL_BUF_SZ , MALLOC_CAP_8BIT |MALLOC_CAP_INTERNAL );
716
+ TEST_ASSERT_NOT_NULL (ibuf );
717
+
718
+ for (int i = 0 ; i < BUF_SZ ; i += INTERNAL_BUF_SZ ) {
719
+ ESP_ERROR_CHECK ( esp_flash_read (chip , ibuf , TEST_OFFS + i , INTERNAL_BUF_SZ ) );
720
+ TEST_ASSERT_EQUAL_HEX8_ARRAY (buf + i , ibuf , INTERNAL_BUF_SZ );
721
+ }
722
+
723
+ free (ibuf );
724
+ free (buf );
725
+ }
726
+
727
+ FLASH_TEST_CASE ("esp_flash_read large PSRAM buffer" , test_flash_read_large_psram_buffer );
728
+
729
+ #endif
0 commit comments