Page 1 of 1

[SOLVED] Power management fail after WiFi join

Posted: Fri Mar 08, 2019 9:17 am
by balix53
Hi,

I have an application that require the power management features. I was using esp-idf 3.1.1, seeing that in 3.1.3 release note there was a "Fixed crash during simultaneous use of Wi-Fi, Bluetooth and modem sleep" I decided to upgrade to this version. However I still have this issue, which will happen every time I successfully join a WiFi access point and seems to be related with the power management since disabling it in menuconfig will work fine. The following is the trace when the ESP32 crashes after having joined an access point:

Code: Select all

I (3511) wifi: mode : sta (30:ae:a4:c9:97:4c) + softAP (30:ae:a4:c9:97:4d)
I (6351) wifi: mode : softAP (30:ae:a4:c9:97:4d)
I (6431) wifi: flush txq
I (6441) wifi: stop sw txq
I (6441) wifi: lmac stop hw txq
I (6461) wifi: mode : sta (30:ae:a4:c9:97:4c)
I (6461) wifi: Set ps type: 2
I (8911) wifi: n:11 0, o:1 0, ap:255 255, sta:11 0, prof:1
I (10951) wifi: state: init -> auth (b0)
I (10961) wifi: state: auth -> assoc (0)
I (10971) wifi: state: assoc -> run (10)
I (11211) wifi: connected with WIFI_SSID, channel 11
I (11211) wifi: pm start, type: 2
E (11311) wifi: l:6968482, o:2320, n:2633426082, now:6974017
abort() was called at PC 0x40149f28 on core 0
0x40149f28: pm_on_beacon_rx at ??:?


Backtrace: 0x4009366f:0x3ffe1760 0x400937c7:0x3ffe1780 0x40149f28:0x3ffe17a0 0x4014a6d5:0x3ffe17e0 0x4014ada5:0x3ffe1800 0x4008a2c2:0x
3ffe1850
0x4009366f: invoke_abort at esp-idf/components/esp32/panic.c:676

0x400937c7: abort at esp-idf/components/esp32/panic.c:676

0x40149f28: pm_on_beacon_rx at ??:?

0x4014a6d5: ppRxProtoProc at ??:?

0x4014ada5: ppRxPkt at ??:?

0x4008a2c2: ppTask at ??:?


CPU halted.

Re: Power management fail after WiFi join

Posted: Fri Mar 08, 2019 2:26 pm
by balix53
I managed to narrow down this issue to the WiFi power save settings. First, I wasn't setting the listen_interval in my WiFi configuration (wifi_config_t) so I added it and set it to zero. It wasn't working either so I tried the other power save mode (WIFI_PS_MIN_MODEM instead of WIFI_PS_MAX_MODEM) and it finally worked.

So the question is: why can't I use the WIFI_PS_MAX_MODEM mode ?

Re: Power management fail after WiFi join

Posted: Thu Mar 21, 2019 4:55 pm
by balix53
For a moment I was happy with the setting WIFI_PS_MIN_MODEM however the mode WIFI_PS_MAX_MODEM seems to be mandatory for my application. So I tried to change the setting just before joining an access point and the device managed to join it without crashing but it messes a bit with my application. I'm not quite sure about how this setting is managed in the Wi-Fi library do I really have to stop and start the Wi-Fi interface to apply it ? (It is how it is done in the examples of the esp-idf github).

Re: Power management fail after WiFi join

Posted: Fri Mar 29, 2019 8:38 am
by balix53
It seems that one of the listen_interval field of a wifi_sta_config_t structure in my code was not initialized. This field is used when in WIFI_PS_MAX_MODEM mode.