summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2026-11-24 22:20:54 +0800
committersakumisu <[email protected]>2026-11-25 21:13:07 +0800
commit87276ca5efd6538c87cc70d01a484379e4ea6ad2 (patch)
tree1200c3885e93b46d2de46c0b293e952dba987edb
parent5a38fd508ba43d2e406c00cd658858bb80909c30 (diff)
update: set enum thread to the lower prio than app prio
Signed-off-by: sakumisu <[email protected]>
-rw-r--r--Kconfig.rtt2
-rw-r--r--Kconfig.rttpkg2
-rw-r--r--cherryusb_config_template.h3
-rw-r--r--demo/usb_host.c6
-rw-r--r--osal/idf/usb_config.h2
-rw-r--r--osal/usb_osal_freertos.c2
-rw-r--r--osal/usb_osal_liteos_m.c2
-rw-r--r--osal/usb_osal_nuttx.c2
-rw-r--r--osal/usb_osal_rtthread.c2
-rw-r--r--osal/usb_osal_threadx.c2
-rw-r--r--osal/usb_osal_zephyr.c2
-rw-r--r--platform/idf/usbh_fatfs.c2
-rw-r--r--platform/idf/usbh_net.c10
-rw-r--r--platform/lwip/usbh_lwip.c10
-rw-r--r--platform/nuttx/usbh_net.c2
-rw-r--r--platform/rtthread/rt_usbh_lwip.c10
-rw-r--r--platform/rtthread/rt_usbh_msc.c2
-rw-r--r--port/pusb2/freertos/usb_config.h2
-rw-r--r--port/pusb2/rt-thread/usb_config.h2
-rw-r--r--port/pusb2/standalone/usb_config.h2
-rw-r--r--port/pusb3/freertos/usb_config.h2
-rw-r--r--port/xhci/phytium/freertos/usb_config.h2
-rw-r--r--port/xhci/phytium/rt-thread/usb_config.h2
-rw-r--r--tests/bouffalolab/inc/usb_config.h2
-rw-r--r--tests/hpmicro/inc/usb_config.h2
-rw-r--r--tests/hpmicro/src/main.c36
-rw-r--r--third_party/nimble-1.6.0/README.md2
-rw-r--r--third_party/nimble-1.6.0/ble_hci_usbh.c6
-rw-r--r--third_party/zephyr_bluetooth-2.7.5/ble_hci_usbh.c6
29 files changed, 89 insertions, 40 deletions
diff --git a/Kconfig.rtt b/Kconfig.rtt
index a9ba6924..6bd4f952 100644
--- a/Kconfig.rtt
+++ b/Kconfig.rtt
@@ -479,7 +479,7 @@ if RT_USING_CHERRYUSB
config CONFIG_USBHOST_PSC_PRIO
int
prompt "Set hubport change thread priority, 0 is the max priority"
- default 0
+ default 29
config CONFIG_USBHOST_PSC_STACKSIZE
int
diff --git a/Kconfig.rttpkg b/Kconfig.rttpkg
index 1caf86ef..3aea1241 100644
--- a/Kconfig.rttpkg
+++ b/Kconfig.rttpkg
@@ -478,7 +478,7 @@ if PKG_USING_CHERRYUSB
config CONFIG_USBHOST_PSC_PRIO
int
prompt "Set hubport change thread priority, 0 is the max priority"
- default 0
+ default 29
config CONFIG_USBHOST_PSC_STACKSIZE
int
diff --git a/cherryusb_config_template.h b/cherryusb_config_template.h
index e6ed5e35..71568c5c 100644
--- a/cherryusb_config_template.h
+++ b/cherryusb_config_template.h
@@ -166,8 +166,9 @@
#define CONFIG_USBHOST_DEV_NAMELEN 16
+/* enum thread priority should be the lower than usb application priority */
#ifndef CONFIG_USBHOST_PSC_PRIO
-#define CONFIG_USBHOST_PSC_PRIO 0
+#define CONFIG_USBHOST_PSC_PRIO 29
#endif
#ifndef CONFIG_USBHOST_PSC_STACKSIZE
#define CONFIG_USBHOST_PSC_STACKSIZE 2048
diff --git a/demo/usb_host.c b/demo/usb_host.c
index 5f6e6e92..3291343f 100644
--- a/demo/usb_host.c
+++ b/demo/usb_host.c
@@ -368,7 +368,7 @@ void usbh_serial_run(struct usbh_serial *serial)
return;
}
serial_is_opened = true;
- usb_osal_thread_create("usbh_serial", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_serial_thread, serial);
+ usb_osal_thread_create("usbh_serial", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_serial_thread, serial);
}
void usbh_serial_stop(struct usbh_serial *serial)
@@ -380,7 +380,7 @@ void usbh_serial_stop(struct usbh_serial *serial)
#ifdef CONFIG_TEST_USBH_HID
void usbh_hid_run(struct usbh_hid *hid_class)
{
- usb_osal_thread_create("usbh_hid", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_hid_thread, hid_class);
+ usb_osal_thread_create("usbh_hid", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_hid_thread, hid_class);
}
void usbh_hid_stop(struct usbh_hid *hid_class)
@@ -391,7 +391,7 @@ void usbh_hid_stop(struct usbh_hid *hid_class)
#ifdef CONFIG_TEST_USBH_MSC
void usbh_msc_run(struct usbh_msc *msc_class)
{
- usb_osal_thread_create("usbh_msc", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_msc_thread, msc_class);
+ usb_osal_thread_create("usbh_msc", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_msc_thread, msc_class);
}
void usbh_msc_stop(struct usbh_msc *msc_class)
diff --git a/osal/idf/usb_config.h b/osal/idf/usb_config.h
index d08d8955..18206c60 100644
--- a/osal/idf/usb_config.h
+++ b/osal/idf/usb_config.h
@@ -167,7 +167,7 @@
#define CONFIG_USBHOST_DEV_NAMELEN 16
#ifndef CONFIG_USBHOST_PSC_PRIO
-#define CONFIG_USBHOST_PSC_PRIO 0
+#define CONFIG_USBHOST_PSC_PRIO 29
#endif
#ifndef CONFIG_USBHOST_PSC_STACKSIZE
#define CONFIG_USBHOST_PSC_STACKSIZE 4096
diff --git a/osal/usb_osal_freertos.c b/osal/usb_osal_freertos.c
index ed145291..692b0f11 100644
--- a/osal/usb_osal_freertos.c
+++ b/osal/usb_osal_freertos.c
@@ -14,6 +14,8 @@
usb_osal_thread_t usb_osal_thread_create(const char *name, uint32_t stack_size, uint32_t prio, usb_thread_entry_t entry, void *args)
{
+ USB_ASSERT_MSG((prio <= CONFIG_USBHOST_PSC_PRIO), "prio must be <= CONFIG_USBHOST_PSC_PRIO", prio, CONFIG_USBHOST_PSC_PRIO);
+
TaskHandle_t htask = NULL;
stack_size /= sizeof(StackType_t);
xTaskCreate(entry, name, stack_size, args, configMAX_PRIORITIES - 1 - prio, &htask);
diff --git a/osal/usb_osal_liteos_m.c b/osal/usb_osal_liteos_m.c
index 543af777..343a6479 100644
--- a/osal/usb_osal_liteos_m.c
+++ b/osal/usb_osal_liteos_m.c
@@ -17,6 +17,8 @@
usb_osal_thread_t usb_osal_thread_create(const char *name, uint32_t stack_size, uint32_t prio, usb_thread_entry_t entry, void *args)
{
+ USB_ASSERT_MSG((prio <= CONFIG_USBHOST_PSC_PRIO), "prio must be <= CONFIG_USBHOST_PSC_PRIO", prio, CONFIG_USBHOST_PSC_PRIO);
+
UINT32 task_id;
UINT32 ret;
diff --git a/osal/usb_osal_nuttx.c b/osal/usb_osal_nuttx.c
index e2b6c0f3..aed2d7dd 100644
--- a/osal/usb_osal_nuttx.c
+++ b/osal/usb_osal_nuttx.c
@@ -39,6 +39,8 @@ struct mq_adpt {
usb_osal_thread_t usb_osal_thread_create(const char *name, uint32_t stack_size, uint32_t prio, usb_thread_entry_t entry, void *args)
{
+ USB_ASSERT_MSG((prio <= CONFIG_USBHOST_PSC_PRIO), "prio must be <= CONFIG_USBHOST_PSC_PRIO", prio, CONFIG_USBHOST_PSC_PRIO);
+
int pid;
char *argv[2];
char arg1[32];
diff --git a/osal/usb_osal_rtthread.c b/osal/usb_osal_rtthread.c
index 593ba194..393d26be 100644
--- a/osal/usb_osal_rtthread.c
+++ b/osal/usb_osal_rtthread.c
@@ -12,6 +12,8 @@
usb_osal_thread_t usb_osal_thread_create(const char *name, uint32_t stack_size, uint32_t prio, usb_thread_entry_t entry, void *args)
{
+ USB_ASSERT_MSG((prio <= CONFIG_USBHOST_PSC_PRIO), "prio must be <= CONFIG_USBHOST_PSC_PRIO", prio, CONFIG_USBHOST_PSC_PRIO);
+
rt_thread_t htask;
htask = rt_thread_create(name, entry, args, stack_size, prio, 10);
if (htask == NULL) {
diff --git a/osal/usb_osal_threadx.c b/osal/usb_osal_threadx.c
index aa855e68..7473c048 100644
--- a/osal/usb_osal_threadx.c
+++ b/osal/usb_osal_threadx.c
@@ -15,6 +15,8 @@ usb_osal_mq_t usb_osal_mq;
usb_osal_thread_t usb_osal_thread_create(const char *name, uint32_t stack_size, uint32_t prio, usb_thread_entry_t entry, void *args)
{
+ USB_ASSERT_MSG((prio <= CONFIG_USBHOST_PSC_PRIO), "prio must be <= CONFIG_USBHOST_PSC_PRIO", prio, CONFIG_USBHOST_PSC_PRIO);
+
TX_THREAD *thread_ptr = TX_NULL;
tx_byte_allocate(&usb_byte_pool, (VOID **)&thread_ptr, USB_ALIGN_UP(sizeof(TX_THREAD), 4) + stack_size, TX_NO_WAIT);
diff --git a/osal/usb_osal_zephyr.c b/osal/usb_osal_zephyr.c
index 6b2a0fa4..a2a97d6f 100644
--- a/osal/usb_osal_zephyr.c
+++ b/osal/usb_osal_zephyr.c
@@ -22,6 +22,8 @@ struct release_thread_work {
usb_osal_thread_t usb_osal_thread_create(const char *name, uint32_t stack_size, uint32_t prio, usb_thread_entry_t entry, void *args)
{
+ USB_ASSERT_MSG((prio <= CONFIG_USBHOST_PSC_PRIO), "prio must be <= CONFIG_USBHOST_PSC_PRIO", prio, CONFIG_USBHOST_PSC_PRIO);
+
k_tid_t tid = NULL;
struct k_thread *thread = (struct k_thread *)k_aligned_alloc(8, sizeof(struct k_thread) + stack_size);
k_thread_stack_t *stack = (k_thread_stack_t *)thread;
diff --git a/platform/idf/usbh_fatfs.c b/platform/idf/usbh_fatfs.c
index ca2713ae..9af4ea06 100644
--- a/platform/idf/usbh_fatfs.c
+++ b/platform/idf/usbh_fatfs.c
@@ -297,7 +297,7 @@ static void usbh_msc_thread(CONFIG_USB_OSAL_THREAD_SET_ARGV)
void usbh_msc_run(struct usbh_msc *msc_class)
{
- usb_osal_thread_create("usbh_msc", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_msc_thread, msc_class);
+ usb_osal_thread_create("usbh_msc", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_msc_thread, msc_class);
}
void usbh_msc_stop(struct usbh_msc *msc_class)
diff --git a/platform/idf/usbh_net.c b/platform/idf/usbh_net.c
index b4febf76..cad0d902 100644
--- a/platform/idf/usbh_net.c
+++ b/platform/idf/usbh_net.c
@@ -139,7 +139,7 @@ void usbh_cdc_ecm_run(struct usbh_cdc_ecm *cdc_ecm_class)
esp_netif_action_start(esp_netif, NULL, 0, NULL);
esp_netif_action_connected(esp_netif, NULL, 0, NULL);
- usb_osal_thread_create("usbh_cdc_ecm_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_cdc_ecm_rx_thread, NULL);
+ usb_osal_thread_create("usbh_cdc_ecm_rx", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_cdc_ecm_rx_thread, NULL);
}
void usbh_cdc_ecm_stop(struct usbh_cdc_ecm *cdc_ecm_class)
@@ -217,7 +217,7 @@ void usbh_rndis_run(struct usbh_rndis *rndis_class)
esp_netif_action_start(esp_netif, NULL, 0, NULL);
esp_netif_action_connected(esp_netif, NULL, 0, NULL);
- usb_osal_thread_create("usbh_rndis_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_rndis_rx_thread, NULL);
+ usb_osal_thread_create("usbh_rndis_rx", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_rndis_rx_thread, NULL);
//timer_init(rndis_class);
}
@@ -279,7 +279,7 @@ void usbh_cdc_ncm_run(struct usbh_cdc_ncm *cdc_ncm_class)
esp_netif_action_start(esp_netif, NULL, 0, NULL);
esp_netif_action_connected(esp_netif, NULL, 0, NULL);
- usb_osal_thread_create("usbh_cdc_ncm_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_cdc_ncm_rx_thread, NULL);
+ usb_osal_thread_create("usbh_cdc_ncm_rx", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_cdc_ncm_rx_thread, NULL);
}
void usbh_cdc_ncm_stop(struct usbh_cdc_ncm *cdc_ncm_class)
@@ -336,7 +336,7 @@ void usbh_asix_run(struct usbh_asix *asix_class)
esp_netif_action_start(esp_netif, NULL, 0, NULL);
esp_netif_action_connected(esp_netif, NULL, 0, NULL);
- usb_osal_thread_create("usbh_asix_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_asix_rx_thread, NULL);
+ usb_osal_thread_create("usbh_asix_rx", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_asix_rx_thread, NULL);
}
void usbh_asix_stop(struct usbh_asix *asix_class)
@@ -393,7 +393,7 @@ void usbh_rtl8152_run(struct usbh_rtl8152 *rtl8152_class)
esp_netif_action_start(esp_netif, NULL, 0, NULL);
esp_netif_action_connected(esp_netif, NULL, 0, NULL);
- usb_osal_thread_create("usbh_rtl8152_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_rtl8152_rx_thread, NULL);
+ usb_osal_thread_create("usbh_rtl8152_rx", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_rtl8152_rx_thread, NULL);
}
void usbh_rtl8152_stop(struct usbh_rtl8152 *rtl8152_class)
diff --git a/platform/lwip/usbh_lwip.c b/platform/lwip/usbh_lwip.c
index 950bd626..2c7c0bac 100644
--- a/platform/lwip/usbh_lwip.c
+++ b/platform/lwip/usbh_lwip.c
@@ -173,7 +173,7 @@ void usbh_cdc_ecm_run(struct usbh_cdc_ecm *cdc_ecm_class)
}
}
- usb_osal_thread_create("usbh_cdc_ecm_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_cdc_ecm_rx_thread, NULL);
+ usb_osal_thread_create("usbh_cdc_ecm_rx", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_cdc_ecm_rx_thread, NULL);
#if LWIP_DHCP
dhcp_start(netif);
usb_osal_timer_start(dhcp_handle);
@@ -277,7 +277,7 @@ void usbh_rndis_run(struct usbh_rndis *rndis_class)
}
}
- usb_osal_thread_create("usbh_rndis_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_rndis_rx_thread, NULL);
+ usb_osal_thread_create("usbh_rndis_rx", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_rndis_rx_thread, NULL);
//timer_init(rndis_class);
@@ -365,7 +365,7 @@ void usbh_cdc_ncm_run(struct usbh_cdc_ncm *cdc_ncm_class)
}
}
- usb_osal_thread_create("usbh_cdc_ncm_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_cdc_ncm_rx_thread, NULL);
+ usb_osal_thread_create("usbh_cdc_ncm_rx", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_cdc_ncm_rx_thread, NULL);
#if LWIP_DHCP
dhcp_start(netif);
usb_osal_timer_start(dhcp_handle);
@@ -448,7 +448,7 @@ void usbh_asix_run(struct usbh_asix *asix_class)
}
}
- usb_osal_thread_create("usbh_asix_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_asix_rx_thread, NULL);
+ usb_osal_thread_create("usbh_asix_rx", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_asix_rx_thread, NULL);
#if LWIP_DHCP
dhcp_start(netif);
usb_osal_timer_start(dhcp_handle);
@@ -531,7 +531,7 @@ void usbh_rtl8152_run(struct usbh_rtl8152 *rtl8152_class)
}
}
- usb_osal_thread_create("usbh_rtl8152_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_rtl8152_rx_thread, NULL);
+ usb_osal_thread_create("usbh_rtl8152_rx", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_rtl8152_rx_thread, NULL);
#if LWIP_DHCP
dhcp_start(netif);
usb_osal_timer_start(dhcp_handle);
diff --git a/platform/nuttx/usbh_net.c b/platform/nuttx/usbh_net.c
index c7af90f9..38db5f3f 100644
--- a/platform/nuttx/usbh_net.c
+++ b/platform/nuttx/usbh_net.c
@@ -118,7 +118,7 @@ static int rndis_ifup(struct net_driver_s *dev)
{
printf("rndis if up\r\n");
g_rndis_dev.linkup = true;
- usb_osal_thread_create("usbh_rndis_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_rndis_rx_thread, NULL);
+ usb_osal_thread_create("usbh_rndis_rx", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_rndis_rx_thread, NULL);
return OK;
}
diff --git a/platform/rtthread/rt_usbh_lwip.c b/platform/rtthread/rt_usbh_lwip.c
index 292e5e3c..9090d38c 100644
--- a/platform/rtthread/rt_usbh_lwip.c
+++ b/platform/rtthread/rt_usbh_lwip.c
@@ -158,7 +158,7 @@ void usbh_cdc_ecm_run(struct usbh_cdc_ecm *cdc_ecm_class)
eth_device_init(&g_cdc_ecm_dev, "u0");
eth_device_linkchange(&g_cdc_ecm_dev, RT_TRUE);
- usb_osal_thread_create("usbh_cdc_ecm_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_cdc_ecm_rx_thread, NULL);
+ usb_osal_thread_create("usbh_cdc_ecm_rx", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_cdc_ecm_rx_thread, NULL);
}
void usbh_cdc_ecm_stop(struct usbh_cdc_ecm *cdc_ecm_class)
@@ -247,7 +247,7 @@ void usbh_rndis_run(struct usbh_rndis *rndis_class)
eth_device_init(&g_rndis_dev, "u2");
eth_device_linkchange(&g_rndis_dev, RT_TRUE);
- usb_osal_thread_create("usbh_rndis_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_rndis_rx_thread, NULL);
+ usb_osal_thread_create("usbh_rndis_rx", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_rndis_rx_thread, NULL);
//timer_init(rndis_class);
}
@@ -319,7 +319,7 @@ void usbh_cdc_ncm_run(struct usbh_cdc_ncm *cdc_ncm_class)
eth_device_init(&g_cdc_ncm_dev, "u1");
eth_device_linkchange(&g_cdc_ncm_dev, RT_TRUE);
- usb_osal_thread_create("usbh_cdc_ncm_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_cdc_ncm_rx_thread, NULL);
+ usb_osal_thread_create("usbh_cdc_ncm_rx", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_cdc_ncm_rx_thread, NULL);
}
void usbh_cdc_ncm_stop(struct usbh_cdc_ncm *cdc_ncm_class)
@@ -388,7 +388,7 @@ void usbh_asix_run(struct usbh_asix *asix_class)
eth_device_init(&g_asix_dev, "u3");
eth_device_linkchange(&g_asix_dev, RT_TRUE);
- usb_osal_thread_create("usbh_asix_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_asix_rx_thread, NULL);
+ usb_osal_thread_create("usbh_asix_rx", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_asix_rx_thread, NULL);
}
void usbh_asix_stop(struct usbh_asix *asix_class)
@@ -457,7 +457,7 @@ void usbh_rtl8152_run(struct usbh_rtl8152 *rtl8152_class)
eth_device_init(&g_rtl8152_dev, "u4");
eth_device_linkchange(&g_rtl8152_dev, RT_TRUE);
- usb_osal_thread_create("usbh_rtl8152_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_rtl8152_rx_thread, NULL);
+ usb_osal_thread_create("usbh_rtl8152_rx", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_rtl8152_rx_thread, NULL);
}
void usbh_rtl8152_stop(struct usbh_rtl8152 *rtl8152_class)
diff --git a/platform/rtthread/rt_usbh_msc.c b/platform/rtthread/rt_usbh_msc.c
index aa2e4a8d..b271731b 100644
--- a/platform/rtthread/rt_usbh_msc.c
+++ b/platform/rtthread/rt_usbh_msc.c
@@ -178,7 +178,7 @@ void usbh_msc_run(struct usbh_msc *msc_class)
rt_device_register(dev, name, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_REMOVABLE | RT_DEVICE_FLAG_STANDALONE);
- usb_osal_thread_create("usbh_msc", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_msc_thread, msc_class);
+ usb_osal_thread_create("usbh_msc", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_msc_thread, msc_class);
}
void usbh_msc_stop(struct usbh_msc *msc_class)
diff --git a/port/pusb2/freertos/usb_config.h b/port/pusb2/freertos/usb_config.h
index 13303785..11b00400 100644
--- a/port/pusb2/freertos/usb_config.h
+++ b/port/pusb2/freertos/usb_config.h
@@ -148,7 +148,7 @@ void cps_otg_switch_to_device(uintptr_t reg_base);
#define CONFIG_USBHOST_DEV_NAMELEN 16
#ifndef CONFIG_USBHOST_PSC_PRIO
-#define CONFIG_USBHOST_PSC_PRIO 0
+#define CONFIG_USBHOST_PSC_PRIO 29
#endif
#ifndef CONFIG_USBHOST_PSC_STACKSIZE
#define CONFIG_USBHOST_PSC_STACKSIZE 8192
diff --git a/port/pusb2/rt-thread/usb_config.h b/port/pusb2/rt-thread/usb_config.h
index 2682d0a2..b8a1d45b 100644
--- a/port/pusb2/rt-thread/usb_config.h
+++ b/port/pusb2/rt-thread/usb_config.h
@@ -129,7 +129,7 @@ unsigned long usb_dc_get_register_base(uint32_t id);
#define CONFIG_USBHOST_DEV_NAMELEN 16
#ifndef CONFIG_USBHOST_PSC_PRIO
-#define CONFIG_USBHOST_PSC_PRIO 0
+#define CONFIG_USBHOST_PSC_PRIO 29
#endif
#ifndef CONFIG_USBHOST_PSC_STACKSIZE
#define CONFIG_USBHOST_PSC_STACKSIZE 8192
diff --git a/port/pusb2/standalone/usb_config.h b/port/pusb2/standalone/usb_config.h
index 7e6bd902..8919a28f 100644
--- a/port/pusb2/standalone/usb_config.h
+++ b/port/pusb2/standalone/usb_config.h
@@ -143,7 +143,7 @@ void usb_osal_leave_critical_section(size_t flag);
#define CONFIG_USBHOST_DEV_NAMELEN 16
#ifndef CONFIG_USBHOST_PSC_PRIO
-#define CONFIG_USBHOST_PSC_PRIO 0
+#define CONFIG_USBHOST_PSC_PRIO 29
#endif
#ifndef CONFIG_USBHOST_PSC_STACKSIZE
#define CONFIG_USBHOST_PSC_STACKSIZE 8192
diff --git a/port/pusb3/freertos/usb_config.h b/port/pusb3/freertos/usb_config.h
index 5162e197..68388a1c 100644
--- a/port/pusb3/freertos/usb_config.h
+++ b/port/pusb3/freertos/usb_config.h
@@ -124,7 +124,7 @@ void usb_hc_enable_interrupt(uint32_t id);
#define CONFIG_USBHOST_DEV_NAMELEN 16
#ifndef CONFIG_USBHOST_PSC_PRIO
-#define CONFIG_USBHOST_PSC_PRIO 0
+#define CONFIG_USBHOST_PSC_PRIO 29
#endif
#ifndef CONFIG_USBHOST_PSC_STACKSIZE
#define CONFIG_USBHOST_PSC_STACKSIZE 8192
diff --git a/port/xhci/phytium/freertos/usb_config.h b/port/xhci/phytium/freertos/usb_config.h
index 642c136b..9af60781 100644
--- a/port/xhci/phytium/freertos/usb_config.h
+++ b/port/xhci/phytium/freertos/usb_config.h
@@ -79,7 +79,7 @@ void usb_hc_enable_interrupt(uint32_t id);
#define CONFIG_USBHOST_DEV_NAMELEN 16
#ifndef CONFIG_USBHOST_PSC_PRIO
-#define CONFIG_USBHOST_PSC_PRIO 0
+#define CONFIG_USBHOST_PSC_PRIO 29
#endif
#ifndef CONFIG_USBHOST_PSC_STACKSIZE
#define CONFIG_USBHOST_PSC_STACKSIZE 8192
diff --git a/port/xhci/phytium/rt-thread/usb_config.h b/port/xhci/phytium/rt-thread/usb_config.h
index c33f6965..db18e25a 100644
--- a/port/xhci/phytium/rt-thread/usb_config.h
+++ b/port/xhci/phytium/rt-thread/usb_config.h
@@ -142,7 +142,7 @@ unsigned long usb_hc_get_register_base(uint32_t id);
#define CONFIG_USBHOST_DEV_NAMELEN 16
#ifndef CONFIG_USBHOST_PSC_PRIO
-#define CONFIG_USBHOST_PSC_PRIO 0
+#define CONFIG_USBHOST_PSC_PRIO 29
#endif
#ifndef CONFIG_USBHOST_PSC_STACKSIZE
#define CONFIG_USBHOST_PSC_STACKSIZE 8192
diff --git a/tests/bouffalolab/inc/usb_config.h b/tests/bouffalolab/inc/usb_config.h
index 01ea6360..d8d00151 100644
--- a/tests/bouffalolab/inc/usb_config.h
+++ b/tests/bouffalolab/inc/usb_config.h
@@ -167,7 +167,7 @@
#define CONFIG_USBHOST_DEV_NAMELEN 16
#ifndef CONFIG_USBHOST_PSC_PRIO
-#define CONFIG_USBHOST_PSC_PRIO 0
+#define CONFIG_USBHOST_PSC_PRIO 29
#endif
#ifndef CONFIG_USBHOST_PSC_STACKSIZE
#define CONFIG_USBHOST_PSC_STACKSIZE 2048
diff --git a/tests/hpmicro/inc/usb_config.h b/tests/hpmicro/inc/usb_config.h
index e59a9954..2a93ea1d 100644
--- a/tests/hpmicro/inc/usb_config.h
+++ b/tests/hpmicro/inc/usb_config.h
@@ -183,7 +183,7 @@
#define CONFIG_USBHOST_DEV_NAMELEN 16
#ifndef CONFIG_USBHOST_PSC_PRIO
-#define CONFIG_USBHOST_PSC_PRIO 0
+#define CONFIG_USBHOST_PSC_PRIO 29
#endif
#ifndef CONFIG_USBHOST_PSC_STACKSIZE
#define CONFIG_USBHOST_PSC_STACKSIZE 2048
diff --git a/tests/hpmicro/src/main.c b/tests/hpmicro/src/main.c
index 81930599..b259856f 100644
--- a/tests/hpmicro/src/main.c
+++ b/tests/hpmicro/src/main.c
@@ -286,3 +286,39 @@ int usbh_uac_volume(int argc, char **argv)
CSH_CMD_EXPORT(usbh_uac_volume, usbh_uac_volume);
#endif
+
+int stack(int argc, const char **argv)
+{
+ (void)argv;
+ if (argc != 1) {
+ printf("Usage: stack\n");
+ return -1;
+ }
+
+ UBaseType_t capacity = uxTaskGetNumberOfTasks() + 4U;
+ TaskStatus_t *tasks = pvPortMalloc(capacity * sizeof(*tasks));
+ if (!tasks) {
+ printf("Failed to allocate task snapshot\n");
+ return -1;
+ }
+
+ UBaseType_t count = uxTaskGetSystemState(tasks, capacity, NULL);
+ if (!count) {
+ vPortFree(tasks);
+ printf("Task list changed; run stack again\n");
+ return -1;
+ }
+
+ printf("%-16s %5s %14s\n", "Task", "Prio", "Min free bytes");
+ for (UBaseType_t i = 0; i < count; i++) {
+ if (tasks[i].eCurrentState == eDeleted || !tasks[i].pcTaskName) {
+ continue;
+ }
+ size_t free_bytes = (size_t)tasks[i].usStackHighWaterMark * sizeof(StackType_t);
+ printf("%-16.16s %5lu %14lu\n", tasks[i].pcTaskName,
+ (unsigned long)tasks[i].uxCurrentPriority, (unsigned long)free_bytes);
+ }
+ vPortFree(tasks);
+ return 0;
+}
+CSH_CMD_EXPORT(stack, show minimum free stack bytes for each task);
diff --git a/third_party/nimble-1.6.0/README.md b/third_party/nimble-1.6.0/README.md
index 5e432e6a..673d77d6 100644
--- a/third_party/nimble-1.6.0/README.md
+++ b/third_party/nimble-1.6.0/README.md
@@ -162,7 +162,7 @@ void nimble_init(void)
{
nimble_port_init();
- usb_osal_thread_create("nimble", 2048, CONFIG_USBHOST_PSC_PRIO + 1, nimble_thread_entry, NULL);
+ usb_osal_thread_create("nimble", 2048, CONFIG_USBHOST_PSC_PRIO - 1, nimble_thread_entry, NULL);
}
```
diff --git a/third_party/nimble-1.6.0/ble_hci_usbh.c b/third_party/nimble-1.6.0/ble_hci_usbh.c
index bc0d436b..7623f50b 100644
--- a/third_party/nimble-1.6.0/ble_hci_usbh.c
+++ b/third_party/nimble-1.6.0/ble_hci_usbh.c
@@ -88,10 +88,10 @@ void usbh_bluetooth_run(struct usbh_bluetooth *bluetooth_class)
hci_h4_sm_init(&g_hci_h4sm, &hci_h4_allocs_from_ll, hci_usb_frame_cb);
#ifdef CONFIG_USBHOST_BLUETOOTH_HCI_H4
- usb_osal_thread_create("ble_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_bluetooth_hci_rx_thread, NULL);
+ usb_osal_thread_create("ble_rx", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_bluetooth_hci_rx_thread, NULL);
#else
- usb_osal_thread_create("ble_evt", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_bluetooth_hci_evt_rx_thread, NULL);
- usb_osal_thread_create("ble_acl", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_bluetooth_hci_acl_rx_thread, NULL);
+ usb_osal_thread_create("ble_evt", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_bluetooth_hci_evt_rx_thread, NULL);
+ usb_osal_thread_create("ble_acl", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_bluetooth_hci_acl_rx_thread, NULL);
#endif
usbh_bluetooth_run_callback();
}
diff --git a/third_party/zephyr_bluetooth-2.7.5/ble_hci_usbh.c b/third_party/zephyr_bluetooth-2.7.5/ble_hci_usbh.c
index 233d5544..65d12d18 100644
--- a/third_party/zephyr_bluetooth-2.7.5/ble_hci_usbh.c
+++ b/third_party/zephyr_bluetooth-2.7.5/ble_hci_usbh.c
@@ -321,10 +321,10 @@ void usbh_bluetooth_run(struct usbh_bluetooth *bluetooth_class)
bt_hci_driver_register(&usbh_drv);
#ifdef CONFIG_USBHOST_BLUETOOTH_HCI_H4
- usb_osal_thread_create("ble_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_bluetooth_hci_rx_thread, NULL);
+ usb_osal_thread_create("ble_rx", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_bluetooth_hci_rx_thread, NULL);
#else
- usb_osal_thread_create("ble_evt", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_bluetooth_hci_evt_rx_thread, NULL);
- usb_osal_thread_create("ble_acl", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_bluetooth_hci_acl_rx_thread, NULL);
+ usb_osal_thread_create("ble_evt", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_bluetooth_hci_evt_rx_thread, NULL);
+ usb_osal_thread_create("ble_acl", 2048, CONFIG_USBHOST_PSC_PRIO - 1, usbh_bluetooth_hci_acl_rx_thread, NULL);
#endif
s_registered = true;
}