diff --git a/src/dfu.c b/src/dfu.c index 2334c687..a5d21d8a 100644 --- a/src/dfu.c +++ b/src/dfu.c @@ -101,7 +101,7 @@ struct dfu_dev *dfu_open(const char *port_spec) { */ if(!str_starts(port_spec, "usb:") && !str_eq(port_spec, "usb")) { - pmsg_error("port name %s must be usb::\n", port_spec); + pmsg_error("invalid -P %s; drop this option or use -P usb::\n", port_spec); return NULL; } @@ -146,7 +146,7 @@ int dfu_init(struct dfu_dev *dfu, unsigned short vid, unsigned short pid) { */ if(pid == 0 && dfu->dev_name == NULL) { - pmsg_error("no DFU support for part; specify in config or USB address via -P usb::\n"); + pmsg_error("no DFU support for part; specify in config or USB address via -P usb::\n"); return -1; } diff --git a/src/micronucleus.c b/src/micronucleus.c index d2e0a5b7..e3186aaa 100644 --- a/src/micronucleus.c +++ b/src/micronucleus.c @@ -585,6 +585,11 @@ static int micronucleus_open(PROGRAMMER *pgm, const char *port) { struct pdata *pdata = &my; const char *bus_name = NULL, *dev_name = NULL; + if(!str_starts(port, "usb:") && !str_eq(port, "usb")) { + pmsg_error("invalid -P %s; drop this option or use -P usb::\n", port); + return -1; + } + // Calculate bus and device names from -P usb:: option if present if(str_starts(port, "usb:")) { bus_name = port + 4; @@ -683,7 +688,7 @@ static int micronucleus_open(PROGRAMMER *pgm, const char *port) { } if(bus_name && !dev_name) { // Delayed error message, so found devices are printed with -P usb:xyz - pmsg_error("invalid -P %s; use -P usb::\n", port); + pmsg_error("invalid -P %s; use -P usb:: or -P usb\n", port); return -1; } diff --git a/src/pickit5.c b/src/pickit5.c index 01969554..ce9b8ce0 100644 --- a/src/pickit5.c +++ b/src/pickit5.c @@ -580,7 +580,7 @@ static int pickit5_open(PROGRAMMER *pgm, const char *port) { #endif if(!str_starts(port, "usb:") && !str_eq(port, "usb")) { - pmsg_error("port name %s must be usb:: or usb:\n", port); + pmsg_error("invalid -P %s; use -P usb::, -P usb: or -P usb\n", port); return -1; } unsigned int new_vid = 0, new_pid = 0, setids = 0; @@ -612,7 +612,7 @@ static int pickit5_open(PROGRAMMER *pgm, const char *port) { if(vidp != pidp) { // User specified an VID // First: Handle VID input if(sscanf(vidp, "%x", &new_vid) != 1) { - pmsg_error("failed to parse -P VID input %s: unexpected format\n", vidp); + pmsg_error("failed to parse -P VID input %s: expected hexadecimal number\n", vidp); return -1; } } else { // VID space empty: default to Microchip @@ -621,7 +621,7 @@ static int pickit5_open(PROGRAMMER *pgm, const char *port) { // Now handle PID input if(sscanf(pidp + 1, "%x", &new_pid) != 1) { - pmsg_error("failed to parse -P PID input %s: unexpected format\n", pidp+1); + pmsg_error("failed to parse -P PID input %s: expected hexadecimal number\n", pidp+1); return -1; } diff --git a/src/usbasp.c b/src/usbasp.c index 034659fe..7aefafb9 100644 --- a/src/usbasp.c +++ b/src/usbasp.c @@ -620,6 +620,11 @@ static int usbasp_open(PROGRAMMER *pgm, const char *port) { if(pgm->bitclock && !(pgm->extra_features & HAS_BITCLOCK_ADJ)) pmsg_warning("setting bitclock despite HAS_BITCLOCK_ADJ missing in pgm->extra_features\n"); + if(!str_starts(port, "usb:") && !str_eq(port, "usb")) { + pmsg_error("invalid -P %s; use -P usb::, -P usb: or -P usb\n", port); + return -1; + } + // usb_init will be done in usbOpenDevice LNODEID usbpid = lfirst(pgm->usbpid); int pid, vid; @@ -649,11 +654,6 @@ static int usbasp_open(PROGRAMMER *pgm, const char *port) { */ } - if(!str_starts(port, "usb:") && !str_eq(port, "usb")) { - pmsg_error("invalid -P %s; use -P usb:: or -P usb:\n", port); - return -1; - } - pmsg_error("cannot find USB device with vid=0x%x pid=0x%x", vid, pid); if(pgm->usbvendor && *pgm->usbvendor) msg_error(" vendor='%s'", pgm->usbvendor); diff --git a/src/usbtiny.c b/src/usbtiny.c index 6e027e88..f2b493e0 100644 --- a/src/usbtiny.c +++ b/src/usbtiny.c @@ -287,6 +287,11 @@ static int usbtiny_open(PROGRAMMER *pgm, const char *port) { pmsg_debug("%s(\"%s\")\n", __func__, port); + if(!str_starts(port, "usb:") && !str_eq(port, "usb")) { + pmsg_error("invalid -P %s; drop this option or use -P usb::\n", port); + return -1; + } + // Calculate bus and device names from -P usb:: option if present if(str_starts(port, "usb:")) { bus_name = port + 4; @@ -338,7 +343,7 @@ static int usbtiny_open(PROGRAMMER *pgm, const char *port) { } if(bus_name && !dev_name) { // Delayed error message, so found devices are printed with -P usb:xyz - pmsg_error("invalid -P %s; use -P usb::\n", port); + pmsg_error("invalid -P %s; use -P usb:: or -P usb\n", port); return -1; }