Hi,
We found following issue in the SDK USB stack when using the USB_DEVICE_CONFIG_USE_TASK option and when handling both USB ports (one thread for each port) on the device (as device ports).
The fix is the following:
diff --git a/middleware/usb/device/usb_device_dci.c b/middleware/usb/device/usb_device_dci.c index d5f449d..c9a7330 100644 --- a/middleware/usb/device/usb_device_dci.c +++ b/middleware/usb/device/usb_device_dci.c @@ -1422,7 +1422,7 @@ usb_status_t USB_DeviceDcdDeinitModule(usb_device_handle handle) void USB_DeviceTaskFunction(void *deviceHandle) { usb_device_struct_t *handle = (usb_device_struct_t *)deviceHandle; - static usb_device_callback_message_struct_t message; + usb_device_callback_message_struct_t message; if (deviceHandle) {
As you can see, the message was static. If now multiple threads (one for each USB port) call this function, it can be that the message content is changed (by another thread will the lower priority thread is handling it....).
This causes invalid behavior leading to endpoints not receiving any more interrupts.
If the aim would be that message should survive the function call, then it should be part of the device handle, so that each device would have its own message being processed.
However I do not see for which purpose the need of static would arise, and anyhow statics are not mutli-thread safe in anyway....
Best Regards,
Luc
Hi Luc:
Thank you for your feedback. I reported this to the develop team.
Regards
Daniel