From 0995fe1288660c3b0a3d4e09e48a1b6b0611848b Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Sun, 18 Oct 2020 15:11:46 +0200 Subject: [PATCH] cmsis-dap: Various fixes - decrease report size to 64, otherwise MIMRXT10x0-EVK crashed when reading larger memory block - dp_read_reg acts direct, fixing CortexM core register read. - length of data to write with read_block. --- src/platforms/hosted/cmsis_dap.c | 11 ++--------- src/platforms/hosted/dap.c | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/platforms/hosted/cmsis_dap.c b/src/platforms/hosted/cmsis_dap.c index 6c58578..4d2bb0b 100644 --- a/src/platforms/hosted/cmsis_dap.c +++ b/src/platforms/hosted/cmsis_dap.c @@ -47,7 +47,7 @@ uint8_t mode; /*- Variables ---------------------------------------------------------------*/ static hid_device *handle = NULL; static uint8_t hid_buffer[1024 + 1]; -static int report_size = 512 + 1; // TODO: read actual report size +static int report_size = 64 + 1; // TODO: read actual report size /* LPC845 Breakout Board Rev. 0 report invalid response with > 65 bytes */ int dap_init(bmp_info_t *info) { @@ -129,14 +129,7 @@ static uint32_t dap_dp_low_access(struct ADIv5_DP_s *dp, uint8_t RnW, static uint32_t dap_dp_read_reg(ADIv5_DP_t *dp, uint16_t addr) { - uint32_t res; - if (addr & ADIV5_APnDP) { - dap_dp_low_access(dp, ADIV5_LOW_READ, addr, 0); - res = dap_dp_low_access(dp, ADIV5_LOW_READ, - ADIV5_DP_RDBUFF, 0); - } else { - res = dap_dp_low_access(dp, ADIV5_LOW_READ, addr, 0); - } + uint32_t res = dap_dp_low_access(dp, ADIV5_LOW_READ, addr, 0); DEBUG_PROBE("dp_read %04x %08" PRIx32 "\n", addr, res); return res; } diff --git a/src/platforms/hosted/dap.c b/src/platforms/hosted/dap.c index 73bf3c0..0f0efee 100644 --- a/src/platforms/hosted/dap.c +++ b/src/platforms/hosted/dap.c @@ -394,7 +394,7 @@ unsigned int dap_read_block(ADIv5_AP_t *ap, void *dest, uint32_t src, buf[2] = sz & 0xff; buf[3] = (sz >> 8) & 0xff; buf[4] = SWD_AP_DRW | DAP_TRANSFER_RnW; - dbg_dap_cmd(buf, 1023, 5 + 1); + dbg_dap_cmd(buf, 1023, 5); unsigned int transferred = buf[0] + (buf[1] << 8); if (buf[2] >= DAP_TRANSFER_FAULT) { DEBUG_WARN("dap_read_block @ %08" PRIx32 " fault -> line reset\n", src);