Skip to content

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 EngineersOS 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

AspectCRust
Memory SafetyManualCompile-time guaranteed
Undefined BehaviorCommonContained in unsafe
Zero-cost AbstractionsLimitedExtensive (traits, generics)
Package ManagerNone standardCargo
Hardware AccessRaw pointersType-safe PACs

Prerequisites

  1. Rust Fundamentals: Ownership, Unsafe Rust
  2. Hardware Knowledge: Registers, memory maps, interrupts
  3. 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           │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Công cụ Cần thiết

ToolMục đích
cargo-embedFlash firmware to device
probe-rsDebug probes support
cargo-binutilsBinary inspection (objdump, size)
qemu-system-*Emulate target hardware
bootimageCreate bootable OS images

"In embedded, every byte matters. In Rust, every byte is safe."