From 9c9d26b87e6ec05f5764c1116251b11022d4ee4d Mon Sep 17 00:00:00 2001 From: dragonmux Date: Sun, 17 Nov 2024 13:43:51 +0000 Subject: [PATCH] hosted/cmsis_dap: Added a quirk restricting when the ZLP read for Bulk adaptors is done so we don't clobber performance on adaptors that don't need it --- src/platforms/hosted/cmsis_dap.c | 7 ++++++- src/platforms/hosted/dap.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/platforms/hosted/cmsis_dap.c b/src/platforms/hosted/cmsis_dap.c index 6ab7decdab6..82c572d8dcb 100644 --- a/src/platforms/hosted/cmsis_dap.c +++ b/src/platforms/hosted/cmsis_dap.c @@ -351,6 +351,10 @@ bool dap_init(bool allow_fallback) dap_version_compare_le(adaptor_version, (dap_version_s){1, 3, 1})) dap_quirks |= DAP_QUIRK_BAD_SWD_NO_RESP_DATA_PHASE; + /* ORBTrace needs an extra ZLP read done on full packet reception */ + if (strcmp(bmda_probe_info.product, "Orbtrace") == 0) + dap_quirks |= DAP_QUIRK_NEEDS_EXTRA_ZLP_READ; + return true; } @@ -513,8 +517,9 @@ ssize_t dbg_dap_cmd_bulk(const uint8_t *const request_data, const size_t request return response_result; } } while (response_data[0] != request_data[0]); + /* If the response requested is the size of the packet size for the adaptor, generate a ZLP read to clean state */ - if (transferred == (int)dap_packet_size) { + if ((dap_quirks & DAP_QUIRK_NEEDS_EXTRA_ZLP_READ) && transferred == (int)dap_packet_size) { uint8_t zlp; int zlp_read = 0; libusb_bulk_transfer(usb_handle, in_ep, &zlp, sizeof(zlp), &zlp_read, TRANSFER_TIMEOUT_MS); diff --git a/src/platforms/hosted/dap.h b/src/platforms/hosted/dap.h index aef0beaaa14..e698ca6de0d 100644 --- a/src/platforms/hosted/dap.h +++ b/src/platforms/hosted/dap.h @@ -72,6 +72,7 @@ typedef enum dap_led_type { #define DAP_QUIRK_NO_JTAG_MUTLI_TAP (1U << 0U) #define DAP_QUIRK_BAD_SWD_NO_RESP_DATA_PHASE (1U << 1U) #define DAP_QUIRK_BROKEN_SWD_SEQUENCE (1U << 2U) +#define DAP_QUIRK_NEEDS_EXTRA_ZLP_READ (1U << 3U) extern uint8_t dap_caps; extern dap_cap_e dap_mode;