* usbasp.c: USB vid/pid/vendor/product from config file are used, for

id "usbasp" nibobee and old usbasp are tried as they were currently
  implemented within usbasp
* avrdude.conf.in: added usb params to "usbasp", added new entry "nibobee"
  with params which were hardcoded in usbasp.c, and added an entry
  "usbasb-clone" which only checks vid/pid.



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1040 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Rene Liebscher 2012-01-17 17:37:23 +00:00
parent f39e538c6b
commit 572d3236bf
3 changed files with 152 additions and 86 deletions

View File

@ -1,3 +1,12 @@
2012-01-17 Rene Liebscher <R.Liebscher@gmx.de>
* usbasp.c: USB vid/pid/vendor/product from config file are used, for
id "usbasp" nibobee and old usbasp are tried as they were currently
implemented within usbasp
* avrdude.conf.in: added usb params to "usbasp", added new entry "nibobee"
with params which were hardcoded in usbasp.c, and added an entry
"usbasb-clone" which only checks vid/pid.
2012-01-10 Rene Liebscher <R.Liebscher@gmx.de> 2012-01-10 Rene Liebscher <R.Liebscher@gmx.de>
bug #35261 avrftdi uses wrong interface in avrftdi_paged_(write|load) bug #35261 avrftdi uses wrong interface in avrftdi_paged_(write|load)

View File

@ -570,6 +570,44 @@ programmer
id = "usbasp"; id = "usbasp";
desc = "USBasp, http://www.fischl.de/usbasp/"; desc = "USBasp, http://www.fischl.de/usbasp/";
type = usbasp; type = usbasp;
usbvid = 0x16C0; # VOTI
usbpid = 0x05DC; # Obdev's free shared PID
usbvendor = "www.fischl.de";
usbproduct = "USBasp";
# following variants are autodetected for id "usbasp"
# original usbasp from fischl.de
# see above "usbasp"
# old usbasp from fischl.de
#usbvid = 0x03EB; # ATMEL
#usbpid = 0xC7B4; # (unoffical) USBasp
#usbvendor = "www.fischl.de";
#usbproduct = "USBasp";
# NIBObee (only if -P nibobee is given on command line)
# see below "nibobee"
;
programmer
id = "nibobee";
desc = "NIBObee";
type = usbasp;
usbvid = 0x16C0; # VOTI
usbpid = 0x092F; # NIBObee PID
usbvendor = "www.nicai-systems.com";
usbproduct = "NIBObee";
;
programmer
id = "usbasp-clone";
desc = "Any usbasp clone with correct VID/PID";
type = usbasp;
usbvid = 0x16C0; # VOTI
usbpid = 0x05DC; # Obdev's free shared PID
#usbvendor = "";
#usbproduct = "";
; ;
programmer programmer

View File

@ -263,41 +263,44 @@ static int usbOpenDevice(libusb_device_handle **device, int vendor,
progname, strerror(libusb_to_errno(r))); progname, strerror(libusb_to_errno(r)));
continue; continue;
} }
if (vendorName == NULL && productName == NULL) { errorCode = 0;
/* name does not matter */
break;
}
/* now check whether the names match: */ /* now check whether the names match: */
/* if vendorName not given ignore it (any vendor matches) */
r = libusb_get_string_descriptor_ascii(handle, descriptor.iManufacturer & 0xff, string, sizeof(string)); r = libusb_get_string_descriptor_ascii(handle, descriptor.iManufacturer & 0xff, string, sizeof(string));
if (r < 0) { if (r < 0) {
if ((vendorName != NULL) && (vendorName[0] != 0)) {
errorCode = USB_ERROR_IO; errorCode = USB_ERROR_IO;
fprintf(stderr, fprintf(stderr,
"%s: Warning: cannot query manufacturer for device: %s\n", "%s: Warning: cannot query manufacturer for device: %s\n",
progname, strerror(libusb_to_errno(r))); progname, strerror(libusb_to_errno(r)));
}
} else { } else {
errorCode = USB_ERROR_NOTFOUND;
if (verbose > 1) if (verbose > 1)
fprintf(stderr, fprintf(stderr,
"%s: seen device from vendor ->%s<-\n", "%s: seen device from vendor ->%s<-\n",
progname, string); progname, string);
if (strcmp(string, vendorName) == 0){ if ((vendorName != NULL) && (vendorName[0] != 0) && (strcmp(string, vendorName) != 0))
errorCode = USB_ERROR_NOTFOUND;
}
/* if productName not given ignore it (any product matches) */
r = libusb_get_string_descriptor_ascii(handle, descriptor.iProduct & 0xff, string, sizeof(string)); r = libusb_get_string_descriptor_ascii(handle, descriptor.iProduct & 0xff, string, sizeof(string));
if (r < 0) { if (r < 0) {
if ((productName != NULL) && (productName[0] != 0)) {
errorCode = USB_ERROR_IO; errorCode = USB_ERROR_IO;
fprintf(stderr, fprintf(stderr,
"%s: Warning: cannot query product for device: %s\n", "%s: Warning: cannot query product for device: %s\n",
progname, strerror(libusb_to_errno(r))); progname, strerror(libusb_to_errno(r)));
}
} else { } else {
errorCode = USB_ERROR_NOTFOUND;
if (verbose > 1) if (verbose > 1)
fprintf(stderr, fprintf(stderr,
"%s: seen product ->%s<-\n", "%s: seen product ->%s<-\n",
progname, string); progname, string);
if(strcmp(string, productName) == 0) if((productName != NULL) && (productName[0] != 0) && (strcmp(string, productName) != 0))
errorCode = USB_ERROR_NOTFOUND;
}
if (errorCode == 0)
break; break;
}
}
}
libusb_close(handle); libusb_close(handle);
handle = NULL; handle = NULL;
} }
@ -339,43 +342,46 @@ static int didUsbInit = 0;
progname, usb_strerror()); progname, usb_strerror());
continue; continue;
} }
if(vendorName == NULL && productName == NULL){ errorCode = 0;
/* name does not matter */
break;
}
/* now check whether the names match: */ /* now check whether the names match: */
/* if vendorName not given ignore it (any vendor matches) */
len = usb_get_string_simple(handle, dev->descriptor.iManufacturer, len = usb_get_string_simple(handle, dev->descriptor.iManufacturer,
string, sizeof(string)); string, sizeof(string));
if(len < 0){ if(len < 0){
if ((vendorName != NULL) && (vendorName[0] != 0)) {
errorCode = USB_ERROR_IO; errorCode = USB_ERROR_IO;
fprintf(stderr, fprintf(stderr,
"%s: Warning: cannot query manufacturer for device: %s\n", "%s: Warning: cannot query manufacturer for device: %s\n",
progname, usb_strerror()); progname, usb_strerror());
}
} else { } else {
errorCode = USB_ERROR_NOTFOUND;
if (verbose > 1) if (verbose > 1)
fprintf(stderr, fprintf(stderr,
"%s: seen device from vendor ->%s<-\n", "%s: seen device from vendor ->%s<-\n",
progname, string); progname, string);
if(strcmp(string, vendorName) == 0){ if((vendorName != NULL) && (vendorName[0] != 0) && (strcmp(string, vendorName) != 0))
errorCode = USB_ERROR_NOTFOUND;
}
/* if productName not given ignore it (any product matches) */
len = usb_get_string_simple(handle, dev->descriptor.iProduct, len = usb_get_string_simple(handle, dev->descriptor.iProduct,
string, sizeof(string)); string, sizeof(string));
if(len < 0){ if(len < 0){
if ((productName != NULL) && (productName[0] != 0)) {
errorCode = USB_ERROR_IO; errorCode = USB_ERROR_IO;
fprintf(stderr, fprintf(stderr,
"%s: Warning: cannot query product for device: %s\n", "%s: Warning: cannot query product for device: %s\n",
progname, usb_strerror()); progname, usb_strerror());
}
} else { } else {
errorCode = USB_ERROR_NOTFOUND;
if (verbose > 1) if (verbose > 1)
fprintf(stderr, fprintf(stderr,
"%s: seen product ->%s<-\n", "%s: seen product ->%s<-\n",
progname, string); progname, string);
if(strcmp(string, productName) == 0) if((productName != NULL) && (productName[0] != 0) && (strcmp(string, productName) != 0))
errorCode = USB_ERROR_NOTFOUND;
}
if (errorCode == 0)
break; break;
}
}
}
usb_close(handle); usb_close(handle);
handle = NULL; handle = NULL;
} }
@ -400,7 +406,16 @@ static int usbasp_open(PROGRAMMER * pgm, char * port)
#else #else
usb_init(); usb_init();
#endif #endif
if (usbOpenDevice(&PDATA(pgm)->usbhandle, pgm->usbvid, pgm->usbvendor,
pgm->usbpid, pgm->usbproduct) != 0) {
/* try alternatives */
if(strcasecmp(ldata(lfirst(pgm->id)), "usbasp") == 0) {
/* for id usbasp autodetect some variants */
if(strcasecmp(port, "nibobee") == 0) { if(strcasecmp(port, "nibobee") == 0) {
fprintf(stderr,
"%s: warning: Using \"-C usbasp -P nibobee\" is deprecated,"
"use \"-C nibobee\" instead.\n",
progname);
if (usbOpenDevice(&PDATA(pgm)->usbhandle, USBASP_NIBOBEE_VID, "www.nicai-systems.com", if (usbOpenDevice(&PDATA(pgm)->usbhandle, USBASP_NIBOBEE_VID, "www.nicai-systems.com",
USBASP_NIBOBEE_PID, "NIBObee") != 0) { USBASP_NIBOBEE_PID, "NIBObee") != 0) {
fprintf(stderr, fprintf(stderr,
@ -408,30 +423,34 @@ static int usbasp_open(PROGRAMMER * pgm, char * port)
"\"NIBObee\" with vid=0x%x pid=0x%x\n", "\"NIBObee\" with vid=0x%x pid=0x%x\n",
progname, USBASP_NIBOBEE_VID, USBASP_NIBOBEE_PID); progname, USBASP_NIBOBEE_VID, USBASP_NIBOBEE_PID);
return -1; return -1;
} }
} else if (usbOpenDevice(&PDATA(pgm)->usbhandle, USBASP_SHARED_VID, "www.fischl.de", return 0;
USBASP_SHARED_PID, "USBasp") != 0) { }
/* check if device with old VID/PID is available */ /* check if device with old VID/PID is available */
if (usbOpenDevice(&PDATA(pgm)->usbhandle, USBASP_OLD_VID, "www.fischl.de", if (usbOpenDevice(&PDATA(pgm)->usbhandle, USBASP_OLD_VID, "www.fischl.de",
USBASP_OLD_PID, "USBasp") != 0) { USBASP_OLD_PID, "USBasp") == 0) {
/* no USBasp found */
fprintf(stderr,
"%s: error: could not find USB device "
"\"USBasp\" with vid=0x%x pid=0x%x\n",
progname, USBASP_SHARED_VID, USBASP_SHARED_PID);
return -1;
} else {
/* found USBasp with old IDs */ /* found USBasp with old IDs */
fprintf(stderr, fprintf(stderr,
"%s: Warning: Found USB device \"USBasp\" with " "%s: Warning: Found USB device \"USBasp\" with "
"old VID/PID! Please update firmware of USBasp!\n", "old VID/PID! Please update firmware of USBasp!\n",
progname); progname);
return 0;
} }
/* original USBasp is specified in config file, so no need to check it again here */
/* no alternative found => fall through to generic error message */
}
fprintf(stderr,
"%s: error: could not find USB device with vid=0x%x pid=0x%x",
progname, pgm->usbvid, pgm->usbpid);
if (pgm->usbvendor[0] != 0) {
fprintf(stderr, " vendor='%s'", pgm->usbvendor);
}
if (pgm->usbproduct[0] != 0) {
fprintf(stderr, " product='%s'", pgm->usbproduct);
}
fprintf(stderr,"\n");
return -1;
} }
return 0; return 0;