From 0a20e78b759efa86a676b4a9fed4027fdd84e90c Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 17 Feb 2023 18:26:05 -0800 Subject: jtag/drivers/cmsis_dap: run queue on reaching transaction limit We currently fail the transfer when issuing more than 255 transactions at once, e.g. > read_memory 0x10000000 32 256 CMSIS-DAP transfer count mismatch: expected 257, got 1 This is because the protocol only supports 255 transactions per packet (65535 for block transactions), and as a result we truncate the transaction count when assembling the packet. Fix it by running the queue when we hit the limit. Change-Id: Ia9e01e3af5ad035f2cf2a32292c9d66e57eafae9 Signed-off-by: Peter Collingbourne Fixes: 40bac8e8c4e5 ("jtag/drivers/cmsis_dap: improve USB packets filling") Reviewed-on: https://review.openocd.org/c/openocd/+/7483 Tested-by: jenkins Reviewed-by: Tomas Vanek --- src/jtag/drivers/cmsis_dap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/jtag/drivers/cmsis_dap.c b/src/jtag/drivers/cmsis_dap.c index 0c42a7f..1e7a851 100644 --- a/src/jtag/drivers/cmsis_dap.c +++ b/src/jtag/drivers/cmsis_dap.c @@ -1001,12 +1001,14 @@ static void cmsis_dap_swd_queue_cmd(uint8_t cmd, uint32_t *dst, uint32_t data) block_cmd); unsigned int resp_size = cmsis_dap_tfer_resp_size(write_count, read_count, block_cmd); + unsigned int max_transfer_count = block_cmd ? 65535 : 255; /* Does the DAP Transfer command and the expected response fit into one packet? * Run the queue also before a targetsel - it cannot be queued */ if (cmd_size > tfer_max_command_size || resp_size > tfer_max_response_size - || targetsel_cmd) { + || targetsel_cmd + || write_count + read_count > max_transfer_count) { if (cmsis_dap_handle->pending_fifo_block_count) cmsis_dap_swd_read_process(cmsis_dap_handle, 0); -- cgit v1.1