Page 1 of 1

Crash when using WiFi after ESP Now [solved]

Posted: Tue Jul 11, 2023 5:34 pm
by floitsch_toit
In my program I'm trying to use ESP Now, then (after shutting it down), WiFi.

Currently I'm running into a crash in 'esp_netif_receive' when I do that. Does anyone have an idea of what I need to do to reset the wireless stack after having used ESP Now?

My deinit code is currently just 'esp_now_deinit()'. Do I need to do more?

The crash and some logs:

Code: Select all

[wifi] DEBUG: connecting
E (12364) esp_netif_lwip: dhcp client start failed
[wifi] DEBUG: connected

Guru Meditation Error: Core  1 panic'ed (InstrFetchProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x00000000  PS      : 0x00060830  A0      : 0x801bae9e  A1      : 0x3ffd9860  
A2      : 0x3ffd65a0  A3      : 0x00000000  A4      : 0x3ffd7328  A5      : 0x3fff2018  
A6      : 0x3ffd5ea8  A7      : 0xbfffffff  A8      : 0x80123283  A9      : 0x3ffd9840  
A10     : 0x3ffd7328  A11     : 0x3ffd65a0  A12     : 0x3ffd7328  A13     : 0x00000000  
A14     : 0x00000041  A15     : 0x3ffd68c8  SAR     : 0x00000016  EXCCAUSE: 0x00000014  
EXCVADDR: 0x00000000  LBEG    : 0x40097974  LEND    : 0x40097990  LCOUNT  : 0xffffffff  


Crash in native code:
Backtrace: 0xfffffffd:0x3ffd9860 0x401bae9b:0x3ffd9880 0x40114c6d:0x3ffd98a0 0x401c134e:0x3ffd98c0 0x401c1405:0x3ffd9910 0x401c31b9:0x3ffd9930 0x401c008c:0x3ffd9950
0xfffffffd: .rtc.force_slow + 0xafffefbd
0x401bae9b: esp_netif_receive + 0xf
0x40114c6d: wifi_sta_receive + 0x15
0x401c134e: sta_input + 0x476
0x401c1405: sta_rx_cb + 0x11
0x401c31b9: ppRxPkt + 0xa5
0x401c008c: ppTask + 0xec
******************************************************************************

Re: Crash when using WiFi after ESP Now

Posted: Wed Jul 12, 2023 10:47 am
by floitsch_toit
Looks like we were missing a call to 'esp_wifi_stop'. That is, we were calling 'esp_wifi_start' for the espnow part of our program; then shutting down espnow (but missing the 'esp_wifi_stop'), followed by calling 'esp_wifi_start' again in the WiFi part of our program.

We now call 'esp_wifi_stop' when we have finished working with ESP Now, and then call 'esp_wifi_start' again when we start using the WiFi normally.

Edit:
The original log had a line "E (12364) esp_netif_lwip: dhcp client start failed".
After enabling debug logging, the error was this one:

Code: Select all

dhcp_start(netif=0x3ffd6608) 0
dhcp_start(): Cannot use this netif with DHCP: MTU is too small