Skip to content

alif/tinyusb_port: Fix setting of USB device addr for fast hosts. #17966

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dpgeorge
Copy link
Member

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.

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

Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge
Copy link
Member Author

@kwagyeman FYI

@kwagyeman
Copy link
Contributor

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants