Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Jul 19, 2024

Conversation

feaser
Copy link
Contributor

@feaser feaser commented Jun 29, 2024

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:

  • tud_descriptor_bos_cb()
  • tud_vendor_control_xfer_cb()

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:

  • tud_mount_cb()
  • tud_umount_cb()
  • tud_suspend_cb()
  • tud_resume_cb()

feaser and others added 2 commits July 19, 2024 20:43
…WEAK for the Keil

compiler for the callback functions:

* tud_descriptor_bos_cb()
* tud_vendor_control_xfer_cb()
* tud_mount_cb()
* tud_umount_cb()
* tud_suspend_cb()
* tud_resume_cb()

Without the fix for the first two functions, the USB device won't enumerate properly, if
the device makes use of a BOS description. For example when using a Microsoft OS 2.0
platform capability descriptor to set a specific Device Interface GUID for WinUSB.

The fix for the other four functions were added, because it's probably just a matter of
time before someone runs into the same problem with those callback functions.
Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you look good. I made neccessary tests for the weak implementation: skip exists check, but we need to check its returned value. Also apply for the qualifier and other_speed

@hathach hathach merged commit 9a41831 into hathach:master Jul 19, 2024
78 checks passed
@feaser feaser deleted the keil_weak_fix branch July 19, 2024 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants