rust-embedded
Skill1 starsChanged 40 days agoMITView on GitHub
Bare-metal / microcontroller Rust (no_std firmware) — the constraints (no heap, interrupts, real-time deadlines, single-instance peripherals) and the patterns that satisfy them: heapless collections, peripheral singletons, embedded-hal drivers, ISR-safe critical sections, and RTIC vs Embassy. Use when writing firmware for Cortex-M / RISC-V / ESP or picking an MCU concurrency model. Triggers: no_std, cortex-m, esp32, stm32, rp2040, embedded-hal, RTIC, embassy, heapless, defmt, probe-rs.
5 other projects use a version of this.
Adopted by
Most recently taken up by
- adxptived/Rust-Skillstheir own version, first seen Oct 17, 2026
- full-stack-skills/rust-skillstheir own version, first seen Oct 15, 2026
- botirkhaltaev/botir-skillstheir own version, first seen Jul 24, 2026
- Microbiosis/rust-claude-skillstheir own version, first seen May 28, 2026
- huiali/rust-skillstheir own version, first seen Feb 9, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- huiali/rust-skills★ 47same name
- full-stack-skills/rust-skills★ 8same name
- botirkhaltaev/botir-skills★ 4same name
- adxptived/Rust-Skills★ 1same name
- Microbiosis/rust-claude-skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository42 other files it gives its agents.
- AGENTS.mdAGENTS.md
- addressing-findingsSkill
- auditSkill
- codebase-onboardingSkill
- codex-reviewSkill
- compatibilitySkill
- debuggingSkill
- developSkill
- distributed-racesSkill
- memorySkill
- nix-dev-envSkill
- nix-flakesSkill
- nixosSkill
- nix-packagingSkill
- nix-reviewSkill
- refactoringSkill
- retroSkill
- review-initSkill
- review-rulesSkill
- rust-architecture-reviewSkill
- rust-architectureSkill
- rust-cliSkill
- rust-cloud-nativeSkill
- rust-concurrencySkill
- rust-ecosystemSkill
- rust-errorsSkill
- rust-fintechSkill
- rust-idiomsSkill
- rust-macrosSkill
- rust-mlSkill
- rust-navigationSkill
- rust-ownershipSkill
- rust-performanceSkill
- rust-pluginsSkill
- rust-reviewSkill
- rust-securitySkill
- rust-testingSkill
- rust-traitsSkill
- rust-unsafeSkill
- rust-webSkill
- specsSkill
- sql-reviewSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 69
Write drivers against embedded-hal 1.0 traits (SpiDevice, I2c, OutputPin, …) rather than a concrete chip, so the same driver runs on STM32, …
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Rust Embedded
Firmware on a microcontroller: no OS, RAM measured in kilobytes, interrupts that preempt anything, and deadlines that are physical. There's no runtime to catch you — the compiler and the ownership model are your safety net. The job is to make the borrow checker enforce hardware invariants (one owner per peripheral, no data race with an ISR) at compile time.
The #![no_std]/#![no_main]/core/alloc/#[panic_handler] scaffold, target triples,
.cargo/config.toml, and cross-compilation are build mechanics owned by rust-ecosystem
(build-and-targets.md). This skill assumes that scaffold
and owns the domain patterns.
When to Use
- Firmware for a Cortex-M / RISC-V / ESP part — a
no_stdbinary that runs on bare metal - Driving peripherals (GPIO/SPI/I2C/UART/DMA) or writing/using a HAL or
embedded-haldriver - Choosing a concurrency model on an MCU (bare super-loop vs RTIC vs Embassy)
Constraints → Rust answer
| Constraint | Why it's physical | Rust answer |
| No heap (often no allocator) | deterministic memory; an OOM at 2 a.m. has no kill -9 | heapless fixed-capacity collections, arrays, static buffers — no Vec/Box/String |
| Interrupts preempt at any time | an ISR can fire between any two instructions of main | share via critical_section::Mutex<RefCell<…>> or atomics — never std::sync::Mutex (no OS to block on) |
| Real-time deadlines | a missed deadline is a defect, not slowness | bounded work on the hot path, no unbounded loops/alloc, priorities (→ concurrency.md) |
| A peripheral is one physical thing | two owners = bus/pin conflict | move-ownership singletons: take() once; the HAL consumes pins by value |
| No std (no OS) | no files / threads / net / println! | core only (→ rust-ecosystem); log with defmt over RTT, not println! |
| A panic can't unwind | it aborts or hangs the chip | a #[panic_handler] (panic-probe/panic-halt); design to return Result, not panic |
Memory without a heap: heapless
Capacity lives in the type, so allocation is static and failure is a value, not a crash:
use heapless::Vec; // heapless = "0.9"
let mut buf: Vec<u8, 64> = Vec::new(); // 64-byte capacity, on the stack/static — no allocator
buf.push(0xAB).ok(); // returns Err(value) when full; never reallocateslet mut s: heapless::String<32> = heapless::String::new(); // bounded String
let q: heapless::spsc::Queue<u8, 16> = heapless::spsc::Queue::new(); // ISR→main, lock-freePulling in the alloc crate (+ embedded-alloc) to use Vec/String is possible but a smell on
a small part — it reintroduces fragmentation and non-determinism you came here to avoid. Reach for
it only with a real reason and headroom.
Peripherals are singletons — the borrow checker as a hardware mutex
Peripherals::take() hands out the register block once (None afterward), so two pieces of
code can't both think they own the UART. The HAL then consumes pins by value, so a pin can't be
configured into two roles:
let dp = pac::Peripherals::take().unwrap(); // ✓ one-time boot precondition; unwrap is fine here
let gpioa = dp.GPIOA.split();
let led = gpioa.pa5.into_push_pull_output(); // pa5 is moved — no one else can claim it
// dp.GPIOA … // ✗ already moved; conflict caught at compile timeWrite drivers against embedded-hal 1.0 traits (SpiDevice, I2c, OutputPin, …) rather
than a concrete chip, so the same driver runs on STM32, nRF, RP2040, ESP — dispatch/generics are
rust-traits.
Sharing with an interrupt (the signature pattern)
main and an ISR both touch a peripheral → you need a critical section (briefly disable
interrupts), not a blocking lock. The portable idiom is the critical-section crate:
use critical_section::Mutex; // NOT std::sync::Mutex — this one disables interrupts
use core::cell::RefCell;
static LED: Mutex<RefCell<Option<Led>>> = Mutex::new(RefCell::new(None));
// in main, after init: move the peripheral into the static (prior None is discarded)
critical_section::with(|cs| LED.borrow(cs).replace(Some(led)));
// in the ISR and in main:
critical_section::with(|cs| {
if let Some(led) = LED.borrow(cs).borrow_mut().as_mut() { led.toggle(); }
});It builds on interior mutability (RefCell → rust-ownership), but the Mutex is a
critical-section mutex (no OS to park a thread). For a single flag/counter, a lock-free atomic
is cheaper than a critical section. Atomics, portable-atomic for chips without native CAS,
SPSC queues, and the full RTIC vs Embassy decision → concurrency.md.
Log and flash: defmt + probe-rs
There's no console, so don't println!. Use defmt (deferred formatting — the format string
stays on the host, only IDs go over the wire) via defmt-rtt, and panic-probe to print panics.
Flash and run with probe-rs run / cargo embed (these supersede the old probe-run); wire
it as the runner in .cargo/config.toml. Add flip-link for near-zero-cost stack-overflow
protection.
Don't panic in steady state
A panic on an MCU aborts or hangs the chip. take().unwrap() at init is fine (a one-time boot
precondition); past init, keep everything Result-based and avoid unwrap/indexing that can
panic. Errors are usually small enums deriving defmt::Format (core::error::Error is available
since 1.81 if you need it). The error strategy is rust-errors; #[entry] fn main() -> ! never
returns.
Boundaries
#![no_std]/#![no_main]/core/alloc/#[panic_handler], target triples,.cargo/config.toml, cross-compilation →rust-ecosystem(build-and-targets.md).RefCell/Cellinterior mutability andDrop/RAII that the ISR mutex builds on →rust-ownership(the critical-section mutex is embedded-specific and owned here).Send/Syncand the threads-vs-async model on a hosted OS →rust-concurrency(an MCU has no threads; ISR / RTIC / Embassy concurrency lives in concurrency.md).Result-vs-panic, defects vs failures →rust-errors. Portable driver generics →rust-traits.unsafefor raw MMIO / register access, or hand-writing a PAC →rust-unsafe.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

