Despite the difficulty of updating the firmware in modules like the ESP-01, the ESP8266 microcontroller with built-in Wi-Fi has become extremely popular among electronic designers. Now, thanks to more information and better tools, the flashing process is significantly easier, and SDK v2.0.0 adds new capabilities.

Introduction

The success of the ESP8266 from Espressif Systems is undeniable. It is a powerful microcontroller with built-in Wi-Fi capabilities and is readily adaptable to a multitude of uses in the rapidly growing IoT (Internet of Things). One of the few difficulties to using the IC has been updating the firmware in the thousands and thousands of development modules that have permeated the market. Judging by the large number of comments posted, this article on All About Circuits has been a help to many. However, the passage of time has revealed some corrections and improvements needed in the information that was provided in October of 2015, and presenting that information is the goal of this article.

Specifically, the following improvements will be addressed:

  • a better flashing circuit
  • an easier-to-use terminal program
  • a revised Flash Download Tool
  • updated SDK v2.0.0 ESP8266 firmware

Taken collectively, and supported by better documentation from Espressif, these changes will streamline the firmware flashing process, and increase the ESP8266's usability to both hobbyists and professional designers.

As a note, this article is a successor to a previous version that was published in October of 2015. You may want to peruse that article for some worthwhile background information.

 

The Flashing Circuit

An improved flashing circuit for the ESP-01 module is shown in the following schematic diagram; several changes have been made to the original design:

  1. The 3.3VDC power is no longer taken from the USB-to-TTL converter. Some converters do not provide sufficient current to properly drive the ESP8266, especially when it is in the Wi-Fi transmitting mode. A separate, well-filtered and regulated 3.3VDC supply capable of supplying at least 500mA should be used.
  2. Capacitors C1 and C2 have been added to provide noise reduction on the power bus. They should be located as close as possible to the Gnd and Vcc pins on the ESP8266.
  3. R2 and R3 are pullup resistors that were added to ensure that the GPIO2 and GPIO0 pins on the ESP8266 are never allowed to float.

These changes do not indicate that the original flashing circuit was nonfunctional; the fact is that it did work for the author and for many other users. However, its shortcomings were such that the circuit could and did fail for some users at least some of the time. These failures could have been due to differences in environmental factors, power supply quality, and/or component tolerances. The improved circuit should eliminate those weaknesses.

 

Click to enlarge

 

The improved flashing circuit is shown built on a solderless breadboard in the following photographs. The first photo shows the entire circuit with the ESP-01 module in place; the second photo shows the circuit with the ESP-01 module removed in order to reveal the locations of C2, R2, and R3. Note that the wire colors in the breadboard assembly correspond to the color designations in the schematic drawing.

 

 

The PCB assembly at the right side of the breadboard is a well regulated and filtered 3.3VDC power supply. For complete information on building a copy of this power supply, see this article on AAC. Otherwise, you may use any power source with similar capabilities.

The PCB assembly in the upper left corner of the breadboard is the USB-to-TTL converter. As you see, it is inserted directly into the solderless breadboard using six Dupont style header pins that protrude down from the bottom of the PCB. You can modify your USB-to-TTL converter to work in that very convenient way, or you can use discrete wires to make the connections. Whichever you choose, be certain to follow the pinout sequence as shown in the schematic drawing and the photographs. Note that only three connections are required: RxD from the converter to TxD on the ESP-01, TxD on the converter to RxD on the ESP-01, and common ground.

Even though the USB-to-TTL converter is not being used to power the ESP-01, be sure that the converter is set to 3.3VDC so that the signal voltage levels will not exceed the input range of the ESP8266. Any voltage higher than 3.3VDC connected to the ESP8266 may damage it beyond repair.

 

 

In the photo immediately above, the ESP-01 module has been removed from the assembly revealing the author's home-built breadboard adapter for the ESP-01. In the photo just below, the home-built adapter is shown on the left, as well as an almost identical professionally built adapter from Addicore on the right. They work identically and make it much easier to use an ESP-01 module in a solderless breadboard or any similar device with connectors on 0.1 inch (2.54 mm) centers.

 

 

Once you have completed construction of your flashing circuit, it's almost time for testing. But before attaching the USB cable or applying power, recheck the wiring—especially the power wiring. It's better to take a few extra minutes now than to damage something because of incorrect wiring.

First, connect the USB cable from the PC to the USB-to-TTL converter. A positive indication is when the red LED at the corner of the PCB close to the USB connector lights, and the PC recognizes the converter. At that point, note what COM port number has been assigned to the converter. As you can see in the photos, COM4 has been assigned to the converter shown, and a label has been attached to identify the relevant COM port.

Next, apply 3.3VDC power to the flashing circuit. You should see a couple of flashes from a blue LED on the ESP-01 module, and a red LED on the module should be steadily illuminated. No smoke or odd smell should be coming from the circuit.

Now, press and release SW1 (the reset switch); the blue LED should flash. Then, press and release SW2 (the flash switch); nothing noticeable should happen.

If all that went according to plan, your flash circuit is probably wired correctly. It's time to perform the definitive check: will the ESP8266 answer when you call it to attention?

 

Parts List

The parts for the flashing circuit are shown in the following table. In addition, you may need assorted wire, solder, and a well-regulated and filtered 3.3VDC power supply.

 

Part Ref. Description Source Item No.
C1 Capacitor, Ceramic, 0.1µF, 50V Digi-Key 399-9797-ND
C2 Capacitor, Aluminum Electrolytic, 220µF, 16V Digi-Key 493-1041-ND
R1-R4 Resistor, ¼ W, 10kΩ Digi-Key 10KQBK-ND
N/A Breadboard, Solderless, 400 Contact Digi-Key 377-2094-ND
N/A Adapter, Breadboard, DIP8, for ESP-01 & nRF24L01 Addicore BB-ADTR
N/A Module, ESP8266, ESP-01 Digi-Key 1568-1235-ND
SW1-SW2 Switch, Tactile, Momentary, Normally Open, SPST, Pushbutton, 2-Pin on-line* N/A
N/A Converter, USB-to-TTL, with 3.3V Capability on-line* N/A
*All parts are readily available from a variety of suppliers with the possible exception of the USB-to-TTL converter, and SW1-SW2, which may have to be located via online searches. SW1 and SW2 are ordinary tactile, momentary, normally open, SPST pushbutton switches, but with only two pins on the bottom. Because the pins are on 0.2" centers, they work well in solderless breadboards; see the photo in this article.

 

Getting Started with Termite

PuTTY was the recommended terminal program in the original article on flashing ESP8266 ICs, and if that is what you have and want to use, it works fine. However, Termite is somewhat more user-friendly in this application and will be used in the step-by-step instructions that follow. Termite is free for both personal and commercial use.

The following instructions assume that the ESP-01 module is programmed just as it is normally received from a supplier. If you (or someone else) has made changes to the default program settings, you will need to experiment to find the current settings for your ESP-01 module.

After checking your ESP-01 flashing circuit as previously described, power it up. Start Termite on your PC and click the Settings button; you should see a window similar to the one below. Be certain that the COM port to which the USB-to-TTL converter is connected is correctly selected in the Serial port settings window. Adjust all other settings as shown in the Serial port settings window below, and click OK to close the Serial port settings window.

 

 

At this point, the cursor should be flashing in the bottom section of the Termite window; if not, click on the bottom section of the Termite window to position the cursor there. Type AT and press Enter on your keyboard; if all is well, the ESP-01 will respond with OK in the Termite window. If it does, breathe a big sigh of relief because you have just cleared a major hurdle.

Next, type AT+GMR and press Enter. The ESP-01 should respond with something very similar to the window below.

 

 

The AT+GMR command tells the ESP8266 to report what version of the AT command set it contains, what SDK (Software Development Kit) has been loaded on it, what company built the ESP module, and when the SDK was loaded on the module. Finally, as usual, the ESP8266 concludes its transmission with OK.

If the ESP-01 responded correctly, you are finished with Termite (unless you want to play some more). You will use it again in this project to confirm a successful firmware flash.

 

ESP8266 Downloads

All the necessary documentation and tools for flashing the firmware on ESP8266 chips are available online, and much of it resides at the Espressif website. As a convenience to AAC readers, much of it is also available here. The Flash Download Tool and the Software Development Kit are absolutely essential. Not all the documents are required, but they are all potentially helpful. Please download the files and store them on your computer in a directory where you can find them, so that you can perform an ESP8266 firmware flash as described just ahead in this article.

 

Flash Download Tool v3.4.4

Version 3.4.4 of the Flash Download Tool is the latest version available from Espressif at the time this article is being prepared. The tool for the ESP8266 looks almost identical to the past several versions all the way back to v2.3, except that two new tools have been added to the package. One is for the ESP8285 and the other is for the ESP32, neither of which are of any use with the ESP8266. Click the button below to download v3.4.4; you will note that it contains a version for PCs and a Mac version. This article will use the PC version.

 

  ESP Flash Download Tools v3.4.4  


Software Development Kit 2.0.0

As of this writing, the latest available version of the ESP8266 Software Development Kit is version 2.0.0, which was released in July of 2016. While almost nothing is certain in firmware development, one might conclude that v2.0.0 is the last version that will be released. At any rate, it seems to be a stable version and will be used in this article. It is available free to download from Espressif, but to save the readers some trouble, it is also available here by clicking the button below.

 

  ESP Software Development Kit v2.0.0  


ESP8266 Documentation

As is often said, "When all else fails, read the instructions," and to that end, Espressif has an impressive collection of documents pertaining to the ESP8266. There is little doubt that the answers to many questions are contained in their pages. Three of the documents used most frequently by the author are ESP8266 Quick Start Guide, version 1.3, ESP8266 SDK Getting Started Guide, version 2.7, and ESP AT Instruction Set, version 2.0.0. These three, along with several others, are included in the zip file available for download via the button below. Note that additional documents and more current documents may be available at the Espressif website.

 

  ESP8266 Technical Documents  


Bits and Bytes Recollected

The amount of EEPROM on an ESP8266 module (such as the ESP-01) is a very important factor in the exact flashing procedure that is to be used. That EEPROM quantity can be expressed in a variety of different units of measurement, and the units used vary from place to place in the documentation, which can be confusing. The bullet points and the table below are included as a ready reference to minimize the muddle.

  • The abbreviation for bit is b, and the abbreviation for byte is B.
  • There are eight bits (b) in one byte (B).
  • The abbreviation for kilobit is Kb, and the abbreviation for kilobyte is KB. Likewise, megabit is abbreviated Mb, and megabyte is abbreviated MB, etc.
  • It's also good to note that most (maybe all) ESP-01 modules built on black PCBs have 1 MB of EEPROM.

 

Term

Byte (B) Kilobyte (KB) Megabyte (MB) Gigabyte (GB) Terabyte (TB)
Number of Bytes 1 1,024 1,048,576 1,073,741,824 1,099,511,627,776

 

The Flashing Process

Reading from Your ESP-01 Module

Install the ESP-01 module in the flashing circuit, connect the USB-to-TTL converter to a USB port on your PC, and power up the circuit with 3.3VDC. Start version 3.4.4 of the Flash Download Tool, and you should see the startup screens as shown below. The back window is where a complete activity log for the download tool is recorded. The top window is a tool selection window; because you are working with an ESP8266 module, click the ESP8266 Download Tool button.

 

 

If this is the first time the ESP8266 download tool has been used, a window like the one below will open with no data in the form fields. If the SPIDownload tab near the top of the window is not selected, select it now.

 

 

If any of the boxes have check marks in them, uncheck them all. Next, make sure that the COM port you are using and the correct BAUD rate are selected at the bottom right. Click the radio button under SPI SPEED for 40MHz, and the radio button under SPI MODE for QIO. Do not click any other radio buttons, add any check marks, or enter any data.

  1. Press and hold the Reset button (SW1) on your flashing circuit.
  2. Press and hold the Flash button (SW2) on your flashing circuit.
  3. Release the Reset button.
  4. Release the Flash button.
  5. Click the Start button at the lower left portion of the download tool window.

The download tool will work for a few seconds to read the contents of the ESP-01 module and print the results in the appropriate panels as shown below.

 

 

Here's what has happened during the download tool process time:

  1. The download tool determined the size of the EEPROM on the module as "QUAD;8Mbit," which translates to 1Megabyte.
  2. The download tool determined the crystal speed to be 26MHz.
  3. The download tool read the MAC addresses for your ESP-01 module in both the AP (Access Point) mode and in the STA (Station) mode, and entered them in Download Panel 1. (Note that the MAC addresses for your ESP-01 module will be different from the addresses shown above; record the MAC addresses of your module for future reference.)

 

Writing to Your ESP-01 Module

Finally, you are ready to select and write the new firmware to your module. Set SpiFlashConfig as follows:

  1. Select CrystalFreq as 26M.
  2. Click the SPI SPEED radio button for 40MHz.
  3. Click the SPI MODE radio button for QIO.
  4. Click the FLASH SIZE radio button for 8Mbit.

Select the binary files to be downloaded from their storage locations as shown in the table below. (The files listed below are contained in the ESP8266 SDK v2.0.0 folder that you dowloaded and stored on your PC.)

 

Binary File Name Binary File Location ESP-01 Flash Address
blank.bin ...\esp8266_nonos_sdk_v2.0.0_16_08_10\ESP8266_NONOS_SDK\bin 0xFB000
esp_init_data_default.bin ...\esp8266_nonos_sdk_v2.0.0_16_08_10\ESP8266_NONOS_SDK\bin 0xFC000
blank.bin ...\esp8266_nonos_sdk_v2.0.0_16_08_10\ESP8266_NONOS_SDK\bin 0x7E000
blank.bin ...\esp8266_nonos_sdk_v2.0.0_16_08_10\ESP8266_NONOS_SDK\bin 0xFE000
boot_v1.6.bin ...\esp8266_nonos_sdk_v2.0.0_16_08_10\ESP8266_NONOS_SDK\bin 0x00000
user1.1024.new.2.bin ...\esp8266_nonos_sdk_v2.0.0_16_08_10\ESP8266_NONOS_SDK\bin\at\512+512 0x01000

 

A. Click to place a check in the first (top left) check box below Download Path Config; the entire data entry line will turn red as shown below.

 

 

B. Click the ellipsis (...) button in the first line and navigate to the location on your PC where the SDK 2.0.0 binary files are stored; select the blank.bin file. The entire file path will be entered into the box to the left of the ellipsis button.

C. Next, enter the hexadecimal address to the right of the ellipsis button where the blank.bin file is to be stored: 0xFB000 in this case.

Repeat steps A through C for each of the six binary files. The completed data will appear as shown below.

 

 

After rechecking all the file paths and hexadecimal storage locations, take the following actions:

  1. Press and hold the Reset button (SW1) on your flashing circuit.
  2. Press and hold the Flash button (SW2) on your flashing circuit.
  3. Release the Reset button.
  4. Release the Flash button.
  5. Click the Start button at the lower left portion of the download tool window.

The download tool will work for several seconds to write the binary files to your ESP-01 module. When the blue progress bar reaches the right side of the window, the flashing process is complete as shown below.

 

 

Press and release the Reset button (SW1) on your flashing circuit. Power down the flashing circuit.

 

Confirming a Successful Flash

To confirm that the flash process was successfully completed, power up the flashing circuit. Start Termite and check the firmware version as previously described, and as shown below. You should see the following results.

 

 

Your ESP-01 module is updated to SDK version 2.0.0, and to AT command set version 1.3.0.0. Congratulations! You are ready to put the ESP-01 to work in your IoT project.

 

Comments

7 Comments


  • Rotten Ronnie 2017-03-19

    Brilliant. I followed this guide almost exactly although I purchased a “ESP01 Programmer Adapter UART GPIO0 ESP-01” on ebay, and resorted to some alligator clips to pull_down RST and GPIO0.

    Thanks!

    • Charles R. Hampton 2017-03-19

      Wow, that’s great to hear; I am thrilled to have helped. As you can see, yours is the first comment and it’s great that the process worked well for you. Hopefully, many others will also benefit. Thanks for the input. Spread the word!

  • keaaw 2017-03-19

    Question about the power supply. In an earlier article you wrote, “Estimates of the current required for the ESP-01 during Wi-Fi operation vary from 250mA to 750mA. The current supplied by the USB to TTL converter should suffice for programming the ESP-01, but may prove to be inadequate for long term use. A better choice is a filtered regulated 3.3VDC supply capable of 1A or more.”  Yet the 3.3v version of the DIY power supply you’re using is rated for 500mA…?

    • Charles R. Hampton 2017-03-19

      Excellent observation. In doing research for the first article, I read somewhere (didn’t note where) that current could be as much as 750mA. I remember thinking at the time that seemed excessive and was probably an outlier, but I put it at the top end of the range just to be on the safe side. Current estimates seem to top out at 320mA, which I now believe; thus, a 500mA supply is ample. I will amend the latest article to that effect. Thanks for the correction.

      • keaaw 2017-03-20

        p.s. thank you for the excellent articles!  I know how much effort goes into writeups like this.  Your articles are clear, with great schematics, photos, clear parts lists (with sources links!), definitely among the best instructables I’ve come across.  I’m really keen to learn about IoT, and the esp8266 seems a great place to start.

  • SergioVels 2017-03-22

    Excellent Post
    Work 100%