Kaynağa Gözat

Merge branch 'bugfix/support_new_BYflash_chip_boot' into 'master'

spi_flash: add external flash support on esp32c3

Closes IDF-2650, IDF-2651, and IDF-2399

See merge request espressif/esp-idf!12121
Michael (XIAO Xufeng) 5 yıl önce
ebeveyn
işleme
423a5458dc

+ 1 - 0
components/bootloader_support/src/flash_qio_mode.c

@@ -94,6 +94,7 @@ const static qio_info_t chip_data[] = {
        This approach works for chips including:
        This approach works for chips including:
        GigaDevice (mfg ID 0xC8, flash IDs including 4016),
        GigaDevice (mfg ID 0xC8, flash IDs including 4016),
        FM25Q32 (QOUT mode only, mfg ID 0xA1, flash IDs including 4016)
        FM25Q32 (QOUT mode only, mfg ID 0xA1, flash IDs including 4016)
+       BY25Q32 (mfg ID 0x68, flash IDs including 4016)
     */
     */
     { NULL,          0xFF,    0xFFFF, 0xFFFF,   read_status_8b_rdsr2,       write_status_8b_wrsr2,      1 },
     { NULL,          0xFF,    0xFFFF, 0xFFFF,   read_status_8b_rdsr2,       write_status_8b_wrsr2,      1 },
 };
 };

+ 1 - 0
components/hal/esp32c3/include/hal/gpspi_flash_ll.h

@@ -148,6 +148,7 @@ static inline void gpspi_flash_ll_set_buffer_data(spi_dev_t *dev, const void *bu
  */
  */
 static inline void gpspi_flash_ll_user_start(spi_dev_t *dev)
 static inline void gpspi_flash_ll_user_start(spi_dev_t *dev)
 {
 {
+    dev->ctrl.hold_pol = 1;
     dev->cmd.update = 1;
     dev->cmd.update = 1;
     while (dev->cmd.update);
     while (dev->cmd.update);
     dev->cmd.usr = 1;
     dev->cmd.usr = 1;

+ 17 - 10
components/spi_flash/test/test_esp_flash.c

@@ -137,17 +137,25 @@ typedef void (*flash_test_func_t)(const esp_partition_t *part);
 
 
    These tests run for all the flash chip configs shown in config_list, below (internal and external).
    These tests run for all the flash chip configs shown in config_list, below (internal and external).
  */
  */
-#if defined(CONFIG_SPIRAM) || TEMPORARY_DISABLED_FOR_TARGETS(ESP32C3)
+#if defined(CONFIG_SPIRAM)
 
 
 #define FLASH_TEST_CASE_3(STR, FUNCT_TO_RUN)
 #define FLASH_TEST_CASE_3(STR, FUNCT_TO_RUN)
 #define FLASH_TEST_CASE_3_IGNORE(STR, FUNCT_TO_RUN)
 #define FLASH_TEST_CASE_3_IGNORE(STR, FUNCT_TO_RUN)
-#else
+#else //CONFIG_SPIRAM
+#if !CONFIG_IDF_TARGET_ESP32C3
 #define FLASH_TEST_CASE_3(STR, FUNC_TO_RUN) \
 #define FLASH_TEST_CASE_3(STR, FUNC_TO_RUN) \
     TEST_CASE(STR", 3 chips", "[esp_flash_3][test_env=UT_T1_ESP_FLASH]") {flash_test_func(FUNC_TO_RUN, TEST_CONFIG_NUM);}
     TEST_CASE(STR", 3 chips", "[esp_flash_3][test_env=UT_T1_ESP_FLASH]") {flash_test_func(FUNC_TO_RUN, TEST_CONFIG_NUM);}
 
 
 #define FLASH_TEST_CASE_3_IGNORE(STR, FUNC_TO_RUN) \
 #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);}
     TEST_CASE(STR", 3 chips", "[esp_flash_3][test_env=UT_T1_ESP_FLASH][ignore]") {flash_test_func(FUNC_TO_RUN, TEST_CONFIG_NUM);}
-#endif
+#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);}
+
+#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
 
 
 //currently all the configs are the same with esp_flash_spi_device_config_t, no more information required
 //currently all the configs are the same with esp_flash_spi_device_config_t, no more information required
 typedef esp_flash_spi_device_config_t flashtest_config_t;
 typedef esp_flash_spi_device_config_t flashtest_config_t;
@@ -196,7 +204,6 @@ flashtest_config_t config_list[] = {
 #elif CONFIG_IDF_TARGET_ESP32S2
 #elif CONFIG_IDF_TARGET_ESP32S2
 flashtest_config_t config_list[] = {
 flashtest_config_t config_list[] = {
     FLASHTEST_CONFIG_COMMON,
     FLASHTEST_CONFIG_COMMON,
-    /* No runners for esp32s2 for these config yet */
     {
     {
         .io_mode = TEST_SPI_READ_MODE,
         .io_mode = TEST_SPI_READ_MODE,
         .speed = TEST_SPI_SPEED,
         .speed = TEST_SPI_SPEED,
@@ -230,8 +237,11 @@ flashtest_config_t config_list[] = {
 };
 };
 #elif CONFIG_IDF_TARGET_ESP32C3
 #elif CONFIG_IDF_TARGET_ESP32C3
 flashtest_config_t config_list[] = {
 flashtest_config_t config_list[] = {
-    FLASHTEST_CONFIG_COMMON,
-    /* No runners for esp32c3 for these config yet */
+    /* No SPI1 CS1 flash on esp32c3 test */
+    {
+        /* no need to init */
+        .host_id = -1,
+    },
     {
     {
         .io_mode = TEST_SPI_READ_MODE,
         .io_mode = TEST_SPI_READ_MODE,
         .speed = TEST_SPI_SPEED,
         .speed = TEST_SPI_SPEED,
@@ -879,14 +889,12 @@ TEST_CASE("SPI flash test reading with all speed/mode permutations", "[esp_flash
 }
 }
 
 
 #ifndef CONFIG_SPIRAM
 #ifndef CONFIG_SPIRAM
-#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C3)
 TEST_CASE("SPI flash test reading with all speed/mode permutations, 3 chips", "[esp_flash_3][test_env=UT_T1_ESP_FLASH]")
 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++) {
     for (int i = 0; i < TEST_CONFIG_NUM; i++) {
         test_permutations_chip(&config_list[i]);
         test_permutations_chip(&config_list[i]);
     }
     }
 }
 }
-#endif //TEMPORARY_DISABLED_FOR_TARGETS(ESP32C3)
 #endif
 #endif
 
 
 
 
@@ -955,8 +963,7 @@ static void test_write_large_buffer(const esp_partition_t* part, const uint8_t *
     read_and_check(part, source, length);
     read_and_check(part, source, length);
 }
 }
 
 
-#if !CONFIG_SPIRAM && !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C3)
-/* No runners on C3, TODO ESP32-C3 IDF-2399 */
+#if !CONFIG_SPIRAM
 
 
 typedef struct {
 typedef struct {
     uint32_t us_start;
     uint32_t us_start;

+ 7 - 0
tools/ci/config/target-test.yml

@@ -578,6 +578,13 @@ UT_C3:
     - ESP32C3_IDF
     - ESP32C3_IDF
     - UT_T1_1
     - UT_T1_1
 
 
+UT_C3_FLASH:
+  extends: .unit_test_c3_template
+  parallel: 3
+  tags:
+    - ESP32C3_IDF
+    - UT_T1_ESP_FLASH
+
 nvs_compatible_test:
 nvs_compatible_test:
   extends: .integration_test_template
   extends: .integration_test_template
   artifacts:
   artifacts: