2001-01-19 02:46:50 +00:00
|
|
|
/*
|
2003-02-08 04:17:25 +00:00
|
|
|
* avrdude - A Downloader/Uploader for AVR device programmers
|
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
2005-05-10 19:17:12 +00:00
|
|
|
* Copyright (C) 2000-2005 Brian S. Dean <bsd@bsdhome.com>
|
2001-01-19 02:46:50 +00:00
|
|
|
*
|
2003-02-06 19:08:33 +00:00
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2001-01-19 02:46:50 +00:00
|
|
|
*
|
2003-02-06 19:08:33 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2001-01-19 02:46:50 +00:00
|
|
|
*
|
2003-02-06 19:08:33 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2001-01-19 02:46:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
/*
|
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
2005-05-10 19:17:12 +00:00
|
|
|
* Code to program an Atmel AVR device through one of the supported
|
|
|
|
* programmers.
|
2001-01-19 02:46:50 +00:00
|
|
|
*
|
2003-02-21 21:19:56 +00:00
|
|
|
* For parallel port connected programmers, the pin definitions can be
|
|
|
|
* changed via a config file. See the config file for instructions on
|
|
|
|
* how to add a programmer definition.
|
|
|
|
*
|
2001-01-19 02:46:50 +00:00
|
|
|
*/
|
|
|
|
|
2003-02-14 20:34:03 +00:00
|
|
|
#include "ac_cfg.h"
|
|
|
|
|
2001-01-19 02:46:50 +00:00
|
|
|
#include <stdio.h>
|
2001-09-19 17:04:25 +00:00
|
|
|
#include <stdlib.h>
|
2001-01-19 02:46:50 +00:00
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <string.h>
|
2001-01-26 20:34:08 +00:00
|
|
|
#include <time.h>
|
2001-01-19 02:46:50 +00:00
|
|
|
#include <unistd.h>
|
2001-09-19 17:04:25 +00:00
|
|
|
#include <ctype.h>
|
2003-02-22 16:45:13 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2003-07-30 23:01:52 +00:00
|
|
|
#include <sys/time.h>
|
2001-01-19 02:46:50 +00:00
|
|
|
|
|
|
|
#include "avr.h"
|
2001-10-14 23:17:26 +00:00
|
|
|
#include "config.h"
|
2003-02-24 23:13:55 +00:00
|
|
|
#include "confwin.h"
|
2001-01-19 02:46:50 +00:00
|
|
|
#include "fileio.h"
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
#include "lists.h"
|
2003-02-13 19:27:50 +00:00
|
|
|
#include "par.h"
|
2001-01-24 19:10:34 +00:00
|
|
|
#include "pindefs.h"
|
2001-01-19 02:46:50 +00:00
|
|
|
#include "term.h"
|
2005-01-24 21:26:11 +00:00
|
|
|
#include "safemode.h"
|
2001-01-19 02:46:50 +00:00
|
|
|
|
|
|
|
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
enum {
|
|
|
|
DEVICE_READ,
|
|
|
|
DEVICE_WRITE,
|
|
|
|
DEVICE_VERIFY
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct update_t {
|
|
|
|
char * memtype;
|
|
|
|
int op;
|
|
|
|
char * filename;
|
|
|
|
int format;
|
|
|
|
} UPDATE;
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-03-06 19:18:40 +00:00
|
|
|
/* Get VERSION from ac_cfg.h */
|
|
|
|
char * version = VERSION;
|
2001-01-19 02:46:50 +00:00
|
|
|
|
2003-02-20 19:59:11 +00:00
|
|
|
int verbose; /* verbose output */
|
2005-09-16 21:52:42 +00:00
|
|
|
int quell_progress; /* un-verebose output */
|
2001-01-19 02:46:50 +00:00
|
|
|
char * progname;
|
|
|
|
char progbuf[PATH_MAX]; /* temporary buffer of spaces the same
|
|
|
|
length as progname; used for lining up
|
|
|
|
multiline messages */
|
|
|
|
|
2001-10-14 23:17:26 +00:00
|
|
|
PROGRAMMER * pgm = NULL;
|
|
|
|
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
LISTID updates;
|
|
|
|
|
2002-08-01 02:06:48 +00:00
|
|
|
/*
|
|
|
|
* global options
|
|
|
|
*/
|
|
|
|
int do_cycles; /* track erase-rewrite cycles */
|
|
|
|
|
2001-09-19 17:04:25 +00:00
|
|
|
|
2001-01-19 02:46:50 +00:00
|
|
|
/*
|
|
|
|
* usage message
|
|
|
|
*/
|
2001-10-13 03:13:13 +00:00
|
|
|
void usage(void)
|
2001-01-19 02:46:50 +00:00
|
|
|
{
|
2005-02-10 16:34:55 +00:00
|
|
|
fprintf(stderr,
|
|
|
|
"Usage: %s [options]\n"
|
|
|
|
"Options:\n"
|
|
|
|
" -p <partno> Required. Specify AVR device.\n"
|
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
2005-05-10 19:17:12 +00:00
|
|
|
" -b <baudrate> Override RS-232 baud rate.\n"
|
2006-01-17 21:11:39 +00:00
|
|
|
" -B <bitclock> Specify JTAG/STK500v2 bit clock period (us).\n"
|
2005-02-10 16:34:55 +00:00
|
|
|
" -C <config-file> Specify location of configuration file.\n"
|
|
|
|
" -c <programmer> Specify programmer type.\n"
|
|
|
|
" -D Disable auto erase for flash memory\n"
|
2006-08-17 15:06:20 +00:00
|
|
|
" -i <delay> ISP Clock Delay [in microseconds]\n"
|
2005-02-10 16:34:55 +00:00
|
|
|
" -P <port> Specify connection port.\n"
|
|
|
|
" -F Override invalid signature check.\n"
|
|
|
|
" -e Perform a chip erase.\n"
|
|
|
|
" -U <memtype>:r|w|v:<filename>[:format]\n"
|
|
|
|
" Memory operation specification.\n"
|
|
|
|
" Multiple -U options are allowed, each request\n"
|
|
|
|
" is performed in the order specified.\n"
|
|
|
|
" -n Do not write anything to the device.\n"
|
|
|
|
" -V Do not verify.\n"
|
2005-09-21 00:20:32 +00:00
|
|
|
" -u Disable safemode, default when running from a script.\n"
|
|
|
|
" -s Silent safemode operation, will not ask you if\n"
|
|
|
|
" fuses should be changed back.\n"
|
2005-02-10 16:34:55 +00:00
|
|
|
" -t Enter terminal mode.\n"
|
|
|
|
" -E <exitspec>[,<exitspec>] List programmer exit specifications.\n"
|
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
2005-05-10 19:17:12 +00:00
|
|
|
" -y Count # erase cycles in EEPROM.\n"
|
|
|
|
" -Y <number> Initialize erase cycle # in EEPROM.\n"
|
2005-02-10 16:34:55 +00:00
|
|
|
" -v Verbose output. -v -v for more.\n"
|
2005-09-16 21:52:42 +00:00
|
|
|
" -q Quell progress output. -q -q for less.\n"
|
2005-02-10 16:34:55 +00:00
|
|
|
" -? Display this usage.\n"
|
|
|
|
"\navrdude project: <URL:http://savannah.nongnu.org/projects/avrdude>\n"
|
|
|
|
,progname);
|
2001-01-19 02:46:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-14 23:17:26 +00:00
|
|
|
int read_config(char * file)
|
2001-09-19 17:04:25 +00:00
|
|
|
{
|
|
|
|
FILE * f;
|
|
|
|
|
2001-10-14 23:17:26 +00:00
|
|
|
f = fopen(file, "r");
|
2001-09-19 17:04:25 +00:00
|
|
|
if (f == NULL) {
|
|
|
|
fprintf(stderr, "%s: can't open config file \"%s\": %s\n",
|
2001-10-16 02:47:55 +00:00
|
|
|
progname, file, strerror(errno));
|
2001-09-19 17:04:25 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2003-02-22 16:45:13 +00:00
|
|
|
lineno = 1;
|
2001-10-14 23:17:26 +00:00
|
|
|
infile = file;
|
|
|
|
yyin = f;
|
2001-09-19 17:04:25 +00:00
|
|
|
|
2001-10-14 23:17:26 +00:00
|
|
|
yyparse();
|
2001-09-19 17:04:25 +00:00
|
|
|
|
2001-10-14 23:17:26 +00:00
|
|
|
fclose(f);
|
2001-09-19 17:04:25 +00:00
|
|
|
|
2001-10-14 23:17:26 +00:00
|
|
|
return 0;
|
2001-09-19 17:04:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-02-21 21:07:43 +00:00
|
|
|
void programmer_display(char * p)
|
2001-09-19 17:04:25 +00:00
|
|
|
{
|
2003-02-22 16:45:13 +00:00
|
|
|
fprintf(stderr, "%sProgrammer Type : %s\n", p, pgm->type);
|
|
|
|
fprintf(stderr, "%sDescription : %s\n", p, pgm->desc);
|
2001-12-29 21:37:20 +00:00
|
|
|
|
2002-11-30 14:09:12 +00:00
|
|
|
pgm->display(pgm, p);
|
2001-09-19 17:04:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-02-21 21:07:43 +00:00
|
|
|
PROGRAMMER * locate_programmer(LISTID programmers, char * configid)
|
2001-10-14 23:17:26 +00:00
|
|
|
{
|
|
|
|
LNODEID ln1, ln2;
|
2001-10-16 02:50:27 +00:00
|
|
|
PROGRAMMER * p = NULL;
|
2001-10-14 23:17:26 +00:00
|
|
|
char * id;
|
|
|
|
int found;
|
|
|
|
|
|
|
|
found = 0;
|
|
|
|
|
|
|
|
for (ln1=lfirst(programmers); ln1 && !found; ln1=lnext(ln1)) {
|
|
|
|
p = ldata(ln1);
|
|
|
|
for (ln2=lfirst(p->id); ln2 && !found; ln2=lnext(ln2)) {
|
|
|
|
id = ldata(ln2);
|
|
|
|
if (strcasecmp(configid, id) == 0)
|
|
|
|
found = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (found)
|
|
|
|
return p;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2003-02-22 16:45:13 +00:00
|
|
|
void list_programmers(FILE * f, char * prefix, LISTID programmers)
|
|
|
|
{
|
|
|
|
LNODEID ln1;
|
|
|
|
PROGRAMMER * p;
|
|
|
|
|
|
|
|
for (ln1=lfirst(programmers); ln1; ln1=lnext(ln1)) {
|
|
|
|
p = ldata(ln1);
|
2003-11-30 16:49:00 +00:00
|
|
|
fprintf(f, "%s%-8s = %-30s [%s:%d]\n",
|
|
|
|
prefix, (char *)ldata(lfirst(p->id)), p->desc,
|
2003-02-22 16:45:13 +00:00
|
|
|
p->config_file, p->lineno);
|
2001-10-14 23:17:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-07-30 23:01:52 +00:00
|
|
|
typedef void (*FP_UpdateProgress)(int percent, double etime, char *hdr);
|
2001-10-14 23:17:26 +00:00
|
|
|
|
2003-07-29 22:08:21 +00:00
|
|
|
static FP_UpdateProgress update_progress;
|
|
|
|
|
2005-02-10 16:34:55 +00:00
|
|
|
/*
|
|
|
|
* Report the progress of a read or write operation from/to the
|
|
|
|
* device.
|
|
|
|
*
|
|
|
|
* The first call of report_progress() should look like this (for a write op):
|
|
|
|
*
|
|
|
|
* report_progress (0, 1, "Writing");
|
|
|
|
*
|
|
|
|
* Then hdr should be passed NULL on subsequent calls while the
|
|
|
|
* operation is progressing. Once the operation is complete, a final
|
|
|
|
* call should be made as such to ensure proper termination of the
|
|
|
|
* progress report:
|
|
|
|
*
|
|
|
|
* report_progress (1, 1, NULL);
|
|
|
|
*
|
|
|
|
* It would be nice if we could reduce the usage to one and only one
|
|
|
|
* call for each of start, during and end cases. As things stand now,
|
|
|
|
* that is not possible and makes maintenance a bit more work.
|
|
|
|
*/
|
2003-07-29 22:08:21 +00:00
|
|
|
void report_progress (int completed, int total, char *hdr)
|
|
|
|
{
|
|
|
|
static int last = 0;
|
2003-07-30 23:01:52 +00:00
|
|
|
static double start_time;
|
2003-07-29 22:08:21 +00:00
|
|
|
int percent = (completed * 100) / total;
|
2003-07-30 23:01:52 +00:00
|
|
|
struct timeval tv;
|
|
|
|
double t;
|
2003-07-29 22:08:21 +00:00
|
|
|
|
|
|
|
if (update_progress == NULL)
|
|
|
|
return;
|
|
|
|
|
2003-07-30 23:01:52 +00:00
|
|
|
gettimeofday(&tv, NULL);
|
|
|
|
t = tv.tv_sec + ((double)tv.tv_usec)/1000000;
|
|
|
|
|
2003-07-29 22:08:21 +00:00
|
|
|
if (hdr) {
|
|
|
|
last = 0;
|
2003-07-30 23:01:52 +00:00
|
|
|
start_time = t;
|
|
|
|
update_progress (percent, t - start_time, hdr);
|
2003-07-29 22:08:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (percent > 100)
|
|
|
|
percent = 100;
|
|
|
|
|
|
|
|
if (percent > last) {
|
|
|
|
last = percent;
|
2003-07-30 23:01:52 +00:00
|
|
|
update_progress (percent, t - start_time, hdr);
|
2003-07-29 22:08:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (percent == 100)
|
|
|
|
last = 0; /* Get ready for next time. */
|
|
|
|
}
|
|
|
|
|
2003-07-30 23:01:52 +00:00
|
|
|
static void update_progress_tty (int percent, double etime, char *hdr)
|
2003-07-29 22:08:21 +00:00
|
|
|
{
|
|
|
|
static char hashes[51];
|
|
|
|
static char *header;
|
2003-08-25 15:55:48 +00:00
|
|
|
static int last = 0;
|
2003-07-29 22:08:21 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
hashes[50] = 0;
|
|
|
|
|
|
|
|
memset (hashes, ' ', 50);
|
|
|
|
for (i=0; i<percent; i+=2) {
|
|
|
|
hashes[i/2] = '#';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hdr) {
|
|
|
|
fprintf (stderr, "\n");
|
|
|
|
last = 0;
|
|
|
|
header = hdr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (last == 0) {
|
2003-07-30 23:01:52 +00:00
|
|
|
fprintf(stderr, "\r%s | %s | %d%% %0.2fs",
|
|
|
|
header, hashes, percent, etime);
|
2003-07-29 22:08:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (percent == 100) {
|
|
|
|
last = 1;
|
|
|
|
fprintf (stderr, "\n\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-30 23:01:52 +00:00
|
|
|
static void update_progress_no_tty (int percent, double etime, char *hdr)
|
2003-07-29 22:08:21 +00:00
|
|
|
{
|
2003-08-28 05:37:57 +00:00
|
|
|
static int done = 0;
|
2003-07-29 22:08:21 +00:00
|
|
|
static int last = 0;
|
|
|
|
int cnt = (percent>>1)*2;
|
|
|
|
|
|
|
|
if (hdr) {
|
|
|
|
fprintf (stderr, "\n%s | ", hdr);
|
|
|
|
last = 0;
|
2003-08-28 05:37:57 +00:00
|
|
|
done = 0;
|
2003-07-29 22:08:21 +00:00
|
|
|
}
|
|
|
|
else {
|
2003-08-28 05:37:57 +00:00
|
|
|
while ((cnt > last) && (done == 0)) {
|
2003-07-29 22:08:21 +00:00
|
|
|
fprintf (stderr, "#");
|
|
|
|
cnt -= 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-28 05:37:57 +00:00
|
|
|
if ((percent == 100) && (done == 0)) {
|
2003-07-30 23:01:52 +00:00
|
|
|
fprintf (stderr, " | 100%% %0.2fs\n\n", etime);
|
2003-07-29 22:08:21 +00:00
|
|
|
last = 0;
|
2003-08-28 05:37:57 +00:00
|
|
|
done = 1;
|
2003-07-29 22:08:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
last = (percent>>1)*2; /* Make last a multiple of 2. */
|
|
|
|
}
|
2001-09-19 17:04:25 +00:00
|
|
|
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
|
|
|
|
UPDATE * parse_op(char * s)
|
|
|
|
{
|
|
|
|
char buf[1024];
|
2003-11-26 22:05:02 +00:00
|
|
|
char * p, * cp, c;
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
UPDATE * upd;
|
|
|
|
int i;
|
2003-11-26 22:05:02 +00:00
|
|
|
size_t fnlen;
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
|
|
|
|
upd = (UPDATE *)malloc(sizeof(UPDATE));
|
|
|
|
if (upd == NULL) {
|
|
|
|
fprintf(stderr, "%s: out of memory\n", progname);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
p = s;
|
|
|
|
while ((i < (sizeof(buf)-1) && *p && (*p != ':')))
|
|
|
|
buf[i++] = *p++;
|
2005-02-10 16:34:55 +00:00
|
|
|
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
if (*p != ':') {
|
|
|
|
fprintf(stderr, "%s: invalid update specification\n", progname);
|
|
|
|
free(upd);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf[i] = 0;
|
|
|
|
|
|
|
|
upd->memtype = (char *)malloc(strlen(buf)+1);
|
|
|
|
if (upd->memtype == NULL) {
|
|
|
|
fprintf(stderr, "%s: out of memory\n", progname);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
strcpy(upd->memtype, buf);
|
|
|
|
|
|
|
|
p++;
|
|
|
|
if (*p == 'r') {
|
|
|
|
upd->op = DEVICE_READ;
|
|
|
|
}
|
|
|
|
else if (*p == 'w') {
|
|
|
|
upd->op = DEVICE_WRITE;
|
|
|
|
}
|
|
|
|
else if (*p == 'v') {
|
|
|
|
upd->op = DEVICE_VERIFY;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(stderr, "%s: invalid I/O mode '%c' in update specification\n",
|
|
|
|
progname, *p);
|
|
|
|
fprintf(stderr,
|
|
|
|
" allowed values are:\n"
|
|
|
|
" r = read device\n"
|
|
|
|
" w = write device\n"
|
|
|
|
" v = verify device\n");
|
|
|
|
free(upd->memtype);
|
|
|
|
free(upd);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
p++;
|
|
|
|
|
|
|
|
if (*p != ':') {
|
|
|
|
fprintf(stderr, "%s: invalid update specification\n", progname);
|
|
|
|
free(upd->memtype);
|
|
|
|
free(upd);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
p++;
|
|
|
|
|
2003-11-26 22:05:02 +00:00
|
|
|
/*
|
|
|
|
* Now, parse the filename component. Instead of looking for the
|
|
|
|
* leftmost possible colon delimiter, we look for the rightmost one.
|
|
|
|
* If we found one, we do have a trailing :format specifier, and
|
|
|
|
* process it. Otherwise, the remainder of the string is our file
|
|
|
|
* name component. That way, the file name itself is allowed to
|
|
|
|
* contain a colon itself (e. g. C:/some/file.hex), except the
|
|
|
|
* optional format specifier becomes mandatory then.
|
|
|
|
*/
|
|
|
|
cp = p;
|
|
|
|
p = strrchr(cp, ':');
|
|
|
|
if (p == NULL) {
|
|
|
|
upd->format = FMT_AUTO;
|
|
|
|
fnlen = strlen(cp);
|
|
|
|
upd->filename = (char *)malloc(fnlen + 1);
|
|
|
|
} else {
|
|
|
|
fnlen = p - cp;
|
|
|
|
upd->filename = (char *)malloc(fnlen +1);
|
|
|
|
c = *++p;
|
|
|
|
if (c && p[1])
|
|
|
|
/* More than one char - force failure below. */
|
|
|
|
c = '?';
|
|
|
|
switch (c) {
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
case 'a': upd->format = FMT_AUTO; break;
|
|
|
|
case 's': upd->format = FMT_SREC; break;
|
|
|
|
case 'i': upd->format = FMT_IHEX; break;
|
|
|
|
case 'r': upd->format = FMT_RBIN; break;
|
|
|
|
case 'm': upd->format = FMT_IMM; break;
|
2006-09-08 21:28:24 +00:00
|
|
|
case 'b': upd->format = FMT_BIN; break;
|
|
|
|
case 'd': upd->format = FMT_DEC; break;
|
|
|
|
case 'h': upd->format = FMT_HEX; break;
|
|
|
|
case 'o': upd->format = FMT_OCT; break;
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
default:
|
2003-11-26 22:05:02 +00:00
|
|
|
fprintf(stderr, "%s: invalid file format '%s' in update specifier\n",
|
|
|
|
progname, p);
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
free(upd->memtype);
|
|
|
|
free(upd);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-26 22:05:02 +00:00
|
|
|
if (upd->filename == NULL) {
|
|
|
|
fprintf(stderr, "%s: out of memory\n", progname);
|
|
|
|
free(upd->memtype);
|
|
|
|
free(upd);
|
|
|
|
return NULL;
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
}
|
2003-11-26 22:05:02 +00:00
|
|
|
memcpy(upd->filename, cp, fnlen);
|
|
|
|
upd->filename[fnlen] = 0;
|
|
|
|
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
return upd;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE * dup_update(UPDATE * upd)
|
|
|
|
{
|
|
|
|
UPDATE * u;
|
|
|
|
|
|
|
|
u = (UPDATE *)malloc(sizeof(UPDATE));
|
|
|
|
if (u == NULL) {
|
|
|
|
fprintf(stderr, "%s: out of memory\n", progname);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(u, upd, sizeof(UPDATE));
|
|
|
|
|
|
|
|
u->memtype = strdup(upd->memtype);
|
|
|
|
u->filename = strdup(upd->filename);
|
|
|
|
|
|
|
|
return u;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE * new_update(int op, char * memtype, int filefmt, char * filename)
|
|
|
|
{
|
|
|
|
UPDATE * u;
|
|
|
|
|
|
|
|
u = (UPDATE *)malloc(sizeof(UPDATE));
|
|
|
|
if (u == NULL) {
|
|
|
|
fprintf(stderr, "%s: out of memory\n", progname);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
u->memtype = strdup(memtype);
|
|
|
|
u->filename = strdup(filename);
|
|
|
|
u->op = op;
|
|
|
|
u->format = filefmt;
|
2005-02-10 16:34:55 +00:00
|
|
|
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
return u;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-07-05 15:04:19 +00:00
|
|
|
int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, int nowrite,
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
int verify)
|
|
|
|
{
|
|
|
|
struct avrpart * v;
|
|
|
|
AVRMEM * mem;
|
2003-08-29 00:14:22 +00:00
|
|
|
int size, vsize;
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
mem = avr_locate_mem(p, upd->memtype);
|
|
|
|
if (mem == NULL) {
|
|
|
|
fprintf(stderr, "\"%s\" memory type not defined for part \"%s\"\n",
|
|
|
|
upd->memtype, p->desc);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (upd->op == DEVICE_READ) {
|
|
|
|
/*
|
|
|
|
* read out the specified device memory and write it to a file
|
|
|
|
*/
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
|
|
|
fprintf(stderr, "%s: reading %s memory:\n",
|
2005-09-22 14:14:14 +00:00
|
|
|
progname, mem->desc);
|
2005-09-16 21:52:42 +00:00
|
|
|
}
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
report_progress(0,1,"Reading");
|
|
|
|
rc = avr_read(pgm, p, upd->memtype, 0, 1);
|
|
|
|
if (rc < 0) {
|
|
|
|
fprintf(stderr, "%s: failed to read all of %s memory, rc=%d\n",
|
2005-09-22 14:14:14 +00:00
|
|
|
progname, mem->desc, rc);
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
report_progress(1,1,NULL);
|
|
|
|
size = rc;
|
|
|
|
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
|
|
|
fprintf(stderr,
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
"%s: writing output file \"%s\"\n",
|
|
|
|
progname,
|
|
|
|
strcmp(upd->filename, "-")==0 ? "<stdout>" : upd->filename);
|
2005-09-16 21:52:42 +00:00
|
|
|
}
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
rc = fileio(FIO_WRITE, upd->filename, upd->format, p, upd->memtype, size);
|
|
|
|
if (rc < 0) {
|
|
|
|
fprintf(stderr, "%s: write to file '%s' failed\n",
|
|
|
|
progname, upd->filename);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (upd->op == DEVICE_WRITE) {
|
2005-02-10 16:34:55 +00:00
|
|
|
/*
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
* write the selected device memory using data from a file; first
|
|
|
|
* read the data from the specified file
|
|
|
|
*/
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
|
|
|
fprintf(stderr,
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
"%s: reading input file \"%s\"\n",
|
|
|
|
progname,
|
|
|
|
strcmp(upd->filename, "-")==0 ? "<stdin>" : upd->filename);
|
2005-09-16 21:52:42 +00:00
|
|
|
}
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
rc = fileio(FIO_READ, upd->filename, upd->format, p, upd->memtype, -1);
|
|
|
|
if (rc < 0) {
|
|
|
|
fprintf(stderr, "%s: write to file '%s' failed\n",
|
|
|
|
progname, upd->filename);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
size = rc;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* write the buffer contents to the selected memory type
|
|
|
|
*/
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
|
|
|
fprintf(stderr, "%s: writing %s (%d bytes):\n",
|
2006-07-17 19:58:50 +00:00
|
|
|
progname, mem->desc, size);
|
2005-09-16 21:52:42 +00:00
|
|
|
}
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
|
|
|
|
if (!nowrite) {
|
|
|
|
report_progress(0,1,"Writing");
|
|
|
|
rc = avr_write(pgm, p, upd->memtype, size, 1);
|
|
|
|
report_progress(1,1,NULL);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* test mode, don't actually write to the chip, output the buffer
|
|
|
|
* to stdout in intel hex instead
|
|
|
|
*/
|
|
|
|
rc = fileio(FIO_WRITE, "-", FMT_IHEX, p, upd->memtype, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc < 0) {
|
|
|
|
fprintf(stderr, "%s: failed to write %s memory, rc=%d\n",
|
2005-09-22 14:14:14 +00:00
|
|
|
progname, mem->desc, rc);
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
vsize = rc;
|
|
|
|
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
|
|
|
fprintf(stderr, "%s: %d bytes of %s written\n", progname,
|
2006-07-17 19:58:50 +00:00
|
|
|
vsize, mem->desc);
|
2005-09-16 21:52:42 +00:00
|
|
|
}
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else if (upd->op == DEVICE_VERIFY) {
|
|
|
|
/*
|
|
|
|
* verify that the in memory file (p->mem[AVR_M_FLASH|AVR_M_EEPROM])
|
|
|
|
* is the same as what is on the chip
|
|
|
|
*/
|
|
|
|
pgm->vfy_led(pgm, ON);
|
|
|
|
|
|
|
|
v = avr_dup_part(p);
|
|
|
|
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
|
|
|
fprintf(stderr, "%s: verifying %s memory against %s:\n",
|
2005-09-22 14:14:14 +00:00
|
|
|
progname, mem->desc, upd->filename);
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
|
2005-09-16 21:52:42 +00:00
|
|
|
fprintf(stderr, "%s: load data %s data from input file %s:\n",
|
2005-09-22 14:14:14 +00:00
|
|
|
progname, mem->desc, upd->filename);
|
2005-09-16 21:52:42 +00:00
|
|
|
}
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
|
|
|
|
rc = fileio(FIO_READ, upd->filename, upd->format, p, upd->memtype, -1);
|
|
|
|
if (rc < 0) {
|
|
|
|
fprintf(stderr, "%s: read from file '%s' failed\n",
|
|
|
|
progname, upd->filename);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
size = rc;
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
|
|
|
fprintf(stderr, "%s: input file %s contains %d bytes\n",
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
progname, upd->filename, size);
|
2005-09-16 21:52:42 +00:00
|
|
|
fprintf(stderr, "%s: reading on-chip %s data:\n",
|
2006-07-17 19:58:50 +00:00
|
|
|
progname, mem->desc);
|
2005-09-16 21:52:42 +00:00
|
|
|
}
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
|
|
|
|
report_progress (0,1,"Reading");
|
|
|
|
rc = avr_read(pgm, v, upd->memtype, size, 1);
|
|
|
|
if (rc < 0) {
|
|
|
|
fprintf(stderr, "%s: failed to read all of %s memory, rc=%d\n",
|
2005-09-22 14:14:14 +00:00
|
|
|
progname, mem->desc, rc);
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
pgm->err_led(pgm, ON);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
report_progress (1,1,NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
|
|
|
fprintf(stderr, "%s: verifying ...\n", progname);
|
|
|
|
}
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
rc = avr_verify(p, v, upd->memtype, size);
|
|
|
|
if (rc < 0) {
|
|
|
|
fprintf(stderr, "%s: verification error; content mismatch\n",
|
|
|
|
progname);
|
|
|
|
pgm->err_led(pgm, ON);
|
|
|
|
return -1;
|
|
|
|
}
|
2005-02-10 16:34:55 +00:00
|
|
|
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
|
|
|
fprintf(stderr, "%s: %d bytes of %s verified\n",
|
2005-09-22 14:14:14 +00:00
|
|
|
progname, rc, mem->desc);
|
2005-09-16 21:52:42 +00:00
|
|
|
}
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
|
|
|
|
pgm->vfy_led(pgm, OFF);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(stderr, "%s: invalid update operation (%d) requested\n",
|
|
|
|
progname, upd->op);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2005-02-10 16:34:55 +00:00
|
|
|
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
|
2001-01-19 02:46:50 +00:00
|
|
|
/*
|
|
|
|
* main routine
|
|
|
|
*/
|
2001-10-13 03:13:13 +00:00
|
|
|
int main(int argc, char * argv [])
|
2001-01-19 02:46:50 +00:00
|
|
|
{
|
|
|
|
int rc; /* general return code checking */
|
|
|
|
int exitrc; /* exit code for main() */
|
|
|
|
int i; /* general loop counter */
|
|
|
|
int ch; /* options flag */
|
|
|
|
int len; /* length for various strings */
|
2001-10-14 23:17:26 +00:00
|
|
|
struct avrpart * p; /* which avr part we are programming */
|
|
|
|
struct avrpart * v; /* used for verify */
|
2001-11-21 02:46:55 +00:00
|
|
|
AVRMEM * sig; /* signature data */
|
2003-02-22 16:45:13 +00:00
|
|
|
struct stat sb;
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
UPDATE * upd;
|
|
|
|
LNODEID * ln;
|
2001-01-19 02:46:50 +00:00
|
|
|
|
|
|
|
/* options / operating mode variables */
|
|
|
|
int erase; /* 1=erase chip, 0=don't */
|
2003-08-29 23:17:32 +00:00
|
|
|
int auto_erase; /* 0=never erase unless explicity told to do
|
|
|
|
so, 1=erase if we are going to program flash */
|
2001-01-19 02:46:50 +00:00
|
|
|
int ovsigck; /* 1=override sig check, 0=don't */
|
2002-11-30 14:09:12 +00:00
|
|
|
char * port; /* device port (/dev/xxx) */
|
2001-01-19 02:46:50 +00:00
|
|
|
int terminal; /* 1=enter terminal mode, 0=don't */
|
|
|
|
int nowrite; /* don't actually write anything to the chip */
|
|
|
|
int verify; /* perform a verify operation */
|
2001-09-21 03:27:20 +00:00
|
|
|
char * exitspecs; /* exit specs string from command line */
|
2003-02-21 21:07:43 +00:00
|
|
|
char * programmer; /* programmer id */
|
2001-10-14 23:17:26 +00:00
|
|
|
char * partdesc; /* part id */
|
2003-02-22 16:45:13 +00:00
|
|
|
char sys_config[PATH_MAX]; /* system wide config file */
|
|
|
|
char usr_config[PATH_MAX]; /* per-user config file */
|
2002-08-01 01:00:03 +00:00
|
|
|
int cycles; /* erase-rewrite cycles */
|
|
|
|
int set_cycles; /* value to set the erase-rewrite cycles to */
|
2002-12-12 03:59:28 +00:00
|
|
|
char * e; /* for strtol() error checking */
|
2004-05-19 23:00:38 +00:00
|
|
|
int baudrate; /* override default programmer baud rate */
|
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
2005-05-10 19:17:12 +00:00
|
|
|
double bitclock; /* Specify programmer bit clock (JTAG ICE) */
|
2006-08-17 15:06:20 +00:00
|
|
|
int ispdelay; /* Specify the delay for ISP clock */
|
2005-01-24 21:26:11 +00:00
|
|
|
int safemode; /* Enable safemode, 1=safemode on, 0=normal */
|
2005-09-21 00:20:32 +00:00
|
|
|
int silentsafe; /* Don't ask about fuses, 1=silent, 0=normal */
|
2005-02-10 18:37:37 +00:00
|
|
|
unsigned char safemode_lfuse = 0xff;
|
|
|
|
unsigned char safemode_hfuse = 0xff;
|
|
|
|
unsigned char safemode_efuse = 0xff;
|
2005-09-21 00:20:32 +00:00
|
|
|
unsigned char safemode_fuse = 0xff;
|
|
|
|
|
|
|
|
char * safemode_response;
|
2005-02-11 19:03:53 +00:00
|
|
|
int fuses_specified = 0;
|
|
|
|
int fuses_updated = 0;
|
2004-06-24 11:05:07 +00:00
|
|
|
#if !defined(WIN32NATIVE)
|
2003-08-28 13:52:52 +00:00
|
|
|
char * homedir;
|
|
|
|
#endif
|
2001-10-14 23:17:26 +00:00
|
|
|
|
2005-11-01 23:02:06 +00:00
|
|
|
progname = strrchr(argv[0],'/');
|
2005-02-10 16:34:55 +00:00
|
|
|
|
|
|
|
#if defined (WIN32NATIVE)
|
2004-06-24 11:05:07 +00:00
|
|
|
/* take care of backslash as dir sep in W32 */
|
2005-11-01 23:02:06 +00:00
|
|
|
if (!progname) progname = strrchr(argv[0],'\\');
|
2005-02-10 16:34:55 +00:00
|
|
|
#endif /* WIN32NATIVE */
|
|
|
|
|
2001-10-14 23:17:26 +00:00
|
|
|
if (progname)
|
|
|
|
progname++;
|
|
|
|
else
|
|
|
|
progname = argv[0];
|
2001-01-19 02:46:50 +00:00
|
|
|
|
2003-02-21 18:46:51 +00:00
|
|
|
default_parallel[0] = 0;
|
|
|
|
default_serial[0] = 0;
|
|
|
|
|
2001-10-14 23:17:26 +00:00
|
|
|
init_config();
|
|
|
|
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
updates = lcreat(NULL, 0);
|
|
|
|
if (updates == NULL) {
|
|
|
|
fprintf(stderr, "%s: cannot initialize updater list\n", progname);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2001-10-14 23:17:26 +00:00
|
|
|
partdesc = NULL;
|
2003-02-21 18:46:51 +00:00
|
|
|
port = default_parallel;
|
2001-09-19 17:04:25 +00:00
|
|
|
erase = 0;
|
2003-08-29 23:17:32 +00:00
|
|
|
auto_erase = 1;
|
2001-09-19 17:04:25 +00:00
|
|
|
p = NULL;
|
|
|
|
ovsigck = 0;
|
|
|
|
terminal = 0;
|
|
|
|
nowrite = 0;
|
2002-10-29 01:59:02 +00:00
|
|
|
verify = 1; /* on by default */
|
2003-07-29 22:08:21 +00:00
|
|
|
quell_progress = 0;
|
2001-09-21 03:27:20 +00:00
|
|
|
exitspecs = NULL;
|
2001-10-14 23:17:26 +00:00
|
|
|
pgm = NULL;
|
2003-02-21 21:07:43 +00:00
|
|
|
programmer = default_programmer;
|
2001-10-13 03:12:52 +00:00
|
|
|
verbose = 0;
|
2002-08-01 01:00:03 +00:00
|
|
|
do_cycles = 0;
|
|
|
|
set_cycles = -1;
|
2004-05-19 23:00:38 +00:00
|
|
|
baudrate = 0;
|
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
2005-05-10 19:17:12 +00:00
|
|
|
bitclock = 0.0;
|
2006-08-17 15:06:20 +00:00
|
|
|
ispdelay = 0;
|
2005-09-21 00:20:32 +00:00
|
|
|
safemode = 1; /* Safemode on by default */
|
|
|
|
silentsafe = 0; /* Ask by default */
|
|
|
|
|
|
|
|
if (isatty(STDIN_FILENO) == 0)
|
|
|
|
safemode = 0; /* Turn off safemode if this isn't a terminal */
|
|
|
|
|
2001-09-19 17:04:25 +00:00
|
|
|
|
2003-02-24 23:13:55 +00:00
|
|
|
|
2004-07-15 17:29:35 +00:00
|
|
|
#if defined(WIN32NATIVE)
|
2003-02-24 23:13:55 +00:00
|
|
|
|
|
|
|
win_sys_config_set(sys_config);
|
|
|
|
win_usr_config_set(usr_config);
|
2005-02-10 16:34:55 +00:00
|
|
|
|
2004-07-15 17:29:35 +00:00
|
|
|
#else
|
2003-02-24 23:13:55 +00:00
|
|
|
|
2003-02-22 16:45:13 +00:00
|
|
|
strcpy(sys_config, CONFIG_DIR);
|
|
|
|
i = strlen(sys_config);
|
|
|
|
if (i && (sys_config[i-1] != '/'))
|
|
|
|
strcat(sys_config, "/");
|
|
|
|
strcat(sys_config, "avrdude.conf");
|
|
|
|
|
|
|
|
usr_config[0] = 0;
|
|
|
|
homedir = getenv("HOME");
|
|
|
|
if (homedir != NULL) {
|
|
|
|
strcpy(usr_config, homedir);
|
|
|
|
i = strlen(usr_config);
|
|
|
|
if (i && (usr_config[i-1] != '/'))
|
|
|
|
strcat(usr_config, "/");
|
|
|
|
strcat(usr_config, ".avrduderc");
|
|
|
|
}
|
2004-02-09 23:43:42 +00:00
|
|
|
|
2004-07-15 17:29:35 +00:00
|
|
|
#endif
|
2001-09-19 17:04:25 +00:00
|
|
|
|
2001-01-19 02:46:50 +00:00
|
|
|
len = strlen(progname) + 2;
|
|
|
|
for (i=0; i<len; i++)
|
|
|
|
progbuf[i] = ' ';
|
|
|
|
progbuf[i] = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* check for no arguments
|
|
|
|
*/
|
|
|
|
if (argc == 1) {
|
|
|
|
usage();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* process command line arguments
|
|
|
|
*/
|
2006-08-17 15:06:20 +00:00
|
|
|
while ((ch = getopt(argc,argv,"?b:B:c:C:DeE:Fi:np:P:qstU:uvVyY:")) != -1) {
|
2001-01-19 02:46:50 +00:00
|
|
|
|
|
|
|
switch (ch) {
|
2004-05-19 23:00:38 +00:00
|
|
|
case 'b': /* override default programmer baud rate */
|
|
|
|
baudrate = strtol(optarg, &e, 0);
|
|
|
|
if ((e == optarg) || (*e != 0)) {
|
|
|
|
fprintf(stderr, "%s: invalid baud rate specified '%s'\n",
|
|
|
|
progname, optarg);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
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
2005-05-10 19:17:12 +00:00
|
|
|
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;
|
|
|
|
|
2006-08-17 15:06:20 +00:00
|
|
|
case 'i': /* specify isp clock delay */
|
|
|
|
ispdelay = strtol(optarg, &e,10);
|
|
|
|
if ((e == optarg) || (*e != 0) || ispdelay == 0) {
|
|
|
|
fprintf(stderr, "%s: invalid isp clock delay specified '%s'\n",
|
|
|
|
progname, optarg);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-02-21 21:07:43 +00:00
|
|
|
case 'c': /* programmer id */
|
|
|
|
programmer = optarg;
|
2001-09-19 17:04:25 +00:00
|
|
|
break;
|
|
|
|
|
2003-02-22 16:45:13 +00:00
|
|
|
case 'C': /* system wide configuration file */
|
|
|
|
strncpy(sys_config, optarg, PATH_MAX);
|
|
|
|
sys_config[PATH_MAX-1] = 0;
|
2001-09-19 17:04:25 +00:00
|
|
|
break;
|
|
|
|
|
2003-08-29 23:17:32 +00:00
|
|
|
case 'D': /* disable auto erase */
|
|
|
|
auto_erase = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'e': /* perform a chip erase */
|
|
|
|
erase = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'E':
|
|
|
|
exitspecs = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'F': /* override invalid signature check */
|
|
|
|
ovsigck = 1;
|
|
|
|
break;
|
|
|
|
|
2001-01-19 02:46:50 +00:00
|
|
|
case 'n':
|
|
|
|
nowrite = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'p' : /* specify AVR part */
|
2001-10-14 23:17:26 +00:00
|
|
|
partdesc = optarg;
|
2001-01-19 02:46:50 +00:00
|
|
|
break;
|
|
|
|
|
2003-08-29 23:17:32 +00:00
|
|
|
case 'P':
|
|
|
|
port = optarg;
|
2003-04-19 23:06:01 +00:00
|
|
|
break;
|
|
|
|
|
2003-08-29 23:17:32 +00:00
|
|
|
case 'q' : /* Quell progress output */
|
2005-09-16 21:52:42 +00:00
|
|
|
quell_progress++ ;
|
2001-01-19 02:46:50 +00:00
|
|
|
break;
|
|
|
|
|
2005-09-21 00:20:32 +00:00
|
|
|
case 's' : /* Silent safemode */
|
|
|
|
silentsafe = 1;
|
|
|
|
safemode = 1;
|
|
|
|
break;
|
|
|
|
|
2001-01-19 02:46:50 +00:00
|
|
|
case 't': /* enter terminal mode */
|
|
|
|
terminal = 1;
|
|
|
|
break;
|
|
|
|
|
2005-01-24 21:26:11 +00:00
|
|
|
case 'u' : /* Disable safemode */
|
|
|
|
safemode = 0;
|
|
|
|
break;
|
2005-02-10 16:34:55 +00:00
|
|
|
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
case 'U':
|
|
|
|
upd = parse_op(optarg);
|
|
|
|
if (upd == NULL) {
|
|
|
|
fprintf(stderr, "%s: error parsing update operation '%s'\n",
|
|
|
|
progname, optarg);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
ladd(updates, upd);
|
|
|
|
|
|
|
|
if (verify && upd->op == DEVICE_WRITE) {
|
|
|
|
upd = dup_update(upd);
|
|
|
|
upd->op = DEVICE_VERIFY;
|
|
|
|
ladd(updates, upd);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2001-10-13 03:12:52 +00:00
|
|
|
case 'v':
|
|
|
|
verbose++;
|
2001-01-19 02:46:50 +00:00
|
|
|
break;
|
|
|
|
|
2002-10-29 01:59:02 +00:00
|
|
|
case 'V':
|
|
|
|
verify = 0;
|
|
|
|
break;
|
|
|
|
|
2002-08-01 01:00:03 +00:00
|
|
|
case 'y':
|
|
|
|
do_cycles = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Y':
|
|
|
|
set_cycles = strtol(optarg, &e, 0);
|
|
|
|
if ((e == optarg) || (*e != 0)) {
|
|
|
|
fprintf(stderr, "%s: invalid cycle count '%s'\n",
|
|
|
|
progname, optarg);
|
|
|
|
exit(1);
|
|
|
|
}
|
2002-08-01 02:06:48 +00:00
|
|
|
do_cycles = 1;
|
2002-08-01 01:00:03 +00:00
|
|
|
break;
|
|
|
|
|
2001-01-19 02:46:50 +00:00
|
|
|
case '?': /* help */
|
|
|
|
usage();
|
|
|
|
exit(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
fprintf(stderr, "%s: invalid option -%c\n\n", progname, ch);
|
|
|
|
usage();
|
|
|
|
exit(1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2003-08-29 23:17:32 +00:00
|
|
|
|
2003-07-29 22:08:21 +00:00
|
|
|
if (quell_progress == 0) {
|
|
|
|
if (isatty (STDERR_FILENO))
|
|
|
|
update_progress = update_progress_tty;
|
2004-06-24 11:05:07 +00:00
|
|
|
else {
|
2003-07-29 22:08:21 +00:00
|
|
|
update_progress = update_progress_no_tty;
|
2004-06-24 11:05:07 +00:00
|
|
|
/* disable all buffering of stderr for compatibility with
|
|
|
|
software that captures and redirects output to a GUI
|
|
|
|
i.e. Programmers Notepad */
|
|
|
|
setvbuf( stderr, NULL, _IONBF, 0 );
|
|
|
|
setvbuf( stdout, NULL, _IONBF, 0 );
|
2005-02-10 16:34:55 +00:00
|
|
|
}
|
2003-07-29 22:08:21 +00:00
|
|
|
}
|
|
|
|
|
2001-10-13 03:12:52 +00:00
|
|
|
if (verbose) {
|
|
|
|
/*
|
|
|
|
* Print out an identifying string so folks can tell what version
|
|
|
|
* they are running
|
|
|
|
*/
|
2004-02-09 23:43:42 +00:00
|
|
|
fprintf(stderr,
|
2006-09-01 21:15:03 +00:00
|
|
|
"\n%s: Version %s, compiled on %s at %s\n"
|
2005-05-14 14:56:00 +00:00
|
|
|
"%sCopyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/\n\n",
|
2006-09-01 21:15:03 +00:00
|
|
|
progname, version, __DATE__, __TIME__, progbuf);
|
2001-10-13 03:12:52 +00:00
|
|
|
}
|
|
|
|
|
2003-02-22 16:45:13 +00:00
|
|
|
if (verbose) {
|
|
|
|
fprintf(stderr, "%sSystem wide configuration file is \"%s\"\n",
|
|
|
|
progbuf, sys_config);
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = read_config(sys_config);
|
2001-10-14 23:17:26 +00:00
|
|
|
if (rc) {
|
2004-02-09 23:43:42 +00:00
|
|
|
fprintf(stderr,
|
2003-02-22 16:45:13 +00:00
|
|
|
"%s: error reading system wide configuration file \"%s\"\n",
|
|
|
|
progname, sys_config);
|
2001-10-14 23:17:26 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2001-10-13 03:12:52 +00:00
|
|
|
|
2003-02-22 16:45:13 +00:00
|
|
|
if (usr_config[0] != 0) {
|
|
|
|
if (verbose) {
|
|
|
|
fprintf(stderr, "%sUser configuration file is \"%s\"\n",
|
|
|
|
progbuf, usr_config);
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = stat(usr_config, &sb);
|
|
|
|
if ((rc < 0) || ((sb.st_mode & S_IFREG) == 0)) {
|
|
|
|
if (verbose) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"%sUser configuration file does not exist or is not a "
|
|
|
|
"regular file, skipping\n",
|
|
|
|
progbuf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rc = read_config(usr_config);
|
|
|
|
if (rc) {
|
|
|
|
fprintf(stderr, "%s: error reading user configuration file \"%s\"\n",
|
|
|
|
progname, usr_config);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (verbose) {
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
}
|
|
|
|
|
2003-03-05 00:53:49 +00:00
|
|
|
if (partdesc) {
|
|
|
|
if (strcmp(partdesc, "?") == 0) {
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
fprintf(stderr,"Valid parts are:\n");
|
|
|
|
list_parts(stderr, " ", part_list);
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (programmer) {
|
|
|
|
if (strcmp(programmer, "?") == 0) {
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
fprintf(stderr,"Valid programmers are:\n");
|
|
|
|
list_programmers(stderr, " ", programmers);
|
|
|
|
fprintf(stderr,"\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-21 21:07:43 +00:00
|
|
|
if (programmer[0] == 0) {
|
2004-02-09 23:43:42 +00:00
|
|
|
fprintf(stderr,
|
2003-02-21 21:07:43 +00:00
|
|
|
"\n%s: no programmer has been specified on the command line "
|
2004-02-09 23:43:42 +00:00
|
|
|
"or the config file\n",
|
2003-02-21 21:07:43 +00:00
|
|
|
progname);
|
2004-02-09 23:43:42 +00:00
|
|
|
fprintf(stderr,
|
2003-02-21 21:07:43 +00:00
|
|
|
"%sSpecify a programmer using the -c option and try again\n\n",
|
|
|
|
progbuf);
|
|
|
|
exit(1);
|
2001-10-14 23:17:26 +00:00
|
|
|
}
|
2003-02-21 21:07:43 +00:00
|
|
|
|
|
|
|
pgm = locate_programmer(programmers, programmer);
|
|
|
|
if (pgm == NULL) {
|
2003-02-22 16:45:13 +00:00
|
|
|
fprintf(stderr,"\n");
|
2004-02-09 23:43:42 +00:00
|
|
|
fprintf(stderr,
|
2003-02-21 21:07:43 +00:00
|
|
|
"%s: Can't find programmer id \"%s\"\n",
|
|
|
|
progname, programmer);
|
2003-02-22 16:45:13 +00:00
|
|
|
fprintf(stderr,"\nValid programmers are:\n");
|
|
|
|
list_programmers(stderr, " ", programmers);
|
2003-02-21 21:07:43 +00:00
|
|
|
fprintf(stderr,"\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2005-05-14 14:49:39 +00:00
|
|
|
if ((strcmp(pgm->type, "STK500") == 0) ||
|
|
|
|
(strcmp(pgm->type, "avr910") == 0) ||
|
|
|
|
(strcmp(pgm->type, "STK500V2") == 0) ||
|
|
|
|
(strcmp(pgm->type, "JTAGMKII") == 0)) {
|
2003-02-21 21:07:43 +00:00
|
|
|
if (port == default_parallel) {
|
|
|
|
port = default_serial;
|
2001-10-14 23:17:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (partdesc == NULL) {
|
2004-02-09 23:43:42 +00:00
|
|
|
fprintf(stderr,
|
2003-02-22 16:45:13 +00:00
|
|
|
"%s: No AVR part has been specified, use \"-p Part\"\n\n",
|
2001-10-13 03:13:13 +00:00
|
|
|
progname);
|
2003-02-22 16:45:13 +00:00
|
|
|
fprintf(stderr,"Valid parts are:\n");
|
|
|
|
list_parts(stderr, " ", part_list);
|
2002-12-12 03:59:28 +00:00
|
|
|
fprintf(stderr, "\n");
|
2001-10-14 23:17:26 +00:00
|
|
|
exit(1);
|
2001-01-19 02:46:50 +00:00
|
|
|
}
|
|
|
|
|
2001-10-14 23:17:26 +00:00
|
|
|
|
|
|
|
p = locate_part(part_list, partdesc);
|
|
|
|
if (p == NULL) {
|
2004-02-09 23:43:42 +00:00
|
|
|
fprintf(stderr,
|
2003-02-22 16:45:13 +00:00
|
|
|
"%s: AVR Part \"%s\" not found.\n\n",
|
2001-10-14 23:17:26 +00:00
|
|
|
progname, partdesc);
|
2003-02-22 16:45:13 +00:00
|
|
|
fprintf(stderr,"Valid parts are:\n");
|
|
|
|
list_parts(stderr, " ", part_list);
|
2002-12-12 03:59:28 +00:00
|
|
|
fprintf(stderr, "\n");
|
2001-10-14 23:17:26 +00:00
|
|
|
exit(1);
|
2001-09-19 17:04:25 +00:00
|
|
|
}
|
|
|
|
|
2001-10-14 23:17:26 +00:00
|
|
|
|
2001-09-21 03:27:20 +00:00
|
|
|
if (exitspecs != NULL) {
|
2006-08-29 23:12:15 +00:00
|
|
|
if (pgm->parseexitspecs == NULL) {
|
2004-02-09 23:43:42 +00:00
|
|
|
fprintf(stderr,
|
2005-11-01 23:02:06 +00:00
|
|
|
"%s: WARNING: -E option not supported by this programmer type\n",
|
2002-11-30 14:09:12 +00:00
|
|
|
progname);
|
|
|
|
exitspecs = NULL;
|
|
|
|
}
|
2006-08-29 23:12:15 +00:00
|
|
|
else if (pgm->parseexitspecs(pgm, exitspecs) < 0) {
|
2001-09-21 03:27:20 +00:00
|
|
|
usage();
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-09 23:43:42 +00:00
|
|
|
/*
|
2001-01-19 02:46:50 +00:00
|
|
|
* set up seperate instances of the avr part, one for use in
|
|
|
|
* programming, one for use in verifying. These are separate
|
2004-02-09 23:43:42 +00:00
|
|
|
* because they need separate flash and eeprom buffer space
|
2001-01-19 02:46:50 +00:00
|
|
|
*/
|
2001-10-14 23:17:26 +00:00
|
|
|
p = avr_dup_part(p);
|
|
|
|
v = avr_dup_part(p);
|
2001-01-19 02:46:50 +00:00
|
|
|
|
|
|
|
/*
|
2002-11-30 14:09:12 +00:00
|
|
|
* open the programmer
|
2001-01-19 02:46:50 +00:00
|
|
|
*/
|
2003-02-21 18:46:51 +00:00
|
|
|
if (port[0] == 0) {
|
2003-02-21 21:07:43 +00:00
|
|
|
fprintf(stderr, "\n%s: no port has been specified on the command line "
|
2004-01-28 20:01:44 +00:00
|
|
|
"or the config file\n",
|
2003-02-21 18:46:51 +00:00
|
|
|
progname);
|
|
|
|
fprintf(stderr, "%sSpecify a port using the -P option and try again\n\n",
|
|
|
|
progbuf);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (verbose) {
|
|
|
|
fprintf(stderr, "%sUsing Port : %s\n", progbuf, port);
|
2003-02-21 21:07:43 +00:00
|
|
|
fprintf(stderr, "%sUsing Programmer : %s\n", progbuf, programmer);
|
2003-02-21 18:46:51 +00:00
|
|
|
}
|
|
|
|
|
2004-05-19 23:00:38 +00:00
|
|
|
if (baudrate != 0) {
|
|
|
|
if (verbose) {
|
|
|
|
fprintf(stderr, "%sOverriding Baud Rate : %d\n", progbuf, baudrate);
|
|
|
|
}
|
|
|
|
pgm->baudrate = baudrate;
|
|
|
|
}
|
|
|
|
|
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
2005-05-10 19:17:12 +00:00
|
|
|
if (bitclock != 0.0) {
|
|
|
|
if (verbose) {
|
|
|
|
fprintf(stderr, "%sSetting bit clk period: %.1f\n", progbuf, bitclock);
|
|
|
|
}
|
2006-01-17 21:11:39 +00:00
|
|
|
|
2005-09-21 15:02:02 +00:00
|
|
|
pgm->bitclock = bitclock * 1e-6;
|
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
2005-05-10 19:17:12 +00:00
|
|
|
}
|
|
|
|
|
2006-08-17 15:06:20 +00:00
|
|
|
if (ispdelay != 0) {
|
|
|
|
if (verbose) {
|
|
|
|
fprintf(stderr, "%sSetting isp clock delay: %3i\n", progbuf, ispdelay);
|
|
|
|
}
|
|
|
|
pgm->ispdelay = ispdelay;
|
|
|
|
}
|
|
|
|
|
2004-01-28 20:01:44 +00:00
|
|
|
rc = pgm->open(pgm, port);
|
|
|
|
if (rc < 0) {
|
|
|
|
exitrc = 1;
|
|
|
|
pgm->ppidata = 0; /* clear all bits at exit */
|
|
|
|
goto main_exit;
|
|
|
|
}
|
2001-01-19 02:46:50 +00:00
|
|
|
|
2002-12-01 06:35:18 +00:00
|
|
|
if (verbose) {
|
|
|
|
avr_display(stderr, p, progbuf, verbose);
|
|
|
|
fprintf(stderr, "\n");
|
2003-02-21 21:07:43 +00:00
|
|
|
programmer_display(progbuf);
|
2002-12-01 06:35:18 +00:00
|
|
|
}
|
|
|
|
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
}
|
2002-12-01 06:35:18 +00:00
|
|
|
|
2001-01-19 02:46:50 +00:00
|
|
|
exitrc = 0;
|
|
|
|
|
2002-11-23 00:47:29 +00:00
|
|
|
/*
|
2002-11-30 14:09:12 +00:00
|
|
|
* enable the programmer
|
2002-11-23 00:47:29 +00:00
|
|
|
*/
|
2002-11-30 14:09:12 +00:00
|
|
|
pgm->enable(pgm);
|
2002-11-23 00:47:29 +00:00
|
|
|
|
2001-01-24 19:10:34 +00:00
|
|
|
/*
|
2002-11-30 14:09:12 +00:00
|
|
|
* turn off all the status leds
|
2001-01-24 19:10:34 +00:00
|
|
|
*/
|
2002-11-30 14:09:12 +00:00
|
|
|
pgm->rdy_led(pgm, OFF);
|
|
|
|
pgm->err_led(pgm, OFF);
|
|
|
|
pgm->pgm_led(pgm, OFF);
|
|
|
|
pgm->vfy_led(pgm, OFF);
|
2001-01-24 19:10:34 +00:00
|
|
|
|
2001-01-19 02:46:50 +00:00
|
|
|
/*
|
|
|
|
* initialize the chip in preperation for accepting commands
|
|
|
|
*/
|
2002-11-30 14:09:12 +00:00
|
|
|
rc = pgm->initialize(pgm, p);
|
2001-01-19 02:46:50 +00:00
|
|
|
if (rc < 0) {
|
2001-10-13 03:13:13 +00:00
|
|
|
fprintf(stderr, "%s: initialization failed, rc=%d\n", progname, rc);
|
2003-08-31 15:40:59 +00:00
|
|
|
if (!ovsigck) {
|
|
|
|
fprintf(stderr, "%sDouble check connections and try again, "
|
|
|
|
"or use -F to override\n"
|
|
|
|
"%sthis check.\n\n",
|
|
|
|
progbuf, progbuf);
|
|
|
|
exitrc = 1;
|
|
|
|
goto main_exit;
|
|
|
|
}
|
2001-01-19 02:46:50 +00:00
|
|
|
}
|
|
|
|
|
2001-01-24 19:10:34 +00:00
|
|
|
/* indicate ready */
|
2002-11-30 14:09:12 +00:00
|
|
|
pgm->rdy_led(pgm, ON);
|
2001-01-24 19:10:34 +00:00
|
|
|
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"%s: AVR device initialized and ready to accept instructions\n",
|
|
|
|
progname);
|
|
|
|
}
|
2001-01-19 02:46:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Let's read the signature bytes to make sure there is at least a
|
|
|
|
* chip on the other end that is responding correctly. A check
|
2006-02-27 17:18:42 +00:00
|
|
|
* against 0xffffff / 0x000000 should ensure that the signature bytes
|
|
|
|
* are valid.
|
2001-01-19 02:46:50 +00:00
|
|
|
*/
|
2002-11-30 14:09:12 +00:00
|
|
|
rc = avr_signature(pgm, p);
|
2001-11-21 02:46:55 +00:00
|
|
|
if (rc != 0) {
|
|
|
|
fprintf(stderr, "%s: error reading signature data, rc=%d\n",
|
|
|
|
progname, rc);
|
2005-07-26 04:13:34 +00:00
|
|
|
exitrc = 1;
|
|
|
|
goto main_exit;
|
2001-11-21 02:46:55 +00:00
|
|
|
}
|
2001-01-19 02:46:50 +00:00
|
|
|
|
2001-11-21 02:46:55 +00:00
|
|
|
sig = avr_locate_mem(p, "signature");
|
|
|
|
if (sig == NULL) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"%s: WARNING: signature data not defined for device \"%s\"\n",
|
|
|
|
progname, p->desc);
|
2002-08-01 01:00:03 +00:00
|
|
|
}
|
2001-11-21 02:46:55 +00:00
|
|
|
|
|
|
|
if (sig != NULL) {
|
2006-02-27 17:18:42 +00:00
|
|
|
int ff, zz;
|
2001-11-21 02:46:55 +00:00
|
|
|
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
|
|
|
fprintf(stderr, "%s: Device signature = 0x", progname);
|
|
|
|
}
|
2006-02-27 17:18:42 +00:00
|
|
|
ff = zz = 1;
|
2001-11-21 02:46:55 +00:00
|
|
|
for (i=0; i<sig->size; i++) {
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
|
|
|
fprintf(stderr, "%02x", sig->buf[i]);
|
|
|
|
}
|
2001-11-21 02:46:55 +00:00
|
|
|
if (sig->buf[i] != 0xff)
|
|
|
|
ff = 0;
|
2006-02-27 17:18:42 +00:00
|
|
|
if (sig->buf[i] != 0x00)
|
|
|
|
zz = 0;
|
2001-11-21 02:46:55 +00:00
|
|
|
}
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
}
|
2001-11-21 02:46:55 +00:00
|
|
|
|
2006-02-27 17:18:42 +00:00
|
|
|
if (ff || zz) {
|
2004-02-09 23:43:42 +00:00
|
|
|
fprintf(stderr,
|
2001-11-21 02:46:55 +00:00
|
|
|
"%s: Yikes! Invalid device signature.\n", progname);
|
|
|
|
if (!ovsigck) {
|
|
|
|
fprintf(stderr, "%sDouble check connections and try again, "
|
|
|
|
"or use -F to override\n"
|
|
|
|
"%sthis check.\n\n",
|
|
|
|
progbuf, progbuf);
|
|
|
|
exitrc = 1;
|
|
|
|
goto main_exit;
|
|
|
|
}
|
2006-02-27 17:18:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sig->size != 3 ||
|
|
|
|
sig->buf[0] != p->signature[0] ||
|
|
|
|
sig->buf[1] != p->signature[1] ||
|
|
|
|
sig->buf[2] != p->signature[2]) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"%s: Expected signature for %s is %02X %02X %02X\n",
|
|
|
|
progname, p->desc,
|
|
|
|
p->signature[0], p->signature[1], p->signature[2]);
|
|
|
|
if (!ovsigck) {
|
|
|
|
fprintf(stderr, "%sDouble check chip, "
|
|
|
|
"or use -F to override this check.\n",
|
|
|
|
progbuf);
|
|
|
|
exitrc = 1;
|
|
|
|
goto main_exit;
|
|
|
|
}
|
2001-01-19 02:46:50 +00:00
|
|
|
}
|
|
|
|
}
|
2005-02-10 16:34:55 +00:00
|
|
|
|
2005-01-24 21:26:11 +00:00
|
|
|
if (safemode == 1) {
|
2005-02-10 16:34:55 +00:00
|
|
|
/* If safemode is enabled, go ahead and read the current low, high,
|
|
|
|
and extended fuse bytes as needed */
|
|
|
|
|
|
|
|
if (safemode_readfuses(&safemode_lfuse, &safemode_hfuse,
|
2005-09-21 00:20:32 +00:00
|
|
|
&safemode_efuse, &safemode_fuse, pgm, p, verbose) != 0) {
|
2005-02-10 16:34:55 +00:00
|
|
|
fprintf(stderr, "%s: safemode: To protect your AVR the programming "
|
|
|
|
"will be aborted\n",
|
|
|
|
progname);
|
|
|
|
exitrc = 1;
|
|
|
|
goto main_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Save the fuses as default
|
2005-09-21 00:20:32 +00:00
|
|
|
safemode_memfuses(1, &safemode_lfuse, &safemode_hfuse, &safemode_efuse, &safemode_fuse);
|
2005-01-24 21:26:11 +00:00
|
|
|
}
|
2001-01-19 02:46:50 +00:00
|
|
|
|
2005-02-10 16:34:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2003-08-29 23:17:32 +00:00
|
|
|
if ((erase == 0) && (auto_erase == 1)) {
|
|
|
|
AVRMEM * m;
|
|
|
|
|
|
|
|
for (ln=lfirst(updates); ln; ln=lnext(ln)) {
|
|
|
|
upd = ldata(ln);
|
|
|
|
m = avr_locate_mem(p, upd->memtype);
|
|
|
|
if (m == NULL)
|
|
|
|
continue;
|
|
|
|
if ((strcasecmp(m->desc, "flash") == 0) && (upd->op == DEVICE_WRITE)) {
|
|
|
|
erase = 1;
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
|
|
|
fprintf(stderr,
|
2004-07-15 17:29:35 +00:00
|
|
|
"%s: NOTE: FLASH memory has been specified, an erase cycle "
|
|
|
|
"will be performed\n"
|
2003-08-29 23:17:32 +00:00
|
|
|
"%sTo disable this feature, specify the -D option.\n",
|
|
|
|
progname, progbuf);
|
2005-09-16 21:52:42 +00:00
|
|
|
}
|
2003-08-29 23:17:32 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-10 16:34:55 +00:00
|
|
|
/*
|
2004-01-03 18:04:54 +00:00
|
|
|
* Display cycle count, if and only if it is not set later on.
|
|
|
|
*
|
|
|
|
* The cycle count will be displayed anytime it will be changed later.
|
2005-02-10 16:34:55 +00:00
|
|
|
*/
|
2004-01-03 18:04:54 +00:00
|
|
|
if ((set_cycles == -1) && ((erase == 0) || (do_cycles == 0))) {
|
2002-08-01 02:06:48 +00:00
|
|
|
/*
|
2002-11-06 02:19:57 +00:00
|
|
|
* see if the cycle count in the last four bytes of eeprom seems
|
2004-02-09 23:43:42 +00:00
|
|
|
* reasonable
|
2002-08-01 02:06:48 +00:00
|
|
|
*/
|
2002-11-30 14:09:12 +00:00
|
|
|
rc = avr_get_cycle_count(pgm, p, &cycles);
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
|
|
|
if ((rc >= 0) && (cycles != 0)) {
|
|
|
|
fprintf(stderr,
|
2002-08-01 02:06:48 +00:00
|
|
|
"%s: current erase-rewrite cycle count is %d%s\n",
|
2004-02-09 23:43:42 +00:00
|
|
|
progname, cycles,
|
2002-08-01 02:06:48 +00:00
|
|
|
do_cycles ? "" : " (if being tracked)");
|
2005-09-16 21:52:42 +00:00
|
|
|
}
|
2002-08-01 02:06:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-03 18:04:54 +00:00
|
|
|
if (set_cycles != -1) {
|
|
|
|
rc = avr_get_cycle_count(pgm, p, &cycles);
|
|
|
|
if (rc == 0) {
|
|
|
|
/*
|
|
|
|
* only attempt to update the cycle counter if we can actually
|
|
|
|
* read the old value
|
|
|
|
*/
|
|
|
|
cycles = set_cycles;
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
|
|
|
fprintf(stderr, "%s: setting erase-rewrite cycle count to %d\n",
|
2004-01-03 18:04:54 +00:00
|
|
|
progname, cycles);
|
2005-09-16 21:52:42 +00:00
|
|
|
}
|
2004-01-03 18:04:54 +00:00
|
|
|
rc = avr_put_cycle_count(pgm, p, cycles);
|
|
|
|
if (rc < 0) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"%s: WARNING: failed to update the erase-rewrite cycle "
|
|
|
|
"counter\n",
|
|
|
|
progname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (erase) {
|
|
|
|
/*
|
|
|
|
* erase the chip's flash and eeprom memories, this is required
|
|
|
|
* before the chip can accept new programming
|
|
|
|
*/
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
|
|
|
fprintf(stderr, "%s: erasing chip\n", progname);
|
|
|
|
}
|
2004-01-03 18:04:54 +00:00
|
|
|
avr_chip_erase(pgm, p);
|
|
|
|
}
|
|
|
|
|
2002-08-01 02:06:48 +00:00
|
|
|
|
2001-01-19 02:46:50 +00:00
|
|
|
if (terminal) {
|
|
|
|
/*
|
|
|
|
* terminal mode
|
2005-01-24 21:26:11 +00:00
|
|
|
*/
|
2002-11-30 14:09:12 +00:00
|
|
|
exitrc = terminal_mode(pgm, p);
|
2001-01-19 02:46:50 +00:00
|
|
|
}
|
|
|
|
|
2001-01-20 16:34:28 +00:00
|
|
|
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
for (ln=lfirst(updates); ln; ln=lnext(ln)) {
|
|
|
|
upd = ldata(ln);
|
|
|
|
rc = do_op(pgm, p, upd, nowrite, verify);
|
|
|
|
if (rc) {
|
2001-01-19 02:46:50 +00:00
|
|
|
exitrc = 1;
|
Introduce a new option, -U, for performing memory operions. Its
argument is a 4 field string (fields seperated by colons) which
indicate what memory type to operate on, what operation to perform is
(read, write, or verify), the filename to read from, write to, or
verify against, and an optional file format field. Multple -U options
can be specified to operate on more than one memory at a time with a
single invocation. For example, to update both the flash and the
eeprom at the same time one can now specify the following:
avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@341 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-21 04:52:36 +00:00
|
|
|
break;
|
2001-01-19 02:46:50 +00:00
|
|
|
}
|
|
|
|
}
|
2005-02-10 16:34:55 +00:00
|
|
|
|
|
|
|
/* Right before we exit programming mode, which will make the fuse
|
|
|
|
bits active, check to make sure they are still correct */
|
2005-01-24 21:26:11 +00:00
|
|
|
if (safemode == 1){
|
2005-02-10 16:34:55 +00:00
|
|
|
/* If safemode is enabled, go ahead and read the current low,
|
|
|
|
* high, and extended fuse bytes as needed */
|
|
|
|
unsigned char safemodeafter_lfuse = 0xff;
|
|
|
|
unsigned char safemodeafter_hfuse = 0xff;
|
2005-09-21 00:20:32 +00:00
|
|
|
unsigned char safemodeafter_efuse = 0xff;
|
|
|
|
unsigned char safemodeafter_fuse = 0xff;
|
2005-02-10 16:34:55 +00:00
|
|
|
unsigned char failures = 0;
|
2005-09-21 00:20:32 +00:00
|
|
|
char yes[1] = {'y'};
|
2005-02-10 16:34:55 +00:00
|
|
|
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
}
|
2005-02-10 16:34:55 +00:00
|
|
|
|
|
|
|
//Restore the default fuse values
|
2005-09-21 00:20:32 +00:00
|
|
|
safemode_memfuses(0, &safemode_lfuse, &safemode_hfuse, &safemode_efuse, &safemode_fuse);
|
2005-02-10 16:34:55 +00:00
|
|
|
|
|
|
|
/* Try reading back fuses, make sure they are reliable to read back */
|
|
|
|
if (safemode_readfuses(&safemodeafter_lfuse, &safemodeafter_hfuse,
|
2006-01-17 20:17:43 +00:00
|
|
|
&safemodeafter_efuse, &safemodeafter_fuse, pgm, p, verbose) != 0) {
|
2005-02-10 16:34:55 +00:00
|
|
|
/* Uh-oh.. try once more to read back fuses */
|
|
|
|
if (safemode_readfuses(&safemodeafter_lfuse, &safemodeafter_hfuse,
|
2005-09-21 00:20:32 +00:00
|
|
|
&safemodeafter_efuse, &safemodeafter_fuse, pgm, p, verbose) != 0) {
|
2005-02-10 16:34:55 +00:00
|
|
|
fprintf(stderr,
|
|
|
|
"%s: safemode: Sorry, reading back fuses was unreliable. "
|
|
|
|
"I have given up and exited programming mode\n",
|
|
|
|
progname);
|
|
|
|
exitrc = 1;
|
|
|
|
goto main_exit;
|
2005-01-24 21:26:11 +00:00
|
|
|
}
|
2005-02-10 16:34:55 +00:00
|
|
|
}
|
2005-09-21 00:20:32 +00:00
|
|
|
|
|
|
|
/* Now check what fuses are against what they should be */
|
|
|
|
if (safemodeafter_fuse != safemode_fuse) {
|
|
|
|
fuses_updated = 1;
|
|
|
|
fprintf(stderr, "%s: safemode: fuse changed! Was %x, and is now %x\n",
|
|
|
|
progname, safemode_fuse, safemodeafter_fuse);
|
|
|
|
|
|
|
|
|
|
|
|
/* Ask user - should we change them */
|
|
|
|
|
|
|
|
if (silentsafe == 0)
|
|
|
|
safemode_response = terminal_get_input("Would you like this fuse to be changed back? [y/n] ");
|
|
|
|
else
|
|
|
|
safemode_response = yes;
|
|
|
|
|
|
|
|
if (tolower(safemode_response[0]) == 'y') {
|
|
|
|
|
|
|
|
/* Enough chit-chat, time to program some fuses and check them */
|
|
|
|
if (safemode_writefuse (safemode_fuse, "fuse", pgm, p,
|
|
|
|
10, verbose) == 0) {
|
|
|
|
fprintf(stderr, "%s: safemode: and is now rescued\n", progname);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(stderr, "%s: and COULD NOT be changed\n", progname);
|
|
|
|
failures++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-02-10 16:34:55 +00:00
|
|
|
|
|
|
|
/* Now check what fuses are against what they should be */
|
|
|
|
if (safemodeafter_lfuse != safemode_lfuse) {
|
2005-02-11 19:03:53 +00:00
|
|
|
fuses_updated = 1;
|
2005-09-21 00:20:32 +00:00
|
|
|
fprintf(stderr, "%s: safemode: lfuse changed! Was %x, and is now %x\n",
|
|
|
|
progname, safemode_lfuse, safemodeafter_lfuse);
|
|
|
|
|
|
|
|
|
|
|
|
/* Ask user - should we change them */
|
|
|
|
|
|
|
|
if (silentsafe == 0)
|
|
|
|
safemode_response = terminal_get_input("Would you like this fuse to be changed back? [y/n] ");
|
|
|
|
else
|
|
|
|
safemode_response = yes;
|
|
|
|
|
|
|
|
if (tolower(safemode_response[0]) == 'y') {
|
|
|
|
|
|
|
|
/* Enough chit-chat, time to program some fuses and check them */
|
|
|
|
if (safemode_writefuse (safemode_lfuse, "lfuse", pgm, p,
|
|
|
|
10, verbose) == 0) {
|
|
|
|
fprintf(stderr, "%s: safemode: and is now rescued\n", progname);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(stderr, "%s: and COULD NOT be changed\n", progname);
|
|
|
|
failures++;
|
|
|
|
}
|
2005-02-10 16:34:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now check what fuses are against what they should be */
|
|
|
|
if (safemodeafter_hfuse != safemode_hfuse) {
|
2005-02-11 19:03:53 +00:00
|
|
|
fuses_updated = 1;
|
2005-09-21 00:20:32 +00:00
|
|
|
fprintf(stderr, "%s: safemode: hfuse changed! Was %x, and is now %x\n",
|
|
|
|
progname, safemode_hfuse, safemodeafter_hfuse);
|
|
|
|
|
|
|
|
/* Ask user - should we change them */
|
|
|
|
if (silentsafe == 0)
|
|
|
|
safemode_response = terminal_get_input("Would you like this fuse to be changed back? [y/n] ");
|
|
|
|
else
|
|
|
|
safemode_response = yes;
|
|
|
|
if (tolower(safemode_response[0]) == 'y') {
|
|
|
|
|
|
|
|
/* Enough chit-chat, time to program some fuses and check them */
|
|
|
|
if (safemode_writefuse(safemode_hfuse, "hfuse", pgm, p,
|
|
|
|
10, verbose) == 0) {
|
|
|
|
fprintf(stderr, "%s: safemode: and is now rescued\n", progname);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(stderr, "%s: and COULD NOT be changed\n", progname);
|
|
|
|
failures++;
|
|
|
|
}
|
2005-02-10 16:34:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now check what fuses are against what they should be */
|
|
|
|
if (safemodeafter_efuse != safemode_efuse) {
|
2005-02-11 19:03:53 +00:00
|
|
|
fuses_updated = 1;
|
2005-09-21 00:20:32 +00:00
|
|
|
fprintf(stderr, "%s: safemode: efuse changed! Was %x, and is now %x\n",
|
|
|
|
progname, safemode_efuse, safemodeafter_efuse);
|
|
|
|
|
|
|
|
/* Ask user - should we change them */
|
|
|
|
if (silentsafe == 0)
|
|
|
|
safemode_response = terminal_get_input("Would you like this fuse to be changed back? [y/n] ");
|
|
|
|
else
|
|
|
|
safemode_response = yes;
|
|
|
|
if (tolower(safemode_response[0]) == 'y') {
|
|
|
|
|
|
|
|
/* Enough chit-chat, time to program some fuses and check them */
|
|
|
|
if (safemode_writefuse (safemode_efuse, "efuse", pgm, p,
|
|
|
|
10, verbose) == 0) {
|
|
|
|
fprintf(stderr, "%s: safemode: and is now rescued\n", progname);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(stderr, "%s: and COULD NOT be changed\n", progname);
|
|
|
|
failures++;
|
|
|
|
}
|
|
|
|
}
|
2005-02-10 16:34:55 +00:00
|
|
|
}
|
|
|
|
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
|
|
|
fprintf(stderr, "%s: safemode: ", progname);
|
|
|
|
if (failures == 0) {
|
|
|
|
fprintf(stderr, "Fuses OK\n");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(stderr, "Fuses not recovered, sorry\n");
|
|
|
|
}
|
2005-02-10 16:34:55 +00:00
|
|
|
}
|
|
|
|
|
2005-02-11 19:03:53 +00:00
|
|
|
if (fuses_updated && fuses_specified) {
|
|
|
|
exitrc = 1;
|
|
|
|
}
|
|
|
|
|
2005-02-10 16:34:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
main_exit:
|
2001-01-19 02:46:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* program complete
|
|
|
|
*/
|
2005-02-10 16:34:55 +00:00
|
|
|
|
2001-01-19 02:46:50 +00:00
|
|
|
|
2002-11-30 14:09:12 +00:00
|
|
|
pgm->powerdown(pgm);
|
2001-09-21 03:27:20 +00:00
|
|
|
|
2002-11-30 14:09:12 +00:00
|
|
|
pgm->disable(pgm);
|
2001-01-24 19:10:34 +00:00
|
|
|
|
2002-11-30 14:09:12 +00:00
|
|
|
pgm->rdy_led(pgm, OFF);
|
2001-02-08 01:42:09 +00:00
|
|
|
|
2002-11-30 14:09:12 +00:00
|
|
|
pgm->close(pgm);
|
2001-01-19 02:46:50 +00:00
|
|
|
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
|
|
|
fprintf(stderr, "\n%s done. Thank you.\n\n", progname);
|
|
|
|
}
|
2001-01-19 02:46:50 +00:00
|
|
|
|
|
|
|
return exitrc;
|
|
|
|
}
|