This is an automated email from Gerrit.

"Peter Collingbourne <p...@google.com>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/7483

-- gerrit

commit 9e4ec6eef8f4d8ef18209c620859d733eeab7378
Author: Peter Collingbourne <p...@google.com>
Date:   Fri Feb 17 18:26:05 2023 -0800

    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 <p...@google.com>

diff --git a/src/jtag/drivers/cmsis_dap.c b/src/jtag/drivers/cmsis_dap.c
index 0c42a7f1e0..1e7a851e4b 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);
 

-- 

Reply via email to