Embedded Rust Development
~10 min
Embedded Development Options
Bare Metal — Direct hardware access with no OS. Maximum determinism and minimal overhead, but you manage everything yourself. Best for simple, resource-constrained, or timing-critical applications.
RTOS — A lightweight real-time operating system provides task scheduling and timing guarantees. Adds some overhead but enables multitasking with predictable behavior. Suited for applications requiring multiple concurrent tasks with real-time constraints.
Embedded OS — A full operating system (e.g., Linux) running on the device. Highest overhead and lowest determinism, but provides rich functionality (networking, filesystems, drivers). Requires more capable hardware.
In this workshop, we'll be doing bare metal Rust.
Development with the Standard Library
Vec<T> and Option<T>, library-defined operations on language primitives, standard macros, I/O and multithreading, among many other things."
Source: https://doc.rust-lang.org/std/
"Out of the Box" Rust is based on the Standard Library. It depends on system primitives provided by the OS system interface to implement functionality. It provides a runtime that sets up stack overflow protection, processes command-line arguments, and spawns the main thread. RTOS and Embedded OS can support it, but not bare metal.
Development with the Core Library
The core library is minimal: it isn't even aware of heap allocation, nor does it provide concurrency or I/O. These things require platform integration, and this library is platform-agnostic."
Source: https://doc.rust-lang.org/core/
The Core Library is a platform-agnostic subset of the Standard Library. It makes no assumptions about the underlying system and is necessary for bare metal implementations.
ESP supports both approaches. The std approach relies on the ESP-IDF framework, which has an underlying RTOS, through the esp-idf-hal crate — note that this is community supported only. In this workshop, we will be doing core (bare metal) development using the esp-hal, which is officially supported by Espressif.