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 <pcc@google.com>
Fixes: 40bac8e8c4 ("jtag/drivers/cmsis_dap: improve USB packets filling")
Reviewed-on: https://review.openocd.org/c/openocd/+/7483
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
This commit is contained in:
Peter Collingbourne 2023-02-17 18:26:05 -08:00 committed by Antonio Borneo
parent c99c043f3f
commit 0a20e78b75
1 changed files with 3 additions and 1 deletions

View File

@ -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);