OpenOCD / JTAG Debugging
Purpose
Guide agents through configuring OpenOCD for JTAG and SWD targets, flashing firmware to microcontrollers, attaching GDB for bare-metal debugging, setting hardware watchpoints, and configuring J-Link and CMSIS-DAP adapters.
Triggers
- "How do I connect GDB to my MCU with OpenOCD?"
- "How do I flash firmware using OpenOCD?"
- "How do I set up J-Link with OpenOCD?"
- "What's the difference between JTAG and SWD?"
- "How do I set a hardware watchpoint in GDB?"
- "OpenOCD says 'Error: unable to find JTAG device' — how do I fix it?"
Workflow
1. JTAG vs SWD
Most Cortex-M microcontrollers support both. Use SWD when pin count is limited.
2. OpenOCD configuration
3. Connecting GDB
4. Flashing firmware
5. Hardware breakpoints and watchpoints
Software breakpoints (break) patch instruction memory with trap instructions — they don't work in flash-execute-in-place without debug registers. Use hardware breakpoints instead:
6. OpenOCD commands reference
7. Common errors
8. J-Link configuration
J-Link GDB Server (alternative to OpenOCD):
Related skills
- Use
skills/embedded/freertosfor FreeRTOS-aware debugging with OpenOCD - Use
skills/embedded/zephyrfor Zephyr'swest debugintegration - Use
skills/debuggers/gdbfor GDB session management - Use
skills/embedded/linker-scriptsfor understanding memory map for flash addresses


