Closed yanmartins closed 1 month ago
Here are the SDKs for both tests:
Thanks for reporting it @yanmartins. We shall take a look and get back to you on this.
Hi @yanmartins,
It seems that xPortGetFreeHeapSize
is calling heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)
which as you can see does no longer include the external memory available.
It is still available and can be used to allocate memory but this API does no longer include the external memory value into the calculation. If you call by yourself heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM)
you should get the 8MB you are expecting. (available in esp_heap_caps.h
).
Hi @yanmartins, It seems that
xPortGetFreeHeapSize
is callingheap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)
which as you can see does no longer include the external memory available. It is still available and can be used to allocate memory but this API does no longer include the external memory value into the calculation. If you call by yourselfheap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM)
you should get the 8MB you are expecting. (available inesp_heap_caps.h
).
@SoucheSouche Now I got Zero:
I (1596) main_task: Calling app_main()
I (1596) app_main: Heap size -> 0
I (2606) app_main: Heap size -> 0
I (3606) app_main: Heap size -> 0
I (4606) app_main: Heap size -> 0
I (5606) app_main: Heap size -> 0
@SoucheSouche By using just the line below, it worked
c heap_caps_get_free_size(MALLOC_CAP_SPIRAM)
Thanks!
Ah sorry, my bad... if you ask for the size of the heap that can handle both internal and external allocations it will of course return 0. Try to call the get size function with MALLOC_CAP_SPIRAM and then again with MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT.
MALLOC_CAP_8BIT
@SoucheSouche Yes! I did it:
I (1595) main_task: Calling app_main()
I (1595) app_main: Heap size: Ext -> 8346648 Int -> 288647
I (2605) app_main: Heap size: Ext -> 8346648 Int -> 288647
I (3605) app_main: Heap size: Ext -> 8346648 Int -> 288647
I (4605) app_main: Heap size: Ext -> 8346648 Int -> 288647
I (5605) app_main: Heap size: Ext -> 8346648 Int -> 288647
Thank you!
Answers checklist.
General issue report
Hello,
I have a custom board with external memory using a ESP32-S3.
Before updating from version 5.0.4 to 5.1.4 I had around 8MB of free RAM. Now this value has dropped to approximately 300KB.
When I run the code, I add this section;
And I got this for 5.0.4:
Logs
``` I (24) boot: ESP-IDF v5.0.4-dirty 2nd stage bootloader I (25) boot: compile time 15:48:30 I (25) boot: Multicore bootloader I (27) boot: chip revision: v0.1 I (31) boot.esp32s3: Boot SPI Speed : 80MHz I (36) boot.esp32s3: SPI Mode : DIO I (41) boot.esp32s3: SPI Flash Size : 16MB I (45) boot: Enabling RNG early entropy source... I (51) boot: Partition Table: I (54) boot: ## Label Usage Type ST Offset Length I (62) boot: 0 otadata OTA data 01 00 0000e000 00002000 I (69) boot: 1 phy_init RF data 01 01 00010000 00001000 I (77) boot: 2 ota_0 OTA app 00 10 00020000 00400000 I (84) boot: 3 ota_1 OTA app 00 11 00420000 00400000 I (91) boot: 4 nvs WiFi data 01 02 00820000 00008000 I (99) boot: 5 nvs_app WiFi data 01 02 00828000 00020000 I (106) boot: 6 nvs_prof WiFi data 01 02 00848000 00200000 I (114) boot: 7 factory_conf WiFi data 01 02 00a48000 00006000 I (122) boot: 8 nvs_keys NVS keys 01 04 00a4e000 00001000 I (129) boot: 9 reserved unknown af af 00a4f000 00400000 I (137) boot: End of partition table I (141) esp_image: segment 0: paddr=00020020 vaddr=3c1a0020 size=a73d0h (685008) map I (272) esp_image: segment 1: paddr=000c73f8 vaddr=3fc9ed00 size=0731ch ( 29468) load I (279) esp_image: segment 2: paddr=000ce71c vaddr=40374000 size=018fch ( 6396) load I (281) esp_image: segment 3: paddr=000d0020 vaddr=42000020 size=192bcch (1649612) map I (583) esp_image: segment 4: paddr=00262bf4 vaddr=403758fc size=192f8h (103160) load I (617) boot: Loaded app from partition at offset 0x20000 I (617) boot: Disabling RNG early entropy source... I (629) cpu_start: Multicore app I (629) octal_psram: vendor id : 0x0d (AP) I (629) octal_psram: dev id : 0x02 (generation 3) I (632) octal_psram: density : 0x03 (64 Mbit) I (638) octal_psram: good-die : 0x01 (Pass) I (643) octal_psram: Latency : 0x01 (Fixed) I (648) octal_psram: VCC : 0x01 (3V) I (653) octal_psram: SRF : 0x01 (Fast Refresh) I (659) octal_psram: BurstType : 0x01 (Hybrid Wrap) I (665) octal_psram: BurstLen : 0x01 (32 Byte) I (670) octal_psram: Readlatency : 0x02 (10 cycles@Fixed) I (676) octal_psram: DriveStrength: 0x00 (1/1) I (682) esp_psram: Found 8MB PSRAM device I (686) esp_psram: Speed: 40MHz I (690) cpu_start: Pro cpu up. I (694) cpu_start: Starting app cpu, entry point is 0x403758b8 0x403758b8: call_start_cpu1 at C:/Users/yan.martins/5.0.4/esp-idf/components/esp_system/port/cpu_start.c:143 I (0) cpu_start: App cpu up. I (1431) esp_psram: SPI SRAM memory test OK I (1442) cpu_start: Pro cpu start user code I (1442) cpu_start: cpu freq: 240000000 Hz I (1443) cpu_start: Application information: I (1446) cpu_start: Project name: dynagateway-v2 I (1451) cpu_start: App version: 0.8.0-beta2-dirty I (1457) cpu_start: Compile time: Sep 16 2024 15:47:51 I (1463) cpu_start: ELF file SHA256: ee3ddbc702dc7216... I (1469) cpu_start: ESP-IDF: v5.0.4-dirty I (1475) cpu_start: Min chip rev: v0.0 I (1480) cpu_start: Max chip rev: v0.99 I (1485) cpu_start: Chip rev: v0.1 I (1489) heap_init: Initializing. RAM available for dynamic allocation: I (1497) heap_init: At 3FCABCC0 len 0003DA50 (246 KiB): DRAM I (1503) heap_init: At 3FCE9710 len 00005724 (21 KiB): STACK/DRAM I (1510) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM I (1516) heap_init: At 600FE010 len 00001FD8 (7 KiB): RTCRAM I (1523) esp_psram: Adding pool of 8157K of PSRAM memory to heap allocator I (1531) spi_flash: detected chip: gd I (1534) spi_flash: flash io: dio W (1539) rmt(legacy): legacy driver is deprecated, please migrate to `driver/rmt_tx.h` and/or `driver/rmt_rx.h` I (1551) app_start: Starting scheduler on CPU0 I (1554) app_start: Starting scheduler on CPU1 I (1554) main_task: Started on CPU0 I (1564) esp_psram: Reserving pool of 32K of internal memory for DMA/internal allocations I (1574) main_task: Calling app_main() I (1574) app_main: Heap size -> 8606092 I (2584) app_main: Heap size -> 8606092 I (3584) app_main: Heap size -> 8606092 I (4584) app_main: Heap size -> 8606092 I (5584) app_main: Heap size -> 8606092 ```And this for 5.1.4:
Logs
``` I (26) boot: ESP-IDF v5.1.4 2nd stage bootloader I (27) boot: compile time Sep 16 2024 15:37:35 I (27) boot: Multicore bootloader I (30) boot: chip revision: v0.1 I (34) boot.esp32s3: Boot SPI Speed : 80MHz I (38) boot.esp32s3: SPI Mode : DIO I (43) boot.esp32s3: SPI Flash Size : 16MB I (48) boot: Enabling RNG early entropy source... I (53) boot: Partition Table: I (57) boot: ## Label Usage Type ST Offset Length I (64) boot: 0 otadata OTA data 01 00 0000e000 00002000 I (72) boot: 1 phy_init RF data 01 01 00010000 00001000 I (79) boot: 2 ota_0 OTA app 00 10 00020000 00400000 I (87) boot: 3 ota_1 OTA app 00 11 00420000 00400000 I (94) boot: 4 nvs WiFi data 01 02 00820000 00008000 I (102) boot: 5 nvs_app WiFi data 01 02 00828000 00020000 I (109) boot: 6 nvs_prof WiFi data 01 02 00848000 00200000 I (117) boot: 7 factory_conf WiFi data 01 02 00a48000 00006000 I (124) boot: 8 nvs_keys NVS keys 01 04 00a4e000 00001000 I (132) boot: 9 reserved unknown af af 00a4f000 00400000 I (139) boot: End of partition table I (144) esp_image: segment 0: paddr=00020020 vaddr=3c1a0020 size=a8ebch (691900) map I (276) esp_image: segment 1: paddr=000c8ee4 vaddr=3fc9f500 size=07134h ( 28980) load I (283) esp_image: segment 2: paddr=000d0020 vaddr=42000020 size=197f08h (1670920) map I (583) esp_image: segment 3: paddr=00267f30 vaddr=3fca6634 size=00480h ( 1152) load I (584) esp_image: segment 4: paddr=002683b8 vaddr=40374000 size=1b4d0h (111824) load I (625) boot: Loaded app from partition at offset 0x20000 I (625) boot: Disabling RNG early entropy source... I (637) cpu_start: Multicore app I (637) octal_psram: vendor id : 0x0d (AP) I (637) octal_psram: dev id : 0x02 (generation 3) I (640) octal_psram: density : 0x03 (64 Mbit) I (646) octal_psram: good-die : 0x01 (Pass) I (651) octal_psram: Latency : 0x01 (Fixed) I (656) octal_psram: VCC : 0x01 (3V) I (661) octal_psram: SRF : 0x01 (Fast Refresh) I (667) octal_psram: BurstType : 0x01 (Hybrid Wrap) I (673) octal_psram: BurstLen : 0x01 (32 Byte) I (678) octal_psram: Readlatency : 0x02 (10 cycles@Fixed) I (684) octal_psram: DriveStrength: 0x00 (1/1) I (690) esp_psram: Found 8MB PSRAM device I (694) esp_psram: Speed: 40MHz I (698) cpu_start: Pro cpu up. I (702) cpu_start: Starting app cpu, entry point is 0x403758dc 0x403758dc: call_start_cpu1 at C:/Users/yan.martins/5.1.4/esp/v5.1.4/esp-idf/components/esp_system/port/cpu_start.c:159 I (0) cpu_start: App cpu up. I (1439) esp_psram: SPI SRAM memory test OK I (1450) cpu_start: Pro cpu start user code I (1450) cpu_start: cpu freq: 240000000 Hz I (1451) cpu_start: Application information: I (1454) cpu_start: Project name: dynagateway-v2 I (1459) cpu_start: App version: 0.8.0-beta2-dirty I (1465) cpu_start: Compile time: Sep 16 2024 15:36:51 I (1471) cpu_start: ELF file SHA256: 59216d50735f352b... I (1477) cpu_start: ESP-IDF: v5.1.4 I (1482) cpu_start: Min chip rev: v0.0 I (1487) cpu_start: Max chip rev: v0.99 I (1492) cpu_start: Chip rev: v0.1 I (1497) heap_init: Initializing. RAM available for dynamic allocation: I (1504) heap_init: At 3FCABE18 len 0003D8F8 (246 KiB): DRAM I (1510) heap_init: At 3FCE9710 len 00005724 (21 KiB): STACK/DRAM I (1517) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM I (1523) heap_init: At 600FE010 len 00001FD8 (7 KiB): RTCRAM I (1530) esp_psram: Adding pool of 8154K of PSRAM memory to heap allocator I (1538) spi_flash: detected chip: gd I (1542) spi_flash: flash io: dio W (1546) rmt(legacy): legacy driver is deprecated, please migrate to `driver/rmt_tx.h` and/or `driver/rmt_rx.h` I (1558) sleep: Configure to isolate all GPIO pins in sleep state I (1564) sleep: Enable automatic switching of GPIO sleep configuration I (1571) app_start: Starting scheduler on CPU0 I (1576) app_start: Starting scheduler on CPU1 I (1576) main_task: Started on CPU0 I (1586) esp_psram: Reserving pool of 32K of internal memory for DMA/internal allocations I (1596) main_task: Calling app_main() I (1596) app_main: Heap size -> 288647 I (2606) app_main: Heap size -> 288647 I (3606) app_main: Heap size -> 288647 I (4606) app_main: Heap size -> 288647 I (5606) app_main: Heap size -> 288647 ```Are there any new settings that could have impacted this value so much?
Thanks!