alif/tinyusb_port: Fix setting of USB device addr for fast hosts. #17966
+8
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
A fast host (eg Mac M4) may request the status for the SET_ADDRESS before TinyUSB gets to process it. This is because TinyUSB does not handle events inside the USB ISR, rather it waits for the top-level thread to process them. Fix that by setting the USB device address as soon as TUSB_REQ_SET_ADDRESS comes in.
This patch follows the corresponding upstream fix: alifsemi/tinyusb@fc40ea7
Testing
Tested on ALIF_ENSEMBLE and OPENMV_AE3 boards, on an Arch Linux laptop. Inspecting
dmsg
logs, everything looks as it did prior to this change, and USB CDC still works correctly.Trade-offs and Alternatives
We could instead update the Alif TinyUSB DCD driver to the latest official/upstream one found in https://github.com/alifsemi/tinyusb/. But that's a lot more effort than just applying this patch.