IoT mit Rust 

programmieren
Lars Gregori

Hybris Labs
Motivation
http://fpiot.metasepi.org/ (Functional IoT)
Imagine IoT devices are:
• connected to the internet
• developed in a short time
• storing personal data
• secure
• more intelligence
• inexpensive
C language can design the IoT devices such like that? No, can't.
Agenda
• Rust
• Überblick
• Control & Safety
• Code Beispiele
• Rust
• Embedded Rust
• Cross Compiling
• MCU Demo
• Debugging Rust
Rust
Überblick
rust-lang.org
Rust FAQ
https://www.rust-lang.org/faq.html
• safe, concurrent, practical systems language
• “We do not intend to be 

100% static, 100% safe, 100% reflective, 

or too dogmatic in any other sense.”
• Mozilla Servo
Rust FAQ
https://www.rust-lang.org/faq.html
• multi-paradigm
• OO
• no garbage collection
• strong influences from the world of functional programming
• built on LLVM
Rust FAQ
https://www.rust-lang.org/faq.html
• Cross-Platform
• Android, iOS, …
• Conditional compilation

#[cfg(target_os	=	"macos")]
Rust
Control & Safety
Control & Safety
C/C++
Safety
Control
Haskell
Go
Java
Rust
Python
Rust concepts
• ownership, the key concept
• borrowing, and their associated feature ‘references’
• lifetimes, an advanced concept of borrowing
“work with the rules of the ownership system for a period of time, 

[..] fight the borrow checker less and less"
Agenda
• Rust
• Überblick
• Control & Safety
• Code Beispiele
• Rust
• Embedded Rust
• Cross Compiling
• MCU Demo
• Debugging Rust
Code Beispiele
Rust
Source Code
fn	main()	{	
				println!("Hello,	world!");	
}
Source Code
fn	main()	{	
				let	world	=	"world!";	
				println!("Hello,	{}",	world);	
}
Code Beispiele
Embedded Rust
Embedded Code-Beispiele
zinc.rs
Zinc is an experimental attempt to write an ARM stack that would be
similar to CMSIS or mbed in capabilities but would show rust’s best safety
features applied to embedded development.
Zinc is mostly assembly-free and completely C-free at the moment.
▶︎Embedded Rust
Agenda
• Rust
• Überblick
• Control & Safety
• Code Beispiele
• Rust
• Embedded Rust
• Cross Compiling
• MCU Demo
• Debugging Rust
Cross-Compiling
Multirust
https://github.com/brson/multirust
• Manage multiple installations of the official Rust binaries.
• Configure Rust toolchains per-directory.
• Install and update from Rust release channels: nightly, beta, and stable.
• …
target
rustc:
rustc	--target=thumbv7em-none-eabi	…	
cargo:
.cargo/config
cargo	build	--target=thumbv7em-none-eabi	…
https://github.com/japaric/rust-cross
▶︎Cross-Compiling
Agenda
• Rust
• Überblick
• Control & Safety
• Code Beispiele
• Rust
• Embedded Rust
• Cross Compiling
• MCU Demo
• Debugging Rust
MCU Demo
Debugging Rust
Debugging Rust
openocd	…	-c	gdb_port	3333	
arm-none-eabi-gdb	
(gdb)	target	remote	:3333	
(gdb)	file	…	
(gdb)	break	main	
(gdb)	next	
…
▶︎MCU Demo
Agenda
• Rust
• Überblick
• Control & Safety
• Code Beispiele
• Rust
• Embedded Rust
• Cross Compiling
• MCU Demo
• Debugging Rust
Thank you!
IoT mit Rust programmieren

IoT mit Rust programmieren