hathach / tinyusb

An open source cross-platform USB stack for embedded system
https://www.tinyusb.org
MIT License
4.66k stars 996 forks source link

Additional fix related to issue #1018. Corrects the usage of TU_ATTR_WEAK for the Keil compiler #2694

Open feaser opened 2 days ago

feaser commented 2 days ago

Describe the PR Issue #1018 resolved the usage of TU_ATTR_WEAK for the Keil compiler when it comes to function dcd_edpt0_status_complete().

Unfortunately, the same problem (the USB device not enumerating properly) occurs again, if the USB device makes use of a BOS descriptor. For example when using a Microsoft OS 2.0 platform capability descriptor to set a specific Device Interface GUID for WinUSB.

In this case the problem is caused by the tud_descriptor_bos_cb() and tud_vendor_control_xfer_cb() callback functions. The compiler does not see and use the user implemented version of these callback functions. Consequently, these callback functions are not called at run-time, causing the enumeration to fail. The attached screenshot shows this:

keil_weak_fix

To fix this PR proposes, is exactly the same as for callback function dcd_edpt0_status_complete(), just now for the callback functions:

I verified that this fix resolves the USB enumeration problem with the Keil compiler. Additionally, I performed a quick regression test to make sure things still work when using the GCC or IAR compiler.

Additional context

The PR also adds the same fix for the following four callback functions, because it is just a matter of time before someone else runs into the same problem with those: