Skip to content

Commit

Permalink
fix(read_flash): flush transmit buffer less often to inrease throughput
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdragun authored and radimkarnis committed Jan 15, 2024
1 parent f1f2734 commit 4e4de29
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion flasher_stub/stub_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 4e4de29

Please sign in to comment.