Embedded Rust Development

~10 min

Embedded Development Options

Bare Metal RTOS OS-based

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

"The Rust Standard Library is the foundation of portable Rust software, a set of minimal and battle-tested shared abstractions for the broader Rust ecosystem. It offers core types, like 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 Rust Core Library is the dependency-free foundation of The Rust Standard Library. It is the portable glue between the language and its libraries, defining the intrinsic and primitive building blocks of all Rust code. It links to no upstream libraries, no system libraries, and no libc.

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.