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 bcd52759b1
commit 04831af970
16 changed files with 2227 additions and 85 deletions

27
main.c
View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2000-2005 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,7 +20,8 @@
/* $Id$ */
/*
* Code to program an Atmel AVR AT90S device using the parallel port.
* Code to program an Atmel AVR device through one of the supported
* programmers.
*
* For parallel port connected programmers, the pin definitions can be
* changed via a config file. See the config file for instructions on
@@ -98,6 +99,8 @@ void usage(void)
"Usage: %s [options]\n"
"Options:\n"
" -p <partno> Required. Specify AVR device.\n"
" -b <baudrate> Override RS-232 baud rate.\n"
" -B <bitclock> Specify JTAG bit clock period (us).\n"
" -C <config-file> Specify location of configuration file.\n"
" -c <programmer> Specify programmer type.\n"
" -D Disable auto erase for flash memory\n"
@@ -115,6 +118,8 @@ void usage(void)
" recovered if they change\n"
" -t Enter terminal mode.\n"
" -E <exitspec>[,<exitspec>] List programmer exit specifications.\n"
" -y Count # erase cycles in EEPROM.\n"
" -Y <number> Initialize erase cycle # in EEPROM.\n"
" -v Verbose output. -v -v for more.\n"
" -q Quell progress output.\n"
" -? Display this usage.\n"
@@ -707,6 +712,7 @@ int main(int argc, char * argv [])
char * e; /* for strtol() error checking */
int quell_progress;
int baudrate; /* override default programmer baud rate */
double bitclock; /* Specify programmer bit clock (JTAG ICE) */
int safemode; /* Enable safemode, 1=safemode on, 0=normal */
unsigned char safemode_lfuse = 0xff;
unsigned char safemode_hfuse = 0xff;
@@ -759,6 +765,7 @@ int main(int argc, char * argv [])
do_cycles = 0;
set_cycles = -1;
baudrate = 0;
bitclock = 0.0;
safemode = 1; /* Safemode enabled by default */
@@ -816,6 +823,15 @@ int main(int argc, char * argv [])
}
break;
case 'B': /* specify JTAG ICE bit clock period */
bitclock = strtod(optarg, &e);
if ((e == optarg) || (*e != 0) || bitclock == 0.0) {
fprintf(stderr, "%s: invalid bit clock period specified '%s'\n",
progname, optarg);
exit(1);
}
break;
case 'c': /* programmer id */
programmer = optarg;
break;
@@ -1112,6 +1128,13 @@ int main(int argc, char * argv [])
pgm->baudrate = baudrate;
}
if (bitclock != 0.0) {
if (verbose) {
fprintf(stderr, "%sSetting bit clk period: %.1f\n", progbuf, bitclock);
}
pgm->bitclock = bitclock;
}
rc = pgm->open(pgm, port);
if (rc < 0) {
exitrc = 1;