369 lines
9.2 KiB
Markdown
369 lines
9.2 KiB
Markdown
[中文](README_CN.md)
|
|
|
|
## Introduce
|
|
|
|
Wireless debugging with ***only one ESP Chip*** !
|
|
|
|
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] ESP32
|
|
- [x] ESP32C3
|
|
- [x] ESP32S3
|
|
|
|
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] Support for [elaphure-dap.js](https://github.com/windowsair/elaphure-dap.js), online ARM Cortex-M firmware flash
|
|
- [x] Support for OpenOCD/pyOCD
|
|
- [x] ...
|
|
|
|
|
|
|
|
## Link your board
|
|
|
|
### WIFI
|
|
|
|
The default connected WIFI SSID is `无线DAP` , 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).
|
|
|
|

|
|
|
|
|
|
There is built-in ipv4 only mDNS server. You can access the device using `dap.local`.
|
|
|
|

|
|
|
|
|
|
|
|
### Debugger
|
|
|
|
|
|
|
|
<details>
|
|
<summary>ESP32</summary>
|
|
|
|
| SWD | |
|
|
|----------------|--------|
|
|
| SWCLK | GPIO14 |
|
|
| SWDIO | GPIO13 |
|
|
| TVCC | 3V3 |
|
|
| GND | GND |
|
|
|
|
|
|
--------------
|
|
|
|
|
|
| JTAG | |
|
|
|--------------------|---------|
|
|
| TCK | GPIO14 |
|
|
| TMS | GPIO13 |
|
|
| TDI | GPIO18 |
|
|
| TDO | GPIO19 |
|
|
| nTRST \(optional\) | GPIO25 |
|
|
| nRESET | GPIO26 |
|
|
| TVCC | 3V3 |
|
|
| GND | GND |
|
|
|
|
</details>
|
|
|
|
|
|
<details>
|
|
<summary>ESP32C3</summary>
|
|
|
|
| SWD | |
|
|
|----------------|--------|
|
|
| SWCLK | GPIO6 |
|
|
| SWDIO | GPIO7 |
|
|
| TVCC | 3V3 |
|
|
| GND | GND |
|
|
|
|
|
|
--------------
|
|
|
|
|
|
| JTAG | |
|
|
|--------------------|--------|
|
|
| TCK | GPIO6 |
|
|
| TMS | GPIO7 |
|
|
| TDI | GPIO5 |
|
|
| TDO | GPIO3 |
|
|
| nTRST \(optional\) | GPIO4 |
|
|
| nRESET | GPIO10 |
|
|
| TVCC | 3V3 |
|
|
| GND | GND |
|
|
|
|
|
|
</details>
|
|
|
|
|
|
<details>
|
|
<summary>ESP32S3</summary>
|
|
|
|
| SWD | |
|
|
|----------------|--------|
|
|
| SWCLK | GPIO12 |
|
|
| SWDIO | GPIO11 |
|
|
| TVCC | 3V3 |
|
|
| GND | GND |
|
|
|
|
|
|
--------------
|
|
|
|
|
|
| JTAG | |
|
|
|--------------------|--------|
|
|
| TCK | GPIO12 |
|
|
| TMS | GPIO11 |
|
|
| TDI | GPIO10 |
|
|
| TDO | GPIO9 |
|
|
| nTRST \(optional\) | GPIO14 |
|
|
| nRESET | GPIO13 |
|
|
| TVCC | 3V3 |
|
|
| GND | GND |
|
|
|
|
|
|
</details>
|
|
|
|
----
|
|
|
|
|
|
## Build And Flash
|
|
|
|
You can build locally or use Github Action to build online and then download firmware to flash.
|
|
|
|
|
|
### General build and Flash
|
|
|
|
<details>
|
|
<summary>ESP32C3</summary>
|
|
|
|
1. Get esp-idf
|
|
|
|
For now, please use esp-idf v5.2.1 : https://github.com/espressif/esp-idf/releases/tag/v5.2.1
|
|
|
|
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 esp32c3
|
|
# Build
|
|
idf.py build
|
|
# Flash
|
|
idf.py -p /dev/ttyS5 flash
|
|
```
|
|
|
|
</details>
|
|
|
|
## 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.0 kmdf ude
|
|
.\usbip.exe attach_ude -r <your-esp-device-ip-address> -b 1-1
|
|
|
|
```
|
|
|
|
If all goes well, you should see your device connected.
|
|
|
|

|
|
|
|
|
|
Here, we use MDK for testing:
|
|
|
|

|
|
|
|
|
|
------
|
|
|
|
## 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
|
|
- ...
|
|
|
|
|
|
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.
|
|
|
|
```bash
|
|
> halt
|
|
> flash write_image [erase] [unlock] filename [offset] [type]
|
|
```
|
|
|
|
> pyOCD is now supported.
|
|
|
|
### Uart TCP Bridge
|
|
|
|
TCP server on PORT 1234.
|
|
|
|
UART default baud: 74880
|
|
|
|
This feature provides a bridge between TCP and Uart:
|
|
```
|
|
Send data -> TCP -> Uart TX -> external devices
|
|
|
|
Recv data <- TCP <- Uart Rx <- external devices
|
|
```
|
|
|
|

|
|
|
|
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.
|
|
|
|
<details>
|
|
<summary>ESP32C3</summary>
|
|
|
|
| | PIN |
|
|
|-----|--------|
|
|
| RX | GPIO20 |
|
|
| TX | GPIO21 |
|
|
|
|
</details>
|
|
|
|
|
|
<details>
|
|
<summary>ESP32</summary>
|
|
|
|
| | PIN |
|
|
|-----|--------|
|
|
| RX | GPIO22 |
|
|
| TX | GPIO23 |
|
|
|
|
</details>
|
|
|
|
<details>
|
|
<summary>ESP32S3</summary>
|
|
|
|
| | PIN |
|
|
|-----|--------|
|
|
| RX | GPIO18 |
|
|
| TX | GPIO17 |
|
|
|
|
|
|
|
|
</details>
|
|
|
|
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://www.github.com/windowsair/wireless-esp8266-dap origin of this project
|
|
> - 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
|
|
|
|
- [@windowsair](https://www.github.com/windowsair/wireless-esp8266-dap)
|
|
- [@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)
|
|
|