Stack overflow in task ble

Jonas A
Posts: 16
Joined: Tue Mar 09, 2021 11:14 am

Stack overflow in task ble

Postby Jonas A » Mon Apr 24, 2023 12:45 pm

Hi,

I use a ESP32 WROVER and run IDF 4.4.3.
The device is setup as BLE central and peripheral.
If the device connects to a peripheral and the peripheral sends more than 150 bytes in a notification (frame will be fragmented)
the device crashes with this crashlog:

***ERROR*** A stack overflow in task ble has been detected.


Backtrace: 0x4008207a:0x3ffe6d00 0x40092995:0x3ffe6d20 0x40095ebe:0x3ffe6d40 0x400944f1:0x3ffe6dc0 0x40092a90:0x3ffe6df0 0x40092a42:0xa5a5a5a5 |<-CORRUPTED
0x4008207a: panic_abort at C:/repo/esp_4_4_3/components/esp_system/panic.c:402

0x40092995: esp_system_abort at C:/repo/esp_4_4_3/components/esp_system/esp_system.c:128

0x40095ebe: vApplicationStackOverflowHook at C:/repo/esp_4_4_3/components/freertos/port/xtensa/port.c:394

0x400944f1: vTaskSwitchContext at C:/repo/esp_4_4_3/components/freertos/tasks.c:3505

0x40092a90: _frxt_dispatch at C:/repo/esp_4_4_3/components/freertos/port/xtensa/portasm.S:436

0x40092a42: _frxt_int_exit at C:/repo/esp_4_4_3/components/freertos/port/xtensa/portasm.S:231



I've tested to increase the BLE task stack with 2000 bytes in the config menu but I get same error.
How can I solve this?
Attachments
sdkconfig.h
(31.01 KiB) Downloaded 168 times
ble_crash.png
ble_crash.png (56.66 KiB) Viewed 1988 times

ESP_Sprite
Posts: 9723
Joined: Thu Nov 26, 2015 4:08 am

Re: Stack overflow in task ble

Postby ESP_Sprite » Tue Apr 25, 2023 3:25 am

Hard to say, I'm afraid. You can try to increase the stack by a bit more (2K is not much, try 16K or so), if that doesn't work it's likely something else like memory corruption.

Jonas A
Posts: 16
Joined: Tue Mar 09, 2021 11:14 am

Re: Stack overflow in task ble

Postby Jonas A » Thu Apr 27, 2023 11:11 am

What is the recommended size of the BLE task stack? We use both peripheral and central role.

felixcollins
Posts: 125
Joined: Fri May 24, 2019 2:02 am

Re: Stack overflow in task ble

Postby felixcollins » Tue May 09, 2023 10:33 pm

You should set it large enough to not crash. Then, later in your project, if you need to regain the memory, look into the stack tools built into freertos. It is possible to run for a while exercising your code through all paths then dump the stack info and see how low each task got. If it gets closer to zero than a few hundred bytes, you are sailing close to the wind.

Who is online

Users browsing this forum: Bing [Bot] and 336 guests