Blinking LEDs and Jumper Logic with Rust on STM32
In this highly detailed and accessible tutorial, Piers Finlayson walks through how to build a complete hardware testing application in just 60 lines of Rust—specifically for his custom Software Defined Retro ROMs. The focus? Interfacing with STM32 GPIOs using the powerful async capabilities of Embassy, with flashing handled by probe-rs and logging by defmt
.
The video is a goldmine for developers curious about embedded Rust. Even if you’ve never touched async Rust before, Piers makes the experience unintimidating and refreshingly practical.
Setting Up a Rust Embedded Project
Piers starts from scratch, initializing the project using cargo new
and building out the tooling to support STM32F411 chips. He sets up cargo.toml
, embeds target-specific settings, and uses build.rs
to manage linker files like defmt.x
and link.x
. With logging handled via RTT, string data is stored on the host, keeping binaries lean and efficient for microcontrollers.
All configuration is done right inside VS Code, with helpful notes for installing targets and setting up the Rust Analyzer properly.
GPIO Control: Blinky LED and Jumper Detection
The main task is split into two parts:
- Flashing an LED on GPIO pin PB15 using asynchronous timers.
- Detecting GPIO interrupts from six jumpers using
exti
input with debounce logic.
Piers uses Embassy’s async main
macro and task system to concurrently manage these inputs. The flash_led
task toggles the LED every 500ms, while the jumper
tasks wait for edge-triggered changes on the GPIO pins. Each jumper reports its status via RTT logs—no bouncing, thanks to simple state tracking.
Why Rust?
Piers wraps up by emphasizing why Rust STM32 GPIOs make embedded development fast, safe, and even enjoyable. The type safety and async architecture eliminate the bugs you might encounter in Python or C. This approach is now his default for embedded work—except in rare cases requiring cycle-exact performance.
Watch the Full Walkthrough
Whether you’re building your own hardware tester or just curious how Rust works in the embedded world, this tutorial delivers clarity, structure, and real-world use. Piers doesn’t just teach you how to use Embassy and probe-rs—he shows you why you’ll want to.