-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Description
Basic Infos
- [y] This issue complies with the issue POLICY doc.
- [y] I have read the documentation at readthedocs and the issue is not addressed there.
- [August 2022, but I can't repair the device with the latest] I have tested that the issue is present in the current master branch (aka latest git).
- [ y] I have searched the issue tracker for a similar issue.
- [just serial debug message] If there is a stack dump, I have decoded it.
- [ y] I have filled out all fields below.
Platform
- Hardware: [ESP-12|ESP-01|ESP-07|ESP8285 device|other]
- Core Version: esp8266 core 3.0.2 [latest git hash or date]
- Development Env: [Arduino IDE|Platformio|Make|other]
- Operating System: [Windows|Ubuntu|MacOS]
Settings in IDE
- Module: [Generic ESP8266 Module|Wemos D1 mini r2|Nodemcu|other]
- Flash Mode: [DOUT|qio|dio|other]
- Flash Size: [4MB/1MB]
- lwip Variant: [v1.4|v2 Lower Memory|Higher Bandwidth]
- Reset Method: [ck|nodemcu]
- Flash Frequency: [40Mhz]
- CPU Frequency: [80Mhz|160MHz]
- Upload Using: [OTA|SERIAL]
- Upload Speed: [115200|other] (serial upload only)
Problem Description
Wemos D1 mini gets bricked aka unable to connect to WiFi after OTA upload with new SSID and password.
By bricked I really mean, no help to it, by loading new different sketch to it via serial still no WiFi connection, if I take new Wemos it runs the same sketch that bricked the other ESP no problem, it runs Wifi and MQTT fine, but I don't want to brick another one just to prove it.
I tried to Erase all Flash contents but it was no help to the bricked ESP.
I faced the same issue previously about 4 times over the last few years, that changing wifi credentials bricks the ESP after reboot, still, I was always able to recover by serial upload, but not this time.
Why is this an issue, and how should I avoid it, maybe with Wifi Manager Library, I've read about it but don't yet know how to use it. The goal is can change the wifi credentials on ESPs without messing things up, and using serial, why do we have OTA? And yes I do stage updates on test devices first.
How can I get bricked ESP back to life what should I upload to it as it is not dead it talks on serial, receives uploads normally, and runs blink sketch just fine, but not Wifi. The madness is that my Wifi MQTT code runs on new ESP but not on bricked one, is it possible to damage internal ESP wifi hardware with code?
The code below should prove the issue, my code has also MQTT which has nothing to do with the issue.
To prove it just follow these steps:
- upload sketch with first wifi credentials via serial
- change wifi credentials
- upload via OTA while still connected to the first wifi
- esp is unable to connect to wifi and shows the error below, by enabling serial debug Wifi
The issue may not emerge if the code running ESP OTA is on the latest core(aka updating over the latest core version), but that does not mean it is fine, as it still breaks old devices by updating via OTA.
Am I the first poking the thin ice on Arduino OTA, as I have not found much related to the issue on google.
Looking forward to finding the solution.
Cheers Matej
MCVE Sketch
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#ifndef STASSID
#define STASSID "first ssid" // than change to another ssid
#define STAPSK "first passwd" // than change to another passwd and do OTA
#endif
const char* ssid = STASSID;
const char* password = STAPSK;
void setup() {
Serial.begin(115200);
Serial.println("Booting");
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("Connection Failed! Rebooting...");
delay(5000);
ESP.restart();
}
ArduinoOTA.begin();
Serial.println("Ready");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
ArduinoOTA.handle();
}
Debug Messages
SDK:2.2.2-dev(38a443e)/Core:3.0.2=30002000/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-48-g7421258/BearSSL:6105635
Booting
fpm close 1
mode : sta(80:7d:3a:6e:4c:d4)
add if0
wifi evt: 8
wifi evt: 2
scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (2)
reconnect
wifi evt: 1
STA disconnect: 2
scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (2)
reconnect
wifi evt: 1
STA disconnect: 2
scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (2)
reconnect
wifi evt: 1
STA disconnect: 2
Connection Failed! Rebooting...