Improve error messaging for serial number mismatch

As advised by @MX682X
This commit is contained in:
stefanrueger
2025-10-30 10:31:28 +01:00
parent e73695f013
commit 0e87b1f7c9

View File

@@ -573,6 +573,7 @@ static int pickit5_open(PROGRAMMER *pgm, const char *port) {
union pinfo pinfo;
LNODEID usbpid;
int rv = LIBAVRDUDE_GENERAL_FAILURE;
size_t serial_num_len = 0;
#if !defined(HAVE_LIBUSB)
pmsg_error("need to be compiled with USB or HIDAPI support\n");
@@ -580,7 +581,7 @@ static int pickit5_open(PROGRAMMER *pgm, const char *port) {
#endif
if(!str_starts(port, "usb:") && !str_eq(port, "usb")) {
pmsg_error("invalid -P %s; use -P usb:<vid>:<pid>, -P usb:<serialno> or -P usb\n", port);
pmsg_error("invalid -P %s; drop -P option or else use -P usb:<vid>:<pid> or -P usb:<serialno>\n", port);
return LIBAVRDUDE_GENERAL_FAILURE;
}
unsigned int new_vid = 0, new_pid = 0, setids = 0;
@@ -627,8 +628,10 @@ static int pickit5_open(PROGRAMMER *pgm, const char *port) {
pmsg_notice("overwriting VID:PID to %04x:%04x\n", new_vid, new_pid);
port = "usb"; // Overwrite the string to avoid confusing the libusb
} // pidp == NULL means vidp could point to serial number
} // vidp == NULL means just 'usb'
} else { // pidp == NULL means vidp points to serial number
serial_num_len = strlen(vidp);
}
} // vidp == NULL means dropped -P option or -P usb
// If the config entry did not specify a USB PID, insert the default one
if(lfirst(pgm->usbpid) == NULL)
@@ -728,6 +731,11 @@ static int pickit5_open(PROGRAMMER *pgm, const char *port) {
serial_close(&pgm->fd);
return LIBAVRDUDE_EXIT;
}
if(serial_num_len) {
pmsg_error("no device found matching the specified serial number %s", vidp);
return LIBAVRDUDE_GENERAL_FAILURE;
}
pmsg_error("no device found matching VID 0x%04x and PID list: 0x%04x, 0x%04x, 0x%04x\n", USB_VENDOR_MICROCHIP,
USB_DEVICE_PICKIT5, USB_DEVICE_PICKIT4_PIC_MODE, USB_DEVICE_SNAP_PIC_MODE);
imsg_error("nor VID 0x%04x with PID list: 0x%04x, 0x%04x\n", USB_VENDOR_ATMEL, USB_DEVICE_PICKIT4_AVR_MODE, USB_DEVICE_SNAP_AVR_MODE);