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

fesp32@joov.de
Posts: 13
Joined: Tue May 02, 2017 9:33 am

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

Postby fesp32@joov.de » Tue Jun 20, 2017 8:11 am

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

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

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

Postby ESP_igrr » Tue Jun 20, 2017 8:29 am

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.

fesp32@joov.de
Posts: 13
Joined: Tue May 02, 2017 9:33 am

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

Postby fesp32@joov.de » Tue Jun 20, 2017 8:55 am

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

BuddyCasino
Posts: 263
Joined: Sun Jun 19, 2016 12:00 am

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

Postby BuddyCasino » Tue Jun 20, 2017 12:55 pm

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.

Who is online

Users browsing this forum: ESP_Roland, Google [Bot], Heggico and 102 guests