27 个版本 (17 个稳定版本)
3.1.1 | 2024 年 8 月 15 日 |
---|---|
3.1.0 | 2024 年 5 月 27 日 |
3.0.0 | 2024 年 3 月 13 日 |
2.1.0 | 2023 年 10 月 3 日 |
0.1.2 | 2020 年 10 月 2 日 |
11 在 嵌入式开发 中
6,675 每月下载量
用于 13 个 包 (3 个直接使用)
5.5MB
6.5K SLoC
包含 (ELF 可执行文件/库, 4MB) resources/apps/esp32c6,(ELF 可执行文件/库, 3MB) resources/apps/esp32c2,(ELF 可执行文件/库, 3.5MB) resources/apps/esp32c3,(ELF 可执行文件/库, 3.5MB) resources/apps/esp32h2,(ELF 可执行文件/库, 1.5MB) resources/apps/esp32,(ELF 可执行文件/库, 1.5MB) resources/apps/esp32s2 以及更多。
espflash
用于烧录 Espressif 设备的库和命令行工具。
支持 ESP32、ESP32-C2/C3/C6、ESP32-H2、ESP32-P4、ESP32-S2/S3。
目录
安装
如果您是从源代码安装 espflash
(即使用 cargo install
),则必须在您的系统上安装 rustc>=1.76.0
。
如果您正在运行 Linux,则还必须安装 libudev;这可以通过大多数流行的软件包管理器获取。如果您正在运行 Windows 或 macOS,则可以忽略此步骤。
# Debian/Ubuntu/etc.
apt-get install libudev-dev
# Fedora
dnf install systemd-devel
安装
cargo install espflash
或者,您可以使用 cargo-binstall 从 发布版 下载预编译的工件,并用它们代替
cargo binstall espflash
用法
A command-line tool for flashing Espressif devices
Usage: espflash <COMMAND>
Commands:
board-info Print information about a connected target device
completions Generate completions for the given shell
erase-flash Erase Flash entirely
erase-parts Erase specified partitions
erase-region Erase specified region
flash Flash an application in ELF format to a connected target device
hold-in-reset Hold the target device in reset
monitor Open the serial monitor without flashing the connected target device
partition-table Convert partition tables between CSV and binary format
read-flash Read SPI flash content
reset Reset the target device
save-image Generate a binary application image and save it to a local disk
write-bin Write a binary file to a specific address in a target device's flash
checksum-md5 Calculate the MD5 checksum of the given region
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
Linux 上的权限
在 Linux 中,当使用需要使用串行端口的任何命令时,当前用户可能没有访问串行端口,并可能出现“权限被拒绝”或“端口不存在”错误。
在大多数Linux发行版中,解决方案是将用户添加到dialout
组(例如,使用ls -l /dev/ttyUSB0
来查找组)的命令,如下所示:sudo usermod -a -G dialout $USER
. 使用su - $USER
可以启用串口读写权限,而无需注销并重新登录。
请查阅您Linux发行版的文档以获取更多信息。
Windows 子系统 for Linux
目前无法在WSL1中使用espflash
。目前没有计划添加对WSL1的支持。
使用WSL2时,也无法使用内置的USB_SERIAL_JTAG
外设来烧录芯片,因为复位也会复位USB_SERIAL_JTAG
外设,从而将芯片从WSL2断开连接。但是,可以使用WSL2通过UART烧录芯片。
Cargo Runner
您也可以将espflash
作为Cargo运行器使用,例如,在项目的.cargo/config.toml
文件中添加以下内容:
[target.'cfg(any(target_arch = "riscv32", target_arch = "xtensa"))']
runner = "espflash flash --baud=921600 --monitor /dev/ttyUSB0"
使用此配置,您可以使用cargo run
来烧录和监控您的应用程序。
将 espflash
作为库使用
espflash
可以作为库在其他应用程序中使用
espflash = { version = "2.1", default-features = false }
或使用以下命令:cargo add espflash --no-default-features
警告 注意,
cli
模块不提供SemVer保证。
我们禁用了default-features
以禁用默认启用的cli
功能;您可能不需要您的应用程序中的任何这些类型或函数,所以没有必要引入额外的依赖项。
配置文件
配置文件允许您定义应用程序的各种参数
- 串口
- 按名称
[connection] serial = "/dev/ttyUSB0"
- 按USB VID/PID值
[[usb_device]] vid = "303a" pid = "1001"
- 按名称
- 波特率
baudrate = 460800
- 引导加载程序
bootloader = "path/to/custom/bootloader.bin"
- 分区表
partition_table = "path/to/custom/partition-table.bin"
- 闪存设置
[flash] mode = "qio" size = "8MB" frequency = "80MHz"
您可以有本地和/或全局配置文件
- 对于本地配置,将文件存储在当前工作目录下或在父目录中(以支持Cargo工作区)的
espflash.toml
名称下 - 全局文件位置因操作系统而异
- Linux:
$HOME/.config/espflash/espflash.toml
- macOS:
$HOME/Library/Application Support/rs.esp.espflash/espflash.toml
- Windows:
%APPDATA%\esp\espflash\espflash.toml
- Linux:
配置优先级
- 环境变量:如果设置了
ESPFLASH_PORT
或ESPFLASH_BAUD
,则将使用这些值而不是配置文件中的值。 - 本地配置文件
- 全局配置文件
日志格式
espflash
的flash
和monitor
子命令支持使用-L/--log-format
参数使用多个日志格式
serial
:默认日志格式defmt
:使用defmt
日志框架。使用日志格式,日志字符串具有框架字节来指示它们是defmt
消息。
许可证
许可证为以下之一
- Apache License, Version 2.0 (LICENSE-APACHE 或 https://apache.ac.cn/licenses/LICENSE-2.0)
- MIT 许可证 (LICENSE-MIT 或 http://opensource.org/licenses/MIT)
任选其一。
贡献
除非您明确声明,否则根据 Apache-2.0 许可证定义,您有意提交的任何贡献,均应按上述方式双重许可,不附加任何额外条款或条件。
依赖项
~3–15MB
~206K SLoC