0
0
Fork 0

Merge pull request #3 from windowsair/develop

Develop
This commit is contained in:
windowsair 2021-06-07 10:36:20 +08:00 committed by GitHub
commit 856432b5f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 2196 additions and 2171 deletions

View File

@ -57,7 +57,7 @@ jobs:
tag_name: ${{ steps.tag.outputs.release_tag }}
files: |
${{ env.FIRMWARE }}/esp8266_dap_full.bin
${{ env.FIRMWARE }}/esp8266_dap.bin
${{ env.FIRMWARE }}/esp8266_dap_app.bin
${{ env.FIRMWARE }}/bootloader/bootloader.bin
${{ env.FIRMWARE }}/partition_table/partition-table.bin

View File

@ -1,9 +1,6 @@
# The following five lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
#set(COMPONENT_DIRS "${IDF_PATH}/components ${PROJECT_PATH}/components")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/main)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(esp8266_dap)

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://user-images.githubusercontent.com/17078589/107881245-7d7d5580-6f1e-11eb-9f66-6ac589e5f95c.png"/></p>
<p align="center"><img src="https://user-images.githubusercontent.com/17078589/120061980-49274280-c092-11eb-9916-4965f6c48388.png"/></p>
![image](https://user-images.githubusercontent.com/17078589/107857220-05ecef00-6e68-11eb-9fa0-506b32052dba.png)
@ -17,7 +17,7 @@ Realized by USBIP and CMSIS-DAP protocol stack.
> 👉 5m distance, 100kb size firmware(Hex) flash test:
<p align="center"><img src="https://user-images.githubusercontent.com/17078589/107896674-e5a95700-6f71-11eb-90f7-bf7362045537.gif"/></p>
<p align="center"><img src="https://user-images.githubusercontent.com/17078589/120925694-4bca0d80-c70c-11eb-91b7-ffa54770faea.gif"/></p>
## Feature
@ -51,6 +51,8 @@ You can change `WIFI_SSID` and ` WIFI_PASS` in [wifi_configuration.h](main/wifi_
You can also specify your IP in the above file (We recommend using the static address binding feature of the router).
![WIFI](https://user-images.githubusercontent.com/17078589/118365659-517e7880-b5d0-11eb-9a5b-afe43348c2ba.png)
### Debugger
@ -59,8 +61,7 @@ You can also specify your IP in the above file (We recommend using the static ad
| SWD | |
|----------------|--------|
| SWCLK | GPIO14 |
| SWDIO | GPIO12 |
| SWDIO_MOSI | GPIO13 |
| SWDIO | GPIO13 |
| LED\_CONNECTED | GPIO2 |
| LED\_RUNNING | GPIO15 |
| TVCC | 3V3 |

View File

@ -1,4 +1,4 @@
set(COMPONENT_ADD_INCLUDEDIRS "config include $ENV{IDF_PATH}/components/esp8266/include/esp8266/ $ENV{IDF_PATH}//components/esp_ringbuf/include/")
set(COMPONENT_ADD_INCLUDEDIRS "config include $ENV{IDF_PATH}/components/esp8266/include/esp8266/ $ENV{IDF_PATH}/components/esp_ringbuf/include/")
set(COMPONENT_SRCS "./source/DAP.c ./source/DAP_vendor.c ./source/JTAG_DP.c ./source/SW_DP.c ./source/SWO.c ./source/uart_modify.c ./source/spi_op.c ./source/spi_switch.c ./source/dap_utility.c")

View File

@ -44,15 +44,20 @@
#include <stdint.h>
#include <string.h>
#include "cmsis_compiler.h"
#include "main/dap_configuration.h"
#include "main/timer.h"
#include "components/DAP/include/cmsis_compiler.h"
#include "components/DAP/include/gpio_op.h"
#include "components/DAP/include/spi_switch.h"
#include "gpio.h"
#include "gpio_struct.h"
#include "timer.h"
#include "esp8266/pin_mux_register.h"
#include "gpio_op.h"
#include "spi_switch.h"
#include "dap_configuration.h"
//**************************************************************************************************
/**
\defgroup DAP_Config_Debug_gr CMSIS-DAP Debug Unit Information
@ -264,7 +269,18 @@ __STATIC_INLINE void PORT_JTAG_SETUP(void)
// set TCK, TMS pin
DAP_SPI_Deinit();
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, FUNC_GPIO14); // GPIO14 is SPI CLK pin (Clock)
GPIO.enable_w1ts |= (0x1 << 14); // PP Output
pin_reg.val = READ_PERI_REG(GPIO_PIN_REG(14));
pin_reg.pullup = 1;
WRITE_PERI_REG(GPIO_PIN_REG(14), pin_reg.val);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13); // GPIO13 is SPI MOSI pin (Master Data Out)
GPIO.enable_w1ts |= (0x1 << 13);
GPIO.pin[13].driver = 1; // OD output
pin_reg.val = READ_PERI_REG(GPIO_PIN_REG(13));
pin_reg.pullup = 0;
WRITE_PERI_REG(GPIO_PIN_REG(13), pin_reg.val);
// use RTC pin 16

View File

@ -1,7 +1,8 @@
#ifndef __GPIO_OP_H__
#define __GPIO_OP_H__
#include "cmsis_compiler.h"
#include "components/DAP/include/cmsis_compiler.h"
#include "gpio.h"
#include "gpio_struct.h"
#include "timer_struct.h"

View File

@ -27,6 +27,7 @@ extern "C" {
#include "esp_err.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"

View File

@ -26,10 +26,10 @@
*---------------------------------------------------------------------------*/
#include <string.h>
#include "DAP_config.h"
#include "DAP.h"
#include "spi_switch.h"
#include "components/DAP/config/DAP_config.h"
#include "components/DAP/include/DAP.h"
#include "components/DAP/include/spi_switch.h"
#if (DAP_PACKET_SIZE < 64U)
@ -385,10 +385,15 @@ static uint32_t DAP_SWJ_Clock(const uint8_t *request, uint8_t *response) {
// clock >= 10MHz -> use 40MHz SPI
if (clock >= 10000000) {
DAP_SPI_Init();
if (DAP_Data.debug_port != DAP_PORT_JTAG) {
DAP_SPI_Init();
SWD_TransferSpeed = kTransfer_SPI;
} else {
SWD_TransferSpeed = kTransfer_GPIO_fast;
}
DAP_Data.fast_clock = 1U;
DAP_Data.clock_delay = 1U;
SWD_TransferSpeed = kTransfer_SPI;
} else if (clock >= 2000000) {
// clock >= 2MHz -> Use GPIO with no program delay
DAP_SPI_Deinit();

View File

@ -25,8 +25,8 @@
*
*---------------------------------------------------------------------------*/
#include "DAP_config.h"
#include "DAP.h"
#include "components/DAP/config/DAP_config.h"
#include "components/DAP/include/DAP.h"
//**************************************************************************************************
/**

View File

@ -25,8 +25,8 @@
*
*---------------------------------------------------------------------------*/
#include "DAP_config.h"
#include "DAP.h"
#include "components/DAP/config/DAP_config.h"
#include "components/DAP/include/DAP.h"
// JTAG Macros

View File

@ -38,16 +38,16 @@
*
*---------------------------------------------------------------------------*/
#include "DAP_config.h"
#include "DAP.h"
#include "components/DAP/config/DAP_config.h"
#include "components/DAP/include/DAP.h"
#include "components/DAP/include/uart_modify.h"
#include "components/DAP/include/swo.h"
#include "esp_err.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "uart_modify.h"
#include "swo.h"
EventGroupHandle_t kSwoThreadEventGroup;

View File

@ -39,13 +39,14 @@
*
*/
#include <stdio.h>
#include "DAP_config.h"
#include "DAP.h"
#include "components/DAP/config/DAP_config.h"
#include "components/DAP/include/DAP.h"
#include "components/DAP/include/spi_op.h"
#include "components/DAP/include/spi_switch.h"
#include "components/DAP/include/dap_utility.h"
#include "spi_op.h"
#include "spi_switch.h"
#include "dap_utility.h"
// Debug
#define PRINT_SWD_PROTOCOL 0

View File

@ -1,4 +1,4 @@
#include "dap_utility.h"
#include "components/DAP/include/dap_utility.h"
const uint8_t kParityByteTable[256] =
{

View File

@ -14,10 +14,13 @@
#include <stdio.h>
#include <stdbool.h>
#include "main/dap_configuration.h"
#include "components/DAP/include/cmsis_compiler.h"
#include "components/DAP/include/spi_op.h"
#include "esp8266/spi_struct.h"
#include "cmsis_compiler.h"
#include "spi_op.h"
#include "dap_configuration.h"
#define DAP_SPI SPI1

View File

@ -12,14 +12,13 @@
*/
#include <stdbool.h>
#include "components/DAP/include/cmsis_compiler.h"
#include "components/DAP/include/spi_switch.h"
#include "esp8266/spi_struct.h"
#include "esp8266/pin_mux_register.h"
#include "esp8266/gpio_struct.h"
#include "cmsis_compiler.h"
#include "spi_switch.h"
#include "dap_configuration.h"
#define DAP_SPI SPI1

View File

@ -19,6 +19,11 @@
#include <stdlib.h>
#include <string.h>
#include "components/DAP/config/DAP_config.h"
#include "components/DAP/include/uart_modify.h"
#include "components/DAP/include/swo.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
@ -26,12 +31,9 @@
#include "freertos/ringbuf.h"
#include "freertos/event_groups.h"
#include "esp_err.h"
#include "esp_log.h"
#include "esp_attr.h"
// SWO modify
#include "DAP_config.h"
#include "esp8266/uart_struct.h"
#include "esp8266/uart_register.h"
#include "esp8266/pin_mux_register.h"
@ -39,9 +41,6 @@
#include "esp8266/rom_functions.h"
#include "rom/ets_sys.h"
#include "uart_modify.h"
#include "swo.h"
#include "driver/uart_select.h"
#define portYIELD_FROM_ISR() taskYIELD()

View File

@ -1,4 +1,4 @@
set(COMPONENT_ADD_INCLUDEDIRS ". ../../main")
set(COMPONENT_SRCS "MSOS20Descriptors.c USB_handle.c USBd_config.c")
set(COMPONENT_SRCS "MSOS20_descriptor.c usb_handle.c usb_descriptor.c")
register_component()

View File

@ -1,5 +1,5 @@
/**
* @file MSOS20Descriptors.c
* @file MSOS20_descriptor.c
* @author windowsair
* @brief Store related data of Microsoft OS 2.0 descriptor
* @change: 2021-5-12 Add support for USB 3.0
@ -13,7 +13,8 @@
////TODO: refactoring into structure
#include <stdint.h>
#include "MSOS20Descriptors.h"
#include "components/USBIP/MSOS20_descriptor.h"
#define USBShort(ui16Value) ((ui16Value) & 0xff), ((ui16Value) >> 8) //((ui16Value) & 0xFF),(((ui16Value) >> 8) & 0xFF)

View File

@ -1,5 +1,5 @@
/**
* @file MSOS20Descriptors.h
* @file MSOS20_descriptor.h
* @author windowsair
* @brief
* @version 0.2
@ -9,10 +9,9 @@
*
*/
#ifndef __MSOS20DESCRIPTORS_H__
#define __MSOS20DESCRIPTORS_H__
#ifndef __MSOS20_DESCRIPTOR_H__
#define __MSOS20_DESCRIPTOR_H__
#include "dap_configuration.h"
#define kLengthOfMsOS20 0xA2

View File

@ -1,6 +1,6 @@
////TODO: refactoring into structure
/**
* @file USBd_config.c
* @file usb_descriptor.c
* @brief Standard USB Descriptor Definitions
* @change: 2020-1-23 : fix bugs
* 2021-5-12 : Add support for USB 3.0
@ -11,8 +11,9 @@
*/
#include <stdint.h>
#include <stdbool.h>
#include "USBd_config.h"
#include "usb_defs.h"
#include "components/USBIP/usb_descriptor.h"
#include "components/USBIP/usb_defs.h"
#define USBShort(ui16Value) ((ui16Value) & 0xff), ((ui16Value) >> 8)

View File

@ -1,7 +1,7 @@
#ifndef __USBD_CONFIG_H__
#define __USBD_CONFIG_H__
#ifndef __USB_DESCRIPTOR_H__
#define __USB_DESCRIPTOR_H__
#include "dap_configuration.h"
#include "main/dap_configuration.h"
// Vendor ID assigned by USB-IF (idVendor).
#define USBD0_DEV_DESC_IDVENDOR 0xC251

View File

@ -9,15 +9,17 @@
*/
#include <stdint.h>
#include <string.h>
#include "main/usbip_server.h"
#include "components/USBIP/usb_handle.h"
#include "components/USBIP/usb_descriptor.h"
#include "components/USBIP/MSOS20_descriptor.h"
#include "lwip/err.h"
#include "lwip/sockets.h"
#include "lwip/sys.h"
#include <lwip/netdb.h>
#include "USB_handle.h"
#include "USBd_config.h"
#include "usbip_server.h"
#include "usb_defs.h"
#include "MSOS20Descriptors.h"
const char *strings_list[] = {

View File

@ -1,7 +1,8 @@
#ifndef __USB_HANDLE_H__
#define __USB_HANDLE_H__
#include "usbip_defs.h"
#include "components/USBIP/usbip_defs.h"
void handleUSBControlRequest(usbip_stage2_header *header);
#endif

View File

@ -20,7 +20,8 @@
#define __USBIP_DEFS_H__
#include <stdint.h>
#include "usb_defs.h"
#include "components/USBIP/usb_defs.h"
#define USBIP_SYSFS_PATH_SIZE 256
#define USBIP_BUSID_SIZE 32

View File

@ -1,4 +1,4 @@
set(COMPONENT_ADD_INCLUDEDIRS ". $ENV{IDF_PATH}/components/esp8266/include/esp8266/ ../components/USBIP")
set(COMPONENT_ADD_INCLUDEDIRS "${PROJECT_PATH}")
set(COMPONENT_SRCS "main.c timer.c tcp_server.c usbip_server.c DAP_handle.c")
register_component()

View File

@ -13,13 +13,13 @@
#include <stdint.h>
#include <string.h>
#include "usbip_server.h"
#include "DAP_handle.h"
#include "DAP.h"
#include "esp_libc.h"
#include "USBd_config.h"
#include "swo.h"
#include "dap_configuration.h"
#include "main/usbip_server.h"
#include "main/DAP_handle.h"
#include "main/dap_configuration.h"
#include "components/USBIP/usb_descriptor.h"
#include "components/DAP/include/DAP.h"
#include "components/DAP/include/swo.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"

View File

@ -1,7 +1,7 @@
#ifndef __DAP_HANDLE_H__
#define __DAP_HANDLE_H__
#include "usbip_defs.h"
#include "components/USBIP/usbip_defs.h"
void handle_dap_data_request(usbip_stage2_header *header, uint32_t length);
void handle_dap_data_response(usbip_stage2_header *header);

View File

@ -9,6 +9,11 @@
#include <string.h>
#include <stdint.h>
#include <sys/param.h>
#include "main/tcp_server.h"
#include "main/timer.h"
#include "main/wifi_configuration.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
@ -23,11 +28,6 @@
#include "lwip/sys.h"
#include <lwip/netdb.h>
#include "tcp_server.h"
#include "timer.h"
#include "wifi_configuration.h"
#include "DAP_config.h"
extern void DAP_Setup(void);
extern void DAP_Thread(void *argument);

View File

@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"

View File

@ -12,6 +12,10 @@
#include <string.h>
#include <stdint.h>
#include <sys/param.h>
#include "main/wifi_configuration.h"
#include "main/usbip_server.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
@ -26,9 +30,6 @@
#include "lwip/sys.h"
#include <lwip/netdb.h>
#include "wifi_configuration.h"
#include "usbip_server.h"
extern TaskHandle_t kDAPTaskHandle;
extern int kRestartDAPHandle;

View File

@ -12,12 +12,9 @@
#include <stdint.h>
#include <stdbool.h>
#include "timer.h"
#include "main/timer.h"
#include "hw_timer.h"
#include "timer_struct.h"
#include "cmsis_compiler.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"

View File

@ -1,17 +1,17 @@
#include <stdint.h>
#include <string.h>
#include "main/usbip_server.h"
#include "main/DAP_handle.h"
#include "components/USBIP/usb_handle.h"
#include "components/USBIP/usb_descriptor.h"
#include "lwip/err.h"
#include "lwip/sockets.h"
#include "lwip/sys.h"
#include <lwip/netdb.h>
#include "usbip_server.h"
#include "usbip_defs.h"
#include "usb_defs.h"
#include "USBd_config.h"
#include "DAP_handle.h"
#include "USB_handle.h"
#include "USBd_config.h"
// attach helper function
static int read_stage1_command(uint8_t *buffer, uint32_t length);

View File

@ -1,7 +1,9 @@
#ifndef __USBIP_SERVER_H__
#define __USBIP_SERVER_H__
#include <stdint.h>
#include "usbip_defs.h"
#include "components/USBIP/usbip_defs.h"
enum state_t
{
ACCEPTING,

View File

@ -148,12 +148,10 @@ CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE=32
CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2048
CONFIG_ESP_MAIN_TASK_STACK_SIZE=3584
CONFIG_ESP_TIMER_TASK_STACK_SIZE=2048
# CONFIG_ESP_CONSOLE_UART_DEFAULT is not set
CONFIG_ESP_CONSOLE_UART_CUSTOM=y
CONFIG_ESP_CONSOLE_UART_DEFAULT=y
# CONFIG_ESP_CONSOLE_UART_CUSTOM is not set
# CONFIG_ESP_CONSOLE_UART_NONE is not set
# CONFIG_ESP_CONSOLE_UART_CUSTOM_NUM_0 is not set
CONFIG_ESP_CONSOLE_UART_CUSTOM_NUM_1=y
CONFIG_ESP_CONSOLE_UART_NUM=1
CONFIG_ESP_CONSOLE_UART_NUM=0
CONFIG_ESP_CONSOLE_UART_BAUDRATE=74880
# CONFIG_ESP_UART0_SWAP_IO is not set
# CONFIG_ESP_TASK_WDT is not set
@ -472,12 +470,10 @@ CONFIG_STACK_CHECK_NONE=y
# CONFIG_STACK_CHECK is not set
# CONFIG_WARN_WRITE_STRINGS is not set
CONFIG_MAIN_TASK_STACK_SIZE=3584
# CONFIG_CONSOLE_UART_DEFAULT is not set
CONFIG_CONSOLE_UART_CUSTOM=y
CONFIG_CONSOLE_UART_DEFAULT=y
# CONFIG_CONSOLE_UART_CUSTOM is not set
# CONFIG_CONSOLE_UART_NONE is not set
# CONFIG_CONSOLE_UART_CUSTOM_NUM_0 is not set
CONFIG_CONSOLE_UART_CUSTOM_NUM_1=y
CONFIG_CONSOLE_UART_NUM=1
CONFIG_CONSOLE_UART_NUM=0
CONFIG_CONSOLE_UART_BAUDRATE=74880
# CONFIG_UART0_SWAP_IO is not set
# CONFIG_TASK_WDT is not set