Bigger partition table uses more heap on same hardware

Leander
Posts: 28
Joined: Thu Sep 26, 2019 8:50 pm

Bigger partition table uses more heap on same hardware

Postby Leander » Wed Apr 01, 2020 7:04 pm

I'm using the same hardware with external 16MB flash for this test.

I'm printing the free heap before and after the nvs_flash_init() function.
With the 4MB partition table i still have 256708 bytes of heap while flashing with 16MB partition table there is only 238788 bytes of heap left.
As I need all available heap for combined Wifi and BLE application i'm wondering if this is normal.
A difference of almost 18K seems quite a lot.

Flashing 4MB partition table:

Code: Select all

I (31) boot: ESP-IDF v3.3-rc-dirty 2nd stage bootloader
I (31) boot: compile time 07:25:28
I (40) boot: Enabling RNG early entropy source...
I (40) boot: SPI Speed      : 40MHz
I (41) boot: SPI Mode       : DIO
I (45) boot: SPI Flash Size : 16MB
I (49) boot: Partition Table:
I (53) boot: ## Label            Usage          Type ST Offset   Length
I (60) boot:  0 nvs              WiFi data        01 02 00009000 00025000
I (67) boot:  1 otadata          OTA data         01 00 0002e000 00002000
I (75) boot:  2 ota_0            OTA app          00 10 00030000 001c0000
I (82) boot:  3 ota_1            OTA app          00 11 001f0000 001c0000
I (90) boot:  4 storage          Unknown data     01 82 003b0000 00050000
I (97) boot: End of partition table
I (101) esp_image: segment 0: paddr=0x00030020 vaddr=0x3f400020 size=0x53bd8 (343000) map
I (231) esp_image: segment 1: paddr=0x00083c00 vaddr=0x3ffbdb60 size=0x034ac ( 13484) load
I (236) esp_image: segment 2: paddr=0x000870b4 vaddr=0x40080000 size=0x00400 (  1024) load
I (238) esp_image: segment 3: paddr=0x000874bc vaddr=0x40080400 size=0x08b54 ( 35668) load
I (261) esp_image: segment 4: paddr=0x00090018 vaddr=0x400d0018 size=0xc1d98 (794008) map
I (539) esp_image: segment 5: paddr=0x00151db8 vaddr=0x40088f54 size=0x0887c ( 34940) load
I (565) boot: Loaded app from partition at offset 0x30000
I (565) boot: Disabling RNG early entropy source...
I (565) cpu_start: Pro cpu up.
I (569) cpu_start: Application information:
I (574) cpu_start: Project name:     Lifeline
I (579) cpu_start: App version:      0.10.0-16-g5f5a6d9-dirty
I (585) cpu_start: Compile time:     Apr  1 2020 16:14:20
I (591) cpu_start: ELF file SHA256:  017534443f19a9ba...
I (597) cpu_start: ESP-IDF:          v3.3-beta3-187-g94d4cae65-dirty
I (604) cpu_start: Starting app cpu, entry point is 0x40081190
I (595) cpu_start: App cpu up.
I (615) heap_init: Initializing. RAM available for dynamic allocation:
I (622) heap_init: At 3FFAE6E0 len 0000F480 (61 KiB): DRAM
I (628) heap_init: At 3FFC9628 len 000169D8 (90 KiB): DRAM
I (634) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (640) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (647) heap_init: At 400917D0 len 0000E830 (58 KiB): IRAM
I (653) cpu_start: Pro cpu start user code
I (227) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.

W (237) ll_main: ******************************************************************************
E (247) ll_main:                         HEAP MEMORY : 260520
W (257) ll_main: ******************************************************************************
Heap summary for capabilities 0x00000004:
  At 0x3ffae6e0 len 62592 free 39084 allocated 23216 min_free 38176
    largest_free_block 38176 alloc_blocks 63 free_blocks 2 total_blocks 65
  At 0x3ffc9628 len 92632 free 92596 allocated 0 min_free 92596
    largest_free_block 92596 alloc_blocks 0 free_blocks 1 total_blocks 1
  At 0x3ffe0440 len 15072 free 15036 allocated 0 min_free 15036
    largest_free_block 15036 alloc_blocks 0 free_blocks 1 total_blocks 1
  At 0x3ffe4350 len 113840 free 113804 allocated 0 min_free 113804
    largest_free_block 113804 alloc_blocks 0 free_blocks 1 total_blocks 1
  Totals:
    free 260520 allocated 23216 min_free 259612 largest_free_block 113804
W (377) ll_main: ******************************************************************************
E (377) ll_main:                         HEAP MEMORY : 256708
W (377) ll_main: ******************************************************************************
Heap summary for capabilities 0x00000004:
  At 0x3ffae6e0 len 62592 free 35272 allocated 26972 min_free 34820
    largest_free_block 35208 alloc_blocks 76 free_blocks 3 total_blocks 79
  At 0x3ffc9628 len 92632 free 92596 allocated 0 min_free 92596
    largest_free_block 92596 alloc_blocks 0 free_blocks 1 total_blocks 1
  At 0x3ffe0440 len 15072 free 15036 allocated 0 min_free 15036
    largest_free_block 15036 alloc_blocks 0 free_blocks 1 total_blocks 1
  At 0x3ffe4350 len 113840 free 113804 allocated 0 min_free 113804
    largest_free_block 113804 alloc_blocks 0 free_blocks 1 total_blocks 1
  Totals:
    free 256708 allocated 26972 min_free 256256 largest_free_block 113804

Flashing 16MB partition table:

Code: Select all

I (31) boot: ESP-IDF v3.3-rc-dirty 2nd stage bootloader
I (31) boot: compile time 07:25:28
I (40) boot: Enabling RNG early entropy source...
I (40) boot: SPI Speed      : 40MHz
I (41) boot: SPI Mode       : DIO
I (45) boot: SPI Flash Size : 16MB
I (49) boot: Partition Table:
I (53) boot: ## Label            Usage          Type ST Offset   Length
I (60) boot:  0 nvs              WiFi data        01 02 00009000 00105000
I (67) boot:  1 otadata          OTA data         01 00 0010e000 00002000
I (75) boot:  2 ota_0            OTA app          00 10 00110000 00600000
I (82) boot:  3 ota_1            OTA app          00 11 00710000 00600000
I (90) boot:  4 storage          Unknown data     01 82 00d10000 002d6800
I (97) boot: End of partition table
E (101) boot: ota data partition invalid and no factory, will try all partitions
I (109) esp_image: segment 0: paddr=0x00110020 vaddr=0x3f400020 size=0x53bd8 (343000) map
I (239) esp_image: segment 1: paddr=0x00163c00 vaddr=0x3ffbdb60 size=0x034ac ( 13484) load
I (244) esp_image: segment 2: paddr=0x001670b4 vaddr=0x40080000 size=0x00400 (  1024) load
I (246) esp_image: segment 3: paddr=0x001674bc vaddr=0x40080400 size=0x08b54 ( 35668) load
I (269) esp_image: segment 4: paddr=0x00170018 vaddr=0x400d0018 size=0xc1d98 (794008) map
I (547) esp_image: segment 5: paddr=0x00231db8 vaddr=0x40088f54 size=0x0887c ( 34940) load
I (573) boot: Loaded app from partition at offset 0x110000
I (573) boot: Disabling RNG early entropy source...
I (573) cpu_start: Pro cpu up.
I (577) cpu_start: Application information:
I (582) cpu_start: Project name:     Lifeline
I (587) cpu_start: App version:      0.10.0-16-g5f5a6d9-dirty
I (593) cpu_start: Compile time:     Apr  1 2020 16:14:20
I (599) cpu_start: ELF file SHA256:  017534443f19a9ba...
I (605) cpu_start: ESP-IDF:          v3.3-beta3-187-g94d4cae65-dirty
I (612) cpu_start: Starting app cpu, entry point is 0x40081190
I (603) cpu_start: App cpu up.
I (623) heap_init: Initializing. RAM available for dynamic allocation:
I (630) heap_init: At 3FFAE6E0 len 0000F480 (61 KiB): DRAM
I (636) heap_init: At 3FFC9628 len 000169D8 (90 KiB): DRAM
I (642) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (648) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (655) heap_init: At 400917D0 len 0000E830 (58 KiB): IRAM
I (661) cpu_start: Pro cpu start user code
I (11) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.

W (22) ll_main: ******************************************************************************
E (32) ll_main:                         HEAP MEMORY : 260520
W (42) ll_main: ******************************************************************************
Heap summary for capabilities 0x00000004:
  At 0x3ffae6e0 len 62592 free 39084 allocated 23216 min_free 38176
    largest_free_block 38176 alloc_blocks 63 free_blocks 2 total_blocks 65
  At 0x3ffc9628 len 92632 free 92596 allocated 0 min_free 92596
    largest_free_block 92596 alloc_blocks 0 free_blocks 1 total_blocks 1
  At 0x3ffe0440 len 15072 free 15036 allocated 0 min_free 15036
    largest_free_block 15036 alloc_blocks 0 free_blocks 1 total_blocks 1
  At 0x3ffe4350 len 113840 free 113804 allocated 0 min_free 113804
    largest_free_block 113804 alloc_blocks 0 free_blocks 1 total_blocks 1
  Totals:
    free 260520 allocated 23216 min_free 259612 largest_free_block 113804
W (182) ll_main: ******************************************************************************
E (182) ll_main:                         HEAP MEMORY : 238788
W (182) ll_main: ******************************************************************************
Heap summary for capabilities 0x00000004:
  At 0x3ffae6e0 len 62592 free 17352 allocated 44892 min_free 16900
    largest_free_block 17288 alloc_blocks 76 free_blocks 3 total_blocks 79
  At 0x3ffc9628 len 92632 free 92596 allocated 0 min_free 92596
    largest_free_block 92596 alloc_blocks 0 free_blocks 1 total_blocks 1
  At 0x3ffe0440 len 15072 free 15036 allocated 0 min_free 15036
    largest_free_block 15036 alloc_blocks 0 free_blocks 1 total_blocks 1
  At 0x3ffe4350 len 113840 free 113804 allocated 0 min_free 113804
    largest_free_block 113804 alloc_blocks 0 free_blocks 1 total_blocks 1
  Totals:
    free 238788 allocated 44892 min_free 238336 largest_free_block 113804

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

Re: Bigger partition table uses more heap on same hardware

Postby ESP_igrr » Wed Apr 01, 2020 10:41 pm

Hi Leander,

It looks like the NVS partition size in your 16MB partition table is bigger than in the 4 MB partition. NVS keeps some data structures in heap for every page (which is 4kB, i.e. one SPI flash sector). The minimum amount of extra RAM usage per page is 128 bytes; maximum is 640 bytes (mentioned at the end of https://docs.espressif.com/projects/esp ... -hash-list section). You can try reducing the NVS partition size if you don't have enough heap.

Leander
Posts: 28
Joined: Thu Sep 26, 2019 8:50 pm

Re: Bigger partition table uses more heap on same hardware

Postby Leander » Fri Apr 03, 2020 8:33 am

Thank you for the clear answer.

Topic may be closed as *solved*

Who is online

Users browsing this forum: Baidu [Spider] and 151 guests