# esptool.py
A Python-based, open source, platform independent, utility to communicate with the ROM bootloader in Espressif ESP8266 & ESP32 chips.
esptool.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/)).
esptool.py is Free Software under a GPLv2 license.
[![Build Status](https://travis-ci.org/espressif/esptool.svg?branch=master)](https://travis-ci.org/espressif/esptool)
## Installation / dependencies
### Easy Installation
You will need [either Python 2.7 or Python 3.4 or newer](https://www.python.org/downloads/) installed on your system.
The latest stable esptool.py release can be installed from [pypi](http://pypi.python.org/pypi/esptool) via pip:
```
$ pip install esptool
```
With some Python installations this may not work and you'll receive an error, try `python -m pip install esptool` or `pip2 install esptool`.
After 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`.
### Manual Installation
Manual installation allows you to run the latest development version from this repository.
esptool.py depends on [pySerial](https://github.com/pyserial/pyserial#readme) version 2.5 or newer for serial communication with the target device.
If you choose to install esptool.py system-wide by running `python setup.py install`, then this will be taken care of automatically.
If not using `setup.py`, then you'll have to install pySerial manually by running something like `pip install pyserial`, `easy_install pyserial` or `apt-get install python-serial`, depending on your platform. (The official pySerial installation instructions are [here](https://pyserial.readthedocs.org/en/latest/pyserial.html#installation)).
esptool.py also bundles the pyaes & ecdsa Python modules as "vendored" libraries. These modules are required when using the ESP32-only `espsecure.py` and `espefuse.py` tools. If you install esptool.py via `pip` or `setup.py` as shown above, then versions of these libraries will be installed from pypi. If you run esptool.py from the repository directory directly, it will use the "vendored" versions.
## Usage
Use `esptool.py -h` to see a summary of all available commands and command line options.
To see all options for a particular command, append `-h` to the command name. ie `esptool.py write_flash -h`.
## Common Options
### Serial Port
The serial port is selected using the `-p` option, like `-p /dev/ttyUSB0` (on unixen like Linux and OSX) or `-p COM1`
(on Windows).
If using Cygwin on Windows, you have to convert the Windows-style name into an Unix-style path (`COM1` -> `/dev/ttyS0`, and so on). (This is not necessary if using esp-idf for ESP32 with the supplied Windows environment, this environment uses a mingw Python & pyserial which accept COM ports as-is.)
### Baud rate
The default esptool.py baud rate is 115200bps. Different rates may be set using `-b 921600` (or another baudrate 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.
The baud rate is limited to 115200 when esptool.py establishes the initial connection, higher speeds are only used for data transfers.
Most hardware configurations will work with `-b 230400`, some with `-b 460800`, `-b 921600` and/or `-b 1500000` or higher.
If 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](#boot-log) information.
## Commands
### Convert ELF to Binary
The `elf2image` command converts an ELF file (from compiler/linker output) into the binary blobs to be flashed:
```
esptool.py --chip esp8266 elf2image my_app.elf
```
This command does not require a serial connection.
`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](#Writing-binaries-to-flash) for details.
#### elf2image for ESP8266
The 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.
`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.
```
esptool.py --chip esp8266 elf2image --version=2 -o my_app-ota.bin my_app.elf
```
#### elf2image for ESP32
For 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:
```
esptool.py --chip esp32 elf2image my_esp32_app.elf
```
In the above example, the output image file would be called `my_esp32_app.bin`.
### Writing binaries to flash
The binaries from elf2image or make_image can be sent to the chip via the serial `write_flash` command:
```
esptool.py --port COM4 write_flash 0x1000 my_app-0x01000.bin
```
Multiple flash addresses and file names can be given on the same command line:
```
esptool.py --port COM4 write_flash 0x00000 my_app.elf-0x00000.bin 0x40000 my_app.elf-0x40000.bin
```
The `--chip` argument is optional when writing to flash, esptool will detect the type of chip when it connects to the serial port.
The `--port` argument specifies the serial port. This may take the form of something like COMx (Windows), /dev/ttyUSBx (Linux) or /dev/tty.usbserial (OS X) or similar names.
The 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.
You may also need to specify arguments for [flash mode and flash size](#flash-modes), if you wish to override the defaults. For example:
```
esptool.py --port /dev/ttyUSB0 write_flash --flash_mode qio --flash_size 32m 0x0 bootloader.bin 0x1000 my_app.bin
```
Since 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, and to detect the flash size. See the [Flash Modes](#flash-modes) section for more details.
By default, the serial transfer data is compressed for better performance. The `-u/--no-compress` option disables this behaviour.
See the [Troubleshooting](#troubleshooting) section if the write_flash command is failing, or the flashed module fails to boot.
### Verifying flash
`write_flash` always verifies the MD5 hash of data which is written to flash, so manual verification is not usually needed. However, if you wish to verify the flash contents then you can do so via the `verify_flash` command:
```
./esptool.py verify_flash 0x40000 my_app.elf-0x40000.bin
```
NOTE: If verifying a default boot image (offset 0 for ESP8266 or offset 0x1000 for ESP32) then any `--flash_mode`, `--flash_size` and `--flash_freq` arguments which were passed to `write_flash` must also be passed to `verify_flash`. Otherwise, `verify_flash` will detect mismatches in the header of the image file.
### Manually assembling a firmware image
You can also manually assemble a firmware image from binary segments (such as those extracted from objcopy), like this:
```
esptool.py --chip esp8266 make_image -f app.text.bin -a 0x40100000 -f app.data.bin -a 0x3ffe8
没有合适的资源?快使用搜索试试~ 我知道了~
ESP8266擦除工具完整安装.zip
共80个文件
py:26个
bin:14个
h:9个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 84 浏览量
2024-04-17
22:21:03
上传
评论
收藏 23.68MB ZIP 举报
温馨提示
ESP8266擦除工具完整安装
资源推荐
资源详情
资源评论
收起资源包目录
ESP8266擦除工具完整安装.zip (80个子文件)
get-pip.py 1.5MB
ESP8266清除flash工具.exe 752KB
读我.txt 372B
a.txt 0B
esptool-master
ecdsa
__init__.py 611B
keys.py 12KB
test_pyecdsa.py 29KB
util.py 10KB
_version.py 7KB
ecdsa.py 24KB
der.py 7KB
rfc6979.py 3KB
ellipticcurve.py 8KB
six.py 12KB
numbertheory.py 16KB
curves.py 2KB
espefuse.py 24KB
flasher_stub
compare_stubs.py 858B
stub_commands.c 5KB
rom_functions.h 925B
stub_8266.ld 1KB
stub_flasher.h 3KB
rom_esp32.h 1KB
Makefile 3KB
run_tests_with_stub.sh 295B
stub_write_flash.c 8KB
slip.h 2KB
stub_flasher.c 13KB
esptool_test_stub.py 1KB
rom_esp8266.h 3KB
wrap_stub.py 3KB
slip.c 2KB
rom_8266.ld 14KB
stub_32.ld 1KB
stub_write_flash.h 603B
miniz.h 40KB
soc_support.h 902B
rom_32.ld 76KB
stub_commands.h 745B
miniz.c 221KB
README.md 2KB
.travis.yml 2KB
setup.py 4KB
LICENSE 18KB
.travis_setup_build_env.sh 809B
CONTRIBUTING.md 3KB
esptool.py 106KB
espsecure.py 18KB
test
test_esptool.py 16KB
elf2image
esp8266-openrtos-blink-v2.elf 992KB
esp8266-nonossdkv12-example.elf 426KB
esp8266-nonossdkv20-at-v2.elf 532KB
esp8266-nonosssdk20-iotdemo.elf 459KB
esp32-bootloader.elf 362KB
esp32-app-template.elf 2.11MB
images
one_mb_zeroes.bin 1024KB
one_kb.bin 1024B
unaligned.bin 8KB
sector.bin 4KB
partitions_singleapp.bin 96B
esp8266_sdk
4096_user1.bin 251KB
boot_v1.4(b1).bin 3KB
esp_init_data_default.bin 128B
blank.bin 4KB
one_mb.bin 1024KB
nodemcu-master-7-modules-2017-01-19-11-10-03-integer.bin 381KB
bootloader.bin 8KB
image_header_only.bin 8B
fifty_kb.bin 50KB
test_imagegen.py 9KB
README.md 1KB
MANIFEST.in 175B
.gitignore 80B
setup.cfg 96B
README.md 22KB
pyaes
__init__.py 2KB
util.py 2KB
blockfeeder.py 8KB
aes.py 59KB
python-2.7.12.amd64.msi 18.9MB
共 80 条
- 1
资源评论
手把手教你学AI
- 粉丝: 7769
- 资源: 4952
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功