Skip to content

Commit

Permalink
speed up s3cdc flash read
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason2866 authored Dec 27, 2023
1 parent f28ec34 commit ee21a7f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 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 int transferred_without_flush = 0;
if (stub_uses_usb_jtag_serial()){
stub_tx_flush();
// Defer flushing until we have a (full - 1) packet or a 0xc0 byte to increase throughput.
// Note that deferring flushing until we have a full packet causes 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 Expand Up @@ -296,6 +303,15 @@ void stub_io_set_baudrate(uint32_t current_baud, uint32_t new_baud)
return;
}
#endif // WITH_USB_OTG
#if WITH_USB_JTAG_SERIAL
/* Workaround for ESP32-S3: UART baud rate divider is not set correctly by get_new_uart_divider. */
if (stub_uses_usb_jtag_serial()) {
ets_delay_us(10000);
uart_div_modify(0, 0);
ets_delay_us(1000);
return;
}
#endif
ets_delay_us(10000);
uart_div_modify(0, get_new_uart_divider(current_baud, new_baud));
ets_delay_us(1000);
Expand Down

0 comments on commit ee21a7f

Please sign in to comment.