Project 2: UART Driver from Scratch (Raspberry Pi Pico)
A serial driver in pure assembly that lets you send “Hello, World!” to your computer over USB-serial, with both polling and interrupt-driven modes.
Quick Reference
| Attribute | Value |
|---|---|
| Primary Language | See main guide |
| Alternative Languages | N/A |
| Difficulty | Level 4: Expert |
| Time Estimate | 1-2 weeks |
| Knowledge Area | Embedded Systems / Drivers |
| Tooling | Raspberry Pi Pico |
| Prerequisites | Project 1 completed, basic serial terminal usage |
What You Will Build
A serial driver in pure assembly that lets you send “Hello, World!” to your computer over USB-serial, with both polling and interrupt-driven modes.
Why It Matters
This project builds core skills that appear repeatedly in real-world systems and tooling.
Core Challenges
- Configuring UART peripheral registers (baud rate divisors, word length, parity)
- Implementing polling-based TX/RX by checking status flags
- Setting up the NVIC (Nested Vectored Interrupt Controller) for UART interrupts
- Writing an interrupt service routine (ISR) that preserves registers correctly
- Handling the RP2040’s dual-core memory considerations
Key Concepts
- UART Protocol & Registers: RP2040 Datasheet Chapter 4 (UART) - Raspberry Pi Foundation
- ARM Procedure Call Standard: “Modern Arm Assembly Language Programming” Ch. 2 - Daniel Kusswurm
- NVIC & Interrupt Handling: “Making Embedded Systems, 2nd Edition” Ch. 4 - Elecia White
- Status Register Polling: STM32 Cortex M0 Bare Metal Tutorial - Martin Hubacek
Real-World Outcome
$ screen /dev/ttyACM0 115200
Hello from bare-metal assembly!
Character count: 35
Implementation Guide
- Reproduce the simplest happy-path scenario.
- Build the smallest working version of the core feature.
- Add input validation and error handling.
- Add instrumentation/logging to confirm behavior.
- Refactor into clean modules with tests.
Milestones
- Milestone 1: Minimal working program that runs end-to-end.
- Milestone 2: Correct outputs for typical inputs.
- Milestone 3: Robust handling of edge cases.
- Milestone 4: Clean structure and documented usage.
Validation Checklist
- Output matches the real-world outcome example
- Handles invalid inputs safely
- Provides clear errors and exit codes
- Repeatable results across runs
References
- Main guide:
ARM_ASSEMBLY_LEARNING_PROJECTS.md - “Making Embedded Systems” by Elecia White