Expected DCD events following tud_disconnect()? #3331
Unanswered
projectgus
asked this question in
Q&A
Replies: 2 comments
-
|
Some extra context from the MicroPython perspective: micropython/micropython#18375 (under "Related Bugs") |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I think it's something we've overlooked, in I think we need to do something like this (untested): diff --git a/src/device/usbd.c b/src/device/usbd.c
index 05fc752af..5a8d51bbe 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -476,12 +476,16 @@ bool tud_remote_wakeup(void) {
}
bool tud_disconnect(void) {
+ dcd_int_disable(_usbd_rhport);
dcd_disconnect(_usbd_rhport);
+ usbd_reset(_usbd_rhport);
+ tud_umount_cb();
return true;
}
bool tud_connect(void) {
dcd_connect(_usbd_rhport);
+ dcd_int_enable(_usbd_rhport);
return true;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When implementing the MicroPython dynamic USB support for RP2040, I relied on the behaviour that calling
tud_disconnect()on a connected and configured USB device causes aDCD_EVENT_BUS_RESETevent to be delivered. This resets internal USB device driver state while the USB device is "soft disconnected", until callingtud_connect()later.(There's an open issue where this doesn't work on RP2040, but it's worked in MicroPython when I've tested it.)
On ESP32-S3 we're finding that no events are delivered after calling
tud_disconnect()- as a result device drivers still have their connected state (in particular, CDC thinks it's connected).Searching issues it seems like something similar happens with other DCD drivers as well (no event comes to tell the devices they are disconnected).
I was wondering if there are any events expected after calling
tud_disconnect(), in general? (If so, missing events may be a bug.)I'm also wondering if it would be reasonable for TinyUSB to always call
dcd_event_bus_reset()ordcd_event_bus_signal(..., DCD_EVENT_UNPLUGGED)to inject an event whentud_disconnect()is called on a configured device. Then the device driver state can update correctly even if the hardware doesn't provide any event?Beta Was this translation helpful? Give feedback.
All reactions