[GH-ISSUE #789] Adding new/additional WiFiParam to existing App causes crash at configuration #660

Closed
opened 2026-02-28 01:26:26 +03:00 by kerem · 8 comments
Owner

Originally created by @gduprey on GitHub (Dec 19, 2018).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/789

Basic Infos

Hardware

WiFimanager Branch/Release:

  • Master
  • Development

Esp8266/Esp32:

  • ESP8266
  • ESP32

Hardware: ESP-12e, esp01, esp25

  • ESP01
  • ESP12 E/F/S (nodemcu, wemos, feather)
  • Other
  • ESP32 OLED WEMOS/WROVER dev board

ESP Core Version: 2.4.0, staging

  • 2.3.0
  • 2.4.0
  • staging (master/dev)
  • 1.0.0 (ESP32)

Description

I have an existing app with no parameters (no WiFiManagerParameters). Configuration works great (using either autoConnect() or startConfigPortal()). I then add a single new parameter to the application, flash it and when I try to connect to the the config portal, the ESP crashes (below).

If I flash the code with the new parameter but do NOT enter the config portal (i.e. use previously stored WiFi settings), everything works (no crash).

If I add a resetSettings() call, then things work fine (I can connect, configure WiFi and see the parameter in the portal and save). But if I store settings and then reboot the chip and re-enter config mode (startConfigPortal()), when I attempt to connect to the ESP AP, it crashes again.

If I remove the parameter, everything works as expected (I can configure and reconfigure many times with no crashes).

The crash happens after the config portal appears as an AP, at the moment you attempt to connect to it (and by connect, I mean join the AP's SSID from my phones WiFi settings page). So you never get a chance to even attempt to view the actual config portal web page with a browser - the WiFi connection alone initiates the crash.

I'm running on an ESP32/WROVER using the development branch WiFiManager.

Settings in IDE

Module: ESP32 WROVER

Additional libraries:

Sketch


#include <WiFiManager.h>

WiFiManagerParameter * custom_led_count;

void setup() {
  char ledCountBuffer[16];
  WiFiManager wm;

  // Configure WiFiManager
  // wm.setDebugOutput(false);
  //wm.resetSettings();
  wm.setConfigPortalTimeout(300);

  // Set configurables
  sprintf(ledCountBuffer, "%d", stripLEDCount);
  custom_led_count = new WiFiManagerParameter("ledCount", "Strip LED Count", ledCountBuffer, 16);
  wm.addParameter(custom_led_count);

  // Set AP settings
  wm.setAPStaticIPConfig(IPAddress(192, 168, 254, 1), IPAddress(192, 168, 254, 1), IPAddress(255, 255, 255, 0));

  // See if we should unconditionally enter config mode vs. auto-mode
  pinMode(CONFIG_BUTTON, INPUT_PULLUP);
  if (digitalRead(CONFIG_BUTTON) == LOW) {
    wifiStarted = wm.startConfigPortal(nodeName);
  } else {
    // Attempt connection or start auto-config
    wifiStarted = wm.autoConnect(nodeName);
  }
}

void loop() {

}

Debug Messages

ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:952
load:0x40078000,len:6084
load:0x40080000,len:7936
entry 0x40080310
Booting
*WM: [3] allocating params bytes: 20
*WM: [2] Added Parameter: ledCount
*WM: [3] WIFI station disconnect 
*WM: [3] WiFi station enable 
*WM: [2] Disabling STA 
*WM: [2] Enabling AP 
*WM: [1] StartAP with SSID:  NET_LED
*WM: [1] Custom AP IP/GW/Subnet: 
*WM: [2] AP has anonymous access! 
*WM: [1] AP IP address: 192.168.254.1
*WM: [3] setupConfigPortal 
*WM: [1] Starting Web Portal 
*WM: [3] dns server started with ip:  192.168.254.1
*WM: [2] HTTP server started 
*WM: [2] WiFi Scan ASYNC started 
*WM: [2] Config Portal Running, blocking, waiting for clients... 
Guru Meditation Error: Core  1 panic'ed (InstrFetchProhibited). Exception was unhandled.
Core 1 register dump:
PC      : 0x00000000  PS      : 0x00060030  A0      : 0x801050b9  A1      : 0x3ffb6270  
A2      : 0x3ffbcb40  A3      : 0x3ffbc328  A4      : 0x3ffbbd8c  A5      : 0x3ffbcb20  
A6      : 0x02fea8c0  A7      : 0x0cfea8c0  A8      : 0x80104f58  A9      : 0x3ffb6230  
A10     : 0x3ffbcb50  A11     : 0x3ffbc328  A12     : 0x3ffb627c  A13     : 0x00000044  
A14     : 0x00000001  A15     : 0x00000006  SAR     : 0x00000010  EXCCAUSE: 0x00000014  
EXCVADDR: 0x00000000  LBEG    : 0x4000c349  LEND    : 0x4000c36b  LCOUNT  : 0x00000000  

Backtrace: 0x00000000:0x3ffb6270 0x401050b6:0x3ffb62b0 0x4010d06d:0x3ffb62d0 0x4010fc19:0x3ffb6310 0x4011635e:0x3ffb6330 0x40104479:0x3ffb6350

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:952
load:0x40078000,len:6084
load:0x40080000,len:7936
entry 0x40080310
Booting
Originally created by @gduprey on GitHub (Dec 19, 2018). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/789 ### Basic Infos #### Hardware **WiFimanager Branch/Release:** - [ ] Master - [X] Development **Esp8266/Esp32:** - [ ] ESP8266 - [X] ESP32 **Hardware: ESP-12e, esp01, esp25** - [ ] ESP01 - [ ] ESP12 E/F/S (nodemcu, wemos, feather) - [ ] Other - [X] ESP32 OLED WEMOS/WROVER dev board **ESP Core Version: 2.4.0, staging** - [ ] 2.3.0 - [ ] 2.4.0 - [ ] staging (master/dev) - [X] 1.0.0 (ESP32) ### Description I have an existing app with no parameters (no WiFiManagerParameters). Configuration works great (using either autoConnect() or startConfigPortal()). I then add a single new parameter to the application, flash it and when I try to connect to the the config portal, the ESP crashes (below). If I flash the code with the new parameter but do NOT enter the config portal (i.e. use previously stored WiFi settings), everything works (no crash). If I add a resetSettings() call, then things work fine (I can connect, configure WiFi and see the parameter in the portal and save). But if I store settings and then reboot the chip and re-enter config mode (startConfigPortal()), when I attempt to connect to the ESP AP, it crashes again. If I remove the parameter, everything works as expected (I can configure and reconfigure many times with no crashes). The crash happens after the config portal appears as an AP, at the moment you attempt to connect to it (and by connect, I mean join the AP's SSID from my phones WiFi settings page). So you never get a chance to even attempt to view the actual config portal web page with a browser - the WiFi connection alone initiates the crash. I'm running on an ESP32/WROVER using the development branch WiFiManager. ### Settings in IDE Module: ESP32 WROVER Additional libraries: ### Sketch ```cpp #include <WiFiManager.h> WiFiManagerParameter * custom_led_count; void setup() { char ledCountBuffer[16]; WiFiManager wm; // Configure WiFiManager // wm.setDebugOutput(false); //wm.resetSettings(); wm.setConfigPortalTimeout(300); // Set configurables sprintf(ledCountBuffer, "%d", stripLEDCount); custom_led_count = new WiFiManagerParameter("ledCount", "Strip LED Count", ledCountBuffer, 16); wm.addParameter(custom_led_count); // Set AP settings wm.setAPStaticIPConfig(IPAddress(192, 168, 254, 1), IPAddress(192, 168, 254, 1), IPAddress(255, 255, 255, 0)); // See if we should unconditionally enter config mode vs. auto-mode pinMode(CONFIG_BUTTON, INPUT_PULLUP); if (digitalRead(CONFIG_BUTTON) == LOW) { wifiStarted = wm.startConfigPortal(nodeName); } else { // Attempt connection or start auto-config wifiStarted = wm.autoConnect(nodeName); } } void loop() { } ``` ### Debug Messages ``` ets Jun 8 2016 00:22:57 rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0018,len:4 load:0x3fff001c,len:952 load:0x40078000,len:6084 load:0x40080000,len:7936 entry 0x40080310 Booting *WM: [3] allocating params bytes: 20 *WM: [2] Added Parameter: ledCount *WM: [3] WIFI station disconnect *WM: [3] WiFi station enable *WM: [2] Disabling STA *WM: [2] Enabling AP *WM: [1] StartAP with SSID: NET_LED *WM: [1] Custom AP IP/GW/Subnet: *WM: [2] AP has anonymous access! *WM: [1] AP IP address: 192.168.254.1 *WM: [3] setupConfigPortal *WM: [1] Starting Web Portal *WM: [3] dns server started with ip: 192.168.254.1 *WM: [2] HTTP server started *WM: [2] WiFi Scan ASYNC started *WM: [2] Config Portal Running, blocking, waiting for clients... Guru Meditation Error: Core 1 panic'ed (InstrFetchProhibited). Exception was unhandled. Core 1 register dump: PC : 0x00000000 PS : 0x00060030 A0 : 0x801050b9 A1 : 0x3ffb6270 A2 : 0x3ffbcb40 A3 : 0x3ffbc328 A4 : 0x3ffbbd8c A5 : 0x3ffbcb20 A6 : 0x02fea8c0 A7 : 0x0cfea8c0 A8 : 0x80104f58 A9 : 0x3ffb6230 A10 : 0x3ffbcb50 A11 : 0x3ffbc328 A12 : 0x3ffb627c A13 : 0x00000044 A14 : 0x00000001 A15 : 0x00000006 SAR : 0x00000010 EXCCAUSE: 0x00000014 EXCVADDR: 0x00000000 LBEG : 0x4000c349 LEND : 0x4000c36b LCOUNT : 0x00000000 Backtrace: 0x00000000:0x3ffb6270 0x401050b6:0x3ffb62b0 0x4010d06d:0x3ffb62d0 0x4010fc19:0x3ffb6310 0x4011635e:0x3ffb6330 0x40104479:0x3ffb6350 Rebooting... ets Jun 8 2016 00:22:57 rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0018,len:4 load:0x3fff001c,len:952 load:0x40078000,len:6084 load:0x40080000,len:7936 entry 0x40080310 Booting ```
kerem 2026-02-28 01:26:26 +03:00
Author
Owner

@pieman64 commented on GitHub (Dec 19, 2018):

@gduprey did you look at an example with parameters as your sketch looks to be missing quite a bit of code?

<!-- gh-comment-id:448612705 --> @pieman64 commented on GitHub (Dec 19, 2018): @gduprey did you look at an example with parameters as your sketch looks to be missing quite a bit of code?
Author
Owner

@gduprey commented on GitHub (Dec 19, 2018):

I stripped the code down to a very minimal example (that still demonstrates the problem).

<!-- gh-comment-id:448614508 --> @gduprey commented on GitHub (Dec 19, 2018): I stripped the code down to a very minimal example (that still demonstrates the problem).
Author
Owner

@pieman64 commented on GitHub (Dec 19, 2018):

Parameters appear 2 or 3 times in the example code. Try one of them.

<!-- gh-comment-id:448615364 --> @pieman64 commented on GitHub (Dec 19, 2018): Parameters appear 2 or 3 times in the example code. Try one of them.
Author
Owner

@gduprey commented on GitHub (Dec 19, 2018):

Yep - the block I pasted was stripped down, but was not the final one (missed a define and two variables). I have that and will post/edit the above when I get back home later today.

There may also be some interaction with the Arduino preferences API - I need to play with a few configs there too as something seems a little off (but not reliably, of course...)

<!-- gh-comment-id:448616432 --> @gduprey commented on GitHub (Dec 19, 2018): Yep - the block I pasted was stripped down, but was not the final one (missed a define and two variables). I have that and will post/edit the above when I get back home later today. There may also be some interaction with the Arduino preferences API - I need to play with a few configs there too as something seems a little off (but not reliably, of course...)
Author
Owner

@gduprey commented on GitHub (Dec 19, 2018):

Well, I'm embarrassed. Its not WiFiManager.

In the process of trimming things down and trying to make an oh-so-perfect report, I cut out (partially) use of the Preferences API. It appears that use of Preferences is not compatible with something in the WiFi system (I assume, the code that keeps/restores the last SSID/Password).

I did insure that I created my own instance of the Preferences object and I used a custom name space that could not conflict with any other used name space.

Might be worth a mention that you cannot use the Preference API with WiFi (again, not a WiFiManager issue, but the support for WiFIManagerParameter is going to encourage someone else to use Preferences to keep/store values for it).

Sorry for the noise.

<!-- gh-comment-id:448628697 --> @gduprey commented on GitHub (Dec 19, 2018): Well, I'm embarrassed. Its not WiFiManager. In the process of trimming things down and trying to make an oh-so-perfect report, I cut out (partially) use of the Preferences API. It appears that use of Preferences is not compatible with something in the WiFi system (I assume, the code that keeps/restores the last SSID/Password). I did insure that I created my own instance of the Preferences object and I used a custom name space that could not conflict with any other used name space. Might be worth a mention that you cannot use the Preference API with WiFi (again, not a WiFiManager issue, but the support for WiFIManagerParameter is going to encourage someone else to use Preferences to keep/store values for it). Sorry for the noise.
Author
Owner

@tablatronix commented on GitHub (Dec 19, 2018):

what is preferences API ?

<!-- gh-comment-id:448655324 --> @tablatronix commented on GitHub (Dec 19, 2018): what is preferences API ?
Author
Owner

@gduprey commented on GitHub (Dec 19, 2018):

Arduino-esp has a Preferences API that just overlays the underlying ESP32 nvm_* functions. It's just a thin "skin" over them. The nvs_* stuff abstracts some flash space into a key/value store for simple stuff and apparently, the underlying WiFi stuff uses the same stuff for storing the last ssid/password combo.

I don't quite understand why they conflict, but they definitely do.

In my case, I had a small number of configurable fields. I was storing their value in the nvs/Preference because it was only 3 fields and didn't seem worth the overhead of creating/parsing/writing a JSON file. So I'd open Preferences, read last saved values, if any, feed those into WiFiManagerParameters and then on the flip side, read those parameter values and store then via Preferences.

Nice a clean and small, but at least right now, not working

Heres a link to the Preferences API

<!-- gh-comment-id:448657046 --> @gduprey commented on GitHub (Dec 19, 2018): Arduino-esp has a Preferences API that just overlays the underlying ESP32 nvm_* functions. It's just a thin "skin" over them. The nvs_* stuff abstracts some flash space into a key/value store for simple stuff and apparently, the underlying WiFi stuff uses the same stuff for storing the last ssid/password combo. I don't quite understand why they conflict, but they definitely do. In my case, I had a small number of configurable fields. I was storing their value in the nvs/Preference because it was only 3 fields and didn't seem worth the overhead of creating/parsing/writing a JSON file. So I'd open Preferences, read last saved values, if any, feed those into WiFiManagerParameters and then on the flip side, read those parameter values and store then via Preferences. Nice a clean and small, but at least right now, not working Heres a link to the [Preferences API](https://github.com/espressif/arduino-esp32/tree/master/libraries/Preferences)
Author
Owner

@tablatronix commented on GitHub (Dec 19, 2018):

interesting, this must be new, I will check it out, pretty cool

<!-- gh-comment-id:448704232 --> @tablatronix commented on GitHub (Dec 19, 2018): interesting, this must be new, I will check it out, pretty cool
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#660
No description provided.