From bc4fee11b5d88dbef6f874e24e862d1155df1873 Mon Sep 17 00:00:00 2001 From: Chen Jichang Date: Fri, 15 Aug 2025 16:28:48 +0800 Subject: [PATCH] fix(rmt): alloc channel memory from internal --- components/esp_driver_rmt/src/rmt_rx.c | 6 +++--- components/esp_driver_rmt/src/rmt_tx.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/esp_driver_rmt/src/rmt_rx.c b/components/esp_driver_rmt/src/rmt_rx.c index 6cf51d176da..0883098142c 100644 --- a/components/esp_driver_rmt/src/rmt_rx.c +++ b/components/esp_driver_rmt/src/rmt_rx.c @@ -188,8 +188,8 @@ esp_err_t rmt_new_rx_channel(const rmt_rx_channel_config_t *config, rmt_channel_ ESP_RETURN_ON_FALSE(config->flags.with_dma == 0, ESP_ERR_NOT_SUPPORTED, TAG, "DMA not supported"); #endif // SOC_RMT_SUPPORT_DMA - // malloc channel memory - uint32_t mem_caps = RMT_MEM_ALLOC_CAPS; + // allocate channel memory from internal memory because it contains atomic variable + uint32_t mem_caps = MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT; rx_channel = heap_caps_calloc(1, sizeof(rmt_rx_channel_t), mem_caps); ESP_GOTO_ON_FALSE(rx_channel, ESP_ERR_NO_MEM, err, TAG, "no mem for rx channel"); // gpio is not configured yet @@ -197,7 +197,7 @@ esp_err_t rmt_new_rx_channel(const rmt_rx_channel_config_t *config, rmt_channel_ // create DMA descriptor size_t num_dma_nodes = 0; if (config->flags.with_dma) { - mem_caps |= MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA; + mem_caps |= MALLOC_CAP_DMA; num_dma_nodes = config->mem_block_symbols * sizeof(rmt_symbol_word_t) / RMT_DMA_DESC_BUF_MAX_SIZE + 1; num_dma_nodes = MAX(2, num_dma_nodes); // at least 2 DMA nodes for ping-pong // DMA descriptors must be placed in internal SRAM diff --git a/components/esp_driver_rmt/src/rmt_tx.c b/components/esp_driver_rmt/src/rmt_tx.c index be85030d3fa..4e366aaf126 100644 --- a/components/esp_driver_rmt/src/rmt_tx.c +++ b/components/esp_driver_rmt/src/rmt_tx.c @@ -256,15 +256,15 @@ esp_err_t rmt_new_tx_channel(const rmt_tx_channel_config_t *config, rmt_channel_ ESP_RETURN_ON_FALSE(config->flags.with_dma == 0, ESP_ERR_NOT_SUPPORTED, TAG, "DMA not supported"); #endif - // malloc channel memory - uint32_t mem_caps = RMT_MEM_ALLOC_CAPS; + // allocate channel memory from internal memory because it contains atomic variable + uint32_t mem_caps = MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT; tx_channel = heap_caps_calloc(1, sizeof(rmt_tx_channel_t) + sizeof(rmt_tx_trans_desc_t) * config->trans_queue_depth, mem_caps); ESP_GOTO_ON_FALSE(tx_channel, ESP_ERR_NO_MEM, err, TAG, "no mem for tx channel"); // GPIO configuration is not done yet tx_channel->base.gpio_num = -1; // create DMA descriptors if (config->flags.with_dma) { - mem_caps |= MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA; + mem_caps |= MALLOC_CAP_DMA; // DMA descriptors must be placed in internal SRAM uint32_t data_cache_line_size = cache_hal_get_cache_line_size(CACHE_LL_LEVEL_INT_MEM, CACHE_TYPE_DATA); // the alignment should meet both the DMA and cache requirement