micropython/shared/tinyusb
Angus Gratton 9a43989a86 shared/tinyusb: Stall the CDC IN endpoint while disconnecting.
Only when dynamic USB devices are enabled.

The issue here is that when the USB reset triggers, the dynamic USB device
reset callback is called from inside the TinyUSB task.

If that callback tries to print something then it'll call through to
tud_cdc_write_flush(), but TinyUSB hasn't finished updating state yet to
know it's no longer configured. Subsequently it may try to queue a transfer
and then the low-level DCD layer panics.

By explicitly stalling the endpoint first, usbd_edpt_claim() will fail and
tud_cdc_write_flush() returns immediately.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-05-09 15:22:31 +10:00
..
mp_cdc_common.c all: Remove the "STATIC" macro and just use "static" instead. 2024-03-07 14:20:42 +11:00
mp_usbd.c extmod/machine_usb_device: Add support for Python USB devices. 2024-03-15 14:22:11 +11:00
mp_usbd.h extmod/machine_usb_device: Add support for Python USB devices. 2024-03-15 14:22:11 +11:00
mp_usbd_descriptor.c extmod/machine_usb_device: Add support for Python USB devices. 2024-03-15 14:22:11 +11:00
mp_usbd_runtime.c shared/tinyusb: Stall the CDC IN endpoint while disconnecting. 2024-05-09 15:22:31 +10:00
tusb_config.h shared/tinyusb: Increase default string descr max length to 40 chars. 2024-03-27 23:57:57 +11:00