SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Downloaden Sie, um offline zu lesen
Eingebettete Systeme
programmieren mit Rust
Jens Siebert (@jens_siebert)
building IoT 2022, 10. Mai 2022
Über mich
• Senior Software Developer bei
doks.innovation in Kassel
• Drohnen-Steuerung, Computer
Vision, Architektur
• Maker, 3D-Drucker, Nerd
Hello... building IoT!
Infos zu Rust
• 2006 als privates Projekt des Entwicklers Graydon Hoare gestartet.
• Ab 2009 von seinem Arbeitgeber (Mozilla) unterstützt.
• Rust 1.0 am 15. Mai 2015.
• 2021 wurde die Rust Foundation gegründet.
• Sponsoren/Nutzer: Amazon (AWS), Microsoft, Google, Mozilla, uvm.
• "Most loved programming language" seit 2016 im Stack Overflow
Developer Survey.
• Stabile Releases alle 6 Wochen, alle 3 Jahre eine neue "Edition".
Besondere Merkmale von Rust
• Sicheres, automatisches Speichermanagement ohne Garbage Collector.
• Nebenläufigkeit ohne Data Races ("Fearless Concurrency").
• Abstraktionen mit möglichst geringem Overhead ("Zero Cost Abstractions").
• Effizientes Interface zu C/C++.
• Aussagekräftige Fehlermeldungen des Compilers.
Lifetimes, Ownership, Copy vs. Move
Referenzen, Borrowing
Veränderbare Referenzen
Structs & Traits
Structs & Traits
Fehlerbehandlung
• panic!
• Result-Datentyp
Nebenläufigkeit
Unsafe Code
Tools, Tools, Tools...
• rustup – Verwaltung der Rust-Installation
• rustc – Der Rust-Compiler
• cargo – Project-/Build-/Test-/Documentation-/Package-Management
• Knurling Tools
• probe-run – cargo runner zum Flashen und Ausführen von Anwendungen (z.B. über JTAG)
• defmt – Logging Framerwork
• flip-link – Stack Protection
• app-template – Vorlagen für eigene Anwendungen
• defmt-test – Test-Framework für On-Device-Tests
rustc – Target Platform Support Policy
• Tier 1: Continuous Integration checks that tier 1 targets will always
build and pass tests.
• Tier 2: Continuous Integration checks that tier 2 targets will always
build, but they may or may not pass tests.
• Tier 3: No guarantees about tier 3 targets; they exist in the codebase,
but may or may not build.
https://doc.rust-lang.org/rustc/target-tier-policy.html
Target Platform Support – Tier 1*
Target
aarch64-unknown-linux-gnu
i686-pc-windows-gnu
i686-pc-windows-msvc
i686-unknown-linux-gnu
x86_64-apple-darwin
x86_64-pc-windows-gnu
x86_64-pc-windows-msvc
x86_64-unknown-linux-gnu
https://doc.rust-lang.org/rustc/platform-support.html#tier-1-with-host-tools
* => Tier 1 with Host Tools
Target Platform Support – Tier 2
Target std
aarch64-unknown-none-softfloat *
aarch64-unknown-none *
armebv7r-none-eabi *
armebv7r-none-eabihf *
armv7a-none-eabi *
armv7r-none-eabi *
armv7r-none-eabihf *
riscv32i-unknown-none-elf *
riscv32imac-unknown-none-elf *
riscv32imc-unknown-none-elf *
riscv64gc-unknown-none-elf *
riscv64imac-unknown-none-elf *
thumbv6m-none-eabi *
thumbv7em-none-eabi *
thumbv7em-none-eabihf *
thumbv7m-none-eabi *
thumbv8m.base-none-eabi *
... ...
https://doc.rust-lang.org/rustc/platform-support.html#tier-2
std vs. no_std
Feature no_std std
heap (dynamic memory) * ✓
collections (Vec, HashMap, etc) ** ✓
stack overflow protection ✘ ✓
runs init code before main ✘ ✓
libstd available ✘ ✓
libcore available ✓ ✓
writing firmware, kernel, or
bootloader code
✓ ✘
* => Nur bei Verwendung des alloc Crates und eines passenden Allocators, wie z.B. alloc-cortex-m
** => Nur bei Verwendung der alloc oder heapless Crates
https://docs.rust-embedded.org/book/intro/no-std.html
Embedded Crates
Application
Board Support Crate Drivers
embedded-hal Crate
embedded-hal impl Crate Drivers
Peripheral Access Crate
Microcontroller
Architecture
Support
Crate
Embedded Crates (Beispiel)
Application
Board Support Crate (rp-pico) Drivers
embedded-hal Crate
embedded-hal impl Crate (rp-2040-hal) Drivers
Peripheral Access Crate (rp-2040-pac)
Microcontroller (Cortex-M0+)
Architecture
Support
Crate
(cortex-m)
Embedded HAL
embedded-hal Serial
I2C SPI
Timer
Watchdog ADC
GPIO
PWM
Beispiel-Projekt (Setup)
rustup update
rustup target add thumbv6m-none-eabi
cargo install elf2uf2-rs
cargo new biot22
Beispiel-Projekt (Layout)
Konfiguration für Build-Tool (Target, Runner, etc.)
Source-Code
Projektinformationen und Abhängigkeiten
.cargo/config für Raspberry Pi Pico
Cargo.toml für Raspberry Pi Pico
Minimale main.rs für Raspberry Pi Pico
Blinky-Projekt (Importe, main.rs)
Blinky-Projekt (Initialisierung, main.rs)
Blinky-Projekt (Pin-Config und blinken, main.rs)
Ergebnis
Fazit
Rust als Sprache für eingebettete Systeme bietet:
• Hohe Performance, geringer Speicherverbrauch.
• Sicheres Speichermanagement.
• Sichere Nebenläufigkeit.
• Viele unterstützte Architekturen (ARM, RISC-V, etc.), Microcontroller und Boards.
• Viele Treiber für externe Hardware bereits vorhanden.
• Komfortables Tooling, welches etablierten Sprachen und Frameworks in nichts nachsteht.
• Teilweise steile Lernkurve (aber es lohnt sich!)
• Freundliche und hilfsbereite Community.
• Open Source (Bitte unterstützen!).
Vielen Dank!
https://www.rust-lang.org/learn
https://docs.rust-embedded.org/discovery/
https://docs.rust-embedded.org/book/
https://github.com/rust-embedded/awesome-embedded-rust
https://knurling.ferrous-systems.com/tools/
Twitter: @jens_siebert

Weitere ähnliche Inhalte

Ähnlich wie Embedded Rust

Die Containerplattform Lego für DevOps
Die Containerplattform Lego für DevOpsDie Containerplattform Lego für DevOps
Die Containerplattform Lego für DevOpsATIX AG
 
Android Apps mit Xamarin entwickeln
Android Apps mit Xamarin entwickelnAndroid Apps mit Xamarin entwickeln
Android Apps mit Xamarin entwickelnAndré Krämer
 
IT-Sicherheit und agile Entwicklung – geht das? Sicher!
IT-Sicherheit und agile Entwicklung – geht das? Sicher!IT-Sicherheit und agile Entwicklung – geht das? Sicher!
IT-Sicherheit und agile Entwicklung – geht das? Sicher!Carsten Cordes
 
Living on the Edge - Microservices in der Wildnis
Living on the Edge - Microservices in der WildnisLiving on the Edge - Microservices in der Wildnis
Living on the Edge - Microservices in der Wildnismmeisenzahl
 
.NET Core, .NET Standard & ASP.NET Core - Eine Übersicht
.NET Core, .NET Standard & ASP.NET Core - Eine Übersicht.NET Core, .NET Standard & ASP.NET Core - Eine Übersicht
.NET Core, .NET Standard & ASP.NET Core - Eine ÜbersichtJürgen Gutsch
 
DACHNUG50 Volt MX & AppScan_20230615.pdf
DACHNUG50 Volt MX & AppScan_20230615.pdfDACHNUG50 Volt MX & AppScan_20230615.pdf
DACHNUG50 Volt MX & AppScan_20230615.pdfDNUG e.V.
 
Architectures for .Net Core Applications
Architectures for .Net Core ApplicationsArchitectures for .Net Core Applications
Architectures for .Net Core ApplicationsRobin Sedlaczek
 
Die hohe Kunst Tretminen in Ihrer Software zu verstecken
Die hohe Kunst Tretminen in Ihrer Software zu versteckenDie hohe Kunst Tretminen in Ihrer Software zu verstecken
Die hohe Kunst Tretminen in Ihrer Software zu versteckenteam-WIBU
 
Django trifft Flutter
Django trifft FlutterDjango trifft Flutter
Django trifft Flutterroskakori
 
WTC 2019 – Flutter
WTC 2019 – FlutterWTC 2019 – Flutter
WTC 2019 – Flutterwebconia
 
Spiele entwickeln mit dem Adobe AIR SDK
Spiele entwickeln mit dem Adobe AIR SDKSpiele entwickeln mit dem Adobe AIR SDK
Spiele entwickeln mit dem Adobe AIR SDKIndieOutpost
 
Niemals nach Mitternacht füttern - Grüne Roboter überall!
Niemals nach Mitternacht füttern - Grüne Roboter überall!Niemals nach Mitternacht füttern - Grüne Roboter überall!
Niemals nach Mitternacht füttern - Grüne Roboter überall!inovex GmbH
 
German: Softwareprodukte aus einem Source Code mit Javascript
German: Softwareprodukte aus einem Source Code mit JavascriptGerman: Softwareprodukte aus einem Source Code mit Javascript
German: Softwareprodukte aus einem Source Code mit JavascriptRalf Schwoebel
 
Software Entwicklung im Team
Software Entwicklung im TeamSoftware Entwicklung im Team
Software Entwicklung im Teambrandts
 
C / C++ Api for Beginners
C / C++ Api for BeginnersC / C++ Api for Beginners
C / C++ Api for BeginnersUlrich Krause
 
Roadshow: Einstieg in die Hybrid-App Entwicklung mit dem Intel XDK und Apache...
Roadshow: Einstieg in die Hybrid-App Entwicklung mit dem Intel XDK und Apache...Roadshow: Einstieg in die Hybrid-App Entwicklung mit dem Intel XDK und Apache...
Roadshow: Einstieg in die Hybrid-App Entwicklung mit dem Intel XDK und Apache...Gregor Biswanger
 
C/ C++ for Notes & Domino Developers
C/ C++ for Notes & Domino DevelopersC/ C++ for Notes & Domino Developers
C/ C++ for Notes & Domino DevelopersUlrich Krause
 
C API for Lotus Notes & Domino
C API for Lotus Notes & DominoC API for Lotus Notes & Domino
C API for Lotus Notes & DominoUlrich Krause
 

Ähnlich wie Embedded Rust (20)

Die Containerplattform Lego für DevOps
Die Containerplattform Lego für DevOpsDie Containerplattform Lego für DevOps
Die Containerplattform Lego für DevOps
 
Android Apps mit Xamarin entwickeln
Android Apps mit Xamarin entwickelnAndroid Apps mit Xamarin entwickeln
Android Apps mit Xamarin entwickeln
 
IT-Sicherheit und agile Entwicklung – geht das? Sicher!
IT-Sicherheit und agile Entwicklung – geht das? Sicher!IT-Sicherheit und agile Entwicklung – geht das? Sicher!
IT-Sicherheit und agile Entwicklung – geht das? Sicher!
 
Living on the Edge - Microservices in der Wildnis
Living on the Edge - Microservices in der WildnisLiving on the Edge - Microservices in der Wildnis
Living on the Edge - Microservices in der Wildnis
 
.NET und jetzt!
.NET und jetzt!.NET und jetzt!
.NET und jetzt!
 
.NET Core, .NET Standard & ASP.NET Core - Eine Übersicht
.NET Core, .NET Standard & ASP.NET Core - Eine Übersicht.NET Core, .NET Standard & ASP.NET Core - Eine Übersicht
.NET Core, .NET Standard & ASP.NET Core - Eine Übersicht
 
DACHNUG50 Volt MX & AppScan_20230615.pdf
DACHNUG50 Volt MX & AppScan_20230615.pdfDACHNUG50 Volt MX & AppScan_20230615.pdf
DACHNUG50 Volt MX & AppScan_20230615.pdf
 
Architectures for .Net Core Applications
Architectures for .Net Core ApplicationsArchitectures for .Net Core Applications
Architectures for .Net Core Applications
 
Die hohe Kunst Tretminen in Ihrer Software zu verstecken
Die hohe Kunst Tretminen in Ihrer Software zu versteckenDie hohe Kunst Tretminen in Ihrer Software zu verstecken
Die hohe Kunst Tretminen in Ihrer Software zu verstecken
 
Django trifft Flutter
Django trifft FlutterDjango trifft Flutter
Django trifft Flutter
 
WTC 2019 – Flutter
WTC 2019 – FlutterWTC 2019 – Flutter
WTC 2019 – Flutter
 
Spiele entwickeln mit dem Adobe AIR SDK
Spiele entwickeln mit dem Adobe AIR SDKSpiele entwickeln mit dem Adobe AIR SDK
Spiele entwickeln mit dem Adobe AIR SDK
 
Industry 4.0 in a box
Industry 4.0 in a boxIndustry 4.0 in a box
Industry 4.0 in a box
 
Niemals nach Mitternacht füttern - Grüne Roboter überall!
Niemals nach Mitternacht füttern - Grüne Roboter überall!Niemals nach Mitternacht füttern - Grüne Roboter überall!
Niemals nach Mitternacht füttern - Grüne Roboter überall!
 
German: Softwareprodukte aus einem Source Code mit Javascript
German: Softwareprodukte aus einem Source Code mit JavascriptGerman: Softwareprodukte aus einem Source Code mit Javascript
German: Softwareprodukte aus einem Source Code mit Javascript
 
Software Entwicklung im Team
Software Entwicklung im TeamSoftware Entwicklung im Team
Software Entwicklung im Team
 
C / C++ Api for Beginners
C / C++ Api for BeginnersC / C++ Api for Beginners
C / C++ Api for Beginners
 
Roadshow: Einstieg in die Hybrid-App Entwicklung mit dem Intel XDK und Apache...
Roadshow: Einstieg in die Hybrid-App Entwicklung mit dem Intel XDK und Apache...Roadshow: Einstieg in die Hybrid-App Entwicklung mit dem Intel XDK und Apache...
Roadshow: Einstieg in die Hybrid-App Entwicklung mit dem Intel XDK und Apache...
 
C/ C++ for Notes & Domino Developers
C/ C++ for Notes & Domino DevelopersC/ C++ for Notes & Domino Developers
C/ C++ for Notes & Domino Developers
 
C API for Lotus Notes & Domino
C API for Lotus Notes & DominoC API for Lotus Notes & Domino
C API for Lotus Notes & Domino
 

Mehr von Jens Siebert

Microservices mit Rust
Microservices mit RustMicroservices mit Rust
Microservices mit RustJens Siebert
 
Backend-Services mit Rust
Backend-Services mit RustBackend-Services mit Rust
Backend-Services mit RustJens Siebert
 
TinyML – Machine Learning für eingebettete Systeme
TinyML – Machine Learning für eingebettete SystemeTinyML – Machine Learning für eingebettete Systeme
TinyML – Machine Learning für eingebettete SystemeJens Siebert
 
Deep Learning mit TensorFlow.js
Deep Learning mit TensorFlow.jsDeep Learning mit TensorFlow.js
Deep Learning mit TensorFlow.jsJens Siebert
 
Chatbots bauen mit dem Microsoft Bot Framework
Chatbots bauen mit dem Microsoft Bot FrameworkChatbots bauen mit dem Microsoft Bot Framework
Chatbots bauen mit dem Microsoft Bot FrameworkJens Siebert
 
Integrating The Things Network Applications with Azure IoT Services
Integrating The Things Network Applications with Azure IoT ServicesIntegrating The Things Network Applications with Azure IoT Services
Integrating The Things Network Applications with Azure IoT ServicesJens Siebert
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScriptJens Siebert
 
Windows 10 IoT Core
Windows 10 IoT CoreWindows 10 IoT Core
Windows 10 IoT CoreJens Siebert
 
Microsoft Bot Framework (Node.js Edition)
Microsoft Bot Framework (Node.js Edition)Microsoft Bot Framework (Node.js Edition)
Microsoft Bot Framework (Node.js Edition)Jens Siebert
 
Microsoft Bot Framework (.NET Edition)
Microsoft Bot Framework (.NET Edition)Microsoft Bot Framework (.NET Edition)
Microsoft Bot Framework (.NET Edition)Jens Siebert
 
Windows 10 IoT Core
Windows 10 IoT CoreWindows 10 IoT Core
Windows 10 IoT CoreJens Siebert
 
Windows 10 IoT Core
Windows 10 IoT CoreWindows 10 IoT Core
Windows 10 IoT CoreJens Siebert
 

Mehr von Jens Siebert (19)

WebAssembly
WebAssemblyWebAssembly
WebAssembly
 
Embedded Rust
Embedded RustEmbedded Rust
Embedded Rust
 
Microservices mit Rust
Microservices mit RustMicroservices mit Rust
Microservices mit Rust
 
Backend-Services mit Rust
Backend-Services mit RustBackend-Services mit Rust
Backend-Services mit Rust
 
TinyML – Machine Learning für eingebettete Systeme
TinyML – Machine Learning für eingebettete SystemeTinyML – Machine Learning für eingebettete Systeme
TinyML – Machine Learning für eingebettete Systeme
 
Deep Learning mit TensorFlow.js
Deep Learning mit TensorFlow.jsDeep Learning mit TensorFlow.js
Deep Learning mit TensorFlow.js
 
Chatbots bauen mit dem Microsoft Bot Framework
Chatbots bauen mit dem Microsoft Bot FrameworkChatbots bauen mit dem Microsoft Bot Framework
Chatbots bauen mit dem Microsoft Bot Framework
 
Integrating The Things Network Applications with Azure IoT Services
Integrating The Things Network Applications with Azure IoT ServicesIntegrating The Things Network Applications with Azure IoT Services
Integrating The Things Network Applications with Azure IoT Services
 
GraphQL
GraphQLGraphQL
GraphQL
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScript
 
Windows 10 IoT Core
Windows 10 IoT CoreWindows 10 IoT Core
Windows 10 IoT Core
 
Microsoft Bot Framework (Node.js Edition)
Microsoft Bot Framework (Node.js Edition)Microsoft Bot Framework (Node.js Edition)
Microsoft Bot Framework (Node.js Edition)
 
Microsoft Bot Framework (.NET Edition)
Microsoft Bot Framework (.NET Edition)Microsoft Bot Framework (.NET Edition)
Microsoft Bot Framework (.NET Edition)
 
Electron
ElectronElectron
Electron
 
Windows 10 IoT Core
Windows 10 IoT CoreWindows 10 IoT Core
Windows 10 IoT Core
 
Physical Web
Physical WebPhysical Web
Physical Web
 
Windows 10 IoT Core
Windows 10 IoT CoreWindows 10 IoT Core
Windows 10 IoT Core
 
TypeScript
TypeScriptTypeScript
TypeScript
 
TypeScript
TypeScriptTypeScript
TypeScript
 

Embedded Rust