Restoring the AT firmware on the ESP8266

Most of the time I am using Wemos D1 mini development boards in combination with the Arduino IDE to make my own firmware to run directly on the ESP8266 chip. But I also have some bare ESP-01 and ESP-12 modules lying around, and recently I came up with the plan to use one of them.

The specific project requires very well controlled timing of an ADC, for which I will use a regular ATmega328P-based Arduino board. In this project the ESP8266 will only be used to transmit the data over WiFi. Neither my ESP-01, not my ESP-12 still have the original AT firmware, since I have been experimenting with various other firmwares.

This is where the challenge starts, since my plan required restoring my ESP-12 to the AT firmware and use a library like ESP8266wifi or WiFiEsp. I realize that I have been struggling with different firmwares before, hence this post to give a short review and to keep some notes for my own future reference.

Module form factor

The ESP8266 microchip comes on various development boards that include an USB interface, such as the Wemos D1 Mini and the NodeMCU board, but also as bare modules such as the ESP-01, 02, etc. This page on the ESP8266 wiki has an overview of all modules and this page has comparison of some of the raw modules with some of the development boards.

ESP-01 module:

ESP-12 module:

Flash memory capacity

Besides the number of GPIO pins that is exposed by each of the modules, another important feature is their flash memory capacity. The AI-Thinker website has a module list table that includes this. The ESP-01 module comes with 512kB flash (old modules) or 1MB (now more common). The ESP-12 module comes with 4MB. Note that there are development boards such as the Wemos D1 mini pro that even have more.

Firmware

As the ESP8266 is nowadays fully supported in the Arduino IDE, I prefer to develop my own custom firmware for the ESP8266 using C/C++ and the Arduino IDE and libraries. So the most confusing aspect of the ESP8266 for me is that there are multiple “standard” firmwares available for it, which I often accidentally confuse. These include

  • The AT firmware, comparable to the Hayes command set on old modems.
  • The NodeMCU firmware, which includes a LUA interpreter.
  • The MicroPython firmware, which includes a Python interpreter.
  • The Espruino firmware, which includes a JavaScript interpreter.

For the firmware options that include a Python or a JavaScript interpreter it should be mentioned that there are other versions from other companies/projects.

The NodeMCU project is more centrally managed/organized and includes a website where you can compile customized firmwares with support for specific hardware add-ons.

Restoring the AT firmware

To flash the firmware to an ESP8266, you will need to wire it up and get it in the right boot loader mode. There are many online tutorials for this and I won’t elaborate here. You will also need software to write the new firmware, I am exclusively using esptool.py.

I tried various options to flash my ESP-12 with the original firmware, most of which failed. The challenge is to figure out which firmware is compatible with my specific module, and to which flash memory locations to write the different pieces of the firmware. In the next section I will describe three things that worked, going from the oldest to most recent firmware versions.

Following the instructions here and using a rather obscure version of the firmware contained in a single binary file from here, I had success with:

esptool.py --port /dev/tty.usbserial-FTG54BPS --baud 115200 write_flash --flash_mode dio 0x00000 v0.9.2.2\ AT\ Firmware.bin

Subsequently I was able to connect in a terminal program with 9600 bps and got

[System Ready, Vendor:www.ai-thinker.com]
AT+GMR

0018000902

OK

Using the old AT firmware from Espressif itself with the “Offical ESP8266 AT+ Commands” from their old GitHub repository I was also able to get it to work with:

esptool.py --port /dev/tty.usbserial-FTG54BPS --baud 115200 write_flash --flash_mode dio 0x00000 boot_v1.1.bin
esptool.py --port /dev/tty.usbserial-FTG54BPS --baud 115200 write_flash --flash_mode dio 0x01000 newest/user1.bin
esptool.py --port /dev/tty.usbserial-FTG54BPS --baud 115200 write_flash --flash_mode dio 0x7C000 esp_init_data_default.bin
esptool.py --port /dev/tty.usbserial-FTG54BPS --baud 115200 write_flash --flash_mode dio 0x7E000 blank.bin

Subsequently I was able to connect in a terminal program with 115200 bps and got

ready
AT+GMR

00200.9.4

OK

The Espressif ESP8266 SDK Getting Started Guide contains the most recent information about the layout of the flash memory. Using the 2.2.1 release from the Espressif NONOS_SDK repository and

esptool.py --port /dev/tty.usbserial-FTG54BPS --baud 115200 write_flash --flash_mode dio 0x00000 boot_v1.2.bin
esptool.py --port /dev/tty.usbserial-FTG54BPS --baud 115200 write_flash --flash_mode dio 0x01000 at/512+512/user1.1024.new.2.bin
esptool.py --port /dev/tty.usbserial-FTG54BPS --baud 115200 write_flash --flash_mode dio 0x7C000 esp_init_data_default_v05.bin
esptool.py --port /dev/tty.usbserial-FTG54BPS --baud 115200 write_flash --flash_mode dio 0x7E000 blank.bin

I also had success and was able to connect in a terminal program with 115200 bps. This resulted in the following response

ready
AT+GMR
AT version:1.6.2.0(Apr 13 2018 11:10:59)
SDK version:2.2.1(6ab97e9)
compile time:Jun 7 2018 19:34:26
Bin version(Wroom 02):1.6.2

I did not have success with the 3.0 release from the Espressif NONOS_SDK repository. That one does not have the “512+512” directory, only the “1024+1024” directory, which I could not get to work on my ESP-12. Suggestions to make this work are welcome.

16 thoughts on “Restoring the AT firmware on the ESP8266

  1. Pingback: My ESP 01 module is not responding to AT commands, HELP – Arduino Apprentices

  2. Federico Briata

    Hey dude,
    many thanks for your tips. WiFiESP is what I was looking for!
    Forget about “512+512” folder, the issue is elsewhere

    # download esptool
    git clone https://github.com/espressif/esptool
    # download the Espressif SDK 2.2.0 https://github.com/espressif/ESP8266_NONOS_SDK/archive/v2.2.0.zip or clone it
    git clone https://github.com/espressif/ESP8266_NONOS_SDK –branch release/v2.2.x

    # Note that on wemos D1 mini, the data must be flashed in 0x3fc000 as we have 4 MB (32Mbit), this apply to modules like ESP-12E, NodeMCU devkit 1.0 as well

    python esptool/esptool.py –port=/dev/ttyUSB0 \
    –chip esp8266 write_flash -fm dio -ff 20m -fs detect \
    0x0000 ESP8266_NONOS_SDK/bin/boot_v1.7.bin \
    0x01000 ESP8266_NONOS_SDK/bin/at/1024+1024/user1.2048.new.5.bin \
    0x3fc000 ESP8266_NONOS_SDK/bin/esp_init_data_default_v05.bin \
    0x7e000 ESP8266_NONOS_SDK/bin/blank.bin \
    0x3fe000 ESP8266_NONOS_SDK/bin/blank.bin

    Reply
    1. Shrey

      Thanks a lot!
      After many hours of trying different firmwares. Your method worked perfectly and restored my NodeMCU.

      Reply
  3. 395v

    Sorry I was wrong:
    AT version:1.6.0.0(Feb 3 2018 12:00:06)
    SDK version:2.2.0(f28eaf2)
    compile time:Feb 6 2018 14:36:25
    Bin version(Wroom 02):1.6.0
    OK

    Reply
    1. Robert Post author

      I did not try the new firmware. I usually use ESP boards with many IO pins (not the ESP01, but e.g. the Wemos D1 mini) and flash it directly from within the Arduino IDE rather than dealing both with an Arduino/Atmel board plus an ESP board just for the wifi.

      Reply
  4. Artem

    Thank you! I also tried v3 ESP library an it didn’t work.

    Thank you for mentioning that part. It helped me to solve the issue I had.

    Reply
  5. Mark

    Thanks a lot for your article and help!

    Its still not really working for me though. I installed from this repository: https://github.com/espressif/ESP8266_AT -> v1.1

    But after installing it and opening arduino serial monitor and send “AT” or any other command, it just returns ERROR.

    Any idea what I could be doing wrong? Is there something else execpt flashing the firmware that I need to do to get it operational?

    Thanks a lot!

    Reply
    1. Robert Post author

      Hi Mark,

      I have not used the AT firmware myself for many years. There are nowadays more versions of the ESP8266 module, so perhaps you have flashed a version of the firmware that is not consistent with the hardware memory layout of the module itself. Perhaps this PDF document from Espressif itself might be of any use.

      best regards,
      Robert

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *