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

@@ -225,6 +225,20 @@ static inline int socket_select(int max_fd,
#endif
}
static inline int socket_recv_timeout(int fd, unsigned long timeout_msec)
{
#ifdef _WIN32
DWORD timeout = timeout_msec;
return setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (const char *)&timeout,
sizeof(timeout));
#else
struct timeval tv;
tv.tv_sec = timeout_msec / 1000;
tv.tv_usec = (timeout_msec % 1000) * 1000;
return setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv, sizeof(tv));
#endif
}
#ifndef HAVE_ELF_H
typedef uint32_t Elf32_Addr;