Turn the usbpid parameter of the programmer into a list of PIDs. Make

the JTAGICE3 programmer handle a list of PIDs, by trying each of them
in sequence.  Use a single, central jtag3_open_common() function to
handle the common code of all jtag3_open_* functions.  Centralize all
USB VID/PID definitions in usbdevs.h.



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1283 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
joerg_wunsch 2014-02-27 13:06:03 +00:00
parent 52c59fade2
commit 7999eaa25a
19 changed files with 223 additions and 233 deletions

View File

@ -1,3 +1,29 @@
2014-02-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* config_gram.y: Turn the usbpid parameter of the programmer into
a list of PIDs. Make the JTAGICE3 programmer handle a list of
PIDs, by trying each of them in sequence. Use a single, central
jtag3_open_common() function to handle the common code of all
jtag3_open_* functions. Centralize all USB VID/PID definitions in
usbdevs.h.
* flip1.c: (Dito.)
* ft245r.c: (Dito.)
* stk500v2.c: (Dito.)
* jtag3.c: (Dito.)
* jtag3.h: (Dito.)
* flip2.c: (Dito.)
* usbdevs.h: (Dito.)
* pgm.c: (Dito.)
* serial.h: (Dito.)
* pgm.h: (Dito.)
* usbtiny.c: (Dito.)
* usbasp.c: (Dito.)
* avrftdi.c: (Dito.)
* usbtiny.h: (Dito.)
* avrdude.conf.in: (Dito.)
* usbasp.h: (Dito.)
* usb_libusb.c: (Dito.)
2014-02-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de> 2014-02-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* usb_libusb.c (usbdev_open): Replace all calls to exit(1) by * usb_libusb.c (usbdev_open): Replace all calls to exit(1) by

View File

@ -31,7 +31,7 @@
# pgmled = <num> ; # pin number # pgmled = <num> ; # pin number
# vfyled = <num> ; # pin number # vfyled = <num> ; # pin number
# usbvid = <hexnum>; # USB VID (Vendor ID) # usbvid = <hexnum>; # USB VID (Vendor ID)
# usbpid = <hexnum>; # USB PID (Product ID) # usbpid = <hexnum> [, <hexnum> ...] # USB PID (Product ID) (1)
# usbdev = <interface>; # USB interface or other device info # usbdev = <interface>; # USB interface or other device info
# usbvendor = <vendorname>; # USB Vendor Name # usbvendor = <vendorname>; # USB Vendor Name
# usbproduct = <productname>; # USB Product Name # usbproduct = <productname>; # USB Product Name
@ -41,6 +41,8 @@
# For a pin list all pins must be inverted. # For a pin list all pins must be inverted.
# A single pin can be specified as usual = ~ <num>, for lists # A single pin can be specified as usual = ~ <num>, for lists
# specify it as follows = ~ ( <num> [, <num2> ... ] ) . # specify it as follows = ~ ( <num> [, <num2> ... ] ) .
#
# (1) Not all programmer types can process a list of PIDs.
# ; # ;
# #
# part # part
@ -994,7 +996,7 @@ programmer
desc = "Atmel AVR JTAGICE3 in JTAG mode"; desc = "Atmel AVR JTAGICE3 in JTAG mode";
type = "jtagice3"; type = "jtagice3";
connection_type = usb; connection_type = usb;
usbpid = 0x2110; usbpid = 0x2110, 0x2140;
; ;
programmer programmer
@ -1002,7 +1004,7 @@ programmer
desc = "Atmel AVR JTAGICE3 in PDI mode"; desc = "Atmel AVR JTAGICE3 in PDI mode";
type = "jtagice3_pdi"; type = "jtagice3_pdi";
connection_type = usb; connection_type = usb;
usbpid = 0x2110; usbpid = 0x2110, 0x2140;
; ;
programmer programmer
@ -1010,7 +1012,7 @@ programmer
desc = "Atmel AVR JTAGICE3 in debugWIRE mode"; desc = "Atmel AVR JTAGICE3 in debugWIRE mode";
type = "jtagice3_dw"; type = "jtagice3_dw";
connection_type = usb; connection_type = usb;
usbpid = 0x2110; usbpid = 0x2110, 0x2140;
; ;
programmer programmer
@ -1018,39 +1020,7 @@ programmer
desc = "Atmel AVR JTAGICE3 in ISP mode"; desc = "Atmel AVR JTAGICE3 in ISP mode";
type = "jtagice3_isp"; type = "jtagice3_isp";
connection_type = usb; connection_type = usb;
usbpid = 0x2110; usbpid = 0x2110, 0x2140;
;
programmer
id = "jtag3edbg";
desc = "Atmel AVR JTAGICE3 in JTAG mode, EDBG protocol";
type = "jtagice3";
connection_type = usb;
usbpid = 0x2140;
;
programmer
id = "jtag3pdi_edbg";
desc = "Atmel AVR JTAGICE3 in PDI mode, EDBG protocol";
type = "jtagice3_pdi";
connection_type = usb;
usbpid = 0x2140;
;
programmer
id = "jtag3dw_edbg";
desc = "Atmel AVR JTAGICE3 in debugWIRE mode, EDBG protocol";
type = "jtagice3_dw";
connection_type = usb;
usbpid = 0x2140;
;
programmer
id = "jtag3isp_edbg";
desc = "Atmel AVR JTAGICE3 in ISP mode, EDBG protocol";
type = "jtagice3_isp";
connection_type = usb;
usbpid = 0x2140;
; ;
programmer programmer

View File

@ -41,6 +41,7 @@
#include "avrpart.h" #include "avrpart.h"
#include "avrftdi_tpi.h" #include "avrftdi_tpi.h"
#include "avrftdi_private.h" #include "avrftdi_private.h"
#include "usbdevs.h"
#ifndef MAX #ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b)) #define MAX(a,b) ((a)>(b)?(a):(b))
@ -666,12 +667,17 @@ static int avrftdi_open(PROGRAMMER * pgm, char *port)
if (pgm->usbvid) if (pgm->usbvid)
vid = pgm->usbvid; vid = pgm->usbvid;
else else
vid = 0x0403; vid = USB_VENDOR_FTDI;
if (pgm->usbpid) LNODEID usbpid = lfirst(pgm->usbpid);
pid = pgm->usbpid; if (usbpid) {
else pid = *(int *)(ldata(usbpid));
pid = 0x6010; if (lnext(usbpid))
fprintf(stderr,
"%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
progname, pid);
} else
pid = USB_DEVICE_FT2232;
if (0 == pgm->usbsn[0]) /* we don't care about SN. Use first avail. */ if (0 == pgm->usbsn[0]) /* we don't care about SN. Use first avail. */
serial = NULL; serial = NULL;

View File

@ -515,12 +515,7 @@ prog_parm_usb:
free_token($3); free_token($3);
} }
} | } |
K_USBPID TKN_EQUAL TKN_NUMBER { K_USBPID TKN_EQUAL usb_pid_list |
{
current_prog->usbpid = $3->value.number;
free_token($3);
}
} |
K_USBSN TKN_EQUAL TKN_STRING { K_USBSN TKN_EQUAL TKN_STRING {
{ {
strncpy(current_prog->usbsn, $3->value.string, PGM_USBSTRINGLEN); strncpy(current_prog->usbsn, $3->value.string, PGM_USBSTRINGLEN);
@ -544,6 +539,29 @@ prog_parm_usb:
} }
; ;
usb_pid_list:
TKN_NUMBER {
{
int *ip = malloc(sizeof(int));
if (ip) {
*ip = $1->value.number;
ladd(current_prog->usbpid, ip);
}
free_token($1);
}
} |
usb_pid_list TKN_COMMA TKN_NUMBER {
{
int *ip = malloc(sizeof(int));
if (ip) {
*ip = $3->value.number;
ladd(current_prog->usbpid, ip);
}
free_token($3);
}
}
;
pin_number_non_empty: pin_number_non_empty:
TKN_NUMBER { assign_pin(pin_name, $1, 0); } TKN_NUMBER { assign_pin(pin_name, $1, 0); }
| |

12
flip1.c
View File

@ -235,8 +235,16 @@ int flip1_initialize(PROGRAMMER* pgm, AVRPART *part)
*/ */
vid = (pgm->usbvid != 0) ? pgm->usbvid : USB_VENDOR_ATMEL; vid = (pgm->usbvid != 0) ? pgm->usbvid : USB_VENDOR_ATMEL;
pid = (pgm->usbpid != 0) ? pgm->usbpid : part->usbpid; LNODEID usbpid = lfirst(pgm->usbpid);
if (usbpid) {
pid = *(int *)(ldata(usbpid));
if (lnext(usbpid))
fprintf(stderr,
"%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
progname, pid);
} else {
pid = part->usbpid;
}
if (!ovsigck && (part->flags & AVRPART_HAS_PDI)) { if (!ovsigck && (part->flags & AVRPART_HAS_PDI)) {
fprintf(stderr, fprintf(stderr,
"%s: \"flip1\" (FLIP protocol version 1) is for AT90USB* and ATmega*U* devices.\n" "%s: \"flip1\" (FLIP protocol version 1) is for AT90USB* and ATmega*U* devices.\n"

11
flip2.c
View File

@ -229,7 +229,16 @@ int flip2_initialize(PROGRAMMER* pgm, AVRPART *part)
*/ */
vid = (pgm->usbvid != 0) ? pgm->usbvid : USB_VENDOR_ATMEL; vid = (pgm->usbvid != 0) ? pgm->usbvid : USB_VENDOR_ATMEL;
pid = (pgm->usbpid != 0) ? pgm->usbpid : part->usbpid; LNODEID usbpid = lfirst(pgm->usbpid);
if (usbpid) {
pid = *(int *)(ldata(usbpid));
if (lnext(usbpid))
fprintf(stderr,
"%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
progname, pid);
} else {
pid = part->usbpid;
}
if (!ovsigck && !(part->flags & AVRPART_HAS_PDI)) { if (!ovsigck && !(part->flags & AVRPART_HAS_PDI)) {
fprintf(stderr, fprintf(stderr,

View File

@ -68,6 +68,7 @@
#include "config.h" #include "config.h"
#include "bitbang.h" #include "bitbang.h"
#include "ft245r.h" #include "ft245r.h"
#include "usbdevs.h"
#if defined(_WIN32) #if defined(_WIN32)
#include <windows.h> #include <windows.h>
@ -557,9 +558,20 @@ static int ft245r_open(PROGRAMMER * pgm, char * port) {
handle = malloc (sizeof (struct ftdi_context)); handle = malloc (sizeof (struct ftdi_context));
ftdi_init(handle); ftdi_init(handle);
LNODEID usbpid = lfirst(pgm->usbpid);
int pid;
if (usbpid) {
pid = *(int *)(ldata(usbpid));
if (lnext(usbpid))
fprintf(stderr,
"%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
progname, pid);
} else {
pid = USB_DEVICE_FT245;
}
rv = ftdi_usb_open_desc_index(handle, rv = ftdi_usb_open_desc_index(handle,
pgm->usbvid?pgm->usbvid:0x0403, pgm->usbvid?pgm->usbvid:USB_VENDOR_FTDI,
pgm->usbpid?pgm->usbpid:0x6001, pid,
pgm->usbproduct[0]?pgm->usbproduct:NULL, pgm->usbproduct[0]?pgm->usbproduct:NULL,
pgm->usbsn[0]?pgm->usbsn:NULL, pgm->usbsn[0]?pgm->usbsn:NULL,
devnum); devnum);

182
jtag3.c
View File

@ -1279,43 +1279,58 @@ static int jtag3_parseextparms(PROGRAMMER * pgm, LISTID extparms)
return rv; return rv;
} }
int jtag3_open_common(PROGRAMMER * pgm, char * port)
static int jtag3_open(PROGRAMMER * pgm, char * port)
{ {
union pinfo pinfo; union pinfo pinfo;
LNODEID usbpid;
int rv = -1;
if (verbose >= 2) #if !defined(HAVE_LIBUSB)
fprintf(stderr, "%s: jtag3_open()\n", progname); fprintf(stderr, "avrdude was compiled without usb support.\n");
return -1;
#endif
/* if (strncmp(port, "usb", 3) != 0) {
* The serial_open() function for USB overrides fprintf(stderr,
* the meaning of the "baud" parameter to be the USB device ID to "%s: jtag3_open_common(): JTAGICE3/EDBG port names must start with \"usb\"\n",
* search for. progname);
*/ return -1;
if (strncmp(port, "usb", 3) == 0) { }
#if defined(HAVE_LIBUSB)
serdev = &usb_serdev_frame; serdev = &usb_serdev_frame;
if (pgm->usbvid) if (pgm->usbvid)
pinfo.usbinfo.vid = pgm->usbvid; pinfo.usbinfo.vid = pgm->usbvid;
else else
pinfo.usbinfo.vid = USB_VENDOR_ATMEL; pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
pinfo.usbinfo.flags = 0;
if (pgm->usbpid) /* If the config entry did not specify a USB PID, insert the default one. */
pinfo.usbinfo.pid = pgm->usbpid; if (lfirst(pgm->usbpid) == NULL)
else ladd(pgm->usbpid, (void *)USB_DEVICE_JTAGICE3);
pinfo.usbinfo.pid = USB_DEVICE_JTAGICE3;
for (usbpid = lfirst(pgm->usbpid); rv < 0 && usbpid != NULL; usbpid = lnext(usbpid)) {
pinfo.usbinfo.flags = PINFO_FL_SILENT;
pinfo.usbinfo.pid = *(int *)(ldata(usbpid));
pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_3; pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_3;
pgm->fd.usb.rep = USBDEV_BULK_EP_READ_3; pgm->fd.usb.rep = USBDEV_BULK_EP_READ_3;
pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_3; pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_3;
pgm->fd.usb.eep = USBDEV_EVT_EP_READ_3; pgm->fd.usb.eep = USBDEV_EVT_EP_READ_3;
#else
fprintf(stderr, "avrdude was compiled without usb support.\n");
return -1;
#endif
}
strcpy(pgm->port, port); strcpy(pgm->port, port);
if (serial_open(port, pinfo, &pgm->fd)==-1) { rv = serial_open(port, pinfo, &pgm->fd);
}
if (rv < 0) {
fprintf(stderr,
"%s: jtag3_open_common(): Did not find any device matching VID 0x%04x and PID list: ",
progname, (unsigned)pinfo.usbinfo.vid);
int notfirst = 0;
for (usbpid = lfirst(pgm->usbpid); usbpid != NULL; usbpid = lnext(usbpid)) {
if (notfirst)
fprintf(stderr, ", ");
fprintf(stderr, "0x%04x", (unsigned int)(*(int *)(ldata(usbpid))));
notfirst = 1;
}
fputc('\n', stderr);
return -1; return -1;
} }
@ -1335,6 +1350,19 @@ static int jtag3_open(PROGRAMMER * pgm, char * port)
*/ */
jtag3_drain(pgm, 0); jtag3_drain(pgm, 0);
return 0;
}
static int jtag3_open(PROGRAMMER * pgm, char * port)
{
if (verbose >= 2)
fprintf(stderr, "%s: jtag3_open()\n", progname);
if (jtag3_open_common(pgm, port) < 0)
return -1;
if (jtag3_getsync(pgm, PARM3_CONN_JTAG) < 0) if (jtag3_getsync(pgm, PARM3_CONN_JTAG) < 0)
return -1; return -1;
@ -1343,58 +1371,11 @@ static int jtag3_open(PROGRAMMER * pgm, char * port)
static int jtag3_open_dw(PROGRAMMER * pgm, char * port) static int jtag3_open_dw(PROGRAMMER * pgm, char * port)
{ {
union pinfo pinfo;
if (verbose >= 2) if (verbose >= 2)
fprintf(stderr, "%s: jtag3_open_dw()\n", progname); fprintf(stderr, "%s: jtag3_open_dw()\n", progname);
/* if (jtag3_open_common(pgm, port) < 0)
* The serial_open() function for USB overrides
* the meaning of the "baud" parameter to be the USB device ID to
* search for.
*/
if (strncmp(port, "usb", 3) == 0) {
#if defined(HAVE_LIBUSB)
serdev = &usb_serdev_frame;
if (pgm->usbvid)
pinfo.usbinfo.vid = pgm->usbvid;
else
pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
pinfo.usbinfo.flags = 0;
if (pgm->usbpid)
pinfo.usbinfo.pid = pgm->usbpid;
else
pinfo.usbinfo.pid = USB_DEVICE_JTAGICE3;
pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_3;
pgm->fd.usb.rep = USBDEV_BULK_EP_READ_3;
pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_3;
pgm->fd.usb.eep = USBDEV_EVT_EP_READ_3;
#else
fprintf(stderr, "avrdude was compiled without usb support.\n");
return -1; return -1;
#endif
}
strcpy(pgm->port, port);
if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1;
}
if (pgm->fd.usb.eep == 0)
{
/* The event EP has been deleted by usb_open(), so we are
running on a CMSIS-DAP device, using EDBG protocol */
pgm->flag |= PGM_FL_IS_EDBG;
if (verbose)
fprintf(stderr,
"%s: Found CMSIS-DAP compliant device, using EDBG protocol\n",
progname);
}
/*
* drain any extraneous input
*/
jtag3_drain(pgm, 0);
if (jtag3_getsync(pgm, PARM3_CONN_DW) < 0) if (jtag3_getsync(pgm, PARM3_CONN_DW) < 0)
return -1; return -1;
@ -1404,58 +1385,11 @@ static int jtag3_open_dw(PROGRAMMER * pgm, char * port)
static int jtag3_open_pdi(PROGRAMMER * pgm, char * port) static int jtag3_open_pdi(PROGRAMMER * pgm, char * port)
{ {
union pinfo pinfo;
if (verbose >= 2) if (verbose >= 2)
fprintf(stderr, "%s: jtag3_open_pdi()\n", progname); fprintf(stderr, "%s: jtag3_open_pdi()\n", progname);
/* if (jtag3_open_common(pgm, port) < 0)
* The serial_open() function for USB overrides
* the meaning of the "baud" parameter to be the USB device ID to
* search for.
*/
if (strncmp(port, "usb", 3) == 0) {
#if defined(HAVE_LIBUSB)
serdev = &usb_serdev_frame;
if (pgm->usbvid)
pinfo.usbinfo.vid = pgm->usbvid;
else
pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
pinfo.usbinfo.flags = 0;
if (pgm->usbpid)
pinfo.usbinfo.pid = pgm->usbpid;
else
pinfo.usbinfo.pid = USB_DEVICE_JTAGICE3;
pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_3;
pgm->fd.usb.rep = USBDEV_BULK_EP_READ_3;
pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_3;
pgm->fd.usb.eep = USBDEV_EVT_EP_READ_3;
#else
fprintf(stderr, "avrdude was compiled without usb support.\n");
return -1; return -1;
#endif
}
strcpy(pgm->port, port);
if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1;
}
if (pgm->fd.usb.eep == 0)
{
/* The event EP has been deleted by usb_open(), so we are
running on a CMSIS-DAP device, using EDBG protocol */
pgm->flag |= PGM_FL_IS_EDBG;
if (verbose)
fprintf(stderr,
"%s: Found CMSIS-DAP compliant device, using EDBG protocol\n",
progname);
}
/*
* drain any extraneous input
*/
jtag3_drain(pgm, 0);
if (jtag3_getsync(pgm, PARM3_CONN_PDI) < 0) if (jtag3_getsync(pgm, PARM3_CONN_PDI) < 0)
return -1; return -1;

View File

@ -25,6 +25,7 @@
extern "C" { extern "C" {
#endif #endif
int jtag3_open_common(PROGRAMMER * pgm, char * port);
int jtag3_send(PROGRAMMER * pgm, unsigned char * data, size_t len); int jtag3_send(PROGRAMMER * pgm, unsigned char * data, size_t len);
int jtag3_recv(PROGRAMMER * pgm, unsigned char **msg); int jtag3_recv(PROGRAMMER * pgm, unsigned char **msg);
void jtag3_close(PROGRAMMER * pgm); void jtag3_close(PROGRAMMER * pgm);

1
pgm.c
View File

@ -76,6 +76,7 @@ PROGRAMMER * pgm_new(void)
memset(pgm, 0, sizeof(*pgm)); memset(pgm, 0, sizeof(*pgm));
pgm->id = lcreat(NULL, 0); pgm->id = lcreat(NULL, 0);
pgm->usbpid = lcreat(NULL, 0);
pgm->desc[0] = 0; pgm->desc[0] = 0;
pgm->type[0] = 0; pgm->type[0] = 0;
pgm->config_file[0] = 0; pgm->config_file[0] = 0;

3
pgm.h
View File

@ -76,7 +76,8 @@ typedef struct programmer_t {
int ppidata; int ppidata;
int ppictrl; int ppictrl;
int baudrate; int baudrate;
int usbvid, usbpid; int usbvid;
LISTID usbpid;
char usbdev[PGM_USBSTRINGLEN], usbsn[PGM_USBSTRINGLEN]; char usbdev[PGM_USBSTRINGLEN], usbsn[PGM_USBSTRINGLEN];
char usbvendor[PGM_USBSTRINGLEN], usbproduct[PGM_USBSTRINGLEN]; char usbvendor[PGM_USBSTRINGLEN], usbproduct[PGM_USBSTRINGLEN];
double bitclock; /* JTAG ICE clock period in microseconds */ double bitclock; /* JTAG ICE clock period in microseconds */

View File

@ -54,6 +54,7 @@ union pinfo
unsigned short pid; unsigned short pid;
unsigned short flags; unsigned short flags;
#define PINFO_FL_USEHID 0x0001 #define PINFO_FL_USEHID 0x0001
#define PINFO_FL_SILENT 0x0002 /* don't complain if not found */
} usbinfo; } usbinfo;
}; };

View File

@ -602,8 +602,13 @@ static int stk500v2_jtag3_recv(PROGRAMMER * pgm, unsigned char *msg,
progname); progname);
return -1; return -1;
} }
/* Getting more data than expected is a normal case for the EDBG
implementation of JTAGICE3, as they always request a full 512
octets from the ICE. Thus, only complain at high verbose
levels. */
if (rv - 1 > maxsize) { if (rv - 1 > maxsize) {
fprintf(stderr, if (verbose > 2)
fprintf(stderr,
"%s: stk500v2_jtag3_recv(): got %u bytes, have only room for %u bytes\n", "%s: stk500v2_jtag3_recv(): got %u bytes, have only room for %u bytes\n",
progname, (unsigned)rv - 1, (unsigned)maxsize); progname, (unsigned)rv - 1, (unsigned)maxsize);
rv = maxsize; rv = maxsize;
@ -3662,43 +3667,14 @@ static int stk500v2_dragon_hv_open(PROGRAMMER * pgm, char * port)
*/ */
static int stk500v2_jtag3_open(PROGRAMMER * pgm, char * port) static int stk500v2_jtag3_open(PROGRAMMER * pgm, char * port)
{ {
union pinfo pinfo;
void *mycookie; void *mycookie;
int rv; int rv;
if (verbose >= 2) if (verbose >= 2)
fprintf(stderr, "%s: stk500v2_jtag3_open()\n", progname); fprintf(stderr, "%s: stk500v2_jtag3_open()\n", progname);
/* if (jtag3_open_common(pgm, port) < 0)
* The serial_open() function for USB overrides
* the meaning of the "baud" parameter to be the USB device ID to
* search for.
*/
if (strncmp(port, "usb", 3) == 0) {
#if defined(HAVE_LIBUSB)
serdev = &usb_serdev_frame;
pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
pinfo.usbinfo.flags = 0;
pinfo.usbinfo.pid = USB_DEVICE_JTAGICE3;
pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_3;
pgm->fd.usb.rep = USBDEV_BULK_EP_READ_3;
pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_3;
pgm->fd.usb.eep = USBDEV_EVT_EP_READ_3;
#else
fprintf(stderr, "avrdude was compiled without usb support.\n");
return -1; return -1;
#endif
}
strcpy(pgm->port, port);
if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1;
}
/*
* drain any extraneous input
*/
stk500v2_drain(pgm, 0);
mycookie = pgm->cookie; mycookie = pgm->cookie;
pgm->cookie = PDATA(pgm)->chained_pdata; pgm->cookie = PDATA(pgm)->chained_pdata;

View File

@ -310,8 +310,10 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
} }
} }
fprintf(stderr, "%s: usbdev_open(): did not find any%s USB device \"%s\"\n", if ((pinfo.usbinfo.flags & PINFO_FL_SILENT) == 0 || verbose > 0)
progname, serno? " (matching)": "", port); fprintf(stderr, "%s: usbdev_open(): did not find any%s USB device \"%s\" (0x%04x:0x%04x)\n",
progname, serno? " (matching)": "", port,
(unsigned)pinfo.usbinfo.vid, (unsigned)pinfo.usbinfo.pid);
return -1; return -1;
} }

View File

@ -38,6 +38,7 @@
#include "avr.h" #include "avr.h"
#include "pgm.h" #include "pgm.h"
#include "usbasp.h" #include "usbasp.h"
#include "usbdevs.h"
#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1_0) #if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1_0)
@ -464,8 +465,19 @@ static int usbasp_open(PROGRAMMER * pgm, char * port)
progname, port); progname, port);
/* usb_init will be done in usbOpenDevice */ /* usb_init will be done in usbOpenDevice */
if (usbOpenDevice(&PDATA(pgm)->usbhandle, pgm->usbvid, pgm->usbvendor, LNODEID usbpid = lfirst(pgm->usbpid);
pgm->usbpid, pgm->usbproduct) != 0) { int pid, vid;
if (usbpid) {
pid = *(int *)(ldata(usbpid));
if (lnext(usbpid))
fprintf(stderr,
"%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
progname, pid);
} else {
pid = USBASP_SHARED_PID;
}
vid = pgm->usbvid? pgm->usbvid: USBASP_SHARED_VID;
if (usbOpenDevice(&PDATA(pgm)->usbhandle, vid, pgm->usbvendor, pid, pgm->usbproduct) != 0) {
/* try alternatives */ /* try alternatives */
if(strcasecmp(ldata(lfirst(pgm->id)), "usbasp") == 0) { if(strcasecmp(ldata(lfirst(pgm->id)), "usbasp") == 0) {
/* for id usbasp autodetect some variants */ /* for id usbasp autodetect some variants */
@ -500,7 +512,7 @@ static int usbasp_open(PROGRAMMER * pgm, char * port)
fprintf(stderr, fprintf(stderr,
"%s: error: could not find USB device with vid=0x%x pid=0x%x", "%s: error: could not find USB device with vid=0x%x pid=0x%x",
progname, pgm->usbvid, pgm->usbpid); progname, vid, pid);
if (pgm->usbvendor[0] != 0) { if (pgm->usbvendor[0] != 0) {
fprintf(stderr, " vendor='%s'", pgm->usbvendor); fprintf(stderr, " vendor='%s'", pgm->usbvendor);
} }

View File

@ -23,16 +23,6 @@
#include "avrpart.h" #include "avrpart.h"
/* USB identifiers */
#define USBASP_SHARED_VID 0x16C0 /* VOTI */
#define USBASP_SHARED_PID 0x05DC /* Obdev's free shared PID */
#define USBASP_OLD_VID 0x03EB /* ATMEL */
#define USBASP_OLD_PID 0xC7B4 /* (unoffical) USBasp */
#define USBASP_NIBOBEE_VID 0x16C0 /* VOTI */
#define USBASP_NIBOBEE_PID 0x092F /* NIBObee PID */
/* USB function call identifiers */ /* USB function call identifiers */
#define USBASP_FUNC_CONNECT 1 #define USBASP_FUNC_CONNECT 1
#define USBASP_FUNC_DISCONNECT 2 #define USBASP_FUNC_DISCONNECT 2

View File

@ -34,6 +34,27 @@
#define USB_DEVICE_XPLAINEDPRO 0x2111 #define USB_DEVICE_XPLAINEDPRO 0x2111
#define USB_DEVICE_JTAG3_EDBG 0x2140 #define USB_DEVICE_JTAG3_EDBG 0x2140
#define USB_VENDOR_FTDI 0x0403
#define USB_DEVICE_FT2232 0x6010
#define USB_DEVICE_FT245 0x6001
#define USBASP_SHARED_VID 0x16C0 /* VOTI */
#define USBASP_SHARED_PID 0x05DC /* Obdev's free shared PID */
#define USBASP_OLD_VID 0x03EB /* ATMEL */
#define USBASP_OLD_PID 0xC7B4 /* (unoffical) USBasp */
#define USBASP_NIBOBEE_VID 0x16C0 /* VOTI */
#define USBASP_NIBOBEE_PID 0x092F /* NIBObee PID */
// 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_DEFAULT 0x1781
#define USBTINY_PRODUCT_DEFAULT 0x0C9F
/* JTAGICEmkII, AVRISPmkII */ /* JTAGICEmkII, AVRISPmkII */
#define USBDEV_BULK_EP_WRITE_MKII 0x02 #define USBDEV_BULK_EP_WRITE_MKII 0x02
#define USBDEV_BULK_EP_READ_MKII 0x82 #define USBDEV_BULK_EP_READ_MKII 0x82

View File

@ -37,6 +37,7 @@
#include "pgm.h" #include "pgm.h"
#include "config.h" #include "config.h"
#include "usbtiny.h" #include "usbtiny.h"
#include "usbdevs.h"
#if defined(HAVE_LIBUSB) // we use LIBUSB to talk to the board #if defined(HAVE_LIBUSB) // we use LIBUSB to talk to the board
#if defined(HAVE_USB_H) #if defined(HAVE_USB_H)
@ -230,11 +231,17 @@ static int usbtiny_open(PROGRAMMER* pgm, char* name)
vid = pgm->usbvid; vid = pgm->usbvid;
else else
vid = USBTINY_VENDOR_DEFAULT; vid = USBTINY_VENDOR_DEFAULT;
if (pgm->usbpid) LNODEID usbpid = lfirst(pgm->usbpid);
pid = pgm->usbpid; if (usbpid) {
else pid = *(int *)(ldata(usbpid));
if (lnext(usbpid))
fprintf(stderr,
"%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
progname, pid);
} else {
pid = USBTINY_PRODUCT_DEFAULT; pid = USBTINY_PRODUCT_DEFAULT;
}
// now we iterate through all the busses and devices // now we iterate through all the busses and devices

View File

@ -22,11 +22,6 @@
#include "avrpart.h" #include "avrpart.h"
// 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_DEFAULT 0x1781
#define USBTINY_PRODUCT_DEFAULT 0x0C9F
// Generic requests to the USBtiny // Generic requests to the USBtiny
#define USBTINY_ECHO 0 // echo test #define USBTINY_ECHO 0 // echo test