21 releases (breaking)
|0.16.0||Jan 29, 2023|
|0.14.2||Jan 18, 2023|
|0.13.0||Jul 12, 2022|
|0.12.1||Nov 25, 2021|
|0.2.0||Oct 23, 2019|
#24 in Embedded development
481 downloads per month
This crate provides a cargo subcommand to flash ELF binaries onto ARM chips.
Various chip families including but not limited to nRF5x, STM32 and LPC800 can be flashed using DAPLink, ST-Link or J-Link. To check if your specific chip is supported, use
cargo flash --list-chips.
If you think
cargo-flash makes your embedded journey more enjoyable or even earns you money, please consider supporting the project on Github Sponsors for better support and more features.
You can install this utility with cargo, after installing the necessary prerequisites:
cargo install cargo-flash
Binary releases are not available.
You can use it like any cargo command would be used
cargo flash <args>
which will then build your binary and download the contents onto the connected target.
Flash the debug version of the current crate
cargo flash --chip nRF52840_xxAA
Specifying manually what options should be used
cargo flash --release --chip nRF52840_xxAA --target thumbv6m-none-eabi --example gpio_hal_blinky
Use a custom chip definition from a non-builtin file
cargo flash --release --chip-description-path nRF52840_xxAA.yaml --target thumbv6m-none-eabi --example gpio_hal_blinky
Manually selecting a chip
To manually select a chip, you can use the
--chip <chip name> argument. The chip name is an identifier such as
STM32F042C4Tx. Capitalization does not matter; Special characters do matter.
Specifying a chip family description file
You can add a temporary chip family description by using the
--chip-description-path <chip description file path> or
-c argument. You need to pass it the path to a valid yaml family description.
All the targets of the family will then be added to the registry temporarily and will override existing variants with the same name.
You can use this feature to tinker with a chip family description until it works and then submit it to upstream for inclusion.
Extracting a chip family description file from a CMSIS-Pack
You can extract the family description file by running target-gen on a
.pack file with
cargo run -- file.pack out_dir. You can obtain the pack from ARM for example. Their online registry is a good start :)
You can also reference to an already unziped
pack directory instead of the
file.pack archive file.
Add more chip definitions
If you have a chip you want to flash, feel free to contribute to probe-rs.
cargo-flash can be built using cargo, after installing the necessary prerequisites. See the list below for your operating
FTDI support is optional. You can enable it with the
ftdi feature. You also need the correct prerequisites from the next section installed.
cargo-flash depends on the libusb and optionally on libftdi libraries, which need to be installed to build cargo-flash.
On Debian and derived distros (e.g. Ubuntu), the following packages need to be installed:
# apt install -y pkg-config libusb-1.0-0-dev libftdi1-dev
If the libusb v0.1 dev package (
libusb-dev) is installed when dependant crates are built, you may get link failures at the end of the build.
On Ubuntu you can fix this by removing it with
# apt purge libusb-dev
On Windows you can use vcpkg to install the prerequisites:
# dynamic linking 64-bit > vcpkg install libftdi1:x64-windows libusb:x64-windows > set VCPKGRS_DYNAMIC=1 # static linking 64-bit > vcpkg install libftdi1:x64-windows-static-md libusb:x64-windows-static-md
On macOS, homebrew is the suggested method to install libftdi:
> brew install libftdi
We use Sentry to record crash data. This helps us trace crashes better.
No data will ever be transmitted without your consent!
All data is transmitted completely anonymously.
This is an OPT-IN feature. On crash, cargo-flash will ask you whether to transmit the data or not. You can also set whether to do this for all times with an environment variable to omit the message in the future.
If you do not wish to have sentry integrated at all, you can also build cargo-flash without sentry by using