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:
parent
52c59fade2
commit
7999eaa25a
26
ChangeLog
26
ChangeLog
|
@ -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>
|
||||
|
||||
* usb_libusb.c (usbdev_open): Replace all calls to exit(1) by
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
# pgmled = <num> ; # pin number
|
||||
# vfyled = <num> ; # pin number
|
||||
# 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
|
||||
# usbvendor = <vendorname>; # USB Vendor Name
|
||||
# usbproduct = <productname>; # USB Product Name
|
||||
|
@ -41,6 +41,8 @@
|
|||
# For a pin list all pins must be inverted.
|
||||
# A single pin can be specified as usual = ~ <num>, for lists
|
||||
# specify it as follows = ~ ( <num> [, <num2> ... ] ) .
|
||||
#
|
||||
# (1) Not all programmer types can process a list of PIDs.
|
||||
# ;
|
||||
#
|
||||
# part
|
||||
|
@ -994,7 +996,7 @@ programmer
|
|||
desc = "Atmel AVR JTAGICE3 in JTAG mode";
|
||||
type = "jtagice3";
|
||||
connection_type = usb;
|
||||
usbpid = 0x2110;
|
||||
usbpid = 0x2110, 0x2140;
|
||||
;
|
||||
|
||||
programmer
|
||||
|
@ -1002,7 +1004,7 @@ programmer
|
|||
desc = "Atmel AVR JTAGICE3 in PDI mode";
|
||||
type = "jtagice3_pdi";
|
||||
connection_type = usb;
|
||||
usbpid = 0x2110;
|
||||
usbpid = 0x2110, 0x2140;
|
||||
;
|
||||
|
||||
programmer
|
||||
|
@ -1010,7 +1012,7 @@ programmer
|
|||
desc = "Atmel AVR JTAGICE3 in debugWIRE mode";
|
||||
type = "jtagice3_dw";
|
||||
connection_type = usb;
|
||||
usbpid = 0x2110;
|
||||
usbpid = 0x2110, 0x2140;
|
||||
;
|
||||
|
||||
programmer
|
||||
|
@ -1018,39 +1020,7 @@ programmer
|
|||
desc = "Atmel AVR JTAGICE3 in ISP mode";
|
||||
type = "jtagice3_isp";
|
||||
connection_type = usb;
|
||||
usbpid = 0x2110;
|
||||
;
|
||||
|
||||
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;
|
||||
usbpid = 0x2110, 0x2140;
|
||||
;
|
||||
|
||||
programmer
|
||||
|
|
16
avrftdi.c
16
avrftdi.c
|
@ -41,6 +41,7 @@
|
|||
#include "avrpart.h"
|
||||
#include "avrftdi_tpi.h"
|
||||
#include "avrftdi_private.h"
|
||||
#include "usbdevs.h"
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) ((a)>(b)?(a):(b))
|
||||
|
@ -666,12 +667,17 @@ static int avrftdi_open(PROGRAMMER * pgm, char *port)
|
|||
if (pgm->usbvid)
|
||||
vid = pgm->usbvid;
|
||||
else
|
||||
vid = 0x0403;
|
||||
vid = USB_VENDOR_FTDI;
|
||||
|
||||
if (pgm->usbpid)
|
||||
pid = pgm->usbpid;
|
||||
else
|
||||
pid = 0x6010;
|
||||
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 = USB_DEVICE_FT2232;
|
||||
|
||||
if (0 == pgm->usbsn[0]) /* we don't care about SN. Use first avail. */
|
||||
serial = NULL;
|
||||
|
|
|
@ -515,12 +515,7 @@ prog_parm_usb:
|
|||
free_token($3);
|
||||
}
|
||||
} |
|
||||
K_USBPID TKN_EQUAL TKN_NUMBER {
|
||||
{
|
||||
current_prog->usbpid = $3->value.number;
|
||||
free_token($3);
|
||||
}
|
||||
} |
|
||||
K_USBPID TKN_EQUAL usb_pid_list |
|
||||
K_USBSN TKN_EQUAL TKN_STRING {
|
||||
{
|
||||
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:
|
||||
TKN_NUMBER { assign_pin(pin_name, $1, 0); }
|
||||
|
|
||||
|
|
12
flip1.c
12
flip1.c
|
@ -235,8 +235,16 @@ int flip1_initialize(PROGRAMMER* pgm, AVRPART *part)
|
|||
*/
|
||||
|
||||
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)) {
|
||||
fprintf(stderr,
|
||||
"%s: \"flip1\" (FLIP protocol version 1) is for AT90USB* and ATmega*U* devices.\n"
|
||||
|
|
11
flip2.c
11
flip2.c
|
@ -229,7 +229,16 @@ int flip2_initialize(PROGRAMMER* pgm, AVRPART *part)
|
|||
*/
|
||||
|
||||
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)) {
|
||||
fprintf(stderr,
|
||||
|
|
16
ft245r.c
16
ft245r.c
|
@ -68,6 +68,7 @@
|
|||
#include "config.h"
|
||||
#include "bitbang.h"
|
||||
#include "ft245r.h"
|
||||
#include "usbdevs.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
|
@ -557,9 +558,20 @@ static int ft245r_open(PROGRAMMER * pgm, char * port) {
|
|||
|
||||
handle = malloc (sizeof (struct ftdi_context));
|
||||
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,
|
||||
pgm->usbvid?pgm->usbvid:0x0403,
|
||||
pgm->usbpid?pgm->usbpid:0x6001,
|
||||
pgm->usbvid?pgm->usbvid:USB_VENDOR_FTDI,
|
||||
pid,
|
||||
pgm->usbproduct[0]?pgm->usbproduct:NULL,
|
||||
pgm->usbsn[0]?pgm->usbsn:NULL,
|
||||
devnum);
|
||||
|
|
182
jtag3.c
182
jtag3.c
|
@ -1279,43 +1279,58 @@ static int jtag3_parseextparms(PROGRAMMER * pgm, LISTID extparms)
|
|||
return rv;
|
||||
}
|
||||
|
||||
|
||||
static int jtag3_open(PROGRAMMER * pgm, char * port)
|
||||
int jtag3_open_common(PROGRAMMER * pgm, char * port)
|
||||
{
|
||||
union pinfo pinfo;
|
||||
LNODEID usbpid;
|
||||
int rv = -1;
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtag3_open()\n", progname);
|
||||
#if !defined(HAVE_LIBUSB)
|
||||
fprintf(stderr, "avrdude was compiled without usb support.\n");
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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;
|
||||
if (strncmp(port, "usb", 3) != 0) {
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_open_common(): JTAGICE3/EDBG port names must start with \"usb\"\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
serdev = &usb_serdev_frame;
|
||||
if (pgm->usbvid)
|
||||
pinfo.usbinfo.vid = pgm->usbvid;
|
||||
else
|
||||
pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
|
||||
|
||||
/* If the config entry did not specify a USB PID, insert the default one. */
|
||||
if (lfirst(pgm->usbpid) == NULL)
|
||||
ladd(pgm->usbpid, (void *)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.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;
|
||||
#endif
|
||||
}
|
||||
|
||||
strcpy(pgm->port, port);
|
||||
if (serial_open(port, pinfo, &pgm->fd)==-1) {
|
||||
strcpy(pgm->port, port);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1335,6 +1350,19 @@ static int jtag3_open(PROGRAMMER * pgm, char * port)
|
|||
*/
|
||||
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)
|
||||
return -1;
|
||||
|
||||
|
@ -1343,58 +1371,11 @@ static int jtag3_open(PROGRAMMER * pgm, char * port)
|
|||
|
||||
static int jtag3_open_dw(PROGRAMMER * pgm, char * port)
|
||||
{
|
||||
union pinfo pinfo;
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtag3_open_dw()\n", progname);
|
||||
|
||||
/*
|
||||
* 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");
|
||||
if (jtag3_open_common(pgm, port) < 0)
|
||||
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)
|
||||
return -1;
|
||||
|
@ -1404,58 +1385,11 @@ static int jtag3_open_dw(PROGRAMMER * pgm, char * port)
|
|||
|
||||
static int jtag3_open_pdi(PROGRAMMER * pgm, char * port)
|
||||
{
|
||||
union pinfo pinfo;
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtag3_open_pdi()\n", progname);
|
||||
|
||||
/*
|
||||
* 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");
|
||||
if (jtag3_open_common(pgm, port) < 0)
|
||||
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)
|
||||
return -1;
|
||||
|
|
1
jtag3.h
1
jtag3.h
|
@ -25,6 +25,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
int jtag3_open_common(PROGRAMMER * pgm, char * port);
|
||||
int jtag3_send(PROGRAMMER * pgm, unsigned char * data, size_t len);
|
||||
int jtag3_recv(PROGRAMMER * pgm, unsigned char **msg);
|
||||
void jtag3_close(PROGRAMMER * pgm);
|
||||
|
|
1
pgm.c
1
pgm.c
|
@ -76,6 +76,7 @@ PROGRAMMER * pgm_new(void)
|
|||
memset(pgm, 0, sizeof(*pgm));
|
||||
|
||||
pgm->id = lcreat(NULL, 0);
|
||||
pgm->usbpid = lcreat(NULL, 0);
|
||||
pgm->desc[0] = 0;
|
||||
pgm->type[0] = 0;
|
||||
pgm->config_file[0] = 0;
|
||||
|
|
3
pgm.h
3
pgm.h
|
@ -76,7 +76,8 @@ typedef struct programmer_t {
|
|||
int ppidata;
|
||||
int ppictrl;
|
||||
int baudrate;
|
||||
int usbvid, usbpid;
|
||||
int usbvid;
|
||||
LISTID usbpid;
|
||||
char usbdev[PGM_USBSTRINGLEN], usbsn[PGM_USBSTRINGLEN];
|
||||
char usbvendor[PGM_USBSTRINGLEN], usbproduct[PGM_USBSTRINGLEN];
|
||||
double bitclock; /* JTAG ICE clock period in microseconds */
|
||||
|
|
1
serial.h
1
serial.h
|
@ -54,6 +54,7 @@ union pinfo
|
|||
unsigned short pid;
|
||||
unsigned short flags;
|
||||
#define PINFO_FL_USEHID 0x0001
|
||||
#define PINFO_FL_SILENT 0x0002 /* don't complain if not found */
|
||||
} usbinfo;
|
||||
};
|
||||
|
||||
|
|
38
stk500v2.c
38
stk500v2.c
|
@ -602,8 +602,13 @@ static int stk500v2_jtag3_recv(PROGRAMMER * pgm, unsigned char *msg,
|
|||
progname);
|
||||
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) {
|
||||
fprintf(stderr,
|
||||
if (verbose > 2)
|
||||
fprintf(stderr,
|
||||
"%s: stk500v2_jtag3_recv(): got %u bytes, have only room for %u bytes\n",
|
||||
progname, (unsigned)rv - 1, (unsigned)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)
|
||||
{
|
||||
union pinfo pinfo;
|
||||
void *mycookie;
|
||||
int rv;
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: stk500v2_jtag3_open()\n", progname);
|
||||
|
||||
/*
|
||||
* 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");
|
||||
if (jtag3_open_common(pgm, port) < 0)
|
||||
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;
|
||||
pgm->cookie = PDATA(pgm)->chained_pdata;
|
||||
|
|
|
@ -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",
|
||||
progname, serno? " (matching)": "", port);
|
||||
if ((pinfo.usbinfo.flags & PINFO_FL_SILENT) == 0 || verbose > 0)
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
18
usbasp.c
18
usbasp.c
|
@ -38,6 +38,7 @@
|
|||
#include "avr.h"
|
||||
#include "pgm.h"
|
||||
#include "usbasp.h"
|
||||
#include "usbdevs.h"
|
||||
|
||||
#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1_0)
|
||||
|
||||
|
@ -464,8 +465,19 @@ static int usbasp_open(PROGRAMMER * pgm, char * port)
|
|||
progname, port);
|
||||
|
||||
/* usb_init will be done in usbOpenDevice */
|
||||
if (usbOpenDevice(&PDATA(pgm)->usbhandle, pgm->usbvid, pgm->usbvendor,
|
||||
pgm->usbpid, pgm->usbproduct) != 0) {
|
||||
LNODEID usbpid = lfirst(pgm->usbpid);
|
||||
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 */
|
||||
if(strcasecmp(ldata(lfirst(pgm->id)), "usbasp") == 0) {
|
||||
/* for id usbasp autodetect some variants */
|
||||
|
@ -500,7 +512,7 @@ static int usbasp_open(PROGRAMMER * pgm, char * port)
|
|||
|
||||
fprintf(stderr,
|
||||
"%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) {
|
||||
fprintf(stderr, " vendor='%s'", pgm->usbvendor);
|
||||
}
|
||||
|
|
10
usbasp.h
10
usbasp.h
|
@ -23,16 +23,6 @@
|
|||
|
||||
#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 */
|
||||
#define USBASP_FUNC_CONNECT 1
|
||||
#define USBASP_FUNC_DISCONNECT 2
|
||||
|
|
21
usbdevs.h
21
usbdevs.h
|
@ -34,6 +34,27 @@
|
|||
#define USB_DEVICE_XPLAINEDPRO 0x2111
|
||||
#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 */
|
||||
#define USBDEV_BULK_EP_WRITE_MKII 0x02
|
||||
#define USBDEV_BULK_EP_READ_MKII 0x82
|
||||
|
|
13
usbtiny.c
13
usbtiny.c
|
@ -37,6 +37,7 @@
|
|||
#include "pgm.h"
|
||||
#include "config.h"
|
||||
#include "usbtiny.h"
|
||||
#include "usbdevs.h"
|
||||
|
||||
#if defined(HAVE_LIBUSB) // we use LIBUSB to talk to the board
|
||||
#if defined(HAVE_USB_H)
|
||||
|
@ -231,10 +232,16 @@ static int usbtiny_open(PROGRAMMER* pgm, char* name)
|
|||
else
|
||||
vid = USBTINY_VENDOR_DEFAULT;
|
||||
|
||||
if (pgm->usbpid)
|
||||
pid = pgm->usbpid;
|
||||
else
|
||||
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 = USBTINY_PRODUCT_DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
// now we iterate through all the busses and devices
|
||||
|
|
|
@ -22,11 +22,6 @@
|
|||
|
||||
#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
|
||||
#define USBTINY_ECHO 0 // echo test
|
||||
|
|
Loading…
Reference in New Issue