• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/H25-Oct-2021-438333

build_tools/H03-May-2022-7158

espressif/H25-Oct-2021-7,3975,570

flasher_stub/H25-Oct-2021-27,00023,482

test/H25-Oct-2021-4,2033,255

.gitignoreH A D25-Oct-202198 1513

.gitlab-ci.ymlH A D25-Oct-20219.5 KiB253228

CONTRIBUTING.mdH A D25-Oct-20212.8 KiB6232

LICENSEH A D25-Oct-202117.7 KiB340281

MANIFEST.inH A D25-Oct-2021235 129

README.mdH A D25-Oct-202129.5 KiB489288

esp_rfc2217_server.pyH A D25-Oct-202110.3 KiB283199

espefuse.pyH A D25-Oct-20216.6 KiB152107

espsecure.pyH A D25-Oct-202143.9 KiB999730

esptool.pyH A D25-Oct-2021249.3 KiB5,1443,936

setup.cfgH A D25-Oct-2021996 2722

setup.pyH A D25-Oct-20214.5 KiB139113

README.md

1# esptool.py
2
3A Python-based, open source, platform independent, utility to communicate with the ROM bootloader in Espressif ESP8266 & ESP32 series chips.
4
5esptool.py was started by Fredrik Ahlberg (@[themadinventor](https://github.com/themadinventor/)) as an unofficial community project. It is now also supported by Espressif. Current primary maintainer is Angus Gratton (@[projectgus](https://github.com/projectgus/)).
6
7esptool.py is Free Software under a GPLv2 license.
8
9[![Test esptool](https://github.com/espressif/esptool/actions/workflows/test_esptool.yml/badge.svg?branch=master)](https://github.com/espressif/esptool/actions/workflows/test_esptool.yml)[![Build esptool](https://github.com/espressif/esptool/actions/workflows/build_esptool.yml/badge.svg?branch=master)](https://github.com/espressif/esptool/actions/workflows/build_esptool.yml)
10
11## Installation / dependencies
12
13### Easy Installation
14
15You will need [either Python 2.7 or Python 3.4 or newer](https://www.python.org/downloads/) installed on your system.
16
17The latest stable esptool.py release can be installed from [pypi](http://pypi.python.org/pypi/esptool) via pip:
18
19```
20$ pip install esptool
21```
22
23With some Python installations this may not work and you'll receive an error, try `python -m pip install esptool` or `pip2 install esptool`, or consult your [Python installation manual](https://pip.pypa.io/en/stable/installing/) for information about how to access pip.
24
25[Setuptools](https://setuptools.readthedocs.io/en/latest/userguide/quickstart.html) is also a requirement which is not available on all systems by default. You can install it by a package manager of your operating system, or by `pip install setuptools`.
26
27After installing, you will have `esptool.py` installed into the default Python executables directory and you should be able to run it with the command `esptool.py` or `python -m esptool`. Please note that probably only `python -m esptool` will work for Pythons installed from Windows Store.
28
29### Development Mode Installation
30
31Development mode allows you to run the latest development version from this repository.
32
33```sh
34$ git clone https://github.com/espressif/esptool.git
35$ cd esptool
36$ pip install --user -e .
37```
38
39This will install esptool's dependencies and create some executable script wrappers in the user's `bin` directory. The wrappers will run the scripts found in the git working directory directly, so any time the working directory contents change it will pick up the new versions.
40
41It's also possible to run the scripts directly from the working directory with this Development Mode installation.
42
43(Note: if you actually plan to do development work with esptool itself, see the CONTRIBUTING.md file.)
44
45## Usage
46
47Use `esptool.py -h` to see a summary of all available commands and command line options.
48
49To see all options for a particular command, append `-h` to the command name. ie `esptool.py write_flash -h`.
50
51## Common Options
52
53### Serial Port
54
55* The serial port is selected using the `-p` option, like `-p /dev/ttyUSB0` (Linux and macOS) or `-p COM1` (Windows).
56* A default serial port can be specified by setting the `ESPTOOL_PORT` environment variable.
57* If no `-p` option or `ESPTOOL_PORT` value is specified, `esptool.py` will enumerate all connected serial ports and try each one until it finds an Espressif device connected (new behaviour in v2.4.0).
58
59Note: Windows and macOS may require drivers to be installed for a particular USB/serial adapter, before a serial port is available. Consult the documentation for your particular device. On macOS, you can also consult [System Information](https://support.apple.com/en-us/HT203001)'s list of USB devices to identify the manufacturer or device ID when the adapter is plugged in. On Windows, you can use [Windows Update or Device Manager](https://support.microsoft.com/en-us/help/15048/windows-7-update-driver-hardware-not-working-properly) to find a driver.
60
61If using Cygwin or WSL on Windows, you have to convert the Windows-style name into a Unix-style path (`COM1` -> `/dev/ttyS0`, and so on). (This is not necessary if using ESP-IDF for ESP32 with the supplied Windows MSYS2 environment, this environment uses a native Windows Python which accepts COM ports as-is.)
62
63In Linux, the current user may not have access to serial ports and a "Permission Denied" error will appear. On most Linux distributions, the solution is to add the user to the `dialout` group with a command like `sudo usermod -a -G dialout <USERNAME>`. Check your Linux distribution's documentation for more information.
64
65### Baud rate
66
67The default esptool.py baud rate is 115200bps. Different rates may be set using `-b 921600` (or another baud rate of your choice). A default baud rate can also be specified using the `ESPTOOL_BAUD` environment variable. This can speed up `write_flash` and `read_flash` operations.
68
69The baud rate is limited to 115200 when esptool.py establishes the initial connection, higher speeds are only used for data transfers.
70
71Most hardware configurations will work with `-b 230400`, some with `-b 460800`, `-b 921600` and/or `-b 1500000` or higher.
72
73If you have connectivity problems then you can also set baud rates below 115200. You can also choose 74880, which is the usual baud rate used by the ESP8266 to output [boot log](https://github.com/espressif/esptool/wiki/ESP8266-Boot-ROM-Log) information.
74
75## Commands
76
77### Write binary data to flash: write_flash
78
79Binary data can be written to the ESP's flash chip via the serial `write_flash` command:
80
81```
82esptool.py --port COM4 write_flash 0x1000 my_app-0x01000.bin
83```
84
85Multiple flash addresses and file names can be given on the same command line:
86
87```
88esptool.py --port COM4 write_flash 0x00000 my_app.elf-0x00000.bin 0x40000 my_app.elf-0x40000.bin
89```
90
91The `--chip` argument is optional when writing to flash, esptool will detect the type of chip when it connects to the serial port.
92
93The `--port` argument is documented under [Serial Port](#serial-port).
94
95The next arguments to write_flash are one or more pairs of offset (address) and file name. When generating ESP8266 "version 1" images, the file names created by `elf2image` include the flash offsets as part of the file name. For other types of images, consult your SDK documentation to determine the files to flash at which offsets.
96
97Numeric values passed to write_flash (and other commands) can be specified either in hex (ie 0x1000), or in decimal (ie 4096).
98
99See the [Troubleshooting](#troubleshooting) section if the write_flash command is failing, or the flashed module fails to boot.
100
101#### Setting flash mode and size
102
103You may also need to specify arguments for [flash mode and flash size](#flash-modes), if you wish to override the defaults. For example:
104
105```
106esptool.py --port /dev/ttyUSB0 write_flash --flash_mode qio --flash_size 32m 0x0 bootloader.bin 0x1000 my_app.bin
107```
108
109Since esptool v2.0, these options are not often needed as the default is to keep the flash mode and size from the `.bin` image file. See the [Flash Modes](#flash-modes) section for more details.
110
111#### Compression
112
113By default, the serial transfer data is compressed for better performance. The `-u/--no-compress` option disables this behaviour.
114
115#### Erasing flash before write
116
117To successfully write data into flash, all 4096-byte memory sectors (the smallest erasable unit) affected by the operation have to be erased first. As a result, when the flashing offset address or the data are not 4096-byte aligned, more memory is erased than actually needed. Esptool will display information about which flash memory sectors will be erased.
118
119Use the `-e/--erase-all` option to erase all flash sectors (not just write areas) before programming.
120
121### Read Flash Contents: read_flash
122
123The read_flash command allows reading back the contents of flash. The arguments to the command are an address, a size, and a filename to dump the output to. For example, to read a full 2MB of attached flash:
124
125```
126esptool.py -p PORT -b 460800 read_flash 0 0x200000 flash_contents.bin
127```
128
129(Note that if `write_flash` updated the boot image's [flash mode and flash size](#flash-modes) during flashing then these bytes may be different when read back.)
130
131### Erase Flash: erase_flash & erase region
132
133To erase the entire flash chip (all data replaced with 0xFF bytes):
134
135```
136esptool.py erase_flash
137```
138
139To erase a region of the flash, starting at address 0x20000 with length 0x4000 bytes (16KB):
140
141```
142esptool.py erase_region 0x20000 0x4000
143```
144
145The address and length must both be multiples of the SPI flash erase sector size. This is 0x1000 (4096) bytes for supported flash chips.
146
147### Read built-in MAC address: read_mac
148
149```
150esptool.py read_mac
151```
152
153### Read SPI flash id: flash_id
154
155```
156esptool.py flash_id
157```
158
159Example output:
160
161```
162Manufacturer: e0
163Device: 4016
164Detected flash size: 4MB
165```
166
167Refer to [flashrom source code](https://review.coreboot.org/plugins/gitiles/flashrom/+/refs/heads/master/flashchips.h) for flash chip manufacturer name and part number.
168
169### Convert ELF to Binary: elf2image
170
171The `elf2image` command converts an ELF file (from compiler/linker output) into the binary executable images which can be flashed and then booted into:
172```
173esptool.py --chip esp8266 elf2image my_app.elf
174```
175
176This command does not require a serial connection.
177
178`elf2image` also accepts the [Flash Modes](#flash-modes) arguments `--flash_freq` and `--flash_mode`, which can be used to set the default values in the image header. This is important when generating any image which will be booted directly by the chip. These values can also be overwritten via the `write_flash` command, see the [write_flash command](#write-binary-data-to-flash-write_flash) for details.
179
180By default, `elf2image` uses the sections in the ELF file to generate each segment in the binary executable. To use segments (PHDRs) instead, pass the `--use_segments` option.
181
182#### elf2image for ESP8266
183
184The default command output is two binary files: `my_app.elf-0x00000.bin` and `my_app.elf-0x40000.bin`. You can alter the firmware file name prefix using the `--output/-o` option.
185
186`elf2image` can also produce a "version 2" image file suitable for use with a software bootloader stub such as [rboot](https://github.com/raburton/rboot) or the Espressif bootloader program. You can't flash a "version 2" image without also flashing a suitable bootloader.
187
188```
189esptool.py --chip esp8266 elf2image --version=2 -o my_app-ota.bin my_app.elf
190```
191
192#### elf2image for ESP32
193
194For ESP32, elf2image produces a single output binary "image file". By default this has the same name as the .elf file, with a .bin extension. ie:
195
196```
197esptool.py --chip esp32 elf2image my_esp32_app.elf
198```
199
200In the above example, the output image file would be called `my_esp32_app.bin`.
201
202### Output .bin image details: image_info
203
204The `image_info` command outputs some information (load addresses, sizes, etc) about a `.bin` file created by `elf2image`.
205
206```
207esptool.py --chip esp32 image_info my_esp32_app.bin
208```
209
210Note that `--chip esp32` is required when reading ESP32 images. Otherwise the default is `--chip esp8266` and the image will be interpreted as an invalid ESP8266 image.
211
212### Advanced Commands
213
214The following commands are less commonly used, or only of interest to advanced users. They are documented on the wiki:
215
216* [verify_flash](https://github.com/espressif/esptool/wiki/Advanced-Commands#verify_flash)
217* [dump_mem](https://github.com/espressif/esptool/wiki/Advanced-Commands#dump_mem)
218* [load_ram](https://github.com/espressif/esptool/wiki/Advanced-Commands#load_ram)
219* [read_mem & write_mem](https://github.com/espressif/esptool/wiki/Advanced-Commands#read_mem--write_mem)
220* [read_flash_status](https://github.com/espressif/esptool/wiki/Advanced-Commands#read_flash_status)
221* [write_flash_status](https://github.com/espressif/esptool/wiki/Advanced-Commands#write_flash_status)
222* [chip_id](https://github.com/espressif/esptool/wiki/Advanced-Commands#chip_id)
223* [make_image](https://github.com/espressif/esptool/wiki/Advanced-Commands#make_image)
224* [run](https://github.com/espressif/esptool/wiki/Advanced-Commands#run)
225
226## Additional ESP32 Tools
227
228The following tools for ESP32, bundled with esptool.py, are documented on the wiki:
229
230* [espefuse.py - for reading/writing ESP32 efuse region](https://github.com/espressif/esptool/wiki/espefuse)
231* [espsecure.py - for working with ESP32 security features](https://github.com/espressif/esptool/wiki/espsecure)
232
233## Serial Connections
234
235The ESP8266 & ESP32 ROM serial bootloader uses a 3.3V UART serial connection. Many development boards make the serial connections for you onboard.
236
237However, if you are wiring the chip yourself to a USB/Serial adapter or similar then the following connections must be made:
238
239ESP32/ESP8266 Pin     | Serial Port Pin
240--------------------- | ----------------------------
241TX (aka GPIO1)        | RX (receive)
242RX (aka GPIO3)        | TX (transmit)
243Ground                | Ground
244
245Note that TX (transmit) on the ESP8266 is connected to RX (receive) on the serial port connection, and vice versa.
246
247Do not connect the chip to 5V TTL serial adapters, and especially not to "standard" RS-232 adapters! 3.3V serial only!
248
249## Entering the Bootloader
250
251Both ESP8266 and ESP32 have to be reset in a certain way in order to launch the serial bootloader.
252
253On some development boards (including NodeMCU, WeMOS, HUZZAH Feather, Core Board, ESP32-WROVER-KIT), esptool.py can automatically trigger a reset into the serial bootloader - in which case you don't need to read this section.
254
255For everyone else, three things must happen to enter the serial bootloader - a reset, required pins set correctly, and GPIO0 pulled low:
256
257### Boot Mode
258
259Both ESP8266 and ESP32 choose the boot mode each time they reset. A reset event can happen in one of several ways:
260
261* Power applied to chip.
262* The nRESET pin was low and is pulled high (on ESP8266 only).
263* The CH_PD/EN pin ("enable") pin was low and is pulled high.
264
265On ESP8266, both the nRESET and CH_PD pins must be pulled high for the chip to start operating.
266
267For more details on selecting the boot mode, see the following Wiki pages:
268
269* [ESP8266 Boot Mode Selection](https://github.com/espressif/esptool/wiki/ESP8266-Boot-Mode-Selection)
270* [ESP32 Boot Mode Selection](https://github.com/espressif/esptool/wiki/ESP32-Boot-Mode-Selection)
271
272## Flash Modes
273
274`write_flash` and some other commands accept command line arguments to set bootloader flash mode, flash size and flash clock frequency. The chip needs correct mode, frequency and size settings in order to run correctly - although there is some flexibility. A header at the beginning of a bootable image contains these values.
275
276To override these values, the options `--flash_mode`, `--flash_size` and/or `--flash_freq` must appear after `write_flash` on the command line, for example:
277
278```
279esptool.py --port /dev/ttyUSB1 write_flash --flash_mode dio --flash_size 4MB 0x0 bootloader.bin
280```
281
282These options are only consulted when flashing a bootable image to an ESP8266 at offset 0x0, or an ESP32 at offset 0x1000. These are addresses used by the ROM bootloader to load from flash. When flashing at all other offsets, these arguments are not used.
283
284### Flash Mode (--flash_mode, -fm)
285
286These set Quad Flash I/O or Dual Flash I/O modes. Valid values are `keep`, `qio`, `qout`, `dio`, `dout`. The default is `keep`, which keeps whatever value is already in the image file. This parameter can also be specified using the environment variable `ESPTOOL_FM`.
287
288Most boards use `qio` mode. Some ESP8266 modules, including the ESP-12E modules on some (not all) NodeMCU boards, are dual I/O and the firmware will only boot when flashed with `--flash_mode dio`. Most ESP32 modules are also dual I/O.
289
290In `qio` mode, two additional GPIOs (9 and 10) are used for SPI flash communications. If flash mode is set to `dio` then these pins are available for other purposes.
291
292For a full explanation of these modes, see the [SPI Flash Modes wiki page](https://github.com/espressif/esptool/wiki/SPI-Flash-Modes).
293
294### Flash Frequency (--flash_freq, -ff)
295
296Clock frequency for SPI flash interactions. Valid values are `keep`, `40m`, `26m`, `20m`, `80m` (MHz). The default is `keep`, which keeps whatever value is already in the image file. This parameter can also be specified using the environment variable `ESPTOOL_FF`.
297
298The flash chip connected to most chips works with 40MHz clock speeds, but you can try lower values if the device won't boot. The highest 80MHz flash clock speed will give the best performance, but may cause crashing if the flash or board design is not capable of this speed.
299
300### Flash Size (--flash_size, -fs)
301
302Size of the SPI flash, given in megabytes. Valid values vary by chip type:
303
304Chip     | flash_size values
305---------|---------------------------------------------------------------
306ESP32    | `keep`, `detect`, `1MB`, `2MB`, `4MB`, `8MB`, `16MB`
307ESP8266  | `keep`, `detect`, `256KB`, `512KB`, `1MB`, `2MB`, `4MB`, `2MB-c1`, `4MB-c1`, `8MB`, `16MB`
308
309For ESP8266, some [additional sizes & layouts for OTA "firmware slots" are available](#esp8266-and-flash-size).
310
311The default `--flash_size` parameter is `keep`. This means that if no `--flash_size` argument is passed when flashing a bootloader, the value in the bootloader .bin file header is kept instead of detecting the actual flash size and updating the header.
312
313To enable automatic flash size detection based on SPI flash ID, add the argument `esptool.py [...] write_flash [...] -fs detect`. If detection fails, a warning is printed and a default value of of `4MB` (4 megabytes) is used.
314
315If flash size is not successfully detected, you can find the flash size by using the `flash_id` command and then looking up the ID from the output (see [Read SPI flash id](#read-spi-flash-id-flash_id)). Alternatively, read off the silkscreen labelling of the flash chip and search for its datasheet.
316
317The default `flash_size` parameter can also be overridden using the environment variable `ESPTOOL_FS`.
318
319#### ESP8266 and Flash Size
320
321The ESP8266 SDK stores WiFi configuration at the "end" of flash, and it finds the end using this size. However there is no downside to specifying a smaller flash size than you really have, as long as you don't need to write an image larger than this size.
322
323ESP-12, ESP-12E and ESP-12F modules (and boards that use them such as NodeMCU, HUZZAH, etc.) usually have at least 4 megabyte / `4MB` (sometimes labelled 32 megabit) flash.
324
325If using OTA, some additional sizes & layouts for OTA "firmware slots" are available. If not using OTA updates then you can ignore these extra sizes:
326
327|flash_size arg | Number of OTA slots | OTA Slot Size | Non-OTA Space |
328|---------------|---------------------|---------------|---------------|
329|256KB          | 1 (no OTA)          | 256KB         | N/A           |
330|512KB          | 1 (no OTA)          | 512KB         | N/A           |
331|1MB            | 2                   | 512KB         | 0KB           |
332|2MB            | 2                   | 512KB         | 1024KB        |
333|4MB            | 2                   | 512KB         | 3072KB        |
334|2MB-c1         | 2                   | 1024KB        | 0KB           |
335|4MB-c1         | 2                   | 1024KB        | 2048KB        |
336|8MB [^]        | 2                   | 1024KB        | 6144KB        |
337|16MB [^]       | 2                   | 1024KB        | 14336KB       |
338
339* [^] Support for 8MB & 16MB flash size is not present in all ESP8266 SDKs. If your SDK doesn't support these flash sizes, use `--flash_size 4MB`.
340
341#### ESP32 and Flash Size
342
343The ESP-IDF flashes a partition table to the flash at offset 0x8000. All of the partitions in this table must fit inside the configured flash size, otherwise the ESP32 will not work correctly.
344
345## Merging binaries
346
347The `merge_bin` command will merge multiple binary files (of any kind) into a single file that can be flashed to a device later. Any gaps between the input files are padded with 0xFF bytes (same as unwritten flash contents).
348
349For example:
350
351```
352esptool.py --chip esp32 merge_bin -o merged-flash.bin --flash_mode dio --flash_size 4MB 0x1000 bootloader.bin 0x8000 partition-table.bin 0x10000 app.bin
353```
354
355Will create a file `merged-flash.bin` with the contents of the other 3 files. This file can be later be written to flash with `esptool.py write_flash 0x0 merged-flash.bin`.
356
357Note: Because gaps between the input files are padded with 0xFF bytes, when the merged binary is written then any flash sectors between the individual files will be erased. To avoid this, write the files individually.
358
359### Options
360
361* The `merge_bin` command supports the same `--flash_mode`, `--flash_size` and `--flash_speed` options as the `write_flash` command to override the bootloader flash header (see above for details). These options are applied to the output file contents in the same way as when writing to flash. Make sure to pass the `--chip` parameter if using these options, as the supported values and the bootloader offset both depend on the chip.
362* The `--target-offset 0xNNN` option will create a merged binary that should be flashed at the specified offset, instead of at offset 0x0.
363* The `--fill-flash-size SIZE` option will pad the merged binary with 0xFF bytes to the full flash specified size, for example `--fill-flash-size 4MB` will create a 4MB binary file.
364* It is possible to append options from a text file with `@filename`. As an example, this can be conveniently used with the ESP-IDF build system, which produces a `flash_args` file in the build directory of a project:
365
366```sh
367cd build    # The build directory of an ESP-IDF project
368esptool.py --chip esp32 merge_bin -o merged-flash.bin @flash_args
369```
370
371## Advanced Options
372
373See the [Advanced Options wiki page](https://github.com/espressif/esptool/wiki/Advanced-Options) for some of the more unusual esptool.py command line options.
374
375## Remote Serial Ports
376
377It is possible to connect to any networked remote serial port that supports [RFC2217](http://www.ietf.org/rfc/rfc2217.txt) (Telnet) protocol, or a plain TCP socket. See the [Remote Serial Ports wiki page](https://github.com/espressif/esptool/wiki/Remote-Serial-Ports) for details.
378
379## Troubleshooting
380
381Flashing problems can be fiddly to troubleshoot. Try the suggestions here if you're having problems:
382
383### Bootloader won't respond
384
385If you see errors like "Failed to connect" then your chip is probably not entering the bootloader properly:
386
387* Check you are passing the correct serial port on the command line.
388* Check you have permissions to access the serial port, and other software (such as modem-manager on Linux) is not trying to interact with it. A common pitfall is leaving a serial terminal accessing this port open in another window and forgetting about it.
389* Check the chip is receiving 3.3V from a stable power source (see [Insufficient Power](#insufficient-power) for more details.)
390* Check that all pins are connected as described in [Entering the bootloader](#entering-the-bootloader). Check the voltages at each pin with a multimeter, "high" pins should be close to 3.3V and "low" pins should be close to 0V.
391* If you have connected other devices to GPIO pins mentioned above section, try removing them and see if esptool.py starts working.
392* Try using a slower baud rate (`-b 9600` is a very slow value that you can use to verify it's not a baud rate problem.)
393
394
395### write_flash operation fails part way through
396
397If flashing fails with random errors part way through, retry with a lower baud rate.
398
399Power stability problems may also cause this (see [Insufficient Power](#insufficient-power).)
400
401### write_flash succeeds but program doesn't run
402
403If esptool.py can flash your module with `write_flash` but your program doesn't run, try the following:
404
405#### Wrong Flash Mode
406
407Some devices only support the `dio` flash mode. Writing to flash with `qio` mode will succeed but the chip can't read the flash back to run - so nothing happens on boot. Try passing the `-fm dio` option to write_flash.
408
409See the [SPI Flash Modes](https://github.com/espressif/esptool/wiki/SPI-Flash-Modes) wiki page for a full description of the flash modes and how to determine which ones are supported on your device.
410
411#### Insufficient Power
412
413The 3.3V power supply for the ESP8266 and ESP32 has to supply large amounts of current (up to 70mA continuous, 200-300mA peak, slightly higher for ESP32). You also need sufficient capacitance on the power circuit to meet large spikes of power demand.
414
415##### Insufficient Capacitance
416
417If you're using a pre-made development board or module then the built-in power regulator & capacitors are usually good enough, provided the input power supply is adequate.
418
419*This is not true for some very simple pin breakout modules - [similar to this](https://user-images.githubusercontent.com/205573/30140831-9da417a6-93ba-11e7-95c3-f422744967de.jpg). These breakouts do not integrate enough capacitance to work reliably without additional components.*. Surface mount OEM modules like ESP-WROOM02 and ESP-WROOM32 require an external bulk capacitor on the PCB to be reliable, consult the module datasheet.
420
421##### Power Supply Rating
422
423It is possible to have a power supply that supplies enough current for the serial bootloader stage with esptool.py, but not enough for normal firmware operation. You may see the 3.3V VCC voltage droop down if you measure it with a multimeter, but you can have problems even if this isn't happening.
424
425Try swapping in a 3.3V supply with a higher current rating, add capacitors to the power line, and/or shorten any 3.3V power wires.
426
427The 3.3V output from FTDI FT232R chips/adapters or Arduino boards *do not* supply sufficient current to power an ESP8266 or ESP32 (it may seem to work sometimes, but it won't work reliably). Other USB TTL/serial adapters may also be marginal.
428
429#### Missing bootloader
430
431Recent ESP8266 SDKs and the ESP32 ESP-IDF both use a small firmware bootloader program. The hardware bootloader in ROM loads this firmware bootloader from flash, and then it runs the program. On ESP8266. firmware bootloader image (with a filename like `boot_v1.x.bin`) has to be flashed at offset 0. If the firmware bootloader is missing then the ESP8266 will not boot. On ESP32, the bootloader image should be flashed by ESP-IDF at offset 0x1000.
432
433Refer to SDK or ESP-IDF documentation for details regarding which binaries need to be flashed at which offsets.
434
435#### SPI Pins which must be disconnected
436
437Compared to the ROM bootloader that esptool.py talks to, a running firmware uses more of the chip's pins to access the SPI flash.
438
439If you set "Quad I/O" mode (`-fm qio`, the esptool.py default) then GPIOs 7, 8, 9 & 10 are used for reading the SPI flash and must be otherwise disconnected.
440
441If you set "Dual I/O" mode (`-fm dio`) then GPIOs 7 & 8 are used for reading the SPI flash and must be otherwise disconnected.
442
443Try disconnecting anything from those pins (and/or swap to Dual I/O mode if you were previously using Quad I/O mode but want to attach things to GPIOs 9 & 10). Note that if GPIOs 9 & 10 are also connected to input pins on the SPI flash chip, they may still be unsuitable for use as general purpose I/O.
444
445In addition to these pins, GPIOs 6 & 11 are also used to access the SPI flash (in all modes). However flashing will usually fail completely if these pins are connected incorrectly.
446
447### Early stage crash
448
449Use a [serial terminal program](#serial-terminal-programs) to view the boot log. (ESP8266 baud rate is 74880bps, ESP32 is 115200bps). See if the program is crashing during early startup or outputting an error message.
450
451## Serial Terminal Programs
452
453There are many serial terminal programs suitable for debugging & serial interaction. The pyserial module (which is required for esptool.py) includes one such command line terminal program - miniterm.py. For more details [see this page](http://pyserial.readthedocs.org/en/latest/tools.html#module-serial.tools.miniterm) or run `miniterm -h`.
454
455Note that not every serial program supports the unusual ESP8266 74880bps "boot log" baud rate. Support is especially sparse on Linux. `miniterm.py` supports this baud rate on all platforms. ESP32 uses the more common 115200bps.
456
457## Tracing esptool.py interactions
458
459Running `esptool.py --trace` will dump all serial interactions to the standard output (this is *a lot* of output). This can be helpful when debugging issues with the serial connection, or when providing information for bug reports.
460
461## Using esptool from Python
462
463esptool.py, espefuse.py, and espsecure.py can easily be integrated into Python applications or called from other Python scripts.
464
465While it currently does have a poor Python API, something which [#208](https://github.com/espressif/esptool/issues/208) will address, it allows for passing CLI
466arguments to `esptool.main()`. This workaround makes integration very straightforward as you can pass exactly the
467same arguments as you would on the CLI.
468
469```python
470command = ['--baud', '460800', 'read_flash', '0', '0x200000', 'flash_contents.bin']
471print('Using command %s' % ' '.join(command))
472esptool.main(command)
473```
474
475## Internal Technical Documentation
476
477The [repository wiki](https://github.com/espressif/esptool/wiki) contains some technical documentation regarding the serial protocol and file format used by the ROM bootloader. This may be useful if you're developing esptool.py or hacking system internals:
478
479* [Firmware Image Format](https://github.com/espressif/esptool/wiki/Firmware-Image-Format)
480* [Serial Protocol](https://github.com/espressif/esptool/wiki/Serial-Protocol)
481* [ESP8266 Boot ROM Log](https://github.com/espressif/esptool/wiki/ESP8266-Boot-ROM-Log)
482
483
484## About
485
486esptool.py was initially created by Fredrik Ahlberg (@themadinventor, @kongo), and is currently maintained by Angus Gratton (@projectgus). It has also received improvements from many members of the ESP8266 community - including @rojer, @jimparis, @jms19, @pfalcon, @tommie, @0ff, @george-hopkins and others.
487
488This document and the attached source code are released under GNU General Public License Version 2. See the accompanying file LICENSE for a copy.
489