From f9414d58265093bf8a4ae59d45c3d1ac441d6ed2 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Mon, 26 Apr 2021 17:55:45 +0200 Subject: [PATCH] cmsis-dap: Handle ADI DP22 devices on probes not multidrop capable. --- src/platforms/hosted/cmsis_dap.c | 2 ++ src/platforms/hosted/platform.c | 2 -- src/target/adiv5_swdp.c | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/platforms/hosted/cmsis_dap.c b/src/platforms/hosted/cmsis_dap.c index 1dae8374..55b94772 100644 --- a/src/platforms/hosted/cmsis_dap.c +++ b/src/platforms/hosted/cmsis_dap.c @@ -426,6 +426,8 @@ int dap_swdptap_init(ADIv5_DP_t *dp) /* DAP_SWD_SEQUENCE does not do auto turnaround, use own!*/ dp->dp_low_read = dap_dp_low_read; dp->dp_low_write = dap_dp_low_write; + } else { + dp->error = dap_dp_error; } dp->seq_out = dap_swdptap_seq_out; dp->seq_out_parity = dap_swdptap_seq_out_parity; diff --git a/src/platforms/hosted/platform.c b/src/platforms/hosted/platform.c index d46e344f..8c4a1008 100644 --- a/src/platforms/hosted/platform.c +++ b/src/platforms/hosted/platform.c @@ -121,8 +121,6 @@ int platform_adiv5_swdp_scan(uint32_t targetid) { info.is_jtag = false; platform_max_frequency_set(cl_opts.opt_max_swj_frequency); - if (targetid && (info.bmp_type != BMP_TYPE_BMP)) - DEBUG_WARN("Ignoring TARGETID for now!\n"); switch (info.bmp_type) { case BMP_TYPE_BMP: case BMP_TYPE_LIBFTDI: diff --git a/src/target/adiv5_swdp.c b/src/target/adiv5_swdp.c index 7085f864..65986a80 100644 --- a/src/target/adiv5_swdp.c +++ b/src/target/adiv5_swdp.c @@ -108,8 +108,9 @@ int adiv5_swdp_scan(uint32_t targetid) uint32_t idcode = 0; volatile uint32_t target_id; bool is_v2 = true; - if (!targetid) { - /* Try to read ID */ + if (!targetid || (initial_dp->error != firmware_swdp_error)) { + /* No targetID given on the command line or probe can not + * handle multi-drop. Try to read ID */ dp_line_reset(initial_dp); volatile struct exception e; TRY_CATCH (e, EXCEPTION_ALL) { @@ -147,9 +148,11 @@ int adiv5_swdp_scan(uint32_t targetid) adiv5_dp_write(initial_dp, ADIV5_DP_CTRLSTAT, 0); break; } - if (!initial_dp->dp_low_read) - /* E.g. CMSIS_DAP < V1.2 can not handle multu-drop!*/ + if (initial_dp->error != firmware_swdp_error) { + DEBUG_WARN("CMSIS_DAP < V1.2 can not handle multi-drop!\n"); + /* E.g. CMSIS_DAP < V1.2 can not handle multi-drop!*/ is_v2 = false; + } } else { is_v2 = false; }