Page 1 of 1

Is the FreeRTOS in esp-idf utilized to the smallest?

Posted: Sun Jun 04, 2017 3:07 pm
by aifer2007
Is the FreeRTOS in esp-idf/componnents utilized to the smallest sytem for esp32?

Re: Is the FreeRTOS in esp-idf utilized to the smallest?

Posted: Sun Jun 04, 2017 10:27 pm
by edmund-huber
Can you clarify what you are trying to figure out, or what you mean?

In general, I would say that there is room for ESP-IDF to be better about RAM usage, but also you can slim down ESP-IDF quite a bit through sdkconfig options. Where it comes to Flash, the linker in the esp32 toolchain (ld) does a good job of stripping unused code and data thanks to "-fdata-sections -ffunction-sections" and "-Wl,--gc-sections".

Re: Is the FreeRTOS in esp-idf utilized to the smallest?

Posted: Mon Jun 05, 2017 6:22 am
by aifer2007
Thank you.

I just want to get more RAM on esp32.

Esp32 has 512K RAM, but in fact, only less then 200K can be used by user app(with FreeRTOS).

I want to know how to slim down the RAM userd by esp32 system function and/or FreeRTOS.

Re: Is the FreeRTOS in esp-idf utilized to the smallest?

Posted: Mon Jun 05, 2017 7:00 am
by edmund-huber
Try building in release mode.

If you're not using WiFi or Bluetooth, disable either or both under "Component config"

If you're only using BLE, not BT Classic, find the "Release DRAM from Classic BT Controller" option and try that out. That's about 30KB according to the documentation for that option.

Under WiFi options, check out "Max number of WiFi dynamic RX buffers" and "Max number of WiFi dynamic TX buffers". You might be able to squeeze another 20-ish KB out of there.

I'm not sure what else to try .. I'm interested to see what other people have to say.

Re: Is the FreeRTOS in esp-idf utilized to the smallest?

Posted: Mon Jun 05, 2017 8:23 am
by f.h-f.s.
Memory is divided into 5 parts. SRAM0-0 (32KB), 0-1(32KB), 0-2(128KB), 1(128KB), 2(200KB).
SRAM0-0 and 0-1 are CPU0 CPU1 instruction cache regions for instructions loaded from flash.
SRAM0-2 is used for instructions too.
SRAM1 and 2 are used for normal malloc's since it's 8bit accessible. Program data, is stored there too. If BT or Wifi are enabled each will reserve 64KB here and will allocate some more at runtime.

I needed a little space too, so I disabled CPU1 which gave me 32KB. You have to use the FreeRTOS functions to malloc in 32bit regions.
Have a look at esp-idf/components/esp32/heap_alloc_caps.c

Re: Is the FreeRTOS in esp-idf utilized to the smallest?

Posted: Mon Jun 05, 2017 10:30 am
by aifer2007
Great!
All the aboves work well.


Is a var declared as const storaged in FLASH?
Or I must add ICACHE_RODATA_ATTR before const?

Re: Is the FreeRTOS in esp-idf utilized to the smallest?

Posted: Mon Jun 05, 2017 11:46 am
by ESP_igrr
const data is stored in flash by default.

Re: Is the FreeRTOS in esp-idf utilized to the smallest?

Posted: Tue Jun 06, 2017 9:53 am
by aifer2007
OK, Thanks