r/embedded • u/Rodrigodd_ • 5h ago
Embedded Rust from Scratch
https://rodrigodd.github.io/2026/12/05/rust-embedded-from-scratch.htmlI recently got a small microcontroller, and I thought it was a good opportunity to learn more about how ARM-based microcontrollers work under the hood and how Rust works on embedded devices. In this blog post, I go over how to implement a very basic example application in Rust from scratch, covering everything from runtime initialization to how to build memory-safe abstractions for peripherals.
Hopefully, preexisting knowledge of Rust is not required to follow the post.
1
Upvotes
1
u/Simple_Tough4223 1h ago
Nice post, and thanks for writing it from scratch. Most Rust embedded tutorials start with cortex-m-rt and a PAC, so it's good to see the linker script and runtime init explained step by step.
A few questions:
- For the safe PORT/HAL abstraction, how did you decide where unsafe stays? Is it only the register access, with the pin type-state on top of it?
- For the critical sections with the pin interrupts, did you just disable interrupts (PRIMASK), or something finer? On Cortex-M0+ there is no BASEPRI, so I'm curious how you share data between the ISR and main.
- Did you check the generated code with optimization on, to see how much the abstractions cost compared to writing the registers directly?
Looking forward to the rest of the series if you continue, e.g. UART or DMA on this board.