MCPInstall

jlink

J-Link 下载与在线调试工具,用于探测设备、烧录固件、读写内存、查看寄存器、复位目标、读取 RTT/SWO 日志, 以及在线调试(暂停/恢复/单步/断点运行/调用栈/变量查看)。 当用户提到 J-Link、JLink、RTT、烧录固件、写内存、读内存、寄存器查看、目标复位、探针连通性检查、 在线调试、单步、断点、调用栈时自动触发,也兼容 /jlink 显式调用。 即使用户只是说"烧录一下"、"看看 RTT 输出"或"调试一下",只要上下文涉及 J-Link 探针就应触发此 skill。

Installs
683
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/zhinkgit/embeddedskills --skill jlink
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads jlink automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

J-Link 下载与在线调试

本 skill 提供 J-Link 探针的设备探测、固件烧录、内存读写、寄存器查看、目标复位、RTT 日志读取,以及轻量在线调试和 GDB 源码级调试能力。

配置

环境级配置(skill/config.json)

skill 目录下的 config.json 包含环境级配置(工具路径、端口号等),首次使用前确认 exe 路径正确:

{
  "exe": "C:\\Program Files\\SEGGER\\JLink\\JLink.exe",
  "gdbserver_exe": "C:\\Program Files\\SEGGER\\JLink\\JLinkGDBServerCL.exe",
  "rtt_exe": "C:\\Program Files\\SEGGER\\JLink\\JLinkRTTClient.exe",
  "gdb_exe": "C:\\Program Files\\Arm\\GNU Toolchain mingw-w64-x86_64-arm-none-eabi\\bin\\arm-none-eabi-gdb.exe",
  "serial_no": "",
  "rtt_telnet_port": 0,
  "swo_command": [],
  "operation_mode": 1
}
  • exe:JLink.exe 完整路径(必填)
  • gdbserver_exe:JLinkGDBServerCL.exe 路径,RTT 和 GDB 调试需要
  • rtt_exe:JLinkRTTClient.exe 路径
  • gdb_exe:arm-none-eabi-gdb 路径,GDB 源码级调试需要
  • serial_no:默认探针序列号,多探针场景下使用
  • rtt_telnet_port:RTT 端口,0 表示使用工具默认值
  • swo_command:可选,完整 SWO viewer 命令数组,供 jlink_swo.py 包装
  • operation_mode:1 直接执行 / 2 输出风险摘要但不阻塞 / 3 执行前确认

工程级配置(.embeddedskills/config.json)

设备参数(device/interface/speed)统一在工作区的 .embeddedskills/config.json 中管理:

{
  "jlink": {
    "device": "STM32F407VG",
    "interface": "SWD",
    "speed": "4000"
  }
}
  • device:芯片型号(如 STM32F407VG、GD32F470ZG)
  • interface:调试接口,SWD 或 JTAG,默认 SWD
  • speed:调试速率 kHz,默认 4000

参数解析优先级:CLI 显式参数 > .embeddedskills/config.json(工程级)> skill/config.json(环境级)> .embeddedskills/state.json > 默认值/报错

成功执行后,确认过的 device/interface/speed 会自动写回工程配置。

子命令

基础操作

子命令用途风险
info探测探针与目标连通性低
flash烧录固件(.hex / .bin / .elf)高
read-mem读取内存区域低
write-mem写入内存高
regs查看 CPU 寄存器低
reset复位目标芯片高
rtt读取 RTT 日志输出低
swo包装外部 SWO viewer 为统一事件流低

在线调试(JLink Commander)

子命令用途风险
halt暂停 CPU,返回寄存器状态低
go恢复 CPU 运行低
step单步执行(支持指定步数),返回执行的指令和寄存器低
run-to设置断点并运行,等待命中后返回状态低

GDB 源码级调试

子命令用途依赖
gdb backtrace/locals查看调用栈和局部变量arm-none-eabi-gdb
gdb break/continue/next/step/finish/untilone-shot 控制执行流arm-none-eabi-gdb
gdb frame/print/watch/disassemble/threads/crash-reportone-shot 源码级诊断arm-none-eabi-gdb

执行流程

  1. 读取 skill/config.json,确认 exe 路径有效
  2. 读取 .embeddedskills/config.json 获取工程级配置(device/interface/speed)
  3. 读取 .embeddedskills/state.json 获取历史状态
  4. 参数解析优先级:CLI 显式参数 > .embeddedskills/config.json(工程级)> skill/config.json(环境级)> .embeddedskills/state.json > 默认值/报错
  5. 若当前动作需要 device 且仍为空,直接要求用户补充,绝不猜测
  6. 多探针场景未指定 serial_no 时,列出探针让用户选择,不自动选择
  7. 按 operation_mode 决定是否需要确认后执行
  8. 使用模板生成临时 .jlink 命令文件,调用 JLink.exe 时带 -NoGui 1 -ExitOnError 1 -AutoConnect 1
  9. 解析输出和返回码,返回结构化结果
  10. 成功执行后,将确认过的 device/interface/speed 写回 .embeddedskills/config.json

脚本调用

skill 目录下有四个 Python 脚本,使用标准库实现,无额外依赖。

jlink_exec.py — 基础操作 + 轻量调试

# 探测连通性
python <skill-dir>/scripts/jlink_exec.py info --device GD32F470ZG --json

# 烧录固件
python <skill-dir>/scripts/jlink_exec.py flash --file build/app.hex --device GD32F470ZG --json

# 烧录 .bin(必须提供地址)
python <skill-dir>/scripts/jlink_exec.py flash --file build/app.bin --device GD32F470ZG --address 0x08000000 --json

# 读取内存
python <skill-dir>/scripts/jlink_exec.py read-mem --address 0x08000000 --length 256 --device GD32F470ZG --json

# 写入内存
python <skill-dir>/scripts/jlink_exec.py write-mem --address 0x20000000 --value 0x12345678 --device GD32F470ZG --json

# 查看寄存器
python <skill-dir>/scripts/jlink_exec.py regs --device GD32F470ZG --json

# 复位目标
python <skill-dir>/scripts/jlink_exec.py reset --device GD32F470ZG --json

# 暂停 CPU
python <skill-dir>/scripts/jlink_exec.py halt --device GD32F470ZG --json

# 恢复运行
python <skill-dir>/scripts/jlink_exec.py go --device GD32F470ZG --json

# 单步执行(3 步)
python <skill-dir>/scripts/jlink_exec.py step --device GD32F470ZG --count 3 --json

# 运行到断点地址
python <skill-dir>/scripts/jlink_exec.py run-to --device GD32F470ZG --address 0x08001234 --timeout-ms 3000 --json

通用可选参数:--interface SWD|JTAG、--speed 4000、--serial-no <序列号>、--exe <JLink.exe路径>

jlink_rtt.py — RTT 日志读取

python <skill-dir>/scripts/jlink_rtt.py --device GD32F470ZG --json

可选参数:--serial-no、--channel、--encoding、--rtt-port、--gdbserver-exe <路径>、--rtt-exe <路径>

RTT 工作原理:脚本先通过 JLinkGDBServerCL.exe 建立调试连接,再启动 JLinkRTTClient.exe 读取 RTT 数据。--json 模式输出 JSON Lines。

jlink_swo.py — SWO 事件流包装

# 使用 config.json 里的 swo_command
python <skill-dir>/scripts/jlink_swo.py --json

# 或显式传入 viewer 命令
python <skill-dir>/scripts/jlink_swo.py \
  --viewer-cmd JLinkSWOViewerCL.exe -device GD32F470ZG -itf SWD -speed 4000 \
  --json

jlink_swo.py 不直接实现 SWO 协议,而是把外部 viewer 的 stdout/stderr 统一包装成 JSON Lines,便于上层 workflow 或 AI 继续消费。

jlink_gdb.py — GDB 源码级调试(需要 arm-none-eabi-gdb)

# 执行自定义 GDB 命令序列
python <skill-dir>/scripts/jlink_gdb.py run \
  --gdbserver-exe <路径> --gdb-exe <arm-none-eabi-gdb路径> \
  --device GD32F470ZG --elf build/app.elf \
  --commands "break main" "continue" "backtrace" "info locals" --json

# 快捷:获取调用栈
python <skill-dir>/scripts/jlink_gdb.py backtrace \
  --gdbserver-exe <路径> --gdb-exe <路径> \
  --device GD32F470ZG --elf build/app.elf --json

# 快捷:查看局部变量
python <skill-dir>/scripts/jlink_gdb.py locals \
  --gdbserver-exe <路径> --gdb-exe <路径> \
  --device GD32F470ZG --elf build/app.elf --json

GDB 调试需要 ELF 文件才能进行源码级调试(断点到函数名、查看变量)。没有 ELF 时仍可使用地址级调试。

输出格式

所有脚本以 JSON 格式返回,基础字段为 status(ok/error)、action、summary、details,并可能附带 context、artifacts、metrics、state、next_actions、timing。流式观测命令使用 JSON Lines,并统一输出 source、channel_type、stream_type。

成功示例:

{
  "status": "ok",
  "action": "halt",
  "summary": "已暂停,PC=0x08049ABC",
  "details": {
    "device": "GD32F470ZG",
    "registers": { "PC": "0x08049ABC", "R0": "0x00000004", "..." : "..." }
  }
}

step 示例(包含执行的指令):

{
  "status": "ok",
  "action": "step",
  "summary": "单步3次,PC=0x08049AB4",
  "details": {
    "steps": [
      { "address": "0x08049AB8", "opcode": "80 1B", "instruction": "SUBS R0, R0, R6" },
      { "address": "0x08049ABA", "opcode": "A8 42", "instruction": "CMP R0, R5" },
      { "address": "0x08049ABC", "opcode": "FA D3", "instruction": "BCC #-0x0C" }
    ],
    "registers": { "PC": "0x08049AB4", "..." : "..." }
  }
}

run-to 示例(断点命中):

{
  "status": "ok",
  "action": "run-to",
  "summary": "断点命中 @ 0x08049AB4,PC=0x08049AB4",
  "details": {
    "bp_address": "0x08049AB4",
    "bp_hit": true,
    "registers": { "PC": "0x08049AB4", "..." : "..." }
  }
}

核心规则

  • 不自动猜测 device 芯片型号,缺失时必须询问用户
  • 多探针场景不自动选择探针,必须让用户指定序列号
  • 参数解析优先级为:CLI 显式参数 > .embeddedskills/config.json(工程级)> skill/config.json(环境级)> .embeddedskills/state.json > 默认值/报错
  • .bin 文件必须显式提供烧录地址,缺失时报错
  • 连接失败时给出排查建议(检查连线、供电、接口类型、速度),不自动尝试更激进参数
  • 烧录、写内存、复位在参数完整且用户意图明确时直接执行
  • run-to 的断点在单次 JLink 会话内完成设置和清除,不存在跨会话 handle 问题
  • 结果回显中始终包含目标芯片、接口类型和执行动作
  • 产物路径(elf/file)不进入工程配置,仍只依赖 state.json
  • last_flash/last_debug 等运行状态继续写入 state.json

调试典型工作流

快速排查(JLink Commander)

halt → regs → read-mem → step → go

适合查看当前执行位置、寄存器状态、内存值,无需 ELF 和 GDB。

断点调试(JLink Commander)

run-to(address) → regs → read-mem → go

在指定地址设置断点并等待命中,查看此时的状态。

源码级调试(GDB)

gdb run --elf app.elf --commands "break main" "continue" "backtrace" "info locals"

需要 ELF 文件和 arm-none-eabi-gdb,支持函数名断点和变量查看。

参考

遇到芯片型号问题时可查阅 references/common_devices.md。

FAQ

What does the jlink skill do?

J-Link 下载与在线调试工具,用于探测设备、烧录固件、读写内存、查看寄存器、复位目标、读取 RTT/SWO 日志, 以及在线调试(暂停/恢复/单步/断点运行/调用栈/变量查看)。 当用户提到 J-Link、JLink、RTT、烧录固件、写内存、读内存、寄存器查看、目标复位、探针连通性检查、 在线调试、单步、断点、调用栈时自动触发,也兼容 /jlink 显式调用。 即使用户只是说"烧录一下"、"看看 RTT 输出"或"调试一下",只要上下文涉及 J-Link 探针就应触发此 skill。

How do I install jlink?

Run npx skills add https://github.com/zhinkgit/embeddedskills --skill jlink in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/jlink/ (personal) or .claude/skills/jlink/ (project).

Which AI agents can use jlink?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is jlink safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains jlink?

It is published by zhinkgit in zhinkgit/embeddedskills. It has 683 recorded installs.

More from zhinkgit/embeddedskills

View all →

keil

zhinkgit/embeddedskills

Keil MDK 工程构建工具,用于扫描 .uvprojx/.uvproj/.uvmpw 工程、枚举 Target、执行 build/rebuild/clean 并解析构建日志,返回可供 jlink/openocd 复用的产物路径。 flash 子命令仅作为兼容入口保留。当用户提到 Keil、MDK、uVision、UV4、 Target 枚举、编译、重建、清理、烧录、下载固件、flash 时自动触发,也兼容 /keil 显式调用。 即使用户只是说"编译一下"或"烧录到板子上",只要上下文涉及嵌入式 Keil 工程就应触发此 skill。

870 installs

serial

zhinkgit/embeddedskills

嵌入式串口调试工具,用于扫描串口、实时监控、发送数据、记录日志和 Hex 查看。 当用户提到串口、COM 口、UART、AT 命令调试、波特率、Hex 串流、串口抓日志、 串口监控、查看 MCU 输出、二进制协议联调时自动触发,也兼容 /serial 显式调用。 即使用户只是说"看看串口输出"、"发个 AT 命令"或"抓一下日志",只要上下文涉及 串口通信就应触发此 skill。

814 installs

can

zhinkgit/embeddedskills

嵌入式 CAN / CAN-FD 调试工具,用于扫描接口、监控报文、发送测试帧、记录日志、数据库文件解码和总线统计。 当用户提到 CAN、CAN-FD、DBC 解码、总线抓包、USB-CAN 联调、报文发送、总线统计、 PCAN、Vector、slcan、CAN 接口扫描、CAN ID 过滤、ASC 日志、BLF 文件时自动触发, 也兼容 /can 显式调用。即使用户只是说"看看 CAN 报文"、"发一帧试试"或"解码一下 DBC", 只要上下文明确提到 CAN 总线通信的操作或问题就应触发此 skill。

720 installs

openocd

zhinkgit/embeddedskills

OpenOCD 下载与调试工具,用于探针探测、固件烧录、Flash 擦除、GDB Server 启动、目标复位控制、 Telnet 在线调试(halt/resume/step/寄存器/内存/断点)、GDB 源码级调试,以及 Semihosting/ITM 输出捕获和底层查询。 当用户提到 OpenOCD、ST-Link、CMSIS-DAP、DAPLink、FTDI、烧录固件、擦除 Flash、GDB Server、 reset、interface/target/board 配置、openocd.cfg、在线调试、单步、断点、寄存器查看、 内存读写、semihosting 时自动触发,也兼容 /openocd 显式调用。 即使用户只是说"烧录一下"、"启动 GDB Server"、"擦除芯片"、"看看寄存器"、"单步调试" 或"抓一下 semihosting",只要上下文涉及 OpenOCD 支持的开源调试器就应触发此 skill。

Backend & APIs673 installs

gcc

zhinkgit/embeddedskills

GCC 嵌入式工程构建工具(CMake + arm-none-eabi-gcc),用于扫描 CMake 型嵌入式工程、 列出预设、配置、编译、重建、清理和分析 ELF 大小。当用户提到 GCC、arm-none-eabi、 CMake 嵌入式编译、Ninja 构建、ELF 大小分析、arm-gcc、交叉编译、cmake --build、 cmake --preset 时自动触发,也兼容 /gcc 显式调用。即使用户只是说"编译一下"或 "看看固件多大",只要上下文涉及 CMake 嵌入式 GCC 工程就应触发此 skill。

667 installs

workflow

zhinkgit/embeddedskills

embeddedskills 的薄编排层,用于在当前 workspace 中发现工程、选择 build/flash/debug/observe 后端、串联 .embeddedskills/state.json,并聚合底层 skill 的结果。 当用户明确输入以下命令之一:"一键构建烧录"、"自动诊断"、"串起 build - flash - debug - observe" 或显式调用 /workflow 时触发。

Popular other skills

View category →

hyperframes-cli

heygen-com/hyperframes

The HyperFrames CLI by job - scaffold, check, look at frames, edit the timeline, preview, render locally or in the cloud, publish, project history - plus reading its JSON and recovering from build or render failures.

1.3M installs

triage

mattpocock/skills

Move issues and external PRs through a state machine of triage roles, categorise, verify, grill if needed, and write agent-ready briefs.

1M installs

ask-matt

mattpocock/skills

Ask which skill or flow fits your situation. A router over the skills in this repo.

778.4K installs

to-questionnaire

mattpocock/skills

Turn a decision you can't fully answer into a questionnaire for someone else to fill in.

508.9K installs

wait-what

mattpocock/skills

Stop. That last message did not land: re-pitch it.

459.7K installs

loop-me

mattpocock/skills

Grill me about specs for the workflows I want to build, within this workspace.

447.9K installs