Did you ever manage to render your ESP8266 to an infinite reset boot loop? I did! Not intentionally of course, but it happened: after loading a sketch with version 2.5.0-beta2 of the ESP8266 core for Arduino to the chip, the magical autoConnect method of the otherwise fantastic WiFiManager library started to threw an exception and triggered an instant reset of the device. (Why did I experiment with a beta? I desperately wanted HTTPS the easy way.) Unfortunately I called this method from the setup function, so the restart happened so quickly that I did not have a chance to load a fixed code onto the device.
Starting in Flash Mode
To successfully load a new code to the device I had to prevent the start of the currently loaded code when the device boots. Under normal circumstances the device starts in Boot Mode, but by pulling the GPIO0 pin to LOW, you can switch it to Flash Mode, which allows loading new code to it. If you are like me you have probably never did it before, because if you have a NodeMCU DevKit, the USB connection does that automatically while flashing (source). This is how I did it on my NodeMCU DevKit v0.9 with a single cable:
The next step is to delete everything you previously loaded or saved to the device. The Arduino IDE by default erases only the sketch, but in the Tools –> Erase Flash menu you can force it to erase All Flash Contents:
A good idea is to load a simple sketch, like Blink to your device with this setting, or one that calls the resetSettings function of the WiFiManager.
The following tools can be also useful:
- Erase Flash sketch by Ken Taylor: A short Arduino sketch to erase all of the flash memory in an ESP8266 device. This is useful for fixing corrupted memory.
- Esptool by Christian Klippel: A tool to create firmware files for the ESP8266 chip and flash the firmware to the chip over serial port.
- ESPlorer by 4refr0nt: An Integrated Development Environment (IDE) for ESP8266 developers, mainly useful for NodeMCU developers even to fix PANIC errors.
- Flash Download Tools by Espressif: The official flashing tool set to completely format or ease the flash memory.
- Termite by CompuPhase: A simple RS232 terminal to catch error messages like rst cause (official PDF) and boot mode.