-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Rebooting when joining WiFi #431
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
Comments
Figured it out.... This used to work just fine...
but now it needs to be with the brackets around each part of the &&
|
OK that has not fixed it. Seems like some small code changes can cause this... then un cause it. |
Not really helping, but dispensing wisdom or so: my two top rules: I don't do Just too difficult to remember: And as far as I see, I use this in wifi-client-mode in my code without any problem. |
Have similar issue with specific router (Mikrotik 951). But not with other (Allied Telesis AT-WA1104G). Got irregular resets by wdt. Sometimes the hardware "reset" solves the issue but not always BUT! When I switch my program to "more verbose" mode (not recompile, just invoke CLI command for change "logging" flag) and I have no resets. There are a lot of "delay(...)" inside main loop so possibly no room for locking PS: I use 1.6.5 git build from 2015-05-28 |
I suspect that there is something going on..... i just had several reboots... and then it worked all of a sudden. This is on an ESP12. the flash previous to this failed, then i changed it from 512K to 4M and it worked. so it is quite an intermittent problem...
|
I am also having an issue similar to you. This is what I add that causes the issue:
I also tried this code without feeding the watchdog and with removing the delays:
Still resets.
I'm not sure if its my code or if it is an SDK issue. |
Just fishing in the dark, but could you try a void *p = malloc(5000); somewhere in your loop? The getfreeheap() function might report misleading values... |
…yboard can use the shortcut. Fixes esp8266#431 and https://code.google.com/p/arduino/issues/detail?id=76
Thanks for the suggestion.
But it still rebooted without giving me a Heap full...
|
This is what the Debugger gives me:
This error is killing me. |
I try code below called every minute in main loop: // === TEST ===
uint16_t a0, a1, a2;
void *_tmp;
a0 = ESP.getFreeHeap();
Serial.print("Heap-test : "); Serial.print(a0); Serial.print("/");
_tmp = malloc(5000);
if (!_tmp) {
Serial.print("FULL/");
} else {
a1 = ESP.getFreeHeap();
free(_tmp);
Serial.print(a1); Serial.print("/");
}
a2 = ESP.getFreeHeap();
Serial.println(a2);
// ==== and got |
Fatal exception (28): epc1=0x4000debe, epc2=0x00000000, epc3=0x00000000, memcmp function was passed a zero for the first argument and generated an |
Problem with getFreeHeap() is, that it gives the total sum of all free heap blocks. So if you have 20 free blocks of 150 bytes in size, you get 3000 bytes free heap. But malloc(200) will fail because no block that size is free. Basically the function is useless in its current state. And that's why I work on a heap walk utility. Current state: fail. :-/ |
As an update about heap: The same error was in ESP8255WiFiMulti while UPD: not reproduced on clean sketch... Will try debug PubsubCliend by Imroy... |
I think the error in @Commander13 's case is one of names[i] being a null pointer. Regarding the "No heap available, failed to malloc 0" messages, Espressif's malloc implementation erroneously prints this message when you try to allocate zero bytes. I will add a check to our malloc wrapper so that these messages are not generated. Regarding heap fragmentation, it is quite hard to achieve such an extreme case in practice without contrived scenarios. I did have the hooks on the allocator functions, pvPortMalloc/vPortFree, installed when I had just started developing this core. I wanted to check if dynamic allocation is useable at all. The hooks just logged the malloc/free calls to console, so I could analyze what was happening. Have to say, with most sketches from the standard Arduino example set which I was able to compile, fragmentation was a non-issue in the long run. While real apps are more complex than these examples, i still think a bit of though and planning goes a long way eliminating issues caused by heap fragmentation. That is not to deter @holgerlembke from the task of writing a heap walking utility, I just want to point out that it is highly unlikely that this is the root cause of the problem reported here :) |
I'm not entirely sure how to proceed with debugging. For me this only happens on an ESP-12 module, not any of the ESP-01 or a NODE-MCU board. Second, my script never gets to the loop. in fact it never gets to the line past joining the wifi, where it prints success.. before it reboots.. |
@sticilface, Just add Yet another test with resets. The same debug output few times:
|
ah... getting more info than when i tried that before.. here is what i get
|
What about minimal sketch? If no error on minimal sketch - try disable parts of your code and check void setup() {
Serial.begin(115200);
Serial.setDebugOutput(true);
WiFi.begin("hardcoded-ssid", "hardcoded-pass");
}
loop () {
;
} UPD: Hey! Did you use non-printable characters in password? AFAIR, some special symbols was reset my ESP until I change password. It may be '&' or '$'... |
You might also try setting wifi.mode() before calling wifi.begin. The SDK seems to hold on to your previous wifi.mode setting, and will try to connect to an AP, for instance, even if you don't call wifi.begin, based on your previous setting. Makes it difficult to debug, because it appears random. |
As per the suggestion of @igrr I checked to ensure that names[i] was not null:
Unfortunately it still reboots... |
I call wifi mode before, no change. my way round it, is to hold down reset for a few seconds.. then just blast reset about 5 times in a row.. then it usually works. im doubtful that it is a code issue on my end, as it was working just fine on this ESP for weeks. stopped working the moment i started using the IDE that makes one binary... and my code works fine on other ESPs so far. This is my test ESP though so it gets used the most! |
You could try to remove power, too. |
Try call WiFi.disconnect() first. Simple mode change does not work for me - ESP still connect via saved config. As "last chance" try full erase - write blank512k.bin from SDK via esptool. Is this ESP (test) on breadboard? May be electrical/pull-up issue? PS: I have build latest git version an hour ago and have no issues neither with wifi nor with malloc(0) |
adding WiFi.disconnect() makes no difference |
I have an constant reboots with git versions now. There is no reboots with older (from May 28, two binary file uploaded) build.
|
From the output, it looks like a null pointer exception inside the system libraries. But I need your .elf file to see where exactly. Could you please upload the elf output file which corresponds to the latest output? |
FYI, I've rebuild (via old 2-file version because it is "working") main loop with a lot of debug prints and it looks like wifi system reconnecting code does not update WDT. I can see a lot of "scandone/reconnecitng to ..." debug messages without returning back to loop(). For now I use Ticker as software watchdog: invoke Log for attached elf:
Hmmm... can't attach file... |
These stack traces are a real life saver! |
Ok. |
Yet another exception.
Possibly is enough to turn off wifi router only
Updated elf here: https://www.dropbox.com/s/rwi1nf7cznngey7/sens_v2.cpp.elf?dl=0 UPD:
|
The first one you posted is a WDT reset when code spins inside As for the second issue, it's a mysterious one, because 0x4010f280 is an address inside the bootloader. I'll try to reproduce that. |
As for me it is not good idea to use ... Replacing the second really was mysterious )) because I can't reproduce it too |
if you ever find out how to reproduce the second one reliably, please let me know — i'm sure i have seen such behaviour once or twice but wasn't able to isolate the issue. |
My module does this repeatedly. crashes when joining the wifi, and before the setup is completed. What usually fixes it (and this is what i've been doing all weekend) is to reboot the module, 5-6 times, by grounding rst, very quickly. this then i'd say 90% of the time. fixes it. Its weird, but i do to know what could cause this behaviour. |
@sticilface the change in 1c8b52b fixed this for @av1024, perhaps it will also help in your case? |
ah sorry, I shall give it a go! |
yield() also work ok. (I'm not sure why 100us delay needed while waiting for network i/o) ... possibly isolate second issue. this code prints error message and make crash after reboot: wifi_bad_cnt ++;
if (wifi_bad_cnt > WIFI_REBOOT_COUNT) {
Serial.println("Too many connect fails. Try reboot.");
Serial.flush();
WiFi.disconnect();
delay(1000);
ESP.reset();
}
Moreover for now the CLI command if (s == "reset") {
prn.println(F("\n\r\n\r *** RESET ***\n\r"));
delay(1000);
ESP.reset();
} |
Ah right. Looks like ESP.reset() doesn't work at all. Please use ESP.restart();
delay(5000); as a workaround until i push a fix for that issue. |
Ok. |
Guys, this is excellent work. I have this issue with PubSubClient and thought I was going mad. Adding the Serial.setDebugOutput(true); function gave me a nice clear indication it is not a fatal exception error for me. The problem for me only occurs now if MQTT has established a connection to the broker and subscribed to channels. If I take down my wireless router that the ESP8266 is connected to at this point I get the WDT reset condition. I am thinking it could be at that moment the class try's to do a keep alive type ping and bombs out. Please let me know anyone when a fix has been found. |
I had the same problem with pubsubclient and it seems to be solved with this version 1.6.4-835-g77d77e8 ( #324 ) |
Thanks Buddy I will try a fixed IP out now and then test the version you specify after with DHCP. Awesome, fingers crossed. Dans |
You are a hero, so Far I have a static IP assigned and no more WDT resets. Superb so it does seem DHCP related. Not only that I have a really good test router that links to my main wireless network and does several drop connections before it becomes solid. An Ideal unit to test for harsh network conditions, I will now look at my current build of the Arduino IDE which is 1.64, how do I find out donwload version of this eg g77d77e8 ? Massive thanks again Dans |
See issue #324 for details how to get Package for nightly build |
Very simple sketch leads to out of heap:
The log http://pastebin.com/M80fvhxs |
The original issue should be fixed in esp8266-1.6.5-804-g2d340c7. |
i was having a number issues with random wdt reboots while trying to connect to the AP - all at different times after startup. What's interesting is that it seems random - will connect fine for hours then stop working for hours (wdt reboots) then it starts working again. Problem seems greatly improved with the latest code (no reboots yet). BTW - what's the best way to get the arduino IDE to detect and reload any updates to the board manager .json code? Also, what tools do you use to debug crashes - gdb? Thnx,Reza |
I also had my ESP8266 (NodeMCU) rebooting on WiFi.begin() with the following messages: For me the issue was that I used WiFi.h (used in many old examples) instead of ESP8266WiFi.h. |
Using latest version 1.6.1-esp8266-1-1054-g3183c7c
I have a project that has been working fine (at least booting and joining wifi.) now it crashes upon trying to join wifi...
Not sure what to do next, to help? I should add that the same code compiled on a previous IDE works fine.
The text was updated successfully, but these errors were encountered: