Chapter 1: The Foundations of embedded Rust development
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
- Rust for Dependable Firmware. Explain why Rust is presented as a timely choice for firmware on constrained, bare-metal devices.
- Compile-Time Safety Without Runtime Overhead. Explain how Rust challenges the traditional trade-off between control and safety in embedded firmware: it enforces memory safety at compile time without the runtime overhead described here as unsuitable for microcontrollers.
- Compile-time memory safety. Explain that Rust’s ownership and borrowing rules eliminate common memory-safety defects at compile time without a garbage collector, reducing potential firmware crashes.
- Predictable Rust resource use. Explain how Rust supports higher-level, safe designs while retaining predictable resource use.
- Minimal runtime performance. Describe the performance and footprint claims made for well-tuned no_std Rust.
- Rust’s embedded tradeoff. Explain why the section presents Rust as a strong fit for small, efficient firmware: it retains C-class size and control while enforcing safety at compile time and providing a modern ecosystem.
- Power-on reset sequence. Trace the hardware sequence from power-on or reset to the reset handler, including the two values the core fetches and their roles.
- Reset handler memory initialization. Explain how the reset handler prepares .data and .bss before user code runs, and why skipping that preparation makes behavior unreliable.
- Reset Handler Entry Handoff. Trace the handoff from the reset handler to user code after memory and the runtime environment are prepared. Describe how an embedded Rust function is designated as the program entry point.
- User Control Without Operating System. Explain what user code controls after entry and describe the two common ways the section says a program proceeds.
- Event handling and resumption. Trace what happens when a hardware event, timer, or fault condition interrupts running code, from the vector table to the resumption of that code.
- Shared state and race conditions. Explain why state accessed by both main code and an interrupt handler needs careful management, and name the kinds of Rust safeguards this section identifies.
- Bare-metal Rust dependencies. Explain what this book means by embedded Rust and which crates such firmware links instead of std.
- The no_std baseline. Explain that no_std omits std and its OS-backed facilities, while core still provides fundamental Rust types and capabilities.
- Heap allocation choices. Describe why common heap-allocating types need extra setup in no_std, and how static or fixed-capacity storage avoids that requirement.
- Bare-Metal Entry Point. Explain why ordinary fn main() is not a bare-metal entry point and how a no_std program takes control of startup.
- Explicit Panic Behavior. Explain why a bare-metal program supplies a non-returning panic handler and describe the kinds of behavior it may choose.
- Runtime crate startup responsibilities. Describe how cortex-m-rt and riscv-rt package early startup: placing a vector table, setting the initial stack pointer, initializing .data and .bss, and transferring control to an attribute-declared entry function. State that they also support interrupt and exception handlers with overridable defaults.
- Language-Level Resource Control. Explain that Rust’s language mechanics help keep control of embedded resources explicit and safe without relying on an operating system.
- Peripheral ownership and transfer. Explain how a peripheral handle controls access to a memory-mapped register block and how moving it transfers exclusive control to the code that drives the device.
- Temporary peripheral borrowing. Distinguish shared from mutable borrows of a peripheral handle and explain how the compiler prevents overlapping access that could leave two parts of a program controlling the same registers.
- Unique peripheral ownership. Explain how a peripheral is acquired once, moved to the module that needs it, and shared through methods or scoped borrows rather than duplicate handles.
- Type-state hardware configuration. Explain how a HAL represents a pin’s configured function in its type, so the compiler permits only operations appropriate to that function and requires reconfiguration before the pin is used differently.
- Interrupt and main code sharing. Explain why state accessed by both an interrupt handler and main code creates a concurrency problem, and why Rust requires that sharing to be controlled explicitly.
- Critical section access permission. Describe how a short critical section controls access to shared state in a simple case.
- Platform focus and portability. Explain why the book primarily uses Arm Cortex-M and how its selected RISC-V examples serve the broader aim of teaching methods that transfer across hardware.
- Cortex-M platform focus. Explain why examples default to Cortex-M microcontrollers, citing their widespread use and suitability for low-power, real-time applications.
- Portable Practices and Target Details. Distinguish the practices the section says transfer across architectures from target-specific details, and explain why isolating those details preserves the surrounding method.
- Boundaries of book coverage. Describe the topics and platform-specific comparisons the book does not attempt to cover.
- Build-first learning approach. Explain how the book teaches embedded Rust through working examples and small, focused iterations, with explanations directed toward dependable firmware. Describe how the provided virtual machine lets readers follow along without spending time on host setup.
- Incremental cross-target examples. Describe how the book builds examples one idea at a time, presents target-neutral concepts before Cortex-M and RISC-V variants, and explains any unsafe code in context.
- Preconfigured firmware workspace. Explain why the book provides a pre-configured virtual machine and what readers can do with it.
- Expected reader background. Describe the Rust and microcontroller knowledge expected of readers, and distinguish it from optional embedded C experience.
- Board Choice and Debugging Tradeoff. Explain why the Blue-Pill is favored for experienced embedded developers while a NUCLEO board is preferred for beginners, including the debugging difference.
- Host setup and target selection. Describe the choice between the pre-configured virtual machine and installing Rust on a host system, and state which OS-free target family to add for Arm Cortex-M or RISC-V.
- Emulator-first development choice. Explain why the section recommends starting with an emulator even though the examples are designed for hardware boards, and name the suggested options for exploring the early sections.
- Basic interactive debug path. Describe the common hardware setup for interactive debugging and explain how the same debug ideas apply when using only an emulator.
Section by section
Introduction
Introduces embedded systems and explains why Rust’s safety guarantees matter for dependable firmware on constrained hardware.
- Embedded Systems and Physical Control: Describe how embedded systems sense and act on the physical world, and why failures in some embedded applications can cause harm.
Why it matters: The physical consequences of firmware failures explain why dependability matters here. - Rust for Dependable Firmware: Explain why Rust is presented as a timely choice for firmware on constrained, bare-metal devices.
Why it matters: It connects Rust’s safety strengths to the constraints and risks of real firmware.
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.
- Compile-Time Safety Without Runtime Overhead: Explain how Rust challenges the traditional trade-off between control and safety in embedded firmware: it enforces memory safety at compile time without the runtime overhead described here as unsuitable for microcontrollers.
Why it matters: This explains why Rust is presented as a practical choice for microcontrollers, not just a safer language.
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.
- Compile-time memory safety: Explain that Rust’s ownership and borrowing rules eliminate common memory-safety defects at compile time without a garbage collector, reducing potential firmware crashes.
Why it matters: Preventing memory defects before deployment can reduce hard-to-find firmware failures. - Explicit failure handling: Describe how Result and Option make failure behavior explicit, and why the section connects this reliability to fewer field failures and lower verification costs in safety-critical contexts.
Why it matters: Explicit failure behavior helps explain why reliability matters beyond preventing memory defects.
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.
- Embedded resource constraints: Explain how physical and resource limits affect embedded software choices.
Why it matters: These limits explain why predictable resource use matters in embedded development. - Predictable Rust resource use: Explain how Rust supports higher-level, safe designs while retaining predictable resource use.
Why it matters: It connects Rust’s safety and structure to the resource predictability embedded systems need. - Minimal runtime performance: Describe the performance and footprint claims made for well-tuned no_std Rust.
Why it matters: It explains why using Rust abstractions need not impose a large performance or binary-size penalty on a microcontroller.
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.
- Rust’s embedded tradeoff: Explain why the section presents Rust as a strong fit for small, efficient firmware: it retains C-class size and control while enforcing safety at compile time and providing a modern ecosystem.
Why it matters: This is the central tradeoff behind the section’s case for embedded Rust. - Manual safety in C and Zig: Distinguish Rust’s compile-time safety checks from the developer-managed memory safety described for C, C++, and Zig.
Why it matters: Low-level control alone does not explain where responsibility for preventing memory bugs falls. - Runtime costs of alternatives: Explain why the section contrasts Go’s garbage collector and MicroPython’s interpreter with Rust’s collector-free native code for constrained firmware.
Why it matters: On constrained or real-time hardware, the runtime cost of a language choice can matter as much as developer productivity.
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.
- Power-on reset sequence: Trace the hardware sequence from power-on or reset to the reset handler, including the two values the core fetches and their roles.
Why it matters: This predictable, self-contained start gives embedded code a known point from which to begin.
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.
- Reset handler memory initialization: Explain how the reset handler prepares .data and .bss before user code runs, and why skipping that preparation makes behavior unreliable.
Why it matters: Even correct application logic depends on memory having the expected values at startup. - Interrupt dispatch startup preparation: Describe the other startup preparation mentioned here: the reset handler establishes a known vector table location and may perform basic hardware setup.
Why it matters: Startup must prepare more than variable values for the device to handle exceptions and interrupts correctly.
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.
- Reset Handler Entry Handoff: Trace the handoff from the reset handler to user code after memory and the runtime environment are prepared. Describe how an embedded Rust function is designated as the program entry point.
Why it matters: This handoff marks where startup ends and the application takes control. - User Control Without Operating System: Explain what user code controls after entry and describe the two common ways the section says a program proceeds.
Why it matters: It explains why an embedded application must account for hardware behavior that an operating system might otherwise manage.
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.
- Event handling and resumption: Trace what happens when a hardware event, timer, or fault condition interrupts running code, from the vector table to the resumption of that code.
Why it matters: This explains how a processor can respond to an event without abandoning the code it was running. - Shared state and race conditions: Explain why state accessed by both main code and an interrupt handler needs careful management, and name the kinds of Rust safeguards this section identifies.
Why it matters: Sharing data safely matters because a handler can interrupt code that uses the same state.
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.
- Bare-metal Rust dependencies: Explain what this book means by embedded Rust and which crates such firmware links instead of std.
Why it matters: This definition sets the scope for the book’s bare-metal examples.
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.
- The no_std baseline: Explain that no_std omits std and its OS-backed facilities, while core still provides fundamental Rust types and capabilities.
Why it matters: This distinction clarifies which familiar Rust features remain available in a bare-metal program. - Heap allocation choices: Describe why common heap-allocating types need extra setup in no_std, and how static or fixed-capacity storage avoids that requirement.
Why it matters: It explains why ordinary collection code may fail to compile for an embedded target and what choices the section offers.
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.
- Bare-Metal Entry Point: Explain why ordinary fn main() is not a bare-metal entry point and how a no_std program takes control of startup.
Why it matters: A custom entry point avoids startup code and assumptions that may not work on a microcontroller. - Explicit Panic Behavior: Explain why a bare-metal program supplies a non-returning panic handler and describe the kinds of behavior it may choose.
Why it matters: Defining panic behavior makes failures predictable on a target without hosted error handling.
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.
- Runtime crate startup responsibilities: Describe how cortex-m-rt and riscv-rt package early startup: placing a vector table, setting the initial stack pointer, initializing .data and .bss, and transferring control to an attribute-declared entry function. State that they also support interrupt and exception handlers with overridable defaults.
Why it matters: It explains what the runtime crate does before your application begins. - Runtime defaults and extension points: Explain why a generic runtime crate is usually sufficient for common single-image firmware and how non-standard projects can extend its setup rather than abandon it. Give examples of the available customizations without detailing their implementation.
Why it matters: It helps you distinguish using a runtime crate from being locked into every one of its defaults.
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.
- Language-Level Resource Control: Explain that Rust’s language mechanics help keep control of embedded resources explicit and safe without relying on an operating system.
Why it matters: This is the connection between Rust’s language features and safe resource control that the following sections develop.
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.
- Peripheral ownership and transfer: Explain how a peripheral handle controls access to a memory-mapped register block and how moving it transfers exclusive control to the code that drives the device.
Why it matters: Transferring the handle makes it clear which code is responsible for configuring and driving a device. - Temporary peripheral borrowing: Distinguish shared from mutable borrows of a peripheral handle and explain how the compiler prevents overlapping access that could leave two parts of a program controlling the same registers.
Why it matters: Short-lived borrows let helpers use a device without silently creating conflicting access to its registers.
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.
- Unique peripheral ownership: Explain how a peripheral is acquired once, moved to the module that needs it, and shared through methods or scoped borrows rather than duplicate handles.
Why it matters: Unique ownership makes it harder for separate parts of firmware to access the same hardware unexpectedly.
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.
- Type-state hardware configuration: Explain how a HAL represents a pin’s configured function in its type, so the compiler permits only operations appropriate to that function and requires reconfiguration before the pin is used differently.
Why it matters: Encoding configuration in a pin’s type can catch mistakes before they become hard-to-debug failures on the device.
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.
- Interrupt and main code sharing: Explain why state accessed by both an interrupt handler and main code creates a concurrency problem, and why Rust requires that sharing to be controlled explicitly.
Why it matters: Recognizing the shared-state problem explains why interrupt code cannot simply use main code’s data without coordination. - Critical section access permission: Describe how a short critical section controls access to shared state in a simple case.
Why it matters: The temporary permission connects a hardware protection step to a rule the compiler can enforce. - Framework and async sharing rules: Distinguish the approaches sketched for RTIC and Embassy, and explain their shared principle for accessing devices across contexts.
Why it matters: These examples show that different concurrency styles still rely on explicit rules for who may use a resource.
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.
- Platform focus and portability: Explain why the book primarily uses Arm Cortex-M and how its selected RISC-V examples serve the broader aim of teaching methods that transfer across hardware.
Why it matters: This focus helps you see which lessons are meant to carry beyond a particular board.
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.
- Cortex-M platform focus: Explain why examples default to Cortex-M microcontrollers, citing their widespread use and suitability for low-power, real-time applications.
Why it matters: This explains why the examples use Cortex-M without implying that embedded Rust is limited to it. - Cross-architecture explanation approach: Describe how the book presents core-dependent concepts and handles material differences on RISC-V.
Why it matters: This helps readers separate a general embedded concept from the platform-specific code used to demonstrate it.
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.
- Portable Practices and Target Details: Distinguish the practices the section says transfer across architectures from target-specific details, and explain why isolating those details preserves the surrounding method.
Why it matters: It helps you recognize which parts of an embedded Rust approach you can reuse on another architecture.
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.
- Boundaries of book coverage: Describe the topics and platform-specific comparisons the book does not attempt to cover.
Why it matters: These boundaries help you judge what detail to expect from the book.
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.
- Build-first learning approach: Explain how the book teaches embedded Rust through working examples and small, focused iterations, with explanations directed toward dependable firmware. Describe how the provided virtual machine lets readers follow along without spending time on host setup.
Why it matters: This tells you what to expect from the examples and how to follow them without first configuring your host.
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.
- Incremental cross-target examples: Describe how the book builds examples one idea at a time, presents target-neutral concepts before Cortex-M and RISC-V variants, and explains any unsafe code in context.
Why it matters: This approach helps you separate a general concept from the details of a particular board or architecture.
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.
- Preconfigured firmware workspace: Explain why the book provides a pre-configured virtual machine and what readers can do with it.
Why it matters: The VM lets you concentrate on the firmware examples instead of configuring your host first. - Host-specific VM packages: Distinguish the VM package and virtualization option provided for Intel or AMD systems from those provided for Apple Silicon Macs.
Why it matters: Choosing the package for your host gives you the right starting point for the supplied VM instructions.
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.
- Expected reader background: Describe the Rust and microcontroller knowledge expected of readers, and distinguish it from optional embedded C experience.
Why it matters: This helps you tell which background the book assumes and which experience is optional. - Background and example support: Explain how the book helps when background is needed and what it says about its listings and commands.
Why it matters: You can use the section references to fill gaps and follow commands as printed.
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.
- Basic Follow-Along Requirements: State the basic toolchain, target, execution, and debugging resources used to follow the book.
Why it matters: These are the resources to plan for before working through the examples. - Board Choice and Debugging Tradeoff: Explain why the Blue-Pill is favored for experienced embedded developers while a NUCLEO board is preferred for beginners, including the debugging difference.
Why it matters: The onboard adapter changes what a reader needs to buy and set up to debug the examples.
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.
- Host setup and target selection: Describe the choice between the pre-configured virtual machine and installing Rust on a host system, and state which OS-free target family to add for Arm Cortex-M or RISC-V.
Why it matters: Choosing the target that matches the board or emulator is part of preparing to build embedded code. - Recommended build and debug toolkit: Describe the roles assigned here to rustup, cargo, a debugger, and an on-chip debug server or probe.
Why it matters: These distinct tool roles give you a practical checklist for preparing an embedded development environment.
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.
- Emulator-first development choice: Explain why the section recommends starting with an emulator even though the examples are designed for hardware boards, and name the suggested options for exploring the early sections.
Why it matters: Emulation lets you begin learning without first resolving problems with cables, wiring, adapters, or drivers. - Hardware and emulation costs: Describe the rough cost difference between using an emulator alone and buying a development board, including when an external probe adds expense.
Why it matters: The cost comparison helps you decide whether to begin virtually or assemble a physical setup.
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.
- Basic interactive debug path: Describe the common hardware setup for interactive debugging and explain how the same debug ideas apply when using only an emulator.
Why it matters: This tells you what kind of connection you need before doing interactive debugging on a board or in an emulator.
Key terms: debug adapter, SWD, JTAG, OpenOCD, gdb, emulator front end
1.7.4 Downloadable content
1.8 Summary
Where this is used later
- What are memory-mapped I/Os in a microcontroller? (chapter 5) · Provides context for the discussion of memory-mapped I/O.
- The three memory regions of an embedded Rust program (chapter 7) · Provides the motivation for examining where an embedded program uses memory.
- A detailed look at reset vector fetching and execution (chapter 4) · A detailed account of reset vector fetching builds on this startup sequence.
- Writing a minimal startup routine in Rust (chapter 4) · The minimal startup routine implements this memory preparation.
- Memory initialization: LMA, VMA, and data movement (chapter 4) · Minimal runtime setup before transfer to user code.
- Manually creating a vector table in Rust (chapter 4) · Vector-table setup is examined in more detail.
- Defining the reset handler (chapter 4) · The reset handler is defined in detail.
- Defining a custom entry point function (chapter 4) · A custom entry point function is defined.
Concepts explained in this chapter
- no_std programno_std is a Rust crate configuration that excludes the standard library.
- interrupt handlerAn interrupt handler is a routine invoked asynchronously in response to a hardware or software interrupt.
- RustRust is a systems programming language designed for memory safety, concurrency, and low-level control without requiring garbage collection.
- microcontrollerA microcontroller is an integrated computing device that combines a processor, memory, and peripherals for dedicated embedded control tasks.
- memory safetyMemory safety is the property that software accesses memory only in valid ways, preventing errors such as use-after-free and out-of-bounds access.
- execution environmentA runtime environment is the collection of execution support, hardware state, and software facilities available to a running program.
- hardware abstraction layerA hardware abstraction layer is a software interface that represents hardware peripherals while hiding device-specific implementation details.
- core libraryRust's core crate provides fundamental types, traits, and APIs without depending on an operating system or heap.
- Arm Cortex-MArm Cortex-M is a family of energy-efficient processor cores designed primarily for microcontrollers and embedded systems.
- linker scriptA linker script is a script that directs a linker when arranging input sections and assigning addresses in an output image.
- emulationEmulation is the reproduction of a target system's behavior so software can run or be tested without the original hardware.
- embedded RustEmbedded Rust is the practice of developing firmware for embedded or bare-metal targets using Rust.
- bare-metal targetA bare-metal target is an execution platform on which software runs directly on hardware without an operating system.
- interrupt vector tableA table of memory addresses that supplies the initial stack pointer and exception or interrupt handler addresses used by a processor.
- reset handlerA reset handler is the startup routine executed after a processor reset to initialize execution and transfer control to application code.
- entry pointThe function or location at which execution begins for a program or runtime path.
- device driverA device driver is software that presents an interface for controlling and communicating with a hardware device.
- critical-sectionA Rust crate that provides a portable abstraction for entering and executing code within critical sections.
- interruptAn interrupt is a hardware or software event that requests processor attention and can trigger execution of an associated handler.
- panic handlerA panic handler is the Rust-defined function that determines how a panic is handled in a target without the hosted panic runtime.
- alloc crateRust’s allocation library, providing heap-allocated collections and related types when an allocator is available.
- bss sectionThe .bss section represents zero-initialized or uninitialized static storage that is cleared during startup.
- data sectionThe .data section contains initialized writable data whose initial values are copied to writable memory during startup.
- fixed-capacity structureA fixed-capacity container is a container whose maximum number of stored elements is bounded in advance and whose storage can be provided without dynamic allocation.
- global allocatorThe program-wide provider used to allocate and release heap memory.
- heapA heap is a region of dynamically managed memory used for runtime allocation.
- runtime crateA runtime crate supplies target-specific startup and exception-handling support for an embedded application.
- peripheralA peripheral is a hardware component connected to a processor that provides a specialized input, output, communication, timing, or control function.
- memory layoutA memory layout specifies the placement of a program's code, data, stack, and other regions in memory.
- type stateThe typestate pattern represents an object's state in its type so that operations can be restricted to valid states at compile time.
- cortex-m-rtcortex-m-rt is a Rust runtime crate that provides startup and exception-handling support for Cortex-M microcontrollers.
- Peripherals::take()Peripherals::take() is a singleton-acquisition function that returns exclusive access to a device's peripheral handles when they have not already been taken.
- CargoCargo is Rust's package manager and build system, providing dependency management, compilation, testing, and related project workflows.
- peripheral handleA peripheral handle is an owning value that grants exclusive software control over a peripheral's memory-mapped registers.
- flash memoryFlash memory is nonvolatile semiconductor memory that retains data without power and can be electrically erased and rewritten.
- QEMUQEMU is an open-source machine emulator and virtualizer capable of emulating processors and complete computer systems.
- main stack pointerMSP is the Cortex-M Main Stack Pointer system register holding the active main-stack address.
- compiler intrinsicAn intrinsic function is a compiler- or architecture-provided function that exposes a low-level operation with direct correspondence to machine instructions.
- static storageMemory whose allocation persists for the entire execution of a program.
- stringA string is a sequence of characters represented as data.
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.
