0
0
Fork 0

fix: Fix some simple bugs (spelling errors, etc.)

This commit is contained in:
windowsair 2020-01-27 10:42:21 +08:00
parent 822aa0b6ad
commit 50079136ab
13 changed files with 75 additions and 40 deletions

View File

@ -1,4 +1,5 @@
set(COMPONENT_ADD_INCLUDEDIRS "config include") set(COMPONENT_ADD_INCLUDEDIRS "config include $ENV{IDF_PATH}/components/esp8266/include/esp8266/")
set(COMPONENT_SRCS "./source/DAP.c ./source/DAP_vendor.c ./source/JTAG_DP.c ./source/SW_DP.c ./source/SWO.c") set(COMPONENT_SRCS "./source/DAP.c ./source/DAP_vendor.c ./source/JTAG_DP.c ./source/SW_DP.c ")
# ./source/SWO.c
register_component() register_component()

View File

@ -28,10 +28,16 @@
#ifndef __DAP_CONFIG_H__ #ifndef __DAP_CONFIG_H__
#define __DAP_CONFIG_H__ #define __DAP_CONFIG_H__
#include <stdint.h>
#include "cmsis_compiler.h"
#include "gpio.h" #include "gpio.h"
#include "gpio_struct.h" #include "gpio_struct.h"
#include "timer_struct.h" #include "timer_struct.h"
//************************************************************************************************** //**************************************************************************************************
/** /**
\defgroup DAP_Config_Debug_gr CMSIS-DAP Debug Unit Information \defgroup DAP_Config_Debug_gr CMSIS-DAP Debug Unit Information
@ -454,7 +460,7 @@ __STATIC_FORCEINLINE void PIN_TDI_OUT(uint32_t bit)
*/ */
__STATIC_FORCEINLINE uint32_t PIN_TDO_IN(void) __STATIC_FORCEINLINE uint32_t PIN_TDO_IN(void)
{ {
return ((GPIO.in >> PIN_TDO_IN) & 0x1); return ((GPIO.in >> PIN_TDI) & 0x1);
} }
// nTRST Pin I/O ------------------------------------------- // nTRST Pin I/O -------------------------------------------
@ -609,8 +615,8 @@ default, the DWT timer is used. The frequency of this timer is configured with
*/ */
__STATIC_INLINE uint32_t TIMESTAMP_GET(void) __STATIC_INLINE uint32_t TIMESTAMP_GET(void)
{ {
// FRC1 is a 24-bit countdown timer // FRC1 is a 23-bit countdown timer
return (0x1000000U - 1U - (frc1.count.data)); return (0x7FFFFF - (frc1.count.data));
} }
///@} ///@}

View File

@ -284,7 +284,10 @@ extern void DAP_Setup (void);
#ifndef DELAY_SLOW_CYCLES #ifndef DELAY_SLOW_CYCLES
#define DELAY_SLOW_CYCLES 3U // Number of cycles for one iteration #define DELAY_SLOW_CYCLES 3U // Number of cycles for one iteration
#endif #endif
#if defined(__CC_ARM)
#define USE_ASSEMBLY 0
#if USE_ASSEMBLY == 0
__STATIC_FORCEINLINE void PIN_DELAY_SLOW (uint32_t delay) { __STATIC_FORCEINLINE void PIN_DELAY_SLOW (uint32_t delay) {
uint32_t count = delay; uint32_t count = delay;
while (--count); while (--count);

View File

@ -0,0 +1,15 @@
#ifndef __CMSIS_COMPILER_H__
#define __CMSIS_COMPILER_H__
#ifndef __STATIC_FORCEINLINE
#define __STATIC_FORCEINLINE static inline __attribute__((always_inline))
#endif
#ifndef __STATIC_INLINE
#define __STATIC_INLINE static inline __attribute__((always_inline))
#endif
#ifndef __WEAK
#define __WEAK __attribute__((weak))
#endif
#endif

View File

@ -27,12 +27,14 @@
#include "DAP_config.h" #include "DAP_config.h"
#include "DAP.h" #include "DAP.h"
/*
#if (SWO_UART != 0) #if (SWO_UART != 0)
#include "Driver_USART.h" #include "Driver_USART.h"
#endif #endif
#if (SWO_STREAM != 0) #if (SWO_STREAM != 0)
#include "cmsis_os2.h" #include "cmsis_os2.h"
#endif #endif
*/
#if (SWO_STREAM != 0) #if (SWO_STREAM != 0)
#ifdef DAP_FW_V1 #ifdef DAP_FW_V1

View File

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

View File

@ -8,6 +8,7 @@
* *
*/ */
#include <stdint.h> #include <stdint.h>
#include <string.h>
#include "lwip/err.h" #include "lwip/err.h"
#include "lwip/sockets.h" #include "lwip/sockets.h"
#include "lwip/sys.h" #include "lwip/sys.h"
@ -22,7 +23,7 @@
static void handleGetDescriptor(usbip_stage2_header *header); static void handleGetDescriptor(usbip_stage2_header *header);
////TODO: may be ok ////TODO: may be ok
int handleUSBControlRequest(usbip_stage2_header *header) void handleUSBControlRequest(usbip_stage2_header *header)
{ {
// Table 9-3. Standard Device Requests // Table 9-3. Standard Device Requests
@ -156,6 +157,7 @@ int handleUSBControlRequest(usbip_stage2_header *header)
} }
break; break;
case 0xC0: // Microsoft OS 2.0 vendor-specific descriptor case 0xC0: // Microsoft OS 2.0 vendor-specific descriptor
{
uint16_t *wIndex = (uint16_t *)(&(header->u.cmd_submit.request.wIndex)); uint16_t *wIndex = (uint16_t *)(&(header->u.cmd_submit.request.wIndex));
switch (*wIndex) switch (*wIndex)
{ {
@ -174,6 +176,7 @@ int handleUSBControlRequest(usbip_stage2_header *header)
header->u.cmd_submit.request.bmRequestType, header->u.cmd_submit.request.bRequest, *wIndex); header->u.cmd_submit.request.bmRequestType, header->u.cmd_submit.request.bRequest, *wIndex);
break; break;
} }
}
break; break;
default: default:
os_printf("USB unknown request, bmRequestType:%d,bRequest:%d\r\n", os_printf("USB unknown request, bmRequestType:%d,bRequest:%d\r\n",
@ -182,7 +185,6 @@ int handleUSBControlRequest(usbip_stage2_header *header)
} }
} }
static void handleGetDescriptor(usbip_stage2_header *header) static void handleGetDescriptor(usbip_stage2_header *header)
{ {
// 9.4.3 Get Descriptor // 9.4.3 Get Descriptor

View File

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

View File

@ -74,13 +74,13 @@ typedef struct
#define USB_REQ_TYPE_STANDARD 0x00 #define USB_REQ_TYPE_STANDARD 0x00
#define USB_REQ_TYPE_CLASS 0x20 #define USB_REQ_TYPE_CLASS 0x20
#define USB_REQ_TYPE_VENDOR 0x40 #define USB_REQ_TYPE_VENDOR 0x40
#define USB_REQ_TYPE_RESERVED 0x60 //#define USB_REQ_TYPE_RESERVED 0x60
/* bits 4..0 : Recipient */ /* bits 4..0 : Recipient */
#define USB_REQ_TYPE_DEVICE 0x00 #define USB_REQ_TYPE_DEVICE 0x00
#define USB_REQ_TYPE_INTERFACE 0x01 #define USB_REQ_TYPE_INTERFACE 0x01
#define USB_REQ_TYPE_ENDPOINT 0x02 #define USB_REQ_TYPE_ENDPOINT 0x02
#define USB_REQ_TYPE_OTHER 0x03 #define USB_REQ_TYPE_OTHER 0x03
#define USB_REQ_TYPE_RESERVED 0x1F //#define USB_REQ_TYPE_RESERVED 0x1F
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
@ -223,7 +223,7 @@ typedef struct
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
/* USB Standard Endpoint Descriptor - Table 9-13 */ /* USB Standard Endpoint Descriptor - Table 9-13 */
typedef struct usb_endpoint_descriptor typedef struct
{ {
uint8_t bLength; uint8_t bLength;
uint8_t bDescriptorType; uint8_t bDescriptorType;
@ -231,7 +231,7 @@ typedef struct usb_endpoint_descriptor
uint8_t bmAttributes; uint8_t bmAttributes;
uint16_t wMaxPacketSize; uint16_t wMaxPacketSize;
uint8_t bInterval; uint8_t bInterval;
} __attribute__((packed)); } __attribute__((packed))usb_endpoint_descriptor;
#define USB_DT_ENDPOINT_SIZE sizeof(usb_endpoint_descriptor) #define USB_DT_ENDPOINT_SIZE sizeof(usb_endpoint_descriptor)
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////

View File

@ -29,11 +29,11 @@
#include "wifi_configuration.h" #include "wifi_configuration.h"
#include "usbip_server.h" #include "usbip_server.h"
uint8_t state = ACCEPTING; uint8_t kState = ACCEPTING;
int kSock = -1; int kSock = -1;
void tcp_server_task(void *pvParameters) void tcp_server_task(void *pvParameters)
{ {
char rx_buffer[2048]; uint8_t rx_buffer[2048];
char addr_str[128]; char addr_str[128];
int addr_family; int addr_family;
int ip_protocol; int ip_protocol;
@ -132,10 +132,10 @@ void tcp_server_task(void *pvParameters)
rx_buffer[len] = 0; // Null-terminate whatever we received and treat like a string rx_buffer[len] = 0; // Null-terminate whatever we received and treat like a string
//os_printf("Received %d bytes from %s:\r\n", len, addr_str); //os_printf("Received %d bytes from %s:\r\n", len, addr_str);
// os_printf("%s", rx_buffer); // os_printf("%s", rx_buffer);
switch (state) switch (kState)
{ {
case ACCEPTING: case ACCEPTING:
state = ATTACHING; kState = ATTACHING;
break; break;
case ATTACHING: case ATTACHING:
@ -155,7 +155,7 @@ void tcp_server_task(void *pvParameters)
// } // }
} }
} }
state = ACCEPTING; kState = ACCEPTING;
if (kSock != -1) if (kSock != -1)
{ {
os_printf("Shutting down socket and restarting...\r\n"); os_printf("Shutting down socket and restarting...\r\n");

View File

@ -22,7 +22,7 @@ void timer_create_task()
frc1.ctrl.div = TIMER_CLKDIV_16; // 80MHz / 16 = 5MHz frc1.ctrl.div = TIMER_CLKDIV_16; // 80MHz / 16 = 5MHz
frc1.ctrl.intr_type = TIMER_EDGE_INT; frc1.ctrl.intr_type = TIMER_EDGE_INT;
frc1.ctrl.reload = 0x01; frc1.ctrl.reload = 0x01;
frc1.load.data = 0x1000000U - 1U; frc1.load.data = 0x7FFFFF; // 23bit??
frc1.ctrl.en = 0x01; frc1.ctrl.en = 0x01;
vPortExitCritical(); vPortExitCritical();
vTaskDelete(NULL); vTaskDelete(NULL);

View File

@ -1,4 +1,5 @@
#include <stdint.h> #include <stdint.h>
#include <string.h>
#include "lwip/err.h" #include "lwip/err.h"
#include "lwip/sockets.h" #include "lwip/sockets.h"
#include "lwip/sys.h" #include "lwip/sys.h"
@ -8,11 +9,13 @@
#include "usbip_defs.h" #include "usbip_defs.h"
#include "usb_defs.h" #include "usb_defs.h"
#include "USBd_config.h" #include "USBd_config.h"
#include "DAP_handle.h"
#include "USB_handle.h"
// attach helper function // attach helper function
static int read_stage1_command(uint8_t *buffer, uint32_t length); static int read_stage1_command(uint8_t *buffer, uint32_t length);
static int handle_device_list(uint8_t *buffer, uint32_t length); static void handle_device_list(uint8_t *buffer, uint32_t length);
static int handle_device_attach(uint8_t *buffer, uint32_t length); static void handle_device_attach(uint8_t *buffer, uint32_t length);
static void send_stage1_header(uint16_t command, uint32_t status); static void send_stage1_header(uint16_t command, uint32_t status);
static void send_device_list(); static void send_device_list();
static void send_device_info(); static void send_device_info();
@ -22,7 +25,7 @@ static void send_interface_info();
static void pack(void *data, int size); static void pack(void *data, int size);
static void unpack(void *data, int size); static void unpack(void *data, int size);
static int handle_submit(usbip_stage2_header *header); static int handle_submit(usbip_stage2_header *header);
static int handle_control_request(usbip_stage2_header *header); static int read_stage2_command(usbip_stage2_header *header, uint32_t length);
int attach(uint8_t *buffer, uint32_t length) int attach(uint8_t *buffer, uint32_t length)
{ {
@ -46,6 +49,7 @@ int attach(uint8_t *buffer, uint32_t length)
os_printf("attach Unknown command: %d\r\n", command); os_printf("attach Unknown command: %d\r\n", command);
break; break;
} }
return 0; ////TODO: ...
} }
static int read_stage1_command(uint8_t *buffer, uint32_t length) static int read_stage1_command(uint8_t *buffer, uint32_t length)
@ -58,21 +62,22 @@ static int read_stage1_command(uint8_t *buffer, uint32_t length)
return (ntohs(req->command) & 0xFF); // 0x80xx low bit return (ntohs(req->command) & 0xFF); // 0x80xx low bit
} }
static int handle_device_list(uint8_t *buffer, uint32_t length) static void handle_device_list(uint8_t *buffer, uint32_t length)
{ {
os_printf("Handling dev list request...\r\n"); os_printf("Handling dev list request...\r\n");
send_stage1_header(USBIP_STAGE1_CMD_DEVICE_LIST, 0); send_stage1_header(USBIP_STAGE1_CMD_DEVICE_LIST, 0);
send_device_list(); send_device_list();
} }
static int handle_device_attach(uint8_t *buffer, uint32_t length) static void handle_device_attach(uint8_t *buffer, uint32_t length)
{ {
os_printf("Handling dev attach request...\r\n"); os_printf("Handling dev attach request...\r\n");
//char bus[USBIP_BUSID_SIZE]; //char bus[USBIP_BUSID_SIZE];
if (length < sizeof(USBIP_BUSID_SIZE)) if (length < sizeof(USBIP_BUSID_SIZE))
{ {
return -1; os_printf("handle device attach failed!\r\n");
return;
} }
//client.readBytes((uint8_t *)bus, USBIP_BUSID_SIZE); //client.readBytes((uint8_t *)bus, USBIP_BUSID_SIZE);
@ -80,7 +85,7 @@ static int handle_device_attach(uint8_t *buffer, uint32_t length)
send_device_info(); send_device_info();
state = EMULATING; kState = EMULATING;
} }
static void send_stage1_header(uint16_t command, uint32_t status) static void send_stage1_header(uint16_t command, uint32_t status)
@ -194,7 +199,7 @@ int emulate(uint8_t *buffer, uint32_t length)
return 0; return 0;
} }
int read_stage2_command(usbip_stage2_header *header, uint32_t length) static int read_stage2_command(usbip_stage2_header *header, uint32_t length)
{ {
if (length < sizeof(usbip_stage2_header)) if (length < sizeof(usbip_stage2_header))
{ {
@ -220,10 +225,10 @@ static void pack(void *data, int size)
{ {
// Ignore the setup field // Ignore the setup field
int size = (size / sizeof(uint32_t)) - 2; int sz = (size / sizeof(uint32_t)) - 2;
uint32_t *ptr = (uint32_t *)data; uint32_t *ptr = (uint32_t *)data;
for (int i = 0; i < size; i++) for (int i = 0; i < sz; i++)
{ {
ptr[i] = htonl(ptr[i]); ptr[i] = htonl(ptr[i]);
@ -244,10 +249,10 @@ static void unpack(void *data, int size)
{ {
// Ignore the setup field // Ignore the setup field
int size = (size / sizeof(uint32_t)) - 2; int sz = (size / sizeof(uint32_t)) - 2;
uint32_t *ptr = (uint32_t *)data; uint32_t *ptr = (uint32_t *)data;
for (int i = 0; i < size; i++) for (int i = 0; i < sz; i++)
{ {
ptr[i] = ntohl(ptr[i]); ptr[i] = ntohl(ptr[i]);
} }
@ -264,7 +269,7 @@ static int handle_submit(usbip_stage2_header *header)
{ {
// control endpoint(endpoint 0) // control endpoint(endpoint 0)
case 0x00: case 0x00:
handle_control_request(header); handleUSBControlRequest(header);
break; break;
// data // data
@ -294,8 +299,7 @@ static int handle_submit(usbip_stage2_header *header)
return -1; return -1;
default: default:
os_printf("*** WARN ! UNKNOWN ENDPOINT: "); os_printf("*** WARN ! UNKNOWN ENDPOINT: %d\r\n", (int)header->base.ep);
os_printf((int)header->base.ep);
return -1; return -1;
} }
return 0; return 0;
@ -316,7 +320,7 @@ void send_stage2_submit(usbip_stage2_header *req_header, int32_t status, int32_t
send(kSock, req_header, sizeof(usbip_stage2_header), 0); send(kSock, req_header, sizeof(usbip_stage2_header), 0);
} }
void send_stage2_submit_data(usbip_stage2_header *req_header, int32_t status, void *data, int32_t data_length) void send_stage2_submit_data(usbip_stage2_header *req_header, int32_t status, const void * const data, int32_t data_length)
{ {
send_stage2_submit(req_header, status, data_length); send_stage2_submit(req_header, status, data_length);

View File

@ -8,12 +8,12 @@ enum state_t
ATTACHING, ATTACHING,
EMULATING EMULATING
}; };
extern uint32_t state; extern uint8_t kState;
extern int kSock; extern int kSock;
int attach(uint8_t *buffer, uint32_t length); int attach(uint8_t *buffer, uint32_t length);
int emulate(uint8_t *buffer, uint32_t length); int emulate(uint8_t *buffer, uint32_t length);
void send_stage2_submit_data(usbip_stage2_header *req_header, int32_t status, void *data, int32_t data_length); void send_stage2_submit_data(usbip_stage2_header *req_header, int32_t status, const void * const data, int32_t data_length);
void send_stage2_submit(usbip_stage2_header *req_header, int32_t status, int32_t data_length); void send_stage2_submit(usbip_stage2_header *req_header, int32_t status, int32_t data_length);
#endif #endif