Chat freely about anything...

User avatar
By majorb
#43986 We've been working on a project that requires being able to switch between using the ESP8266 in Station and SoftAP mode. We've been wrestling with a bug. When we attempt the switch, the watchdog timer reset the device when dealing with a connection or disconnection. It usually happens on the first connection or disconnection but sometimes gives a few connects\disconnects before it triggers. We made a version where after re-configuring the device, we rebooted the ESP; this worked, but is far from optimal for our project.

We have made a very slim use case for this bug, where we we have a callback from user_init that configures and switches to station mode before configuring and switching to SoftAP. Why would this code crash the wdt?
Attachments
(765 Bytes) Downloaded 523 times
User avatar
By lethe
#44022 Your os_memcpy commands have an incorrect length parameter, which will cause invalid reads. I would recommend to use either os_strcpy or the correct length of the source buffer.

Apart from that I don't see any obvious issues with your code.
If it still resets, I suggest you check your power supply. SoftAP mode requires more power than station mode, which makes brown outs more likely with an insufficient power supply.
User avatar
By majorb
#44037
lethe wrote:Your os_memcpy commands have an incorrect length parameter, which will cause invalid reads. I would recommend to use either os_strcpy or the correct length of the source buffer.

Apart from that I don't see any obvious issues with your code.
If it still resets, I suggest you check your power supply. SoftAP mode requires more power than station mode, which makes brown outs more likely with an insufficient power supply.


We tried switching to os_strcpy, and the same issue happened. We also tried switching to a stronger power supply, and that didn't work either. We have to be doing something very wrong to cause the watchdog timer to trigger when a device connects or disconnects to the ESP. Or maybe there's a bug of some sort?
User avatar
By majorb
#44638 I think the problem may have been that we were trying to configure the modes before switching to them rather than after switching to them. The SDK API manual pretty much says that configuration functions like wifi_station_set_config don't work if not already in the correct opmode. A small amount of testing testing makes it look like the problem has gone away but I'm not 100% convinced yet.

Also, note for any Googlers with this issue: make sure you use wifi_station_connect after switching to station mode and configuring it, because it won't automatically try to connect otherwise!