# Rust Embedded

> Rust for embedded systems Use when this capability is needed.

- Skill: `tomevault-io/rust-embedded-2` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/rust-embedded-2`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/rust-embedded-2/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/rust-embedded-2

---

# Rust Embedded

> Develop embedded systems firmware with Rust for safety, performance, and modern tooling.

## Quick Start
```rust
//! Blinky example for STM32 microcontroller
#![no_std]
#![no_main]

use cortex_m_rt::entry;
use panic_halt as _;
use stm32f4xx_hal::{
    pac,
    prelude::*,
    timer::Timer,
};
use embedded_hal::digital::OutputPin;

#[entry]
fn main() -> ! {
    // Get peripherals
    let dp = pac::Peripherals::take().unwrap();
    let cp = cortex_m::Peripherals::take().unwrap();

    // Configure clocks
    let rcc = dp.RCC.constrain();
    let clocks = rcc.cfgr.sysclk(48.MHz()).freeze();

    // Configure LED pin (PC13 on many STM32 boards)
    let gpioc = dp.GPIOC.split();
    let mut led = gpioc.pc13.into_push_pull_output();

    // Configure timer
    let mut timer = Timer::syst(cp.SYST, 1.Hz(), &clocks);

    // Blink loop
    loop {
        led.set_high().unwrap();
        timer.wait(); // 1 second delay
        led.set_low().unwrap();
        timer.wait();
    }
}
```

```toml
# .cargo/config.toml — Cross-compilation target
[target.thumbv7em-none-eabihf]
runner = "gdb-multiarch"
rustflags = ["-C", "link-arg=-Tlink.x", "-C", "linker=arm-none-eabi-gcc"]

[build]
target = "thumbv7em-none-eabihf"
```

```rust
// Embedded HAL traits — abstraction for portability
use embedded_hal::{
    blocking::delay::DelayMs,
    digital::OutputPin,
    spi::SpiDevice,
};

fn control_display<D: DelayMs<u32>, P: OutputPin>(
    delay: &mut D,
    reset: &mut P,
) {
    reset.set_low().unwrap();
    delay.delay_ms(10);
    reset.set_high().unwrap();
    delay.delay_ms(100);
}
```

## Key Concepts
`#![no_std]` enables bare-metal code without the standard library. The Embedded HAL provides portable hardware abstraction. `cortex-m-rt` handles vector table and startup. Use probe-rs for flashing and debugging.

## When to Use
- Firmware for ARM Cortex-M, RISC-V microcontrollers
- IoT sensor nodes and actuators
- Safety-critical embedded systems
- Replacing C/C++ with memory-safe Rust

## Validation
1. `cargo build --target thumbv7em-none-eabihf` compiles without std
2. Firmware flashes to device and runs (LED blinks)
3. UART/sensor output matches expected values
4. Binary size fits within target flash memory

---
> Source: [ssrjkk/claude-skills](https://github.com/ssrjkk/claude-skills) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-06-16 -->

