Use when developing embedded/no_std Rust. Keywords: embedded, no_std, microcontroller, MCU, ARM, RISC-V, bare metal, firmware, HAL, PAC, RTIC, embassy, interrupt, DMA, peripheral, GPIO, SPI, I2C, UART, embedded-hal, cortex-m, esp32, stm32, nrf, 嵌入式, 单片机, 固件, 裸机
指導 Rust 嵌入式與 no_std 開發,涵蓋限制、框架、crate 與硬體模式。
- 功能
- 此技能為撰寫嵌入式與 no_std Rust(例如微控制器韌體)提供領域指引。它列出無堆積配置、中斷安全與周邊裝置所有權等限制,並對應到 heapless 集合、臨界區與 HAL 單例等 Rust 模式。它也比較框架(RTIC、Embassy、裸機)、列出常用 crate,並提供靜態周邊裝置的程式碼範例與常見錯誤。產出的是參考說明,而非檔案或指令碼。
- 適用情境
- 適用於開發嵌入式或裸機 Rust,包括針對 ARM、RISC-V、STM32、ESP32、nRF 等 MCU 的 no_std 韌體。涉及 HAL、PAC、中斷、DMA 或周邊裝置,或在 RTIC、Embassy 與裸機方案之間做選擇時也適用。
- 執行需求
- 不需要指令碼或工具,僅為說明性內容。它假定處於 Rust 嵌入式專案環境,其注入的上下文會在存在時讀取 .cargo/config.toml。
Project Context (Auto-Injected)
Target configuration:
!cat .cargo/config.toml 2>/dev/null || echo "No .cargo/config.toml found"
Embedded Domain
Layer 3: Domain Constraints
Domain Constraints → Design Implications
Critical Constraints
No Dynamic Allocation
Interrupt Safety
Hardware Ownership
Trace Down ↓
From constraints to design (Layer 2):
Layer Stack
Framework Comparison
Key Crates
Design Patterns
Code Pattern: Static Peripheral
Common Mistakes
Trace to Layer 1
Related Skills