I've found Rust to work well on Stm32, due to outstanding PAC and Cortex-M libs. I've released a commercial product using it with Stm32 L4, plan to release another using Rust+Nordic, and a third with Stm32H7 in a few months. Overall, Rust is a very nice language to work with, due to it's ergonomics and builtin tools/docs. · · Here's the HAL lib I wrote for the job: STM32-HAL Answer from DOCon.1 on community.st.com
Reddit
reddit.com › r/embedded › rust on stm32
r/embedded on Reddit: Rust on STM32
December 9, 2024 -
Curious to hear any feedback from people who have done a project with Rust on an STM32 microcontroller instead of C/C++ (I realize Rust isn't officially supported by them but there aren't any technical reasons it's shouldn't be fine as far as I can tell). However, would love to hear about any "gotchas" that are worth noting from other people's experience.
Top answer 1 of 5
51
STM32 support in Rust is amazing in either RTIC or Embassy. The compiler safety guarantees will force you to be a better programmer through the borrow checker, which is where people get frustrated. Unsafe should be rarely used except around heap initialization or maybe accessing the peripherals during initialization (or register access outside the HAL). Cargo is 1000x better at managing projects than CMake, which is hard to overstate. Unit testing is built in to Cargo as well. There may be features you need implemented that the HAL might not have, but you can either fork the HAL and make contributions or fall back to the PAC and do it yourself at register level. Debug support is great in VS Code using breakpoints or command line (probe-rs). The only gotcha is learning Rust, which has a learning curve for sure. I think traits are so much better than OOP. There are tons of great examples in the HAL, RTIC, and Embassy crates.
2 of 5
21
I haven't personally used Rust for embedded yet, but not too long ago we assigned one team to port one of our mid-range products to rust as an investigational task. About a month in, the entire team decided that they hated it and that it created more headaches than it solved. The project was abandoned. The major gripe was that so much of the code needed to be "unsafe" that all of the extra work didn't actually yield any tangible benefit. We're sticking with C/C++ for now.
Medium
medium.com › @saifhajsalem12 › running-rust-on-stm32-microcontrollers-a-practical-guide-for-embedded-enthusiasts-fed6550e4aef
Running Rust on STM32 Microcontrollers: A Practical Guide for Embedded Enthusiasts | by Saif Haj Salem | Medium
January 7, 2025 - RTIC (Real-Time Interrupt-driven Concurrency) is a framework for managing tasks and interrupts in embedded Rust. ... Add drivers for sensors like accelerometers or temperature sensors. ... Use probe-rs for debugging and monitoring. ... Optimize for limited memory and compute resources. ... Use panic-halt or panic-reset to define behavior on panics. ... Leverage hardware abstraction layers for cleaner code. ... Always test your code on actual hardware to ensure proper functionality. Rust on STM32F103 Blue Pill with Probe-run tooling
Videos
Top answer 1 of 9
1
I've found Rust to work well on Stm32, due to outstanding PAC and Cortex-M libs. I've released a commercial product using it with Stm32 L4, plan to release another using Rust+Nordic, and a third with Stm32H7 in a few months. Overall, Rust is a very nice language to work with, due to it's ergonomics and builtin tools/docs. · · Here's the HAL lib I wrote for the job: STM32-HAL
2 of 9
0
Push
GitHub
github.com › stm32-rs › stm32-rs
GitHub - stm32-rs/stm32-rs: Embedded Rust device crates for STM32 microcontrollers
This repository provides Rust device support crates for all STM32 microcontrollers, providing a safe API to that device's peripherals using svd2rust and a community-built collection of patches to the basic SVD files.
Starred by 1.6K users
Forked by 253 users
Languages Python 65.9% | HTML 18.4% | Shell 9.1% | Makefile 6.6% | Python 65.9% | HTML 18.4% | Shell 9.1% | Makefile 6.6%
Bastelblog
jonathanklimt.de › electronics › programming › embedded-rust › rust-on-stm32-2
Rust on STM32: Getting started - Bastelblog
December 1, 2024 - You can for example use arm-none-eabi-objcopy -O binary target/thumbv7m-none-eabi/release/blinky-rust blinky-rust.bin and then ls. Now you are ready to flash the controller with cargo flash. It should auto-detect your ST-Link and use it to program the microcontroller. You only have to specify the target chip (stm32f103C8).
Rust Embedded
docs.rust-embedded.org › book
Introduction - The Embedded Rust Book
This book will be using the STM32F3DISCOVERY development board from STMicroelectronics for the majority of the examples contained within.
Rust Documentation
doc.rust-lang.org › beta › embedded-book › intro › hardware.html
Hardware - The Embedded Rust Book
A word of caution: be careful if you want to apply external signals to the board. The microcontroller STM32F303VCT6 pins take a nominal voltage of 3.3 volts.
Embedded Rust
docs.rust-embedded.org › discovery
Choose Your Discovery - Rust Embedded
There are currently three versions of this book. All of them provide an introduction to microcontrollers and how to use Rust with them. Unless you need to work with a micro:bit v1 or an STM32F3 discovery board, it is strongly recommended that you use the latest book.
GitHub
github.com › rust-embedded › awesome-embedded-rust
GitHub - rust-embedded/awesome-embedded-rust: Curated list of resources for Embedded and Low-level development in the Rust programming language · GitHub
Building a sailing starter board with Rust (RTIC) A step-by-step story/guide to build STM32-based PCB and program it with Rust for fun and games. STM32F4xx with Embedded Rust at the HAL A blog containing a series of tutorials demonstrating the use of several peripherals through simple examples leveraging the stm32f4xx-hal crate.
Starred by 7.8K users
Forked by 467 users
Rust Programming Language
users.rust-lang.org › embedded
Guidance on the Compatibility of Rust with STM32F3 Microcontroller and Various Sensors/Device - embedded - The Rust Programming Language Forum
June 20, 2023 - I have experience with Rust but not with embedded technology. They have assigned me the task of researching whether the following sensors and devices can work with Rust and the STM32F3 microcontroller: Serial Module FTDI Basic MQ-4 Gas Detector AHT20, BMP280, F-28, DS18B20, AM2302, DHT22, AM2303, ...
GitHub
github.com › stm32-rs › stm32f4xx-hal
GitHub - stm32-rs/stm32f4xx-hal: A Rust embedded-hal HAL for all MCUs in the STM32 F4 family · GitHub
Starred by 676 users
Forked by 218 users
Languages Rust
Rust-classes
rust-classes.com › chapter_embedded
STM32F103 - Rust Development Classes
We'll be using the excellent embassy crate to program the STM32. The embassy crate is a framework for building concurrent firmware for embedded systems.
YouTube
youtube.com › watch
How to Embedded STM32 Rust - YouTube
Learning how to program my STM32 with the Rust programming language to meet President Biden’s national cybersecurity strategy listed in the February 2024 Bac...
Published March 29, 2024
Theembeddedrustacean
blog.theembeddedrustacean.com › 6-things-i-wish-i-knew-starting-with-embedded-rust
6 Things I Wish I Knew Starting with Embedded Rust
March 28, 2024 - From what I understand, the HALs built with the mebedded-hal as a basis seem to be the ones mainly adopted by the embedded working group. Additionally, I am not sure if the stm32-hal has any equivalent counterparts for other manufacturer devices. Having learned Rust the language followed by embedded Rust, I did feel a noticeable difference.
GitHub
github.com › stm32-rs › stm32f1xx-hal
GitHub - stm32-rs/stm32f1xx-hal: A Rust embedded-hal HAL impl for the STM32F1 family based on japarics stm32f103xx-hal · GitHub
A Rust embedded-hal HAL impl for the STM32F1 family based on japarics stm32f103xx-hal - stm32-rs/stm32f1xx-hal
Starred by 644 users
Forked by 190 users
Languages Rust