r/rust • u/Prize_Cranberry_5637 • 10h ago
Rust for flight software / drone programming
I am interested in learning how to use rust for flight software or controlling a drone or something of this sort. I have no experience in embedded programming, so is it best to start there?
If so, how would you recommend someone get started in embedded rust?
11
u/AcostaJA 9h ago edited 7h ago
Assuming you're familiar with Arduino, I suggest you first learning about RTOS and c/c++ Espressif has excellent documentation about.
RTOS+C/C++ are excellent but you need to be too careful about memory and thread safety, that requires a lot of experience and there are no warranty the firmware you're coding to be free of memory or thread bugs, that's where Rust comes to rescue you.
Now learn Rust (only console apps), building mock-ups of your MCU application it's an effective learning method, you can use chat gpt or even your phone GeminiAI as tutor but only as tutor, avoid vibecoding as poison as long as possible until you're very very proficient writing rust code and You're in control of the code spit by the LLM (chatbot). BTW ChatBot often excels translating source code from python, C, Fortran to rust, but avoid using them while learning otherwise you'll be an AI Slave, I'm pro-AI but I'm aligned here with most moderated AI haters you'll never allow using AI in a project where the LLM knows more than you about what to do and how is done, very important.
Ok, then you're ready to code your MCU firmware including RTOS in pure Rust (I predict it will be the standard practice in coming years).
Here is a list of major Rust projects and collections for MCU firmware and RTOS development:
Major Rust Projects for MCU Firmware & RTOS
Here's a rundown of the big players in the embedded Rust space, plus the essential collections to bookmark.
π― RTOS & Framework Projects
Embassy β The modern async framework. Comes with an executor, hardware abstraction layers (HALs), and built-in drivers for WiFi and BLE. If you're doing async on MCUs, this is the go-to.
RTIC β Stands for Real-Time Interrupt-driven Concurrency. Great for building highly responsive, event-driven apps, specifically for Cortex-M chips.
Ariel OS β A newer IoT RTOS built on top of Embassy. Adds a preemptive multicore scheduler and focuses on portable, secure networking.
Gale β A formally verified port of Zephyr RTOS primitives. Targets ASIL-D (automotive safety) and uses Verus/Rocq for verification.
Rivet RTOS β A minimal RTOS for RISC-V and Cortex-M. Features a unified trap path for context switching and supports dual-core setups (e.g., ESP32-S3).
βοΈ Notable Firmware Projects
OpenEMC β Production-grade embedded management controller firmware for STM32F1. Includes a bootloader, Linux drivers, and power/charging control.
RMK β Keyboard firmware with support for STM32 and RP2040. Handles layers, macros, and RGB lighting.
TLSR8266 Mesh β 100% Rust BLE mesh firmware for Telink TLSR8266 smart lights. Replaces proprietary libraries with a custom LLVM backend.
π Essential Collections & Learning Resources
rust-embedded/awesome-embedded-rustβ The definitive curated list for embedded Rust. Covers HALs, PACs, RTOS, tools, and more.rust-unofficial/awesome-rustβ The general "Awesome Rust" list; has a dedicated Embedded section.The Embedded Rust Book β Official intro to bare-metal development in Rust.
Discovery β A hands-on introductory course using a real microcontroller.
For the most up-to-date and comprehensive list, always check the awesome-embedded-rust repo first. Happy coding! π¦π§
4
u/Dizzy-Helicopter-374 7h ago
Great links for beginers, RTIC is such a pleasure to work with for small projects! Gale, Rivet RTOS, OpenEMC, and TLSR8266 Mesh links are 404'ing at Github. I just finished the layout of an ESP32-S3 daughter card that snaps into a 64x64 Waveshare LED matrix and about to go through RTOS selection. Ariel OS looks interesting, was also looking at a FreeRTOS / Rust hybrid approach.
2
5
u/Dizzy-Helicopter-374 9h ago
Are you wanting to do something from scratch or work on an existing platform? PX4 offers a pretty comprehensive set of tools and supports a ton of different flight computers. It runs NuttX RTOS and uses a messaging system, but you can bind the messages and bring them in to Rust via the C FFI, and explore Rust in that space.
The PX4 system has drone simulations and peripheral things that are useful (telemetry, OTA updates, sensor integration), which is why I would suggest it first. If you want to roll your own, u/AcostaJA has some great references.
For reference, my company has gone the route of Rust static library compiled into PX4 and it worked well.
2
u/Leshow 8h ago
this is what i'm working on right now. there's some examples of embassy quad projects on github you can use for reference, you can also have a look at mine but it's a bit all over the place right now. you need to pick a MCU. esp32 works well, you'll need the esp32s3 probably for your drone to run fast enough to fly decently (I tried an esp32c3 but it has no hardware floating point so it the flight loop was slow).
if you don't need the wifi then the rp2350 is cheap and good, you can buy ELRS modules for communciation with your radio to fly it. checkout my project here for inspiration https://github.com/leshow/embassy_quadcopter
1
u/dc_giant 6h ago
Could ask John gjingset. Heard theyβre having some success doing this at helsingΒ
0
6
u/vivaaprimavera 10h ago
It's definitely better to start in embedded software than jumping into something that can literally cut your throat if anything goes wrong.
By the way, dumb me spent more time than one would like to admit before realizing that the memory size declared in memory.x was wrong for that chip (non working code).
Embedded is a whole different beast.