Skip to content

Commit

Permalink
Merge branch 'release/v0.1.1-alpha'
Browse files Browse the repository at this point in the history
  • Loading branch information
windowsair committed Nov 12, 2020
2 parents f45e017 + bed6adc commit 87a6a1d
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 80 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
language: c
sudo: required
before_install:
- sudo apt install -y gcc git wget make libncurses-dev flex bison python python-serial
- sudo apt update
- sudo apt install -y gcc git wget make libncurses-dev flex bison python python-serial ninja-build
- wget https://dl.espressif.com/dl/xtensa-lx106-elf-linux64-1.22.0-100-ge567ec7-5.2.0.tar.gz

install:
- tar -xzf ./xtensa-lx106-elf-linux64-1.22.0-100-ge567ec7-5.2.0.tar.gz
- git clone --recursive https://github.com/espressif/ESP8266_RTOS_SDK.git
- wget https://github.com/espressif/ESP8266_RTOS_SDK/releases/download/v3.3-rc1/ESP8266_RTOS_SDK-v3.3-rc1.zip
- unzip ESP8266_RTOS_SDK-v3.3-rc1.zip
- python -m pip install --user -r ./ESP8266_RTOS_SDK/requirements.txt

before_script:
Expand Down
57 changes: 43 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,35 @@ Realized by USBIP and CMSIS-DAP protocol stack.
## Feature

1. Debug Communication Mode
- [x] SWJ
- [x] SWD
- [x] JTAG

2. USB Communication Mode
- [x] USB-HID
- [ ] WCID & WinUSB
- [x] USB-HID (Default)
- [x] WCID & WinUSB (Experimental)

3. Debug Trace
- [ ] UART Serial Wire Output(SWO)
- [ ] SWO Streaming Trace

4. More..
- [x] Custom maximum debug clock(more than 10MHz)
- [x] Custom maximum debug clock ~~(more than 10MHz)~~ (experimental)
- [ ] ...



## Link your board

1. WIFI
### WIFI

The default connected WIFI SSID is `DAP` , password `12345678`

You can change `WIFI_SSID` and ` WIFI_PASS` in [wifi_configuration.h](main/wifi_configuration.h)

2. Debugger
### Debugger



- SWD

| SWD | |
|----------------|--------|
Expand All @@ -58,7 +59,9 @@ You can change `WIFI_SSID` and ` WIFI_PASS` in [wifi_configuration.h](main/wifi_
| TVCC | 3V3 |
| GND | GND |

- JTAG

--------------


| JTAG | |
|--------------------|---------|
Expand All @@ -81,12 +84,13 @@ You can modify these pin definitions in [DAP_config.h](components/DAP/config/DAP

1. Get ESP8266 RTOS Software Development Kit

See: [ESP8266_RTOS_SDK](https://github.com/espressif/ESP8266_RTOS_SDK "ESP8266_RTOS_SDK")
For now, use the 3.3-rc1 version of the SDK (this is a known issue)
See: [ESP8266_RTOS_SDK](https://github.com/espressif/ESP8266_RTOS_SDK/releases/tag/v3.3-rc1 "ESP8266_RTOS_SDK")

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")
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 on Windows:

Expand All @@ -104,29 +108,49 @@ python ./idf.py -p /dev/ttyS5 flash

1. Get USBIP project

- Windows: [usbip-windows](https://github.com/george-hopkins/usbip-windows "usbip-windows") . Or you can find it already built here: https://github.com/barbalion/usbip-win-client
- Windows: [usbip-win](https://github.com/cezanne/usbip-win) .
> The pre-compiled version on SourceForge is also available, for HID mode only, but it may be faster.
- Linux: Distributed as part of the kernel

2. Start esp8266 and connect it to the device to be debugged

3. Connect it with usbip:

```bash
# HID Mode
# for pre-compiled version on SourceForge
# or usbip old version
.\usbip.exe -D -a <your-esp8266-ip-address> 1-1

# HID Mode Or WinUSB Mode
# for usbip-win 0.3.0 kmdf ude
.\usbip.exe attach-ude -r <your-esp8266-ip-address> -b 1-1

```

If all goes well, you should see your device connected.

![image](https://user-images.githubusercontent.com/17078589/73833411-eb3f6d80-4844-11ea-8501-02a008f6119d.png)


Then test it under MDK:

![target](https://user-images.githubusercontent.com/17078589/73830040-eb3c6f00-483e-11ea-85ee-c40b68a836b2.png)



## Develop

1. Use WinUSB Mode:

change `USE_WINUSB` macor in [USBd_config.h](components/USBIP/USBd_config.h)



> Credits to:
> - 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

In this repo you can find the complete implementation of the USB protocol stack including USB-HID, WCID, WinUSB. Although WinUSB-based mode currently does not work on USBIP :disappointed_relieved: . They are very easy and can help you quickly build your own DAP on other hardware platforms.
Expand All @@ -139,13 +163,18 @@ Currently using USB-HID for transmission is still slightly slower, If you have a

### Issue

2-4
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.

1-31
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.

Expand Down
2 changes: 1 addition & 1 deletion components/USBIP/MSOS20Descriptors.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const uint8_t bosDescriptor[kLengthOfBos] =
0x05, // bLength of this descriptor
USB_DESCRIPTOR_TYPE_BOS, // BOS Descriptor type(Constant)
USBShort(kLengthOfBos), // wLength
0x01, // bNumDeviceCaps
0x01, // bNumDeviceCaps -> only 0x01 for OS2.0 descriptor

// Microsoft OS 2.0 platform capability descriptor header (Table 4)
// See also:
Expand Down
16 changes: 6 additions & 10 deletions components/USBIP/USB_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,9 @@
#include "usb_defs.h"
#include "MSOS20Descriptors.h"

// const char *strings_list[] = {
// 0, // reserved: available languages
// "windowsair",
// "CMSIS-DAP v2",
// "1234",
// };

const char *strings_list[] = {
0, // reserved: available languages
0, // reserved: available languages -> iInterface
"windowsair",
"esp8266 CMSIS-DAP",
"1234",
Expand Down Expand Up @@ -241,8 +235,7 @@ static void handleGetDescriptor(usbip_stage2_header *header)
else
{
os_printf("Sending ALL CONFIG\r\n");

send_stage2_submit(header, 0, header->u.cmd_submit.data_length);
send_stage2_submit(header, 0, sizeof(kUSBd0ConfigDescriptor) + sizeof(kUSBd0InterfaceDescriptor));
send(kSock, kUSBd0ConfigDescriptor, sizeof(kUSBd0ConfigDescriptor), 0);
send(kSock, kUSBd0InterfaceDescriptor, sizeof(kUSBd0InterfaceDescriptor), 0);
}
Expand Down Expand Up @@ -315,16 +308,19 @@ static void handleGetDescriptor(usbip_stage2_header *header)
////TODO:UNIMPLEMENTED
send_stage2_submit(header, 0, 0);
break;

#if (USE_WINUSB == 1)
case USB_DT_BOS:
os_printf("* GET 0x0F BOS DESCRIPTOR\r\n");
send_stage2_submit_data(header, 0, bosDescriptor, sizeof(bosDescriptor));
break;
#else
case USB_DT_HID_REPORT:
os_printf("* GET 0x22 HID REPORT DESCRIPTOR\r\n");
send_stage2_submit_data(header, 0, (void *)kHidReportDescriptor, sizeof(kHidReportDescriptor));
break;
#endif
default:
//// TODO: ms os 1.0 descriptor
os_printf("USB unknown Get Descriptor requested:%d\r\n", header->u.cmd_submit.request.wValue.u8lo);
os_printf("low bit :%d\r\n",header->u.cmd_submit.request.wValue.u8lo);
os_printf("high bit :%d\r\n",header->u.cmd_submit.request.wValue.u8hi);
Expand Down
5 changes: 5 additions & 0 deletions components/USBIP/USBd_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ const uint8_t kUSBd0DeviceDescriptor[0x12] =
{
0x12, // bLength
USB_DT_DEVICE, // bDescriptorType

#if (USE_WINUSB == 1)
USBShort(0x0210), // bcdUSB
#else
USBShort(0x0200), // bcdUSB
#endif
////TODO: Is it also available elsewhere?

// We need to use a device other than the USB-IF standard, set to 0x00
Expand Down
Loading

0 comments on commit 87a6a1d

Please sign in to comment.