Embedded Rust, by example of RIOT-OS applications
A summary of the options and abstractions available for Rust on embedded systems, with a focus on RIOT-OS.
It was presented during the Rust Meetup 2018-11-27 at the Metalab in Vienna.
Links
Recommended resources:
Awesome Embedded Rust: The collection of everything about the Embedded Rust WG -- tutorials, examples, tools, and supported devices.
Most noteworthy:
RIOT bindings:
- wrappers: Safe abstractions around RIOT C APIs
- examples: The examples shown during the presentation
Points taken down from the Q&A session
- How is cross compilation done?
- Just by passing the --target thumbv7m-none-eabi flag to Cargo / rustc (exact value depends on MCU). If the toolchain is not installed, rustup target add thumbv7m-none-eabi takes care of that.
- How about AVR (ATmega, as in Arduino Uno)?
- Rust has no official suport for AVR; there is an implementation, but I can't say how mature it is.
- Can this be used to implement modules for RIOT in Rust?
- Conceptually yes; how they would be fully integrated and configured is up for exploration, especially for add-on modules or drivers.
- Is (D)TLS cryptography supported in such a setup?
- RIOT supports DTLS, and while not explicitly wrapped, this should be usable from Rust, especially from the CoAP stack. Wrappers that support no_std are available for other TLS libraries, eg. mbedtls. Supporting the (not TLS based but tailored towards IoT protocols) OSCORE protocol is a candidate for experimentation with Rust modules for RIOT.
- Are there known security vulnerabilities in RIOT to be aware of?
- I am not aware of any current issues, or remember having heard of any. The RIOT developer community is very security conscious. The largest threat I perceive to embedded systems are long-term deployments the possibility for timely updates.
- Can embedded Rust development be done without knowing C well?
- Yes. I recommend you start with bare-metal Rust development rather than wrapped RIOT. (There, chances are you'll get into areas where there are no wrappers yet, and as bindgen can not translate some functions, you'll get your hands on C code there).
- You've used a VI to show the examples. Do you use any IDE-ish Rust integration features?
- No; I've had some installed (don't remember which), but when they broke for some reason, I did not miss them enough to fix them. All I use is line- and token-level autocompletion.