aboutsummaryrefslogtreecommitdiff
path: root/src/command.c
diff options
context:
space:
mode:
authorPaul Fertser2013-05-05 00:46:47 +0400
committerGareth McMullin2013-05-14 12:32:44 +1200
commite0fc21a2a715893331f49d9d838bc0d4a69cf84c (patch)
treec22d81dcee5ef48f414fb1da8b038aba368948ee /src/command.c
parent510d1c0dc845f860ff953168e3ae12528036070e (diff)
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 <fercerpav@gmail.com>
Diffstat (limited to 'src/command.c')
-rw-r--r--src/command.c13
1 files changed, 13 insertions, 0 deletions
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)
{