ESP8266 SDK: Getting Started Guide
ESP8266 SDK: Getting Started Guide
Version 3.4
Espressif Systems
Copyright © 2020
About This Guide
This document takes ESP-LAUNCHER and ESP-WROOM-02 as examples to introduce
how to use the ESP8266 SDK V2.X and earlier versions. The contents include preparations
before compilation, SDK compilation and firmware download.
For the new ESP8266_RTOS_SDK (ESP-IDF style) V3.0 and later versions, please see
ESP8266_RTOS_SDK/docs.
Release Notes
Date Version Release notes
Certification
Download certificates for Espressif products from https://www.espressif.com/en/
certificates.
Table of Contents
1. Overview ................................................................................................................................ 1
1.1. Procedure Overview ...................................................................................................................1
4. Flash Maps........................................................................................................................... 13
4.1. Non-OTA ..................................................................................................................................14
1. Overview
1.1. Procedure Overview
Figure 1-1 shows the overall procedure of the SDK compilation.
ESP-LAUNCHER
Chapter 4. Flash
Map
Chapter 6.
ESP8266 Toolkit
Downloading the Firmware
!
Figure 1-1 Procedure Overview
📖 Notes:
• If users use other development boards or modules that integrate ESP8266EX, please use the
development firmware provided by the corresponding manufacturers.
• If users would like to purchase ESP-WROOM-02 or ESP-LAUNCHER, please visit Espressif’s official
online store at: https://espressif.taobao.com,
Espressif ! /28
1 2020.09
1. Overview
!
1.4. ESP8266 FW
ESP8266 FW (Firmware) has been provided in binary format files (.BIN) that can be
downloaded directly to the HDK. Users can choose between Over-The-Air (OTA) and non-
OTA firmware. For detailed information, please refer to Table 1-1.
Espressif ! /28
2 2020.09
1. Overview
!
Compulsory for
user1.bin Main program compiled from SDK. ❌ ☑
first usage
Used in firmware
user2.bin Main program compiled from SDK. ❌ ☑
upgrade
📖 Notes:
• For the contents of SDK, please refer to Chapter 3, "Preparing the Software".
• For the addresses of binaries in the flash, please refer to Chapter 4, "Flash Maps".
Espressif ! /28
3 2020.09
1. Overview
!
Users may directly input commands into the terminal and view or record responses in real
time.
📖 Note:
We recommend CoolTerm (for Windows and Mac OS) and Minicom (for Linux OS) as the serial port
debug tool.
Espressif ! /28
4 2020.09
2. Preparing the Hardware
!
ESP-LAUNCHER ESP-WROOM-02
• 1 × ESP-WROOM-02
• 1 × ESP-LAUNCHER • 1 × USB-to-TTL converter (FT232R recommended)
• 1 × USB cable • 6 × Dupont lines
• 1 × soldering tool suite
OR
! ! ! !
1 × PC with pre-installed Windows OS
⚠ Notice:
The ESP8266 Wi-Fi module needs a 3.3V power supply and may draw a minimum current of 500 mA.
2.1. ESP-LAUNCHER
1. Connect PC to the USB-UART interface of ESP-LAUNCHER using the USB cable.
2. Set ESP-LAUNCHER to download mode.
Steps Result
• Slide Power Switch towards the outer GPIO0 Control Chip Switch
to the board.
! Power Switch J82
Espressif ! /!28
5 2020.09
2. Preparing the Hardware
!
📖 Note:
Make sure that the proper driver for the USB-to-TTL converter is installed and recognized by the PC.
4. Power on ESP-LAUNCHER by sliding the Power Switch towards the inner side.
5. Power on the chip by sliding the Chip Switch towards the outer side.
6. Download firmware to flash with the ESP8266 DOWNLOAD TOOL.
📖 Note:
On how to download firmware, please refer to Chapter 4, "Flash Map" and Chapter 6, "Downloading the
Firmware".
7. After downloading, slide the GPIO0 Control towards the outer side to enable ESP-
LAUNCHER's working mode.
8. Power on the chip again with the Chip Switch and the chip will read and run programs
from the flash.
2.2. ESP-WROOM-02
1. Lead out the pins of the ESP-WROOM-02, as shown in Table 2-2.
EN Pull up
GND GND
Espressif ! /!28
6 2020.09
2. Preparing the Hardware
!
ESP-WROOM-02
USB-to-TTL converter
3V3
3V3
EN
RXD TXD
PC
TXD RXD
GND GND
IO15 IO0
! !
📖 Note:
On how to download firmware, please refer to Chapter 4, "Flash Maps" and Chapter 6, "Downloading the
Firmware".
📖 Notes:
• IO0 is an internal pull-up pin.
Espressif ! /!28
7 2020.09
3. Preparing the Software
!
!
Figure 3-1. Non-OS SDK Directory Structure
Espressif ! /!28
8 2020.09
3. Preparing the Software
!
!
Figure 3-2. RTOS SDK Directory Structure
Espressif ! /!28
9 2020.09
3. Preparing the Software
!
📖 Note:
Please choose the right version of VirtualBox according to the host machine's OS.
Steps Results
• Double-click
VirtualBox-5.0.16-105871-Win.exe
and install VirtualBox.
📖 Note:
VirtualBox has different versions. We
are using Windows V.5.0.16 as an
example.
• Double-click Oracle VM
VirtualBox.exe to run the program,
and the system will show the main
menu 👉 .
💬 Tip:
Espressif ! /! 28
10 2020.09
3. Preparing the Software
!
Steps Results
Espressif ! /! 28
11 2020.09
3. Preparing the Software
!
Steps Results
Espressif ! /! 28
12 2020.09
4. Flash Maps
!
4. Flash Maps
This chapter provides the flash maps for OTA firmware and non-OTA firmware in flash
memories with a different capacity. Users can modify the map as needed.
Figure 4-1 shows the flash maps for the two different types of firmware.
Non-FOTA
eagle.flash.bin eagle.irom0text.bin
RF_CAL
RF
FOTA
1 2
user1.bin user2.bin
RF_CAL
Boot ata RF
!
Figure 4-1. Flash Maps
📖 Note:
For ESP8266 firmware, please refer to Section 1.3, "ESP8266 FW".
• System Program: This area stores the firmware necessary for the system to run.
• User Data: If the system data do not take up all the flash memory, the remaining area
can be used to store user data. It is recommended that the user reserve at least 12 KB
in the user data area to store user parameters.
• RF_CAL Parameter: The system automatically stores the calibrated RF parameters in
this area.
• Default RF Parameter: Download esp_int_data_default.bin in this area to store the
default RF parameters.
• System Parameter Area: This area stores the system parameters.
• Boot Data: It is located in Partition 1 of the FOTA firmware, and stores boot data.
Espressif ! /! 28
13 2020.09
4. Flash Maps
!
📖 Notes:
• Each sector of the flash is 4 KB.
4.1. Non-OTA
4.1.1. Flash Map
Users can change the limit by modifying ESP8266_NONOS_SDK/ld/eagle.app.v6.ld.
Users can modify the len field in irom0_0_seg, as shown in Figure 4-2 (red rectangle).
The location of irom0.text varies across different versions of SDK. Users must consult the
eagle.app.v6.ld file and ensure that they are downloading eagle.irom0.text.bin to the
correct offset in the flash. The address in the blue rectangle marks the location of
eagle.irom0.text.bin in the flash.
!
Figure 4-2. Location for irom0.text
Table 4-1 shows the storage limits of eagle.irom0text.bin with different len values.
📖 Note:
ESP8266 presently only supports a System Param area of up to 1024 KB.
Espressif ! /! 28
14 2020.09
4. Flash Maps
!
eagle.flash.bin 0x00000
eagle.irom0text.bin 0x10000
📖 Notes:
• In general, ESP Flash Download Tool can be used to download firmware into flash. It is recommended
that the user start from the lower bits when downloading the firmware.
Flash capacity boot user1.bin user2.bin RF_CAL Default System User data
parameter parameter parameter
2048
2048
4 ≤ 1000 ≤ 1000 4 4 12 ≥0
(Partition 1 = 1024)
4096
4096
Espressif ! /! 28
15 2020.09
4. Flash Maps
!
Flash capacity boot user1.bin user2.bin RF_CAL Default System User data
parameter parameter parameter
8192
16384
esp_init_data
0x7C000 0xFC000 0x1FC000 0x3FC000 0x7FC000 0xFFC000
_default.bin
boot.bin 0x00000
user1.bin 0x01000
📖 Notes:
• In general, ESP Flash Download Tool can be used to download firmware into flash. It is recommended
that the user start from the lower bits when downloading the firmware.
• For OTA firmware, users do not need to download user2.bin, but upgrade the firmware via the cloud
server.
Espressif ! /! 28
16 2020.09
5. Compiling the SDK
!
5.1. Preparations
5.1.1. Modifying SDK Files
📖 Note:
Users need to modify the SDK files if using the OTA firmware.
!
• Modify #define ESP_PARAM_START_SEC in user_esp_platform.h.
!
Table 5-1 lists the modified values.
Table 5-1. Modify the Field Values in the "include" File (unit: kB)
Espressif ! /! 28
17 2020.09
5. Compiling the SDK
!
📖 Note:
Users need not modify the SDK files if using a 512-KB flash.
Steps Results
Steps Results
• Execute ./mount.sh.
• Input the password: espressif.
Downloading shared files is completed.
• Open the shared directory
ESP8266_NONOS_SDK in the virtual machine
and confirm whether the download has been
successful.
- If successful, the directory contains such
files as those in the figure on the right 👉 .
- If not, the directory will be empty, and users
will need to go over this step again.
⚠ Notice:
If users use the RTOS SDK, please continue with the following steps; if use the non-OS SDK, please skip
Step 5.
export BIN_PATH=~/Share/ESP8266_RTOS_SDK/bin
Espressif ! /! 28
18 2020.09
5. Compiling the SDK
!
📖 Note:
Users can add it to .bashrc file, otherwise Step 5 needs to be repeated each time the compiler is
restarted.
5.2. Compilation
5.2.1. Compile ESP8266_NONOS_SDK_v0.9.5 and Later Versions
1. Switch to the /Share/ESP8266_NONOS_SDK/IoT_Demo directory in the terminal.
cd /home/esp8266/Share/ESP8266_NONOS_SDK/IoT_Demo
./gen_misc.sh
FOTA? N
New
version?
Y
N
First-time
usage?
N
STEP 2: choose bin generate
(0=eagle.flash.bin+eagle.irom0text.bin
2 Y 1 0 , 1=user1.bin, 2=user2.bin)
enter (0/1/2, default 0)
Choose as required
Choose as required
Choose as required
Example Option
!
Figure 5-1. Compile SDK
Espressif ! /! 28
19 2020.09
5. Compiling the SDK
!
📖 Notes:
• The sample options are marked in green. Users can select the right options as needed.
• For OTA and non-OTA firmware, please refer to Section 1.4, "ESP8266 FW".
• Only sdk_v1.1.0 + boot 1.4 + flash download tool_v1.2 and higher versions support options 5 and 6 in
Step 5.
• After compiling user1.bin, execute make clean first to clear the temporary files generated by the last
compilation, and then compile user2.bin.
• For the flash map in Step 5, please refer to Chapter 4, "Flash Maps".
3. After compilation, the generated binaries and the addresses in flash are shown as
follows:
Generate user1.2048.new.3.bin successfully in folder bin/upgrade.
boot.bin------------>0x00000
01000
!!!
📖 Note:
Users can open the /home/esp8266/Share/ESP8266_NONOS_SDK/bin directory and check the
compiled binaries.
−−🔚
📖 Note:
ESP8266_NONOS_SDK_v0.7 and earlier are non-OTA firmware.
Espressif ! /! 28
20 2020.09
6. Downloading the Firmware
!
Espressif ! /! 28
21 2020.09
6. Downloading the Firmware
!
📖 Note:
The binaries to be downloaded and the corresponding addresses vary with different SPI Flash sizes and
actual demands. For details, please refer to Chapter 4, "Flash Maps".
Items Description
CrystalFreq Select the crystal frequency according to the crystal oscillator used.
CombineBin Combine the selected binaries into target.bin with the address 0x0000.
SPI SPEED Select SPI read/write speed with the maximum value of 80 MHz.
Select SPI mode according to the SPI Flash used. If the flash is Dual SPI, select
DIO or DOUT. If the flash is Quad SPI, select DIO or DOUT.
SPI MODE ⚠ Notice:
If ISSI Flash is used, please refer to Appendix, "Configure ISSI & MXIC Flash
QIO Mode".
• If users select DoNotChgBin, the flash working frequency, mode, and flash
map will be based on the configuration when compiling.
DoNotChgBin
• If users do not select DoNotChgBin, the flash working frequency, mode, and
flash map will be defined by the final configuration of the compiler.
Download Panel
Click START to start download. When the download completes, FINISH will
START
appear in the green area on the left.
If download is successful, the system will show the MAC addresses of ESP8266
MAC Address
STA and ESP8266 AP.
Espressif ! /! 28
22 2020.09
6. Downloading the Firmware
!
Items Description
BAUDRATE Select the baud rate of downloading. The default value is 115200.
5. After downloading, turn GPIO0 Control on ESP-LAUNCHER to the outer side and power
the board on to enable the working mode.
Port number Set the port number according to the connected device.
The baud rate at which the device is running, related to the crystal oscillator.
• 69120 (24 M crystal oscillator)
• 74880 (26 M crystal oscillator)
Baud rate
• 115200 (40 M crystal oscillator)
The ESP8266 AT example supports the baud rate of 115200 by default.
Users cannot modify it.
The ESP8266 IOT Demo example supports the baud rate of 74880. Users
can modify it.
Data bit 8
Calibration None.
reset reason: 0
Espressif ! /! 28
23 2020.09
6. Downloading the Firmware
!
add if0
add if1
bcn 100
finish
6.2.2. ESP8266 AT
If users download the ESP8266 AT firmware, or the default firmware in ESP-LAUNCHER or
ESP-WROOM-02, the system in working mode will display “Ready” at the end. Input
command “AT” in the terminal and the system will return “OK”, which means that the
firmware works properly.
📖 Notes:
• The baud rate in AT firmware is configured as 115200 manually, however, the default baud rate of
ESP8266 is 74880, due to this discrepancy, the system initialization information will be displayed as
mojibake. It is a normal phenomenon as long as the system shows “Ready” at the end.
• For more information on AT commands, please refer to ESP8266 AT Instruction Set.
Espressif ! /! 28
24 2020.09
Appendix A
!
A. Appendix—Configuring Flash
DIO to QIO Mode
⚠ Notice:
Choose DIO or DOUT mode when downloading, otherwise errors may occur. There is no need to modify
binaries in DIO or DOUT mode.
For some 2-line flash (for example, the flash manufactured by ISSI or MXIC), users can
configure the flash from the DIO mode to the QIO mode by modifying the first two bytes in
blank.bin, as instructed in Table A-1. When booting up, ESP8266 will check the first two
bytes of the blank.bin file and switch to the QIO mode automatically if the condition set
forth in Table A-1 is met.
strcut boot_hdr{
char boot_status:1;
char to_qio:1;
char reverse:4;
char test_pass_flag:1;
char test_start_flag:1;
char enhance_boot_flag:1;
Option Description
Espressif ! /! 28
25 2020.09
Appendix B
!
B. Appendix—Learning
Resources
B.1. Must-Read Documents
• ESP8266EX Datasheet
Espressif ! /! 28
26 2020.09
Appendix B
!
Espressif ! /! 28
27 2020.09
Disclaimer and Copyright Notice
Information in this document, including URL references, is subject to change without
notice.
THIS DOCUMENT IS PROVIDED AS IS WITH NO WARRANTIES WHATSOEVER,
INCLUDING ANY WARRANTY OF MERCHANTABILITY, NON-INFRINGEMENT, FITNESS
FOR ANY PARTICULAR PURPOSE, OR ANY WARRANTY OTHERWISE ARISING OUT
OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.
All liability, including liability for infringement of any proprietary rights, relating to use of
information in this document is disclaimed. No licenses express or implied, by estoppel or
otherwise, to any intellectual property rights are granted herein.
The Wi-Fi Alliance Member logo is a trademark of the Wi-Fi Alliance. The Bluetooth logo is
a registered trademark of Bluetooth SIG.
All trade names, trademarks and registered trademarks mentioned in this document are
Espressif IOT Team
property of their respective owners, and are hereby acknowledged.
www.espressif.com Copyright © 2020 Espressif Inc. All rights reserved.