diff --git a/drivers/device.h b/drivers/device.h index 3a1cffb..708b50a 100644 --- a/drivers/device.h +++ b/drivers/device.h @@ -68,6 +68,7 @@ struct device_args { const char *path; const char *forced_chip_id; const char *requested_serial; + const char *require_fwupdate; }; struct device_class { diff --git a/drivers/tilib.c b/drivers/tilib.c index d859db7..1607cd9 100644 --- a/drivers/tilib.c +++ b/drivers/tilib.c @@ -482,10 +482,11 @@ static void fw_progress(unsigned int msg_id, unsigned long w_param, } } -static int do_fw_update(struct tilib_device *dev) +static int do_fw_update(struct tilib_device *dev, const char *filename) { printc("Starting firmware update (this may take some time)...\n"); - if (dev->MSP430_FET_FwUpdate(NULL, fw_progress, (long)dev) < 0) { + if (dev->MSP430_FET_FwUpdate((char *)filename, + fw_progress, (long)dev) < 0) { report_error(dev, "MSP430_FET_FwUpdate"); return -1; } @@ -511,11 +512,19 @@ static int do_init(struct tilib_device *dev, const struct device_args *args) return -1; } - if (version < 0) { + if (args->require_fwupdate) { + printc("Updating firmware using %s\n", + args->require_fwupdate); + + if (do_fw_update(dev, args->require_fwupdate) < 0) { + dev->MSP430_Close(0); + return -1; + } + } else if (version < 0) { printc("FET firmware update is required.\n"); if (args->flags & DEVICE_FLAG_DO_FWUPDATE) { - if (do_fw_update(dev) < 0) { + if (do_fw_update(dev, NULL) < 0) { dev->MSP430_Close(0); return -1; } diff --git a/mspdebug.man b/mspdebug.man index 868f25c..a8e6233 100644 --- a/mspdebug.man +++ b/mspdebug.man @@ -72,6 +72,13 @@ List available USB devices and exit. .IP "\-\-force-reset" When using a FET device, always send a reset during initialization. By default, an initialization without reset will be tried first. +.IP "\-\-allow-fw-update" +When using a V3 FET device via the TI library, allow the library to +perform a firmware update if the FET firmware is incompatible with the +library. +.IP "\-\-require-fw-update \fIimage.txt\fR" +When using a V3 FET device, force a firmware update using the given +firmware image. The firmware file must be in TI Text format. .IP "\-\-version" Show program version and copyright information. .SH DRIVERS diff --git a/ui/main.c b/ui/main.c index dcbbfb6..3ca7160 100644 --- a/ui/main.c +++ b/ui/main.c @@ -111,6 +111,9 @@ static void usage(const char *progname) " Force target reset in initialization sequence.\n" " --allow-fw-update\n" " Update FET firmware (tilib only) if necessary.\n" +" --require-fw-update \n" +" Require FET firmware update (tilib only). The image must be\n" +" a TI Text file.\n" " --version\n" " Show copyright and version information.\n" "\n" @@ -180,6 +183,7 @@ static int parse_cmdline_args(int argc, char **argv, {"long-password", 0, 0, 'P'}, {"force-reset", 0, 0, 'R'}, {"allow-fw-update", 0, 0, 'A'}, + {"require-fw-update", 1, 0, 'M'}, {NULL, 0, 0, 0} }; int want_usb = 0; @@ -213,6 +217,10 @@ static int parse_cmdline_args(int argc, char **argv, args->devarg.flags |= DEVICE_FLAG_TTY; break; + case 'M': + args->devarg.require_fwupdate = optarg; + break; + case 'U': args->devarg.path = optarg; want_usb = 1;