Was having issues with ESP32 connecting to my router using APSTA mode and found that changing from a local variable to program variable fixed the issue.
Please find attached the sample testing code I used with ESP32 and ESP-IDF.
Mike
Tried with other ESP units with the same results.
This WiFi Code causes Stack overflow
This WiFi Code causes Stack overflow
- Attachments
-
- testing.zip
- (15.73 KiB) Downloaded 125 times
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: This WiFi Code causes Stack overflow
...Okay, thanks for sharing, but did you have a question? In general, yes, if you declare variables inside your functions, it'll use up stack space, and if you didn't allocate enough of that to your task, it'll overflow your stack. Making variables global is one way around that, although normally people would just increase the stack size by a bit.
Re: This WiFi Code causes Stack overflow
Since IDF is in control of the stack it should not happen.
If I remove the string copies from the code the stack does not overflow.
In addition, even though the stack does not overflow it will never connect to the router.
Mike
If I remove the string copies from the code the stack does not overflow.
In addition, even though the stack does not overflow it will never connect to the router.
Mike
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: This WiFi Code causes Stack overflow
No, it is not. ESP-IDF will create the main task with the amount of stack you configure, and it's your job to reconfigure it if it's too small. Enter menuconfig and then Component config → ESP System Settings → Main task stack size to change it, or use xTaskCreate to create your own stack.
That is a different issue. Do you have logs for that problem?In addition, even though the stack does not overflow it will never connect to the router.
Who is online
Users browsing this forum: dzungpv, Google [Bot] and 152 guests