tilib: add --require-fw-update option for forced image loading.

This commit is contained in:
Daniel Beer 2011-12-14 13:11:29 +13:00
parent 805b022a68
commit 82ec966d5e
4 changed files with 29 additions and 4 deletions

View File

@ -68,6 +68,7 @@ struct device_args {
const char *path; const char *path;
const char *forced_chip_id; const char *forced_chip_id;
const char *requested_serial; const char *requested_serial;
const char *require_fwupdate;
}; };
struct device_class { struct device_class {

View File

@ -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"); 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"); report_error(dev, "MSP430_FET_FwUpdate");
return -1; return -1;
} }
@ -511,11 +512,19 @@ static int do_init(struct tilib_device *dev, const struct device_args *args)
return -1; 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"); printc("FET firmware update is required.\n");
if (args->flags & DEVICE_FLAG_DO_FWUPDATE) { if (args->flags & DEVICE_FLAG_DO_FWUPDATE) {
if (do_fw_update(dev) < 0) { if (do_fw_update(dev, NULL) < 0) {
dev->MSP430_Close(0); dev->MSP430_Close(0);
return -1; return -1;
} }

View File

@ -72,6 +72,13 @@ List available USB devices and exit.
.IP "\-\-force-reset" .IP "\-\-force-reset"
When using a FET device, always send a reset during initialization. By When using a FET device, always send a reset during initialization. By
default, an initialization without reset will be tried first. 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" .IP "\-\-version"
Show program version and copyright information. Show program version and copyright information.
.SH DRIVERS .SH DRIVERS

View File

@ -111,6 +111,9 @@ static void usage(const char *progname)
" Force target reset in initialization sequence.\n" " Force target reset in initialization sequence.\n"
" --allow-fw-update\n" " --allow-fw-update\n"
" Update FET firmware (tilib only) if necessary.\n" " Update FET firmware (tilib only) if necessary.\n"
" --require-fw-update <image.txt>\n"
" Require FET firmware update (tilib only). The image must be\n"
" a TI Text file.\n"
" --version\n" " --version\n"
" Show copyright and version information.\n" " Show copyright and version information.\n"
"\n" "\n"
@ -180,6 +183,7 @@ static int parse_cmdline_args(int argc, char **argv,
{"long-password", 0, 0, 'P'}, {"long-password", 0, 0, 'P'},
{"force-reset", 0, 0, 'R'}, {"force-reset", 0, 0, 'R'},
{"allow-fw-update", 0, 0, 'A'}, {"allow-fw-update", 0, 0, 'A'},
{"require-fw-update", 1, 0, 'M'},
{NULL, 0, 0, 0} {NULL, 0, 0, 0}
}; };
int want_usb = 0; int want_usb = 0;
@ -213,6 +217,10 @@ static int parse_cmdline_args(int argc, char **argv,
args->devarg.flags |= DEVICE_FLAG_TTY; args->devarg.flags |= DEVICE_FLAG_TTY;
break; break;
case 'M':
args->devarg.require_fwupdate = optarg;
break;
case 'U': case 'U':
args->devarg.path = optarg; args->devarg.path = optarg;
want_usb = 1; want_usb = 1;