Hello!
This is a small patch that will let you program the chip via the
Robokits USB Programmer in HID mode. It seems to work with the
existing avrdoper driver but the driver doesn't recognize the programmer
because it looks for a fixed vendor/product id. This patch adds Robokits'
vendor/product id to the checks. In addition I removed the code that performs
a check for vendor/product name. Just for simplicity - if it's required someone
can merge that in.
Greetings,
Janne Junnila
--- avrdude-5.8/ser_avrdoper.c 2009-07-11 01:48:48.000000000 +0300
+++ avrdude-5.8.new/ser_avrdoper.c 2009-08-07 15:11:55.000000000 +0300
@@ -51,8 +51,11 @@
#define USB_ERROR_BUSY 16
#define USB_ERROR_IO 5
-#define USB_VENDOR_ID 0x16c0
-#define USB_PRODUCT_ID 0x05df
+#define USB_VENDOR_ID_OBDEV_AT 0x16c0
+#define USB_PRODUCT_ID_AVR_DOPER 0x05df
+#define USB_VENDOR_ID_ROBOKITS 0x20a7
+#define USB_PRODUCT_ID_ROBOKITS 0x0264
+
static int reportDataSizes[4] = {13, 29, 61, 125};
@@ -100,8 +103,7 @@
*ascii++ = 0;
}
-static int usbOpenDevice(union filedescriptor *fdp, int vendor, char *vendorName,
- int product, char *productName, int usesReportIDs)
+static int usbOpenDevice(union filedescriptor *fdp, int usesReportIDs)
{
GUID hidGuid; /* GUID for HID driver */
HDEVINFO deviceInfoList;
@@ -147,30 +149,12 @@
HidD_GetAttributes(handle, &deviceAttributes);
DEBUG_PRINT(("device attributes: vid=%d pid=%d\n",
deviceAttributes.VendorID, deviceAttributes.ProductID));
- if(deviceAttributes.VendorID != vendor || deviceAttributes.ProductID != product)
+ if(!((deviceAttributes.VendorID == USB_VENDOR_ID_OBDEV_AT &&
+ deviceAttributes.ProductID == USB_PRODUCT_ID_AVR_DOPER) ||
+ (deviceAttributes.VendorID == USB_VENDOR_ID_ROBOKITS &&
+ deviceAttributes.ProductID == USB_PRODUCT_ID_ROBOKITS)))
continue; /* ignore this device */
errorCode = USB_ERROR_NOTFOUND;
- if(vendorName != NULL && productName != NULL){
- char buffer[512];
- if(!HidD_GetManufacturerString(handle, buffer, sizeof(buffer))){
- DEBUG_PRINT(("error obtaining vendor name\n"));
- errorCode = USB_ERROR_IO;
- continue;
- }
- convertUniToAscii(buffer);
- DEBUG_PRINT(("vendorName = \"%s\"\n", buffer));
- if(strcmp(vendorName, buffer) != 0)
- continue;
- if(!HidD_GetProductString(handle, buffer, sizeof(buffer))){
- DEBUG_PRINT(("error obtaining product name\n"));
- errorCode = USB_ERROR_IO;
- continue;
- }
- convertUniToAscii(buffer);
- DEBUG_PRINT(("productName = \"%s\"\n", buffer));
- if(strcmp(productName, buffer) != 0)
- continue;
- }
break; /* we have found the device we are looking for! */
}
SetupDiDestroyDeviceInfoList(deviceInfoList);
@@ -284,8 +268,7 @@
return i-1;
}
-static int usbOpenDevice(union filedescriptor *fdp, int vendor, char *vendorName,
- int product, char *productName, int doReportIDs)
+static int usbOpenDevice(union filedescriptor *fdp, int doReportIDs)
{
struct usb_bus *bus;
struct usb_device *dev;
@@ -301,7 +284,10 @@
usb_find_devices();
for(bus=usb_get_busses(); bus; bus=bus->next){
for(dev=bus->devices; dev; dev=dev->next){
- if(dev->descriptor.idVendor == vendor && dev->descriptor.idProduct == product){
+ if((dev->descriptor.idVendor == USB_VENDOR_ID_OBDEV_AT &&
+ dev->descriptor.idProduct == USB_PRODUCT_ID_AVR_DOPER) ||
+ (dev->descriptor.idVendor == USB_VENDOR_ID_ROBOKITS &&
+ dev->descriptor.idProduct == USB_PRODUCT_ID_ROBOKITS)){
char string[256];
int len;
handle = usb_open(dev); /* we need to open the device in order to query strings */
@@ -311,38 +297,7 @@
usb_strerror());
continue;
}
- if(vendorName == NULL && productName == NULL){ /* name does not matter */
- break;
- }
- /* now check whether the names match: */
- len = usbGetStringAscii(handle, dev->descriptor.iManufacturer,
- 0x0409, string, sizeof(string));
- if(len < 0){
- errorCode = USB_ERROR_IO;
- fprintf(stderr,
- "Warning: cannot query manufacturer for device: %s\n",
- usb_strerror());
- }else{
- errorCode = USB_ERROR_NOTFOUND;
- /* fprintf(stderr, "seen device from vendor ->%s<-\n", string); */
- if(strcmp(string, vendorName) == 0){
- len = usbGetStringAscii(handle, dev->descriptor.iProduct,
- 0x0409, string, sizeof(string));
- if(len < 0){
- errorCode = USB_ERROR_IO;
- fprintf(stderr,
- "Warning: cannot query product for device: %s\n",
- usb_strerror());
- }else{
- errorCode = USB_ERROR_NOTFOUND;
- /* fprintf(stderr, "seen product ->%s<-\n", string); */
- if(strcmp(string, productName) == 0)
- break;
- }
- }
- }
- usb_close(handle);
- handle = NULL;
+ break;
}
}
if(handle)
@@ -507,10 +462,8 @@
static void avrdoper_open(char *port, long baud, union filedescriptor *fdp)
{
int rval;
- char *vname = "obdev.at";
- char *devname = "AVR-Doper";
- rval = usbOpenDevice(fdp, USB_VENDOR_ID, vname, USB_PRODUCT_ID, devname, 1);
+ rval = usbOpenDevice(fdp, 1);
if(rval != 0){
fprintf(stderr, "%s: avrdoper_open(): %s\n", progname, usbErrorText(rval));
exit(1);
_______________________________________________
avrdude-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avrdude-dev