Page 1 of 1

Use single core to free RAM/heap (disable flash-cache of 2nd core)

Posted: Tue Jun 20, 2017 8:11 am
by fesp32@joov.de
Hi all,

I am trying to squeeze an app into the ESP32 which uses Bluetooth and Wifi and heap space is under pressure. I do not need a lot of CPU so I am happy to disable the second CPU to free some RAM.

I disabled CONFIG_MEMMAP_SMP and I enabled CONFIG_FREERTOS_UNICORE and this gives me 5748 additional bytes of RAM.

I was actually expecting that the flash-cache for the second core gets disabled as well and that I get an additional 32 kBytes of RAM, but apparently this does not happen automatically.

What do I have to change to disable the flash-cache of the second core?

Any pointers welcome.

Cheers,
Johannes

Re: Use single core to free RAM/heap (disable flash-cache of 2nd core)

Posted: Tue Jun 20, 2017 8:29 am
by ESP_igrr
Currently APP CPU cache region is not added to the allocator even if you enable single core mode.
You can easily change this however, if you remove the following line in components/esp32/heap_alloc_caps.c:

Code: Select all

disable_mem_region((void*)0x40078000, (void*)0x40080000); //CPU1 cache region
Note however that this will not increase the size of byte addressable heap memory, which the "normal" heap used by malloc/calloc/realloc.
Instruction memory can only be accessed as 32-bit words, and you can allocate it using pvPortMallocCaps function with MALLOC_CAP_32BIT argument.

Re: Use single core to free RAM/heap (disable flash-cache of 2nd core)

Posted: Tue Jun 20, 2017 8:55 am
by fesp32@joov.de
Many thanks for the fast and precise reply. I see the 32 kBytes now as IRAM in the boot-up messages, and as you said they do not increase the size reported by esp_get_free_heap_size() used by malloc() etc.

Unfortunately when enabling Bluetooth this also does not re-use this IRAM region automatically. I was hoping some part of the Bluetooth driver would make use of IRAM, but apparently is lives entirely on DRAM. Bluetooth uses 140 kBytes of DRAM (without any application) which I find excessive. Almost a show stopper when using Bluetooth+Wifi.

Cheers,
Johannes

Re: Use single core to free RAM/heap (disable flash-cache of 2nd core)

Posted: Tue Jun 20, 2017 12:55 pm
by BuddyCasino
Bluetooth uses 140 kBytes of DRAM (without any application) which I find excessive. Almost a show stopper when using Bluetooth+Wifi.
Not sure its 140 kBytes, but I agree advanced apps are hard to do with the current memory limitations. Wrover will hopefully change that.