2 Star 3 Fork 19

snail0815 / wireless-esp32-dap

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

背面

简介

只需要合宙9.9的ESP32C3简约版即可开始无线调试!通过USBIP协议栈和CMSIS-DAP协议栈实现。

👉在5米范围内,擦除并烧写100kb大小的固件(Hex固件) :


对于Keil用户,我们现在支持elaphureLink。无需usbip即可开始您的无线调试之旅!

1679409793691

特性

  1. 支持的ESP芯片

    • ESP32C3
  2. 支持的调试接口:

    • SWD
    • JTAG
  3. 支持的USB通信协议:

    • USB-HID
    • WCID & WinUSB (默认)
  4. 支持的调试跟踪器:

    • TCP转发的串口
  5. 其它

    • 通过SPI接口加速的SWD协议(最高可达40MHz)
    • 支持elaphureLink,无需驱动的快速Keil调试
    • 整个工程成本不超过12块RMB就能实现。

连接你的开发板

WIFI连接

固件默认的WIFI SSID是DAP或者OTA,密码是12345678

你可以在wifi_configuration.h文件中添加多个无线接入点。

你还可以在上面的配置文件中修改IP地址(但是我们更推荐你通过在路由器上绑定静态IP地址)。

image-20230321224009975

固件中已经内置了一个mDNS服务。你可以通过dap.local的地址访问到设备。

调试接口连接

ESP32C3
SWD
SWCLK GPIO6
SWDIO GPIO7
TVCC 3V3
GND GND

JTAG
TCK GPIO6
TMS GPIO7
TDI GPIO9
TDO GPIO8
nTRST (optional) GPIO4
nRESET GPIO5
TVCC 3V3
GND GND

Other
LED_WIFI_STATUS GPIO12
Tx GPIO19
Rx GPIO18

Rx和Tx用于TCP转发的串口,默认不开启该功能。


硬件参考电路

硬件使用合宙9.9的ESP32-C3,通过制作一个底板的方式将引脚引出,详细见文件夹:1.Hardware

image-20230321225154149

你也可以去以下开源平台查看工程:https://oshwhub.com/badboyhuan/wu-xian-daplink-di-zuo_copy


编译固件并烧写

在本地构建并烧写

ESP32/ESP32C3
  1. 获取esp-idf

    目前,请考虑使用esp-idf v4.4.2: https://github.com/espressif/esp-idf/releases/tag/v4.4.2

  2. 编译和烧写

    使用ESP-IDF编译系统进行构建。 更多的信息,请见:Build System

下面例子展示了在Windows上完成这些任务的一种可行方法:

# 编译
idf.py build
# 烧写
idf.py -p /dev/ttyS5 flash

位于项目根目录的idf.py脚本仅适用于较老的ESP8266设备,请不要在ESP32设备上使用。

我们还提供了预编译固件用于快速评估。详见 wireless-esp32-dap 发行版 - Gitee.com

使用

  1. 获取USBIP项目
  1. 获得的.ZIP文件解压,放在一个文件夹里,并在系统的环境变量里添加位置。

  2. 安装 USB/IP 测试证书:

    • 安装(密码:usbip)driver/usbip_test.pfx
    • 证书应安装在
      1. “本地计算机”中的“受信任的根证书颁发机构”(不是当前用户)
      2. “本地计算机”中的“受信任的发布者”(不是当前用户)
  3. 在命令行输入:(开启系统测试模式)

    bcdedit.exe /set TESTSIGNING ON
  4. 重新启动系统以应用 重启后会出现下图: image-20230321223239477

  5. 在管理员身份下运行CMD输入如下命令:

    usbip.exe install
  6. 启动ESP32-C3并且把ESP32-C3连接到同一个WIFI下。

  7. 通过USBIP连接ESP32:

# 👉 推荐HID模式或者WinUSB模式。用于usbip-win 0.3.6 版本。
usbip.exe attach -r <usbip server ip> -b 1-1

如果一切顺利,你应该看到你的设备被连接,如下图所示。

image-20230321222750084

下面我们用keil MDK来测试:

image-20230321222936834


经常会问的问题

Keil提示“RDDI-DAP ERROR”或“SWD/JTAG Communication Failure”

  1. 检查线路连接。别忘了连接3V3引脚。
  2. 检查网络连接是否稳定。

DAP很慢或者不稳定

注意,本项目受限于周围的网络环境。如果你在电脑上使用热点进行连接,你可以尝试使用wireshark等工具对网络连接进行分析。当调试闲置时,线路上应保持静默,而正常工作时一般不会发生太多的丢包。

一些局域网广播数据包可能会造成严重影响,这些包可能由这些应用发出:

  • DropBox LAN Sync
  • Logitech Arx Control
  • ...

对于ESP32, 这无异于UDP洪水攻击...😰

周围的射频环境同样会造成影响,此外距离、网卡性能等也可能是需要考虑的。

文档

速度策略

单独使用ESP32通用IO时的最大翻转速率只有大概2MHz。当你选择最大时钟时,我们需要采取以下操作:

  • clock < 2Mhz :与你选择的时钟速度类似。
  • 2MHz <= clock < 10MHz :使用最快的纯IO速度。
  • clock >= 10MHz :使用40MHz时钟的SPI加速。

请注意,这个项目最重要的速度制约因素仍然是TCP连接速度。

对于OpenOCD用户

这个项目最初是为在Keil上运行而设计的,但现在你也可以在OpenOCD上通过它来烧录程序。 注意,如果你想使用40MHz的SPI加速器,你需要在连接目标设备后指定速度,否则会在开始时失败。

# 在使用flash指令前需要先运行:
> adapter speed 10000

> halt
> flash write_image [erase] [unlock] filename [offset] [type]

Keil的操作时序与OpenOCD的有些不同。例如,OpenOCD在读取 "IDCODE "寄存器之前缺少SWD线复位序列。

系统 OTA

当这个项目被更新时,你可以通过无线方式更新固件。

请访问以下网站了解OTA操作。在线OTA

对于大多数ESP32设备,你不需要关心闪存的大小。然而,闪存大小设置不当可能会导致OTA失败。在这种情况下,请用idf.py menuconfig改变闪存大小,或者修改sdkconfig

# 选择一个flash大小
CONFIG_ESPTOOLPY_FLASHSIZE_1MB=y
CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y

# 然后设置flash大小
CONFIG_ESPTOOLPY_FLASHSIZE="2MB"

如果闪存大小为2MB,sdkconfig文件会看起来像这样:

CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y
CONFIG_ESPTOOLPY_FLASHSIZE="2MB"

可以用esptool.py工具检查你使用的ESP设备闪存大小:

esptool.py -p (PORT) flash_id

TCP转发的串口

该功能在TCP和Uart之间提供了一个桥梁:

发送数据   ->  TCP  ->  Uart TX -> 外部设备

接收数据   <-  TCP  <-  Uart Rx <- 外部设备

当TCP连接建立后,ESP芯片将尝试解决首次发送的文本。当文本是一个有效的波特率时,转发器就会切换到该波特率。例如,发送ASCII文本115200会将波特率切换为115200。 由于性能原因,该功能默认不启用。你可以修改 wifi_configuration.h 来打开它。

abc


开发

请查看其他分支以了解最新的开发进展。我们欢迎任何形式的贡献,包括但不限于新功能、关于电路的想法和文档。

如果你有什么想法,欢迎在下面提出:

致谢

归功于以下项目、人员和组织。

许可证

MIT 许可证

![背面](README.assets/背面.png) [中文](README_CN.md) ## Introduce Just need **the simplified version of ESP32C3 from Universal 9.9** to start wireless debugging! Implemented through the USBIP protocol stack and the CMSIS-DAP protocol stack. Realized by USBIP and CMSIS-DAP protocol stack. > 👉 5m range, 100kb size firmware(Hex) earse and download test: <p align="center"><img src="https://user-images.githubusercontent.com/17078589/120925694-4bca0d80-c70c-11eb-91b7-ffa54770faea.gif"/></p> ---- For Keil users, we now also support [elaphureLink](https://github.com/windowsair/elaphureLink). No need for usbip to start your wireless debugging! ## Feature 1. SoC Compatibility - [x] ESP32C3 2. Debug Communication Mode - [x] SWD - [x] JTAG 3. USB Communication Mode - [x] USB-HID - [x] WCID & WinUSB (Default) 4. Debug Trace (Uart) - [x] Uart TCP Bridge 5. More.. - [x] SWD protocol based on SPI acceleration (Up to 40MHz) - [x] Support for [elaphureLink](https://github.com/windowsair/elaphureLink), fast Keil debug without drivers - [x] ... ## Link your board ### WIFI The default connected WIFI SSID is `DAP` or `OTA` , password `12345678` Support for specifying multiple possible WAP. It can be added here: [wifi_configuration.h](main/wifi_configuration.h) You can also specify your IP in the above file (We recommend using the static address binding feature of the router). ![image-20230321224009975](README.assets/image-20230321224009975.png) There is built-in ipv4 only mDNS server. You can access the device using `dap.local`. > The mDNS in ESP8266 only supports ipv4. ![mDNS](https://user-images.githubusercontent.com/17078589/149659052-7b29533f-9660-4811-8125-f8f50490d762.png) ### Debugger <details> <summary>ESP32C3</summary> | SWD | | |----------------|--------| | SWCLK | GPIO6 | | SWDIO | GPIO7 | | TVCC | 3V3 | | GND | GND | -------------- | JTAG | | |--------------------|---------| | TCK | GPIO6 | | TMS | GPIO7 | | TDI | GPIO9 | | TDO | GPIO8 | | nTRST \(optional\) | GPIO4 | | nRESET | GPIO5 | | TVCC | 3V3 | | GND | GND | -------------- | Other | | |--------------------|---------------| | LED\_WIFI\_STATUS | GPIO10 | | Tx | GPIO19 | | Rx | GPIO18 | > Rx and Tx is used for uart bridge, not enabled by default. </details> ---- ## Hardware Reference The hardware uses the ESP 32-C3 of Universal 9.9 to lead out the pins by making a backplane ![image-20230321225154149](README.assets/image-20230321225154149.png) ***Alternatively, you can connect directly with wires as we gave at the beginning, without additional circuits.*** You can also view projects on the following open source platformscircuit:https://oshwhub.com/badboyhuan/wu-xian-daplink-di-zuo_copy ------ ## Build And Flash You can build locally or use Github Action to build online and then download firmware to flash. ### Build with Github Action Online See: [Build with Github Action](https://github.com/windowsair/wireless-esp8266-dap/wiki/Build-with-Github-Action) ### General build and Flash <details> <summary>ESP32/ESP32C3</summary> 1. Get esp-idf For now, please use esp-idf v4.4.2 : https://github.com/espressif/esp-idf/releases/tag/v4.4.2 2. Build & Flash Build with ESP-IDF build system. More information can be found at the following link: [Build System](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html "Build System") The following example shows a possible way to build: ```bash # Set build target idf.py set-target esp32 # Build idf.py build # Flash idf.py -p /dev/ttyS5 flash ``` > The `idf.py` in the project root directory is only applicable to the old ESP8266 target. Don't use it in ESP32. </details> > We also provided sample firmware for quick evaluation. See [wireless-esp32-dap 发行版 - Gitee.com](https://gitee.com/wu-donghuan/wireless-esp32-dap/releases)](https://github.com/windowsair/wireless-esp8266-dap/releases) ## Usage 1. Get USBIP project - Windows: [usbip-win](https://github.com/cezanne/usbip-win) . - Linux: Distributed as part of the Linux kernel, but we have not yet tested on Linux platform, and the following instructions are all under Windows platform. 2. Start ESP chip and connect it to the device to be debugged 3. Connect it with usbip: ```bash # HID Mode only # for pre-compiled version on SourceForge # or usbip old version .\usbip.exe -D -a <your-esp-device-ip-address> 1-1 # 👉 Recommend # HID Mode Or WinUSB Mode # for usbip-win 0.3.6 ude usbip.exe attach -r <usbip server ip> -b 1-1 ``` If all goes well, you should see your device connected. ![image-20230321222750084](README.assets/image-20230321222750084.png) Here, we use MDK for testing: ![image-20230321222936834](README.assets/image-20230321222936834.png) ------ ## FAQ ### Keil is showing a "RDDI-DAP ERROR" or "SWD/JTAG Communication Failure" message. 1. Check your line connection. Don't forget the 3v3 connection cable. 2. Check that your network connection is stable. ### DAP is slow or often abnormal. Note that this project is sensitive to the network environment. If you are using a hotspot on your computer, you can try using network analyzer such as wireshark to observe the status of your AP network. During the idle time, the network should stay silent, while in the working state, there should be no too much packet loss. Some LAN broadcast packets can cause serious impact, including: - DropBox LAN Sync - Logitech Arx Control - ... For ESP8266, this is not far from UDP FLOOD...😰 It is also affected by the surrounding radio environment, your AP situation (some NICs have terrible AP performance), distance, etc. ---- ## Document ### Speed Strategy The maximum rate of esp8266 pure IO is about 2MHz. When you select max clock, we will take the following actions: - `clock < 2Mhz` : Similar to the clock speed you choose. - `2MHz <= clock < 10MHz` : Use the fastest pure IO speed. - `clock >= 10MHz` : SPI acceleration using 40MHz clock. > Note that the most significant speed constraint of this project is still the TCP connection speed. ### For OpenOCD user This project was originally designed to run on Keil, but now you can also perform firmware flash on OpenOCD. Note that if you want to use a 40MHz SPI acceleration, you need to specify the speed after the target device is connected, otherwise it will fail with the beginning. ```bash # Run before approaching the flash command > adapter speed 10000 > halt > flash write_image [erase] [unlock] filename [offset] [type] ``` > Keil's timing handling is somewhat different from OpenOCD's. For example, OpenOCD lacks the SWD line reset sequence before reading the `IDCODE` registers. ### System OTA When this project is updated, you can update the firmware over the air. Visit the following website for OTA operations: [online OTA](http://corsacota.surge.sh/?address=dap.local:3241) For most devices, you don't need to care about flash size. However, improper setting of the flash size may cause the OTA to fail. In this case, please change the flash size with `idf.py menuconfig`, or modify `sdkconfig`: ``` # Choose a flash size. CONFIG_ESPTOOLPY_FLASHSIZE_1MB=y CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y # Then set a flash size CONFIG_ESPTOOLPY_FLASHSIZE="2MB" ``` If flash size is 2MB, the sdkconfig file might look like this: ``` CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y CONFIG_ESPTOOLPY_FLASHSIZE="2MB" ``` For devices with 1MB flash size such as ESP8285, the following changes must be made: ``` CONFIG_PARTITION_TABLE_FILENAME="partitions_two_ota.1MB.csv" CONFIG_ESPTOOLPY_FLASHSIZE_1MB=y CONFIG_ESPTOOLPY_FLASHSIZE="1MB" CONFIG_ESP8266_BOOT_COPY_APP=y ``` The flash size of the board can be checked with the esptool.py tool: ```bash esptool.py -p (PORT) flash_id ``` ### Uart TCP Bridge This feature provides a bridge between TCP and Uart: ``` Send data -> TCP -> Uart TX -> external devices Recv data <- TCP <- Uart Rx <- external devices ``` ![uart_tcp_bridge](https://user-images.githubusercontent.com/17078589/150290065-05173965-8849-4452-ab7e-ec7649f46620.jpg) When the TCP connection is established, bridge will try to resolve the text sent for the first packet. When the text is a valid baud rate, bridge will switch to it. For example, sending the ASCII text `115200` will switch the baud rate to 115200. For performance reasons, this feature is not enabled by default. You can modify [wifi_configuration.h](main/wifi_configuration.h) to turn it on. ---- ## Develop Check other branches to know the latest development progress. Any kind of contribute is welcome, including but not limited to new features, ideas about circuits, documentation. You can also ask questions to make this project better. - [Issues · wu-donghuan/wireless-esp32-dap - Gitee.com](https://gitee.com/wu-donghuan/wireless-esp32-dap/issues) - [Pull Requests · wu-donghuan/wireless-esp32-dap - Gitee.com](https://gitee.com/wu-donghuan/wireless-esp32-dap/pulls) ### Issue 2020.12.1 TCP transmission speed needs to be further improved. 2020.11.11 Winusb is now available, but it is very slow. 2020.2.4 Due to the limitation of USB-HID (I'm not sure if this is a problem with USBIP or Windows), now each URB packet can only reach 255 bytes (About 1MBps bandwidth), which has not reached the upper limit of ESP8266 transmission bandwidth. I now have an idea to construct a Man-in-the-middle between the two to forward traffic, thereby increasing the bandwidth of each transmission. 2020.1.31 At present, the adaptation to WCID, WinUSB, etc. has all been completed. However, when transmitting data on the endpoint, we received an error message from USBIP. This is most likely a problem with the USBIP project itself. Due to the completeness of the USBIP protocol document, we have not yet understood its role in the Bulk transmission process, which may also lead to errors in subsequent processes. We will continue to try to make it work on USB HID. Once the USBIP problem is solved, we will immediately transfer it to work on WinUSB ------ ## Credit Credits to the following project, people and organizations: > - https://github.com/thevoidnn/esp8266-wifi-cmsis-dap for adapter firmware based on CMSIS-DAP v1.0 > - https://github.com/ARM-software/CMSIS_5 for CMSIS > - https://github.com/cezanne/usbip-win for usbip windows - [@HeavenSpree](https://www.github.com/HeavenSpree) - [@Zy19930907](https://www.github.com/Zy19930907) - [@caiguang1997](https://www.github.com/caiguang1997) - [@ZhuYanzhen1](https://www.github.com/ZhuYanzhen1) ## License [MIT LICENSE](LICENSE)

简介

基于ESP32C3的DAP无线调试器,在一些需要无线的调试场景下,可以很好解决,支持TCP传输串口信息。 展开 收起
C
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/snail0815/wireless-esp32-dap.git
git@gitee.com:snail0815/wireless-esp32-dap.git
snail0815
wireless-esp32-dap
wireless-esp32-dap
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891