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

2.2.0 Exception (3): #1997

Closed
tablatronix opened this issue May 5, 2016 · 54 comments
Closed

2.2.0 Exception (3): #1997

tablatronix opened this issue May 5, 2016 · 54 comments

Comments

@tablatronix
Copy link
Contributor

tablatronix commented May 5, 2016

Basic Infos

Using wifimanager library, on credential save, I get exceptions

Hardware

Hardware: nodemcu v1 12e
Core Version: 2.2.0 stable

Description

Need help deciphering this stack

Settings in IDE

ide 1.6.8

Module: nodemcu v1 12e
Flash Size: 4MB/1MB
CPU Frequency: 80Mhz
Flash Mode: qio
Flash Frequency: 80Mhz
Upload Using: SERIAL
Reset Method: nodemcu

Exception (3):
epc1=0x401003e9 epc2=0x00000000 epc3=0x00000000 excvaddr=0x4000cbd9 depc=0x00000000

ctx: cont 
sp: 3fff03f0 end: 3fff0990 offset: 01a0
Decoding 49 results
0x401003e9: _umm_malloc at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266\umm_malloc/umm_malloc.c line 1380
0x40230770: etharp_output at ?? line ?
0x40231808: ip_output_if_opt at ?? line ?
0x401004f4: calloc at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266\umm_malloc/umm_malloc.c line 1682
0x401073cc: pvPortZalloc at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/heap.c line 33
0x40220d4d: wifi_param_save_protect_with_check at ?? line ?
0x401057d2: spi_flash_read at ?? line ?
0x40220e35: system_param_save_with_protect at ?? line ?
0x40221224: wifi_station_ap_number_set at ?? line ?
0x4022137f: wifi_station_ap_number_set at ?? line ?
0x4022140c: wifi_station_ap_number_set at ?? line ?
0x40221448: wifi_station_set_config at ?? line ?
0x40202896: ESP8266WiFiSTAClass::begin(char const*, char const*, int, unsigned char const*, bool) at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\libraries\ESP8266WiFi\src/ESP8266WiFiSTA.cpp line 505
0x402027b7: ESP8266WiFiSTAClass::begin(char const*, char const*, int, unsigned char const*, bool) at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\libraries\ESP8266WiFi\src/ESP8266WiFiSTA.cpp line 505
0x4020a200: wifi_fpm_set_wakeup_cb at ?? line ?
0x40208d41: String::getBytes(unsigned char*, unsigned int, unsigned int) const at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/WString.cpp line 519
0x402423d0: bignum_exptmod at ?? line ?
0x40208d41: String::getBytes(unsigned char*, unsigned int, unsigned int) const at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/WString.cpp line 519
0x40208d6c: String::indexOf(char, unsigned int) const at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/WString.cpp line 519
0x402423d0: bignum_exptmod at ?? line ?
0x40208d90: String::indexOf(char) const at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/WString.cpp line 519
0x402048b0: FunctionRequestHandler::handle(ESP8266WebServer&, HTTPMethod, String) at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\libraries\ESP8266WebServer\src\detail/RequestHandlersImpl.h line 53
0x40209638: Print::write(unsigned char const*, unsigned int) at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/Print.cpp line 64
0x40208355: Print::write(char const*) at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/Print.cpp line 64
0x40241508: bignum_exptmod at ?? line ?
0x40208355: Print::write(char const*) at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/Print.cpp line 64
0x40220a9a: wifi_get_opmode at ?? line ?
0x402083a4: Print::println(__FlashStringHelper const*) at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/Print.cpp line 64
0x4020276c: ESP8266WiFiSTAClass::status() at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\libraries\ESP8266WiFi\src/ESP8266WiFiSTA.cpp line 505
0x40206c4c: WiFiManager::connectWifi(String, String) at Documents\projects\arduino\sketches\libraries\WiFiManager/WiFiManager.cpp line 716
0x4020872c: String::changeBuffer(unsigned int) at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/WString.cpp line 519
0x4020877b: String::reserve(unsigned int) at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/WString.cpp line 519
0x402087ad: String::copy(char const*, unsigned int) at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/WString.cpp line 519
0x402088b4: String::operator=(String const&) at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/WString.cpp line 519
0x402010ae: delay at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/core_esp8266_wiring.c line 53
0x4024153c: bignum_exptmod at ?? line ?
0x40207a4f: WiFiManager::startConfigPortal(char const*, char const*) at Documents\projects\arduino\sketches\libraries\WiFiManager/WiFiManager.cpp line 716
0x4010068c: free at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266\umm_malloc/umm_malloc.c line 1731
0x40241560: bignum_exptmod at ?? line ?
0x40207b85: WiFiManager::autoConnect(char const*, char const*) at Documents\projects\arduino\sketches\libraries\WiFiManager/WiFiManager.cpp line 716
0x4010068c: free at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266\umm_malloc/umm_malloc.c line 1731
0x40207bdc: WiFiManager::autoConnect() at Documents\projects\arduino\sketches\libraries\WiFiManager/WiFiManager.cpp line 716
0x40206a5f: WiFiManager::WiFiManager() at Documents\projects\arduino\sketches\libraries\WiFiManager/WiFiManager.cpp line 716
0x40202024: setup at Documents\projects\arduino\sketches\libraries\WiFiManager\examples\AutoConnectWithFeedbackLED/AutoConnectWithFeedbackLED.ino line 51
0x40201f70: configModeCallback(WiFiManager*) at Documents\projects\arduino\sketches\libraries\WiFiManager\examples\AutoConnectWithFeedbackLED/AutoConnectWithFeedbackLED.ino line 20
0x402091b4: loop_wrapper at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/core_esp8266_main.cpp line 43
0x40100718: cont_norm at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/cont.S line 109

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@tablatronix
Copy link
Contributor Author

And testing similar code ( a PR 157 on the wifimanager repo )

Exception (3):
epc1=0x40100255 epc2=0x00000000 epc3=0x00000000 excvaddr=0x40070bde depc=0x00000000

ctx: cont 
sp: 3fff0710 end: 3fff0b90 offset: 01a0
Decoding 30 results
0x40100255: _umm_free at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266\umm_malloc/umm_malloc.c line 1298
0x4010020c: _umm_free at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266\umm_malloc/umm_malloc.c line 1285
0x402441c0: bignum_exptmod at ?? line ?
0x4010068c: free at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266\umm_malloc/umm_malloc.c line 1731
0x40105b32: spi_flash_read at ?? line ?
0x401075c0: vPortFree at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/heap.c line 18
0x40221a2a: wifi_param_save_protect_with_check at ?? line ?
0x402441c0: bignum_exptmod at ?? line ?
0x40221a47: wifi_param_save_protect_with_check at ?? line ?
0x40221aad: system_param_save_with_protect at ?? line ?
0x40221e9c: wifi_station_ap_number_set at ?? line ?
0x40221ff7: wifi_station_ap_number_set at ?? line ?
0x40222084: wifi_station_ap_number_set at ?? line ?
0x402220c0: wifi_station_set_config at ?? line ?
0x40202888: ESP8266WiFiSTAClass::disconnect(bool) at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\libraries\ESP8266WiFi\src/ESP8266WiFiSTA.cpp line 505
0x4010053d: _umm_realloc at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266\umm_malloc/umm_malloc.c line 1489
:  (inlined by) realloc at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266\umm_malloc/umm_malloc.c line 1707
0x4010053d: _umm_realloc at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266\umm_malloc/umm_malloc.c line 1489
:  (inlined by) realloc at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266\umm_malloc/umm_malloc.c line 1707
0x40221712: wifi_get_opmode at ?? line ?
0x4022253b: wifi_station_get_connect_status at ?? line ?
0x40202990: ESP8266WiFiSTAClass::status() at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\libraries\ESP8266WiFi\src/ESP8266WiFiSTA.cpp line 505
0x40209338: String::changeBuffer(unsigned int) at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/WString.cpp line 519
0x402083bc: WiFiManager::startConfigPortal(char const*, char const*) at Documents\projects\arduino\sketches\libraries\WiFiManager/WiFiManager.cpp line 839
0x4010020c: _umm_free at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266\umm_malloc/umm_malloc.c line 1285
0x4010068c: free at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266\umm_malloc/umm_malloc.c line 1731
0x40208528: WiFiManager::startConfigPortal() at Documents\projects\arduino\sketches\libraries\WiFiManager/WiFiManager.cpp line 839
0x4020703f: WiFiManager::WiFiManager() at Documents\projects\arduino\sketches\libraries\WiFiManager/WiFiManager.cpp line 839
0x40201fc4: setup at Documents\projects\arduino\sketches\libraries\WiFiManager\examples\ConfigOnSwitch/ConfigOnSwitch.ino line 35
0x40209d90: loop_wrapper at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/core_esp8266_main.cpp line 43
0x40100718: cont_norm at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/cont.S line 109

@marwijn
Copy link

marwijn commented May 6, 2016

I got the same exception with the program below:

inline void handler (void)
{
  timer0_write(ESP.getCycleCount() + 500000); 
}

void setup() {
  Serial.begin(74880);
  noInterrupts();
  timer0_isr_init();
  timer0_attachInterrupt(handler);

  timer0_write(ESP.getCycleCount() + 160000);
  interrupts();

}

void loop() {
  Serial.println("Test");
  delay(1000);
}

Hopefully this helps in solving the issue.

@igrr
Copy link
Member

igrr commented May 6, 2016

@marwijn you are missing ICACHE_RAM_ATTR attribute on the interrupt handler.

@marwijn
Copy link

marwijn commented May 6, 2016

@igrr Thanks a lot never realised I needed it. This fixes my problem. So the original problem is probably not related.

@tablatronix
Copy link
Contributor Author

tablatronix commented May 6, 2016

I turned debugging on full

*WM: Sent wifi save page
:rcl
:abort
*WM: Connecting to new AP
*WM: Connecting as wifi client...
there is no poison after the block. Expected poison address: 0x3fff3e90, actual data: 0x0 0x5 0x8d 0xfe

Panic AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266\umm_malloc\umm_malloc.c:851 check_poison_block

ctx: cont 
sp: 3fff1050 end: 3fff1590 offset: 01b0

@tablatronix
Copy link
Contributor Author

Seems like the same problems over and over #1856 #1699 #1675

can reproduce similar problem with that #1699 (comment) sketch, but my flash seems ok

Flash real id:   001640E0
Flash real size: 4194304

Flash ide  size: 4194304
Flash ide speed: 40000000
Flash ide mode:  DIO
Flash Chip configuration ok.

@tablatronix
Copy link
Contributor Author

tablatronix commented May 6, 2016

I had to install esptool.py again and use it for erasing flash to fix this.
Esptool.exe -ce was not doing anything

It works for a second and then does this ( the checkflash sketch again )

Joining network
[WIFI][APlistAdd] add SSID: myNetworkName
[WIFI] delete old wifi config...
there is no poison after the block. Expected poison address: 0x3fff1880, actual data: 0x0 0x5 0xff 0x3f

Panic C:\Users\alverson\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266\umm_malloc\umm_malloc.c:851 check_poison_block

ctx: cont 
sp: 3fff02c0 end: 3fff0700 offset: 01b0

>>>stack>>>
3fff0470:  feefeffe feefeffe feefeffe 40100334  
3fff0480:  feefeffe 00000ca0 3ffef5f4 40100435  
3fff0490:  feefeffe feefeffe feefeffe 40100537  
3fff04a0:  feefeffe 00001000 00000484 401006f5  
3fff04b0:  00000484 00001000 000003fe 40107014  
3fff04c0:  40004b31 3fff04f0 0000001c 4021ad41  
3fff04d0:  4010571a 4021ae29 3fff13fc 000003ff  
3fff04e0:  000003fd 3fff0590 3fff13fc 000003fd  
3fff04f0:  ffffff01 55aa55aa 00000009 0000001c  
3fff0500:  0000001c 00000063 00000063 000003ff  
3fff0510:  4021b218 3fff13fc 3fff13fc 000000ff  
3fff0520:  00000001 3fff05b0 4021b373 00000008  
3fff0530:  3fff13fc 000000ff 3fff0590 00000000  
3fff0540:  3fff14bc 3fff05f1 00000001 4021b400  
3fff0550:  3fff0590 3fff13fc 3ffef618 fffffffe  
3fff0560:  3fff05b0 3fff7734 3fff13fc 3ffef618  
3fff0570:  4021b43c 00000000 00000000 6c6f2065  
3fff0580:  402024ec 63206966 69666e6f 2e2e2e67  
3fff0590:  3fff0000 40106e68 3ffef618 00000008  
3fff05a0:  3ffef618 00000029 3fff05f9 402036d0  
3fff05b0:  3fff0500 3fff05c0 00000008 0000002a  
3fff05c0:  3ffef618 00000008 60000000 0000007e  
3fff05d0:  6000001c 0000002b 3ffef4b4 00400000  
3fff05e0:  3ffe8780 53532064 3fff05c0 3fff05f0  
3fff05f0:  3fff088c 402025b0 fe000a65 fffffffe  
3fff0600:  3ffef618 3ffef4b4 00000000 40202283  
3fff0610:  3fff0650 3fff0620 00000008 401006d8  
3fff0620:  4f494420 3030000a 3fff083c 3fff13c4  
3fff0630:  3fff0670 3fff083c 00000018 4020238b  
3fff0640:  3ffe8874 3ffe84b4 3fff0620 3fff0650  
3fff0650:  3fff0690 0000000e 00000009 3fff083c  
3fff0660:  3ffef4a8 3ffe84b4 3ffef618 4020249d  
3fff0670:  3fff083c 3fff13c4 3ffef4a8 40202f61  
3fff0680:  3ffe8494 3ffef5f8 3ffef618 3ffef5f8  
3fff0690:  00400000 3ffef4a8 3ffef618 3ffef5f8  
3fff06a0:  00400000 3ffef4a8 3ffef618 40201d37  
3fff06b0:  feefeffe feefeffe feefeffe feefeffe  
3fff06c0:  00000002 feefeffe feefeffe feefeffe  
3fff06d0:  feefeffe feefeffe feefeffe 3ffef6d4  
3fff06e0:  3fffdad0 00000000 3ffef6cc 40203553  
3fff06f0:  feefeffe feefeffe 3ffef6e0 40100958  
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1264, room 16 
tail 0
chksum 0x0f
csum 0x0f

@igrr
Copy link
Member

igrr commented May 7, 2016

Reproduced this, thanks for detailed report. Looks like an out-of-bound write in SDK code. Will dig deeper on Monday.

@kentaylor
Copy link

@tablatronix tested WifiManager, found it to fail, provided the trace and @igrr was able to reproduce it.

I believe this is the same problem that led me to finding WiFiManager flaky and which further led to
to my "PR 157 on the wifimanager repo". I believe tzapu/WiFiManager#157 fixes the problem. I always thought there was an underlying issue in the Espressif SDK but assumed Espressif would be unlikely to fix it. It is fascinating to see that @igrr is now interested in fixing this on behalf of Espressif. I further think the issue in the Espressif SDK is subtle and it can also be fixed for Arduino without modifying the Espressif SDK by modifying the ESP8266WiFiSTAClass::begin method.

@tablatronix provides a trace of my version failing as well but the memory corruption could have occurred when running tzapu/WiFiManager and still have been there when later testing with https://github.com/kentaylor/WiFiManager/. I haven't had my version fail during testing and the fix I think was calling WiFi.disconnect(true) before calling WiFi.begin(new SSID, new password) as shown at kentaylor/WiFiManager@3bb5fad#diff-bfe0a2d15de63f0ead6d59ff54dd518eR241 .

I found that calling Wifi.begin(existing SSID, existing password) never failed but calling WiFi.begin(new SSID, new password) or WiFi.begin() will occasionally cause the ESP8266 to fail to connect to WiFi until rebooted and rarely put it into a state that requires reflashing to fix the corrupted memory. Usually rebooting was enough. It was never repeatable for me but the probability of failure did seem to depend on where it was up to in connecting to the access point.

Most people hard code Wifi.begin(SSID, password) into their sketch so are effectively calling Wifi.begin(existing SSID, existing password) which never causes a problem. In this case the Espressif SDK functions wifi_station_set_config, wifi_station_set_config_current and wifi_station_connect are not called. See

if(sta_config_equal(current_conf, conf)) {
. So the problem must be associated with calling these functions.

The ESP8266 will autoconnect to WiFi at startup using the stored SSID and password. Currently if Wifi.begin(new SSID, new password) is called while already connecting to WiFi then wifi_station_set_config or wifi_station_set_config_current will be called at an indeterminate time in the WiFi connection sequence. Wifi.begin(new SSID, new password) and WiFi.begin() call the Espressif SDK function wifi_station_connect() when it is already connecting. Mostly it doesn't matter but it seems that if wifi_station_connect() is called when it is at a particular point in the WiFi connection process it causes problems.

Therefore the solution for Arduino is to call wifi_station_disconnect() prior to calling wifi_station_set_config or wifi_station_set_config_current and to not call wifi_station_connect() when it is already connecting to WiFi.

The problem is occurring because wifi_station_connect() is being called when it is not required and can be fixed in Arduino by only calling wifi_station_connect() when required. However, the Espressif SDK should also be modified so that calling wifi_station_connect() is never harmful even if called when not required.

@tablatronix
Copy link
Contributor Author

Another issue I referenced above had succesfully workaround by setting persistant to false avoiding the saves i am assuming.

@kentaylor
Copy link

@tablatronix Yes, if persistent is false wifi_station_set_config_current is called which doesn't write data to flash according to @igrr in #1054. If persistent is true wifi_station_set_config is called which does write data to flash. So it seems setting persistent to false is likely to avoid corrupting the flash.

But WiFi also fails sometimes for me when calling WiFi.begin() and persistent is irrelevant in that case. WiFi.begin() calls the Espressif SDK function wifi_station_connect() see

and wifi_station_dhcpc_start(). I think calling these functions when it is already automatically connecting to WiFi can be harmful.

@igrr
Copy link
Member

igrr commented May 10, 2016

Okay, the issue in SDK code has been found and will be fixed in the next release. In the meantime I will push a workaround which prevents buffer overrun.

@overtone1000
Copy link
Contributor

I encountered this bug using version 2.3.0 of the esp8266 core with the Eclipse Arduino Plugin on an ESP-12 module (via Adafruit). I could not reproduce it on a Sparkfun Thing Dev. I noted the error when calling the ESP8266WiFiMulti::run() function, and the debug output was exactly as previously described. I was also able to elicit the error by calling the WiFi::setOutputPower() method.

I implemented the WiFi.persistent(false) workaround described by @tablatronix and @kentaylor, which resolved the issue. The sketch now runs on both devices, and all WiFi behavior is normal in both station and access point modes. Thanks for your help!

@kentaylor
Copy link

This sketch fixed my bricked devices. It writes NULL to the whole flash including wiping itself from flash, so it can only run once after uploading. I wiped the whole of flash because I didn't know where the WiFi credentials are stored. If I knew that I could read out that area and look at the nature of the corruption.

I'm confused where @tablatronix says "so the corruption has nothing to do with wifi credentials flash probably". It must be corrupted flash because it persists over rebooting and uploading new sketches. I understood the effect of the buffer overrun to be writing stuff to flash from memory that is beyond the intended memory buffer. This can happen when you rely on identifying the end of a string by a NULL character and that NULL character has been overwritten. I guess the end of the SSID string and password string in flash is identified by a NULL character and the absence of that character means extra stuff is read in when loading the WiFi credentials from flash. When we overwrite the whole flash with NULLs we put that terminating NULL character back.

This post and the previous contains a lot of speculation so I will not be surprised if someone points out where they are wrong.

@tablatronix
Copy link
Contributor Author

tablatronix commented Dec 9, 2016

You said the wifi credentials delete function, i did not realize there was a full flash erase sketch. Either way credentials cant fix the problem only full erase.

@kentaylor
Copy link

kentaylor commented Dec 13, 2016

@engrziarehman you might be interested in this from the Espressif SDK 1.4

Resolved Issues(Bugs below are eligible for Bug Bounty Program):
...
The ESP8266 maybe reset if connected to a special router.

It isn't used by Arduino yet.

@engrziarehman
Copy link

Thank you for your reply! I had been thinking that this version of sdk is incorporated in arduino, it shows 1.5.4_16_05_20. If it is not, then yes! it may be!

@tablatronix
Copy link
Contributor Author

@igrr I noticed this workaround is still in master , was this not fixed in SDK yet?

@tablatronix
Copy link
Contributor Author

@igrr bump
FYI, this workaround is still in code in RC

            // workaround for #1997: make sure the value of ap_number is updated and written to flash
            // to be removed after SDK update
            wifi_station_ap_number_set(2);
            wifi_station_ap_number_set(1);

@shivamkeshri
Copy link

If you are getting fatal error exception like this:

Exception (3):
epc1=0x401003e9 epc2=0x00000000 epc3=0x00000000 excvaddr=0x4000cbd9 depc=0x00000000
In infinite loop in your serial monitor of arduino IDE .

then goto this link download the software and follow the procedure and erase the flash memory to solve the error.

This does not solve fatal error that occurs due to your program but in case your device goes in such condition that it can’t be able to access program memory then it will work and try atleast one time to solve the problem.

This is the procedure to hard reset the nodemcu

( https://www.youtube.com/watch?v=MHrm7axsImI&t=146s )

Step :
Install latest python version in you pc.(https://www.python.org/downloads )
Open cmd prompt as administrator .
Go to c/program files or program files (x86)->python (your version)->Script. For this type (cd c/program files (x86)/python(your version)/Script) then press enter .
Now type (pip install esptool).
Now download ESPlorer ( https://esp8266.ru/esplorer/ ) version(Download ESPlorer.zip (v 0.2.0-rc6)) and extract the file and open executable jar file .
Now goto nodemcu firmware site (https://github.com/nodemcu/nodemcu-firmware/releases ) and from download file (nodemcu_float_0.9.6-dev_20150704.bin ) and copy this file into the c/program files (x86)/python(your version)/Script folder .
Now in cmd prompt just type.
esptool.py --port COM(your port no.) --baud 115200 erase_flash
And press enter.

Note : you can see your port no. into the device manager .

@rippe
Copy link

rippe commented Jan 5, 2018

@igrr , I saw a comment you made more than a year ago about (!!!!) about ICACHE_RAM_ATTR. I must say, I don't understan what to do with it or where to place it :-(

I need som assistance for sure :-)

My code below is quite a dirty one, and beside the crash problem I would like to put as muck of the web server code in the setup to aviod lagging the processor. The connection to the Wemos is made one time upon a start/restart.

If I didn't give all the needed information, don't hestita to ask.

`// Including the ESP8266 WiFi library
#include "HLW8012.h"
#include <ESP8266WiFi.h>
//#include <OneWire.h>
//#include <DallasTemperature.h>

#include <TimeLib.h>
#include <SimpleTimer.h>

// Replace with your network details
const char* ssid = "xxxxx";
const char* password = "xxxxx";

// Web Server on port 80
WiFiServer server(80);

//OLED
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <SFE_MicroOLED.h> // Include the SFE_MicroOLED library
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16
#define PIN_RESET 255 //
#define DC_JUMPER 0 // I2C Addres: 0 - 0x3C, 1 - 0x3D
int R[3] = {0};
int xPos[3] ={34,34,34};
int tempXpos, levelXpos, DiagXpos;

MicroOLED oled(PIN_RESET, DC_JUMPER); // I2C Example

const int interruptPin = D7; // the number of the interrupt pin
volatile int pwmValue = 0;

volatile unsigned long startTime = 0; // timer for interruptpin
volatile unsigned long stopTime = 0; // timer for interruptpin
volatile unsigned long connectionTime = 0; // timer for the overall signal

int countISR = 0;
volatile unsigned int msTime[3] = {22,33,44};

bool startUp = false;
bool fallingEdge = false;

unsigned int temperature; // 22 - 88 ms
unsigned int level; // 22 - 88 ms
unsigned int diagnostic; // 22 - 88 ms
int level_mm; // 20 - 80 mm
unsigned int periodTimeRecieved = 0;
unsigned int periodTime = 110;

//int LEDone = 31;
//int LEDtwo = 33;

/float levelRange[15] = {31.65,33.81,35.97,38.14,40.30,42.46,44.62,46.78,48.95,51.11,53.27,55.43,57.59,59.76}; //Level in [ms]
float levelRange[7] = {31.65,35.99,40.33,44.67,49.01,53.35,59.69};
float levelRange_mm[7] = {20,30,40,50,60,70,80};

WiFiClient client = server.available();

// only runs once on boot
void setup() {
// Initializing serial port for debugging purposes
Serial.begin(115200);
delay(10);

pinMode(interruptPin, INPUT);
attachInterrupt(digitalPinToInterrupt(interruptPin), Rising, RISING);

// Connecting to WiFi network
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);

//WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");

// Starting the web server
server.begin();
Serial.println("Web server running. Waiting for the ESP IP...");
delay(10000);

// Printing the ESP IP address
Serial.println(WiFi.localIP());

if (client)
{
Serial.println("connected");
}
else
{
Serial.println("connection failed");
}

//OLED
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
oled.begin(); // Initialize the OLED
// init done
//oled.display();
//delay(2000);
// Clear the buffer.
oled.clear(PAGE);
oled.clear(ALL);
// text display tests
oled.setFontType(1);
//oled.setTextColor(WHITE);
oled.setCursor(16,0);
oled.println("Oil");
oled.display();
delay(300);
oled.setCursor(8,18);
oled.print("Level");
oled.display();
delay(300);
oled.setCursor(8,36);
oled.print("Check");
oled.display();
delay(3000);
oled.clear(PAGE);
oled.clear(ALL);

}

// runs over and over again
void loop() {
// Listenning for new clients
//WiFiClient client = server.available();

//if (client) {
//Serial.println("New client");
// bolean to locate when the http request ends
boolean blank_line = true;
//while (client.connected()) {
if (client.available()) {
char c = client.read();

    if (c == '\n' && blank_line) {
        //getValues();
        client.println("HTTP/1.1 200 OK");
        client.println("Content-Type: text/html");
        client.println("Connection: close");
        client.println();
        // your actual web page that displays temperature
        client.println("<!DOCTYPE HTML>");
        client.println("<html>");
        client.println("<meta http-equiv=&#34refresh&#34 content=&#3415&#34>");
        client.println("<head></head><body><h1>Oil temp & level check</h1><h3>Temperature: ");
        client.println(temperature);
        //Serial.print("Temp: ");
        //Serial.println(temperature);
        client.println("&#8451;</h3><h3>Level: ");
        client.println(level_mm);
        //Serial.print("Level:         ");
        //Serial.print(level_mm);
        client.println("mm</h3><h3>Diagnostic: ");
        client.println(diagnostic);
        //Serial.print("Diagnostic:                ");
        //Serial.print(diagnostic);
        client.println("</h3></body></html>");  
        //break;
    }
    if (c == '\n') {
      // when starts reading a new line
      blank_line = true;
    }
    else if (c != '\r') {
      // when finds a character on the current line
      blank_line = false;
    }
  }
//}  
// closing the client connection
//delay(1);
//client.stop();
//Serial.println("Client disconnected.");

//}

while(!startUp) {
ESP.wdtFeed();
//Serial.println("Startup");
pwmValue = (stopTime - startTime) / 1000;   //1000 före felsökning
/*Serial.print("stopTime ");
Serial.print(stopTime);
Serial.print("     startTime ");
Serial.print(startTime);
Serial.print("   /1000000     =     ");
Serial.println(pwmValue);*/

delay(100);
//Serial.println(pwmValue);

if(pwmValue >= 10 && pwmValue <= 150) {
  //Serial.println("I if pwmValue");
  ESP.wdtFeed();
  connectionTime = millis();
  while((millis() - connectionTime) <= 500 && !digitalRead(interruptPin)) {
  //Serial.println("I while() millis()");
  ESP.wdtFeed();
    if(millis() - connectionTime >= 500) {
      ESP.wdtFeed();
      startUp = true;
      fallingEdge = false;
      Serial.println("Start OK");
      break;
    }        
  } 
} 

}

/*

  • Decode the diffrent phases in signal and

  • store measured value.

  • When three values are received the parse function is called.
    */
    if(fallingEdge) {

    fallingEdge = false;
    msTime[countISR] = (stopTime - startTime) / 1000;
    //Serial.println(msTime[countISR]);
    countISR++;

    if(countISR == 3) {

    ParseTime();
    countISR = 0;
    //SetLED(level_mm);
    if((R[0] != temperature) || (R[1] != level_mm) || (R[2] != diagnostic)) ShowValuesOnDisplay();
    //Print(); // debug function
    connectionTime = millis(); //
    }
    }

/*

  • The length of the overall signal is 1000 [ms] (+- 10%)
  • If no information is received in the overall signal time,
  • this function sets the program in start mode.
    /
    if((millis() - connectionTime) > 1300 ) {
    Serial.println("no connection");
    msTime[3] = {0};
    startUp = false;
    }
    }
    /
  • Detect rising edge of PWM signal and sets interrupt mode to trigger on falling edge
    */
    void Rising()
    {
    //Serial.println("Rising edge!");
    startTime = micros();
    //Serial.print(startTime);
    //Serial.print(" ");
    if(countISR == 1)
    {
    periodTimeRecieved = millis();
    }
    if(countISR == 2)
    {
    periodTimeRecieved = millis() - periodTimeRecieved;
    //Print();
    }
    attachInterrupt(digitalPinToInterrupt(interruptPin), Falling, FALLING);
    }

/*

  • Detect rising edge of PWM signal and sets interrupt mode to trigger on rising edge
    */
    void Falling()
    {
    //Serial.println("Falling edge!");
    //Serial.print(" ");
    //Serial.println(countISR);
    stopTime = micros();
    //Serial.println(stopTime);
    //Serial.print(" ");
    //Serial.println((stopTime - startTime) / 1000);
    //Print();
    fallingEdge = true;
    attachInterrupt(digitalPinToInterrupt(interruptPin), Rising, RISING);
    }

/*

  • Parse received information to right variable and

  • detect if information are in right range
    */
    void ParseTime()
    {
    for(int i=0; i < 2; i++) {

    if(msTime[i] <= 22 || msTime[i] > 150) {
    msTime[i] = NULL;
    }
    }

temperature = msTime[0];
level_mm = 74/32*((msTime[1]-23))periodTimeRecieved/periodTime;
if(level_mm >500) level_mm = 0;
diagnostic = msTime[2];
//Serial.println(msTime[1]);
//Serial.println(level_mm);
//level_mm = 74/32
((level_mm-23)*(periodTimeRecieved/110));
//level_mm = FmultiMap(level_mm, levelRange, levelRange_mm,7);
Serial.print(periodTimeRecieved);
Print();
}

/*

  • Debug print
    /
    void Print()
    {
    Serial.println("");
    Serial.println(millis());
    Serial.print("Temperature: ");
    Serial.println(temperature); //temperature före ändringen
    Serial.print("Level: ");
    Serial.println(level_mm); //level_mm före ändringen
    //Serial.print(2.3125 * (level-23)); // Level[mm]=74mm/32ms
    (T2[ms]-23ms*T[ms]/110ms)
    //Serial.println(" mm");
    Serial.print("Diagnostic: ");
    Serial.println(diagnostic); //diagnostic före ändringen
    Serial.println("");
    }

void ShowValuesOnDisplay()
{
//tempXpos, levelXpos, DiagXpos
/Serial.print("ShowValuesOnDisplay");
Serial.print(" ");
Serial.print(temperature);
Serial.print(" ");
Serial.print(level_mm);
Serial.print(" ");
Serial.println(diagnostic);
//if(R[0] != T[0] || R[1] != T[1] || R[2] != T[2])
//{
/
//Serial.println("Update values on screen");
//
/char buffer[7];
itoa(temperature,buffer,10);
/
String measString[0] = String(temperature);
measString[1] = String(level_mm);
measString[2] = String(diagnostic);
//Serial.println(thisString.length());
int q;
String oledSpace[3];
for(q; q < 3;q++)
{
ESP.wdtFeed();
/if(R[q] < 100 && msTime[q] > 99) //If previous value was 2 digit and the new is 3 digit, then (move cursor back 6 points) and erase the first char
{
xPos[q] = 34; // ReWriteScreen(); //If previous value was 3 digits and the new one is not, clear
oledSpace[q] = "";
}
else if(R[q] > 99 && msTime[q] < 100)
{
xPos[q] = 34;
oledSpace[q] = " ";
}
/

  if(measString[q].length() < 10) oledSpace[q] = "  ";
  if(measString[q].length() < 100) oledSpace[q] = " ";
  if(measString[q].length() < 1000) oledSpace[q] = "";
  
  //}
}

/*{
  oled.clear(PAGE);
  oled.clear(ALL);
}*/
R[0] = temperature;
R[1] = level_mm;
R[2] = diagnostic;
oled.setCursor(xPos[0],0);
oled.print(oledSpace[0]);
oled.print(temperature);
/*if(level_mm > 99) 
{
  level_mmXpos = 35;
  ReWriteScreen();
}
else
{
  level_mmXpos = 40;
}*/
//if(R[1] > 99 && level_mm < 99)
//{
  oled.setCursor(xPos[1],18);
  oled.print(oledSpace[0]);
  //oled.print(" ");
//}
//else
//{
  //oled.setCursor(40,18);
//}
oled.print(level_mm);
oled.setCursor(xPos[2],36);
oled.print(oledSpace[0]);
oled.print(diagnostic);
oled.display();
Print();

//}
/oled.clear(PAGE);
oled.clear(ALL);
// text display tests
oled.setFontType(1);
//oled.setTextColor(WHITE);
oled.setCursor(0,0);
oled.println("Temp ");
oled.print(T[0]);
oled.setCursor(0,18);
oled.println("Lev ");
oled.print(T[1]);
oled.setCursor(0,36);
oled.println("Diag ");
oled.print(T[2]);
oled.display();
/
}

void ReWriteScreen()
{
//Put up the headlines Tmp, Lev and Dia on the display
oled.clear(PAGE);
oled.clear(ALL);
oled.setFontType(1);
//oled.setTextColor(WHITE);
oled.setCursor(0,0);
oled.println("Tmp ");
//oled.print(T[0]);
oled.setCursor(0,18);
oled.println("Lev ");
//oled.print(T[1]);
oled.setCursor(0,36);
oled.println("Dia ");
//oled.print(T[2]);
oled.display();
}
`
Best regards Richard
P.S. Sorry for the messy code... it splits up when finding a new " ' " in the code... :-(

@rippe
Copy link

rippe commented Jan 5, 2018

Hi,

I just read somewhere to test the xtensa-lx106-elf-addr2line -pfia -e path/to/build/directory/your-sketch.elf 0x4000bf1b. The result is strangely enough:
0x4000bf1b: ?? ??:0

I must be doing this wrong...?
Br, Richard

@devyte
Copy link
Collaborator

devyte commented Jan 5, 2018

@rippe void Rising() => ICACHE_RAM_ATTR void Rising()
This is documented in the docs.
Please refer such questions to a community forum.

@rippe
Copy link

rippe commented Jan 5, 2018

@devyte, ooops, I'm so sorry... Don't use to post questions at all. Will do this in the future.
Thank you for the answer anyway (much more basic than I thought and what I could google).

Best regards Richard

@JasXSL
Copy link

JasXSL commented Jun 24, 2018

I'm still getting this problem after wiping settings through resetSettings or using arduino IDE to erase all flash:

*WM: WiFi save
*WM: Sent wifi save page
*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Connection result: 
*WM: 3

Exception (3):
epc1=0x4010010e epc2=0x00000000 epc3=0x00000000 excvaddr=0x40007221 depc=0x00000000

ctx: cont 
sp: 3fff1e00 end: 3fff2120 offset: 01a0

Decoding 13 results
0x40211601: Print::write(char const*) at C:\Users\username\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\cores\esp8266/Print.cpp line 87
0x4010020c: _umm_free at C:\Users\username\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\cores\esp8266\umm_malloc/umm_malloc.c line 1291
0x40100690: free at C:\Users\username\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\cores\esp8266\umm_malloc/umm_malloc.c line 1739
0x40211d18: String::~String() at C:\Users\username\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\cores\esp8266/WString.cpp line 545
0x40207224: onWifiPortalStart(WiFiManager*) at E:\_ARDUINO_\_INU DEVICES_\Temperature/Temperature.ino line 19
0x4020b971: Inu::init(String, String (*)(WiFiManager*)) at C:\Users\username\Documents\Arduino\libraries\inuLib/inuLib.cpp line 297
0x40209d20: dummyString(WiFiManager*) at C:\Users\username\Documents\Arduino\libraries\inuLib/inuLib.cpp line 297
0x40213cb0: std::_Function_base::_Base_manager ::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) at c:\users\username\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2/functional line 1934
0x40213c94: std::_Function_handler ::_M_invoke(std::_Any_data const&, WiFiManager*) at c:\users\username\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2/functional line 2054
0x40211e3e: String::String(char const*) at C:\Users\username\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\cores\esp8266/WString.cpp line 545
0x40207376: setup at E:\_ARDUINO_\_INU DEVICES_\Temperature/Temperature.ino line 38
0x40212a3c: loop_wrapper at C:\Users\username\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\cores\esp8266/core_esp8266_main.cpp line 57
0x40100710: cont_norm at C:\Users\username\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\cores\esp8266/cont.S line 109

I don't get it when I update existing credentials though.

@dontsovcmc
Copy link
Contributor

dontsovcmc commented Jul 12, 2018

I got exception when connecting to Wi-Fi that turned off =(

 ets Jan  8 2013,rst cause:1, boot mode:(3,0)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v614f7c32
~ld
000:00:00:00:056  NOTICE    (ESP) : Booted
1 000:00:00:00:059  NOTICE    (I2C) : mode=1
3 1 D3 B 0 0 0 0 0 0 0 0 0 0 000:00:00:00:070  NOTICE    (I2C) : data received
000:00:00:00:070  NOTICE    (WIF) : key= email=, hostname=blynk-cloud.com
000:00:00:00:071  NOTICE    (WIF) : value0_start=0.00, impules0_start=0, factor=10
000:00:00:00:077  NOTICE    (WIF) : value1_start=0.00, impules1_start=0
000:00:00:00:084  NOTICE    (ESP) : new impulses=0 0
000:00:00:00:088  NOTICE    (ESP) : new values=0.00 0.00
000:00:00:00:093  NOTICE    (ESP) : I2C-begined: mode SETUP
000:00:00:00:099  NOTICE    (WIF) : User requested captive portal

Exception (3):
epc1=0x401003e9 epc2=0x00000000 epc3=0x00000000 excvaddr=0x4006e149 depc=0x00000000

ctx: cont
sp: 3fff0600 end: 3fff0b60 offset: 01a0

0x40213724: __ssputs_r at /Users/igrokhotkov/e/newlib-xtensa/xtensa-lx106-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/nano-vfprintf.c line 180
0x4020fae0: _printf_i at /Users/igrokhotkov/e/newlib-xtensa/xtensa-lx106-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/nano-vfprintf_i.c line 241
0x401004f4: calloc at ?? line ?
0x40106b98: pvPortZalloc at ?? line ?
0x4010577c: spi_flash_read at ?? line ?
0x40235d55: wifi_param_save_protect_with_check at ?? line ?
0x401063f1: __wrap_spi_flash_read at ?? line ?
0x40235e3f: system_param_save_with_protect at ?? line ?
0x40235e22: system_param_save_with_protect at ?? line ?
0x4023630c: wifi_station_ap_number_set at ?? line ?
0x401063f1: __wrap_spi_flash_read at ?? line ?
0x40236526: wifi_station_ap_number_set at ?? line ?
0x402365d6: wifi_station_ap_number_set at ?? line ?
0x4024d530: sleep_reset_analog_rtcreg_8266 at ?? line ?
0x402365a5: wifi_station_ap_number_set at ?? line ?
0x4023660c: wifi_station_set_config at ?? line ?
0x402068e0: ESP8266WiFiSTAClass::disconnect(bool) at ?? line ?
0x40213700: __any_on at /Users/igrokhotkov/e/newlib-xtensa/xtensa-lx106-elf/newlib/libc/stdlib/../../../.././newlib/libc/stdlib/mprec.c line 1039
0x4020fae0: _printf_i at /Users/igrokhotkov/e/newlib-xtensa/xtensa-lx106-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/nano-vfprintf_i.c line 241
0x4020eab8: Print::write(unsigned char const*, unsigned int) at ?? line ?
0x40209f39: Print::write(char const*) at ?? line ?
0x40209f4c: Print::print(char const*) at ?? line ?
0x4020562e: setup_ap(Settings&, SlaveData const&, float const&, float const&) at ?? line ?
0x40209f39: Print::write(char const*) at ?? line ?
0x4020eab8: Print::write(unsigned char const*, unsigned int) at ?? line ?
0x40209f39: Print::write(char const*) at ?? line ?
0x4020a075: Print::printNumber(unsigned long, unsigned char) at ?? line ?
0x40210248: sprintf at /Users/igrokhotkov/e/newlib-xtensa/xtensa-lx106-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/sprintf.c line 646
0x4020eab8: Print::write(unsigned char const*, unsigned int) at ?? line ?
0x4020eab8: Print::write(unsigned char const*, unsigned int) at ?? line ?
0x4020a0d3: Print::print(long, int) at ?? line ?
0x4020eab8: Print::write(unsigned char const*, unsigned int) at ?? line ?
0x40209f39: Print::write(char const*) at ?? line ?
0x40209f4c: Print::print(char const*) at ?? line ?
0x40202ebc: calculate_values(Settings&, SlaveData&, float*, float*) at ?? line ?
0x40205384: MasterI2C::getSlaveData(SlaveData&) at ?? line ?
0x40240000: etharp_output at netif/etharp.c line 950 (discriminator 1)
0x40209bdc: EspClass::wdtDisable() at ?? line ?
0x40204928: loop at ?? line ?
0x4020b048: loop_wrapper() at core_esp8266_main.cpp line ?
0x40100700: cont_norm at cont.S.o line ?

PLATFORM: Espressif 8266 > Espressif Generic ESP8266 ESP-01 1M
SYSTEM: ESP8266 80MHz 80KB RAM (1MB Flash)
WifiManager 0.12

@seinecle
Copy link

seinecle commented Nov 7, 2018

For those still struggling with this issue in 2018, this did the trick:

WiFi.persistent(false);
WiFi.disconnect(true);
WiFi.begin(ssid, password);

source: http://blog.flynnmetrics.com/uncategorized/esp8266-exception-3/

@ta4ukoma
Copy link

ta4ukoma commented Aug 6, 2019

For those still struggling with this issue in 2018, this did the trick:

WiFi.persistent(false);
WiFi.disconnect(true);
WiFi.begin(ssid, password);

source: http://blog.flynnmetrics.com/uncategorized/esp8266-exception-3/

THX! thank you so much! That's working!

@tablatronix
Copy link
Contributor Author

Wow this is old, Probably need to look at this again

@dahlheim2
Copy link

old yes, but helped me! Thanks, seinecle!

@dzid26
Copy link

dzid26 commented Oct 8, 2019

WiFi.persistent(false);
WiFi.disconnect(true);
WiFi.begin(ssid, password);
But that means no WiFi manager :/

It is strange. I have bare ESP8266MOD and ESP-12F (Huzzah dev board) and first one works and the other one doesn't. And it worked before (with less code I had before).

Mode: AP
PHY mode: N
Channel: 1
AP id: 0
Status: 255
Auto connect: 1
SSID (0):
Passphrase (0):
BSSID set: 0
We haven't got any access point credentials, so get them now
failed to connect, finishing setup anyway

Exception (3):
epc1=0x40216d98 epc2=0x00000000 epc3=0x00000000 excvaddr=0x401f832d depc=0x00000000

stack>>>

EDIT:

@d-a-v
Copy link
Collaborator

d-a-v commented Oct 8, 2019

@dzid26 can you try with latest git version of this core ?

@4C3T
Copy link

4C3T commented Jan 9, 2020

I had this error, among others. I succeeded with installing the older version of the ESP8266 board manager, 2.1.0 to be exact, and also chose a lower baud rate to flash it and it worked flawlessly after that.
I'm not sure if this might help anyone else (Or if it's mentioned above. I read a few pages until I realized it actually said to use 9600 Baud on the back of the module, which the newest version couldn't deliver for some reason), but it did work finally.
The sketch I'm using is a sample code for AJAX. It tossed out heaps of errors, but now - Nothing.

@kdkwarhead
Copy link

I got the same problem with my Di Mini Pro.
I Tried with lua firmware from https://nodemcu-build.com before audrino IDE. Didn’t like it much so I tried Arduino IDE instead. It worked fine until I tried “WiFi.begin()”. Total crash!

FIX:
In Arduino IDE:
Change tools/Erase flash to "All flash content" once
flash a sketch.
And then set it back to "only sketch"

I did it with upload speed 57600 but it should work with other speeds as well.
It was some leftover data from old firmware in my case.
Works perfectly now :)

ThomasDevoogdt added a commit to ThomasDevoogdt/SmartHue that referenced this issue Oct 18, 2020
ThomasDevoogdt added a commit to ThomasDevoogdt/SmartHue that referenced this issue Oct 18, 2020
@svefro
Copy link

svefro commented Nov 17, 2022

I have run in to a similar issue with most of my esp8266 devices in my house.
i get random reboots, sometimes 3 minutes sometimes 1 day uptime.
Fatal exception:4 flag:3 (Software Watchdog) epc1:0x4025c1ca epc2:0x00000000 epc3:0x00000000 excvaddr:0x00000000 depc:0x00000000

stack trace mostly points to pm_send_nullfunc, somthing with dhcp, wifi or dns.
nothing in my code. i save stack trace in eeprom on some devices and read it back after boot.

if i do a erase_flash with esptool.exe the problem seams to goes away. (i have done this with a few devices and they seem to be ok)

But i have more than 70-80 devices in my house. They control everything. heatpumps, water heater, floor heating. ventilation, water valves and more.
They all run the same firmware (2 versions 1Mb lite version and 2Mb full that contain all features) that i have developed since from about 2016-2017.

I recently changed my wifi to Unifi and with that i changed my ssid and password. That is when it all started.
At the same time did some changes to the firmware so i did not understand that it was the wifi that caused the issue.
i have been debugging ever since.

I have tried implementing ota firmware upload with kentaylor s sketch (https://github.com/kentaylor/EraseEsp8266Flash)
but i have had no luck getting it to run after flash is erased :p

Has there been any progress on this topic since it was started?
I would like to be able to fix the corrupt flash without having to connect to every device and do a errace_flash+reload firmware.

i'm currently using espressif8266@4.0.1 arduino core v3.0.2

checkFlashCRC and checkFlashConfig returns true;

i see in ESP.cpp that there is a function called rtcUserMemoryWrite.
can i use that to clear the system data? is wifi details stored here?
|<------system data (256 bytes)------->|<-----------------user data (512 bytes)--------------->|

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests