From 7512ad66222f0c031d4eaf5abf605ab403440e83 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Wed, 27 Aug 2025 15:34:12 +1000 Subject: [PATCH] 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 --- shared/tinyusb/mp_usbd.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/shared/tinyusb/mp_usbd.h b/shared/tinyusb/mp_usbd.h index 5c8f2a6095..ed7a248aca 100644 --- a/shared/tinyusb/mp_usbd.h +++ b/shared/tinyusb/mp_usbd.h @@ -43,7 +43,18 @@ // Initialise TinyUSB device. static inline void mp_usbd_init_tud(void) { tusb_init(); - 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); }