BLE memory fragmentation malloc problem

Bartosz
Posts: 8
Joined: Tue Jul 09, 2019 8:06 pm

BLE memory fragmentation malloc problem

Postby Bartosz » Thu Feb 10, 2022 12:56 pm

Hi
I've used ESP32-PICO-V3-02 in my project so in theory there's a lot of RAM.
I need to allocate 134400 bytes buffer for LCD so it must be usable by DMA.
I also need to use BLE for data transmission.

LCd buffer is allocated using heap_caps_malloc:
vlcd = (uint16_t*)heap_caps_malloc(LCD_SCREEN_BYTE_SIZE, MALLOC_CAP_DMA);

without BLE enabled in menuconfig everything works
heap_caps_print_heap_info(MALLOC_CAP_DMA):
Heap summary for capabilities 0x00000008:
At 0x3ffae6e0 len 6432 free 128 allocated 4152 min_free 128
largest_free_block 0 alloc_blocks 31 free_blocks 0 total_blocks 31
At 0x3ffb5eb0 len 172368 free 151600 allocated 18616 min_free 150608
largest_free_block 131072 alloc_blocks 21 free_blocks 2 total_blocks 23
At 0x3ffe0440 len 15072 free 12920 allocated 0 min_free 12920
largest_free_block 8192 alloc_blocks 0 free_blocks 1 total_blocks 1
At 0x3ffe4350 len 113840 free 111688 allocated 0 min_free 111688
largest_free_block 65536 alloc_blocks 0 free_blocks 1 total_blocks 1
Totals:
free 276336 allocated 22768 min_free 275344 largest_free_block 131072

largest_free_block is 131072 (lower than required 134400) but heap_caps_malloc allocate required buffer

with BLE enabled in menuconfig (BLE Only Bluedroid, first malloc from PSRAM):
heap_caps_print_heap_info(MALLOC_CAP_DMA):
Heap summary for capabilities 0x00000008:
At 0x3ffae6e0 len 62592 free 37492 allocated 22948 min_free 36500
largest_free_block 32768 alloc_blocks 55 free_blocks 2 total_blocks 57
At 0x3ffc3b38 len 115912 free 113760 allocated 0 min_free 113760
largest_free_block 65536 alloc_blocks 0 free_blocks 1 total_blocks 1
At 0x3ffe0440 len 15072 free 12920 allocated 0 min_free 12920
largest_free_block 8192 alloc_blocks 0 free_blocks 1 total_blocks 1
At 0x3ffe4350 len 113840 free 111688 allocated 0 min_free 111688
largest_free_block 65536 alloc_blocks 0 free_blocks 1 total_blocks 1
Totals:
free 275860 allocated 22948 min_free 274868 largest_free_block 65536

largest_free_block is 65536, heap_caps_malloc fails

I've tried different settings in menuconfig but they not affecting largest_free_block value when BLE is enabled. I need LCD and BLE working together - any ideas how to do that?

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 111 guests