From e0fc21a2a715893331f49d9d838bc0d4a69cf84c Mon Sep 17 00:00:00 2001 From: Paul Fertser Date: Sun, 5 May 2013 00:46:47 +0400 Subject: adiv5_swdp: allow to connect to a sleeping target by pulling SRST This patch introduces a new command, "connect_srst [enable|disable]" which allows to enable special mode in which SRST would be pulled low before the SWD scan till attaching to a target. Since on Cortex-Mx the SRST signal doesn't gate JTAG and SWD, it's possible to connect to a target while holding reset, ask it to stop at reset vector and only then deassert reset, thus allowing to attach to the kind of firmware that goes immediately to sleep or disables debugging by other means early on start. Tested on an STM32VLDiscovery board with STM32F100 configured to go to STOP mode and executing WFI in the very beginning of main(). Signed-off-by: Paul Fertser --- src/command.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/command.c') diff --git a/src/command.c b/src/command.c index e1ed837..e9f7096 100644 --- a/src/command.c +++ b/src/command.c @@ -46,6 +46,7 @@ static bool cmd_jtag_scan(target *t, int argc, char **argv); static bool cmd_swdp_scan(void); static bool cmd_targets(target *t); static bool cmd_morse(void); +static bool cmd_connect_srst(target *t, int argc, const char **argv); #ifdef PLATFORM_HAS_TRACESWO static bool cmd_traceswo(void); #endif @@ -57,6 +58,7 @@ const struct command_s cmd_list[] = { {"swdp_scan", (cmd_handler)cmd_swdp_scan, "Scan SW-DP for devices" }, {"targets", (cmd_handler)cmd_targets, "Display list of available targets" }, {"morse", (cmd_handler)cmd_morse, "Display morse error message" }, + {"connect_srst", (cmd_handler)cmd_connect_srst, "Configure connect under SRST: (enable|disable)" }, #ifdef PLATFORM_HAS_TRACESWO {"traceswo", (cmd_handler)cmd_traceswo, "Start trace capture" }, #endif @@ -209,6 +211,17 @@ bool cmd_morse(void) return true; } +static bool cmd_connect_srst(target *t, int argc, const char **argv) +{ + (void)t; + if (argc == 1) + gdb_outf("Assert SRST during connect: %s\n", + connect_assert_srst ? "enabled" : "disabled"); + else + connect_assert_srst = !strcmp(argv[1], "enable"); + return true; +} + #ifdef PLATFORM_HAS_TRACESWO static bool cmd_traceswo(void) { -- cgit v1.2.3