Skip to content
K Smith edited this page Jan 16, 2021 · 11 revisions

Flashing ESP8266 (ESP-01) using Arduino

Hardware

Arduino

Arduino MKR series, Arduino Zero or compatibles, based on SAMD21 or SAMD51 MCU’s with at least 8 Kbytes of SRAM and 16 Kbyte of flash, working at 3.3 volt.

The MCU should have native USB for PC connection and hardware UART for connection to ESP, for best performance, like the SAMD-based MCU’s have.

Arduino MKR ZERO (I2S bus & SD for sound, music & digital audio data)

(ESP pinout diagram by blinkmaker on www.instructables.com/Flash-or-Upgrade-Firmware-on-ESP8266-ESP-01-Module/

 

Hardware setup

Connect the ESP8266 (ESP-01) to the Arduino like this:

Arduino pin

ESP8266 (ESP-01) pin

Purpose

8 (D8)

CH_PD / EN (the marking differ)

Chip select / Chip enable signal. Used to enable and reset the ESP.

9 (D9)

GPIO0

Select flashing mode in ESP.

10 (D10)

RESET

ESP reset.

RX (13 on MKR)

TX

Serial

TX (14 on MKR)

RX

Serial

GND

GND

Ground

VCC (3.3V / 3V3)

3V3

3.3V power

 

Firmware from Espressif

Firmware may be found at https://www.espressif.com/en/support/download/at.

Content of firmware download from espressif:


 Filename                                                                      Size
 ESP8266_NonOS_AT_Bin_V1.7.4\.DS_Store                                          8196
 ESP8266_NonOS_AT_Bin_V1.7.4\ESP8266 NonOS AT Release Note.pdf                117598
 ESP8266_NonOS_AT_Bin_V1.7.4\bin\.DS_Store                                     10244
 ESP8266_NonOS_AT_Bin_V1.7.4\bin\blank.bin                                      4096
 ESP8266_NonOS_AT_Bin_V1.7.4\bin\boot_v1.7.bin                                  4080
 ESP8266_NonOS_AT_Bin_V1.7.4\bin\esp_init_data_default_v08.bin                   128
 ESP8266_NonOS_AT_Bin_V1.7.4\bin\at\.DS_Store                                   8196
 ESP8266_NonOS_AT_Bin_V1.7.4\bin\at\README.md                                   2182
 ESP8266_NonOS_AT_Bin_V1.7.4\bin\at\1024+1024\user1.2048.new.5.bin            413444
 ESP8266_NonOS_AT_Bin_V1.7.4\bin\at\1024+1024\user2.2048.new.5.bin            413444
 ESP8266_NonOS_AT_Bin_V1.7.4\bin\at\512+512\user1.1024.new.2.bin              413444
 ESP8266_NonOS_AT_Bin_V1.7.4\bin\at\512+512\user2.1024.new.2.bin              413444
 ESP8266_NonOS_AT_Bin_V1.7.4\bin\at_sdio\README.md                              1764
 ESP8266_NonOS_AT_Bin_V1.7.4\bin\at_sdio\1024+1024\user1.2048.new.5.bin       461732
 ESP8266_NonOS_AT_Bin_V1.7.4\bin\at_sdio\1024+1024\user2.2048.new.5.bin       461732

First part of ESP8266_NonOS_AT_Bin_V1.7.4\bin\at\README.md:

# Notice:
 AT firmware becomes larger since it supports more functions. So, we provide two firmwares here:
 * 1024+1024: Normal AT, which is compiled from ESP8266_NONOS_SDK/examples/at, and uses mbedTLS lib.
 * 512+512: Nano AT, which is compiled from ESP8266_NONOS_SDK/examples/at_nano, and uses SSL lib that supports less cipher suites.
 It is suggested to use normal AT(1024+1024), if your flash size is 2MB or larger.
 # BOOT MODE
 ## download
 ### Flash size 8Mbit: 512KB+512KB
     boot_v1.2+.bin              0x00000
     user1.1024.new.2.bin        0x01000
     esp_init_data_default.bin   0xfc000
     blank.bin                   0x7e000 & 0xfe000
 ### Flash size 16Mbit-C1: 1024KB+1024KB
     boot_v1.2+.bin              0x00000
     user1.2048.new.5.bin        0x01000
     esp_init_data_default.bin   0x1fc000
     blank.bin                   0xfe000 & 0x1fe000

For an ESP8266 with 8 Mbit / 1 Mbyte flash, configure the ESP8266 Download Tool according to the information from the README.md file like below. Some deduction must be done, to find the correct files:

Text from README.md Remark Firmware file Start address
boot_v1.2+.bin                  0x00000 This means to choose a file with bootloader with version 1.2 or newer bin\boot_v1.7.bin 0x0
user1.1024.new.2.bin      0x01000 Finds this file in the 512+512 folder bin\at\512+512\user1.1024.new.2.bin 0x1000
esp_init_data_default.bin  0xfc000 Matches with esp_init_data_default_v08.bin bin\esp_init_data_default_v08.bin 0xfc000
blank.bin           0x7e000 & 0xfe000 With two start addresses, this file must be flashed into two addresses bin\blank.bin 0x7e000
    bin\blank.bin 0xfe000

For an ESP8266 with 16 Mbit / 2 Mbyte flash, configure the ESP8266 Download Tool according to the information from the README.md file like below. Some deduction must be done, to find the correct files:

Text from README.md Remark Firmware file Start address
boot_v1.2+.bin                  0x00000 This means to choose a file with bootloader with version 1.2 or newer bin\boot_v1.7.bin 0x0
user1.2048.new.5.bin      0x01000 Finds this file in the 512+512 folder bin\at\1024+1024\user1.2048.new.5.bin 0x1000
esp_init_data_default.bin  0x1fc000 Matches with esp_init_data_default_v08.bin bin\esp_init_data_default_v08.bin 0x1fc000
blank.bin           0xfe000 & 0x1fe000 With two start addresses, this file must be flashed into two addresses bin\blank.bin 0xfe000
    bin\blank.bin 0x1fe000
 

If having a flash of 16 Mbit or more or wanting to use the AT-SDIO version for 16 Mbit flash, refer to the ESP8266_NonOS_AT_Bin_V1.7.4\bin\at_sdio\README.md file.

ESP firmware download tool

The ESP firmware flashing  tool may be downloaded from https://www.espressif.com/en/support/download/other-tools.

Unpack and run the flash download tool:

A black window appears.

Select Developer Mode

Select ESP8266 DownloadTool

Use SpiAutoSet to get parameters from ESP, by checking SpiAutoSet and pressing START with no files selected for flashing. Filenames may be listed, but they must be unchecked.

When using an Arduino MKR or Zero, baud rate could be set at up to 1500000 baud. If using an Arduino without native USB, 115200 should be used, and PASSTHROUGH_MODE should be set to FlashingMode in the sketch.

The command window shows the working. Initially the flashing program connect using 115200 baud, sending a stub loader to the ESP. If another baud rate than 115200 is selected in the user interface, the baud rate is switched. Switching baud rates will only work for Arduinos with native USB connection to the PC, since they in fact ignore the baud rate between the PC and Arduino, always running at full USB speed, which for an SAMD21 is 12 Mbit/sec. The EspSerialPassthrough sketch detects the baud rate change command, and changes the baud rate between the Arduino and the ESP accordingly.

The result for an ESP-01 / ESP8266 with 8 Mbit flash:

The program finds the crystal frequency (CrystFreq) and flash size. In my case it keeps the SPI MODE set to QIO. Several tries flashing with SPI mode set to QIO failed, but an Internet search found that DOUT might be necessary to select manually.

Uncheck SpiAutoSet and select the appropriate SPI MODE, which for my ESP8266 was DOUT. SPI Mode seems to control the way the ESP flashes itself.

Then select the correct files to flash, according to the README.md file of the ESP firmware, and click START:

 

For baud rates, using an Arduino MKR with SAMD21 microcontroller, connected to the PC using native USB, I successfully have flashed with baud rates up to 1500000.

Verify successful flashing

Reset the Arduino, which makes the Arduino program reset the ESP8266.

Open a serial monitor or terminal emulator like Putty. Make sure to send both NewLine and Carriage Return as line feeds. May manually be entered as Ctrl-M + Ctrl-J instead of using the ENTER key.

Run the AT+GMR command:

Firmware upgraded successfully!