liveBook · Manning

Chapter 1: The Foundations of embedded Rust development

What you will learn in chapter 1 of Embedded Software with Rust

Introduces embedded systems and explains why Rust’s safety guarantees matter for dependable firmware on constrained hardware.

After this chapter you will be able to

Section by section

Introduction

Introduces embedded systems and explains why Rust’s safety guarantees matter for dependable firmware on constrained hardware.

Key terms: embedded systems, sensors, actuators, memory-mapped peripherals, safety-critical functions, compile-time guarantees, bare metal, memory safety, concurrency correctness, register level control

1.1 Why embedded Rust? Benefits and adoption

The section explains why Rust’s compile-time memory safety is attractive for resource-constrained embedded firmware.

Key terms: memory safety, compile time, runtime overhead, resource budgets, predictable timing

1.1.1 Compile-time safety and reliability

Explains how Rust’s compile-time memory safety and explicit error handling can make embedded firmware more reliable.

Key terms: ownership, borrowing, compile-time, garbage collector, Result, Option, type-based error handling, field failures, verification costs

1.1.2 Constraints, Determinism, and Performance

This section explains how embedded resource limits shape software design and why Rust can meet those limits without sacrificing predictable performance.

Key terms: Flash, RAM, power budgets, allocation, lifetimes, redundant copying, hidden dynamic behavior, no_std, zero-cost abstractions, core

1.1.3 How Rust compares to other approaches

Compares Rust with other embedded-language approaches to show how it combines small, controllable firmware with compile-time safety.

Key terms: compile time, size and control profile, modern ecosystem, pointer aliasing, lifetime, borrow checker, type system, garbage collector, deterministic timing, interpreter

1.2 Rust execution sequence: From reset to main

Introduces the reset-to-main sequence as context for understanding how an embedded Rust program begins, without explaining its steps yet.

1.2.1 Power on and reset (steps 1 to 2)

Explains how a microcontroller starts executing its reset handler after power-on or reset.

Key terms: main stack pointer, reset vector, reset handler

1.2.2 Minimal runtime setup (step 2 to 4)

The reset handler prepares memory and essential hardware state before user code runs.

Key terms: reset handler, .data, .bss, non-volatile memory, RAM, vector table, exceptions, interrupts, clock domain, memory protection

1.2.3 Transfer to user code (step 5 and 6)

This section explains how the reset handler hands control to user code and why that code directs hardware behavior without an operating system.

Key terms: reset handler, program entry point, entry, main control flow, main loop, executor, peripherals, power management

1.2.4 Exceptions and interrupts at a glance (step 7)

This section sketches how the processor handles interrupts and exceptions, and why sharing state with handlers requires care.

Key terms: vector table, handler function, register context, current stack, main context, interrupt handler, race conditions, ownership and borrowing, synchronization primitives

1.3 What is non-standard library Rust?

Defines embedded Rust in this book as bare-metal firmware without the standard library and identifies the crates it uses instead.

Key terms: bare-metal firmware, std, core crate, alloc crate, global allocator, startup or runtime crate

1.3.1 What no_std excludes and what core provides

This section explains what a no_std build removes, what core retains, and how embedded programs handle types that need heap allocation.

Key terms: no_std, std, core, alloc, global allocator, Vec<u8>, statically allocated Rust array, fixed-capacity structures

1.3.2 Entry and panic requirements

This section explains why a bare-metal no_std program must define its own entry point and panic behavior instead of relying on hosted Rust runtime facilities.

Key terms: fn main(), no_std, ENTRY, _start, #[panic_handler], hosted unwinder, watchdog

1.3.3 What minimal runtime crates initialize

Minimal runtime crates handle common bare-metal startup work while leaving extension points for firmware with non-standard needs.

Key terms: cortex-m-rt, riscv-rt, vector table, initial stack pointer, .data, .bss, single-image firmware, extension points, linker script, memory.x

1.4 Core Rust features in embedded context

This introduction connects Rust’s core language mechanics to explicit, safe control of embedded resources without an operating system.

Key terms: ownership and borrowing, peripherals, construction-time singletons, type-state APIs, interrupts, async tasks

1.4.1 Ownership and borrowing for hardware resources

The section shows how Rust ownership and borrowing control access to finite hardware peripherals and prevent conflicting register access.

Key terms: peripheral handle, ownership, memory-mapped register block, moving, borrowing, shared reference, mutable reference, peripheral registers

1.4.2 The singleton pattern for peripherals

This section explains how Rust gives each hardware peripheral a single owner and allows other code to use it without creating another owner.

Key terms: singleton pattern, Peripherals::take(), non-Copy handles, scoped borrows

1.4.3 Type-enforced hardware correctness

This section explains how HALs use Rust’s type system to make invalid peripheral use a compile-time error rather than a hardware failure.

Key terms: type-state pattern, HAL, peripheral configuration, traits, Pin<RxMode>

1.4.4 Concurrency preview: Interrupts, sharing, and async

The section explains why concurrent microcontroller code needs explicit sharing rules and sketches how critical sections, frameworks, and async drivers preserve controlled access.

Key terms: interrupt handler, shared state, data races, synchronization mechanism, critical section, permission, RTIC, Embassy, async executors, await point

1.5 Scope and audience: architectures and examples

Sets the book’s hardware focus and explains why its examples emphasize transferable methods.

Key terms: Arm Cortex-M, RISC-V, portability

1.5.1 Platform focus

The section explains why the book defaults to Cortex-M microcontrollers and how it handles concepts that vary across architectures.

Key terms: Cortex-M, MCU, NVIC, core neutral, Cortex-M specifics, RISC-V, minimal variant

1.5.2 What transfers across architectures

The subsection distinguishes embedded Rust practices that carry across architectures from target-specific details that must be isolated.

Key terms: no_std, ownership based resource control, singleton approach, interrupt safe data sharing, hardware abstraction layers, Cargo

1.5.3 What is out of scope

This section sets boundaries on the topics and platform-specific comparisons the book covers.

Key terms: vendor integrated development environments, board family, operating system level topics, linker scripts, memory controllers

1.6 How this book teaches

The section explains the book’s build-first teaching approach and how its virtual machine helps readers follow along.

Key terms: build first approach, working context, small focused iterations, virtual machine

1.6.1 Teaching strategy

This section explains how the book uses runnable, incremental examples to teach concepts across targets while making unsafe code explicit.

Key terms: emulator, Cortex-M, RISC-V, unsafe

1.6.2 Using the virtual machine and code

This section explains how the book’s pre-configured virtual machine lets readers start working with firmware and which VM package to use for their host computer.

Key terms: pre-configured virtual machine, Rust toolchain, example projects, emulator, .ova appliance, Oracle VirtualBox, VMware, UTM, .qcow2 disk image

1.6.3 Reader support

This section states the reader’s expected background and explains how the book supports readers with references and tested examples.

Key terms: rustup, cargo, ownership and borrowing, traits, modules, flash, stable toolchain, listings, commands

1.6.4 What you will be able to do by the end

The section lists the embedded Rust capabilities readers are expected to gain by the end of the book.

1.7 What you need to follow along

This section identifies the basic tools and execution options for following the book and recommends development boards based on the reader’s experience and debugging needs.

Key terms: stable Rust toolchain, embedded targets, emulator, development board, debug path, STM32 Blue-Pill, STM32 NUCLEO, STM32 NUCLEO-F103RB, on-board debug adapter, ST-Link v2

1.7.1 Toolchain and targets

This section identifies the setup options, architecture-specific targets, and tools needed to follow the embedded Rust examples.

Key terms: pre-configured virtual machine, rustup, thumb target, riscv32 target, cargo, gdb, gdb-multiarch, OpenOCD, on-chip debug server

1.7.2 Hardware or emulator?

This subsection recommends starting embedded development with an emulator to avoid hardware setup problems and compares the costs of emulation and physical boards.

Key terms: instruction-set simulator, emulator, QEMU, PICSimLab, integrated probe, external SWD or JTAG probe, development board

1.7.3 Debug and flash path

Identifies the basic hardware or emulator path needed for interactive debugging.

Key terms: debug adapter, SWD, JTAG, OpenOCD, gdb, emulator front end

1.7.4 Downloadable content

1.8 Summary

Where this is used later

Concepts explained in this chapter

Chapter 2: Setting up your Rust tool-chain →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.