diff --git a/flasher_stub/stub_io.c b/flasher_stub/stub_io.c index 6cff6c3..d0b08dd 100644 --- a/flasher_stub/stub_io.c +++ b/flasher_stub/stub_io.c @@ -171,8 +171,15 @@ void stub_tx_one_char(char c) #endif // WITH_USB_OTG uart_tx_one_char(c); #if WITH_USB_JTAG_SERIAL + static unsigned short transferred_without_flush = 0; if (stub_uses_usb_jtag_serial()){ - stub_tx_flush(); + // Defer flushing until we have a (full - 1) packet or a end of packet (0xc0) byte to increase throughput. + // Note that deferring flushing until we have a full packet can cause hang-ups on some platforms. + ++transferred_without_flush; + if (c == '\xc0' || transferred_without_flush >= 63) { + stub_tx_flush(); + transferred_without_flush = 0; + } } #endif // WITH_USB_JTAG_SERIAL }