fix(spi_flash): Fix suspend issue on esp32s31, and add trs timing on other target

This commit is contained in:
C.S.M
2026-06-08 14:39:47 +08:00
parent c3640229af
commit 01a9cbe421
26 changed files with 249 additions and 46 deletions
@@ -203,14 +203,14 @@ static void s_flash_init_mxic(esp_rom_spiflash_read_mode_t mode)
#if CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR
s_set_pin_drive_capability(3);
s_set_flash_dtr_str_opi_mode(1, 0x1);
esp_rom_opiflash_cache_mode_config(mode, &rom_opiflash_cmd_def->cache_rd_cmd);
esp_rom_spiflash_cache_mode_config(mode, &rom_opiflash_cmd_def->cache_rd_cmd);
esp_rom_spi_set_dtr_swap_mode(0, false, false);
esp_rom_spi_set_dtr_swap_mode(1, false, false);
#else //CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_DTR
s_set_pin_drive_capability(3);
bool need_swap = s_mxic_dtr_need_swap();
s_set_flash_dtr_str_opi_mode(1, 0x2);
esp_rom_opiflash_cache_mode_config(mode, &rom_opiflash_cmd_def->cache_rd_cmd);
esp_rom_spiflash_cache_mode_config(mode, &rom_opiflash_cmd_def->cache_rd_cmd);
esp_rom_spi_set_dtr_swap_mode(0, need_swap, need_swap);
esp_rom_spi_set_dtr_swap_mode(1, need_swap, need_swap);
#endif
@@ -81,9 +81,9 @@ components/spi_flash/test_apps/flash_suspend:
disable:
- if: SOC_SPI_MEM_SUPPORT_AUTO_SUSPEND != 1
disable_test:
- if: IDF_TARGET != "esp32c3"
- if: IDF_TARGET in ["esp32c2", "esp32c6", "esp32h2", "esp32p4", "esp32s3", "esp32h4"]
temporary: true
reason: lack of runners
reason: lack of runners, or we don't trust generic runner must support suspend
depends_components:
- *common_components
- spi_flash
@@ -213,7 +213,7 @@ TEST_CASE("flash suspend test", "[spi_flash][suspend]")
// 15 stands for threshold. We allow the interval time minus duration time is little bit larger than TSUS value
#if CONFIG_SPI_FLASH_PLACE_FUNCTIONS_IN_IRAM
// Don't check the performance because it should be slow.
TEST_ASSERT_LESS_THAN(CONFIG_SPI_FLASH_SUSPEND_TSUS_VAL_US + 15, isr_interval_time - isr_duration_time);
TEST_ASSERT_LESS_THAN(CONFIG_SPI_FLASH_SUSPEND_TSUS_VAL_US + 35, isr_interval_time - isr_duration_time);
#endif
ESP_LOGI(TAG, "Reasonable value!");
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytest_embedded import Dut
@@ -17,3 +17,18 @@ from pytest_embedded_idf.utils import idf_parametrize
@idf_parametrize('target', ['esp32c3'], indirect=['target'])
def test_flash_auto_suspend(dut: Dut) -> None:
dut.run_all_single_board_cases(timeout=30)
# Generic test for all targets that support flash auto suspend
@pytest.mark.generic
@pytest.mark.parametrize(
'config',
[
'release',
'text_in_flash_when_suspend',
],
indirect=True,
)
@idf_parametrize('target', ['esp32c5', 'esp32c61', 'esp32s31'], indirect=['target'])
def test_flash_auto_suspend_generic(dut: Dut) -> None:
dut.run_all_single_board_cases(timeout=30)