From 776c57e0ac0bcbecbcea0bd5ae620608352fe512 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Mon, 20 Aug 2018 16:12:14 +1000 Subject: [PATCH 1/2] heap: When adding a new heap, allocate its metadata block from internal memory only --- components/heap/heap_caps_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/heap/heap_caps_init.c b/components/heap/heap_caps_init.c index af1e27df4..d675e408d 100644 --- a/components/heap/heap_caps_init.c +++ b/components/heap/heap_caps_init.c @@ -206,7 +206,7 @@ esp_err_t heap_caps_add_region_with_caps(const uint32_t caps[], intptr_t start, } } - heap_t *p_new = malloc(sizeof(heap_t)); + heap_t *p_new = heap_caps_malloc(sizeof(heap_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT); if (p_new == NULL) { err = ESP_ERR_NO_MEM; goto done; From c4ed9d15f735d4322ef7ccd6e5c1ab11cb88ac02 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Mon, 20 Aug 2018 16:14:13 +1000 Subject: [PATCH 2/2] heap: Drop priority of DMA reserved memory pool Ensures that non-reserved memory should be used up first, before allocating from this pool. --- components/esp32/spiram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp32/spiram.c b/components/esp32/spiram.c index 72198734e..98effb127 100644 --- a/components/esp32/spiram.c +++ b/components/esp32/spiram.c @@ -185,7 +185,7 @@ esp_err_t esp_spiram_reserve_dma_pool(size_t size) { return ESP_ERR_NO_MEM; } - uint32_t caps[] = { MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL, 0, MALLOC_CAP_8BIT|MALLOC_CAP_32BIT }; + uint32_t caps[] = { 0, MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL, MALLOC_CAP_8BIT|MALLOC_CAP_32BIT }; esp_err_t e = heap_caps_add_region_with_caps(caps, (intptr_t) dma_heap, (intptr_t) dma_heap+next_size-1); if (e != ESP_OK) { return e;