How can I increase wifi task stack size?

jsam589
Posts: 74
Joined: Sat Aug 17, 2019 9:31 pm

How can I increase wifi task stack size?

Postby jsam589 » Mon May 11, 2020 7:50 pm

Task "wifi" is overflowing its stack sometimes and when I just checked the high water mark, it was 48 bytes (i.e. very close to stack overflow!). I am using v4.0 stable IDF. I don't see a CONFIG parameter to increase the stack for wifi. Although many other system tasks have adjustable sizes. Am I missing something?

I already have these increased parameters in sdkconfig.defaults:

Code: Select all

CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=6144
CONFIG_ESP_MAIN_TASK_STACK_SIZE=6144
CONFIG_ESP_TIMER_TASK_STACK_SIZE=3584
CONFIG_ESP_IPC_TASK_STACK_SIZE=2048
Console output

Code: Select all

2002-02-02T14:00:10+02:00, I, 10492, "wifi", "wifi firmware version: 581f422"
2002-02-02T14:00:10+02:00, I, 10513, "wifi", "config NVS flash: enabled"
2002-02-02T14:00:10+02:00, I, 10760, "wifi", "config nano formating: disabled"
2002-02-02T14:00:10+02:00, I, 10763, "wifi", "Init dynamic tx buffer num: 32"
2002-02-02T14:00:10+02:00, I, 10784, "wifi", "Init data frame dynamic rx buffer num: 32"
2002-02-02T14:00:10+02:00, I, 10787, "wifi", "Init management frame dynamic rx buffer num: 32"
2002-02-02T14:00:10+02:00, I, 10811, "wifi", "Init management short buffer num: 32"
2002-02-02T14:00:10+02:00, I, 11007, "wifi", "Init static tx buffer num: 16"
Fsync/sizecheck log file on SPIFFS (every 10 messages)
Log_1 sz = 385124
2002-02-02T14:00:10+02:00, I, 11011, "wifi", "Init static rx buffer size: 1600"
2002-02-02T14:00:10+02:00, I, 11051, "wifi", "Init static rx buffer num: 10"
2002-02-02T14:00:10+02:00, I, 11055, "wifi", "Init dynamic rx buffer num: 32"
2002-02-02T14:00:10+02:00, D, 11079, "CA: WIFI", "Read SSID from NVS : [xxxxxx]"
2002-02-02T14:00:10+02:00, D, 11081, "CA: WIFI", "Read PWD from NVS : [xxxxxx]"
Prepare to start wifi
I (13293) phy: phy_version: 4180, cb3948e, Sep 12 2019, 16:39:13, 0, 0
2002-02-02T14:00:11+02:00, I, 11176, "wifi", "mode : sta (24:0a:c4:47:39:8c)"
2002-02-02T14:00:11+02:00, D, 11179, "system_event", "SYSTEM_EVENT_STA_START"
2002-02-02T14:00:11+02:00, D, 11184, "event", "running post WIFI_EVENT:2 with handler 0x4012b4d4 on loop 0x3ffdffa0"
0x4012b4d4: handle_sta_start at /home/senocal/Esp_Idf_Versions/4_0_stable/esp-idf/components/tcpip_adapter/event_handlers.c:140

2002-02-02T14:00:11+02:00, D, 11195, "event", "running post SYSTEM_EVENT:2 with handler 0x4012c4d8 on loop 0x3ffdffa0"
0x4012c4d8: esp_event_post_to_user at /home/senocal/Esp_Idf_Versions/4_0_stable/esp-idf/components/esp_event/event_loop_legacy.c:31

2002-02-02T14:00:11+02:00, D, 11205, "CA: WIFI", "appWifiEvtHdlr: SYSTEM_EVENT_STA_START"
2002-02-02T14:00:11+02:00, D, 11195, "CA: WIFI", "Wifi started - Waiting for EVENT GROUP TO BE RELEASED!"
***ERROR*** A stack overflow in task wifi has been detected.
abort() was called at PC 0x400955d0 on core 0

rojer9
Posts: 17
Joined: Mon Dec 14, 2015 10:45 pm
Contact:

Re: How can I increase wifi task stack size?

Postby rojer9 » Sat Oct 24, 2020 6:34 pm

there is no menucfg option for this, but it is possible.
looks like stack size is either 3072 or 3584 based on some menuconfig option (didn't quite figure out which).
but it can be overridden: wifi subsystem takes a struct with function pointers to various system functions it uses, including creating tasks. you can intercept the call to create tasks and adjust stack as you wish.
here's an example - https://github.com/mongoose-os-libs/wif ... aa3f5f95c6

Who is online

Users browsing this forum: Google [Bot] and 135 guests