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 1abbdba1d4
commit 7512ad6622

View File

@@ -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);
}