aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorN S <nlshipp@yahoo.com>2023-01-22 21:34:16 -0800
committerAntonio Borneo <borneo.antonio@gmail.com>2024-02-11 23:10:30 +0000
commit7295ddc15c0516a64c9996d2b351accb50175803 (patch)
tree887cf1f0f7d4b918b85c6a08e53861fb4dc7c1e4
parent81a50d3e9050eed8f4d95622f2b326054a200b93 (diff)
downloadriscv-openocd-7295ddc15c0516a64c9996d2b351accb50175803.zip
riscv-openocd-7295ddc15c0516a64c9996d2b351accb50175803.tar.gz
riscv-openocd-7295ddc15c0516a64c9996d2b351accb50175803.tar.bz2
jtag/drivers: OpenJTAG standard variant perf improvement
Calculate exact size of response expected from OpenJTAG device so that openjtag_buf_read_standard doesn't spend 5 retry cycles waiting for data that isn't coming. Change-Id: Icd010d1fa4453d6592a1f9aed93fb1f01e0a19da Signed-off-by: N S <nlshipp@yahoo.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8101 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
-rw-r--r--src/jtag/drivers/openjtag.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/jtag/drivers/openjtag.c b/src/jtag/drivers/openjtag.c
index 45064fe..1c79a2c 100644
--- a/src/jtag/drivers/openjtag.c
+++ b/src/jtag/drivers/openjtag.c
@@ -530,9 +530,20 @@ static int openjtag_quit(void)
static void openjtag_write_tap_buffer(void)
{
uint32_t written;
+ uint32_t rx_expected = 0;
+
+ /* calculate expected number of return bytes */
+ for (int tx_offs = 0; tx_offs < usb_tx_buf_offs; tx_offs++) {
+ if ((usb_tx_buf[tx_offs] & 0x0F) == 6) {
+ rx_expected++;
+ tx_offs++;
+ } else if ((usb_tx_buf[tx_offs] & 0x0F) == 2) {
+ rx_expected++;
+ }
+ }
openjtag_buf_write(usb_tx_buf, usb_tx_buf_offs, &written);
- openjtag_buf_read(usb_rx_buf, usb_tx_buf_offs, &usb_rx_buf_len);
+ openjtag_buf_read(usb_rx_buf, rx_expected, &usb_rx_buf_len);
usb_tx_buf_offs = 0;
}