Wednesday 

Room 3 

16:20 - 17:20 

(UTC+02

Talk (60 min)

Extending MicroPython with Rust: Two Worlds Collide

Achieving memory safety on microcontrollers is hard, perhaps even harder than elsewhere.

Python
Technique
Languages
Rust

In this talk, we will explore two readily available options. On the one side, there is MicroPython, an implementation of Python that targets microcontrollers. Python is a powerful and expressive language, and manages its memory with a garbage collector. Unfortunately, it is also famous for its performance limitations, which are even more pronounced in constrained environments.

On the other side, we can reach for Rust, a modern systems language with zero-cost abstractions and ownership-based memory management. As a drawback, the language is arguably more difficult to use, and its ecosystem for embedded environments is (still) not quite mature enough.

What if we could combine the advantages of the two?

This session explores the intersection of the contrasting programming paradigms and how they can coexist within the constrained memory space of a microcontroller. We'll cover the background on both languages’ memory models, and specific challenges encountered when they interact, such as ownership conflicts, buffer aliasing issues, and garbage collection considerations.

We will present the experiences gained when implementing a Rust-MicroPython interop layer, solutions to some of the problems outlined above, and techniques for implementing a safe Rust API for extending MicroPython.

Jan Matějek

Developer, hacker, architect, head and tech lead for the Firmware team at Trezor Company, vocal proponent of open-source.

He has been programming since childhood, professionally for over two decades, and he still loves it enough to keep doing it in his free time. Especially thrives on challenging problems and in constrained environments.