From 7fbc350589536c2690c62763c0b2ea7d0314f162 Mon Sep 17 00:00:00 2001 From: Abdelatif Guettouche Date: Fri, 5 Mar 2021 11:11:08 +0100 Subject: [PATCH] xtensa/esp32: Warn about unused memory regions. In case CONFIG_MM_REGIONS doesn't include all the available memory regions the user will have a warning to increase it. Signed-off-by: Abdelatif Guettouche --- arch/xtensa/src/esp32/esp32_allocateheap.c | 28 ++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/arch/xtensa/src/esp32/esp32_allocateheap.c b/arch/xtensa/src/esp32/esp32_allocateheap.c index 09e4a5c1d34..df255a79a77 100644 --- a/arch/xtensa/src/esp32/esp32_allocateheap.c +++ b/arch/xtensa/src/esp32/esp32_allocateheap.c @@ -96,17 +96,41 @@ void xtensa_add_region(void) { void *start; size_t size; + int availregions; + int nregions = CONFIG_MM_REGIONS - 1; + +#ifdef CONFIG_SMP + availregions = 2; +# ifdef CONFIG_BOARD_LATE_INITIALIZE + availregions++; +# else + minfo("A ~3KB heap region can be added to the heap by enabling" + " CONFIG_BOARD_LATE_INITIALIZE\n"); +# endif +#else + availregions = 1; +#endif + +#ifdef CONFIG_ESP32_SPIRAM + availregions++; +#endif + + if (nregions < availregions) + { + mwarn("Some memory regions are left unused!\n"); + mwarn("Increase CONFIG_MM_NREGIONS to add them to the heap\n"); + } #ifndef CONFIG_SMP start = (FAR void *)(HEAP_REGION2_START + XTENSA_IMEM_REGION_SIZE); size = (size_t)(uintptr_t)&_eheap - (size_t)start; umm_addregion(start, size); - + #else start = (FAR void *)HEAP_REGION2_START; size = (size_t)(HEAP_REGION2_END - HEAP_REGION2_START); umm_addregion(start, size); - + start = (FAR void *)HEAP_REGION3_START + XTENSA_IMEM_REGION_SIZE; size = (size_t)(uintptr_t)&_eheap - (size_t)start; umm_addregion(start, size);