The Next Big Thing: Rust for Linux Drivers

Writing Linux drivers in Rust on the STM32MP1 platform. Memory safety without garbage collector — the future of embedded is already here.

About the Course

70% of all security vulnerabilities in operating systems (Microsoft, Google) result from memory management bugs: buffer overflow, use-after-free, double-free. In response to these challenges, Rust has officially entered the Linux kernel mainline (v6.1).

Rust is a systems language guaranteeing memory safety at compile time — without a garbage collector, with performance comparable to C. This is not an academic experiment, but a strategic step toward eliminating entire classes of bugs.

For the STM32MP1 platform, used in critical applications (IoT gateways, HMI, medical devices), Rust means drivers that:

  • Have no memory leaks — RAII frees resources automatically
  • Have no data races — the compiler blocks access without locks
  • Enforce error handlingResult<T, E> instead of ignored return codes

You don’t need to know Rust — Day 1 is an intensive “accelerator” for C programmers.


🎯 Project Goal: “GPIO Driver in Rust”

During the course, we write a real driver, not copy examples. Participants will create a kernel module that:

Controls an LED via the BSRR register (atomic write, no race condition)

Handles a button interrupt (User Button) with press counter

Exposes a file interface /dev/stm32_rust for userspace communication

Is controlled from Python — script blinks the LED and reads button state

Automatically frees resources — thanks to RAII and the Drop trait

Compiles in Yocto — full integration with the OpenSTLinux ecosystem


📅 Training Program

DAY 1: The Language – From C to Rust in One Day

Intensive “accelerator” for C programmers. You don’t need to know Rust — you’ll learn it here.

Module 1.1: Why Rust in the Kernel?

  • Case study: Use-after-free bug and how the Rust compiler blocks it
  • CVE statistics: 70% are memory bugs — can we eliminate them?
  • The “Safe Rust” myth: the role of unsafe in kernel code

Module 1.2: Ownership Model

  • Mapping C concepts → Rust: kmalloc/kfreeBox, mutexMutex<Data>, refcount_tArc
  • Borrow Checker: why the compiler complains and how to fix it
  • Lab: Rewriting a C code fragment to Rust

Module 1.3: Yocto Configuration for Rust

  • 32-bit ARM challenges (Tier 2): bindgen, ABI, memory alignment
  • Kernel configuration with Rust support
  • Lab: Preparing the Yocto layer and building the image

Module 1.4: First Module — “Hello STM32MP1”

  • Rust kernel module structure: module! macro, Module trait, Drop trait
  • Automatic resource management (RAII) vs manual kfree in C
  • Lab: Compiling and loading the first module

DAY 2: The Hardware – Platform Drivers and MMIO

Interaction with STM32MP1 hardware. Safe access to GPIO registers.

Module 2.1: STM32MP1 Memory Map

  • Memory Mapped I/O: registers as addresses in processor space
  • GPIO registers: MODER, ODR, BSRR — modes and atomic operations
  • Why BSRR? The Read-Modify-Write problem on multi-core SoC

Module 2.2: Device Tree and Platform Driver

  • Binding Device Tree entry with driver
  • PlatformDriver trait in Rust (kernel 6.6+)
  • Lab: Device Tree modification, driver registration

Module 2.3: Safe Register Access (IoMem)

  • Problem: readl/writel as raw pointers → unsafe
  • Solution: IoMem<SIZE> abstraction and Devres
  • Lab: Implementing probe, GPIO mapping

Module 2.4: LED Control

  • unsafe blocks — when and why they’re necessary
  • Limiting unsafe to minimal scope
  • Lab: Blinking an LED from the driver

DAY 3: The Integration – Interrupts, Userspace, and Final Project

Button handling, file interface, and Python application integration.

Module 3.1: Interrupt Handling (IRQ)

  • User button as an interrupt source
  • Registering a threaded IRQ
  • Synchronization: SpinLock vs Mutex — compiler enforces correctness
  • Lab: Button handling with press counter

Module 3.2: File Interface (Character Device)

  • Registering miscdevice/dev/stm32_rust file
  • file::Operations trait: implementing read/write
  • Lab: LED control and counter reading via device file

Module 3.3: Final Project

  • Integration of all elements into one driver
  • Communication with userspace application (Python)
  • Lab: Complete driver with file interface and interrupt handling

Module 3.4: Summary and Q&A

  • C vs Rust comparison: memory management, errors, concurrency, size
  • Binary size optimization
  • Future of Rust in the Linux kernel
  • Consultation on your own projects

💰 Pricing

FULL RUST EXPERIENCE (3 Days)

Complete training from Rust basics to a working driver with userspace interface.

ScopeFull program (Days 1-3)
OutcomeWorking GPIO driver in Rust + Yocto integration knowledge
Price€1,100 net / person
Min. group5 people

Don’t know Rust? That’s fine — Day 1 is an intensive “accelerator” for C programmers. You leave with solid language foundations.


🏆 Why is it worth it?

BenefitDescription
Bug class elimination70% of CVEs disappear — use-after-free, buffer overflow, data race
32-bit ARM specificWe address Tier 2 challenges: bindgen, ABI, lack of 64-bit atomics
Practice, not theoryWe write a GPIO driver with hardware effect (LED, button)
ComplianceCyber Resilience Act (CRA) enforces memory safety — Rust is the answer

🛠️ Requirements

Hardware (provided):

  • STM32MP157C-DK2 board
  • 16GB microSD card
  • USB Type-C cable, USB-UART converter

Software:

  • Docker container with pre-configured Yocto + Rust toolchain
  • VS Code with rust-analyzer (real-time code suggestions)

Participant knowledge:

  • C language (pointers, structures, memory management)
  • Linux kernel basics (user space vs kernel space, modules)
  • Rust is NOT required — you’ll learn on-site

🎁 Hardware stays with participants after the workshop!

Want to reserve a date for your team? Contact me to arrange details. Join the revolution — write drivers that have no memory leaks.

Interested in the training?

Contact me to discuss details, customize the program for your team, or schedule a date.

Contact ← All Trainings
Training Information
  • Duration:
    3 days
  • Level:
    Advanced
  • Requirements:
    C, Linux kernel basics
Categories
Rust Linux Drivers STM32MP1
Ask about Training

I customize the program to participants' needs. Trainings conducted on-site, remotely, or hybrid.

Contact