Close

Embedded Rust

A project log for Adventures in Rust

I decided to find out what the deal is with the Rust programming language

ken-yapKen Yap 02/04/2024 at 10:260 Comments

As you might guess, the strong guarantees the Rust provide can improve the reliability of bare-metal software. In fact this was one of my original motivations, to use Rust for embedded projects.

Embedded support exists for various platforms. Your 8 or 16-bitter won't be supported by Rust*, but 32-bitters are not a problem, provided the toolchain exists. STM32, Cortex and RISC-V have support, as does the classic ESP32 using the Espressif tools. The newer ESP32-C3 is RISC-V based. Apparently an upstream merge of the Espressif compiler to the mainstream is expected. Since Rust uses LLVM compiler technology, these are the architectures supported: https://docs.rust-embedded.org/embedonomicon/compiler-support.html

* But there appears to be an AVR support project.

Rust has the #![no_std] crate attribute which indicates that the crate uses the core crate instead of the std crate which assumes an OS underneath. This rules out a lot of very convenient crates, so some searching and experimentation is required.

Here are some links:

From the horse's mouth: https://www.rust-lang.org/what/embedded

An online book: https://docs.rust-embedded.org/book/

About #![no_std]: https://docs.rust-embedded.org/book/intro/no-std.html

Also have a look at Wokwi which supports Rust for their simulated IoT platforms: https://wokwi.com/

A page with useful tips for getting started with Rust on ESP-32: https://nereux.blog/posts/getting-started-esp32-nostd/

Discussions