Page 1 of 2
No heap anymore after adding bluetooth in menuconfig
Posted: Wed Sep 20, 2017 9:06 am
by jumjum123
Plan was to start adding bluetooth support to my application.
First step was to set Bluetooth in Component Config and compiled everything without any other changes.
Download to board, reset and got abort after starting scheduler.
Some time later after a lot of testing etc. found the problem is in heapsize
In my application, without bluetooth, after starting everything, esp_get_free_heap_size() returns 133644
Checking heapsize in start_cpu0_default, without bluetooth, gives 73644 only.
Looks like lot of heap is used during startup (?)
Checking heapsize in start_cpu0_default, now with bluetooth, gives 720 only.
Fully understand, that this is too poor to do anything.
Where is memory gone, I only added Bluetooth to components ?
Is there anything I can do ?
Re: No heap anymore after adding bluetooth in menuconfig
Posted: Wed Sep 20, 2017 9:26 am
by jumjum123
Some more info, compared heap during startup with / without bluetooth.
BTW, line 333 in components/esp32/cpu_start.c changed to get heapsize
Code: Select all
ESP_LOGI(TAG, "Starting scheduler(%d) on PRO CPU.",esp_get_free_heap_size());
without bluetooth
I (4571) cpu_start: Single core mode
I (4604) heap_init: Initializing. RAM available for dynamic allocation:
I (4660) heap_init: At 3FFAE2A0 len 00001D60 (7 KiB): DRAM
I (4708) heap_init: At 3FFCCFC8 len 00013038 (76 KiB): DRAM
I (4757) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (4807) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (4858) heap_init: At 400909E0 len 0000F620 (61 KiB): IRAM
I (4907) cpu_start: Pro cpu start user code
I (5059) cpu_start: Starting scheduler(73644) on PRO CPU.
with bluetooth
I (4753) cpu_start: Single core mode
I (4786) heap_init: Initializing. RAM available for dynamic allocation:
I (4842) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (4890) heap_init: At 3FFDCFC8 len 00003038 (12 KiB): DRAM
I (4939) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (4989) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (5041) heap_init: At 400909E0 len 0000F620 (61 KiB): IRAM
I (5090) cpu_start: Pro cpu start user code
I (5241) cpu_start: Starting scheduler(828) on PRO CPU.
There is a difference of 64 k in 2nd heap_init
Re: No heap anymore after adding bluetooth in menuconfig
Posted: Wed Sep 20, 2017 10:16 am
by loboris
Bluetooth, when enabled, uses a lot of memory. You can free ~30K by selecting → Component config → Bluetooth → Bluedroid Bluetooth stack enabled → Release DRAM from Classic BT controller if you are using BLE only.
If this is not enough, you will need to use ESP32 with psRAM...
Re: No heap anymore after adding bluetooth in menuconfig
Posted: Wed Sep 20, 2017 11:23 am
by jumjum123
@ loboris,
thanks a lot. This helped to get my app running again.
I will continue and try to get BLE implemented.
When ESP32 arrived, memory seemed to be endless.
Now we are close to good old ESP8266, starting to fight for bytes
Hopefully, there is somebody who will optimize memory consumption.
Re: No heap anymore after adding bluetooth in menuconfig
Posted: Wed Sep 20, 2017 12:11 pm
by loboris
If your application needs a lot of heap, I would recommend using ESP32 with
spiram. In small quantities you can get two modules from
AnalogLamb, ALB32-WROVER and ESP32-WROVER.
SPIRAM support is now included in latest esp-idf and xtensa toolchain, so there should be no problem using it.
You will have 4MB of heap available for application usage and more DRAM can be left for the system.
Re: No heap anymore after adding bluetooth in menuconfig
Posted: Wed Sep 20, 2017 12:41 pm
by jumjum123
AFAIK, there is no bread board with psram.
We have a nice wording for people like me, I'm born with (at least) 2 left hands.
Means soldering a chip on a board is far beyond my skills.
Therefore I'm waiting for a board, acceptable priced.
Anyway, from my point of view, there is a bottleneck during start.
Available heap is about 60 k less, compared to running tasks.
There should be a way to bypass this bottleneck.
Re: No heap anymore after adding bluetooth in menuconfig
Posted: Wed Sep 20, 2017 2:02 pm
by kolban
jumjum123,
While I am also not aware of any breakout boards support WROVER, I am delighted with this board:
https://www.analoglamb.com/product/esp- ... er-module/
(see @loboris post above).
While the board is indeed pricy ($47) it is (opinion) well worth it. Think how much time we spend tinkering with these things. Not only does that board contain a WROVER module, it has a screen, great breakout pins and ... most importantly of all ... built in JTAG. This means that you can source step through your running apps on the ESP32 in real time.
This contains a WROVER as well as male header pins. These can be connected by male/female socket wires to your breadboard. The result was an immediate whopping 4.5MBytes of RAM available to my apps. In my JavaScript Duktape experiments, I was dead in the water with 190K of RAM on the WROOM but with WROVER, memory issues are gone. Its early days for WROVER, but "its-a-coming".
WROOM = ESP32 module.
WROVER = ESP32 module where module includes pSRAM.
Re: No heap anymore after adding bluetooth in menuconfig
Posted: Wed Sep 20, 2017 3:52 pm
by loboris
kolban wrote:While I am also not aware of any breakout boards support WROVER...
AnalogLam now has
breakout board for ESP32-WROVER.
It looks like it is sold without any component soldered. It would be good if AnalogLamb could release this board with all components (including ESP32-WROVER module) soldered, for those with no soldering skills.
Re: No heap anymore after adding bluetooth in menuconfig
Posted: Wed Sep 20, 2017 4:40 pm
by BuddyCasino
I have three Wrover modules and some unpopulated Wroom breakout boards. Does that mean they are not pin-compatible and I need new breakouts?
Re: No heap anymore after adding bluetooth in menuconfig
Posted: Wed Sep 20, 2017 4:57 pm
by loboris
BuddyCasino wrote:I have three Wrover modules and some unpopulated Wroom breakout boards. Does that mean they are not pin-compatible and I need new breakouts?
Wrower and Wroon has different footprint. There is also
ALB32-WROVER which has the same footprint as ESP32-WROOM, but with 4MB psRAM included.