diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0eb1581..7bc2902 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,5 +3,7 @@
cmake_minimum_required(VERSION 3.5)
#set(COMPONENT_DIRS "${IDF_PATH}/components ${PROJECT_PATH}/components")
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/main)
+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(esp8266_dap)
diff --git a/README.md b/README.md
index c01e68d..943ef50 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@

Wireless ESP8266 DAP
-[](https://travis-ci.com/windowsair/wireless-esp8266-dap) master
-[](https://travis-ci.com/windowsair/wireless-esp8266-dap) develop
+[](https://github.com/windowsair/wireless-esp8266-dap/actions?query=branch%3Amaster) master
+[](https://github.com/windowsair/wireless-esp8266-dap/actions?query=branch%3Adevelop) develop
[](https://github.com/windowsair/wireless-esp8266-dap/LICENSE) [](https://github.com/windowsair/wireless-esp8266-dap/pulls) [](https://github.com/windowsair/wireless-esp8266-dap)
@@ -32,8 +32,9 @@ Realized by USBIP and CMSIS-DAP protocol stack.
- [ ] SWO Streaming Trace
4. More..
- - [x] Custom maximum debug clock ~~(more than 10MHz)~~ (experimental)
- - [ ] ...
+ - [x] Custom maximum debug clock (40MHz, SWD only)
+ - [x] SWD protocol based on SPI acceleration
+ - [x] ...
@@ -82,6 +83,14 @@ You can modify these pin definitions in [DAP_config.h](components/DAP/config/DAP
## Build
+You can build locally or use Github Action to build online
+
+### Build with Github Action Online
+
+See: [Build with Github Action](https://github.com/windowsair/wireless-esp8266-dap/wiki/Build-with-Github-Action)
+
+### General build
+
1. Get ESP8266 RTOS Software Development Kit
For now, use the 3.3-rc1 version of the SDK (this is a known issue)
@@ -117,14 +126,14 @@ python ./idf.py -p /dev/ttyS5 flash
3. Connect it with usbip:
```bash
-# HID Mode
+# HID Mode only
# for pre-compiled version on SourceForge
# or usbip old version
.\usbip.exe -D -a 1-1
# HID Mode Or WinUSB Mode
# for usbip-win 0.3.0 kmdf ude
-.\usbip.exe attach-ude -r -b 1-1
+.\usbip.exe attach_ude -r -b 1-1
```
@@ -141,6 +150,8 @@ Then test it under MDK:
## Develop
+0. Check other branches to know the latest development progress.
+
1. Use WinUSB Mode:
change `USE_WINUSB` macor in [USBd_config.h](components/USBIP/USBd_config.h)
@@ -153,16 +164,20 @@ Then test it under MDK:
> - 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.
-Currently using USB-HID for transmission is still slightly slower, If you have any ideas, welcome:
+Currently TCP transmission speed needs to be further improved, If you have any ideas, welcome:
- [New issues](https://github.com/windowsair/wireless-esp8266-dap/issues)
- [New pull](https://github.com/windowsair/wireless-esp8266-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.
diff --git a/components/DAP/config/DAP_config.h b/components/DAP/config/DAP_config.h
index f502fb6..fcf2d24 100644
--- a/components/DAP/config/DAP_config.h
+++ b/components/DAP/config/DAP_config.h
@@ -37,7 +37,7 @@
#include "esp8266/pin_mux_register.h"
#include "spi_switch.h"
-
+#include "dap_configuration.h"
//**************************************************************************************************
/**
\defgroup DAP_Config_Debug_gr CMSIS-DAP Debug Unit Information
@@ -98,18 +98,11 @@ This information includes:
#define DAP_DEFAULT_SWJ_CLOCK 1000000U ///< Default SWD/JTAG clock frequency in Hz.
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<1MHz
-/// Maximum Package Size for Command and Response data.
-/// This configuration settings is used to optimize the communication performance with the
-/// debugger and depends on the USB peripheral. Typical vales are 64 for Full-speed USB HID or WinUSB,
-/// 1024 for High-speed USB HID and 512 for High-speed USB WinUSB.
-#define DAP_PACKET_SIZE 255U ///< Specifies Packet Size in bytes.
-// <<<<<<<<<<<<<<<<<<<<<<<<<<<<< 512 for High-speed USB WinUSB.
-
/// Maximum Package Buffers for Command and Response data.
/// This configuration settings is used to optimize the communication performance with the
/// debugger and depends on the USB peripheral. For devices with limited RAM or USB buffer the
/// setting can be reduced (valid range is 1 .. 255).
-#define DAP_PACKET_COUNT 20 ///< Specifies number of packets buffered.
+#define DAP_PACKET_COUNT 255 ///< Specifies number of packets buffered.
/// Indicate that UART Serial Wire Output (SWO) trace is available.
/// This information is returned by the command \ref DAP_Info as part of Capabilities.
diff --git a/components/README.md b/components/README.md
deleted file mode 100644
index 3fc0da1..0000000
--- a/components/README.md
+++ /dev/null
@@ -1,2 +0,0 @@
-# TODO
-1. USB
\ No newline at end of file
diff --git a/components/USBIP/USB_handle.c b/components/USBIP/USB_handle.c
index 0ea27c5..e806f1e 100644
--- a/components/USBIP/USB_handle.c
+++ b/components/USBIP/USB_handle.c
@@ -272,6 +272,7 @@ static void handleGetDescriptor(usbip_stage2_header *header)
os_printf("low bit : %d\r\n", (int)header->u.cmd_submit.request.wValue.u8lo);
os_printf("high bit : %d\r\n", (int)header->u.cmd_submit.request.wValue.u8hi);
os_printf("***Unsupported String descriptor***\r\n");
+ send_stage2_submit(header, 0, 0);
}
break;
diff --git a/components/USBIP/USBd_config.h b/components/USBIP/USBd_config.h
index dc3a3e2..188b529 100644
--- a/components/USBIP/USBd_config.h
+++ b/components/USBIP/USBd_config.h
@@ -1,7 +1,7 @@
#ifndef __USBD_CONFIG_H__
#define __USBD_CONFIG_H__
-#define USE_WINUSB 0
+#include "dap_configuration.h"
// Vendor ID assigned by USB-IF (idVendor).
#define USBD0_DEV_DESC_IDVENDOR 0xC251
diff --git a/main/DAP_handle.c b/main/DAP_handle.c
index 3efb856..ff7f2cc 100644
--- a/main/DAP_handle.c
+++ b/main/DAP_handle.c
@@ -16,6 +16,7 @@
#include "DAP.h"
#include "esp_libc.h"
#include "USBd_config.h"
+#include "dap_configuration.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
@@ -32,8 +33,6 @@ extern TaskHandle_t kDAPTaskHandle;
int kRestartDAPHandle = 0;
-////TODO: Merge this
-#define DAP_PACKET_SIZE 255
#if (USE_WINUSB == 1)
typedef struct
diff --git a/main/dap_configuration.h b/main/dap_configuration.h
new file mode 100644
index 0000000..07298cf
--- /dev/null
+++ b/main/dap_configuration.h
@@ -0,0 +1,22 @@
+#ifndef __DAP_CONFIGURATION_H__
+#define __DAP_CONFIGURATION_H__
+
+/**
+ * @brief Specify the use of WINUSB
+ *
+ */
+#define USE_WINUSB 1
+
+/// Maximum Package Size for Command and Response data.
+/// This configuration settings is used to optimize the communication performance with the
+/// debugger and depends on the USB peripheral. Typical vales are 64 for Full-speed USB HID or WinUSB,
+/// 1024 for High-speed USB HID and 512 for High-speed USB WinUSB.
+
+#if (USE_WINUSB == 1)
+ #define DAP_PACKET_SIZE 512U // 512 for WinUSB.
+#else
+ #define DAP_PACKET_SIZE 255U // 255 for USB HID
+#endif
+
+
+#endif
diff --git a/main/tcp_server.c b/main/tcp_server.c
index aee67c0..8f85f6f 100644
--- a/main/tcp_server.c
+++ b/main/tcp_server.c
@@ -37,11 +37,12 @@ int kSock = -1;
void tcp_server_task(void *pvParameters)
{
- uint8_t tcp_rx_buffer[768];
+ uint8_t tcp_rx_buffer[1024];
char addr_str[128];
int addr_family;
int ip_protocol;
+ int on = 1;
while (1)
{
@@ -71,6 +72,9 @@ void tcp_server_task(void *pvParameters)
}
os_printf("Socket created\r\n");
+ setsockopt(listen_sock, SOL_SOCKET, SO_KEEPALIVE, (void *)&on, sizeof(on));
+ setsockopt(listen_sock, IPPROTO_TCP, TCP_NODELAY, (void *)&on, sizeof(on));
+
int err = bind(listen_sock, (struct sockaddr *)&destAddr, sizeof(destAddr));
if (err != 0)
{
@@ -101,6 +105,8 @@ void tcp_server_task(void *pvParameters)
os_printf("Unable to accept connection: errno %d\r\n", errno);
break;
}
+ setsockopt(kSock, SOL_SOCKET, SO_KEEPALIVE, (void *)&on, sizeof(on));
+ setsockopt(kSock, IPPROTO_TCP, TCP_NODELAY, (void *)&on, sizeof(on));
os_printf("Socket accepted\r\n");
while (1)
diff --git a/sdkconfig b/sdkconfig
index e20f324..c3b4568 100644
--- a/sdkconfig
+++ b/sdkconfig
@@ -123,8 +123,8 @@ CONFIG_TASK_WDT_PANIC=y
CONFIG_TASK_WDT_TIMEOUT_15N=y
CONFIG_TASK_WDT_TIMEOUT_S=15
CONFIG_RESET_REASON=y
-CONFIG_WIFI_PPT_TASKSTACK_SIZE=2048
-CONFIG_EVENT_LOOP_STACK_SIZE=2048
+CONFIG_WIFI_PPT_TASKSTACK_SIZE=4096
+CONFIG_EVENT_LOOP_STACK_SIZE=4096
# CONFIG_ESP8266_OTA_FROM_OLD is not set
# CONFIG_ESP8266_BOOT_COPY_APP is not set
CONFIG_ESP_ERR_TO_NAME_LOOKUP=y
@@ -135,9 +135,9 @@ CONFIG_WIFI_TX_RATE_SEQUENCE_FROM_HIGH=y
# CONFIG_ESP8266_WIFI_QOS_ENABLED is not set
# CONFIG_ESP8266_WIFI_AMPDU_RX_ENABLED is not set
# CONFIG_ESP8266_WIFI_AMSDU_ENABLED is not set
-CONFIG_ESP8266_WIFI_RX_BUFFER_NUM=26
-CONFIG_ESP8266_WIFI_LEFT_CONTINUOUS_RX_BUFFER_NUM=4
-CONFIG_ESP8266_WIFI_RX_PKT_NUM=7
+CONFIG_ESP8266_WIFI_RX_BUFFER_NUM=28
+CONFIG_ESP8266_WIFI_LEFT_CONTINUOUS_RX_BUFFER_NUM=8
+CONFIG_ESP8266_WIFI_RX_PKT_NUM=16
CONFIG_ESP8266_WIFI_TX_PKT_NUM=6
CONFIG_ESP8266_WIFI_NVS_ENABLED=y
CONFIG_ESP8266_WIFI_CONNECT_OPEN_ROUTER_WHEN_PWD_IS_SET=y
@@ -183,9 +183,8 @@ CONFIG_TCPIP_RECVMBOX_SIZE=64
CONFIG_LWIP_ARP_TABLE_SIZE=10
CONFIG_LWIP_ARP_MAXAGE=300
# CONFIG_LWIP_ESP_GRATUITOUS_ARP is not set
-CONFIG_LWIP_SOCKET_MULTITHREAD=y
+# CONFIG_LWIP_SOCKET_MULTITHREAD is not set
CONFIG_ENABLE_NONBLOCK_SPEEDUP=y
-CONFIG_SET_SOLINGER_DEFAULT=y
CONFIG_ESP_UDP_SYNC_SEND=y
CONFIG_ESP_UDP_SYNC_RETRY_MAX=5
CONFIG_LWIP_MAX_SOCKETS=10
@@ -214,13 +213,13 @@ CONFIG_ESP_DNS=y
CONFIG_DNS_MAX_SERVERS=3
# CONFIG_LWIP_NETIF_LOOPBACK is not set
CONFIG_TCP_HIGH_SPEED_RETRANSMISSION=y
-CONFIG_LWIP_MAX_ACTIVE_TCP=5
+CONFIG_LWIP_MAX_ACTIVE_TCP=16
CONFIG_LWIP_MAX_LISTENING_TCP=8
CONFIG_TCP_MAXRTX=12
CONFIG_TCP_SYNMAXRTX=6
CONFIG_TCP_MSS=1460
CONFIG_TCP_SND_BUF_DEFAULT=2920
-CONFIG_TCP_WND_DEFAULT=5840
+CONFIG_TCP_WND_DEFAULT=10240
CONFIG_TCP_RECVMBOX_SIZE=16
CONFIG_TCP_QUEUE_OOSEQ=y
CONFIG_TCP_OVERSIZE_MSS=y