jtag/mpsse: mpsse_flush should not treat LIBUSB_ERROR_INTERRUPTED as an error
[openocd.git] / src / jtag / drivers / cmsis_dap.c
index 5d060bdadd0ad13a7671adbef8dbbfeccd3c8b7f..caacc9b91602ea543d956ebda8ab9323fee3d59f 100644 (file)
@@ -861,9 +861,10 @@ static void cmsis_dap_swd_write_from_queue(struct cmsis_dap *dap)
                goto skip;
        }
 
-       dap->pending_fifo_put_idx = (dap->pending_fifo_put_idx + 1) % dap->packet_count;
+       unsigned int packet_count = dap->quirk_mode ? 1 : dap->packet_count;
+       dap->pending_fifo_put_idx = (dap->pending_fifo_put_idx + 1) % packet_count;
        dap->pending_fifo_block_count++;
-       if (dap->pending_fifo_block_count > dap->packet_count)
+       if (dap->pending_fifo_block_count > packet_count)
                LOG_ERROR("internal: too much pending writes %u", dap->pending_fifo_block_count);
 
        return;
@@ -984,7 +985,8 @@ static void cmsis_dap_swd_read_process(struct cmsis_dap *dap, enum cmsis_dap_blo
 
 skip:
        block->transfer_count = 0;
-       dap->pending_fifo_get_idx = (dap->pending_fifo_get_idx + 1) % dap->packet_count;
+       if (!dap->quirk_mode && dap->packet_count > 1)
+               dap->pending_fifo_get_idx = (dap->pending_fifo_get_idx + 1) % dap->packet_count;
        dap->pending_fifo_block_count--;
 }
 
@@ -1079,7 +1081,8 @@ static void cmsis_dap_swd_queue_cmd(uint8_t cmd, uint32_t *dst, uint32_t data)
                /* Not enough room in the queue. Run the queue. */
                cmsis_dap_swd_write_from_queue(cmsis_dap_handle);
 
-               if (cmsis_dap_handle->pending_fifo_block_count >= cmsis_dap_handle->packet_count)
+               unsigned int packet_count = cmsis_dap_handle->quirk_mode ? 1 : cmsis_dap_handle->packet_count;
+               if (cmsis_dap_handle->pending_fifo_block_count >= packet_count)
                        cmsis_dap_swd_read_process(cmsis_dap_handle, CMSIS_DAP_BLOCKING);
        }
 
@@ -1222,7 +1225,7 @@ static int cmsis_dap_swd_switch_seq(enum swd_special_seq seq)
        if (swd_mode)
                queued_retval = cmsis_dap_swd_run_queue();
 
-       if (seq != LINE_RESET &&
+       if (cmsis_dap_handle->quirk_mode && seq != LINE_RESET &&
                        (output_pins & (SWJ_PIN_SRST | SWJ_PIN_TRST))
                                == (SWJ_PIN_SRST | SWJ_PIN_TRST)) {
                /* Following workaround deasserts reset on most adapters.
@@ -2220,6 +2223,19 @@ COMMAND_HANDLER(cmsis_dap_handle_backend_command)
        return ERROR_OK;
 }
 
+COMMAND_HANDLER(cmsis_dap_handle_quirk_command)
+{
+       if (CMD_ARGC > 1)
+               return ERROR_COMMAND_SYNTAX_ERROR;
+
+       if (CMD_ARGC == 1)
+               COMMAND_PARSE_ENABLE(CMD_ARGV[0], cmsis_dap_handle->quirk_mode);
+
+       command_print(CMD, "CMSIS-DAP quirk workarounds %s",
+                                 cmsis_dap_handle->quirk_mode ? "enabled" : "disabled");
+       return ERROR_OK;
+}
+
 static const struct command_registration cmsis_dap_subcommand_handlers[] = {
        {
                .name = "info",
@@ -2249,6 +2265,13 @@ static const struct command_registration cmsis_dap_subcommand_handlers[] = {
                .help = "set the communication backend to use (USB bulk or HID).",
                .usage = "(auto | usb_bulk | hid)",
        },
+       {
+               .name = "quirk",
+               .handler = &cmsis_dap_handle_quirk_command,
+               .mode = COMMAND_ANY,
+               .help = "allow expensive workarounds of known adapter quirks.",
+               .usage = "[enable | disable]",
+       },
 #if BUILD_CMSIS_DAP_USB
        {
                .name = "usb",

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)