summaryrefslogtreecommitdiff
path: root/examples/fxload.c
diff options
context:
space:
mode:
authorPete Batard <pete@akeo.ie>2013-04-14 22:38:52 +0100
committerPete Batard <pete@akeo.ie>2013-04-14 22:38:52 +0100
commit77a37cba5493de44f042095d69aaa200d9ff5fd5 (patch)
tree82bc41b1fa96c484517b864849394876d30deb87 /examples/fxload.c
parente68c66679293a86da62a2636df54b43bbde1daa4 (diff)
downloadlibusb-77a37cba5493de44f042095d69aaa200d9ff5fd5.tar.gz
Samples: Fix timeout error on FX3 and logging improvements for fxload
* Add a specific ezusb_fx3_jump() that handles timeout as a non-error This is required as a successful jump call makes the device disconnect from the bus * Set default verbosity to 1 and adjust some messages' verbosity level * Add a new -q option to decrease verbosity * Add readout of the bootloader version for FX3 devices * Filter the image types actually supported for FX3 * Fix the "errcode shadows a global variable" warning on some systems
Diffstat (limited to 'examples/fxload.c')
-rw-r--r--examples/fxload.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/examples/fxload.c b/examples/fxload.c
index 8537ca2..d8e9941 100644
--- a/examples/fxload.c
+++ b/examples/fxload.c
@@ -64,15 +64,16 @@ void logerror(const char *format, ...)
va_end(ap);
}
-static int print_usage(int errcode) {
+static int print_usage(int error_code) {
fprintf(stderr, "\nUsage: fxload [-v] [-V] [-t type] [-d vid:pid] [-p bus,addr] -i firmware\n");
fprintf(stderr, " -i <path> -- Firmware to upload\n");
fprintf(stderr, " -t <type> -- Target type: an21, fx, fx2, fx2lp, fx3\n");
fprintf(stderr, " -d <vid:pid> -- Target device, as an USB VID:PID\n");
fprintf(stderr, " -p <bus,addr> -- Target device, as a libusbx bus number and device address path\n");
fprintf(stderr, " -v -- Increase verbosity\n");
+ fprintf(stderr, " -q -- Decrease verbosity (silent mode)\n");
fprintf(stderr, " -V -- Print program version\n");
- return errcode;
+ return error_code;
}
#define FIRMWARE 0
@@ -94,7 +95,7 @@ int main(int argc, char*argv[])
libusb_device_handle *device = NULL;
struct libusb_device_descriptor desc;
- while ((opt = getopt(argc, argv, "vV?hd:p:i:I:t:")) != EOF)
+ while ((opt = getopt(argc, argv, "qvV?hd:p:i:I:t:")) != EOF)
switch (opt) {
case 'd':
@@ -130,6 +131,10 @@ int main(int argc, char*argv[])
verbose++;
break;
+ case 'q':
+ verbose--;
+ break;
+
case '?':
case 'h':
default:
@@ -184,8 +189,8 @@ int main(int argc, char*argv[])
} else {
status = libusb_get_device_descriptor(dev, &desc);
if (status >= 0) {
- if (verbose >= 2) {
- logerror("trying to match against %04x:%04x (%d,%d)\n",
+ if (verbose >= 3) {
+ logerror("examining %04x:%04x (%d,%d)\n",
desc.idVendor, desc.idProduct, _busnum, _devaddr);
}
for (j=0; j<ARRAYSIZE(known_device); j++) {
@@ -274,7 +279,7 @@ int main(int argc, char*argv[])
}
/* single stage, put into internal memory */
- if (verbose)
+ if (verbose > 1)
logerror("single stage: load on-chip memory\n");
status = ezusb_load_ram(device, path[FIRMWARE], fx_type, img_type[FIRMWARE], 0);