Fads to Obsessions and Beyond...




Free domain for life, exceptional technical support, website transfer

Installing/Flashing Espressif AT Command Firmware

Demonstrate how to flash/update Espressif firmware to enable ESP8266 to be controlled via AT commands, sent via serial UART.

The ESP8266 chip itself is a SoC that includes a microcontroller and Wi-Fi Transceiver (2.4 GHz, and implements TCP/IP and full 802.11 b/g/n WLAN MAC protocol). A "bare" ESP8266 is not particularly useful for the DIY/Hobbyist. However, third-party manufactures, notably Ai-Thinker, have produced modules with the ESP8266 bundled with necessary peripheral components (from the "minimum" of including an antenna and breakout pins, through to including FTDI header, micro-USB sockets etc).

In order to facilitate the use of the ESP8266 as a serial to Wi-Fi adapter, it is generally supplied with firmware installed that implements an AT command processor. This allows the ESP8266 to be rapidly and relatively easily integrated into projects by "simply" sending the appropriate AT commands over the serial UART.

However, this firmware is over-written if the ESP8266 is programmed via the Arduino IDE or similar when using custom firmware using the ESP8266 as a stand alone microcontroller in an application.

This project demonstrates how to re-install the Espressif AT command interpreter into a ESP8266 and or update the firmware version.

The following sections document the necessary ancillary circuitry required to power-up the ESP8266 and connect to PC to enable flashing. The actual instructions, stepping through the necessary steps and detailing the software and firmware required, is given in the Testing/Experimental Results Section.


The ESP8266 modules from ebay (ESP-7, ESP-12 etc), typically being used as they are the most economical, tend to also only have the minimum parts necessary (e.g., no power supply, USB-serial converter, etc). This means some "set-up" is required in order to initially communicate with the ESP8266 and check functionality of newly purchased items for example. The following describes what is required in order to get the ESP8266 breakout board ready for flashing. Other ESP8266 boards already with FDTI, USB etc can skip these steps.

Generally the ESP8266 on the breakout board (ESP-7, ESP-12 etc) will be supplied without connectors on the various pins (see middle component in the pictures in the Photographs Section). In terms of prototyping/testing on a breadboard, some method of wires/leads etc will be required. I used cutoff wire from resistor leads (used in other various projects) as "pins". Initially, I used an IC socket as a "carrier" (see right-hand component in the pictures in the Photographs Section) both to fit standard breadboard and to give mechanical strength to the pins that would be inserted/removed from the breadboard. However, the resistor leads proved sufficiently robust to be used directly (left-hand component in the pictures in the Photographs Section)- although this arrangement takes up more room on a breadboard.

After arranging for the ESP-7 module to be able to be physically connected to other components, the most important point is to keep in mind that the ESP8266 operates at 3.3V (especially the RX pin when connected to an external microcontroller, which typically operate at 5V). Powering ESP-7 or similar with 5V most likely will damage the unit.

In addition, there are a number of pins that are required to be pulled up/down to Vcc/ground in order to enable ESP8266 operation and or set the boot mode for either normal operation or flashing. The Schematic Diagram Section outlines the requirements. The Photographs Section has pictures of the ESP-7 hooked-up on breadboard with the various required external connections, as per the following.

Three pins (GPIO0, GPIO2 and GPIO15) control boot-up mode while the pin CH_PD is chip enable/disable. The pin CH_PD must be pulled-high with a 10Kohm resistor to Vcc.

While the three pins controlling the boot mode give eight possible modes, the following table gives the two boot modes generally used.

GPIO15 GPIO0 GPIO2 Boot Mode
L L H Flash program to device (boot from UART)
L H H normal start-up (boot from flash memory)

Connecting GPIO0 with a switch to Vcc via a 10Kohm resistor and 100ohm resistor to ground provides a convenient method of starting the ESP8266 either in normal mode or ready for flash programming.

To prevent the potential of "random" resets, connect the RST (reset) pin to Vcc through a 10Kohm resistor. Alternatively, the RST pin can be connected via a momentary switch to either Vcc or ground, thus giving a reset.

The final 'ancillary' circuitry required in order to use a ESP8266 module is the power supply. A USB-TTL converter is typically used to connect the ESP8266 to PC for serial communications, and the usual USB-TTL converters provide both 3.3V and 5V output sourced from the PC USB port. This is not recommended as power supply for the ESP8266 (remember, 3.3V only). The ESP8266 has relatively high current requirement on startup (and Wi-Fi comms) which can overload the PC USB port, potentially causing damage.

Recommend using power supply from suitable lab supply, battery, linear voltage regulator, SMPS style regulator etc.

Connect ESP8266 to PC

With the ESP8266 physically connected as per the schematic, now only require connecting the RX and TX lines of the ESP8266 to the TX and RX lines respectively of the USB-TTL converter (check that the USB-TTL converter being used outputs 3.3V on the TX line). If connecting via another microcontroller or USB-TTL converter that outputs 5V on the TX line, use a suitable voltage divider or converter (the RX pin on the ESP8266 is not 5V tolerant).

The ESP8266 is now ready for communication with PC and flashing (see the Testing/Experimental Results Section for details).


Note: Image loading can be slow depending on server load.

  • ESP8266 Initial Setup SchematicESP8266 Initial Setup Schematic

    Silver Membership registration gives access to full resolution schematic diagrams.

    ESP8266 Initial Setup Schematic

    ESP8266 Initial Setup Schematic

This project did not require a PCB.

The construction was done using prototyping board. See the photographs and schematic diagram sections.

Qty Schematic Part-Reference Value Notes
Resistors
6R1-R5, R610Kohm1/4W, 10% 
1R7100 ohm1/4W, 10% 
Capacitors
1C110uF 
Integrated Circuits
1U1ESP8266module ESP-12, ESP-7 etc datasheet
Miscellaeous
1Z1USB-TTL serial converter 
1SW1momentary switch 
1SW2SPDT switch 
Description Downloads
Bill of Materials Text File Download

Connect the ESP8266 module (ESP7 ESP12 etc) as per the details in the Circuit Details Section.

Sourcing Flashing Software and AT Command Firmware

In order to flash the ESP8266 you require both the Espressif Flash Tool (to be installed on the PC) and the AT Command Processor firmware (to be flashed to the ESP8266 module).

Both of these items are available from the official Espressif site here (1). Download the Flash Tool from the Espressif site:

  • Download the Flash ToolDownload the Flash Tool

    Download the Flash Tool

    Screen Shot 1: Download the Flash Tool

Simiarily, download the AT Command Process firmware from the Espressif site:

  • Download AT Command ProcessorDownload  AT Command Processor

    Download AT Command Processor

    Screen Shot 2: Download the AT Command Processor

Un-zip the downloaded files into suitable locations on the hard drive and then run the "flash_download_tools_v3.6.5.exe" (or whatever is the latest version when you download from the Espressif site). In the resultant dialog window click the "ESP8266 Download Tool" button to start the ESP8266 flash tool which will display a user interface (following screen shot 3) requiring details about what and where to flash the desired data.

Four binary (.bin) files are necessary to be flashed to the ESP8266 in order to install the AT Command Processor firmware (which are located in the directory to which you unzipped the downloaded firmware zip archive from the Espressif site, as detailed above). In the ESP8266 Flash Tool, in the "Download Path Config" section at the top, click the (…) button, and in the resultant file selection dialog box, navigate to the location of the necessary file as shown in the following screen shot 3 and then click the OK button. Enter the corresponding ESP8266 flash memory address for each file as shown. Ensure that the "tick box" at the start of each entry box in the "Download Path Config" section is 'ticked'. The memory location box will turn green, indicating that the file is to be flashed.

Once the four binary file locations and associated flash memory locations have been entered, select the following parameters (which are typical for most ESP8266 modules, and I have found to work on the ESP7 and ESP12 modules):

  • Crystal Frequency: 26M
  • SPI Speed: 40MHz
  • Flash Size: 8Mbit
  • COM: Whatever is your connection (COM5 in my case)
  • Baud 115200 (may need to experiment with this)
  • Flash Tool InterfaceFlash Tool Interface

    Flash Tool Interface

    Screen Shot 3: ESP8266 Flash Tool Interface

When all the parameters have been entered, check that the switch on the ESP8266 is selecting "programming", i.e., GPIO0 pin is connected to ground via pull down resistor, and then power-up the ESP8266. Push the reset button on the ESP8266 circuit (this will pulse the RST pin to ground) and the ESP8266 is now ready for flashing.

Click the "Start" button on the ESP8266 Flash Tool user interface and flashing of the firmware to the ESP8266 should begin. At the start of the flashing process, the DETECTED INFO text box will be populated with information about the connected ESP8266 module (flash vendor, size and crystal frequency etc) and the MAC address of the ESP8266 will also be displayed in the textbox in the "Download Panel".

When the flashing has been completed, the button in the "Download Panel" will change to "FINISH". If you get an error, check the physical connections of the ESP8266, the entries in the ESP8266 Flash Tool user interface, power down the ESP8266 module and then repeat the flashing process. The Construction Notes/Trouble Shooting Section gives some more tips in case of further trouble.

Checking Flashed ESP8266 Firmware

If not already, power-down the ESP8266 module, then check that the switch on the ESP8266 is selecting "normal boot", i.e., GPIO0 pin is connected to 3.3V via pull up resistor, and then power-up the ESP8266.

Using a suitable serial terminal programme (RealTerm, PuTTY, Terminal, Arduino IDE Serial Monitor, etc), connect via the correct COM port using a baud rate of 115200 (typically, may need to experiment with baud rate), 8 bits, no parity and 1 stop bit (see the following screen shot 4). Now AT commands can be sent to the ESP8266 from the serial terminal, and the ESP8266 will respond if the AT Command Process firmware was successfully flashed.

The Espressif AT instruction set is available as a pdf (2). A good initial command to test if the ESP8266 is connected and operating correctly is simply "AT" (the capital letters A followed by T). All AT commands need to sent with both a carriage return and line feed as terminal characters (see the red highlighted region in the following diagram). If the ESP8266 is connected and operating correctly, in response the string "OK" will be received.

Another useful AT command for initial testing is "AT+GMR" which will cause the ESP8266 to respond with firmware version.

  • Serial Terminal ConnectionSerial Terminal Connection

    ESP8266 Serial Terminal Connection

    Screen Shot 4: ESP8266 Serial Terminal Connection


The most important item to check is that the ESP8266 is being powered via a 3.3V supply, and that the RX pin of the ESP8266 module is only receiving 3.3V when transmission from whatever device is connected (otherwise, a suitable voltage divider and or voltage converter is required).

Double check that the TX of the ESP8266 is connected the RX of the USB-TTL serial converter, and similarily, that the RX of the ESP8266 is connected to the TX (via voltage divider if necessary) of the USB-TTL serial converter, i.e., the connections are "reversed".

Powering the ESP8266 from the USB-TTL converter can result in high current load from the PC-USB, which it either cannot provide giving problems with the ESP8266 and or damaging the PC USB port. Recommend using power supply from suitable lab supply, battery, linear voltage regulator, SMPS style regulator etc.

The suggested ESP8266 crystal frequency, baud rate are only the "typical" settings reported on the Internet etc (which I have found OK for the modules I have physically worked with). These can be different, particularly the baud rate. May need to experiment with these settings. See the Espressif site for background documents which discuss these settings.

The latest version(s) of the ESP8266 Flash Tool can sometimes be problematic/buggy (if newly released). Here is a link to an older version which I have found to be reliable (3).


Comments/Questions

No comments yet.

Add Comment/Question

Only Logged-In Members can add comments

"If we could sell our experiences for what they cost us, we'd all be millionaires".

Please donate any amount to help with hosting this web site.

If you subscribe (only $2/annum) you can view the site without advertisements and get emails abouts updates etc.

X

Sorry!

Only logged-in users with Silver Membership and above can download.


Silver Membership is only $2, so join now!