Skip to content

Commit

Permalink
hosted/cmsis_dap: Added a quirk restricting when the ZLP read for Bul…
Browse files Browse the repository at this point in the history
…k adaptors is done so we don't clobber performance on adaptors that don't need it
  • Loading branch information
dragonmux committed Nov 17, 2024
1 parent cf98ee8 commit d45942f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/platforms/hosted/cmsis_dap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/platforms/hosted/dap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d45942f

Please sign in to comment.