openocd-jlink-stlink-debug
Skill36 starsChanged 5 months agoMITView on GitHub
Use when debugging OpenOCD, J-Link, ST-Link, CMSIS-DAP, probe connection, reset scripts, flash algorithms, GDB attach, semihosting, RTT, or SWD/JTAG failures
In this repository75 other files it gives its agents.
- 8051-mcu-debugSkill
- avem-integrationSkill
- battery-charger-fuel-gauge-integrationSkill
- ble-gatt-integrationSkill
- bootloader-debugSkill
- canbus-integrationSkill
- canopen-integrationSkill
- cellular-at-modem-integrationSkill
- cmbacktrace-integrationSkill
- cmsis-dsp-integrationSkill
- cortex-m-debugSkill
- cortex-r5-debugSkill
- crc-checksum-integrationSkill
- easylogger-integrationSkill
- embedded-app-example-libsSkill
- embedded-buffer-queue-libsSkill
- embedded-data-parsing-libsSkill
- embedded-debug-entrySkill
- embedded-fault-debugSkill
- embedded-framework-libsSkill
- embedded-input-libsSkill
- embedded-library-entrySkill
- embedded-linux-login-debugSkill
- embedded-peripheral-bringupSkill
- embedded-serial-log-debugSkill
- embedded-state-machine-libsSkill
- embedded-timing-libsSkill
- epd-integrationSkill
- esp-idf-integrationSkill
- fatfs-integrationSkill
- flashdb-integrationSkill
- freemodbus-integrationSkill
- freertos-kernel-debugSkill
- freertos-plus-tcp-integrationSkill
- gnss-gps-integrationSkill
- hardware-interface-debugSkill
- heatshrink-integrationSkill
- letter-shell-integrationSkill
- littlefs-integrationSkill
- low-power-debugSkill
- lvgl-integrationSkill
- lwip-integrationSkill
- mbedtls-integrationSkill
- mcuboot-integrationSkill
- mcu-flashing-debugSkill
- micro-ecc-integrationSkill
- miniz-integrationSkill
- mqtt-embedded-integrationSkill
- nanopb-integrationSkill
- nrf-connect-sdk-integrationSkill
- nr-micro-shell-integrationSkill
- openthread-integrationSkill
- ota-update-integrationSkill
- plooc-integrationSkill
- power-management-integrationSkill
- qspi-xip-flash-debugSkill
- readme-writingSkill
- riscv-mcu-debugSkill
- rtos-debugSkill
- rt-thread-integrationSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 3 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
Use this skill to debug probe sessions by separating physical wiring, probe firmware, target voltage, reset strategy, transport, target …
- Distinctive: line 16
Use this skill when:
- Very specific: line 24
Do not use this skill for application fault analysis after a stable debug session exists.
- Very specific: line 53
Default TCP ports: GDB 3333, Telnet monitor 4444, Tcl 6666.
- Very specific: line 58
Check VTref, ground, cable length, pinout, SRST line, and whether the probe powers or only senses the target.
- Very specific: line 64
Start with adapter speed 480 or lower, then raise only after IDCODE, halt, reset, and mdw reads are stable.
- Very specific: line 80
Read state with targets, reg, mdw 0x08000000 4, mdh, mdb.
- Very specific: line 102
Use target remote for a single-session attach, target extended-remote to allow reconnect.
- Distinctive: line 136
Before claiming the debug path works:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
OpenOCD J-Link ST-Link Debug
Overview
Use this skill to debug probe sessions by separating physical wiring, probe firmware, target voltage, reset strategy, transport, target script, flash algorithm, and GDB behavior. Probe failures are often reset or adapter issues.
When To Use
Use this skill when:
- The user cannot connect, halt, reset, flash, erase, verify, or attach with OpenOCD, J-Link, ST-Link, CMSIS-DAP, pyOCD, or GDB.
- The issue involves SWD/JTAG wiring, adapter speed, reset config, target scripts, flash loaders, protected devices, semihosting, RTT, or multicore.
- The same firmware behaves differently under debugger and standalone boot.
Do not use this skill for application fault analysis after a stable debug
session exists. Use the architecture-specific debug skill then. For flash
download failures focused on erase/program/verify, use mcu-flashing-debug.
First Questions
Ask for:
- Probe model, firmware version, debugger tool, target MCU/SoC, board, and OS.
- Wiring:
VTref, GND,SWDIO/TMS,SWCLK/TCK,nRST/SRST,SWO, and power ownership. - Exact command, the
-f interface/*.cfgand-f target/*.cfgscripts,adapter speed,transport select, and full log. - Reset mode, boot pins, readout protection (STM32
RDP), low-power state, and external flash. - Whether connect-under-reset, halt-after-reset, or attach-to-running is needed.
Launch Reference
- ST-Link:
openocd -f interface/stlink.cfg -f target/stm32f4x.cfg(stlink.cfgis thehladriver; usetarget/stm32f1x.cfg,stm32h7x.cfg,nrf52.cfgetc. for other parts). - J-Link:
openocd -f interface/jlink.cfg -c "transport select swd" -f target/stm32f4x.cfg. - CMSIS-DAP/DAPLink:
openocd -f interface/cmsis-dap.cfg -c "transport select swd" -f target/stm32f1x.cfg. - Force JTAG instead of SWD:
-c "transport select jtag"(notestlink.cfghlaonly supportshla_swd/hla_jtag). - Set speed before target script:
-c "adapter speed 1000"(kHz; deprecated aliasadapter_khz). Pick a probe by serial with-c "adapter serial <SN>"(older:hla_serial). - Default TCP ports: GDB
3333, Telnet monitor4444, Tcl6666.
Debug Workflow
- Prove physical connection.
Check
VTref, ground, cable length, pinout,SRSTline, and whether the probe powers or only senses the target. In the log confirm a validSWD DPIDR 0x2ba01477(Cortex-M3/M4) or JTAGIDCODE, not a zero/failed read (SWD DPIDR 0x00000000/Error connecting DP: cannot read IDR). - Lower the adapter speed.
Start with
adapter speed 480or lower, then raise only after IDCODE, halt, reset, andmdwreads are stable. - Pick the right reset strategy.
In the target/board cfg set
reset_config, e.g.srst_only srst_nogatefor connect-under-reset, ornone separate. Then usereset halt/reset init/reset run. Add-c "reset_config connect_assert_srst"for locked or fast-sleeping parts. - Validate target scripts.
Confirm
transport select, chip family cfg, TAP/DAP IDs (-expected-idonjtag newtap/swj_newdap,-dp-idfor SWD multidrop),flash bank, and_TARGETNAME/work-area RAM. List cores withtargets. - Separate attach from flash.
Enter the monitor with
telnet localhost 4444, theninitandreset halt. Read state withtargets,reg,mdw 0x08000000 4,mdh,mdb; write withmww 0x40021000 0x01. Only then flash:program firmware.elf verify resetorflash write_image erase firmware.bin 0x08000000/flash erase_sector 0 0 last/flash info 0.resumeto run,dump_image out.bin 0x08000000 0x10000to read back. - Add extras last.
Enable
arm semihosting enable, SWO/tpiu, or RTT only after the base debug path is reliable (see RTT And Semihosting).
GDB Attach
arm-none-eabi-gdb firmware.elf
(gdb) target extended-remote localhost:3333
(gdb) monitor reset halt
(gdb) load
(gdb) monitor reg
(gdb) continueUse target remote for a single-session attach, target extended-remote to
allow reconnect. monitor <cmd> forwards any OpenOCD command (e.g.
monitor reset init, monitor flash write_image erase firmware.bin).
RTT And Semihosting
- Semihosting: after halt run
arm semihosting enable(optionallyarm semihosting_fileio enable);printf/putsoutput appears on the OpenOCD console once the firmware linkslibnosys/semihosting stubs. - RTT:
rtt setup 0x20000000 2048 "SEGGER RTT"thenrtt start; expose a channel withrtt server start 9090 0and read it viatelnet localhost 9090. Usertt channelsto confirm the control block was found. The ID string defaults to"SEGGER RTT".
Common Failures
VTrefis missing, soError: target voltage may be too lowor the probe cannot sense target voltage.- Adapter speed too high for early boot/low-power/long wires, giving a failed
DPIDR read (
Error connecting DP: cannot read IDR),Error: init mode failed (unable to connect to the target), orSWD ack not OK. SRSTnot wired but the script usesreset_config srst_only; switch tonone/connect_assert_srst.- Device is readout-protected or locked (
Error: … cannot be programmed); for STM32 clearRDPwithstm32f4x unlock 0/stm32f1x unlock 0(mass-erases). - Wrong target cfg selects the wrong
flash bankor work-area RAM, soflash write_image/programfails or verify mismatches. - External QSPI/SPI flash needs a board-specific
flash bankdriver (stmqspi,cfi), not the internal loader. hla(stlink.cfg) cannot do rawswd/jtaglow-level commands or SWD multidrop; useinterface/stlink-dap.cfgor a J-Link/CMSIS-DAP v2 probe.
Verification
Before claiming the debug path works:
- State probe, tool, exact command,
transport,adapter speed, and reset mode. - Confirm
SWD DPIDR/IDCODE,reset halt,targetsshowshalted, aregread, and anmdwmemory read. - Confirm
program … verify resetorflash write_imageplus verify when flashing is required. - Confirm standalone boot still works after
reset runand power-cycle, i.e. after debugger-specific settings.
Example
User:
OpenOCD 连 STM32 一直 timeout。Agent:
- Checks
VTref, ground, SWD pins,SRST, and lowersadapter speed 480. - Retries with
reset_config connect_assert_srstand the correcttarget/stm32f4x.cfg, watching forSWD DPIDR. - Separates connection evidence (
init,targets,mdw) fromprogram/flash write_imageerrors.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

