Skip to content

Rust Tutorials for Raspberry Pi

Learn stable Rust from values and ownership to traits, lifetimes, concurrency and a tested Raspberry Pi Linux application. The language course is complete, with 29 lessons organised into four parts. You can learn the language on another supported computer; GPIO equipment and C++ knowledge are not prerequisites.

Where to start

Runnable examples on GitHub

The Rust Learning examples repository contains the existing code from all 41 lessons, including the advanced comparison/design series. Each lesson links to its own files, commands and expected output; the repository links back here. Article source is reused, not rewritten.

Use Cargo rather than CMake. Most lessons share a category workspace; the macro lesson preserves its existing two-package workspace. Intentional compile/test failures are isolated and checked separately. The CLI and system-status projects include fixtures so you can run them without sensors or live device access. The existing C++ comparison programs are included alongside their Rust lessons.

Language course

All articles linked in Parts 1–4 are published. Each part has a checkpoint; the final lesson reviews the course. Article titles are unnumbered, as in the C++ course. Follow the list order or the previous/next links within each article.

Part 1: Values, Ownership and Data

Build small programs, understand who owns each value, and distinguish missing data from invalid input.

Checkpoint: explain and extend the input report. Zero is a measured value, not absence.

Part 2: Abstraction and APIs

Separate project boundaries from type relationships, then test the contract a caller sees.

Checkpoint: defend and extend the documented public API. Use unit, integration and documentation tests without confusing tests with a proof of correctness.

Part 3: Resources and Advanced Rust

Study resource cleanup and concurrency before distinguishing async suspension, pinning and unsafe implementation obligations.

Checkpoint: defend ownership and worker shutdown. Name the owner, blocking operations and completion policy; adding more advanced features is not itself a better design.

Part 4: Integration and Reference

Apply the language to a small native Linux tool, then learn how to investigate the governing rules.

Checkpoint: test the integrated system snapshot, including fixtures, read/write failures and strict exit policy. Finish with the course review.

Advanced design series after the language course

This separate twelve-lesson series follows Parts 1–4 and is not needed to complete the language course. Part 5 compares Rust and C++ contracts; Part 6 revisits design patterns by requirements and change boundaries. Each part ends with comparison exercises.

Part 5: Rust and C++

Checkpoint: defend the six comparison contracts. Similar names do not establish identical mechanisms.

Part 6: Design in Rust

Revisit design patterns by the problem each solves. Evaluate change requirements, invariants and failure behaviour rather than assuming a pattern or language is universally better.

Checkpoint: defend the six design boundaries. Compare the requirement and change cost, not a pattern name or an unmeasured speed claim.

Requirements and scope

You need basic terminal navigation and a supported Rust toolchain. Examples use stable Rust and edition 2024; verification notes record the actual compiler and environment. Start with fixtures, so the early lessons do not depend on a board or sensor.

The native Pi workflow uses 64-bit user space. Check the installed OS architecture rather than inferring it from the board model. Older boards and 32-bit installations need a toolchain/target compatibility check.

This is practical language fluency, not an exhaustive specification or unsafe-code manual. Language rules, standard-library APIs, Cargo and third-party runtimes are distinguished. Rust does not automatically fix permissions, wiring, deadlocks, logical errors or every external-interface obligation. No hardware speed, power or safety benchmark is claimed.

For a hardware follow-on, read the Raspberry Pi model and try an LED with Rust and RPPAL. The same project gives you an optional ARM64 cross-compilation exercise. Raspberry Pi Linux applications and Pico firmware use different targets.

Donate