docs.rust-embedded.org
Introduction Welcome to The Embedded Rust Book: An introductory book about using the Rust Programming Language on "Bare Metal" embedded systems, such as Microcontrollers. Who Embedded Rust is For Embedded Rust is for everyone who wants to d...
The Embedded Rust Book
Book
2024-01-01
~4 min read
docs.rust-embedded.org
Meet Your Hardware Let's get familiar with the hardware we'll be working with. STM32F3DISCOVERY (the "F3") What does this board contain? • A STM32F303VCT6 microcontroller. This microcontroller has • A single-core ARM Cortex-M4F processor wi...
The Embedded Rust Book
Book
2024-01-01
~1 min read
docs.rust-embedded.org
A no_std Rust Environment The term Embedded Programming is used for a wide range of different classes of programming. Ranging from programming 8-Bit MCUs (like the ST72325xx) with just a few KB of RAM and ROM, up to systems like the Raspber...
The Embedded Rust Book
Book
2024-01-01
~2 min read
docs.rust-embedded.org
Tooling Dealing with microcontrollers involves using several different tools as we'll be dealing with an architecture different than your laptop's and we'll have to run and debug programs on a remote device. We'll use all the tools listed b...
The Embedded Rust Book
Book
2024-01-01
~6 min read
docs.rust-embedded.org
Installing the tools This page contains OS-agnostic installation instructions for a few of the tools: Rust Toolchain Install rustup by following the instructions at https://rustup.rs. NOTE Make sure you have a compiler version equal to or n...
The Embedded Rust Book
Book
2024-01-01
~1 min read
docs.rust-embedded.org
Linux Here are the installation commands for a few Linux distributions. Packages • Ubuntu 18.04 or newer / Debian stretch or newer NOTE gdb-multiarch is the GDB command you'll use to debug your ARM Cortex-M programs sudo apt install gdb-mul...
The Embedded Rust Book
Book
2024-01-01
~1 min read
docs.rust-embedded.org
macOS All the tools can be installed using Homebrew or MacPorts: Install tools with Homebrew $ # GDB $ brew install arm-none-eabi-gdb $ # OpenOCD $ brew install openocd $ # QEMU $ brew install qemu NOTE If OpenOCD crashes you may need to in...
The Embedded Rust Book
Book
2024-01-01
~1 min read
docs.rust-embedded.org
Windows arm-none-eabi-gdb ARM provides .exe installers for Windows. Grab one from here, and follow the instructions. Just before the installation process finishes tick/select the "Add path to environment variable" option. Then verify that t...
The Embedded Rust Book
Book
2024-01-01
~1 min read
docs.rust-embedded.org
Verify Installation In this section we check that some of the required tools / drivers have been correctly installed and configured. Connect your laptop / PC to the discovery board using a Mini-USB USB cable. The discovery board has two USB...
The Embedded Rust Book
Book
2024-01-01
~2 min read
docs.rust-embedded.org
Getting Started In this section we'll walk you through the process of writing, building, flashing and debugging embedded programs. You will be able to try most of the examples without any special hardware as we will show you the basics usin...
The Embedded Rust Book
Book
2024-01-01
~1 min read
docs.rust-embedded.org
QEMU We'll start writing a program for the LM3S6965, a Cortex-M3 microcontroller. We have chosen this as our initial target because it can be emulated using QEMU so you don't need to fiddle with hardware in this section and we can focus on...
The Embedded Rust Book
Book
2024-01-01
~12 min read
docs.rust-embedded.org
Hardware By now you should be somewhat familiar with the tooling and the development process. In this section we'll switch to real hardware; the process will remain largely the same. Let's dive in. Know your hardware Before we begin you nee...
The Embedded Rust Book
Book
2024-01-01
~7 min read
docs.rust-embedded.org
Memory Mapped Registers Embedded systems can only get so far by executing normal Rust code and moving data around in RAM. If we want to get any information into or out of our system (be that blinking an LED, detecting a button press or comm...
The Embedded Rust Book
Book
2024-01-01
~8 min read
docs.rust-embedded.org
Semihosting Semihosting is a mechanism that lets embedded devices do I/O on the host and is mainly used to log messages to the host console. Semihosting requires a debug session and pretty much nothing else (no extra wires!) so it's super c...
The Embedded Rust Book
Book
2024-01-01
~2 min read
docs.rust-embedded.org
Panicking Panicking is a core part of the Rust language. Built-in operations like indexing are runtime checked for memory safety. When out of bounds indexing is attempted this results in a panic. In the standard library panicking has a defi...
The Embedded Rust Book
Book
2024-01-01
~2 min read
docs.rust-embedded.org
Exceptions Exceptions, and interrupts, are a hardware mechanism by which the processor handles asynchronous events and fatal errors (e.g. executing an invalid instruction). Exceptions imply preemption and involve exception handlers, subrout...
The Embedded Rust Book
Book
2024-01-01
~6 min read
docs.rust-embedded.org
Interrupts Interrupts differ from exceptions in a variety of ways but their operation and use is largely similar and they are also handled by the same interrupt controller. Whereas exceptions are defined by the Cortex-M architecture, interr...
The Embedded Rust Book
Book
2024-01-01
~2 min read
docs.rust-embedded.org
Peripherals What are Peripherals? Most Microcontrollers have more than just a CPU, RAM, or Flash Memory - they contain sections of silicon which are used for interacting with systems outside of the microcontroller, as well as directly and i...
The Embedded Rust Book
Book
2024-01-01
~3 min read
docs.rust-embedded.org
A First Attempt The Registers Let's look at the 'SysTick' peripheral - a simple timer which comes with every Cortex-M processor core. Typically you'll be looking these up in the chip manufacturer's data sheet or Technical Reference Manual,...
The Embedded Rust Book
Book
2024-01-01
~4 min read
docs.rust-embedded.org
Mutable Global State Unfortunately, hardware is basically nothing but mutable global state, which can feel very frightening for a Rust developer. Hardware exists independently from the structures of the code we write, and can be modified at...
The Embedded Rust Book
Book
2024-01-01
~1 min read