From 5feb57a56b93e6d7e814ab076e7227122e50d7a6 Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Tue, 18 Mar 2025 16:20:15 +0800 Subject: [PATCH 1/2] fix(i2s): fixed mismatch of the i2s and gdma iram-safe config Closes https://github.com/espressif/esp-idf/issues/15533 --- components/driver/Kconfig | 1 + components/driver/i2s/i2s_private.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/components/driver/Kconfig b/components/driver/Kconfig index f191fc1d49..e474e6fd03 100644 --- a/components/driver/Kconfig +++ b/components/driver/Kconfig @@ -256,6 +256,7 @@ menu "Driver Configurations" config I2S_ISR_IRAM_SAFE bool "I2S ISR IRAM-Safe" default n + select GDMA_ISR_IRAM_SAFE if SOC_GDMA_SUPPORTED help Ensure the I2S interrupt is IRAM-Safe by allowing the interrupt handler to be executable when the cache is disabled (e.g. SPI Flash write). diff --git a/components/driver/i2s/i2s_private.h b/components/driver/i2s/i2s_private.h index 0777091c85..dae3aba359 100644 --- a/components/driver/i2s/i2s_private.h +++ b/components/driver/i2s/i2s_private.h @@ -30,7 +30,7 @@ extern "C" { // If ISR handler is allowed to run whilst cache is disabled, // Make sure all the code and related variables used by the handler are in the SRAM -#if CONFIG_I2S_ISR_IRAM_SAFE +#if CONFIG_I2S_ISR_IRAM_SAFE || CONFIG_GDMA_ISR_IRAM_SAFE #define I2S_INTR_ALLOC_FLAGS (ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_INTRDISABLED | ESP_INTR_FLAG_SHARED) #define I2S_MEM_ALLOC_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT) #else From 2ee026308375a50b09e14c61e89794f50d1ccd24 Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Thu, 20 Mar 2025 16:55:17 +0800 Subject: [PATCH 2/2] fix(i2s): add check for i2s DMA buffer array allocation Closes https://github.com/espressif/esp-idf/issues/15607 --- components/driver/i2s/i2s_common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/components/driver/i2s/i2s_common.c b/components/driver/i2s/i2s_common.c index b226dbc94c..dcd06bd314 100644 --- a/components/driver/i2s/i2s_common.c +++ b/components/driver/i2s/i2s_common.c @@ -423,6 +423,7 @@ esp_err_t i2s_alloc_dma_desc(i2s_chan_handle_t handle, uint32_t num, uint32_t bu handle->dma.desc = (lldesc_t **)heap_caps_calloc(num, sizeof(lldesc_t *), I2S_MEM_ALLOC_CAPS); ESP_GOTO_ON_FALSE(handle->dma.desc, ESP_ERR_NO_MEM, err, TAG, "create I2S DMA decriptor array failed"); handle->dma.bufs = (uint8_t **)heap_caps_calloc(num, sizeof(uint8_t *), I2S_MEM_ALLOC_CAPS); + ESP_GOTO_ON_FALSE(handle->dma.bufs, ESP_ERR_NO_MEM, err, TAG, "create I2S DMA buffer array failed"); size_t desc_size = 0; for (int i = 0; i < num; i++) { /* Allocate DMA descriptor */