diff --git a/avrdude/ChangeLog b/avrdude/ChangeLog index 5de11b29..8588017e 100644 --- a/avrdude/ChangeLog +++ b/avrdude/ChangeLog @@ -1,3 +1,9 @@ +2013-01-29 Rene Liebscher + + patch #7932 Read USBtiny VID and PID from avrdude.conf if provided. + * avrdude.conf.in: added usbpid, usbvid to usbtiny + * usbtiny.[ch]: use usbpid, usbpid if provided in config file + 2013-01-26 Joerg Wunsch bug #38172: avrftdi: Incorrect information in avrdude.conf diff --git a/avrdude/avrdude.conf.in b/avrdude/avrdude.conf.in index 0eb79a9f..a7fe118b 100644 --- a/avrdude/avrdude.conf.in +++ b/avrdude/avrdude.conf.in @@ -714,6 +714,8 @@ programmer desc = "USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/"; type = "usbtiny"; connection_type = usb; + usbvid = 0x1781; + usbpid = 0x0c9f; ; programmer diff --git a/avrdude/usbtiny.c b/avrdude/usbtiny.c index 5a5c16a5..2825083e 100644 --- a/avrdude/usbtiny.c +++ b/avrdude/usbtiny.c @@ -204,6 +204,7 @@ static int usbtiny_open(PROGRAMMER* pgm, char* name) struct usb_device *dev = 0; char *bus_name = NULL; char *dev_name = NULL; + int vid, pid; // if no -P was given or '-P usb' was given if(strcmp(name, "usb") == 0) @@ -225,11 +226,22 @@ static int usbtiny_open(PROGRAMMER* pgm, char* name) PDATA(pgm)->usb_handle = NULL; + if (pgm->usbvid) + vid = pgm->usbvid; + else + vid = USBTINY_VENDOR_DEFAULT; + + if (pgm->usbpid) + pid = pgm->usbpid; + else + pid = USBTINY_PRODUCT_DEFAULT; + + // now we iterate through all the busses and devices for ( bus = usb_busses; bus; bus = bus->next ) { for ( dev = bus->devices; dev; dev = dev->next ) { - if (dev->descriptor.idVendor == USBTINY_VENDOR - && dev->descriptor.idProduct == USBTINY_PRODUCT ) { // found match? + if (dev->descriptor.idVendor == vid + && dev->descriptor.idProduct == pid ) { // found match? if(verbose) fprintf(stderr, "%s: usbdev_open(): Found USBtinyISP, bus:device: %s:%s\n", @@ -259,7 +271,7 @@ static int usbtiny_open(PROGRAMMER* pgm, char* name) } if (!PDATA(pgm)->usb_handle) { fprintf( stderr, "%s: Error: Could not find USBtiny device (0x%x/0x%x)\n", - progname, USBTINY_VENDOR, USBTINY_PRODUCT ); + progname, vid, pid ); return -1; } diff --git a/avrdude/usbtiny.h b/avrdude/usbtiny.h index 5bc5f827..1bf49fc2 100644 --- a/avrdude/usbtiny.h +++ b/avrdude/usbtiny.h @@ -25,8 +25,8 @@ // these are specifically assigned to USBtiny, // if you need your own VID and PIDs you can get them for cheap from // www.mecanique.co.uk so please don't reuse these. Thanks! -#define USBTINY_VENDOR 0x1781 -#define USBTINY_PRODUCT 0x0C9F +#define USBTINY_VENDOR_DEFAULT 0x1781 +#define USBTINY_PRODUCT_DEFAULT 0x0C9F // Generic requests to the USBtiny #define USBTINY_ECHO 0 // echo test