Merge branch 'fix/i2s_sample_rate_restriction_v6.1' into 'release/v6.1'

fix(i2s): fix test issue on esp32s31 & esp32h4 (v6.1)

See merge request espressif/esp-idf!48952
This commit is contained in:
morris
2026-06-04 11:14:58 +08:00
11 changed files with 108 additions and 77 deletions
@@ -3,10 +3,6 @@
components/esp_driver_i2s/test_apps/i2s: components/esp_driver_i2s/test_apps/i2s:
disable: disable:
- if: SOC_I2S_SUPPORTED != 1 - if: SOC_I2S_SUPPORTED != 1
disable_test:
- if: IDF_TARGET in ["esp32h4"]
temporary: true
reason: cannot pass # TODO: IDF-15609
depends_components: depends_components:
- esp_driver_i2s - esp_driver_i2s
- esp_driver_pcnt - esp_driver_pcnt
@@ -21,7 +21,6 @@ from pytest_embedded_idf.utils import soc_filtered_targets
indirect=['target'], indirect=['target'],
) )
@pytest.mark.temp_skip_ci(targets=['esp32h21'], reason='lack of runners') @pytest.mark.temp_skip_ci(targets=['esp32h21'], reason='lack of runners')
@pytest.mark.temp_skip_ci(targets=['esp32h4'], reason='cannot pass') # TODO: IDF-15609
def test_i2s(dut: Dut) -> None: def test_i2s(dut: Dut) -> None:
dut.run_all_single_board_cases() dut.run_all_single_board_cases()
@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
@@ -80,6 +80,9 @@ static void test_i2s_tdm_master(uint32_t sample_rate, i2s_data_bit_width_t bit_w
.gpio_cfg = TEST_I2S_DEFAULT_GPIO(I2S_GPIO_UNUSED, true), .gpio_cfg = TEST_I2S_DEFAULT_GPIO(I2S_GPIO_UNUSED, true),
}; };
i2s_tdm_config.clk_cfg.mclk_multiple = I2S_MCLK_MULTIPLE_512; i2s_tdm_config.clk_cfg.mclk_multiple = I2S_MCLK_MULTIPLE_512;
#if CONFIG_IDF_TARGET_ESP32S31
i2s_tdm_config.clk_cfg.clk_src = I2S_CLK_SRC_APLL;
#endif
TEST_ESP_OK(i2s_channel_init_tdm_mode(i2s_tdm_tx_handle, &i2s_tdm_config)); TEST_ESP_OK(i2s_channel_init_tdm_mode(i2s_tdm_tx_handle, &i2s_tdm_config));
TEST_ESP_OK(i2s_channel_init_tdm_mode(i2s_tdm_rx_handle, &i2s_tdm_config)); TEST_ESP_OK(i2s_channel_init_tdm_mode(i2s_tdm_rx_handle, &i2s_tdm_config));
@@ -293,7 +296,7 @@ TEST_CASE_MULTIPLE_DEVICES("I2S_TDM_full_duplex_test_in_48k_8bits_4slots", "[I2S
/* The I2S source clock can only reach 96Mhz on ESP32H2, /* The I2S source clock can only reach 96Mhz on ESP32H2,
and the max clock source APLL on P4 is 125M, and the max clock source APLL on P4 is 125M,
which can't satisfy the following configurations in slave mode */ which can't satisfy the following configurations in slave mode */
#if !CONFIG_IDF_TARGET_ESP32H2 && !CONFIG_IDF_TARGET_ESP32P4 #if !CONFIG_IDF_TARGET_ESP32H2 && !CONFIG_IDF_TARGET_ESP32H4 && !CONFIG_IDF_TARGET_ESP32P4
static void test_i2s_tdm_master_48k_16bits_8slots(void) static void test_i2s_tdm_master_48k_16bits_8slots(void)
{ {
test_i2s_tdm_master(48000, I2S_DATA_BIT_WIDTH_16BIT, I2S_TDM_SLOT0 | I2S_TDM_SLOT1 | I2S_TDM_SLOT2 | I2S_TDM_SLOT3 | test_i2s_tdm_master(48000, I2S_DATA_BIT_WIDTH_16BIT, I2S_TDM_SLOT0 | I2S_TDM_SLOT1 | I2S_TDM_SLOT2 | I2S_TDM_SLOT3 |
@@ -339,7 +342,7 @@ static void test_i2s_external_clk_src(bool is_master, bool is_external)
std_cfg.clk_cfg.clk_src = I2S_CLK_SRC_EXTERNAL; std_cfg.clk_cfg.clk_src = I2S_CLK_SRC_EXTERNAL;
std_cfg.clk_cfg.ext_clk_freq_hz = 22579200; std_cfg.clk_cfg.ext_clk_freq_hz = 22579200;
} }
#if CONFIG_IDF_TARGET_ESP32P4 #if CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32S31
else { else {
// Use APLL instead. // Use APLL instead.
// Because the default clock source is not sufficient for 22.58M MCLK // Because the default clock source is not sufficient for 22.58M MCLK
@@ -228,10 +228,6 @@ examples/peripherals/i2s/i2s_codec/i2s_es7210_tdm:
disable: disable:
- if: SOC_I2S_SUPPORTS_TDM != 1 or (SOC_I2C_SUPPORTED != 1 or SOC_GPSPI_SUPPORTED != 1) - if: SOC_I2S_SUPPORTS_TDM != 1 or (SOC_I2C_SUPPORTED != 1 or SOC_GPSPI_SUPPORTED != 1)
reason: rely on I2S TDM mode to receive audio, I2C to config es7210 and SPI to save audio to SD card reason: rely on I2S TDM mode to receive audio, I2C to config es7210 and SPI to save audio to SD card
disable_test:
- if: IDF_TARGET in ["esp32h4"]
temporary: true
reason: cannot pass # TODO: IDF-15609
depends_components: depends_components:
- esp_driver_i2s - esp_driver_i2s
- esp_driver_dma - esp_driver_dma
@@ -244,10 +240,6 @@ examples/peripherals/i2s/i2s_codec/i2s_es8311:
disable: disable:
- if: (SOC_I2S_SUPPORTED != 1 or SOC_I2C_SUPPORTED != 1) - if: (SOC_I2S_SUPPORTED != 1 or SOC_I2C_SUPPORTED != 1)
reason: rely on I2S STD mode and I2C to config es7210 reason: rely on I2S STD mode and I2C to config es7210
disable_test:
- if: IDF_TARGET in ["esp32h4"]
temporary: true
reason: cannot pass # TODO: IDF-15609
depends_components: depends_components:
- esp_driver_dma - esp_driver_dma
- esp_driver_i2s - esp_driver_i2s
@@ -29,7 +29,7 @@ Recorded voice will be saved to SD card in `wav` format, and can be played or pr
* A SPI SD card module * A SPI SD card module
* A SD card reader and a PC (if you want to play recorded voice) * A SD card reader and a PC (if you want to play recorded voice)
All the GPIO used in this example can be changed according to your board, by macros `EXAMPLE_xxx_IO` defined at the beginning of [i2s_es7210_record_example.c](main/i2s_es7210_record_example.c). All the GPIO used in this example can be changed according to your board, via `idf.py menuconfig` under `Example Configuration` -> `Example IO Configuration`.
### Dependency ### Dependency
@@ -49,7 +49,7 @@ If the dependency is added, you can check `idf_component.yml` for more detail. W
idf.py set-target TARGET idf.py set-target TARGET
``` ```
The configuration macros are defined at the beginning of `main/i2s_es7210_record_example.c`, you can change the configuration macros according to your needs. Run `idf.py menuconfig` to configure GPIO pins and other options under `Example Configuration`.
### Build and Flash ### Build and Flash
@@ -0,0 +1,69 @@
menu "Example Configuration"
menu "Example IO Configuration"
config EXAMPLE_I2C_SDA_IO
int "I2C SDA IO"
default 1 if IDF_TARGET_ESP32S3
default 17 if IDF_TARGET_ESP32H4
default 3
config EXAMPLE_I2C_SCL_IO
int "I2C SCL IO"
default 16 if IDF_TARGET_ESP32H4
default 2
config EXAMPLE_I2S_MCLK_IO
int "I2S MCLK IO"
default 20 if IDF_TARGET_ESP32S3
default 4 if IDF_TARGET_ESP32P4
default 0
config EXAMPLE_I2S_BCLK_IO
int "I2S BCLK IO"
default 10 if IDF_TARGET_ESP32S3
default 5 if IDF_TARGET_ESP32P4
default 4 if IDF_TARGET_ESP32H4
default 1
config EXAMPLE_I2S_WS_IO
int "I2S WS IO"
default 9 if IDF_TARGET_ESP32S3
default 6 if IDF_TARGET_ESP32P4
default 5 if IDF_TARGET_ESP32H4
default 10
config EXAMPLE_I2S_DIN_IO
int "I2S DIN IO"
default 11 if IDF_TARGET_ESP32S3
default 7 if IDF_TARGET_ESP32P4
default 6 if IDF_TARGET_ESP32H4
default 8
config EXAMPLE_SD_SPI_CLK_IO
int "SD card SPI CLK IO"
default 18 if IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32P4
default 12 if IDF_TARGET_ESP32H4
default 5
config EXAMPLE_SD_SPI_MOSI_IO
int "SD card SPI MOSI IO"
default 17 if IDF_TARGET_ESP32S3
default 19 if IDF_TARGET_ESP32P4
default 13 if IDF_TARGET_ESP32H4
default 7
config EXAMPLE_SD_SPI_MISO_IO
int "SD card SPI MISO IO"
default 16 if IDF_TARGET_ESP32S3
default 14 if IDF_TARGET_ESP32P4 || IDF_TARGET_ESP32H4
default 6
config EXAMPLE_SD_SPI_CS_IO
int "SD card SPI CS IO"
default 15 if IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32H4
default 17 if IDF_TARGET_ESP32P4
default 4
endmenu
endmenu
@@ -0,0 +1,27 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#pragma once
#include "sdkconfig.h"
/* I2C port and GPIOs */
#define EXAMPLE_I2C_NUM (0)
#define EXAMPLE_I2C_SDA_IO CONFIG_EXAMPLE_I2C_SDA_IO
#define EXAMPLE_I2C_SCL_IO CONFIG_EXAMPLE_I2C_SCL_IO
/* I2S port and GPIOs */
#define EXAMPLE_I2S_NUM (0)
#define EXAMPLE_I2S_MCK_IO CONFIG_EXAMPLE_I2S_MCLK_IO
#define EXAMPLE_I2S_BCK_IO CONFIG_EXAMPLE_I2S_BCLK_IO
#define EXAMPLE_I2S_WS_IO CONFIG_EXAMPLE_I2S_WS_IO
#define EXAMPLE_I2S_DI_IO CONFIG_EXAMPLE_I2S_DIN_IO
/* SD card SPI GPIOs */
#define EXAMPLE_SD_SPI_CLK_IO CONFIG_EXAMPLE_SD_SPI_CLK_IO
#define EXAMPLE_SD_SPI_MOSI_IO CONFIG_EXAMPLE_SD_SPI_MOSI_IO
#define EXAMPLE_SD_SPI_MISO_IO CONFIG_EXAMPLE_SD_SPI_MISO_IO
#define EXAMPLE_SD_SPI_CS_IO CONFIG_EXAMPLE_SD_SPI_CS_IO
@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
@@ -13,60 +13,7 @@
#include "esp_codec_dev.h" #include "esp_codec_dev.h"
#include "esp_codec_dev_vol.h" #include "esp_codec_dev_vol.h"
#include "format_wav.h" #include "format_wav.h"
#include "example_config.h"
#if CONFIG_IDF_TARGET_ESP32S3 // ESP32-S3-Korvo-1 pin out
/* I2C port and GPIOs */
#define EXAMPLE_I2C_NUM (0)
#define EXAMPLE_I2C_SDA_IO (1)
#define EXAMPLE_I2C_SCL_IO (2)
/* I2S port and GPIOs */
#define EXAMPLE_I2S_NUM (0)
#define EXAMPLE_I2S_MCK_IO (20)
#define EXAMPLE_I2S_BCK_IO (10)
#define EXAMPLE_I2S_WS_IO (9)
#define EXAMPLE_I2S_DI_IO (11)
/* SD card SPI GPIOs */
#define EXAMPLE_SD_SPI_CLK_IO (18)
#define EXAMPLE_SD_SPI_MOSI_IO (17)
#define EXAMPLE_SD_SPI_MISO_IO (16)
#define EXAMPLE_SD_SPI_CS_IO (15)
#elif CONFIG_IDF_TARGET_ESP32P4
#define EXAMPLE_I2C_NUM (0)
#define EXAMPLE_I2C_SDA_IO (3)
#define EXAMPLE_I2C_SCL_IO (2)
/* I2S port and GPIOs */
#define EXAMPLE_I2S_NUM (0)
#define EXAMPLE_I2S_MCK_IO (4)
#define EXAMPLE_I2S_BCK_IO (5)
#define EXAMPLE_I2S_WS_IO (6)
#define EXAMPLE_I2S_DI_IO (7)
/* SD card SPI GPIOs */
#define EXAMPLE_SD_SPI_CLK_IO (18)
#define EXAMPLE_SD_SPI_MOSI_IO (19)
#define EXAMPLE_SD_SPI_MISO_IO (14)
#define EXAMPLE_SD_SPI_CS_IO (17)
#else
#define EXAMPLE_I2C_NUM (0)
#define EXAMPLE_I2C_SDA_IO (3)
#define EXAMPLE_I2C_SCL_IO (2)
/* I2S port and GPIOs */
#define EXAMPLE_I2S_NUM (0)
#define EXAMPLE_I2S_MCK_IO (0)
#define EXAMPLE_I2S_BCK_IO (1)
#define EXAMPLE_I2S_WS_IO (10)
#define EXAMPLE_I2S_DI_IO (8)
/* SD card SPI GPIOs */
#define EXAMPLE_SD_SPI_CLK_IO (5)
#define EXAMPLE_SD_SPI_MOSI_IO (7)
#define EXAMPLE_SD_SPI_MISO_IO (6)
#define EXAMPLE_SD_SPI_CS_IO (4)
#endif
/* I2S configurations */ /* I2S configurations */
#define EXAMPLE_I2S_CHAN_NUM (4) #define EXAMPLE_I2S_CHAN_NUM (4)
@@ -9,7 +9,6 @@ from pytest_embedded_idf.utils import soc_filtered_targets
@pytest.mark.generic @pytest.mark.generic
@idf_parametrize('target', soc_filtered_targets('SOC_I2S_SUPPORTS_TDM == 1'), indirect=['target']) @idf_parametrize('target', soc_filtered_targets('SOC_I2S_SUPPORTS_TDM == 1'), indirect=['target'])
@pytest.mark.temp_skip_ci(targets=['esp32h21'], reason='lack of runners') @pytest.mark.temp_skip_ci(targets=['esp32h21'], reason='lack of runners')
@pytest.mark.temp_skip_ci(targets=['esp32h4'], reason='cannot pass') # TODO: IDF-15609
def test_i2s_es7210_tdm_example(dut: Dut) -> None: def test_i2s_es7210_tdm_example(dut: Dut) -> None:
dut.expect_exact('example: Create I2S receive channel') dut.expect_exact('example: Create I2S receive channel')
dut.expect_exact('example: Configure I2S receive channel to TDM mode') dut.expect_exact('example: Configure I2S receive channel to TDM mode')
@@ -10,13 +10,13 @@ menu "Example Configuration"
config EXAMPLE_I2C_SDA_IO config EXAMPLE_I2C_SDA_IO
int "I2C SDA IO" int "I2C SDA IO"
default 17 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 default 17 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32H4
default 9 if IDF_TARGET_ESP32H2 default 9 if IDF_TARGET_ESP32H2
default 7 default 7
config EXAMPLE_I2C_SCL_IO config EXAMPLE_I2C_SCL_IO
int "I2C SCL IO" int "I2C SCL IO"
default 16 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 default 16 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32H4
default 8 if IDF_TARGET_ESP32H2 || IDF_TARGET_ESP32P4 default 8 if IDF_TARGET_ESP32H2 || IDF_TARGET_ESP32P4
default 6 default 6
@@ -13,7 +13,6 @@ from pytest_embedded_idf.utils import soc_filtered_targets
indirect=['target'], indirect=['target'],
) )
@pytest.mark.temp_skip_ci(targets=['esp32h21'], reason='lack of runners') @pytest.mark.temp_skip_ci(targets=['esp32h21'], reason='lack of runners')
@pytest.mark.temp_skip_ci(targets=['esp32h4'], reason='cannot pass') # TODO: IDF-15609
def test_i2s_es8311_example_generic(dut: Dut) -> None: def test_i2s_es8311_example_generic(dut: Dut) -> None:
dut.expect('i2s es8311 codec example start') dut.expect('i2s es8311 codec example start')
dut.expect('-----------------------------') dut.expect('-----------------------------')