Skip to content

Commit 9777f42

Browse files
committed
backport: jtag/drivers: add T-Head CK-Link JTAG adapter driver
Driver for T-Head CK-Link Lite V2 probes, including the Bouffalo Lab BL616/BL702 CK-Link clones used as built-in debuggers on BL61x/BL70x evaluation boards. The wire protocol is a framed command format over USB bulk endpoints, reverse-engineered from T-Head's DebugServer. Implements JTAG_SCAN via the probe's batch opcode, with IR caching across execute_queue boundaries and end-of-queue flush so OpenOCD's Capture-IR validation reads real hardware data. Speed is programmable (freq_kHz = 48000 / (N+1), capped at the DebugServer-validated 2526 kHz). Probes are matched against a built-in VID/PID list and by adapter serial. Known protocol limitations, surfaced as one-time warnings: - Single batch entry encodes IR/DR bit-counts in single bytes; scans > 255 bits are clamped with TDI pass-through on the un-shifted portion. - The T-Head DTM's Capture-IR returns the current IR value rather than the IEEE 1149.1 'xxx01' pattern; init pre-loads IR = IDCODE. - No TMS-sequence opcode: JTAG_TMS and JTAG_PATHMOVE return ERROR_JTAG_NOT_IMPLEMENTED. - Multi-TAP chains are not supported. - RTCK is not supported. Tested against BL618 and BL702 evaluation boards. Adapted for the Zephyr OpenOCD fork: uses .transports string array instead of .transport_ids, and the 4-argument jtag_libusb_open() signature (serial matching handled internally by libusb_helper). Backport of: https://review.openocd.org/c/openocd/+/9586 Signed-off-by: William Markezana <william.markezana@gmail.com>
1 parent 91bd278 commit 9777f42

7 files changed

Lines changed: 778 additions & 0 deletions

File tree

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ m4_define([ADAPTER_OPT], [m4_translit(ADAPTER_ARG($1), [_], [-])])
115115

116116
m4_define([USB1_ADAPTERS],
117117
[[[ftdi], [MPSSE mode of FTDI based devices], [FTDI]],
118+
[[cklink], [T-Head CK-Link JTAG Probe], [CKLINK]],
118119
[[stlink], [ST-Link Programmer], [HLADAPTER_STLINK]],
119120
[[ti_icdi], [TI ICDI JTAG Programmer], [HLADAPTER_ICDI]],
120121
[[ulink], [Keil ULINK JTAG Programmer], [ULINK]],

contrib/60-openocd.rules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@ ATTRS{idVendor}=="2aec", ATTRS{idProduct}=="1106", MODE="660", GROUP="plugdev",
226226
ATTRS{idVendor}=="303a", ATTRS{idProduct}=="1001", MODE="660", GROUP="plugdev", TAG+="uaccess"
227227
ATTRS{idVendor}=="303a", ATTRS{idProduct}=="1002", MODE="660", GROUP="plugdev", TAG+="uaccess"
228228

229+
# T-Head CK-Link Lite (PingTouGe Semiconductor)
230+
ATTRS{idVendor}=="32bf", ATTRS{idProduct}=="b210", MODE="660", GROUP="plugdev", TAG+="uaccess"
231+
232+
# Bouffalo Lab BL616/BL702 CK-Link clones
233+
ATTRS{idVendor}=="42bf", ATTRS{idProduct}=="b210", MODE="660", GROUP="plugdev", TAG+="uaccess"
234+
229235
# Marvell Sheevaplug
230236
ATTRS{idVendor}=="9e88", ATTRS{idProduct}=="9e8f", MODE="660", GROUP="plugdev", TAG+="uaccess"
231237

doc/openocd.texi

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2523,6 +2523,22 @@ and a specific set of GPIOs is used.
25232523
@c chooses among list of bit configs ... only one option
25242524
@end deffn
25252525

2526+
@deffn {Interface Driver} {cklink}
2527+
Driver for the T-Head CK-Link Lite V2 JTAG probe and Bouffalo Lab
2528+
BL616/BL702 clones, including the built-in debugger on Bouffalo BL618
2529+
evaluation boards. Communication is over USB bulk endpoints using a
2530+
T-Head DebugServer-compatible framed command protocol.
2531+
2532+
The driver only supports JTAG transport and a single-TAP chain. The
2533+
probe runs at a fixed clock; @command{adapter speed} requests are
2534+
accepted but ignored (with a one-time warning). @command{JTAG_TMS} and
2535+
@command{JTAG_PATHMOVE} are not supported by this probe's protocol.
2536+
2537+
By default the driver matches 0x42bf/0xb210 (Bouffalo) and
2538+
0x32bf/0xb210 (T-Head). The built-in list can be overridden via
2539+
@command{adapter usb vid_pid}.
2540+
@end deffn
2541+
25262542
@deffn {Interface Driver} {cmsis-dap}
25272543
ARM CMSIS-DAP compliant based adapter v1 (USB HID based)
25282544
or v2 (USB bulk).

src/jtag/drivers/Makefile.am

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ endif
165165
if XLNX_PCIE_XVC
166166
DRIVERFILES += %D%/xlnx-pcie-xvc.c
167167
endif
168+
if CKLINK
169+
DRIVERFILES += %D%/cklink.c
170+
endif
168171
if BCM2835GPIO
169172
DRIVERFILES += %D%/bcm2835gpio.c
170173
endif

0 commit comments

Comments
 (0)