From d414fd21d84082ec4bebd1e593cefabddbc40fe5 Mon Sep 17 00:00:00 2001 From: sakumisu <1203593632@qq.com> Date: Fri, 1 Dec 2023 20:43:13 +0800 Subject: [PATCH] add config for rndis & ecm thread --- cherryusb_config_template.h | 14 ++++++++++++++ class/cdc/usbh_cdc_ecm.c | 2 +- class/wireless/usbh_rndis.c | 8 +++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/cherryusb_config_template.h b/cherryusb_config_template.h index 891a243e..fd429fda 100644 --- a/cherryusb_config_template.h +++ b/cherryusb_config_template.h @@ -128,6 +128,20 @@ #define CONFIG_USBHOST_MSC_TIMEOUT 5000 #endif +#ifndef CONFIG_USBHOST_RNDIS_PRIO +#define CONFIG_USBHOST_RNDIS_PRIO 1 +#endif +#ifndef CONFIG_USBHOST_RNDIS_STACKSIZE +#define CONFIG_USBHOST_RNDIS_STACKSIZE 2048 +#endif + +#ifndef CONFIG_USBHOST_CDC_ECM_PRIO +#define CONFIG_USBHOST_CDC_ECM_PRIO 1 +#endif +#ifndef CONFIG_USBHOST_CDC_ECM_STACKSIZE +#define CONFIG_USBHOST_CDC_ECM_STACKSIZE 2048 +#endif + /* ================ USB Device Port Configuration ================*/ //#define USBD_IRQHandler USBD_IRQHandler diff --git a/class/cdc/usbh_cdc_ecm.c b/class/cdc/usbh_cdc_ecm.c index cc016491..28451485 100644 --- a/class/cdc/usbh_cdc_ecm.c +++ b/class/cdc/usbh_cdc_ecm.c @@ -309,7 +309,7 @@ err_t usbh_cdc_ecm_linkoutput(struct netif *netif, struct pbuf *p) void usbh_cdc_ecm_lwip_thread_init(struct netif *netif) { - usb_osal_thread_create("usbh_cdc_ecm_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_cdc_ecm_rx_thread, netif); + usb_osal_thread_create("usbh_cdc_ecm_rx", CONFIG_USBHOST_RNDIS_STACKSIZE, CONFIG_USBHOST_CDC_ECM_PRIO, usbh_cdc_ecm_rx_thread, netif); } __WEAK void usbh_cdc_ecm_run(struct usbh_cdc_ecm *cdc_ecm_class) diff --git a/class/wireless/usbh_rndis.c b/class/wireless/usbh_rndis.c index c1c308a1..bfe6b594 100644 --- a/class/wireless/usbh_rndis.c +++ b/class/wireless/usbh_rndis.c @@ -492,12 +492,18 @@ find_class: g_rndis_rx_length = 0; USB_LOG_ERR("No memory to alloc pbuf for rndis rx\r\n"); } + } else { + g_rndis_rx_length = 0; + USB_LOG_ERR("Error rndis packet message\r\n"); } } } + + // clang-format off delete: USB_LOG_INFO("Delete rndis rx thread\r\n"); usb_osal_thread_delete(NULL); + // clang-format on } err_t usbh_rndis_linkoutput(struct netif *netif, struct pbuf *p) @@ -543,7 +549,7 @@ err_t usbh_rndis_linkoutput(struct netif *netif, struct pbuf *p) void usbh_rndis_lwip_thread_init(struct netif *netif) { - usb_osal_thread_create("usbh_rndis_rx", 2560, CONFIG_USBHOST_PSC_PRIO + 1, usbh_rndis_rx_thread, netif); + usb_osal_thread_create("usbh_rndis_rx", CONFIG_USBHOST_RNDIS_STACKSIZE, CONFIG_USBHOST_RNDIS_PRIO, usbh_rndis_rx_thread, netif); } __WEAK void usbh_rndis_run(struct usbh_rndis *rndis_class)