在 Pinecil 上使用 JLink 进行 JTAG 调试
摘要
本文详细介绍如何通过扩展板将 JLink JTAG 调试器连接到 Pinecil 电烙铁,从而实现对 Bouffalo Lab BL706 MCU(SiFive E24 内核)的硬件调试,使用 JLinkGDBServer 和 GDB 进行调试,尤其适用于 Zephyr RTOS 的开发场景。
暂无内容
查看缓存全文
缓存时间: 2026/06/05 02:11
# JLink JTAG 接入 Pinecil
来源:https://danielmangum.com/posts/jlink-jtag-pinecil/
距离我购买 [Pinecil 烙铁](https://pine64.com/product/pinecil-smart-mini-portable-soldering-iron/),并撰写关于[焊接扩展板](https://danielmangum.com/posts/risc-v-bytes-soldering-pinecil-breakout-board/)和[访问 UART](https://danielmangum.com/posts/risc-v-bytes-accessing-pinecil-uart-picoprobe/) 的文章,已经过去两年多了。最近我又开始更多地使用 Pinecil,起因是 [Bouffalo Lab BL706 MCU](https://en.bouffalolab.com/product/?type=detail&id=8) 获得了 [Zephyr](https://zephyrproject.org/) 的[上游支持](https://github.com/zephyrproject-rtos/zephyr/pull/94004)(特别感谢 [@VynDragon](https://github.com/VynDragon)、[@will-tm](https://github.com/will-tm)、[@josuah](https://github.com/josuah) 以及所有为上游 Bouffalo Lab 工作做出贡献的朋友们!)。
jlink-jtag-pinecil-0
访问 UART 虽然有助于查看日志,但在排查系统早期初始化和驱动问题时,调试访问才是关键。市面上有各种各样的 JTAG 探针,我通常会选用 [JLink](https://www.segger.com/products/debug-probes/j-link/),因为它兼容性广、工具链完善。要将 JLink 连接到 Pinecil,需要用到我在之前文章中介绍的[扩展板](https://pine64.com/product/pinecil-break-out-board/)。该扩展板提供了一个 10 针 JTAG 引出接头,包含一个 3v3 参考引脚、4 个 GND 引脚以及标准 JTAG 信号引脚。虽然市面上有[多种适配器](https://www.segger.com/products/debug-probes/j-link/accessories/adapters/overview/)可用于将各种调试引脚连接到 JLink 的 20 针接口,但直接使用母对母杜邦线将 Pinecil 扩展板上标准 2.54mm 间距的引脚与 JLink 相连也很简便。本文顶部的示意图展示了引脚映射关系,下图则展示了通过排线连接各杜邦线与 JLink 的实际接线情况(使用母对公杜邦线),这样在 Pinecil 调试会话之间需要将 JLink 用于其他用途时,就无需每次重新插拔引脚了。
> 使用排线时,引脚方向容易搞混。将缺口朝上时,`VTref` 引脚(JLink 的第 1 针,见下图白色线)位于排线引脚图的左上角,需与 JLink 引脚图右上角的 `VTref` 引脚对接。
jlink-jtag-pinecil-1
连接完成后,可以使用 `JLinkExe` 验证接线是否正确。扩展板 3v3 引脚与 `VTref` 的连接应能让 JLink 检测到逻辑电平电压(约 `3.3V`)。
```
SEGGER J-Link Commander V9.28 (Compiled Mar 18 2026 15:27:55)
DLL version V9.28, compiled Mar 18 2026 15:26:49
Connecting to J-Link via USB...O.K.
Firmware: J-Link V11 compiled Apr 1 2025 10:02:30
Hardware version: V11.00
J-Link uptime (since boot): 0d 00h 00m 02s
S/N: 821010562
License(s): GDB
USB speed mode: High speed (480 MBit/s)
VTref=3.335V
```
若要连接调试器(如 `gdb`),可以使用 `JLinkGDBServer` 连接 BL706 MCU 中底层 [SiFive E24 核心复合体](https://www.sifive.com/cores/essential-e-series)上的 JTAG 电路,并在本地 `2331` 端口启动一个 `gdb` 服务器。
```
JLinkGDBServer -device E24 -if JTAG
```
```
SEGGER J-Link GDB Server V9.28 Command Line Version
JLinkARM.dll V9.28 (DLL compiled Mar 18 2026 15:26:49)
Command line: -device E24 -if JTAG
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: yes
Generate logfile: off
Verify download: off
Init regs on start: off
Silent mode: off
Single run mode: off
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none
------Target related settings------
Target device: E24
Target device parameters: none
Target interface: JTAG
Target interface speed: 4000kHz
Target endian: little
Connecting to J-Link...
J-Link is connected.
Firmware: J-Link V11 compiled Apr 1 2025 10:02:30
Hardware: V11.00
S/N: 821010562
Feature(s): GDB
Checking target voltage...
Target voltage: 3.30 V
Listening on TCP/IP port 2331
Connecting to target...
J-Link found 1 JTAG device, Total IRLen = 5
JTAG ID: 0x20000E05 (RISC-V)
Halting core...
RISC-V RV32 detected. Using RV32 register set for communication with GDB
Core implements single precision FPU
Connected to target
Waiting for GDB connection...
```
可以使用以下 `gdb` 命令连接到服务器并加载固件符号。
```
gdb -ex 'target remote :2331' ./path/to/firmware.elf
```
```
Remote debugging using :2331
arch_irq_unlock (key=8) at /home/hasheddan/code/github.com/zephyrproject-rtos/zephyr/include/zephyr/arch/riscv/arch.h:338
338 __asm__ volatile ("csrs " RV_STATUS_CSR ", %0"
```
之后便可以开始逐指令单步执行了。
祝调试愉快!
相似文章
本地运行 Qwen3.6-35B-A3B 作为编码 Agent:我的完整部署与可用配置
一份详尽指南,教你如何在 Apple Silicon 上通过 llama.cpp 本地运行 350 亿参数 Qwen3.6 模型,并驱动 pi 编码 Agent,附带优化后的启动参数与采样配置。
用RP2350监视Z80
一篇博客文章,探讨如何使用带PIO的Raspberry Pi Pico RP2350来监视Z80微处理器的地址和数据总线,包括时序考虑和时钟速度限制。
can1357/oh-my-pi
Oh My Pi 是一个基于 Pi 构建的开源编码代理,提供集成的 IDE,支持 40 多个提供商,内置工具,以及在多种模型上的显著性能提升。
使用OpenCode、Llama.cpp和Qwen3.6在您的代码中查找错误
本文介绍了如何使用编码代理OpenCode结合llama.cpp和Qwen3.6模型在代码中查找错误,同时强调了防止LLM访问敏感数据所需的关键安全措施。
首次实现本地真实编程工作
开发者借助 Qwen3.6-35B 4-bit MLX 模型与 pi.dev 工具,在当前硬件上实现了高效的本地智能体编程,顺利完成了实际项目工单。