Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when using wifiManager.setAPStaticIPConfig() #1006

Open
3 of 7 tasks
flavio-fernandes opened this issue Feb 7, 2020 · 8 comments
Open
3 of 7 tasks

Exception when using wifiManager.setAPStaticIPConfig() #1006

flavio-fernandes opened this issue Feb 7, 2020 · 8 comments
Labels
bug Validated BUG DEV Help Wanted Developer Needs Help Priority

Comments

@flavio-fernandes
Copy link
Contributor

Basic Infos

Hardware

WiFimanager Branch/Release:

  • Master
  • Development

Esp8266/Esp32:

  • ESP8266
  • ESP32

Hardware: ESP-12e, esp01, esp25

ESP Core Version: 2.4.0, staging

  • ESP32 version 1.0.4

Description

While trying to configure setAPStaticIPConfig using the following code:

#define DEFAULT_WIFIMANAGER_PORTAL_IP IPAddress(10,0,1,1)
#define DEFAULT_WIFIMANAGER_PORTAL_GW IPAddress(10,0,1,1)
#define DEFAULT_WIFIMANAGER_PORTAL_MASK IPAddress(255,255,255,0)

wifiManager.setAPStaticIPConfig(DEFAULT_WIFIMANAGER_PORTAL_IP, DEFAULT_WIFIMANAGER_PORTAL_GW, DEFAULT_WIFIMANAGER_PORTAL_MASK);

I see the following exception as soon as my laptop connects to the portal:

   PC: 0x00000000
    EXCVADDR: 0x00000000

    Decoding stack results
    0x40121376: handle_dhcp at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/apps/dhcpserver/dhcpserver.c line 1031
    0x4012e465: udp_input at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/udp.c line 401
    0x4013346d: ip4_input at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/ipv4/ip4.c line 740
    0x4013870a: ethernet_input at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/netif/ethernet.c line 184
    0x40121d7f: tcpip_thread at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/api/tcpip.c line 135
    0x40088b7d: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143

This is what I see in the Serial output when it happens:

06:35:25.141 -> *WM: [1] SoftAP Configuration
06:35:25.141 -> *WM: [1] --------------------
06:35:25.141 -> *WM: [1] ssid:             ESP32_3312CFA4
06:35:25.141 -> *WM: [1] password:
06:35:25.141 -> *WM: [1] ssid_len:         14
06:35:25.141 -> *WM: [1] channel:          1
06:35:25.141 -> *WM: [1] authmode:
06:35:25.141 -> *WM: [1] ssid_hidden:
06:35:25.141 -> *WM: [1] max_connection:   4
06:35:25.141 -> *WM: [1] country:          CN
06:35:25.141 -> *WM: [1] beacon_interval:  100(ms)
06:35:25.141 -> *WM: [1] --------------------
06:35:25.645 -> *WM: [1] AP IP address: 10.0.1.1
06:35:25.645 -> *WM: [3] setupConfigPortal
06:35:25.645 -> *WM: [1] Starting Web Portal
06:35:25.645 -> *WM: [3] dns server started with ip:  10.0.1.1
06:35:25.645 -> *WM: [2] HTTP server started
06:35:27.953 -> *WM: [2] WiFi Scan completed in 2303 ms
06:35:27.953 -> *WM: [2] Config Portal Running, blocking, waiting for clients...
06:35:40.189 -> dhcps: send_nak>>udp_sendto result 0
06:35:41.442 -> dhcps: send_offer>>udp_sendto result 0
06:35:42.544 -> Guru Meditation Error: Core  0 panic'ed (InstrFetchProhibited). Exception was unhandled.
06:35:42.544 -> Core 0 register dump:
06:35:42.544 -> PC      : 0x00000000  PS      : 0x00060230  A0      : 0x80121379  A1      : 0x3ffb3f70
06:35:42.544 -> A2      : 0x3ffce5cc  A3      : 0x3ffcf088  A4      : 0x3ffce848  A5      : 0x3ffce828
06:35:42.544 -> A6      : 0x0201000a  A7      : 0x0c01000a  A8      : 0x8012121c  A9      : 0x3ffb3f30
06:35:42.544 -> A10     : 0x3ffce5dc  A11     : 0x3ffcf088  A12     : 0x3ffb3f7c  A13     : 0x00000044
06:35:42.544 -> A14     : 0x00000001  A15     : 0x00000006  SAR     : 0x00000010  EXCCAUSE: 0x00000014
06:35:42.544 -> EXCVADDR: 0x00000000  LBEG    : 0x4000c349  LEND    : 0x4000c36b  LCOUNT  : 0x00000000
06:35:42.544 ->
06:35:42.544 -> Backtrace: 0x00000000:0x3ffb3f70 0x40121376:0x3ffb3fb0 0x4012e465:0x3ffb3fd0 0x4013346d:0x3ffb4010 0x4013870a:0x3ffb4030 0x40121d7f:0x3ffb4050 0x40088b7d:0x3ffb4080
06:35:42.544 ->
06:35:42.544 -> Rebooting...
06:35:42.580 -> ets Jun  8 2016 00:22:57
06:35:42.580 ->
06:35:42.580 -> rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

This is 100% reproducible. And it never happens if I avoid making the wifiManager.setAPStaticIPConfig() call.

Settings in IDE

Arduino IDE 1.8.10
IDE setting here: https://imgur.com/a/JDwuLlt

WifiManager library, on branch development

Additional libraries:

N/A

Please see flavio-fernandes/persistWifiSetting@879c848 for code used to make it happen.

flavio-fernandes referenced this issue in flavio-fernandes/persistWifiSetting Feb 7, 2020
Use this commit and the readme on this repo to reproduce issue 1003
tzapu/WiFiManager#1003

This is the stack trace crash that we get once a client connects to
the portal:

PC: 0x00000000
EXCVADDR: 0x00000000

Decoding stack results
0x40121376: handle_dhcp at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/apps/dhcpserver/dhcpserver.c line 1031
0x4012e465: udp_input at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/udp.c line 401
0x4013346d: ip4_input at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/ipv4/ip4.c line 740
0x4013870a: ethernet_input at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/netif/ethernet.c line 184
0x40121d7f: tcpip_thread at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/api/tcpip.c line 135
0x40088b7d: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143

06:35:25.036 -> *WM: [3] allocating params bytes: 20
06:35:25.036 -> *WM: [2] Added Parameter: wifi_pass
06:35:25.036 -> *WM: [2] Added Parameter: mqtt_server
06:35:25.036 -> *WM: [2] Added Parameter: mqtt_port
06:35:25.036 -> *WM: [2] Added Parameter: mqtt_username
06:35:25.036 -> *WM: [2] Added Parameter: mqtt_password
06:35:25.036 -> *WM: [3] Updated _max_params: 10
06:35:25.036 -> *WM: [3] re-allocating params bytes: 40
06:35:25.036 -> *WM: [2] Added Parameter: mqtt_topic
06:35:25.036 -> *WM: [1] Free heap:        263960
06:35:25.036 -> *WM: [1] ESP-IDF version:  v3.2.3-14-gd3e562907
06:35:25.036 -> *WM: [2] Starting Config Portal
06:35:25.036 -> *WM: [3] WIFI station disconnect
06:35:25.036 -> *WM: [3] WiFi station enable
06:35:25.036 -> *WM: [2] Disabling STA
06:35:25.036 -> *WM: [2] Enabling AP
06:35:25.036 -> *WM: [1] StartAP with SSID:  ESP32_3312CFA4
06:35:25.036 -> *WM: [1] Custom AP IP/GW/Subnet:
06:35:25.141 -> *WM: [2] AP has anonymous access!
06:35:25.141 -> *WM: [1] SoftAP Configuration
06:35:25.141 -> *WM: [1] --------------------
06:35:25.141 -> *WM: [1] ssid:             ESP32_3312CFA4
06:35:25.141 -> *WM: [1] password:
06:35:25.141 -> *WM: [1] ssid_len:         14
06:35:25.141 -> *WM: [1] channel:          1
06:35:25.141 -> *WM: [1] authmode:
06:35:25.141 -> *WM: [1] ssid_hidden:
06:35:25.141 -> *WM: [1] max_connection:   4
06:35:25.141 -> *WM: [1] country:          CN
06:35:25.141 -> *WM: [1] beacon_interval:  100(ms)
06:35:25.141 -> *WM: [1] --------------------
06:35:25.645 -> *WM: [1] AP IP address: 10.0.1.1
06:35:25.645 -> *WM: [3] setupConfigPortal
06:35:25.645 -> *WM: [1] Starting Web Portal
06:35:25.645 -> *WM: [3] dns server started with ip:  10.0.1.1
06:35:25.645 -> *WM: [2] HTTP server started
06:35:27.953 -> *WM: [2] WiFi Scan completed in 2303 ms
06:35:27.953 -> *WM: [2] Config Portal Running, blocking, waiting for clients...
06:35:40.189 -> dhcps: send_nak>>udp_sendto result 0
06:35:41.442 -> dhcps: send_offer>>udp_sendto result 0
06:35:42.544 -> Guru Meditation Error: Core  0 panic'ed (InstrFetchProhibited). Exception was unhandled.
06:35:42.544 -> Core 0 register dump:
06:35:42.544 -> PC      : 0x00000000  PS      : 0x00060230  A0      : 0x80121379  A1      : 0x3ffb3f70
06:35:42.544 -> A2      : 0x3ffce5cc  A3      : 0x3ffcf088  A4      : 0x3ffce848  A5      : 0x3ffce828
06:35:42.544 -> A6      : 0x0201000a  A7      : 0x0c01000a  A8      : 0x8012121c  A9      : 0x3ffb3f30
06:35:42.544 -> A10     : 0x3ffce5dc  A11     : 0x3ffcf088  A12     : 0x3ffb3f7c  A13     : 0x00000044
06:35:42.544 -> A14     : 0x00000001  A15     : 0x00000006  SAR     : 0x00000010  EXCCAUSE: 0x00000014
06:35:42.544 -> EXCVADDR: 0x00000000  LBEG    : 0x4000c349  LEND    : 0x4000c36b  LCOUNT  : 0x00000000
06:35:42.544 ->
06:35:42.544 -> Backtrace: 0x00000000:0x3ffb3f70 0x40121376:0x3ffb3fb0 0x4012e465:0x3ffb3fd0 0x4013346d:0x3ffb4010 0x4013870a:0x3ffb4030 0x40121d7f:0x3ffb4050 0x40088b7d:0x3ffb4080
06:35:42.544 ->
06:35:42.544 -> Rebooting...
06:35:42.580 -> ets Jun  8 2016 00:22:57
06:35:42.580 ->
06:35:42.580 -> rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
@tablatronix tablatronix added bug Validated BUG DEV Help Wanted Developer Needs Help Priority labels Feb 7, 2020
@tablatronix
Copy link
Collaborator

tablatronix commented Feb 7, 2020

What happen if you use regular const or vars? Not defines.

have you tried a plain sketch without wm ?

@flavio-fernandes
Copy link
Contributor Author

What happen if you use regular const or vars? Not defines.

have you tried a plain sketch without wm ?

The same issue happens when I use const, static or plain variables.

See: flavio-fernandes/persistWifiSetting@17f485e

PC: 0x00000000
EXCVADDR: 0x00000000

Decoding stack results
0x401211a2: handle_dhcp at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/apps/dhcpserver/dhcpserver.c line 1031
0x4012e291: udp_input at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/udp.c line 401
0x40133299: ip4_input at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/ipv4/ip4.c line 740
0x40138536: ethernet_input at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/netif/ethernet.c line 184
0x40121bab: tcpip_thread at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/api/tcpip.c line 135
0x40088b7d: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143
18:05:19.095 -> here we go
18:05:19.095 -> wifiConfig_init called
18:05:19.204 -> *WM: [1] <form action='/wifi'    method='get'><button>Configure WiFi</button></form><br/>
18:05:19.204 -> <form action='/info'    method='get'><button>Info</button></form><br/>
18:05:19.204 -> <form action='/exit'    method='get'><button>Exit</button></form><br/>
18:05:19.204 ->  
18:05:19.204 -> *WM: [3] allocating params bytes: 20
18:05:19.204 -> *WM: [2] Added Parameter: wifi_pass
18:05:19.204 -> *WM: [2] Added Parameter: mqtt_server
18:05:19.204 -> *WM: [2] Added Parameter: mqtt_port
18:05:19.204 -> *WM: [2] Added Parameter: mqtt_username
18:05:19.204 -> *WM: [2] Added Parameter: mqtt_password
18:05:19.204 -> *WM: [3] Updated _max_params: 10
18:05:19.204 -> *WM: [3] re-allocating params bytes: 40
18:05:19.204 -> *WM: [2] Added Parameter: mqtt_topic
18:05:19.204 -> *WM: [1] Free heap:        263980
18:05:19.204 -> *WM: [1] ESP-IDF version:  v3.2.3-14-gd3e562907
18:05:19.204 -> *WM: [2] Starting Config Portal 
18:05:19.204 -> *WM: [3] WIFI station disconnect 
18:05:19.204 -> *WM: [3] WiFi station enable 
18:05:19.204 -> *WM: [2] Disabling STA 
18:05:19.204 -> *WM: [2] Enabling AP 
18:05:19.204 -> *WM: [1] StartAP with SSID:  ESP32_20A4AE30
18:05:19.204 -> *WM: [1] Custom AP IP/GW/Subnet: 
18:05:19.352 -> *WM: [2] AP has anonymous access! 
18:05:19.352 -> *WM: [1] SoftAP Configuration 
18:05:19.352 -> *WM: [1] -------------------- 
18:05:19.352 -> *WM: [1] ssid:             ESP32_20A4AE30
18:05:19.352 -> *WM: [1] password:         
18:05:19.352 -> *WM: [1] ssid_len:         14
18:05:19.352 -> *WM: [1] channel:          1
18:05:19.352 -> *WM: [1] authmode:        
18:05:19.352 -> *WM: [1] ssid_hidden:     
18:05:19.352 -> *WM: [1] max_connection:   4
18:05:19.352 -> *WM: [1] country:          CN
18:05:19.352 -> *WM: [1] beacon_interval:  100(ms)
18:05:19.352 -> *WM: [1] -------------------- 
18:05:19.844 -> *WM: [1] AP IP address: 10.0.1.2
18:05:19.844 -> *WM: [3] setupConfigPortal 
18:05:19.844 -> *WM: [1] Starting Web Portal 
18:05:19.844 -> *WM: [3] dns server started with ip:  10.0.1.2
18:05:19.844 -> *WM: [2] HTTP server started 
18:05:22.139 -> *WM: [2] WiFi Scan completed in 2304 ms
18:05:22.139 -> *WM: [2] Config Portal Running, blocking, waiting for clients... 
18:05:28.665 -> dhcps: send_offer>>udp_sendto result 0
18:05:29.847 -> Guru Meditation Error: Core  0 panic'ed (InstrFetchProhibited). Exception was unhandled.
18:05:29.847 -> Core 0 register dump:
18:05:29.847 -> PC      : 0x00000000  PS      : 0x00060e30  A0      : 0x801211a5  A1      : 0x3ffb3f70  
18:05:29.847 -> A2      : 0x3ffce2b8  A3      : 0x3ffce4ec  A4      : 0x3ffcd9d4  A5      : 0x3ffcd9b4  
18:05:29.847 -> A6      : 0x0301000a  A7      : 0x0d01000a  A8      : 0x80121048  A9      : 0x3ffb3f30  
18:05:29.847 -> A10     : 0x3ffce2c8  A11     : 0x3ffce4ec  A12     : 0x3ffb3f7c  A13     : 0x00000044  
18:05:29.847 -> A14     : 0x00000001  A15     : 0x00000006  SAR     : 0x00000010  EXCCAUSE: 0x00000014  
18:05:29.847 -> EXCVADDR: 0x00000000  LBEG    : 0x4000c349  LEND    : 0x4000c36b  LCOUNT  : 0x00000000  
18:05:29.847 -> 
18:05:29.847 -> Backtrace: 0x00000000:0x3ffb3f70 0x401211a2:0x3ffb3fb0 0x4012e291:0x3ffb3fd0 0x40133299:0x3ffb4010 0x40138536:0x3ffb4030 0x40121bab:0x3ffb4050 0x40088b7d:0x3ffb4080
18:05:29.847 -> 
18:05:29.847 -> Rebooting...

@tablatronix
Copy link
Collaborator

I am assuming you tried inline also? Ill try to test , in the meantime I am sure there is a example for static ip try that also as this exception seems to make it to the esp lib so see if its a esp bug

@tablatronix
Copy link
Collaborator

You using arduino for idf?

@tablatronix
Copy link
Collaborator

Wrong thread

@Craigzyc
Copy link

Craigzyc commented May 12, 2020

I have been experiencing this issue.

It seems like if you do an erase_flash through esptool.py you get some reboots out of it before it starts causing issues.

Some reboots, it will listen and set the IP as requested (8.8.8.8 in my case) but other reboots it doesn't get properly set, defaults to 192.168.4.1 then reboots on the first client connecting. I see yours does seem to set the IP so this may be similar but unrelated.
image

After a few reboots, I have about a 20% success rate where it will correctly set 8.8.8.8 which fixes the captive portal not appearing on android.

I'm setting the IP like so:
wm.setAPStaticIPConfig(IPAddress(8,8,8,8), IPAddress(8,8,8,8), IPAddress(255,255,255,0));

It consistently works as expected any time it successfully sets the IP and consistently crashes when it doesn't
image

@tablatronix
Copy link
Collaborator

tablatronix commented May 12, 2020

hmm, not able to reproduce, ill keep trying
I am running latest of course development branch

wm.setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));

Screen Shot 2020-05-11 at 11 43 11 PM

@Boguinhos
Copy link

I can't really check right away but i'm on ESP8266 and i think i'm passing thru the same issue.
After setting static STA addresses and wm.debug is on, if the ESP does not connect some exception pops up. if Debug is off , ESP runs without crashing but something weird is happening to me. if i always use DCHP connection is perfect. if i am forcing STAIpConfig , the ESP will only connect at second try. first try nothing happens and it seems like its hung up. if i power cycle the device by removing the cable and power it again it will connect with success. just never at first time. if i'm using the computer and serial terminal it seems like this issue does not occur as often, even with wm.debug false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Validated BUG DEV Help Wanted Developer Needs Help Priority
Projects
None yet
Development

No branches or pull requests

4 participants