shared/tinyusb: Fix hang from new tx_overwritabe_if_not_connected flag.

This flag is in the main branch of TinyUSB, included in Espressif since
their v0.18.0~3 component release (but it's not actually in TinyUSB v0.18.0
release).

Setting the flag is needed for the USB device not to block waiting for
space in the FIFO if the host is disconnected.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
Angus Gratton
2025-08-27 15:34:12 +10:00
committed by Damien George
parent 8d5a8892d2
commit 3ec2e367de

View File

@@ -45,7 +45,18 @@
static inline void mp_usbd_init_tud(void) { static inline void mp_usbd_init_tud(void) {
tusb_init(); tusb_init();
#if MICROPY_HW_USB_CDC #if MICROPY_HW_USB_CDC
tud_cdc_configure_fifo_t cfg = { .rx_persistent = 0, .tx_persistent = 1 }; tud_cdc_configure_fifo_t cfg = { .rx_persistent = 0,
.tx_persistent = 1,
// This config flag is unreleased in TinyUSB >v0.18.0
// but included in Espressif's TinyUSB component since v0.18.0~3
//
// Versioning issue reported as
// https://github.com/espressif/esp-usb/issues/236
#if TUSB_VERSION_NUMBER > 1800 || defined(ESP_PLATFORM)
.tx_overwritabe_if_not_connected = 1,
#endif
};
tud_cdc_configure_fifo(&cfg); tud_cdc_configure_fifo(&cfg);
#endif #endif
} }