X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Ftarget%2Fadi_v5_swd.c;h=c503f090b8dd4e0e105a725658eec6297c301941;hb=a640f139baa9fe4f44d428b1e4e1a9da245532ca;hp=60223f91163c134f7f8f4aa2034c24243051476c;hpb=d0e763ac7ef6aa17b17bd00ccdfbccfb4eacda69;p=openocd.git diff --git a/src/target/adi_v5_swd.c b/src/target/adi_v5_swd.c index 60223f9116..c503f090b8 100644 --- a/src/target/adi_v5_swd.c +++ b/src/target/adi_v5_swd.c @@ -107,12 +107,24 @@ static int swd_connect(struct adiv5_dap *dap) * MUST READ DPIDR */ + /* Check if we should reset srst already when connecting, but not if reconnecting. */ + if (!dap->do_reconnect) { + enum reset_types jtag_reset_config = jtag_get_reset_config(); + + if (jtag_reset_config & RESET_CNCT_UNDER_SRST) { + if (jtag_reset_config & RESET_SRST_NO_GATING) + swd_add_reset(1); + else + LOG_WARNING("\'srst_nogate\' reset_config option is required"); + } + } + /* Note, debugport_init() does setup too */ jtag_interface->swd->switch_seq(JTAG_TO_SWD); /* Clear link state, including the SELECT cache. */ dap->do_reconnect = false; - dap->select = DP_SELECT_INVALID; + dap_invalidate_cache(dap); swd_queue_dp_read(dap, DP_DPIDR, &dpidr); @@ -412,8 +424,13 @@ static int swd_init(struct command_context *ctx) /* Force the DAP's ops vector for SWD mode. * messy - is there a better way? */ arm->dap->ops = &swd_dap_ops; + /* First connect after init is not reconnecting. */ + dap->do_reconnect = false; - return swd_connect(dap); + int retval = swd_connect(dap); + if (retval != ERROR_OK) + LOG_ERROR("SWD connect failed"); + return retval; } static struct transport swd_transport = {