Empty project uses 80kb more ram than with esp-idf, why?

ipsilondev
Posts: 6
Joined: Thu Sep 07, 2017 3:41 pm

Empty project uses 80kb more ram than with esp-idf, why?

Postby ipsilondev » Wed Jan 31, 2018 12:53 am

Hi everyone,

i have been working with my newly arrived esp32. for the purpose i'm looking to use it, i need the biggest amount of ram possible (esp32 is the cheapest cpu with the most amount of ram available in the market) so have been playing with it. on one of my trials, i just uploaded an empty project compiled with arduino IDE and i got 218Kb free of heap. Pretty good. then i uploaded the hello_world, example with

Code: Select all

make flash
and printing the heap with

Code: Select all

system_get_free_heap_size();
that got me 301kb of free memory.

so, why there is so big gap? the serial communication in arduino takes that much of ram? is

Code: Select all

system_get_free_heap_size()
also counting iram there? i only need to free dram really.

config has BT / TLS all disabled, but again, both are just empty projects.

Any idea?

ESP_Sprite
Posts: 9715
Joined: Thu Nov 26, 2015 4:08 am

Re: Empty project uses 80kb more ram than with esp-idf, why?

Postby ESP_Sprite » Wed Jan 31, 2018 2:26 am

System_get_free_heap_size() returns all available memory that can be used as heap (i.e. can be returned from malloc()); IRAM is not part of this. No idea why Arduino takes up 80K; perhaps it configures esp-idf slightly differently (e.g. allocating the tcp/ip stack memory statically instead of dynamically).

You can also use Arduino as a component in esp-idf and that gives you the freedom to configure esp-idf in any way you want; perhaps that is an option?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Empty project uses 80kb more ram than with esp-idf, why?

Postby WiFive » Wed Jan 31, 2018 2:50 am

Bluetooth and task stacks probably

ipsilondev
Posts: 6
Joined: Thu Sep 07, 2017 3:41 pm

Re: Empty project uses 80kb more ram than with esp-idf, why?

Postby ipsilondev » Wed Jan 31, 2018 2:59 am

ESP_Sprite wrote:System_get_free_heap_size() returns all available memory that can be used as heap (i.e. can be returned from malloc()); IRAM is not part of this. No idea why Arduino takes up 80K; perhaps it configures esp-idf slightly differently (e.g. allocating the tcp/ip stack memory statically instead of dynamically).

You can also use Arduino as a component in esp-idf and that gives you the freedom to configure esp-idf in any way you want; perhaps that is an option?
Yep, i'm seeing it as a possibility, i need to figure out how to compile the webserver lib as a component :)
WiFive wrote:Bluetooth and task stacks probably
from

Code: Select all

make menuconfig
i have BT completely disabled. if you compile with arduino IDE it does enable it anyway? where i could check this?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Empty project uses 80kb more ram than with esp-idf, why?

Postby WiFive » Wed Jan 31, 2018 3:54 am

Arduino libraries are precompiled so I think bt memory is always reserved and you have to release it at startup. Or maybe not since it is a link time option, but you would have to edit the sdkconfig in the arduino directory.

ipsilondev
Posts: 6
Joined: Thu Sep 07, 2017 3:41 pm

Re: Empty project uses 80kb more ram than with esp-idf, why?

Postby ipsilondev » Wed Jan 31, 2018 12:53 pm

WiFive wrote:Arduino libraries are precompiled so I think bt memory is always reserved and you have to release it at startup. Or maybe not since it is a link time option, but you would have to edit the sdkconfig in the arduino directory.
Thanks for the tip ! but unfortunately, i wasn't able to free the memory :(

i made the following:
  • Disabled and put to 0 bt memory at hardware/expressif/esp32/tools/sdk/sdkconfig
    Disabled and put to 0 (CONFIG_BT_RESERVE_DRAM) on hardware/expressif/esp32/tools/sdk/include/config/sdkconfig.h
    Deleted header and link files for bt, erased -lbt and "-I{compiler.sdk.path}/include/bt" from hardware/expressif/esp32/platform.txt
    Erased bt includes at hardware/expressif/esp32/cores/esp32/esp32-hal.h
    Tried erasing the constants for trace memory and bt at hardware/expressif/esp32/tools/sdk/ld/esp32.ld
so, maybe i missed something? but i don't think the bt stack is the one consuming the memory.
There is any way to trace from where or what is consuming the memory?

Thanks in advance!

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Empty project uses 80kb more ram than with esp-idf, why?

Postby WiFive » Wed Jan 31, 2018 2:05 pm

idf_size.py

ipsilondev
Posts: 6
Joined: Thu Sep 07, 2017 3:41 pm

Re: Empty project uses 80kb more ram than with esp-idf, why?

Postby ipsilondev » Wed Jan 31, 2018 4:26 pm

WiFive wrote:idf_size.py
Wasn't much of help really. not only on the empty idf project was giving me an incorrect total memory (170kb vs 300kb from get heap), plus, if you compile with arduino IDE, you don't get the map file to actually use it.

I switched to arduino-esp32 as a component already, and i only have 2kb less (298kb) than plain idf.

It would be awesome if some kind of warning could be set in the arduino-esp32 github or somewhere, about this, until is fixed / resolved :D

Who is online

Users browsing this forum: No registered users and 54 guests