From df6f0ec3bc1335b020d09fd825e23b755fe1a62f Mon Sep 17 00:00:00 2001 From: Daniel Beer Date: Tue, 21 May 2013 15:59:17 +1200 Subject: [PATCH] Add --fet-skip-close option. Supplying this option causes the JTAG close procedure to be skipped when closing the FET driver. --- drivers/device.c | 5 ----- drivers/device.h | 6 +----- drivers/fet_core.c | 5 ++++- drivers/fet_core.h | 3 +++ mspdebug.man | 3 +++ ui/main.c | 8 ++++++++ 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/device.c b/drivers/device.c index 71e84c7..33f5e48 100644 --- a/drivers/device.c +++ b/drivers/device.c @@ -144,8 +144,3 @@ int device_erase(device_erase_type_t et, address_t addr) return device_default->type->erase(device_default, et, addr); } - -int device_needs_skip_close(device_t dev) -{ - return (dev->dev_id[0] == 0x51) && (dev->dev_id[1] == 0x37); -} diff --git a/drivers/device.h b/drivers/device.h index 27d4ae7..0e6e03e 100644 --- a/drivers/device.h +++ b/drivers/device.h @@ -70,6 +70,7 @@ struct device_breakpoint { #define DEVICE_FLAG_TTY 0x04 /* default is USB */ #define DEVICE_FLAG_FORCE_RESET 0x08 #define DEVICE_FLAG_DO_FWUPDATE 0x10 +#define DEVICE_FLAG_SKIP_CLOSE 0x20 struct device_args { int flags; @@ -140,11 +141,6 @@ int device_probe_id(device_t dev); */ int device_is_fram(device_t dev); -/* Determine, from the device ID bytes, whether this chip has problems - * with the FET close procedure. - */ -int device_needs_skip_close(device_t dev); - /* Set or clear a breakpoint. The index of the modified entry is * returned, or -1 if no free entries were available. The modified * entry is flagged so that it will be reloaded on the next run. diff --git a/drivers/fet_core.c b/drivers/fet_core.c index a0156b1..41c6503 100644 --- a/drivers/fet_core.c +++ b/drivers/fet_core.c @@ -717,7 +717,7 @@ void fet_destroy(device_t dev_base) { struct fet_device *dev = (struct fet_device *)dev_base; - if (device_needs_skip_close(dev_base)) { + if (dev->fet_flags & FET_SKIP_CLOSE) { printc_dbg("Skipping close procedure\n"); } else { /* The second argument to C_RESET is a boolean which @@ -1020,6 +1020,9 @@ device_t fet_open(const struct device_args *args, struct fet_device *dev = malloc(sizeof(*dev)); int i; + if (args->flags & DEVICE_FLAG_SKIP_CLOSE) + fet_flags |= FET_SKIP_CLOSE; + if (!dev) { pr_error("fet: failed to allocate memory"); return NULL; diff --git a/drivers/fet_core.h b/drivers/fet_core.h index ee2dde2..82f10d0 100644 --- a/drivers/fet_core.h +++ b/drivers/fet_core.h @@ -22,6 +22,9 @@ #include "device.h" #include "transport.h" +/* Don't attempt to close JTAG on exit */ +#define FET_SKIP_CLOSE 0x04 + /* The new identify method should always be used */ #define FET_IDENTIFY_NEW 0x08 diff --git a/mspdebug.man b/mspdebug.man index 9256240..b8fcc6c 100644 --- a/mspdebug.man +++ b/mspdebug.man @@ -73,6 +73,9 @@ When using a FET device, force the connected chip to be recognised by MSPDebug as one of the given type during initialization. This overrides the device ID returned by the FET. The given string should be a chip name in long form, for example "MSP430F2274". +.IP "\-\-fet\-skip\-close" +When using a FET device, skip the JTAG close procedure when disconnecting. +With some boards, this removes the need to replug the debugger after use. .IP "\-\-usb\-list" List available USB devices and exit. .IP "\-\-force-reset" diff --git a/ui/main.c b/ui/main.c index fba774a..a28d6ff 100644 --- a/ui/main.c +++ b/ui/main.c @@ -118,6 +118,8 @@ static void usage(const char *progname) " Show a list of devices supported by the FET driver.\n" " --fet-force-id string\n" " Override the device ID returned by the FET.\n" +" --fet-skip-close\n" +" Skip the JTAG close procedure when using the FET driver.\n" " --usb-list\n" " Show a list of available USB devices.\n" " --force-reset\n" @@ -221,6 +223,7 @@ static int parse_cmdline_args(int argc, char **argv, LOPT_HELP = 0x100, LOPT_FET_LIST, LOPT_FET_FORCE_ID, + LOPT_FET_SKIP_CLOSE, LOPT_USB_LIST, LOPT_VERSION, LOPT_LONG_PASSWORD, @@ -234,6 +237,7 @@ static int parse_cmdline_args(int argc, char **argv, {"help", 0, 0, LOPT_HELP}, {"fet-list", 0, 0, LOPT_FET_LIST}, {"fet-force-id", 1, 0, LOPT_FET_FORCE_ID}, + {"fet-skip-close", 0, 0, LOPT_FET_SKIP_CLOSE}, {"usb-list", 0, 0, LOPT_USB_LIST}, {"version", 0, 0, LOPT_VERSION}, {"long-password", 0, 0, LOPT_LONG_PASSWORD}, @@ -304,6 +308,10 @@ static int parse_cmdline_args(int argc, char **argv, args->devarg.forced_chip_id = optarg; break; + case LOPT_FET_SKIP_CLOSE: + args->devarg.flags |= DEVICE_FLAG_SKIP_CLOSE; + break; + case LOPT_HELP: usage(argv[0]); exit(0);