How Tech - Systems Programming

How Tech - Systems Programming

Debugging RISC-V Firmware with GDB and OpenOCD: From JTAG Signal to Source-Level Breakpoint

Sep 28, 2026
∙ Paid

1. Introduction

Debugging firmware is fundamentally different from debugging a userspace process. There is no ptrace(), no scheduler to preempt into a debugger, and frequently no operating system at all — just a hart sitting at its reset vector, executing whatever is in flash or ROM. On RISC-V, the mechanism that makes this possible is not a proprietary vendor protocol but an open, ratified specification: the RISC-V External Debug Support spec, which defines a hardware Debug Module (DM) inside the core, accessible over a transport such as JTAG. OpenOCD implements the host side of that transport and exposes a GDB Remote Serial Protocol (RSP) server; GDB becomes the client. Understanding this stack — from electrical signal to source line — is what separates an engineer who can bring up silicon from one who can only debug applications.

This lesson walks through the entire path: the historical reasons RISC-V standardized debug hardware instead of leaving it vendor-specific, how the Debug Module talks to a halted hart, how GDB’s RSP maps onto DM registers through OpenOCD, and how the same infrastructure underpins kgdb once Linux is actually running on the core.

User's avatar

Continue reading this post for free, courtesy of Systems.

Or purchase a paid subscription.
© 2026 Sumedh S · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture