Learn Bare Metal Programming — Expanded Project Guides

Generated from: LEARN_BARE_METAL_PROGRAMMING.md

This folder contains deep-dive guides for each project in the bare metal programming learning path.


Overview

Bare metal programming means writing code that runs directly on hardware—no operating system, no runtime, no abstractions. Your code is the first thing the CPU executes after power-on. You control everything: memory, peripherals, interrupts, the CPU itself.

Traditional Programming:          Bare Metal Programming:
┌─────────────────────────┐      ┌─────────────────────────┐
│     Your Application    │      │                         │
├─────────────────────────┤      │     Your Code           │
│    Runtime/Libraries    │      │     (Everything!)       │
├─────────────────────────┤      │                         │
│   Operating System      │      │                         │
├─────────────────────────┤      ├─────────────────────────┤
│       Hardware          │      │       Hardware          │
└─────────────────────────┘      └─────────────────────────┘

These expanded project guides transform the project summaries into comprehensive implementation guides. Each guide provides:

  • Deep theoretical foundations — Learn the concepts before building
  • Solution architecture — Understand what the solution looks like without being given the code
  • Phased implementation — Step-by-step guidance to keep you on track
  • Testing strategies — Know how to verify your work
  • Common pitfalls — Avoid the mistakes others have made
  • Real-world connections — See how this applies beyond the classroom

Project Index

# Project Platform Difficulty Time Key Focus
1 Blink LED on AVR Arduino/AVR Beginner Weekend GPIO, registers, cross-compilation
2 UART Serial Communication Arduino/AVR Intermediate 1 week Serial protocol, interrupts, ring buffers
3 Hardware Timer and PWM Arduino/AVR Intermediate 1 week Timers, PWM, interrupts
4 Raspberry Pi Bare Metal Raspberry Pi Advanced 2 weeks ARM architecture, boot process, linker scripts
5 x86 Bootloader - Real Mode x86 (QEMU) Expert 1-2 weeks Real mode, BIOS services, boot sector
6 x86 Protected Mode Kernel x86 (QEMU) Expert 2-3 weeks GDT, protected mode, VGA
7 Interrupt Descriptor Table x86 (QEMU) Expert 2 weeks IDT, ISRs, PIC, exceptions
8 Memory Management - Paging x86 (QEMU) Master 3-4 weeks Virtual memory, page tables, MMU
9 STM32 Bare Metal STM32/ARM Advanced 3-4 weeks ARM Cortex-M, clocks, DMA
10 Simple Kernel with Multitasking x86 (QEMU) Master 4-6 weeks Context switching, scheduling, TCB
11 File System Driver x86 (QEMU) Expert 3-4 weeks ATA/IDE, FAT16, block I/O
12 UEFI Application x86 (QEMU) Advanced 2 weeks Modern boot, GOP, UEFI services

Learning Paths

Choose a path based on your goals and available hardware:

Path 1: Microcontroller Basics (4-6 weeks)

P1 → P2 → P3

Best for: Beginners, embedded systems introduction, limited hardware budget (~$25)

What you’ll learn: GPIO registers, serial communication, hardware timers, interrupt handling on simple 8-bit microcontrollers.

Path 2: ARM Architecture (4-6 weeks)

P4 → P9

Best for: Understanding ARM systems, professional embedded development

What you’ll learn: ARM boot process, Cortex-M architecture, professional embedded toolchain (STM32), DMA transfers.

Path 3: x86 Boot Process (6-8 weeks)

P5 → P6 → P12

Best for: OS development foundation, understanding PC boot

What you’ll learn: BIOS/real mode, protected mode transition, UEFI modern boot, GDT setup, VGA output.

Path 4: OS Foundations (8-12 weeks)

P7 → P8 → P11 → P10

Best for: Operating system development, kernel programming

What you’ll learn: Interrupt handling, virtual memory, file systems, multitasking/scheduling.

Complete Path (6-12 months)

P1 → P2 → P3 → P4 → P9 → P5 → P6 → P12 → P7 → P8 → P11 → P10

Best for: Maximum depth, comprehensive bare metal mastery


Dependency Graph

                                    ┌─────────────────────────┐
                                    │  PROJECT 10: CAPSTONE   │
                                    │   Multitasking Kernel   │
                                    └───────────┬─────────────┘
                                                │
              ┌─────────────────────────────────┼─────────────────────────────────┐
              │                                 │                                 │
              ▼                                 ▼                                 ▼
    ┌─────────────────┐               ┌─────────────────┐               ┌─────────────────┐
    │  P11: File      │               │  P8: Memory     │               │  P7: Interrupt  │
    │  System Driver  │               │  Paging         │               │  Table (IDT)    │
    └────────┬────────┘               └────────┬────────┘               └────────┬────────┘
             │                                 │                                 │
             └─────────────────────────────────┼─────────────────────────────────┘
                                               │
                                               ▼
                                      ┌─────────────────┐
                                      │  P6: Protected  │
                                      │  Mode Kernel    │
                                      └────────┬────────┘
                                               │
                         ┌─────────────────────┴─────────────────────┐
                         │                                           │
                         ▼                                           ▼
               ┌─────────────────┐                         ┌─────────────────┐
               │  P5: x86        │                         │  P12: UEFI      │
               │  Bootloader     │                         │  Application    │
               └────────┬────────┘                         └─────────────────┘
                        │
                        │ (x86 path)
        ┌───────────────┴───────────────┐
        │                               │
        ▼                               ▼
┌─────────────────┐             ┌─────────────────┐
│  P4: Raspberry  │             │  P9: STM32      │
│  Pi Bare Metal  │             │  Bare Metal     │
└────────┬────────┘             └────────┬────────┘
         │ (ARM path)                    │ (ARM path)
         └───────────────┬───────────────┘
                         │
                         ▼
                ┌─────────────────┐
                │  P3: Timer/PWM  │
                └────────┬────────┘
                         │
                         ▼
                ┌─────────────────┐
                │  P2: UART       │
                │  Serial         │
                └────────┬────────┘
                         │
                         ▼
                ┌─────────────────┐
                │  P1: Blink LED  │
                │  (Start Here)   │
                └─────────────────┘
                      START

Hardware Requirements

Platform Hardware Needed Approximate Cost
AVR (P1-P3) Arduino Uno or ATmega328P ~$25
ARM RPi (P4) Raspberry Pi 3/4, USB-TTL cable ~$50
STM32 (P9) STM32F4 Blue Pill or Nucleo ~$5-15
x86 (P5-P8, P10-P12) QEMU only (free!) $0

Note: All x86 projects run in QEMU emulator—no physical hardware required!


Prerequisites for the Learning Journey

Before starting Project 1, you should have:

  • C Programming: Comfortable writing, compiling, and debugging C programs
  • Command Line: Familiar with Linux/Unix shell, basic navigation
  • Binary/Hex: Understand binary and hexadecimal notation
  • Datasheet Reading: Willing to read hardware documentation
  • Patience: Bare metal debugging can be challenging!

Recommended but not required:

  • Some exposure to assembly language
  • Basic electronics knowledge (for hardware projects)
  • Experience with embedded systems or Arduino

Tools You’ll Need

For AVR Projects (P1-P3)

  • avr-gcc - AVR cross-compiler
  • avrdude - Programmer utility
  • Arduino Uno or compatible board
  • USB cable

For Raspberry Pi (P4)

  • arm-none-eabi-gcc - ARM cross-compiler
  • Raspberry Pi 3 or 4
  • USB-to-TTL serial cable
  • microSD card

For STM32 (P9)

  • arm-none-eabi-gcc - ARM cross-compiler
  • OpenOCD or st-link - Programming tools
  • STM32F4 board

For x86 Projects (P5-P8, P10-P12)

  • NASM - x86 assembler
  • i686-elf-gcc - i386 cross-compiler (or x86_64-elf-gcc)
  • QEMU - Emulator
  • GDB - Debugger
  • OVMF - UEFI firmware (for P12)

How to Use These Guides

  1. Read the theory first — Don’t jump to implementation
  2. Study the solution architecture — Understand the “shape” of the solution
  3. Follow the phased approach — Complete checkpoints before moving on
  4. Use the testing strategy — Verify as you go
  5. Check your understanding — Complete the self-assessment checklist
  6. Try the extensions — Push yourself further

Essential Resources

Books

  • “Operating Systems: Three Easy Pieces” by Arpaci-Dusseau — Free online, excellent for OS concepts
  • “Making Embedded Systems” by Elecia White — Practical embedded development
  • “Bare-metal programming for ARM” by Daniels Umanovskis — Free ebook, covers ARM basics
  • “Write Great Code, Volume 1 & 2” by Randall Hyde — Low-level programming
  • “AVR Workshop” by John Boxall — AVR fundamentals

Online Resources


For the original project summaries, see LEARN_BARE_METAL_PROGRAMMING.md