liveBook · Manning

Rust

As explained in Embedded Software with Rust

Rust is a systems programming language designed for memory safety, concurrency, and low-level control without requiring garbage collection.

Rust is a systems programming language suited to firmware that needs low-level control and memory safety. Its ownership and borrowing rules catch common memory-safety defects at compile time without a garbage collector. Result and Option make failure and absence explicit in types. section 1.1 section 1.1.1

Embedded devices often have tight Flash, RAM, and power budgets. Rust produces native code and permits control over allocation and lifetimes. In a no_std build, firmware can use Rust’s core crate without an operating system; startup, memory placement, and interrupt behavior then need explicit attention. section 1.0 section 1.1.2

Hardware access still requires care. Reading or writing an arbitrary memory-mapped address is unsafe, so Rust requires an explicit unsafe block. The programmer is responsible for correctness where the compiler cannot enforce safety guarantees. Volatile access, peripheral access crates, and hardware abstraction layers offer a progression from direct register access toward reusable APIs. section 5.2 section 5.0

#define SYST_CSR (*(volatile unsigned int *)0xE000E010)
#define SYST_RVR (*(volatile unsigned int *)0xE000E014)
#define SYST_CVR (*(volatile unsigned int *)0xE000E018)

void systick_init(void) {
    SYST_RVR = 8000000 - 1;   // Reload value for 1 s at 8 MHz
    SYST_CVR = 0;             // Clear current count
    SYST_CSR = 0x7;           // Enable counter, interrupt, core clock
}

This C SysTick example illustrates direct access to memory-mapped registers. Equivalent arbitrary-address access in Rust requires an explicit unsafe block. section 5.2

C and C++ also provide low-level control, but leave memory-safety responsibility to the developer. Go’s garbage collector and MicroPython’s interpreter add runtime costs that can be difficult to accommodate on small microcontrollers. Rust instead combines native code with compile-time safety checks, though resource use and timing still require attention. section 1.1.3 section 1.1.2

How Embedded Software with Rust covers it

How deep it goes
Explains compile-time safety and language trade-offs, then connects Rust to startup, memory-mapped I/O, unsafe access, and hardware abstractions.
Examples
Illustrates direct register access with a C SysTick initialization example before discussing Rust’s unsafe boundary.
What it assumes
Assumes familiarity with embedded programming while introducing Rust’s strengths for firmware development.
What you can do after
Builds no_std firmware for emulators and hardware, configuring startup and memory layouts and interacting with peripherals through drivers and abstractions.
How it connects
Connects ownership and borrowing to memory safety, and links unsafe code with volatile access and hardware abstraction layers.

Also explained in

Compare how 8 books explain Rust →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Embedded Software with Rust. The section links point to the parts of the book it draws on.