COMP.530 Bare Metal Rust – Hands-on Rust for Embedded Programmers

An image showing a Longan Nano with an LCD displaying Ferris the Crab
Longan Nano uses an LCD to display Ferris the Crab, powered by Rust.

COMP.530 Bare Metal Rust starts with a motivational talk and a basic info session on Monday 30.8. at 14:15. Enroll now :)

The course will see students complete exercises aimed at teaching the basics of writing Rust for an embedded microcontroller. A graduate of the course will be able to navigate the embedded Rust ecosystem, write a Rust driver, and design their own IoT/ASIC/SoC applications using the best available Rust tools.

Bare Metal Rust is a software developer’s view to the world of microcontrollers.

On Bare Metal Rust we learn to work in the space between operating systems and the hardware. We take an in-depth look into the smartest Rust tools available for creating platform drivers and embedded applications. We work with bits and bytes, pins and voltages, and interrupts and critical sections. In addition to learning about the ecosystem as a whole, we also delve in the actual work of programming a microcontroller by building several programs in the form of course challenges.

This year’s iteration builds on the premier implementation of Autumn 2020. While last year we had students writing small essays, this year is much more about real exercises and scaffolded programming work. Spoiler alert: the first challenge is ‘rustlings’, familiar to last year’s students. Former candidates are free to re-submit last year’s solutions 🙂

Besides being a primarily hands-on programming course, the course is built on the principles of extreme apprenticeship[1]: model, scaffold, fade. On each week of the course, we create a mental model of our objectives by taking a new perspective on the subject matter. This new perspective is then supported by an exercise scaffold: a bi-weekly challenge published on Moodle. Each week builds on what was learned last week to support effective learning. While the challenges are not necessarily easy to everyone, the student is supported by course staff and a network of peers.

For a passing grade, each student must only complete the series of fully online challenges in Moodle (3 cr, a credits’ upgrade from last year), which may or may not be nationally available through Fitech[2]. In parallel with the online implementation, the student may also choose to complete a free-form embedded course project for 1-2 credits on an agreed upon schedule. The only requirements for the embedded project are that it’s mainly written in Rust and without the facilities of a desktop operating system. Support for choosing an interesting project and its scheduling is provided on the course. We also have an exciting RISC-V development board available for use in student’s projects and practice.

Here’s a demo of an advanced project from last year:

Play video on YouTube (opens in new tab)

Full source available (with a… permissive license…) at: https://github.com/teo3n/BMR_WirelessGame

This year’s topics are as follows:
– C, Rust, and embedded programming
– Basic embedded Rust skills
– The anatomy of a binary ELF: how to turn a Rust program into flashable binary for any[3] processor
– From ‘just metal’ to RTOS: the embedded Rust stack
– Rust drivers in the wild: advanced control of systems on chip
– How to write a HAL-driver for your application?

I was thinking of finishing my dissertation, so despite this course being the most fun thing, we may or may not go on a break next year 😛 I’ll be working on Rust for embedded systems regardless. I recommend taking this implementation if you’re still considering.

Link to course brochure: https://sis-tuni.funidata.fi/student/courseunit/otm-80081dfb-63f8-41d3-8d73-141aef69e1af/brochure

– [1] Vihavainen, A., Paksula, M., & Luukkainen, M. (2011, March). Extreme apprenticeship method in teaching programming for beginners. In Proceedings of the 42nd ACM technical symposium on Computer science education (pp. 93-98).
– [2] Fitech. https://fitech.io/en/. However, our Fitech implementation is currently lost in bureaucracy, so it may or may not be currently available.
– [3] any := architectures specified at https://doc.rust-lang.org/rustc/platform-support.html. The course does also provide some ideas on how to create a binary that’s executable on non-supported platforms 🙂