Introduction

Welcome to The Embedded Rust Book: An introductory book about using the RustProgramming Language on "Bare Metal" embedded systems, such as Microcontrollers.

Who Embedded Rust is For

Embedded Rust is for everyone who wants to do embedded programming while taking advantage of the higher-level concepts and safety guarantees the Rust language provides.(See also Who Rust Is For)

Scope

The goals of this book are:

  • Get developers up to speed with embedded Rust development. i.e. How to setup a development environment.

  • Share current best practices about using Rust for embedded development. i.e.How to best use Rust language features to write more correct embeddedsoftware.

  • Serve as a cookbook in some cases. e.g. How do I do mix C and Rust in a singleproject?

This book tries to be as general as possible but to make things easier for boththe readers and the writers it uses the ARM Cortex-M architecture in all itsexamples. However, the book doesn't assume that the reader is familiar with thisparticular architecture and explains details particular to this architecturewhere required.

Who This Book is For

This book caters towards people with either some embedded background or some Rust background, however we believeeverybody curious about embedded Rust programming can get something out of this book. For those without any prior knowledgewe suggest you read the "Assumptions and Prerequisites" section and catch up on missing knowledge to get more out of the bookand improve your reading experience. You can check out the "Other Resources" section to find resources on topicsyou might want to catch up on.

Assumptions and Prerequisites

  • You are comfortable using the Rust Programming Language, and have written,run, and debugged Rust applications on a desktop environment. You should alsobe familiar with the idioms of the 2018 edition as this book targetsRust 2018.
  • You are comfortable developing and debugging embedded systems in anotherlanguage such as C, C++, or Ada, and are familiar with concepts such as:
    • Cross Compilation
    • Memory Mapped Peripherals
    • Interrupts
    • Common interfaces such as I2C, SPI, Serial, etc.

Other Resources

If you are unfamiliar with anything mentioned above or if you want more information about a specific topic mentioned in this book you might find some of these resources helpful.

TopicResourceDescription
RustRust BookIf you are not yet comfortable with Rust, we highly suggest reading this book.
Rust, EmbeddedDiscovery BookIf you have never done any embedded programming, this book might be a better start
Rust, EmbeddedEmbedded Rust BookshelfHere you can find several other resources provided by Rust's Embedded Working Group.
Rust, EmbeddedEmbedonomiconThe nitty gritty details when doing embedded programming in Rust.
Rust, Embeddedembedded FAQFrequently asked questions about Rust in an embedded context.
InterruptsInterrupt-
Memory-mapped IO/PeripheralsMemory-mapped I/O-
SPI, UART, RS232, USB, I2C, TTLStack Exchange about SPI, UART, and other interfaces-

How to Use This Book

This book generally assumes that you’re reading it front-to-back. Laterchapters build on concepts in earlier chapters, and earlier chapters maynot dig into details on a topic, revisiting the topic in a later chapter.

This book will be using the STM32F3DISCOVERY development board fromSTMicroelectronics for the majority of the examples contained within. This boardis based on the ARM Cortex-M architecture, and while basic functionality isthe same across most CPUs based on this architecture, peripherals and otherimplementation details of Microcontrollers are different between differentvendors, and often even different between Microcontroller families from the samevendor.

For this reason, we suggest purchasing the STM32F3DISCOVERY development boardfor the purpose of following the examples in this book.

Contributing to This Book

The work on this book is coordinated in this repository and is mainlydeveloped by the resources team.

If you have trouble following the instructions in this book or find that somesection of the book is not clear enough or hard to follow then that's a bug andit should be reported in the issue tracker of this book.

Pull requests fixing typos and adding new content are very welcome!