This quick article explains how to erase ESP8266 NodeMCU flash memory to restore it to its factory default settings. Using a tool named esptool.py, we'll be able to communicate. If the system keeps crashing and you can't upload new code, if you want to remove any firmware or configuration modifications you made, if you want to clean off old data, or for other reasons, you may find it useful to restore ESP8266 to its factory settings.
Installing esptool.py
We'll use esptool, which is a “Python-based, open-source, platform-independent utility to communicate with the ROM bootloader in Espressif chips,” to perform an ESP8266 factory reset.
You need Python 3.7 or newer installed on your system to install esptool. Make sure you choose the right package for your system before beginning the download and installation process at the following link:
Open a terminal window and use pip to install the latest stable release of the esptool.py package when Python 3 is installed.
pip install esptool
Note: That command may not work in some Python installations, and you will receive an error. If this is the case, try installing esptool.py using:
- pip3 install esptool
- python -m pip install esptool
- pip2 install esptool
Setuptools
is also a requirement that is not installed by default on all systems. You may use the following command to install it:
pip install setuptools
Read More: How to Flash NodeMCU Firmware on ESP8266 using Windows
You should be able to run esptool.py with the command esptool
after installation since it will be placed in the default Python executables directory. Run the following command from your terminal window:
python -m esptool
If it was installed properly, it should display a similar message (regardless of your operating system):
Erasing ESP8266 NodeMCU Flash Memory
Follow the next steps to erase ESP8266 NodeMCU flash:
- Connect the ESP8266 board to your computer.
- Open a terminal window on your computer.
- Hold the ESP8266 BOOT/FLASH button.
- Copy the following command to your terminal window and press Enter (continue holding the FLASH/BOOT button).
Read More: Build an ESP8266 Web Server: The Complete Guide
python -m esptool --chip esp8266 erase_flash
- You may release the “BOOT/FLASH” button after the “Erasing” process has begun. The ESP8266 flash memory will be deleted after a few seconds.
Note: If you keep seeing new dots after the “Connecting…” message, your ESP8266 board is not in flashing mode. To make sure that your ESP8266 enters flashing mode and properly completes the erasing process, you need to repeat all of the previously stated steps and hold the “BOOT/FLASH” button.