Mega-commit to bring in both, the STK500v2 support from Erik

Walthinsen, as well as JTAG ICE mkII support (by me).

Erik's submission has been cleaned up a little bit, mostly to add his
name and the current year to the copyright of the new file, remove
trailing white space before importing the files, and fix the minor
syntax errors in his avrdude.conf.in additions (missing semicolons).

The JTAG ICE mkII support should be considered alpha to beta quality
at this point.  Few things are still to be done, like defering the
hfuse (OCDEN) tweaks until they are really required.  Also, for
reasons not yet known, the target MCU doesn't start to run after
signing off from the ICE, it needs a power-cycle first (at least on my
STK500).

Note that for the JTAG ICE, I did change a few things in the internal
API.  Notably I made the serial receive timeout configurable by the
backends via an exported variable (done in both the Posix and the
Win32 implementation), and I made the serial_recv() function return a
-1 instead of bailing out with exit(1) upon encountering a receive
timeout (currently only done in the Posix implementation).  Both
measures together allow me to receive a datastreem from the ICE at 115
kbps on a somewhat lossy PCI multi-UART card that occasionally drops a
character.  The JTAG ICE mkII protocol has enough of safety layers to
allow recovering from these events, but the previous code wasn't
prepared for any kind of recovery.  The Win32 change for this still
has to be done, and the traditional drivers need to be converted to
exit(1) upon encountering a timeout (as they're now getting a -1
returned they didn't see before in that case).


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@451 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
joerg_wunsch
2005-05-10 19:17:12 +00:00
parent 1041ecd45e
commit b49dc8f645
16 changed files with 2227 additions and 85 deletions

View File

@@ -41,6 +41,8 @@
extern char *progname;
extern int verbose;
long serial_recv_timeout = 5000; /* ms */
struct baud_mapping {
long baud;
speed_t speed;
@@ -76,7 +78,7 @@ static speed_t serial_baud_lookup(long baud)
exit(1);
}
static int serial_setattr(int fd, long baud)
int serial_setspeed(int fd, long baud)
{
int rc;
struct termios termios;
@@ -90,7 +92,7 @@ static int serial_setattr(int fd, long baud)
*/
rc = tcgetattr(fd, &termios);
if (rc < 0) {
fprintf(stderr, "%s: serial_setattr(): tcgetattr() failed, %s",
fprintf(stderr, "%s: serial_setspeed(): tcgetattr() failed, %s",
progname, strerror(errno));
return -errno;
}
@@ -108,7 +110,7 @@ static int serial_setattr(int fd, long baud)
rc = tcsetattr(fd, TCSANOW, &termios);
if (rc < 0) {
fprintf(stderr, "%s: serial_setattr(): tcsetattr() failed, %s",
fprintf(stderr, "%s: serial_setspeed(): tcsetattr() failed, %s",
progname, strerror(errno));
return -errno;
}
@@ -135,7 +137,7 @@ int serial_open(char * port, int baud)
/*
* set serial line attributes
*/
rc = serial_setattr(fd, baud);
rc = serial_setspeed(fd, baud);
if (rc) {
fprintf(stderr,
"%s: serial_open(): can't set attributes for device \"%s\"\n",
@@ -199,9 +201,10 @@ int serial_send(int fd, char * buf, size_t buflen)
reselect:
nfds = select(fd+1, NULL, &wfds, NULL, &timeout);
if (nfds == 0) {
fprintf(stderr,
"%s: serial_send(): programmer is not responding\n",
progname);
if (verbose >= 1)
fprintf(stderr,
"%s: serial_send(): programmer is not responding\n",
progname);
exit(1);
}
else if (nfds == -1) {
@@ -239,8 +242,8 @@ int serial_recv(int fd, char * buf, size_t buflen)
char * p = buf;
size_t len = 0;
timeout.tv_sec = 5;
timeout.tv_usec = 0;
timeout.tv_sec = serial_recv_timeout / 1000L;
timeout.tv_usec = (serial_recv_timeout % 1000L) * 1000;
while (len < buflen) {
FD_ZERO(&rfds);
@@ -249,10 +252,11 @@ int serial_recv(int fd, char * buf, size_t buflen)
reselect:
nfds = select(fd+1, &rfds, NULL, NULL, &timeout);
if (nfds == 0) {
fprintf(stderr,
"%s: serial_recv(): programmer is not responding\n",
progname);
exit(1);
if (verbose > 1)
fprintf(stderr,
"%s: serial_recv(): programmer is not responding\n",
progname);
return -1;
}
else if (nfds == -1) {
if (errno == EINTR) {