From d5ce0e4757b8b8f37b7388fc75f1ef59652cd8ac 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 32aa19b67e2..28660e09013 100644 --- a/components/esp_driver_rmt/src/rmt_rx.c +++ b/components/esp_driver_rmt/src/rmt_rx.c @@ -207,8 +207,8 @@ esp_err_t rmt_new_rx_channel(const rmt_rx_channel_config_t *config, rmt_channel_ ESP_RETURN_ON_FALSE(config->flags.allow_pd == 0, ESP_ERR_NOT_SUPPORTED, TAG, "not able to power down in light sleep"); #endif // SOC_RMT_SUPPORT_SLEEP_RETENTION - // 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 @@ -219,7 +219,7 @@ esp_err_t rmt_new_rx_channel(const rmt_rx_channel_config_t *config, rmt_channel_ size_t num_dma_nodes = 0; if (config->flags.with_dma) { // DMA descriptors must be placed in internal SRAM - 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) / DMA_DESCRIPTOR_BUFFER_MAX_SIZE + 1; num_dma_nodes = MAX(2, num_dma_nodes); // at least 2 DMA nodes for ping-pong rmt_dma_descriptor_t *dma_nodes = heap_caps_aligned_calloc(RMT_DMA_DESC_ALIGN, num_dma_nodes, sizeof(rmt_dma_descriptor_t), mem_caps); diff --git a/components/esp_driver_rmt/src/rmt_tx.c b/components/esp_driver_rmt/src/rmt_tx.c index 782d8fed6dc..376be9f594c 100644 --- a/components/esp_driver_rmt/src/rmt_tx.c +++ b/components/esp_driver_rmt/src/rmt_tx.c @@ -272,8 +272,8 @@ esp_err_t rmt_new_tx_channel(const rmt_tx_channel_config_t *config, rmt_channel_ ESP_RETURN_ON_FALSE(config->flags.allow_pd == 0, ESP_ERR_NOT_SUPPORTED, TAG, "not able to power down in light sleep"); #endif // SOC_RMT_SUPPORT_SLEEP_RETENTION - // 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 @@ -281,7 +281,7 @@ esp_err_t rmt_new_tx_channel(const rmt_tx_channel_config_t *config, rmt_channel_ // create DMA descriptors if (config->flags.with_dma) { // DMA descriptors must be placed in internal SRAM - mem_caps |= MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA; + mem_caps |= MALLOC_CAP_DMA; rmt_dma_descriptor_t *dma_nodes = heap_caps_aligned_calloc(RMT_DMA_DESC_ALIGN, RMT_DMA_NODES_PING_PONG, sizeof(rmt_dma_descriptor_t), mem_caps); ESP_GOTO_ON_FALSE(dma_nodes, ESP_ERR_NO_MEM, err, TAG, "no mem for tx DMA nodes"); tx_channel->dma_nodes = dma_nodes;