0
0
Fork 0

Merge branch 'release/v0.1.1-alpha'

This commit is contained in:
windowsair 2020-11-12 14:40:55 +08:00
commit 87a6a1dd6e
9 changed files with 161 additions and 82 deletions

View File

@ -1,12 +1,14 @@
language: c language: c
sudo: required sudo: required
before_install: 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 - wget https://dl.espressif.com/dl/xtensa-lx106-elf-linux64-1.22.0-100-ge567ec7-5.2.0.tar.gz
install: install:
- tar -xzf ./xtensa-lx106-elf-linux64-1.22.0-100-ge567ec7-5.2.0.tar.gz - 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 - python -m pip install --user -r ./ESP8266_RTOS_SDK/requirements.txt
before_script: before_script:

View File

@ -20,34 +20,35 @@ Realized by USBIP and CMSIS-DAP protocol stack.
## Feature ## Feature
1. Debug Communication Mode 1. Debug Communication Mode
- [x] SWJ - [x] SWD
- [x] JTAG - [x] JTAG
2. USB Communication Mode 2. USB Communication Mode
- [x] USB-HID - [x] USB-HID (Default)
- [ ] WCID & WinUSB - [x] WCID & WinUSB (Experimental)
3. Debug Trace 3. Debug Trace
- [ ] UART Serial Wire Output(SWO) - [ ] UART Serial Wire Output(SWO)
- [ ] SWO Streaming Trace - [ ] SWO Streaming Trace
4. More.. 4. More..
- [x] Custom maximum debug clock(more than 10MHz) - [x] Custom maximum debug clock ~~(more than 10MHz)~~ (experimental)
- [ ] ... - [ ] ...
## Link your board ## Link your board
1. WIFI ### WIFI
The default connected WIFI SSID is `DAP` , password `12345678` 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) You can change `WIFI_SSID` and ` WIFI_PASS` in [wifi_configuration.h](main/wifi_configuration.h)
2. Debugger ### Debugger
- SWD
| SWD | | | SWD | |
|----------------|--------| |----------------|--------|
@ -58,7 +59,9 @@ You can change `WIFI_SSID` and ` WIFI_PASS` in [wifi_configuration.h](main/wifi_
| TVCC | 3V3 | | TVCC | 3V3 |
| GND | GND | | GND | GND |
- JTAG
--------------
| JTAG | | | JTAG | |
|--------------------|---------| |--------------------|---------|
@ -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 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 2. Build & Flash
Build with ESP-IDF 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") 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: The following example shows a possible way to build on Windows:
@ -104,7 +108,8 @@ python ./idf.py -p /dev/ttyS5 flash
1. Get USBIP project 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 - Linux: Distributed as part of the kernel
2. Start esp8266 and connect it to the device to be debugged 2. Start esp8266 and connect it to the device to be debugged
@ -112,21 +117,40 @@ python ./idf.py -p /dev/ttyS5 flash
3. Connect it with usbip: 3. Connect it with usbip:
```bash ```bash
# HID Mode
# for pre-compiled version on SourceForge
# or usbip old version
.\usbip.exe -D -a <your-esp8266-ip-address> 1-1 .\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. If all goes well, you should see your device connected.
![image](https://user-images.githubusercontent.com/17078589/73833411-eb3f6d80-4844-11ea-8501-02a008f6119d.png) ![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) ![target](https://user-images.githubusercontent.com/17078589/73830040-eb3c6f00-483e-11ea-85ee-c40b68a836b2.png)
## Develop ## Develop
1. Use WinUSB Mode:
change `USE_WINUSB` macor in [USBd_config.h](components/USBIP/USBd_config.h)
> Credits to: > Credits to:
> - https://github.com/thevoidnn/esp8266-wifi-cmsis-dap for adapter firmware based on CMSIS-DAP v1.0 > - 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/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. 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.
@ -139,13 +163,18 @@ Currently using USB-HID for transmission is still slightly slower, If you have a
### Issue ### 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. 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. 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. 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.

View File

@ -61,7 +61,7 @@ const uint8_t bosDescriptor[kLengthOfBos] =
0x05, // bLength of this descriptor 0x05, // bLength of this descriptor
USB_DESCRIPTOR_TYPE_BOS, // BOS Descriptor type(Constant) USB_DESCRIPTOR_TYPE_BOS, // BOS Descriptor type(Constant)
USBShort(kLengthOfBos), // wLength USBShort(kLengthOfBos), // wLength
0x01, // bNumDeviceCaps 0x01, // bNumDeviceCaps -> only 0x01 for OS2.0 descriptor
// Microsoft OS 2.0 platform capability descriptor header (Table 4) // Microsoft OS 2.0 platform capability descriptor header (Table 4)
// See also: // See also:

View File

@ -19,15 +19,9 @@
#include "usb_defs.h" #include "usb_defs.h"
#include "MSOS20Descriptors.h" #include "MSOS20Descriptors.h"
// const char *strings_list[] = {
// 0, // reserved: available languages
// "windowsair",
// "CMSIS-DAP v2",
// "1234",
// };
const char *strings_list[] = { const char *strings_list[] = {
0, // reserved: available languages 0, // reserved: available languages -> iInterface
"windowsair", "windowsair",
"esp8266 CMSIS-DAP", "esp8266 CMSIS-DAP",
"1234", "1234",
@ -241,8 +235,7 @@ static void handleGetDescriptor(usbip_stage2_header *header)
else else
{ {
os_printf("Sending ALL CONFIG\r\n"); os_printf("Sending ALL CONFIG\r\n");
send_stage2_submit(header, 0, sizeof(kUSBd0ConfigDescriptor) + sizeof(kUSBd0InterfaceDescriptor));
send_stage2_submit(header, 0, header->u.cmd_submit.data_length);
send(kSock, kUSBd0ConfigDescriptor, sizeof(kUSBd0ConfigDescriptor), 0); send(kSock, kUSBd0ConfigDescriptor, sizeof(kUSBd0ConfigDescriptor), 0);
send(kSock, kUSBd0InterfaceDescriptor, sizeof(kUSBd0InterfaceDescriptor), 0); send(kSock, kUSBd0InterfaceDescriptor, sizeof(kUSBd0InterfaceDescriptor), 0);
} }
@ -315,16 +308,19 @@ static void handleGetDescriptor(usbip_stage2_header *header)
////TODO:UNIMPLEMENTED ////TODO:UNIMPLEMENTED
send_stage2_submit(header, 0, 0); send_stage2_submit(header, 0, 0);
break; break;
#if (USE_WINUSB == 1)
case USB_DT_BOS: case USB_DT_BOS:
os_printf("* GET 0x0F BOS DESCRIPTOR\r\n"); os_printf("* GET 0x0F BOS DESCRIPTOR\r\n");
send_stage2_submit_data(header, 0, bosDescriptor, sizeof(bosDescriptor)); send_stage2_submit_data(header, 0, bosDescriptor, sizeof(bosDescriptor));
break; break;
#else
case USB_DT_HID_REPORT: case USB_DT_HID_REPORT:
os_printf("* GET 0x22 HID REPORT DESCRIPTOR\r\n"); os_printf("* GET 0x22 HID REPORT DESCRIPTOR\r\n");
send_stage2_submit_data(header, 0, (void *)kHidReportDescriptor, sizeof(kHidReportDescriptor)); send_stage2_submit_data(header, 0, (void *)kHidReportDescriptor, sizeof(kHidReportDescriptor));
break; break;
#endif
default: 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("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("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); os_printf("high bit :%d\r\n",header->u.cmd_submit.request.wValue.u8hi);

View File

@ -26,7 +26,12 @@ const uint8_t kUSBd0DeviceDescriptor[0x12] =
{ {
0x12, // bLength 0x12, // bLength
USB_DT_DEVICE, // bDescriptorType USB_DT_DEVICE, // bDescriptorType
#if (USE_WINUSB == 1)
USBShort(0x0210), // bcdUSB USBShort(0x0210), // bcdUSB
#else
USBShort(0x0200), // bcdUSB
#endif
////TODO: Is it also available elsewhere? ////TODO: Is it also available elsewhere?
// We need to use a device other than the USB-IF standard, set to 0x00 // We need to use a device other than the USB-IF standard, set to 0x00

View File

@ -1,8 +1,9 @@
/** /**
* @file DAP_handle.c * @file DAP_handle.c
* @brief Handle DAP packets and transaction push * @brief Handle DAP packets and transaction push
* @version 0.2 * @version 0.3
* @date 2020-02-04 * @date 2020-02-04 first version
* 2020-11-11 support WinUSB mode
* *
* @copyright Copyright (c) 2020 * @copyright Copyright (c) 2020
* *
@ -31,9 +32,26 @@ extern TaskHandle_t kDAPTaskHandle;
////TODO: Merge this ////TODO: Merge this
#define DAP_PACKET_SIZE 255 #define DAP_PACKET_SIZE 255
static uint8_t data_out[DAP_PACKET_SIZE]; #if (USE_WINUSB == 1)
typedef struct
{
uint32_t length;
uint8_t buf[DAP_PACKET_SIZE];
} DAPPacetDataType;
#else
typedef struct
{
uint8_t buf[DAP_PACKET_SIZE];
} DAPPacetDataType;
#endif
#define DAP_HANDLE_SIZE (sizeof(DAPPacetDataType))
static DAPPacetDataType DAPDataProcessed;
static int dap_respond = 0; static int dap_respond = 0;
// SWO Trace // SWO Trace
static int swo_trace_respond = 0; static int swo_trace_respond = 0;
static uint8_t *swo_data_to_send; static uint8_t *swo_data_to_send;
@ -52,37 +70,52 @@ void handle_dap_data_request(usbip_stage2_header *header, uint32_t length)
// Point to the beginning of the URB packet // Point to the beginning of the URB packet
#if (USE_WINUSB == 1) #if (USE_WINUSB == 1)
dap_respond = DAP_ProcessCommand((uint8_t *)data_in, (uint8_t *)data_out);
//handle_dap_data_response(header);
send_stage2_submit(header, 0, 0);
#else
xRingbufferSend(dap_dataIN_handle, data_in, length - sizeof(usbip_stage2_header), portMAX_DELAY);
//os_printf("LENGTH: %d\r\n", length - sizeof(usbip_stage2_header));
xTaskNotifyGive(kDAPTaskHandle);
send_stage2_submit(header, 0, 0); send_stage2_submit(header, 0, 0);
// always send constant size buf -> cuz we don't care about the IN packet size
// and to unify the style, we set aside the length of the section
xRingbufferSend(dap_dataIN_handle, data_in - sizeof(uint32_t), DAP_HANDLE_SIZE, portMAX_DELAY);
xTaskNotifyGive(kDAPTaskHandle);
#else
send_stage2_submit(header, 0, 0);
xRingbufferSend(dap_dataIN_handle, data_in, DAP_HANDLE_SIZE, portMAX_DELAY);
xTaskNotifyGive(kDAPTaskHandle);
#endif #endif
// dap_respond = DAP_ProcessCommand((uint8_t *)data_in, (uint8_t *)data_out);
// //handle_dap_data_response(header);
// send_stage2_submit(header, 0, 0);
} }
void handle_dap_data_response(usbip_stage2_header *header) void handle_dap_data_response(usbip_stage2_header *header)
{ {
if (dap_respond) return;
{ // int resLength = dap_respond & 0xFFFF;
send_stage2_submit_data(header, 0, data_out, DAP_PACKET_SIZE); // if (resLength)
dap_respond = 0; // {
}
else // send_stage2_submit_data(header, 0, (void *)DAPDataProcessed.buf, resLength);
{ // dap_respond = 0;
send_stage2_submit(header, 0, 0); // }
} // else
// {
// send_stage2_submit(header, 0, 0);
// }
} }
void handle_swo_trace_response(usbip_stage2_header *header) void handle_swo_trace_response(usbip_stage2_header *header)
{ {
// TODO:
send_stage2_submit(header, 0, 0);
return;
if (swo_trace_respond) if (swo_trace_respond)
{ {
swo_trace_respond = 0; swo_trace_respond = 0;
send_stage2_submit_data(header, 0, data_out, DAP_PACKET_SIZE); //send_stage2_submit_data(header, 0, (void *)DAPDataProcessed.buf, DAP_PACKET_SIZE);
} }
else else
{ {
@ -109,11 +142,12 @@ void SWO_AbortTransfer(void)
void DAP_Thread(void *argument) void DAP_Thread(void *argument)
{ {
dap_dataIN_handle = xRingbufferCreate(DAP_PACKET_SIZE * 20, RINGBUF_TYPE_BYTEBUF); dap_dataIN_handle = xRingbufferCreate(DAP_HANDLE_SIZE * 20, RINGBUF_TYPE_BYTEBUF);
dap_dataOUT_handle = xRingbufferCreate(DAP_PACKET_SIZE * 10, RINGBUF_TYPE_BYTEBUF); dap_dataOUT_handle = xRingbufferCreate(DAP_HANDLE_SIZE * 20, RINGBUF_TYPE_BYTEBUF);
data_response_mux = xSemaphoreCreateMutex(); data_response_mux = xSemaphoreCreateMutex();
size_t packetSize; size_t packetSize;
uint8_t *item; int resLength;
DAPPacetDataType *item;
if (dap_dataIN_handle == NULL || dap_dataIN_handle == NULL || if (dap_dataIN_handle == NULL || dap_dataIN_handle == NULL ||
data_response_mux == NULL) data_response_mux == NULL)
@ -128,14 +162,14 @@ void DAP_Thread(void *argument)
{ {
ulTaskNotifyTake(pdFALSE, portMAX_DELAY); ulTaskNotifyTake(pdFALSE, portMAX_DELAY);
packetSize = 0; packetSize = 0;
item = (uint8_t *)xRingbufferReceiveUpTo(dap_dataIN_handle, &packetSize, item = (DAPPacetDataType *)xRingbufferReceiveUpTo(dap_dataIN_handle, &packetSize,
(1 / portTICK_RATE_MS), DAP_PACKET_SIZE); (1 / portTICK_RATE_MS), DAP_HANDLE_SIZE);
if (packetSize == 0) if (packetSize == 0)
{ {
break; break;
} }
else if (packetSize < DAP_PACKET_SIZE) else if (packetSize < DAP_HANDLE_SIZE)
{ {
os_printf("Wrong data in packet size:%d , data in remain: %d\r\n", packetSize, (int)xRingbufferGetMaxItemSize(dap_dataIN_handle)); os_printf("Wrong data in packet size:%d , data in remain: %d\r\n", packetSize, (int)xRingbufferGetMaxItemSize(dap_dataIN_handle));
vRingbufferReturnItem(dap_dataIN_handle, (void *)item); vRingbufferReturnItem(dap_dataIN_handle, (void *)item);
@ -143,12 +177,22 @@ void DAP_Thread(void *argument)
// This may not happen because there is a semaphore acquisition // This may not happen because there is a semaphore acquisition
} }
if (item[0] == ID_DAP_QueueCommands) if (item->buf[0] == ID_DAP_QueueCommands)
item[0] = ID_DAP_ExecuteCommands; {
DAP_ProcessCommand(item, data_out); item->buf[0] = ID_DAP_ExecuteCommands;
}
resLength = DAP_ProcessCommand((uint8_t *)item->buf, (uint8_t *)DAPDataProcessed.buf); // use first 4 byte to save length
resLength &= 0xFFFF; // res length in lower 16 bits
vRingbufferReturnItem(dap_dataIN_handle, (void *)item); // process done.
// now prepare to reply
#if (USE_WINUSB == 1)
DAPDataProcessed.length = resLength;
#endif
xRingbufferSend(dap_dataOUT_handle, (void *)&DAPDataProcessed, DAP_HANDLE_SIZE, portMAX_DELAY);
vRingbufferReturnItem(dap_dataIN_handle, (void *)item);
xRingbufferSend(dap_dataOUT_handle, data_out, DAP_PACKET_SIZE, portMAX_DELAY);
if (xSemaphoreTake(data_response_mux, portMAX_DELAY) == pdTRUE) if (xSemaphoreTake(data_response_mux, portMAX_DELAY) == pdTRUE)
{ {
++dap_respond; ++dap_respond;
@ -164,19 +208,28 @@ int fast_reply(uint8_t *buf, uint32_t length)
{ {
if (dap_respond > 0) if (dap_respond > 0)
{ {
uint8_t *item; DAPPacetDataType *item;
size_t packetSize = 0; size_t packetSize = 0;
item = (uint8_t *)xRingbufferReceiveUpTo(dap_dataOUT_handle, &packetSize, item = (DAPPacetDataType *)xRingbufferReceiveUpTo(dap_dataOUT_handle, &packetSize,
(10 / portTICK_RATE_MS), DAP_PACKET_SIZE); (10 / portTICK_RATE_MS), DAP_HANDLE_SIZE);
if (packetSize == DAP_PACKET_SIZE) if (packetSize == DAP_HANDLE_SIZE)
{ {
unpack((uint32_t *)buf, sizeof(usbip_stage2_header)); unpack((uint32_t *)buf, sizeof(usbip_stage2_header));
send_stage2_submit_data((usbip_stage2_header *)buf, 0, item, DAP_PACKET_SIZE);
#if (USE_WINUSB == 1)
uint32_t resLength = item->length;
send_stage2_submit_data((usbip_stage2_header *)buf, 0, item->buf, resLength);
#else
send_stage2_submit_data((usbip_stage2_header *)buf, 0, item->buf, DAP_HANDLE_SIZE);
#endif
if (xSemaphoreTake(data_response_mux, portMAX_DELAY) == pdTRUE) if (xSemaphoreTake(data_response_mux, portMAX_DELAY) == pdTRUE)
{ {
--dap_respond; --dap_respond;
xSemaphoreGive(data_response_mux); xSemaphoreGive(data_response_mux);
} }
vRingbufferReturnItem(dap_dataOUT_handle, (void *)item); vRingbufferReturnItem(dap_dataOUT_handle, (void *)item);
return 1; return 1;
} }
@ -188,8 +241,9 @@ int fast_reply(uint8_t *buf, uint32_t length)
} }
else else
{ {
buf[3] = 0x3; // command //// TODO: ep0 dir 0 ?
buf[15] = 0; // direction buf[0x3] = 0x3; // command
buf[0xF] = 0; // direction
buf[0x16] = 0; buf[0x16] = 0;
buf[0x17] = 0; buf[0x17] = 0;
buf[27] = 0; buf[27] = 0;
@ -203,7 +257,6 @@ int fast_reply(uint8_t *buf, uint32_t length)
static void unpack(void *data, int size) static void unpack(void *data, int size)
{ {
// Ignore the setup field // Ignore the setup field
int sz = (size / sizeof(uint32_t)) - 2; int sz = (size / sizeof(uint32_t)) - 2;
uint32_t *ptr = (uint32_t *)data; uint32_t *ptr = (uint32_t *)data;

View File

@ -28,7 +28,6 @@
#include "wifi_configuration.h" #include "wifi_configuration.h"
extern void SWO_Thread(void *argument); extern void SWO_Thread(void *argument);
extern void usart_monitor_task(void *argument); extern void usart_monitor_task(void *argument);
extern void DAP_Setup(void); extern void DAP_Setup(void);
@ -63,14 +62,14 @@ static esp_err_t event_handler(void *ctx, system_event_t *event)
break; break;
case SYSTEM_EVENT_STA_GOT_IP: case SYSTEM_EVENT_STA_GOT_IP:
xEventGroupSetBits(wifi_event_group, IPV4_GOTIP_BIT); xEventGroupSetBits(wifi_event_group, IPV4_GOTIP_BIT);
os_printf("SYSTEM_EVENT_STA_GOT_IP\r\n"); os_printf("SYSTEM EVENT STA GOT IP : %s\r\n", ip4addr_ntoa(&event->event_info.got_ip.ip_info.ip));
break; break;
case SYSTEM_EVENT_STA_DISCONNECTED: case SYSTEM_EVENT_STA_DISCONNECTED:
os_printf("Disconnect reason : %d\r\n", info->disconnected.reason); os_printf("Disconnect reason : %d\r\n", info->disconnected.reason);
if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT)
{ {
/*Switch to 802.11 bgn mode */ /*Switch to 802.11 bgn mode */
esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N);
} }
esp_wifi_connect(); esp_wifi_connect();
xEventGroupClearBits(wifi_event_group, IPV4_GOTIP_BIT); xEventGroupClearBits(wifi_event_group, IPV4_GOTIP_BIT);
@ -111,7 +110,6 @@ static void initialise_wifi(void)
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config)); ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config));
ESP_ERROR_CHECK(esp_wifi_start()); ESP_ERROR_CHECK(esp_wifi_start());
} }
static void wait_for_ip() static void wait_for_ip()
@ -128,9 +126,6 @@ static void wait_for_ip()
} }
void app_main() void app_main()
{ {
ESP_ERROR_CHECK(nvs_flash_init()); ESP_ERROR_CHECK(nvs_flash_init());
@ -144,5 +139,4 @@ void app_main()
// SWO Trace Task // SWO Trace Task
//xTaskCreate(SWO_Thread, "swo_task", 1024, NULL, 6, NULL); //xTaskCreate(SWO_Thread, "swo_task", 1024, NULL, 6, NULL);
//xTaskCreate(usart_monitor_task, "uart_task", 512, NULL, 6, NULL); //xTaskCreate(usart_monitor_task, "uart_task", 512, NULL, 6, NULL);
} }

View File

@ -34,7 +34,7 @@ int kSock = -1;
void tcp_server_task(void *pvParameters) void tcp_server_task(void *pvParameters)
{ {
uint8_t tcp_rx_buffer[305]; uint8_t tcp_rx_buffer[768];
char addr_str[128]; char addr_str[128];
int addr_family; int addr_family;
int ip_protocol; int ip_protocol;

View File

@ -181,13 +181,12 @@ static void send_interface_info()
int emulate(uint8_t *buffer, uint32_t length) int emulate(uint8_t *buffer, uint32_t length)
{ {
// usbip_stage2_header header;
#if (USE_WINUSB == 0)
if(fast_reply(buffer, length)) if(fast_reply(buffer, length))
{ {
return 0; return 0;
} }
#endif
int command = read_stage2_command((usbip_stage2_header *)buffer, length); int command = read_stage2_command((usbip_stage2_header *)buffer, length);
if (command < 0) if (command < 0)
{ {
@ -281,6 +280,7 @@ static int handle_submit(usbip_stage2_header *header, uint32_t length)
{ {
// control endpoint(endpoint 0) // control endpoint(endpoint 0)
case 0x00: case 0x00:
//// TODO: judge usb setup 8 byte?
handleUSBControlRequest(header); handleUSBControlRequest(header);
break; break;