summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngus Gratton <angus@redyak.com.au>2025-08-27 15:34:12 +1000
committerDamien George <damien@micropython.org>2025-09-10 12:34:59 +1000
commit3ec2e367decd8da968b1b85b65264bbab367bc9c (patch)
treeb1f0c9c07653a66f19fd01bf794f7a88bdccbcaa
parent8d5a8892d22388b0d1b0e6769a0f1719a362937b (diff)
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>
-rw-r--r--shared/tinyusb/mp_usbd.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/shared/tinyusb/mp_usbd.h b/shared/tinyusb/mp_usbd.h
index 866ef8503..4e3403b35 100644
--- a/shared/tinyusb/mp_usbd.h
+++ b/shared/tinyusb/mp_usbd.h
@@ -45,7 +45,18 @@
static inline void mp_usbd_init_tud(void) {
tusb_init();
#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);
#endif
}