From d5ecb6963319c1b91c6ec1616eabc77eefa7bd15 Mon Sep 17 00:00:00 2001 From: Ionut Nicu Date: Wed, 23 Mar 2011 17:13:03 +0200 Subject: [PATCH] Add --force-reset option Without this option MSP430F5526 fails to reset its registers properly. When the SP register points to a random address and we try to set a breakpoint with gdb, it will try to read all memory locations from SP up to the top of the RAM searching for the return address in the current stack frame. On MSP430F47173 initialization fails when not using reset (command C_IDENT1 failed) and we also need to fall back to using try_open with send_reset = 1. Signed-off-by: Ionut Nicu --- device.h | 1 + fet.c | 2 +- main.c | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/device.h b/device.h index f2cc8c5..2b11be2 100644 --- a/device.h +++ b/device.h @@ -59,6 +59,7 @@ struct device_breakpoint { #define DEVICE_FLAG_JTAG 0x01 /* default is SBW */ #define DEVICE_FLAG_LONG_PW 0x02 #define DEVICE_FLAG_TTY 0x04 /* default is USB */ +#define DEVICE_FLAG_FORCE_RESET 0x08 struct device_args { int flags; diff --git a/fet.c b/fet.c index 77933ac..f411096 100644 --- a/fet.c +++ b/fet.c @@ -978,7 +978,7 @@ int try_open(struct fet_device *dev, const struct device_args *args, if (do_configure(dev, args) < 0) return -1; - if (send_reset) { + if (send_reset || args->flags & DEVICE_FLAG_FORCE_RESET) { printc_dbg("Sending reset...\n"); if (xfer(dev, C_RESET, NULL, 0, 3, FET_RESET_ALL, 0, 0) < 0) printc_err("warning: fet: reset failed\n"); diff --git a/main.c b/main.c index ee6aefb..b2953b7 100644 --- a/main.c +++ b/main.c @@ -102,6 +102,8 @@ static void usage(const char *progname) " Override the device ID returned by the FET.\n" " --usb-list\n" " Show a list of available USB devices.\n" +" --force-reset\n" +" Force target reset in initialization sequence.\n" " --version\n" " Show copyright and version information.\n" "\n" @@ -169,6 +171,7 @@ static int parse_cmdline_args(int argc, char **argv, {"usb-list", 0, 0, 'I'}, {"version", 0, 0, 'V'}, {"long-password", 0, 0, 'P'}, + {"force-reset", 0, 0, 'R'}, {NULL, 0, 0, 0} }; int want_usb = 0; @@ -234,6 +237,10 @@ static int parse_cmdline_args(int argc, char **argv, args->devarg.flags |= DEVICE_FLAG_LONG_PW; break; + case 'R': + args->devarg.flags |= DEVICE_FLAG_FORCE_RESET; + break; + case '?': printc_err("Try --help for usage information.\n"); return -1;