From 4765fd4c864c47d48754350c196bd5c5ce9c5ed9 Mon Sep 17 00:00:00 2001 From: Edward Fewell Date: Wed, 20 Jun 2018 20:22:04 -0500 Subject: Moved double nSRST workaround from script to XDS110 and CMSIS-DAP drivers --- openocd/src/jtag/drivers/cmsis_dap_usb.c | 18 ++++++++++++++++-- openocd/src/jtag/drivers/xds110.c | 17 +++++++++++++++-- openocd/src/target/startup.tcl | 9 +-------- openocd/tcl/target/ti_msp432.cfg | 5 ++--- 4 files changed, 34 insertions(+), 15 deletions(-) (limited to 'openocd') diff --git a/openocd/src/jtag/drivers/cmsis_dap_usb.c b/openocd/src/jtag/drivers/cmsis_dap_usb.c index dd37522..d1a9857 100644 --- a/openocd/src/jtag/drivers/cmsis_dap_usb.c +++ b/openocd/src/jtag/drivers/cmsis_dap_usb.c @@ -1003,11 +1003,25 @@ static void cmsis_dap_execute_reset(struct jtag_command *cmd) * there's no way to tristate them */ uint8_t pins = 0; - if (!cmd->cmd.reset->srst) - pins |= SWJ_PIN_SRST; + static bool first = true; + if (!cmd->cmd.reset->trst) pins |= SWJ_PIN_TRST; + if (!cmd->cmd.reset->srst) + pins |= SWJ_PIN_SRST; + else if (swd_mode) { + /* Always assert nSRST in SWD mode */ + /* pin = 0 */ + } else if (first) { + /* Assert nSRST in JTAG mode on first call */ + first = false; + } else { + /* Do not assert nSRST in JTAG mode on second call */ + pins |= SWJ_PIN_SRST; + first = true; + } + int retval = cmsis_dap_cmd_DAP_SWJ_Pins(pins, SWJ_PIN_TRST | SWJ_PIN_SRST, 0, NULL); if (retval != ERROR_OK) diff --git a/openocd/src/jtag/drivers/xds110.c b/openocd/src/jtag/drivers/xds110.c index 4a20f94..fe975a7 100644 --- a/openocd/src/jtag/drivers/xds110.c +++ b/openocd/src/jtag/drivers/xds110.c @@ -1594,6 +1594,8 @@ static void xds110_execute_reset(struct jtag_command *cmd) char trst; char srst; + static bool first = true; + if (cmd->cmd.reset->trst != -1) { if (cmd->cmd.reset->trst == 0) { /* Deassert nTRST (active low) */ @@ -1610,8 +1612,19 @@ static void xds110_execute_reset(struct jtag_command *cmd) /* Deassert nSRST (active low) */ srst = 1; } else { - /* Assert nSRST (active low) */ - srst = 0; + /* TODO: Workaround for double nSRST reset in JTAG mode */ + if (xds110.is_swd_mode) { + /* Always assert nSRST in SWD mode (active low) */ + srst = 0; + } else if (first) { + /* Assert nSRST first time in JTAG mode (active low) */ + srst = 0; + first = false; + } else { + /* Do not assert nSRST second time in JTAG mode (active low) */ + srst = 1; + first = true; + } } (void)xds_set_srst(srst); diff --git a/openocd/src/target/startup.tcl b/openocd/src/target/startup.tcl index 6290b3a..247eff7 100644 --- a/openocd/src/target/startup.tcl +++ b/openocd/src/target/startup.tcl @@ -80,14 +80,7 @@ proc ocd_process_reset_inner { MODE } { foreach t $targets { # C code needs to know if we expect to 'halt' if {![using_jtag] || [jtag tapisenabled [$t cget -chain-position]]} { - # TODO: Workaround for double nSRST pulse issue. The call to - # init_reset above will assert and deassert nSRST. But the - # steps to examine and restore debug connection only happen just - # after that point. This arp_reset call will assert nSRST again - # but examination will not happen again. Also, some of the events - # that fire need the target scan chain to be examined. - # So comment out this second nSRST assert as a quick workaround. - # $t arp_reset assert $halt + $t arp_reset assert $halt } } foreach t $targets { diff --git a/openocd/tcl/target/ti_msp432.cfg b/openocd/tcl/target/ti_msp432.cfg index 523371d..47ae8b7 100644 --- a/openocd/tcl/target/ti_msp432.cfg +++ b/openocd/tcl/target/ti_msp432.cfg @@ -46,6 +46,5 @@ $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE set _FLASHNAME $_CHIPNAME.flash flash bank $_FLASHNAME msp432 0 0 0 0 $_TARGETNAME -if { ![using_hla] } { - cortex_m reset_config sysresetreq -} +reset_config srst_only +adapter_nsrst_delay 100 -- cgit v1.2.3-54-g00ecf