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
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802047560号
Welcome to OpenOCD!
OpenOCD provides on-chip programming and debugging support with a layered architecture of JTAG interface and TAP support including:
Several network interfaces are available for interacting with OpenOCD: telnet, TCL, and GDB. The GDB server enables OpenOCD to function as a “remote target” for source-level debugging of embedded systems using the GNU GDB program (and the others who talk GDB protocol, e.g. IDA Pro).
This README file contains an overview of the following topics:
============================ Quickstart for the impatient ============================
If you have a popular board then just start OpenOCD with its config, e.g.:
openocd -f board/stm32f4discovery.cfg
If you are connecting a particular adapter with some specific target, you need to source both the jtag interface and the target configs, e.g.:
openocd -f interface/ftdi/jtagkey2.cfg -c “transport select jtag”
-f target/ti_calypso.cfg
openocd -f interface/stlink.cfg -c “transport select hla_swd”
-f target/stm32l0.cfg
After OpenOCD startup, connect GDB with
(gdb) target extended-remote localhost:3333
===================== OpenOCD Documentation =====================
In addition to the in-tree documentation, the latest manuals may be viewed online at the following URLs:
OpenOCD User’s Guide: http://openocd.org/doc/html/index.html
OpenOCD Developer’s Manual: http://openocd.org/doc/doxygen/html/index.html
These reflect the latest development versions, so the following section introduces how to build the complete documentation from the package.
For more information, refer to these documents or contact the developers by subscribing to the OpenOCD developer mailing list:
Building the OpenOCD Documentation
By default the OpenOCD build process prepares documentation in the “Info format” and installs it the standard way, so that “info openocd” can access it.
Additionally, the OpenOCD User’s Guide can be produced in the following different formats:
If PDFVIEWER is set, this creates and views the PDF User Guide.
make pdf && ${PDFVIEWER} doc/openocd.pdf
If HTMLVIEWER is set, this creates and views the HTML User Guide.
make html && ${HTMLVIEWER} doc/openocd.html/index.html
The OpenOCD Developer Manual contains information about the internal architecture and other details about the code:
NB! make sure doxygen is installed, type doxygen –version
make doxygen && ${HTMLVIEWER} doxygen/index.html
================== Supported hardware ==================
JTAG adapters
AICE, AM335x, ARM-JTAG-EW, ARM-USB-OCD, ARM-USB-TINY, AT91RM9200, axm0432, BCM2835, Bus Blaster, Buspirate, Cadence DPI, Cadence vdebug, Chameleon, CMSIS-DAP, Cortino, Cypress KitProg, DENX, Digilent JTAG-SMT2, DLC 5, DLP-USB1232H, embedded projects, Espressif USB JTAG Programmer, eStick, FlashLINK, FlossJTAG, Flyswatter, Flyswatter2, FTDI FT232R, Gateworks, Hoegl, ICDI, ICEBear, J-Link, JTAG VPI, JTAGkey, JTAGkey2, JTAG-lock-pick, KT-Link, Linux GPIOD, Lisa/L, LPC1768-Stick, Mellanox rshim, MiniModule, NGX, Nuvoton Nu-Link, Nu-Link2, NXHX, NXP IMX GPIO, OOCDLink, Opendous, OpenJTAG, Openmoko, OpenRD, OSBDM, Presto, Redbee, Remote Bitbang, RLink, SheevaPlug devkit, Stellaris evkits, ST-LINK (SWO tracing supported), STM32-PerformanceStick, STR9-comStick, sysfsgpio, Tigard, TI XDS110, TUMPA, Turtelizer, ULINK, USB-A9260, USB-Blaster, USB-JTAG, USBprog, VPACLink, VSLLink, Wiggler, XDS100v2, Xilinx XVC/PCIe, Xverve.
Debug targets
ARM: AArch64, ARM11, ARM7, ARM9, Cortex-A/R (v7-A/R), Cortex-M (ARMv{6/7/8}-M), FA526, Feroceon/Dragonite, XScale. ARCv2, AVR32, DSP563xx, DSP5680xx, EnSilica eSi-RISC, EJTAG (MIPS32, MIPS64), ESP32, ESP32-S2, ESP32-S3, Intel Quark, LS102x-SAP, NDS32, RISC-V, ST STM8, Xtensa.
Flash drivers
ADUC702x, AT91SAM, AT91SAM9 (NAND), ATH79, ATmega128RFA1, Atmel SAM, AVR, CFI, DSP5680xx, EFM32, EM357, eSi-RISC, eSi-TSMC, EZR32HG, FM3, FM4, Freedom E SPI, GD32, i.MX31, Kinetis, LPC8xx/LPC1xxx/LPC2xxx/LPC541xx, LPC2900, LPC3180, LPC32xx, LPCSPIFI, Marvell QSPI, MAX32, Milandr, MXC, NIIET, nRF51, nRF52 , NuMicro, NUC910, Nuvoton NPCX, onsemi RSL10, Orion/Kirkwood, PIC32mx, PSoC4/5LP/6, Raspberry RP2040, Renesas RPC HF and SH QSPI, S3C24xx, S3C6400, SiM3x, SiFive Freedom E, Stellaris, ST BlueNRG, STM32, STM32 QUAD/OCTO-SPI for Flash/FRAM/EEPROM, STMSMI, STR7x, STR9x, SWM050, TI CC13xx, TI CC26xx, TI CC32xx, TI MSP432, Winner Micro w600, Xilinx XCF, XMC1xxx, XMC4xxx.
================== Installing OpenOCD ==================
A Note to OpenOCD Users
If you would rather be working “with” OpenOCD rather than “on” it, your operating system or JTAG interface supplier may provide binaries for you in a convenient-enough package.
Such packages may be more stable than git mainline, where bleeding-edge development takes place. These “Packagers” produce binary releases of OpenOCD after the developers produces new “release” versions of the source code. Previous versions of OpenOCD cannot be used to diagnose problems with the current release, so users are encouraged to keep in contact with their distribution package maintainers or interface vendors to ensure suitable upgrades appear regularly.
Users of these binary versions of OpenOCD must contact their Packager to ask for support or newer versions of the binaries; the OpenOCD developers do not support packages directly.
A Note to OpenOCD Packagers
You are a PACKAGER of OpenOCD if you:
As a PACKAGER, you will experience first reports of most issues. When you fix those problems for your users, your solution may help prevent hundreds (if not thousands) of other questions from other users.
If something does not work for you, please work to inform the OpenOCD developers know how to improve the system or documentation to avoid future problems, and follow-up to help us ensure the issue will be fully resolved in our future releases.
That said, the OpenOCD developers would also like you to follow a few suggestions:
================ Building OpenOCD ================
The INSTALL file contains generic instructions for running ‘configure’ and compiling the OpenOCD source code. That file is provided by default for all GNU autotools packages. If you are not familiar with the GNU autotools, then you should read those instructions first.
The remainder of this document tries to provide some instructions for those looking for a quick-install.
OpenOCD Dependencies
GCC or Clang is currently required to build OpenOCD. The developers have begun to enforce strict code warnings (-Wall, -Werror, -Wextra, and more) and use C99-specific features: inline functions, named initializers, mixing declarations with code, and other tricks. While it may be possible to use other compilers, they must be somewhat modern and could require extending support to conditionally remove GCC-specific extensions.
You’ll also need:
OpenOCD uses jimtcl library; build from git can retrieve jimtcl as git submodule.
Additionally, for building from git:
Optional USB-based adapter drivers need libusb-1.0.
Optional USB-Blaster, ASIX Presto and OpenJTAG interface adapter drivers need:
Optional CMSIS-DAP adapter driver needs HIDAPI library.
Optional linuxgpiod adapter driver needs libgpiod library.
Optional JLink adapter driver needs libjaylink; build from git can retrieve libjaylink as git submodule.
Optional ARM disassembly needs capstone library.
Optional development script checkpatch needs:
Permissions delegation
Running OpenOCD with root/administrative permissions is strongly discouraged for security reasons.
For USB devices on GNU/Linux you should use the contrib/60-openocd.rules file. It probably belongs somewhere in /etc/udev/rules.d, but consult your operating system documentation to be sure. Do not forget to add yourself to the “plugdev” group.
For parallel port adapters on GNU/Linux and FreeBSD please change your “ppdev” (parport* or ppi*) device node permissions accordingly.
For parport adapters on Windows you need to run install_giveio.bat (it’s also possible to use “ioperm” with Cygwin instead) to give ordinary users permissions for accessing the “LPT” registers directly.
Compiling OpenOCD
To build OpenOCD, use the following sequence of commands:
./bootstrap (when building from the git repository) ./configure [options] make sudo make install
The ‘configure’ step generates the Makefiles required to build OpenOCD, usually with one or more options provided to it. The first ‘make’ step will build OpenOCD and place the final executable in ‘./src/‘. The final (optional) step, ``make install’’, places all of the files in the required location.
To see the list of all the supported options, run ./configure –help
Cross-compiling Options
Cross-compiling is supported the standard autotools way, you just need to specify the cross-compiling target triplet in the –host option, e.g. for cross-building for Windows 32-bit with MinGW on Debian:
./configure –host=i686-w64-mingw32 [options]
To make pkg-config work nicely for cross-compiling, you might need an additional wrapper script as described at
https://autotools.io/pkgconfig/cross-compiling.html
This is needed to tell pkg-config where to look for the target libraries that OpenOCD depends on. Alternatively, you can specify *_CFLAGS and *_LIBS environment variables directly, see “./configure –help” for the details.
For a more or less complete script that does all this for you, see
contrib/cross-build.sh
Parallel Port Dongles
If you want to access the parallel port using the PPDEV interface you have to specify both –enable-parport AND –enable-parport-ppdev, since the later option is an option to the parport driver.
The same is true for the –enable-parport-giveio option, you have to use both the –enable-parport AND the –enable-parport-giveio option if you want to use giveio instead of ioperm parallel port access method.
========================== Obtaining OpenOCD From GIT ==========================
You can download the current GIT version with a GIT client of your choice from the main repository:
git://git.code.sf.net/p/openocd/code
You may prefer to use a mirror:
http://repo.or.cz/r/openocd.git git://repo.or.cz/openocd.git
Using the GIT command line client, you might use the following command to set up a local copy of the current repository (make sure there is no directory called “openocd” in the current directory):
git clone git://git.code.sf.net/p/openocd/code openocd
Then you can update that at your convenience using
git pull
There is also a gitweb interface, which you can use either to browse the repository or to download arbitrary snapshots using HTTP:
http://repo.or.cz/w/openocd.git
Snapshots are compressed tarballs of the source tree, about 1.3 MBytes each at this writing.