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 <ionut.nicu@mindbit.ro>
This commit is contained in:
Ionut Nicu 2011-03-23 17:13:03 +02:00 committed by Daniel Beer
parent 5c0a57254c
commit d5ecb69633
3 changed files with 9 additions and 1 deletions

View File

@ -59,6 +59,7 @@ struct device_breakpoint {
#define DEVICE_FLAG_JTAG 0x01 /* default is SBW */ #define DEVICE_FLAG_JTAG 0x01 /* default is SBW */
#define DEVICE_FLAG_LONG_PW 0x02 #define DEVICE_FLAG_LONG_PW 0x02
#define DEVICE_FLAG_TTY 0x04 /* default is USB */ #define DEVICE_FLAG_TTY 0x04 /* default is USB */
#define DEVICE_FLAG_FORCE_RESET 0x08
struct device_args { struct device_args {
int flags; int flags;

2
fet.c
View File

@ -978,7 +978,7 @@ int try_open(struct fet_device *dev, const struct device_args *args,
if (do_configure(dev, args) < 0) if (do_configure(dev, args) < 0)
return -1; return -1;
if (send_reset) { if (send_reset || args->flags & DEVICE_FLAG_FORCE_RESET) {
printc_dbg("Sending reset...\n"); printc_dbg("Sending reset...\n");
if (xfer(dev, C_RESET, NULL, 0, 3, FET_RESET_ALL, 0, 0) < 0) if (xfer(dev, C_RESET, NULL, 0, 3, FET_RESET_ALL, 0, 0) < 0)
printc_err("warning: fet: reset failed\n"); printc_err("warning: fet: reset failed\n");

7
main.c
View File

@ -102,6 +102,8 @@ static void usage(const char *progname)
" Override the device ID returned by the FET.\n" " Override the device ID returned by the FET.\n"
" --usb-list\n" " --usb-list\n"
" Show a list of available USB devices.\n" " Show a list of available USB devices.\n"
" --force-reset\n"
" Force target reset in initialization sequence.\n"
" --version\n" " --version\n"
" Show copyright and version information.\n" " Show copyright and version information.\n"
"\n" "\n"
@ -169,6 +171,7 @@ static int parse_cmdline_args(int argc, char **argv,
{"usb-list", 0, 0, 'I'}, {"usb-list", 0, 0, 'I'},
{"version", 0, 0, 'V'}, {"version", 0, 0, 'V'},
{"long-password", 0, 0, 'P'}, {"long-password", 0, 0, 'P'},
{"force-reset", 0, 0, 'R'},
{NULL, 0, 0, 0} {NULL, 0, 0, 0}
}; };
int want_usb = 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; args->devarg.flags |= DEVICE_FLAG_LONG_PW;
break; break;
case 'R':
args->devarg.flags |= DEVICE_FLAG_FORCE_RESET;
break;
case '?': case '?':
printc_err("Try --help for usage information.\n"); printc_err("Try --help for usage information.\n");
return -1; return -1;