rust-embedded-talk/EmbeddedRust.md

105 lines
2.4 KiB
Markdown

---
title: Embedded Rust
subtitle: Intro and Ecosystem Overview
author: Levi Pearson
...
# Overview
## Background
I am:
+ A very experienced embedded systems programmer
+ A moderately experienced Rustacean
+ Relatively new at the combination
## Questions to answer
+ What are embedded systems?
+ What makes Rust interesting in that context?
+ What resources are there right now?
+ How do I get started?
# Embedded Systems?
## A (very general) definition
> When a device has a computerized, software-controlled component as part of its
> mechanism, which supports its primary function rather than the computer *being*
> its primary function, that component constitutes an embedded system.
## Examples
+ A digital scale's control system
+ The engine management computer in a car
+ The management controller in a hard drive
## They are everywhere
+ Microcontrollers start in the ~$0.01 price range
+ They can be as small as a grain of rice
+ They are in credit cards and SIM cards
+ They are also often off-the-shelf Windows boxes
## Microcontrollers
+ Computers specialized for embedded control duty
+ Much wider variety of architecture
+ Integrated peripherals:
- Timers
- Sensors
- Communication bus interfaces
- Display controllers
# Why Rust?
## The landscape today
+ Most embedded systems are still done in C
+ C was a big step up from assembly
+ C is still very error-prone
+ We are putting more software in more things
## Why not other safe languages?
+ Real-time response requirements
+ Resource (often RAM/Flash) constraints
+ Memory layout and representation control
+ Perception
## Big wins
+ The big enabler: `#[no_std]` and powerful, alloc-free `core` library
+ Static resource analysis via ownership and hiding
+ Modularity without overhead via traits
+ Flexible, easy-to-use builds including cross-compiling with cargo
+ Industrial strength multi-arch compiler back-end via LLVM
# Rusty resources
## Compiler and tools
+ `rustup target list | grep none` for no-OS embedded targets
+ `cargo install cargo-binutils` for `cargo size`, `cargo nm`, etc.
+ `rustup component add llvm-tools-preview` for LLVM-native binutils
+ `gdb` built for the target arch for debugging
+ `openocd` to drive the programmer/debugger module
## Embedded-wg resources
+ Embedded Rust Book
+ Awesome / Not-Yet-Awesome Lists
+ `svd2rust` and Peripheral Access Crates
+ `embedded-hal` and HAL Crates
+ Board Support Crates
+ `rtfm` "Real-Time For The Masses" framework