Giao diện
Embedded Systems & Bare Metal Rust Expert
Rust không cần Operating System — Từ Microcontroller đến Kernel
Triết lý Module
"Bare Metal = Total Control"
Module này dành cho những ai muốn chạy Rust mà không có OS. Từ microcontrollers như STM32/ESP32 đến viết kernel cho x86_64 — đây là lãnh thổ của #![no_std].
⚠️ TARGET AUDIENCE
Module này dành cho Embedded Engineers và OS Developers — những người cần control từng byte memory và từng CPU cycle.
Kiến trúc Module
Cấu trúc Nội dung
📦 #![no_std] Universe
Hiểu điều gì xảy ra khi disable standard library. Custom heap allocators, panic handlers, và core library.
🎛️ Microcontroller Programming
Memory-Mapped I/O, hardware registers, embedded-hal traits. Viết portable drivers cho STM32/ESP32.
🖥️ OS Development Basics
Boot process từ BIOS/UEFI đến kernel. Inline assembly, Interrupt Descriptor Table, VGA text mode.
⚡ Low-Level Primitives
Volatile reads/writes, linker scripts, cross-compilation targeting bare metal.
Embedded Rust vs C
| Aspect | C | Rust |
|---|---|---|
| Memory Safety | Manual | Compile-time guaranteed |
| Undefined Behavior | Common | Contained in unsafe |
| Zero-cost Abstractions | Limited | Extensive (traits, generics) |
| Package Manager | None standard | Cargo |
| Hardware Access | Raw pointers | Type-safe PACs |
Prerequisites
- Rust Fundamentals: Ownership, Unsafe Rust
- Hardware Knowledge: Registers, memory maps, interrupts
- Target Architecture: ARM Cortex-M hoặc x86_64
Learning Path
┌─────────────────────────────────────────────────────────────────┐
│ │
│ 1. #![no_std] 2. Microcontrollers 3. OS Dev │
│ ──────────── ──────────────────── ────────── │
│ • Core library • MMIO registers • Boot process │
│ • Custom allocator • embedded-hal • Inline asm │
│ • Panic handler • HAL drivers • IDT/VGA │
│ │
│ From Embedded Device to Operating System │
│ │
└─────────────────────────────────────────────────────────────────┘1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
Công cụ Cần thiết
| Tool | Mục đích |
|---|---|
cargo-embed | Flash firmware to device |
probe-rs | Debug probes support |
cargo-binutils | Binary inspection (objdump, size) |
qemu-system-* | Emulate target hardware |
bootimage | Create bootable OS images |
"In embedded, every byte matters. In Rust, every byte is safe."