fn main() {
let mut button = Button::new();
let mut led = Led::new();
loop {
if button.is_pressed() {
led.on();
} else {
led.off();
}
}
}
Ulf Lilleengen (@lulf)
Jens Reimann (@ctron)
Software Engineers @ Red Hat
Work on open source IoT
Cloud & embedded
With a focus on "Drogue IoT"
A language empowering everyone to build reliable and efficient software.
~70% of the vulnerabilities Microsoft assigns a CVE each year continue to be memory safety issues
Those 70% would never have existed, if Rust had been used!
A tale of Rust, the ESP32 and IoT
A talk to get you excited about Rust.
16 kB - 512 kB RAM
128 kB - 2 MB ROM/Flash
No operating system
No memory allocator
Rust Embedded
Official working group of the Rust language
Community to collaborate on Rust embedded topics
ARM (Cortex-M)
STM32
nRF (micro:bit)
Raspberry Pi Pico
RISC-V
ESP32 C3
…
Plain Rust
RTIC
Embassy
fn main() {
let mut button = Button::new();
let mut led = Led::new();
loop {
if button.is_pressed() {
led.on();
} else {
led.off();
}
}
}
Inefficient (busy looping)
static BUTTON: Mutex<Option<Button>> = Mutex::new(None);
static LED: Mutex<Option<Led>> = Mutex::new(None);
fn main() {
LED.lock().replace(Led::new());
BUTTON.lock().replace(Button::new());
setup_irq(button_event); // Magic
}
fn button_event() {
if BUTTON.lock().as_mut().unwrap().is_pressed() {
LED.lock().as_mut().unwrap().on();
} else {
LED.lock().as_mut().unwrap().off();
}
}
Complex!
async fn main() {
let mut button = Button::new();
let mut led = Led::new();
loop {
button.wait_changed().await;
if button.is_pressed() {
led.on();
} else {
led.off();
}
}
}
Interrupt handling internally
Efficient - executor puts app to sleep on await points
Rust requires an "executor" to drive async workload.
Async executor for std
Builds on top of an I/O loop
EMBedded ASYnc
An executor for embedded Rust, supporting no_std
.
Async synchronization primitives, time keeping
HALs for nRF, STM32 and RP2040
Bootloader
USB, TCP/IP, LoRa and BLE
Drivers from crates.io
Ector
Drogue Device
…
An actor framework.
Distribution of Embassy focused on a few boards supporting IoT, OTA updates.
Join the community!
Join the matrix.org chat!
Questions?