Rust for embedded development


How well suited Rust is for embedded development? Specifically a project for the nRF51-DK board.

How is the toolchain support (compilers, debugging, etc.) for ARM controllers?

How is the size of a program in Rust compared to one written in C (for embedded platforms)?


There’s a lot of threads on here in general, if you search from them, you’ll find many things.

is a group of people working on making this stuff not just possible, but awesome :smile:


I’ve been working on rust for the cc3200 (Cortex-M4) so similar but not identical to what you’re doing.

My gut tells me that the code size is similar, or perhaps a bit larger. Stack usage can be considerably higher, especially if you do any type of formatted printing output. And you don’t seem to have quite the granularity that you have using a traditional C/Makefile system (i.e. with make buildsystem I can compile most of the system using -Os and the stuff I want to debug with -O0). With cargo, I can’t seem to do that yet.

I’m also currently working on the nrf51822, although my initial foray has been using C and C++. Once I have all of that working, I’m going to take a look at doing the same thing in rust to see how it compares.

It looks like the rust embedded link is primarily for rust on embedded linux. For bare metal stuff, I highly recommend: and you should probably look at as well.


Managing your own rust toolchain is a pleasant experience with xargo. Depending on your platform you may need to create your own LLVM target file which can be an endeavor the first time. The same author of xargo wrote a good cross compilation guide here.

The primary problem I ran into using rust on ARM was avoiding compiler-rt symbols. It has little/no support for ARM and you will have to define some symbols yourself. I’m collecting them as needed here. Also: #![no_builtins].