https://github.com/gemesa/rustlink
small set of Rust tools to program STM32 devices
https://github.com/gemesa/rustlink
arm board cargo cortex-m embedded linux nucleo nucleo-board programmer-tool rust stlink stlinkv2 stm32 stmicroelectronics
Last synced: about 2 months ago
JSON representation
small set of Rust tools to program STM32 devices
- Host: GitHub
- URL: https://github.com/gemesa/rustlink
- Owner: gemesa
- License: gpl-3.0
- Created: 2023-05-09T16:32:30.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-21T11:45:25.000Z (about 2 years ago)
- Last Synced: 2025-02-15T04:24:56.815Z (4 months ago)
- Topics: arm, board, cargo, cortex-m, embedded, linux, nucleo, nucleo-board, programmer-tool, rust, stlink, stlinkv2, stm32, stmicroelectronics
- Language: Rust
- Homepage: https://shadowshell.io/
- Size: 54.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rustlink
[](https://github.com/gemesa/rustlink/actions/workflows/codespell.yml)
[](https://github.com/gemesa/rustlink/actions/workflows/md-link.yml)
[](https://github.com/gemesa/rustlink/actions/workflows/rust.yml)
[](https://github.com/gemesa/rustlink/actions/workflows/shellcheck.yml)rustlink is a set of tools to program STM32 devices:
- `rst-info`: device information tool
- `rst-flash`: programmer and flash manipulation toolThe motivation behind these tools is that [probe-rs-cli](https://crates.io/crates/probe-rs-cli) can not handle multiple connected probes (devices):
```
$ probe-rs-cli info
Error: 2 probes were found.
```With `rst-flash` you can choose by serial number which device to use:
```
$ rst-info list
[0]: STLink V2 - serial: AAAAAAAAAAAAAAAAAAAAAAAAAAAA
[1]: STLink V2 - serial: BBBBBBBBBBBBBBBBBBBBBBBBBBBB
$ rst-flash download -s AAAAAAAAAAAAAAAAAAAAAAAAAAAA -t STM32F103C8 -f app.elf
Finished in 0.179s
$ rst-flash reset -s AAAAAAAAAAAAAAAAAAAAAAAAAAAA -t STM32F103C8
```## Installation from source
### Prerequisites
The following tools are necessary for building:
- `cargo` (>=1.68.2)
- `rustc` (>=1.68.2)Both can be installed from the [official Rust site](https://www.rust-lang.org/tools/install).
### How to build and install
Invoke the following commands:
```bash
$ cargo build --release
$ cargo install --path .
```which will build `rst-info` and `rst-flash` executables and install them in `/.cargo/bin/`.
## Examples
### List STlink devices
```
$ rst-info list
[0]: STLink V2 - serial: AAAAAAAAAAAAAAAAAAAAAAAAAAAA
[1]: STLink V2 - serial: BBBBBBBBBBBBBBBBBBBBBBBBBBBB
```### Download to flash and run
```
$ rst-flash download -s AAAAAAAAAAAAAAAAAAAAAAAAAAAA -t STM32F103C8 -f app.elf
Finished in 0.179s
$ rst-flash reset -s AAAAAAAAAAAAAAAAAAAAAAAAAAAA -t STM32F103C8
```### Dump and erase memory
```
$ rst-flash download -s AAAAAAAAAAAAAAAAAAAAAAAAAAAA -t STM32F103C8 -f app.elf
Finished in 0.191s
$ rst-flash dump -s AAAAAAAAAAAAAAAAAAAAAAAAAAAA -t STM32F103C8 0x0800_0000 1
Addr 0x08000000: 0x20005000
Read 1 words in 498.057µs
$ rst-flash erase -s AAAAAAAAAAAAAAAAAAAAAAAAAAAA -t STM32F103C8
$ rst-flash dump -s AAAAAAAAAAAAAAAAAAAAAAAAAAAA -t STM32F103C8 0x0800_0000 1
Addr 0x08000000: 0xffffffff
Read 1 words in 473.943µs
```### Get chip info
```
$ probe-rs-cli chip info STM32F103C8
STM32F103C8
Cores (1):
- main (Armv7m)
RAM: 0x20000000..0x20005000 (20.00 KiB)
NVM: 0x08000000..0x08010000 (64.00 KiB)
```