feat(lwip) & build: Imporve netconn code, modify the default idf tool to use the sdk under the project path
This commit is contained in:
parent
676908adae
commit
687929b43d
2
idf.py
2
idf.py
|
@ -118,7 +118,7 @@ def check_environment():
|
||||||
if not executable_exists(["cmake", "--version"]):
|
if not executable_exists(["cmake", "--version"]):
|
||||||
raise FatalError("'cmake' must be available on the PATH to use %s" % PROG)
|
raise FatalError("'cmake' must be available on the PATH to use %s" % PROG)
|
||||||
# find the directory idf.py is in, then the parent directory of this, and assume this is IDF_PATH
|
# find the directory idf.py is in, then the parent directory of this, and assume this is IDF_PATH
|
||||||
detected_idf_path = _realpath(os.path.join(os.path.dirname(__file__), ".."))
|
detected_idf_path = _realpath(os.path.join(os.path.dirname(__file__), "./ESP8266_RTOS_SDK"))
|
||||||
if "IDF_PATH" in os.environ:
|
if "IDF_PATH" in os.environ:
|
||||||
set_idf_path = _realpath(os.environ["IDF_PATH"])
|
set_idf_path = _realpath(os.environ["IDF_PATH"])
|
||||||
if set_idf_path != detected_idf_path:
|
if set_idf_path != detected_idf_path:
|
||||||
|
|
|
@ -173,13 +173,16 @@ void app_main()
|
||||||
DAP_Setup();
|
DAP_Setup();
|
||||||
timer_init();
|
timer_init();
|
||||||
|
|
||||||
|
// Specify the usbip server task
|
||||||
#if (USE_KCP == 1)
|
#if (USE_KCP == 1)
|
||||||
xTaskCreate(kcp_server_task, "kcp_server", 4096, NULL, 7, NULL);
|
xTaskCreate(kcp_server_task, "kcp_server", 4096, NULL, 7, NULL);
|
||||||
#else
|
#elif (USE_TCP_NETCONN == 1)
|
||||||
//xTaskCreate(tcp_netconn_task, "tcp_server", 4096, NULL, 14, NULL);
|
xTaskCreate(tcp_netconn_task, "tcp_server", 4096, NULL, 14, NULL);
|
||||||
|
#else // BSD style
|
||||||
xTaskCreate(tcp_server_task, "tcp_server", 4096, NULL, 14, NULL);
|
xTaskCreate(tcp_server_task, "tcp_server", 4096, NULL, 14, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// DAP handle task
|
||||||
xTaskCreate(DAP_Thread, "DAP_Task", 2048, NULL, 10, &kDAPTaskHandle);
|
xTaskCreate(DAP_Thread, "DAP_Task", 2048, NULL, 10, &kDAPTaskHandle);
|
||||||
|
|
||||||
// SWO Trace Task
|
// SWO Trace Task
|
||||||
|
|
|
@ -57,8 +57,8 @@ typedef struct
|
||||||
|
|
||||||
extern TaskHandle_t kDAPTaskHandle;
|
extern TaskHandle_t kDAPTaskHandle;
|
||||||
extern int kRestartDAPHandle;
|
extern int kRestartDAPHandle;
|
||||||
|
extern uint8_t kState;
|
||||||
|
|
||||||
uint8_t kStateNetconn = ACCEPTING;
|
|
||||||
struct netconn *kNetconn = NULL;
|
struct netconn *kNetconn = NULL;
|
||||||
|
|
||||||
int tcp_netconn_send(const void *buffer, size_t len)
|
int tcp_netconn_send(const void *buffer, size_t len)
|
||||||
|
@ -72,8 +72,8 @@ int tcp_netconn_send(const void *buffer, size_t len)
|
||||||
static void netCallback(struct netconn *conn, enum netconn_evt evt, uint16_t length)
|
static void netCallback(struct netconn *conn, enum netconn_evt evt, uint16_t length)
|
||||||
{
|
{
|
||||||
// Show some callback information (debug)
|
// Show some callback information (debug)
|
||||||
debug("sock:%u\tsta:%u\tevt:%u\tlen:%u\ttyp:%u\tfla:%02X\terr:%d",
|
debug("sock:%u\tsta:%u\tevt:%u\tlen:%u\ttyp:%u\tfla:%02x\terr:%d",
|
||||||
(uint32_t)conn, conn->state, evt, length, conn->type, conn->flags, conn->last_err);
|
(uint32_t)conn, conn->state, evt, length, conn->type, conn->flags, conn->pending_err);
|
||||||
|
|
||||||
netconn_events events;
|
netconn_events events;
|
||||||
|
|
||||||
|
@ -173,14 +173,14 @@ void tcp_netconn_task()
|
||||||
{
|
{
|
||||||
netbuf_data(netbuf, (void *)&buffer, &len_buf);
|
netbuf_data(netbuf, (void *)&buffer, &len_buf);
|
||||||
kNetconn = events.nc;
|
kNetconn = events.nc;
|
||||||
switch (kStateNetconn)
|
switch (kState)
|
||||||
{
|
{
|
||||||
case ACCEPTING:
|
case ACCEPTING:
|
||||||
kStateNetconn = ATTACHING;
|
kState = ATTACHING;
|
||||||
|
|
||||||
case ATTACHING:
|
case ATTACHING:
|
||||||
attach((uint8_t *)buffer, len_buf);
|
attach((uint8_t *)buffer, len_buf);
|
||||||
kStateNetconn = EMULATING; // FIXME
|
kState = EMULATING;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EMULATING:
|
case EMULATING:
|
||||||
|
@ -194,8 +194,18 @@ void tcp_netconn_task()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (events.nc->pending_err == ERR_CLSD)
|
||||||
|
{
|
||||||
|
continue; // The same hacky way to treat a closed connection
|
||||||
|
}
|
||||||
|
os_printf("Shutting down socket and restarting...\r\n");
|
||||||
close_tcp_netconn(events.nc);
|
close_tcp_netconn(events.nc);
|
||||||
printf("Error read netconn %u, close it \n", (uint32_t)events.nc);
|
if (kState == EMULATING)
|
||||||
|
kState = ACCEPTING;
|
||||||
|
// Restart DAP Handle
|
||||||
|
kRestartDAPHandle = 1;
|
||||||
|
if (kDAPTaskHandle)
|
||||||
|
xTaskNotifyGive(kDAPTaskHandle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,5 +4,6 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
int tcp_netconn_send(const void *buffer, size_t len);
|
int tcp_netconn_send(const void *buffer, size_t len);
|
||||||
|
void tcp_netconn_task();
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "main/usbip_server.h"
|
#include "main/usbip_server.h"
|
||||||
#include "main/kcp_server.h"
|
#include "main/kcp_server.h"
|
||||||
|
#include "main/tcp_netconn.h"
|
||||||
#include "main/DAP_handle.h"
|
#include "main/DAP_handle.h"
|
||||||
#include "main/wifi_configuration.h"
|
#include "main/wifi_configuration.h"
|
||||||
|
|
||||||
|
@ -37,8 +38,9 @@ static void send_stage2_unlink(usbip_stage2_header *req_header);
|
||||||
int usbip_network_send(int s, const void *dataptr, size_t size, int flags) {
|
int usbip_network_send(int s, const void *dataptr, size_t size, int flags) {
|
||||||
#if (USE_KCP == 1)
|
#if (USE_KCP == 1)
|
||||||
return kcp_network_send(dataptr, size);
|
return kcp_network_send(dataptr, size);
|
||||||
#else
|
#elif (USE_TCP_NETCONN == 1)
|
||||||
//return tcp_netconn_send(dataptr, size);
|
return tcp_netconn_send(dataptr, size);
|
||||||
|
#else // BSD style
|
||||||
return send(s, dataptr, size, flags);
|
return send(s, dataptr, size, flags);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +19,23 @@
|
||||||
#define DAP_IP_ADDRESS 192, 168, 137, 123
|
#define DAP_IP_ADDRESS 192, 168, 137, 123
|
||||||
#define DAP_IP_GATEWAY 192, 168, 137, 1
|
#define DAP_IP_GATEWAY 192, 168, 137, 1
|
||||||
#define DAP_IP_NETMASK 255, 255, 255, 0
|
#define DAP_IP_NETMASK 255, 255, 255, 0
|
||||||
|
//
|
||||||
|
|
||||||
|
#define USE_TCP_NETCONN 0
|
||||||
|
|
||||||
// DO NOT CHANGE
|
// DO NOT CHANGE
|
||||||
#define PORT 3240
|
#define PORT 3240
|
||||||
#define CONFIG_EXAMPLE_IPV4 1
|
#define CONFIG_EXAMPLE_IPV4 1
|
||||||
#define USE_KCP 0
|
#define USE_KCP 0
|
||||||
#define MTU_SIZE 1500
|
#define MTU_SIZE 1500
|
||||||
|
//
|
||||||
|
|
||||||
|
#if (USE_TCP_NETCONN == 1 && USE_KCP == 1)
|
||||||
|
#error Can not use KCP and TCP at the same time!
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (USE_KCP == 1)
|
||||||
|
#warning KCP is a very experimental feature, and it should not be used under any circumstances. Please make sure what you are doing. Related usbip version: https://github.com/windowsair/usbip-win
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue