rust-embedded
Skill4 starsChanged 3 months agoApache-2.0View on GitHub
Embedded Rust development for bare-metal and no_std environments. Use when targeting microcontrollers, writing HAL drivers, working with peripherals, handling interrupts, or using RTIC/Embassy for real-time systems.
Files
Rust Embedded Development
Based on The Embedded Rust Book, The Embedonomicon, and Embedded Rust on Espressif.
When to Use This Skill
- Writing
#![no_std]applications for microcontrollers - Working with HAL (Hardware Abstraction Layer) crates
- Configuring linker scripts and memory layouts
- Handling interrupts and DMA
- Using RTIC or Embassy for concurrency
- Targeting ARM Cortex-M, RISC-V, or ESP32
Project Structure
my-firmware/
├── .cargo/config.toml # target, linker settings
├── Cargo.toml
├── memory.x # memory layout (flash + RAM regions)
├── build.rs # optional: extra link args
└── src/
└── main.rs # #![no_std] #![no_main]Minimal no_std Binary
#![no_std]
#![no_main]
use panic_halt as _; // panic handler (halt on panic)
use cortex_m_rt::entry;
#[entry]
fn main() -> ! {
// Initialize peripherals
let dp = pac::Peripherals::take().unwrap();
let mut led = dp.GPIOA.pin(5).into_push_pull_output();
loop {
led.toggle();
cortex_m::asm::delay(8_000_000);
}
}Memory Layout (memory.x)
MEMORY
{
FLASH : ORIGIN = 0x08000000, LENGTH = 256K
RAM : ORIGIN = 0x20000000, LENGTH = 64K
}.cargo/config.toml
[target.thumbv7em-none-eabihf]
runner = "probe-rs run --chip STM32F303VCTx"
[build]
target = "thumbv7em-none-eabihf"
[env]
DEFMT_LOG = "info"HAL Layer Architecture
┌─────────────────────────────┐
│ Application Code │
├─────────────────────────────┤
│ HAL (e.g. stm32f3xx-hal) │ ← high-level, safe API
├─────────────────────────────┤
│ PAC (e.g. stm32f3) │ ← auto-generated register access
├─────────────────────────────┤
│ Hardware │
└─────────────────────────────┘- PAC (Peripheral Access Crate): Generated from SVD files, provides raw register access
- HAL: Type-safe wrappers implementing
embedded-haltraits - BSP (Board Support Package): Board-specific pin mappings and initialization
embedded-hal Traits
Portable driver abstraction:
use embedded_hal::digital::OutputPin;
use embedded_hal::i2c::I2c;
use embedded_hal::spi::SpiDevice;
use embedded_hal::delay::DelayNs;
// Write a portable driver
pub struct Sensor<I2C> {
i2c: I2C,
addr: u8,
}
impl<I2C: I2c> Sensor<I2C> {
pub fn read_temp(&mut self) -> Result<f32, I2C::Error> {
let mut buf = [0u8; 2];
self.i2c.write_read(self.addr, &[0x00], &mut buf)?;
Ok(i16::from_be_bytes(buf) as f32 * 0.0625)
}
}Interrupts
use cortex_m::peripheral::NVIC;
use stm32f3xx_hal::pac::interrupt;
#[interrupt]
fn TIM2() {
// Timer interrupt handler
// Access shared state via critical section or RTIC resources
cortex_m::interrupt::free(|cs| {
if let Some(timer) = TIMER.borrow(cs).borrow_mut().as_mut() {
timer.clear_interrupt(Event::Update);
}
});
}RTIC (Real-Time Interrupt-driven Concurrency)
#[rtic::app(device = stm32f3xx_hal::pac, dispatchers = [SPI1])]
mod app {
use super::*;
#[shared]
struct Shared { led: Led }
#[local]
struct Local { timer: Timer }
#[init]
fn init(cx: init::Context) -> (Shared, Local) {
// Setup peripherals
(Shared { led }, Local { timer })
}
#[task(binds = TIM2, local = [timer], shared = [led])]
fn tick(cx: tick::Context) {
cx.local.timer.clear_interrupt();
cx.shared.led.lock(|led| led.toggle());
}
}Key Crates
| Crate | Purpose |
cortex-m | Low-level ARM Cortex-M access |
cortex-m-rt | Runtime (vector table, entry) |
panic-halt | Panic handler: infinite loop |
defmt | Efficient logging for embedded |
probe-rs | Flashing and debugging tool |
embedded-hal | Hardware abstraction traits |
rtic | Real-time concurrency framework |
embassy | Async embedded framework |
Reference Map
references/no-std-basics.md— no_std setup, panic handlers, allocreferences/peripherals-hal.md— GPIO, timers, I2C, SPI, UARTreferences/interrupts-concurrency.md— NVIC, critical sections, RTIC, Embassy
Key References
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- huiali/rust-skills★ 47same name
- full-stack-skills/rust-skills★ 8same 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 repository80 other files it gives its agents.
- a11y-accessibility-designSkill
- agentic-ui-patternsSkill
- ai-native-ui-designSkill
- ai-ui-anti-patternsSkill
- ai-ui-heuristicsSkill
- calm-technology-uiSkill
- conversion-growth-designSkill
- cross-platform-designSkill
- dark-mode-designSkill
- data-visualizationSkill
- design-systemsSkill
- design-thinking-processSkill
- error-empty-statesSkill
- ethical-design-patternsSkill
- form-uxSkill
- information-architectureSkill
- interaction-design-patternsSkill
- internationalization-uiSkill
- mobile-touch-designSkill
- modal-classes-lifecycleSkill
- modal-container-imagesSkill
- modal-dicts-queuesSkill
- modal-endpointsSkill
- modal-fundamentalsSkill
- modal-gpu-computeSkill
- modal-networkingSkill
- modal-observabilitySkill
- modal-parallel-executionSkill
- modal-sandboxesSkill
- modal-scaling-performanceSkill
- modal-schedulingSkill
- modal-secretsSkill
- modal-serversSkill
- modal-storageSkill
- modal-web-servingSkill
- modal-workspace-adminSkill
- motion-design-principlesSkill
- notifications-permissionsSkill
- onboarding-uxSkill
- rust-api-designSkill
- rust-async-programmingSkill
- rust-cargo-masterySkill
- rust-cli-applicationsSkill
- rust-clippy-lintsSkill
- rust-closures-iteratorsSkill
- rust-compiler-internalsSkill
- rust-concurrencySkill
- rust-design-patternsSkill
- rust-editionsSkill
- rust-error-handlingSkill
- rust-game-developmentSkill
- rust-lifetimes-borrowingSkill
- rust-macrosSkill
- rust-performanceSkill
- rust-rustdocSkill
- rust-rustup-toolchainSkill
- rust-smart-pointersSkill
- rust-testing-benchmarkingSkill
- rust-type-systemSkill
- rust-unsafe-ffiSkill
- The first 60 shown.
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.

