jtag/drivers/cmsis_dap: add new backend cmsis_dap_tcp

Create a new backend for cmsis_dap driver that allows CMSIS-DAP protocol
to run over TCP/IP instead of USB.

An example implementation of the firmware for an SWD programmer that
uses this cmsis_dap_tcp protocol can be found at the link below.
https://github.com/bkuschak/cmsis_dap_tcp_esp32

Using this cmsis_dap_tcp backend with the firmware above on an ESP32-C6
programmer and STM32F401RE target shows the following performance:
- loading 96KB image to RAM: 80 KB/sec
- dumping 96KB image from RAM: 72 KB/sec
- flashing 512KB image completes in about 13.5 seconds (including erase,
  program, and verify).

Change-Id: I6e3e45016bd16ef2259561b1046788f5536b0687
Signed-off-by: Brian Kuschak <bkuschak@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8973
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
This commit is contained in:
Brian Kuschak
2025-06-11 12:41:04 +08:00
committed by Tomas Vanek
parent 64ed1c74d5
commit fcff4b712c
8 changed files with 543 additions and 11 deletions

View File

@@ -2621,7 +2621,7 @@ ch347 activity_led n4
@deffn {Interface Driver} {cmsis-dap}
ARM CMSIS-DAP compliant based adapter v1 (USB HID based)
or v2 (USB bulk).
or v2 (USB bulk or TCP/IP).
@deffn {Config Command} {cmsis-dap vid_pid} [vid pid]+
The vendor ID and product ID of the CMSIS-DAP device. If not specified
@@ -2632,14 +2632,17 @@ cmsis-dap vid_pid 0xc251 0xf001 0x0d28 0x0204
@end example
@end deffn
@deffn {Config Command} {cmsis-dap backend} [@option{auto}|@option{usb_bulk}|@option{hid}]
@deffn {Config Command} {cmsis-dap backend} [@option{auto}|@option{usb_bulk}|@option{hid}|@option{tcp}]
Specifies how to communicate with the adapter:
@itemize @minus
@item @option{hid} Use HID generic reports - CMSIS-DAP v1
@item @option{hid} Use USB HID generic reports - CMSIS-DAP v1
@item @option{usb_bulk} Use USB bulk - CMSIS-DAP v2
@item @option{auto} First try USB bulk CMSIS-DAP v2, if not found try HID CMSIS-DAP v1.
This is the default if @command{cmsis-dap backend} is not specified.
@item @option{tcp} Use TCP/IP instead of USB
@item @option{auto} First try USB bulk CMSIS-DAP v2, if not found try USB HID
CMSIS-DAP v1, if not found try TCP (if @command{cmsis-dap tcp host} is
configured). This is the default if @command{cmsis-dap backend} is not
specified.
@end itemize
@end deffn
@@ -2649,6 +2652,36 @@ In most cases need not to be specified and interfaces are searched by
interface string or for user class interface.
@end deffn
@deffn {Config Command} {cmsis-dap tcp host} hostname
Specifies the @var{hostname} or IP address of the remote programmer. For use
with 'tcp' backend only.
@example
cmsis-dap backend tcp
cmsis-dap tcp host 192.168.1.4
@end example
@end deffn
@deffn {Config Command} {cmsis-dap tcp port} port
Specifies the TCP @var{port} number used by the remote programmer for DAP
commands. The default port is 4441. For use with 'tcp' backend only.
@example
cmsis-dap backend tcp
cmsis-dap tcp host 192.168.1.4
cmsis-dap tcp port 4441
@end example
@end deffn
@deffn {Config Command} {cmsis-dap tcp min_timeout} milliseconds
Sets a lower bound on the requested timeout in @var{milliseconds} to wait for
response packets from the remote programmer when using the 'tcp' backend. The
user may want to use a larger value on slower networks, to avoid getting
command mismatch errors. Default value is 150 milliseconds. For use with 'tcp'
backend only.
@example
cmsis-dap tcp min_timeout 200
@end example
@end deffn
@deffn {Command} {cmsis-dap quirk} [@option{enable}|@option{disable}]
Enables or disables the following workarounds of known CMSIS-DAP adapter
quirks: