This is an automated email from Gerrit. "N S <[email protected]>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9237
-- gerrit commit 70bce72646aef03bc2db69fd4f0713cd9e6a3d18 Author: N S <[email protected]> Date: Sat Nov 15 17:11:01 2025 -0800 jtag/drivers: Speed up OpenJTAG adapter by using async reads Improve performance of USB OpenJTAG adapters by requesting async USB read result before sending TAP commands to device. Allows device to immediately start sending results to host before all commands have been processed. Signed-off-by: N S <[email protected]> Change-Id: I27ea2a2dc89d7820dc5f56949723c529bdb1e1b6 diff --git a/src/jtag/drivers/openjtag.c b/src/jtag/drivers/openjtag.c index d45a1c6a97..1817df1b01 100644 --- a/src/jtag/drivers/openjtag.c +++ b/src/jtag/drivers/openjtag.c @@ -80,6 +80,7 @@ static uint16_t openjtag_pid = 0x6001; static char *openjtag_device_desc; static struct ftdi_context ftdic; +static struct ftdi_transfer_control *async_read; #define OPENJTAG_BUFFER_SIZE 504 #define OPENJTAG_MAX_PENDING_RESULTS 256 @@ -266,6 +267,22 @@ static int openjtag_buf_write( } } +static int openjtag_start_buf_read(uint8_t *buf, uint32_t qty) +{ + switch (openjtag_variant) { + case OPENJTAG_VARIANT_CY7C65215: + return ERROR_OK; + default: + async_read = ftdi_read_data_submit(&ftdic, buf, qty); + if (!async_read) { + LOG_DEBUG_IO("ftdi_read_data_submit: %s", + ftdi_get_error_string(&ftdic)); + return ERROR_JTAG_DEVICE_ERROR; + } + return ERROR_OK; + } +} + static int openjtag_buf_read_standard( uint8_t *buf, uint32_t qty, uint32_t *bytes_read) { @@ -276,15 +293,24 @@ static int openjtag_buf_read_standard( *bytes_read = 0; while ((*bytes_read < qty) && timeout--) { - retval = ftdi_read_data(&ftdic, buf + *bytes_read, - qty - *bytes_read); + retval = ftdi_transfer_data_done(async_read); if (retval < 0) { *bytes_read = 0; - LOG_DEBUG_IO("ftdi_read_data: %s", + LOG_DEBUG_IO("ftdi_transfer_data_done: %s", ftdi_get_error_string(&ftdic)); return ERROR_JTAG_DEVICE_ERROR; } *bytes_read += retval; + + if ((*bytes_read < qty) && timeout) { + async_read = ftdi_read_data_submit(&ftdic, buf + *bytes_read, + qty - *bytes_read); + if (!async_read) { + LOG_DEBUG_IO("ftdi_read_data_submit: %s", + ftdi_get_error_string(&ftdic)); + return ERROR_JTAG_DEVICE_ERROR; + } + } } #ifdef _DEBUG_USB_COMMS_ @@ -476,6 +502,7 @@ static int openjtag_init(void) usb_tx_buf_offs = 0; usb_rx_buf_len = 0; openjtag_scan_result_count = 0; + async_read = NULL; switch (openjtag_variant) { case OPENJTAG_VARIANT_CY7C65215: @@ -542,6 +569,7 @@ static void openjtag_write_tap_buffer(void) } } + openjtag_start_buf_read(usb_rx_buf, rx_expected); openjtag_buf_write(usb_tx_buf, usb_tx_buf_offs, &written); openjtag_buf_read(usb_rx_buf, rx_expected, &usb_rx_buf_len); --
