{"id":31588651,"url":"https://github.com/bkuschak/cmsis_dap_tcp_esp32","last_synced_at":"2026-05-17T00:02:59.954Z","repository":{"id":300875144,"uuid":"1002659977","full_name":"bkuschak/cmsis_dap_tcp_esp32","owner":"bkuschak","description":"CMSIS-DAP programmer using TCP/IP rather than USB connection to the host.  Runs on ESP32 and connects over WiFi to OpenOCD using the cmsis-dap-tcp backend.  Supports JTAG and SWD.","archived":false,"fork":false,"pushed_at":"2025-09-29T07:44:59.000Z","size":3495,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-06T02:24:53.823Z","etag":null,"topics":["arm","cmsis-dap","cmsis-dap-v2","debugger","esp-idf","esp32","esp32c6","esp32s3","esp32s3-devkitc-1","flash","jtag","jtag-adapter","jtag-probe","openocd","programmer","swd","swd-probe"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bkuschak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-15T23:42:27.000Z","updated_at":"2025-09-28T01:49:18.000Z","dependencies_parsed_at":"2025-08-27T04:28:18.892Z","dependency_job_id":"7646da92-ddc3-4654-8819-5391b6b81060","html_url":"https://github.com/bkuschak/cmsis_dap_tcp_esp32","commit_stats":null,"previous_names":["bkuschak/cmsis_dap_tcp_esp32"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bkuschak/cmsis_dap_tcp_esp32","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkuschak%2Fcmsis_dap_tcp_esp32","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkuschak%2Fcmsis_dap_tcp_esp32/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkuschak%2Fcmsis_dap_tcp_esp32/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkuschak%2Fcmsis_dap_tcp_esp32/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bkuschak","download_url":"https://codeload.github.com/bkuschak/cmsis_dap_tcp_esp32/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkuschak%2Fcmsis_dap_tcp_esp32/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279166535,"owners_count":26118042,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-16T02:00:06.019Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arm","cmsis-dap","cmsis-dap-v2","debugger","esp-idf","esp32","esp32c6","esp32s3","esp32s3-devkitc-1","flash","jtag","jtag-adapter","jtag-probe","openocd","programmer","swd","swd-probe"],"created_at":"2025-10-06T02:12:00.074Z","updated_at":"2025-10-16T07:44:24.698Z","avatar_url":"https://github.com/bkuschak.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cmsis_dap_tcp for OpenOCD\n\nOpenOCD supports the CMSIS-DAP protocol to communicate with a JTAG / SWD\nprogrammer. Typically this is a local programmer with a USB connection. With\nthe addition of the OpenOCD cmsis_dap_tcp backend, the CMSIS-DAP protocol can\nnow run over TCP/IP instead of USB. This allows OpenOCD to connect to a remote\nprogrammer over the network.\n\nThis project provides the remote-side implementation of the cmsis_dap_tcp\nprotocol, using an ESP32 as the remote programmer. It allows a cheap ESP32\nboard to program and debug an ARM microcontroller target. Both JTAG and the\ntwo-wire SWD interface are supported. OpenOCD connects to the ESP32 using\nTCP/IP over WiFi, allowing remote flashing and debugging of the ARM target\nboard.\n\n![diagram](img/cmsis_dap_tcp_diagram.svg)\n\n- Tested with the XIAO ESP32C6 and ESP32-S3-DevKitC-1 development boards as the\n  programmer, and STM32F103 Blue Pill and Nucleo STM32F401RE as the targets.\n- Either JTAG mode or SWD mode can be used to program the target. 2 GPIO are\n  needed for SWD, or a minimum of 4 GPIO for JTAG.\n- An optional GPIO pin can be used to drive the NRST# (SRST) signal, but this\n  is typically not required.\n- In JTAG mode, an optional GPIO pin can be used to drive the TRST signal, but\n  this is typically not required.\n- A separate GPIO may be used to control an activity LED.\n- UART to TCP/IP bridge can be enabled to provide access to the target board's\n  serial console remotely, using an ESP32 UART.\n- Typical performance:\n  - Reading / writing SRAM: up to 200 KB/sec\n  - Flashing a 512 KB firmware image to the STM32F401RE\n  completes in about 13.4 seconds, including erase, program, and verify (with 4\n  to 8 seconds of that time used for flash erasure). The Blue Pill takes about\n  6 seconds for a 64KB image.\n  - Performance depends on the quality of your WiFi network.\n\n![pinout](img/xiao_esp32c6_pinout.png)\n\nThe CMSIS-DAP code came from the Firmware directory of the [CMSIS-DAP\nrepo](https://github.com/ARM-software/CMSIS-DAP). ```DAP_config.h``` was then\nmodified to support the ESP32 GPIO.\n```\ncommit 1fd47bed772ea40923472c90dfe11516e76033ee (HEAD -\u003e main, tag: v2.1.2, origin/main, origin/HEAD)\n```\n\n# Limitations\n\nThe software has some limitations:\n\n- SWO is currently unsupported.\n- Maximum clock rate is about 1000 KHz (ESP32C6 configured for 160 MHz / 80 MHz).\n- The WiFi credentials are hardcoded. The software must be rebuilt if you want\n  to change them.\n\n# Building and Flashing the Firmware\n\nThis code requires the ESP-IDF build tools. Refer to the official\n[installation guide](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/get-started/index.html#installation)\nand install them first.\n\nActivate your ESP-IDF virtual environment:\n\n```\n. $HOME/esp/esp-idf/export.sh\n```\n\nThe code supports multiple different boards, and each one has its own\n```sdkconfig``` file.\n\nChoose the correct ```sdkconfig.\u003cboard_name\u003e``` file for your board and copy it\nto ```sdkconfig```. Then configure, build and flash the firmware. For example,\nfor the Xiao ESP32-C6 board:\n\n```\ncp sdkconfig.xiao_esp32c6 sdkconfig\nidf.py fullclean menuconfig\nidf.py build flash\n```\n\nIn menuconfig, goto to the \"CMSIS-DAP configuration\" page.\n\n* Your WiFi SSID and password can be configured on the \"WiFi configuration\"\n  subpage.  (If you are not using WPA2, you might need to adjust the WiFi Scan\n  auth mode threshold).\n\n  \u003cimg src=\"img/menuconfig1.png\" width=\"75%\" /\u003e\n  \u003cbr\u003e\u003cbr\u003e\n  \u003cimg src=\"img/menuconfig2.png\" width=\"75%\" /\u003e\n\n* If needed, you can change the GPIO port pins for JTAG, SWD, reset, and LED on\n  the \"GPIO number assignments\" subpage. The signals can be disabled if they are\n  not needed.\n\n  \u003cimg src=\"img/menuconfig3.png\" width=\"75%\" /\u003e\n\n* If you want to use the UART to TCP/IP bridge, it can be configured on the\n  the \"UART to TCP/IP bridge\" subpage. (Currently, the baud rate and other\n  settings cannot be changed at runtime). A script ```host/uart_bridge.sh```\n  is provided that uses ```socat``` to present the remote UART as a pseudo-tty\n  that can be opened using any serial terminal program on the host.\n\n  \u003cimg src=\"img/menuconfig4.png\" width=\"75%\" /\u003e\n\n\n# Building and Running OpenOCD\n\nGet the latest source code from git. Configure and build it as usual:\n\n```\ngit clone git://git.code.sf.net/p/openocd/code openocd\ncd openocd\n./bootstrap\n./configure\nmake\n```\n\nAn OpenOCD configuration file has been provided for convenience.\nEdit your ```tcl/interface/cmsis_dap_tcp.cfg``` configuration file to point to\nyour ESP32's IP address:\n\n```\nadapter driver cmsis-dap\ncmsis-dap backend tcp\ncmsis-dap tcp host 192.168.1.107\ncmsis-dap tcp port 4441\ntransport select swd\nreset_config none\n```\n\nIf you are on a slow WiFi network, you might need to add this line to avoid\nshort timeouts that can lead to command mismatch errors in some cases. If so,\nspecify a longer timeout in milliseconds:\n\n```\ncmsis-dap tcp min_timeout 300\n```\n\nTo flash an STM32 target, for example, run the following command from your\nOpenOCD build directory.  Replace ```firmware.elf``` with the name of your\nELF file, and ```stm32f1x.cfg``` with the appropriate file for your\nmicrocontroller.\n\n```\n./src/openocd --search tcl \\\n              -f tcl/interface/cmsis-dap-tcp.cfg \\\n              -f tcl/target/stm32f1x.cfg \\\n              -c \"program firmware.elf verify reset exit\"\n```\n\n# Operation\n\nAfter power-on, the ESP32 will attempt to connect to the WiFi that was\nconfigured using menuconfig. It will then begin listening for an incoming\nconnection from OpenOCD. The ESP32 will print status and error messages to the\nconsole, including the WiFi connection status and IP address. A message is\nprinted whenever the OpenOCD client connects or disconnects. (Only one active\nclient is allowed).\n\nYou can run the serial monitor to view the console output. To exit the serial\nmonitor use ```Ctrl+]```.\n\n```\nidf.py monitor\n```\n\nOnce the ESP32 has connected to WiFi and obtained an IP address by DHCP, you\ncan then run OpenOCD. You should see something like this from the ESP32:\n\n```\nCMSIS-DAP TCP running on ESP32\nESP-IDF version: v6.0-dev-1489-g4e036983a7\nHardware version: esp32s3 with 2 CPU core(s), WiFi/BLE, silicon revision v0.2, 2MB external flash\nMinimum free heap size: 337312 bytes\nMAC address: E4B323B60EB4\nAttempting to connect to WiFi SSID: 'SomeWifiRouter'\nConnected to WiFi SSID: 'SomeWifiRouter'. RSSI: -75 dBm\nIP address: 192.168.1.107\nDisabling WiFi power savings to improve performance.\ncmsis_dap_tcp: listening on port 4441.\nUART bridge: remapping UART_TX = GPIO_NUM_16, UART_RX = GPIO_NUM_15.\nUART bridge: listening on port 4442 for UART1.\nIPv6 address (link-local): fe80:0000:0000:0000:9aa3:16ff:feec:6640\nIPv6 address (global): 2406:3400:031f:ba10:9aa3:16ff:feec:6640\n```\n\nAdditional debugging messages may be enabled by editing\n```main/cmsis_dap_tcp.h``` and uncommenting the following line. This will\nimpact performance.\n\n```\n#define DEBUG_PRINTING\n```\n\n# Performance\n\nA single SWD 32-bit transfer completes in about 45 microseconds, with an\nSWCLK clock rate of approximately 1 MHz. Yellow is SWCLK. Green is SWDIO.\n\n(TODO: the scope available at the time to make these measurements was very\nlimited. Redo these measurements with a better scope).\n\n![scopeshot1](img/scopeshot1.png)\n\n![scopeshot1](img/scopeshot2.png)\n\nActual performance will depend on your WiFi network. For slow networks,\nyou might need to increase the ```cmsis-dap tcp min_timeout``` parameter if\nyou see error messages related to command mismatch.\n\nStarting the OpenOCD server like this:\n\n```\n./src/openocd \\\n    --search tcl \\\n    -c \"debug_level 2\" \\\n    -c \"adapter driver cmsis-dap\" \\\n    -c \"transport select swd\" \\\n    -c \"cmsis-dap backend tcp\" \\\n    -c \"cmsis-dap tcp host 192.168.1.107\" \\\n    -c \"cmsis-dap tcp port 4441\" \\\n    -c \"cmsis-dap tcp min_timeout 150\" \\\n    -f \"tcl/target/stm32f4x.cfg\" \\\n    -c \"reset_config none\"\n\nOpen On-Chip Debugger 0.12.0+dev-01114-gbf01f1089 (2025-08-07-11:52)\nLicensed under GNU GPL v2\nFor bug reports, read\n\thttp://openocd.org/doc/doxygen/bugs.html\nInfo : CMSIS-DAP: using minimum timeout of 100 ms for TCP packets.\nnone separate\nInfo : Listening on port 6666 for tcl connections\nInfo : Listening on port 4444 for telnet connections\nInfo : CMSIS-DAP: Connecting to 192.168.1.107:4441 using TCP backend\nInfo : CMSIS-DAP: SWD supported\nInfo : CMSIS-DAP: JTAG supported\nInfo : CMSIS-DAP: Atomic commands supported\nInfo : CMSIS-DAP: Test domain timer supported\nInfo : CMSIS-DAP: FW Version = 2.1.2\nInfo : CMSIS-DAP: Serial# = E4B323B60EB4\nInfo : CMSIS-DAP: Interface Initialised (SWD)\nInfo : SWCLK/TCK = 0 SWDIO/TMS = 0 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1\nInfo : CMSIS-DAP: Interface ready\nInfo : clock speed 2000 kHz\nInfo : SWD DPIDR 0x2ba01477\nInfo : [stm32f4x.cpu] Cortex-M4 r0p1 processor detected\nInfo : [stm32f4x.cpu] target has 6 breakpoints, 4 watchpoints\nInfo : [stm32f4x.cpu] Examination succeed\nInfo : [stm32f4x.cpu] starting gdb server on 3333\nInfo : Listening on port 3333 for gdb connections\nInfo : accepting 'telnet' connection on tcp/4444\n```\n\n## Using ESP32-C6 @ 160 MHz\n\nXiao ESP32C6 running at 160 MHz is the programmer board. Connecting to an\nSTM32F401RE target and reading and writing SRAM:\n\n```\n% telnet localhost 4444\n\u003e poll off\n\n\u003e load_image ./random_96kb.bin 0x20000000\n98304 bytes written at address 0x20000000\ndownloaded 98304 bytes in 1.092678s (87.858 KiB/s)\n\n\u003e dump_image /dev/null 0x20000000 0x18000\ndumped 98304 bytes in 1.469766s (65.317 KiB/s)\n```\n\nProgramming and verifying a 512 KB flash image takes about 20 seconds:\n\n```\ntime ./src/openocd \\\n    --search tcl \\\n    -c \"debug_level 2\" \\\n    -c \"adapter driver cmsis-dap\" \\\n    -c \"transport select swd\" \\\n    -c \"cmsis-dap backend tcp\" \\\n    -c \"cmsis-dap tcp host 192.168.1.107\" \\\n    -c \"cmsis-dap tcp port 4441\" \\\n    -f \"tcl/target/stm32f4x.cfg\" \\\n    -c \"reset_config none\" \\\n    -c \"program ${ELF} verify reset exit\"\n\nOpen On-Chip Debugger 0.12.0+dev-01114-gbf01f1089 (2025-08-07-11:52)\nLicensed under GNU GPL v2\nFor bug reports, read\n\thttp://openocd.org/doc/doxygen/bugs.html\nnone separate\nInfo : CMSIS-DAP: Connecting to 192.168.1.107:4441 using TCP backend\nInfo : CMSIS-DAP: SWD supported\nInfo : CMSIS-DAP: JTAG supported\nInfo : CMSIS-DAP: Atomic commands supported\nInfo : CMSIS-DAP: Test domain timer supported\nInfo : CMSIS-DAP: FW Version = 2.1.2\nInfo : CMSIS-DAP: Serial# = E4B323B60EB4\nInfo : CMSIS-DAP: Interface Initialised (SWD)\nInfo : SWCLK/TCK = 0 SWDIO/TMS = 0 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1\nInfo : CMSIS-DAP: Interface ready\nInfo : clock speed 2000 kHz\nInfo : SWD DPIDR 0x2ba01477\nInfo : [stm32f4x.cpu] Cortex-M4 r0p1 processor detected\nInfo : [stm32f4x.cpu] target has 6 breakpoints, 4 watchpoints\nInfo : [stm32f4x.cpu] Examination succeed\nInfo : [stm32f4x.cpu] starting gdb server on 3333\nInfo : Listening on port 3333 for gdb connections\n[stm32f4x.cpu] halted due to debug-request, current mode: Thread\nxPSR: 0x01000000 pc: 0x08000734 msp: 0x20018000\n** Programming Started **\nInfo : device id = 0x10016433\nInfo : flash size = 512 KiB\n** Programming Finished **\n** Verify Started **\n** Verified OK **\n** Resetting Target **\nshutdown command invoked\n\nreal\t0m19.242s\nuser\t0m0.052s\nsys\t\t0m0.155s\n```\n\n## Using ESP32-S3 @ 240 MHz\n\nPerformance is higher on ESP32-S3. The throughput seems more variable\non each run, but here are some representative numbers for writing and\nreading SRAM:\n\n```\n% telnet localhost 4444\n\u003e poll off\n\n\u003e load_image ./random_96kb.bin 0x20000000\n98304 bytes written at address 0x20000000\ndownloaded 98304 bytes in 0.489488s (196.123 KiB/s)\n\n\u003e dump_image /dev/null 0x20000000 0x18000\ndumped 98304 bytes in 0.832846s (115.267 KiB/s)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbkuschak%2Fcmsis_dap_tcp_esp32","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbkuschak%2Fcmsis_dap_tcp_esp32","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbkuschak%2Fcmsis_dap_tcp_esp32/lists"}