ticktrace
// book

Learning Assembly with ticktrace

A book for total beginners who want to understand what a CPU really does and write their own bare-metal firmware for the Raspberry Pi Pico 2. You should be comfortable with some programming language; you do not need prior assembly experience.

// chapters

  1. 01
    Chapter 1: Introduction
    This book is a working introduction to ARM Thumb-2 assembly programming on the Raspberry Pi RP2350 microcontroller. It uses **ticktrace**, a pure-assembly SDK for that chip, as its running codebase.
  2. 02
    Chapter 2: What is assembly language?
    Before we touch a Pico, let's get clear on what assembly *is*.
  3. 03
    Chapter 3: The RP2 family
    The "RP2" in ticktrace refers to the family of microcontrollers designed by Raspberry Pi Ltd themselves, first the RP2040 (launched in 2021) and then the RP2350 (launched in 2024). They are the silicon at the heart of the Raspberry Pi Pico
  4. 04
    Chapter 4: The Cortex-M33 and Thumb-2
    This chapter is a closer look at the processor that runs your ticktrace code. Don't try to memorise everything here, treat it as a reference to come back to. You'll absorb the details as you write programs.
  5. 05
    Chapter 5: Setting up ticktrace
    In this chapter we install the toolchain, clone ticktrace, and build the default blinky.uf2. By the end you'll be one drag-and-drop away from a running program.
  6. 06
    Chapter 6: Your first program: blinky
    Time to read code.
  7. 07
    Chapter 7: Assembler syntax and instructions
    You've read one program end-to-end. This chapter zooms in on the *syntax* of GNU ARM assembly so you can read driver code, not just user code. Think of it as a reference you'll come back to until the patterns become instinctive.
  8. 08
    Chapter 8: Functions and the calling convention
    Up to now we've been calling ticktrace driver functions without thinking too hard about *how* the calling works. In this chapter we make the rules explicit, so that you can write your own functions and have them play nicely with the rest of
  9. 09
    Chapter 9: GPIO and memory-mapped I/O
    The chip's CPU and its peripherals are separate hardware blocks, but they share an address space. To talk to a peripheral you just read or write memory, at certain *special* addresses. This is called **memory-mapped I/O**, or MMIO, and it i
  10. 10
    Chapter 10: UART: talking to the host
    A blinking LED is satisfying but limited. To debug real programs you need a way for the chip to *say things*, print numbers, log states, report errors. The classic way to do that on a microcontroller is a **UART**: a serial port that sends
  11. 11
    Chapter 11: Timers and interrupts
    Our blinky program loops 12 million times to delay 250 ms. While it does that, the CPU is fully occupied, 100% busy doing literally nothing. That's a bad pattern. Microcontrollers should sleep when there's no work, and wake up only when som
  12. 12
    Chapter 12: Scheduling
    [Chapter 11](11-timers-and-interrupts.md) introduced interrupts as a way to react to single hardware events. Real firmware usually has more than one thing to do: read a UART, drive a motor, blink a status LED, service a button. Once you hav
  13. 13
    Chapter 13: Multicore
    The RP2350 has **two** Cortex-M33 cores on the same die. They share SRAM, peripherals, and the SIO block; each has its own register file, NVIC, and SysTick. Up to chapter 12 we have used core 0 exclusively and let core 1 sit in its reset st
  14. 14
    Chapter 14: Where to go next
    You can now read and write ticktrace. You understand registers, instructions, the calling convention, memory-mapped I/O, GPIO, UART, interrupts, scheduling, and multicore. That's enough vocabulary to navigate the entire SDK. The rest is *wh

// appendices

  1. A
    Appendix A: Glossary
    Every term used in this book, with a one-paragraph definition and a pointer to the chapter that introduces it.
  2. B
    Appendix B: Cheat sheet
    Everything you need to read or write a ticktrace function, in one place.
  3. C
    Appendix C: Debugging
    This appendix is a quick map of the debugging options available to a ticktrace program. It is not a tutorial, it's a "which tool when" reference. Deeper coverage of GDB/OpenOCD will come in a later revision once the on-chip debug surface in
  4. D
    Appendix D: Memory layouts and execution patterns
    Up to chapter 14 this book has treated flash-vs-SRAM as a binary choice: build the flash variant for production, the SRAM variant for emulation tests. The RP2350 hardware supports more than two patterns, and the right choice for hard-real-t
  5. E
    Appendix E: Studio
    Up to this point every example in the book has been built and flashed the same way: make build/<name>_flash.uf2, hold BOOTSEL, drag-drop. That is the truthful, low-level path: the Makefile is the build system, picotool (or the BOOTSEL drive