#cli #embedded #esp

bin+lib espflash

A command-line tool for flashing Espressif devices over serial

18 releases (11 stable)

2.0.0-rc.3 Jan 12, 2023
2.0.0-rc.2 Dec 7, 2022
2.0.0-rc.1 Nov 7, 2022
1.7.0 Sep 16, 2022
0.1.2 Oct 2, 2020

#60 in Command line utilities

Download history 723/week @ 2022-12-11 536/week @ 2022-12-18 441/week @ 2022-12-25 715/week @ 2023-01-01 553/week @ 2023-01-08 631/week @ 2023-01-15 1007/week @ 2023-01-22 853/week @ 2023-01-29 734/week @ 2023-02-05 836/week @ 2023-02-12 687/week @ 2023-02-19 742/week @ 2023-02-26 935/week @ 2023-03-05 777/week @ 2023-03-12 955/week @ 2023-03-19 899/week @ 2023-03-26

3,606 downloads per month
Used in 2 crates

MIT/Apache and GPL-3.0 licenses

255KB
5.5K SLoC

espflash

Crates.io docs.rs MSRV Crates.io

A library and command-line tool for flashing Espressif devices over serial.

Supports the ESP32, ESP32-C2/C3/C6, ESP32-S2/S3, and ESP8266.

Installation

If you are installing espflash from source (ie. using cargo install) then you must have rustc>=1.63.0 installed on your system.

If you are running macOS or Linux then libuv must also be installed; this is available via most popular package managers. If you are running Windows you can ignore this step.

# macOS
brew install libuv
# Debian/Ubuntu/etc.
apt-get install libuv-dev
# Fedora
dnf install systemd-devel

To install:

cargo install espflash

Alternatively, you can use cargo-binstall to download pre-compiled artifacts from the releases and use them instead:

cargo binstall espflash

If you would like to flash from a Raspberry Pi using the built-in UART peripheral, you can enable the raspberry feature (note that this is not available if using cargo-binstall):

cargo install espflash --features=raspberry

Usage

A command-line tool for flashing Espressif devices over serial

Usage: espflash <COMMAND>

Commands:
  board-info       Display information about the connected board and exit without flashing
  flash            Flash an application to a target device
  monitor          Open the serial monitor without flashing
  partition-table  Operations for partitions tables
  save-image       Save the image to disk instead of flashing to device
  write-bin        Writes a binary file to a specific address in the chip's flash
  help             Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help information
  -V, --version  Print version information

Cargo Runner

You can also use espflash as a Cargo runner by adding the following to your project's .cargo/config.toml file, for example:

[target.'cfg(any(target_arch = "riscv32", target_arch = "xtensa"))']
runner = "espflash flash --baud=921600 --monitor /dev/ttyUSB0"

With this configuration you can flash and monitor you application using cargo run.

Configuration

It's possible to specify a serial port and/or USB VID/PID values by setting them in a configuration file. The location of this file differs based on your operating system:

Operating System Configuration Path
Linux $HOME/.config/espflash/espflash.toml
macOS $HOME/Library/Application Support/rs.esp.espflash/espflash.toml
Windows %APPDATA%\esp\espflash\espflash.toml

Windows Subsystem for Linux

It is not currently possible to use espflash from within WSL1.

It is not possible to flash chips using the built-in USB_SERIAL_JTAG when using WSL2, because the reset also resets USB_SERIAL_JTAG peripheral which then disconnects the chip from WSL2. Chips can be flashed via UART using WSL2, however.

License

Licensed under either of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~16–24MB
~466K SLoC