Closed zekageri closed 1 year ago
This crash happened again. The chip can not boot because of this error.
Here is the crash now:
New light updated with name: Spot and id: r_l7syypoc_jb29u
New light updated with name: Csillár and id: k_l7syz7o9_fibq8
New light updated with name: Spot and id: b_l7sz1dne_r6qqh
New light updated with name: Spot and id: q_l7sz3188_5h976
New light updated with name: Spot and id: v_l7sz4gau_lslwi
assert failed: block_trim_free heap_tlsf.c:377 (block_is_free(block) && "block must be free")
Backtrace:0x40083cbd:0x3ffd57e00x4008ece5:0x3ffd5800 0x400944d9:0x3ffd5820 0x40093621:0x3ffd5950 0x40093e67:0x3ffd5970 0x400940e8:0x3ffd5990 0x400840a2:0x3ffd59b0 0x400840b5:0x3ffd59e0 0x400d297e:0x3ffd5a00 0x400ddf85:0x3ffd5a20 0x400ddfe5:0x3ffd5a90 0x400de60d:0x3ffd5ab0 0x400f60d9:0x3ffd5af0 0x400f669e:0x3ffd5d90 0x400f66cf:0x3ffd5db0 0x400f673d:0x3ffd5dd0
#0 0x40083cbd:0x3ffd57e0 in esp_rom_uart_tx_wait_idle at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_rom/patches/esp_rom_uart.c:41
#1 0x4008ece5:0x3ffd5800 in cpu_ll_get_core_id at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/hal/esp32/include/hal/cpu_ll.h:35
(inlined by) xPortGetCoreID at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/include/freertos/portmacro.h:634
(inlined by) xTaskRemoveFromEventList at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/tasks.c:3705
#2 0x400944d9:0x3ffd5820 in ?? ??:0
#3 0x40093621:0x3ffd5950 in spi_flash_chip_generic_erase_block at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/spi_flash/spi_flash_chip_generic.c:191
#4 0x40093e67:0x3ffd5970 in ?? ??:0
#5 0x400940e8:0x3ffd5990 in ?? ??:0
#6 0x400840a2:0x3ffd59b0 in heap_caps_realloc_base at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/heap_caps.c:381
(inlined by) heap_caps_realloc_base at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/heap_caps.c:347
#7 0x400840b5:0x3ffd59e0 in heap_caps_realloc_base at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/heap_caps.c:382
(inlined by) heap_caps_realloc_base at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/heap_caps.c:347
#8 0x400d297e:0x3ffd5a00 in _stext at ??:?
#9 0x400ddf85:0x3ffd5a20 in MDNSResponder::addService(char*, char*, unsigned short) at C:/Users/zekag/.platformio/packages/framework-arduinoespressif32/libraries/ESPmDNS/src/ESPmDNS.cpp:147
#10 0x400ddfe5:0x3ffd5a90 in MDNSResponder::addServiceTxt(char*, char*, char*, char*) at C:/Users/zekag/.platformio/packages/framework-arduinoespressif32/libraries/ESPmDNS/src/ESPmDNS.cpp:155
#11 0x400de60d:0x3ffd5ab0 in ErriezDS3231::readBuffer(unsigned char, void*, unsigned char) at lib/ErriezDS3231/src/ErriezDS3231.cpp:898
#12 0x400f60d9:0x3ffd5af0 in wpa_supplicant_process_1_of_2_wpa at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/wpa_supplicant/src/rsn_supp/wpa.c:1415
(inlined by) wpa_supplicant_process_1_of_2 at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/wpa_supplicant/src/rsn_supp/wpa.c:1541
(inlined by) wpa_sm_rx_eapol at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/wpa_supplicant/src/rsn_supp/wpa.c:2031
#13 0x400f669e:0x3ffd5d90 in wpa_supplicant_activate_ptk at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/wpa_supplicant/src/rsn_supp/wpa.c:1265
(inlined by) wpa_supplicant_send_4_of_4_txcallback at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/wpa_supplicant/src/rsn_supp/wpa.c:1281
(inlined by) eapol_txcb at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/wpa_supplicant/src/rsn_supp/wpa.c:2469
#14 0x400f66cf:0x3ffd5db0 in wpa_supplicant_send_4_of_4_txcallback at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/wpa_supplicant/src/rsn_supp/wpa.c:1298
(inlined by) eapol_txcb at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/wpa_supplicant/src/rsn_supp/wpa.c:2469
#15 0x400f673d:0x3ffd5dd0 in wpa_sta_in_4way_handshake at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/wpa_supplicant/src/rsn_supp/wpa.c:2493
ELF file SHA256: 0000000000000000
This is a different ESP from the same modell. Heavy PS-ram use. Ps ram is allocated on class creation, but the class creation is not at startup, but inside setup() so the ps ram is inited.
Plus the sketch uses ps ram before this error without issue.
My sketch initializing tasks one by one at startup.
void initTasks(){
// Every init is a task creation.
hsh_modbus.init(-1,3,MODBUS_SYS_STACK_SIZE);
vTaskDelay(100);
hsh_Server.init(1,2,SERVER_SYS_STACK_SIZE);
hsh_Performance.init(1,2,PERFORMANCE_SYS_STACK_SIZE);
hsh_timeSystem.init(1,2,TIME_SYS_STACK_SIZE);
zones.init(1,3,ZONES_SYS_STACK_SIZE);
xTaskCreateUniversal(shaderTask, "HSH_SHADER_TASK", 4000, NULL, 4, NULL, 1);
}
The crash happens in the zones task at it's setup. Inside this task i read a config file from LitleFS in JSON format and start to loop over it. For every component inside the JSON file i create a class dynamically like this (Using ArduinoJSON):
SpiRamJsonDocument zonesObj(ZONES_OBJ_SIZE);
DeserializationError error = deserializeJson(zonesObj, (const char *)zones, ZONES_OBJ_SIZE);
if (error) { return; }
JsonObject zones = zonesObj.as<JsonObject>();
for (JsonPair zoneRef : zones) {
const char* zoneID = zoneRef.key().c_str();
JsonObject zone = zones[zoneID];
boolean isZone = zone["isZone"].as<boolean>();
if( !isZone ){ continue; }
JsonObject lightsObj = zone["lights"].as<JsonObject>();
if( !lightsObj.isNull() ){
for (JsonPair componentRef : lightsObj) {
if( lightCount >= MAX_LIGHTS ){break;}
const char* componentID = componentRef.key().c_str();
JsonObject component = lightsObj[componentID];
lightsArray[lightCount] = new lightSystem();
if( !lightsArray[lightCount] ){ continue; }
lightsArray[lightCount]->update(component,componentID,lightCount,zoneID);
lightCount++;
}
}
}
As you can see in the error log, it start to create the light classes and suddenly it crashes with this error.
Light class constructor and descructor looks like this:
// Constructor
void lightSystem::allocateResources(){
outputs = (char *) ps_malloc (IO_SIZE * sizeof (char));
inputs = (char *) ps_malloc (IO_SIZE * sizeof (char));
triggerInputs = (char *) ps_malloc (IO_SIZE * sizeof (char));
id = (char *) ps_malloc (IDS_AND_NAMES_SIZE * sizeof (char));
zoneID = (char *) ps_malloc (IDS_AND_NAMES_SIZE * sizeof (char));
name = (char *) ps_malloc (IDS_AND_NAMES_SIZE * sizeof (char));
if( outputs == NULL || inputs == NULL || triggerInputs == NULL || id == NULL || zoneID == NULL || name == NULL ){
Serial.println("[LIGHT_SYS] - Failed to allocate resources");
}
}
// Descurtor
void lightSystem::freeResources(){
free(id);
free(zoneID);
free(name);
free(outputs);
free(inputs);
free(triggerInputs);
}
LightsArray holds the class pointers. It looks like this:
extern lightSystem* lightsArray[MAX_LIGHTS];
What could be the problem?
@zekageri this happens only with one particular board, but not with any other one, correct? Even though both traces are the same, the cause looks to be the same.
@igrr do you have any pointers what could be going wrong with PSRAM? This seems to be an ECO3 ESP32, so could it be the PSRAM chip is failing in some way?
This is both an ESP32-Wrover with 8mb ps ram and 16mb flash. Both chip is the same type. I ditched the other one because of this error. I thought that the ext ram died in one and replaced the chip. But this one does it too.
Now it could start but i got this on serial
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc was called but failed to allocate 500000 bytes with 0x400 capabilities.
my free heap is 1.5mb
I randomly get these messages
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
heap_caps_malloc_default was called but failed to allocate 0 bytes with 0x1000 capabilities.
This bug should be fixed in IDF by https://github.com/espressif/esp-idf/commit/b43e777e0a25fecd4652d5282427366fadae8b1d (available on release/v4.4 branch, will be part of v4.4.3)
But i did not try to allocate 0 byte
@zekageri if you check out manually Arduino core master branch, it's supposed to be solved. Our current master use ESP-IDF 4.4.3.
Thank you. I will test it!
@zekageri Does it work for you? I didnt had issues in my test.
Yes. It seems to be working. Thank you very much!
基于esp-idfv4.4.4条件下使用esp32S3,启用external spiram 使用nimble client功能下在BLE_GAP_EVENT_NOTIFY_RX事件中有接口用于处理接收的数据,将接收的数据解析打包push到队列中,再由其他其他线程将队列中的数据上报到云;该接口在蓝牙数据上报频繁时会在malloc是出现报错assert failed: block_trim_free heap_tlsf.c:371 (block_is_free(block) && "block must be free"),但是该接口在上报频率较低或者该接口在串口读取数据处理从未报过该错误。其中malloc也测试过使用片内和片外ram,均出现同样错误,而且malloc不会执行到返回null;直接在调用malloc()或者heap_caps_malloc()内部就已经开始报错了
assert failed: block_trim_free heap_tlsf.c:371 (block_is_free(block) && "block must be free")
Backtrace: 0x40375d6e:0x3fcd9e90 0x4037f8e9:0x3fcd9eb0 0x40386b6d:0x3fcd9ed0 0x40385352:0x3fcd9ff0 0x40385d25:0x3fcda010 0x403760de:0x3fcda030 0x403760f1:0x3fcda060 0x4200e616:0x3fcda080 0x4200f4b0:0x3fcda930 0x42009c7b:0x3fcdab70 0x42019f61:0x3fcdb1c0 0x42019fab:0x3fcdb1e0 0x4201b6dc:0x3fcdb200 0x420226dd:0x3fcdb260 0x42017601:0x3fcdb280 0x420174d7:0x3fcdb2b0 0x42016cb8:0x3fcdb2e0 0x42016cc3:0x3fcdb300 0x4201e166:0x3fcdb320 0x420094de:0x3fcdb340
0x40375d6e: panic_abort at C:/Espressif/frameworks/esp-idf-v4.4.4/components/esp_system/panic.c:408
0x4037f8e9: esp_system_abort at C:/Espressif/frameworks/esp-idf-v4.4.4/components/esp_system/esp_system.c:137
0x40386b6d: __assert_func at C:/Espressif/frameworks/esp-idf-v4.4.4/components/newlib/assert.c:85
0x40385352: block_locate_free at C:/Espressif/frameworks/esp-idf-v4.4.4/components/heap/heap_tlsf.c:441
(inlined by) tlsf_malloc at C:/Espressif/frameworks/esp-idf-v4.4.4/components/heap/heap_tlsf.c:849
0x40385d25: multi_heap_malloc_impl at C:/Espressif/frameworks/esp-idf-v4.4.4/components/heap/multi_heap.c:200
0x403760de: heap_caps_malloc_base at C:/Espressif/frameworks/esp-idf-v4.4.4/components/heap/heap_caps.c:154
(inlined by) heap_caps_malloc_base at C:/Espressif/frameworks/esp-idf-v4.4.4/components/heap/heap_caps.c:99
0x403760f1: heap_caps_malloc at C:/Espressif/frameworks/esp-idf-v4.4.4/components/heap/heap_caps.c:174
I can also report that still this happens to me on a WROVER-E 8MB with IDF version ESP-IDF v4.4.3-347-g9ee3c8337d.
It happens more infrequently when SPIRAM frequency is at 40Mhz
Board
esp-wrover-kit
Device Description
esp32-wrover-e ( 8mb psram 16mb flash )
Hardware Configuration
ETH_Lan8720, DS3231 (i2c), Heavy serial 1 ( modbus ), SPI display
Version
latest development Release Candidate (RC-X)
IDE Name
Platform IO
Operating System
Windows 10
Flash frequency
80Mhz
PSRAM enabled
yes
Upload speed
115200
Description
External ram memory allocation assert fail. Happens on one esp32-wrover-e but not on others with the exact same sketch. How to capture the exception?
Sketch
Debug Message
Other Steps to Reproduce
I'm using ArduinoJsonAllocator for a lot of JSON serialization / deserialization. This error happens on only one esp32 ( tested on 5 chip with the exact same parameters )
I can not capture this exception because it happens internally.
Error:
assert failed: block_trim_free heap_tlsf.c:377 (block_is_free(block) && "block must be free")
I have found two issues that stated that problem but it seems to me that it was patched a long time ago.
I have a check in setup which looks like this but it did not help:
I have checked existing issues, online documentation and the Troubleshooting Guide