/openocd-jtag
OpenOCD skill for embedded hardware debugging. Use when configuring OpenOCD for JTAG or SWD targets, flashing firmware, connecting GDB to bare-metal targets, setting hardware watchpoints, or using J-Link with OpenOCD. Activates on queries about OpenOCD, JTAG, SWD, GDB remote
$ npx -y skills add mohitmishra786/low-level-dev-skills --skill openocd-jtag --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/openocd-jtag
Context preview
The summary Claude sees to decide when to auto-load this skill.
OpenOCD skill for embedded hardware debugging. Use when configuring OpenOCD for JTAG or SWD targets, flashing firmware, connecting GDB to bare-metal targets, setting hardware watchpoints, or using J-Link with OpenOCD. Activates on queries about OpenOCD, JTAG, SWD, GDB remote
SKILL.md
openocd-jtag.SKILL.mdname: openocd-jtag
description: OpenOCD skill for embedded hardware debugging. Use when configuring OpenOCD for JTAG or SWD targets, flashing firmware, connecting GDB to bare-metal targets, setting hardware watchpoints, or using J-Link with OpenOCD. Activates on queries about OpenOCD, JTAG, SWD, GDB remote target, flash programming, hardware breakpoints, J-Link, or connecting GDB to an MCU.
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
| Feature | JTAG | SWD (Serial Wire Debug) | |---------|------|------------------------| | Pins | 4+ (TCK, TMS, TDI, TDO, TRST) | 2 (SWCLK, SWDIO) | | Multi-target | Yes (daisy chain) | No (one target) | | Speed | Up to 30 MHz | Up to 10 MHz | | Availability | Full JTAG: Cortex-A/R, RISC-V | SWD: Cortex-M only | | Cable cost | More complex | Simpler 2-wire |
Most Cortex-M microcontrollers support both. Use SWD when pin count is limited.
2. OpenOCD configuration
# openocd.cfg — CMSIS-DAP (ST-Link v2, DAPLink)
source [find interface/cmsis-dap.cfg]
source [find target/stm32f4x.cfg]
adapter speed 4000 # kHz
# For SWD explicitly
transport select swd
# J-Link adapter
source [find interface/jlink.cfg]
jlink serial 123456789 # optional: select by serial
source [find target/nrf52.cfg]
adapter speed 8000
# Run OpenOCD (keeps running, serves GDB on port 3333)
openocd -f openocd.cfg
# Common interface config files
ls $(openocd --help 2>&1 | grep "scripts" | head -1)/interface/
# cmsis-dap.cfg, jlink.cfg, ftdi/olimex-arm-usb-ocd.cfg, stlink.cfg ...
# Common target config files
ls $(openocd --help 2>&1 | grep "scripts" | head -1)/target/
# stm32f4x.cfg, nrf52.cfg, esp32.cfg, rp2040.cfg, at91sam4s.cfg ...
3. Connecting GDB
# In terminal 1: start OpenOCD
openocd -f openocd.cfg
# In terminal 2: start GDB
arm-none-eabi-gdb firmware.elf
# GDB commands
(gdb) target extended-remote :3333 # connect to OpenOCD
(gdb) monitor reset halt # reset and halt target
(gdb) load # flash ELF to target
(gdb) monitor reset init # re-initialize after flash
(gdb) break main # set software breakpoint
(gdb) continue
# One-liner for quick debugging
arm-none-eabi-gdb -ex "target extended-remote :3333" \
-ex "monitor reset halt" \
-ex "load" \
-ex "break main" \
-ex "continue" \
firmware.elf4. Flashing firmware
# Flash via OpenOCD telnet interface
telnet localhost 4444
# OpenOCD telnet commands
> reset halt
> program firmware.elf verify reset
> exit
# Or via GDB
(gdb) monitor flash write_image erase firmware.bin 0x08000000
(gdb) monitor reset run
# Flash only (no debug) — script mode
openocd -f openocd.cfg \
-c "program firmware.elf verify reset exit"
# For raw binary
openocd -f openocd.cfg \
-c "program firmware.bin 0x08000000 verify reset exit"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:
# Hardware breakpoint (uses debug register, limited count: 4-8 on Cortex-M)
(gdb) hbreak function_name
(gdb) hbreak *0x08001234
# Hardware watchpoint — triggers on memory read/write
(gdb) watch global_variable # write watchpoint
(gdb) rwatch some_buffer # read watchpoint
(gdb) awatch sensor_value # read OR write watchpoint
# List breakpoints/watchpoints
(gdb) info breakpoints
# Cortex-M typically has: 4–8 hardware breakpoints, 2–4 watchpoints
6. OpenOCD commands reference
# Via telnet (port 4444) or GDB monitor
monitor reset halt # reset and hold at reset vector
monitor reset init # reset and run init scripts
monitor reset run # reset and run freely
monitor halt # halt running target
monitor resume # resume execution
monitor mdw 0x20000000 # memory display word at address
monitor mww 0x40021000 0x1 # memory write word
monitor reg r0 # read register
monitor arm disassemble 0x08000000 16 # disassemble 16 instructions
# Flash operations
monitor flash list
monitor flash erase_sector 0 0 0 # erase sector 0
monitor flash write_bank 0 firmware.bin 0
7. Common errors
| Error | Cause | Fix | |-------|-------|-----| | `unable to find JTAG device` | Wrong interface, cable, or power | Check USB connection; power target; verify interface config | | `JTAG scan chain interrogation failed` | Wrong target config or bad SWD mode | Match config to exact MCU; try `transport select swd` | | `flash 'stm32f4x' is not supported` | Wrong target | Check MCU part number; use correct `.cfg` | | `Error: timed out while waiting for target halted` | Target running, not halted | `monitor halt`; check BOOT pins | | `Cannot access memory at address` | MMU, memory protection, or wrong address | Check MPU config; use correct flash/RAM address | | `Warn: target not examined yet` | OpenOCD not connected to target | Check power and connections |
8. J-Link configuration
# openocd.cfg for J-Link
source [find interface/jlink.cfg]
jlink usb 0 # use first J-Link found
transport select swd # or jtag
adapter speed 4000
source [find target/stm32l4x.cfg]
J-Link GDB S
Read more
name: openocd-jtag description: OpenOCD skill for embedded hardware debugging. Use when configuring OpenOCD for JTAG or SWD targets, flashing firmware, connecting GDB to bare-metal targets, setting hardware watchpoints, or using J-Link with OpenOCD. Activates on queries about OpenOCD, JTAG, SWD, GDB remote target, flash programming, hardware breakpoints, J-Link, or connecting GDB to an MCU.
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
| Feature | JTAG | SWD (Serial Wire Debug) | |---------|------|------------------------| | Pins | 4+ (TCK, TMS, TDI, TDO, TRST) | 2 (SWCLK, SWDIO) | | Multi-target | Yes (daisy chain) | No (one target) | | Speed | Up to 30 MHz | Up to 10 MHz | | Availability | Full JTAG: Cortex-A/R, RISC-V | SWD: Cortex-M only | | Cable cost | More complex | Simpler 2-wire |
Most Cortex-M microcontrollers support both. Use SWD when pin count is limited.
2. OpenOCD configuration
# openocd.cfg — CMSIS-DAP (ST-Link v2, DAPLink) source [find interface/cmsis-dap.cfg] source [find target/stm32f4x.cfg] adapter speed 4000 # kHz # For SWD explicitly transport select swd # J-Link adapter source [find interface/jlink.cfg] jlink serial 123456789 # optional: select by serial source [find target/nrf52.cfg] adapter speed 8000
# Run OpenOCD (keeps running, serves GDB on port 3333) openocd -f openocd.cfg # Common interface config files ls $(openocd --help 2>&1 | grep "scripts" | head -1)/interface/ # cmsis-dap.cfg, jlink.cfg, ftdi/olimex-arm-usb-ocd.cfg, stlink.cfg ... # Common target config files ls $(openocd --help 2>&1 | grep "scripts" | head -1)/target/ # stm32f4x.cfg, nrf52.cfg, esp32.cfg, rp2040.cfg, at91sam4s.cfg ...
3. Connecting GDB
# In terminal 1: start OpenOCD
openocd -f openocd.cfg
# In terminal 2: start GDB
arm-none-eabi-gdb firmware.elf
# GDB commands
(gdb) target extended-remote :3333 # connect to OpenOCD
(gdb) monitor reset halt # reset and halt target
(gdb) load # flash ELF to target
(gdb) monitor reset init # re-initialize after flash
(gdb) break main # set software breakpoint
(gdb) continue
# One-liner for quick debugging
arm-none-eabi-gdb -ex "target extended-remote :3333" \
-ex "monitor reset halt" \
-ex "load" \
-ex "break main" \
-ex "continue" \
firmware.elf4. Flashing firmware
# Flash via OpenOCD telnet interface
telnet localhost 4444
# OpenOCD telnet commands
> reset halt
> program firmware.elf verify reset
> exit
# Or via GDB
(gdb) monitor flash write_image erase firmware.bin 0x08000000
(gdb) monitor reset run
# Flash only (no debug) — script mode
openocd -f openocd.cfg \
-c "program firmware.elf verify reset exit"
# For raw binary
openocd -f openocd.cfg \
-c "program firmware.bin 0x08000000 verify reset exit"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:
# Hardware breakpoint (uses debug register, limited count: 4-8 on Cortex-M) (gdb) hbreak function_name (gdb) hbreak *0x08001234 # Hardware watchpoint — triggers on memory read/write (gdb) watch global_variable # write watchpoint (gdb) rwatch some_buffer # read watchpoint (gdb) awatch sensor_value # read OR write watchpoint # List breakpoints/watchpoints (gdb) info breakpoints # Cortex-M typically has: 4–8 hardware breakpoints, 2–4 watchpoints
6. OpenOCD commands reference
# Via telnet (port 4444) or GDB monitor monitor reset halt # reset and hold at reset vector monitor reset init # reset and run init scripts monitor reset run # reset and run freely monitor halt # halt running target monitor resume # resume execution monitor mdw 0x20000000 # memory display word at address monitor mww 0x40021000 0x1 # memory write word monitor reg r0 # read register monitor arm disassemble 0x08000000 16 # disassemble 16 instructions # Flash operations monitor flash list monitor flash erase_sector 0 0 0 # erase sector 0 monitor flash write_bank 0 firmware.bin 0
7. Common errors
| Error | Cause | Fix | |-------|-------|-----| | `unable to find JTAG device` | Wrong interface, cable, or power | Check USB connection; power target; verify interface config | | `JTAG scan chain interrogation failed` | Wrong target config or bad SWD mode | Match config to exact MCU; try `transport select swd` | | `flash 'stm32f4x' is not supported` | Wrong target | Check MCU part number; use correct `.cfg` | | `Error: timed out while waiting for target halted` | Target running, not halted | `monitor halt`; check BOOT pins | | `Cannot access memory at address` | MMU, memory protection, or wrong address | Check MPU config; use correct flash/RAM address | | `Warn: target not examined yet` | OpenOCD not connected to target | Check power and connections |
8. J-Link configuration
# openocd.cfg for J-Link source [find interface/jlink.cfg] jlink usb 0 # use first J-Link found transport select swd # or jtag adapter speed 4000 source [find target/stm32l4x.cfg]
J-Link GDB S
A curated suite of AI agent skills for systems and low-level programming — C/C++, Rust, Zig, GPU, bare-metal firmware, Linux kernel/driver development, computer architecture, compiler internals, HPC, and more.
Repo: mohitmishra786/low-level-dev-skills
Other skills on low-level-dev-skills.
- /custom-allocators
Custom allocator skill for memory allocation strategies. Use when implementing pool/slab/arena allocators, tuning jemalloc/mimalloc, writing Rust GlobalAlloc, or benchmarking allocator performance. Activates on queries about jemalloc, mimalloc, tcmalloc, arena allocator,
Open skill - /numa-programming
NUMA programming skill for multi-socket memory locality. Use when detecting NUMA topology, binding processes with numactl, using libnuma API, building NUMA-aware data structures, or measuring remote access penalties. Activates on queries about numactl, libnuma, NUMA topology,
Open skill - /af-xdp
AF_XDP skill for high-performance XDP sockets. Use when creating AF_XDP sockets, configuring UMEM and XSK rings, XDP_REDIRECT programs, copy vs zero-copy mode, or comparing with DPDK. Activates on queries about AF_XDP, xsk_umem, XDP_REDIRECT, libbpf xsk, or zero-copy XDP.
Open skill - /dpdk
DPDK skill for userspace packet I/O. Use when initializing EAL, configuring PMD drivers, using mbuf pools and rte_ring, setting up huge pages, RSS, or testpmd validation. Activates on queries about DPDK, EAL, rte_eth_rx_burst, hugepages, PMD, or testpmd.
Open skill - /io-uring
io_uring skill for Linux async I/O. Use when building high-performance servers with liburing, multi-shot operations, provided buffers, fixed files, zero-copy send, or tokio-uring. Activates on queries about io_uring, SQE/CQE, liburing, IORING_OP_PROVIDE_BUFFERS, or io_uring vs
Open skill - /adc-dac-baremetal
Bare-metal ADC and DAC skill. Use when configuring analog sampling, DMA-driven ADC, calibration, or DAC output on MCUs. Activates on queries about ADC bare-metal, sampling time, DMA ADC, or DAC channel setup.
Open skill

