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>
|
2014-02-28 14:26:24 +00:00
|
|
|
* Copyright 2007-2014 Joerg Wunsch <j@uriah.heep.sax.de>
|
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
|
2012-11-20 14:03:50 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
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>
|
2014-05-18 08:41:46 +00:00
|
|
|
#include <stdarg.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
|
|
|
|
2014-05-19 10:01:59 +00:00
|
|
|
#include "avrdude.h"
|
|
|
|
#include "libavrdude.h"
|
|
|
|
|
2001-01-19 02:46:50 +00:00
|
|
|
#include "term.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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
char * progname;
|
|
|
|
char progbuf[PATH_MAX]; /* temporary buffer of spaces the same
|
|
|
|
length as progname; used for lining up
|
|
|
|
multiline messages */
|
|
|
|
|
2014-06-13 20:07:40 +00:00
|
|
|
int avrdude_message(const int msglvl, const char *format, ...)
|
2014-05-18 08:41:46 +00:00
|
|
|
{
|
2014-06-13 20:07:40 +00:00
|
|
|
int rc = 0;
|
2014-05-18 08:41:46 +00:00
|
|
|
va_list ap;
|
2014-06-13 20:07:40 +00:00
|
|
|
if (verbose >= msglvl) {
|
|
|
|
va_start(ap, format);
|
|
|
|
rc = vfprintf(stderr, format, ap);
|
|
|
|
va_end(ap);
|
|
|
|
}
|
2014-05-18 08:41:46 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2014-05-16 15:52:25 +00:00
|
|
|
|
2007-01-29 20:41:47 +00:00
|
|
|
struct list_walk_cookie
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
const char *prefix;
|
|
|
|
};
|
|
|
|
|
2012-01-17 20:56:37 +00:00
|
|
|
static LISTID updates = 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
|
|
|
|
2012-01-17 20:56:37 +00:00
|
|
|
static LISTID extended_params = NULL;
|
2007-11-06 19:42:16 +00:00
|
|
|
|
2012-01-17 20:56:37 +00:00
|
|
|
static LISTID additional_config_files = NULL;
|
2012-01-10 18:07:19 +00:00
|
|
|
|
main.c, pgm.c, pgm.h: Add setup and teardown hooks to the programmer
definition. If present, call the setup hook immediately after finding
the respective programmer object, and schedule the teardown hook to be
called upon exit. This allows the programmer implementation to
dynamically allocate private programmer data.
avr910.c, butterfly.c, jtagmkI.c, jtagmkII.c, stk500v2.c, usbasp.c,
usbtiny.c: Convert static programmer data into dynamically allocated
data.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@764 81a1dc3b-b13d-400b-aceb-764788c761c2
2007-11-07 20:36:12 +00:00
|
|
|
static PROGRAMMER * pgm;
|
|
|
|
|
2002-08-01 02:06:48 +00:00
|
|
|
/*
|
|
|
|
* global options
|
|
|
|
*/
|
2007-01-24 21:07:54 +00:00
|
|
|
int verbose; /* verbose output */
|
|
|
|
int quell_progress; /* un-verebose output */
|
|
|
|
int ovsigck; /* 1=override sig check, 0=don't */
|
2002-08-01 02:06:48 +00:00
|
|
|
|
2001-09-19 17:04:25 +00:00
|
|
|
|
2014-05-18 08:41:46 +00:00
|
|
|
|
|
|
|
|
2001-01-19 02:46:50 +00:00
|
|
|
/*
|
|
|
|
* usage message
|
|
|
|
*/
|
2007-01-24 22:43:46 +00:00
|
|
|
static void usage(void)
|
2001-01-19 02:46:50 +00:00
|
|
|
{
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO,
|
2005-02-10 16:34:55 +00:00
|
|
|
"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"
|
2006-10-09 14:34:24 +00:00
|
|
|
" -O Perform RC oscillator calibration (see AVR053). \n"
|
2005-02-10 16:34:55 +00:00
|
|
|
" -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"
|
2007-11-06 19:42:16 +00:00
|
|
|
" -x <extended_param> Pass <extended_param> to programmer.\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"
|
2013-05-16 09:11:32 +00:00
|
|
|
" -l logfile Use logfile rather than stderr for diagnostics.\n"
|
2005-02-10 16:34:55 +00:00
|
|
|
" -? Display this usage.\n"
|
2009-07-02 08:42:14 +00:00
|
|
|
"\navrdude version %s, URL: <http://savannah.nongnu.org/projects/avrdude/>\n"
|
|
|
|
,progname, version);
|
2001-01-19 02:46:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2007-11-08 22:34:36 +00:00
|
|
|
setvbuf(stderr, (char*)NULL, _IONBF, 0);
|
|
|
|
|
2003-07-29 22:08:21 +00:00
|
|
|
hashes[50] = 0;
|
|
|
|
|
|
|
|
memset (hashes, ' ', 50);
|
|
|
|
for (i=0; i<percent; i+=2) {
|
|
|
|
hashes[i/2] = '#';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hdr) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\n");
|
2003-07-29 22:08:21 +00:00
|
|
|
last = 0;
|
|
|
|
header = hdr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (last == 0) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\r%s | %s | %d%% %0.2fs",
|
2003-07-30 23:01:52 +00:00
|
|
|
header, hashes, percent, etime);
|
2003-07-29 22:08:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (percent == 100) {
|
2014-06-13 20:07:40 +00:00
|
|
|
if (!last) avrdude_message(MSG_INFO, "\n\n");
|
2003-07-29 22:08:21 +00:00
|
|
|
last = 1;
|
|
|
|
}
|
2007-11-08 22:34:36 +00:00
|
|
|
|
|
|
|
setvbuf(stderr, (char*)NULL, _IOLBF, 0);
|
2003-07-29 22:08:21 +00:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2007-11-08 22:34:36 +00:00
|
|
|
setvbuf(stderr, (char*)NULL, _IONBF, 0);
|
|
|
|
|
2003-07-29 22:08:21 +00:00
|
|
|
if (hdr) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\n%s | ", hdr);
|
2003-07-29 22:08:21 +00:00
|
|
|
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)) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "#");
|
2003-07-29 22:08:21 +00:00
|
|
|
cnt -= 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-28 05:37:57 +00:00
|
|
|
if ((percent == 100) && (done == 0)) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, " | 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. */
|
2007-11-08 22:34:36 +00:00
|
|
|
|
|
|
|
setvbuf(stderr, (char*)NULL, _IOLBF, 0);
|
2003-07-29 22:08:21 +00:00
|
|
|
}
|
2001-09-19 17:04:25 +00:00
|
|
|
|
2007-01-29 20:41:47 +00:00
|
|
|
static void list_programmers_callback(const char *name, const char *desc,
|
|
|
|
const char *cfgname, int cfglineno,
|
|
|
|
void *cookie)
|
|
|
|
{
|
|
|
|
struct list_walk_cookie *c = (struct list_walk_cookie *)cookie;
|
2011-12-16 20:44:07 +00:00
|
|
|
if (verbose){
|
|
|
|
fprintf(c->f, "%s%-16s = %-30s [%s:%d]\n",
|
|
|
|
c->prefix, name, desc, cfgname, cfglineno);
|
|
|
|
} else {
|
|
|
|
fprintf(c->f, "%s%-16s = %-s\n",
|
|
|
|
c->prefix, name, desc);
|
|
|
|
}
|
2007-01-29 20:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void list_programmers(FILE * f, const char *prefix, LISTID programmers)
|
|
|
|
{
|
|
|
|
struct list_walk_cookie c;
|
|
|
|
|
|
|
|
c.f = f;
|
|
|
|
c.prefix = prefix;
|
|
|
|
|
2011-12-16 20:44:07 +00:00
|
|
|
sort_programmers(programmers);
|
|
|
|
|
2007-01-29 20:41:47 +00:00
|
|
|
walk_programmers(programmers, list_programmers_callback, &c);
|
|
|
|
}
|
|
|
|
|
2012-01-31 17:03:43 +00:00
|
|
|
static void list_programmer_types_callback(const char *name, const char *desc,
|
|
|
|
void *cookie)
|
|
|
|
{
|
|
|
|
struct list_walk_cookie *c = (struct list_walk_cookie *)cookie;
|
|
|
|
fprintf(c->f, "%s%-16s = %-s\n",
|
|
|
|
c->prefix, name, desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void list_programmer_types(FILE * f, const char *prefix)
|
|
|
|
{
|
|
|
|
struct list_walk_cookie c;
|
|
|
|
|
|
|
|
c.f = f;
|
|
|
|
c.prefix = prefix;
|
|
|
|
|
|
|
|
walk_programmer_types(list_programmer_types_callback, &c);
|
|
|
|
}
|
|
|
|
|
2007-01-29 20:41:47 +00:00
|
|
|
static void list_avrparts_callback(const char *name, const char *desc,
|
|
|
|
const char *cfgname, int cfglineno,
|
|
|
|
void *cookie)
|
|
|
|
{
|
|
|
|
struct list_walk_cookie *c = (struct list_walk_cookie *)cookie;
|
|
|
|
|
2012-01-27 21:14:34 +00:00
|
|
|
/* hide ids starting with '.' */
|
|
|
|
if ((verbose < 2) && (name[0] == '.'))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (verbose) {
|
2011-12-16 20:44:07 +00:00
|
|
|
fprintf(c->f, "%s%-8s = %-18s [%s:%d]\n",
|
|
|
|
c->prefix, name, desc, cfgname, cfglineno);
|
|
|
|
} else {
|
|
|
|
fprintf(c->f, "%s%-8s = %s\n",
|
|
|
|
c->prefix, name, desc);
|
|
|
|
}
|
2007-01-29 20:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void list_parts(FILE * f, const char *prefix, LISTID avrparts)
|
|
|
|
{
|
|
|
|
struct list_walk_cookie c;
|
|
|
|
|
|
|
|
c.f = f;
|
|
|
|
c.prefix = prefix;
|
|
|
|
|
2011-12-16 20:44:07 +00:00
|
|
|
sort_avrparts(avrparts);
|
|
|
|
|
2007-01-29 20:41:47 +00:00
|
|
|
walk_avrparts(avrparts, list_avrparts_callback, &c);
|
|
|
|
}
|
|
|
|
|
main.c, pgm.c, pgm.h: Add setup and teardown hooks to the programmer
definition. If present, call the setup hook immediately after finding
the respective programmer object, and schedule the teardown hook to be
called upon exit. This allows the programmer implementation to
dynamically allocate private programmer data.
avr910.c, butterfly.c, jtagmkI.c, jtagmkII.c, stk500v2.c, usbasp.c,
usbtiny.c: Convert static programmer data into dynamically allocated
data.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@764 81a1dc3b-b13d-400b-aceb-764788c761c2
2007-11-07 20:36:12 +00:00
|
|
|
static void exithook(void)
|
|
|
|
{
|
|
|
|
if (pgm->teardown)
|
|
|
|
pgm->teardown(pgm);
|
|
|
|
}
|
|
|
|
|
2012-01-17 20:56:37 +00:00
|
|
|
static void cleanup_main(void)
|
|
|
|
{
|
|
|
|
if (updates) {
|
2012-01-31 17:03:43 +00:00
|
|
|
ldestroy_cb(updates, (void(*)(void*))free_update);
|
2012-01-17 20:56:37 +00:00
|
|
|
updates = NULL;
|
|
|
|
}
|
|
|
|
if (extended_params) {
|
|
|
|
ldestroy(extended_params);
|
|
|
|
extended_params = NULL;
|
|
|
|
}
|
|
|
|
if (additional_config_files) {
|
|
|
|
ldestroy(additional_config_files);
|
|
|
|
additional_config_files = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup_config();
|
|
|
|
}
|
|
|
|
|
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 */
|
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;
|
2007-01-24 22:43:46 +00:00
|
|
|
|
2001-01-19 02:46:50 +00:00
|
|
|
|
|
|
|
/* options / operating mode variables */
|
|
|
|
int erase; /* 1=erase chip, 0=don't */
|
2006-10-09 14:34:24 +00:00
|
|
|
int calibrate; /* 1=calibrate RC oscillator, 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 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-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 */
|
2008-07-29 21:26:55 +00:00
|
|
|
int init_ok; /* Device initialization worked well */
|
2010-01-13 12:44:54 +00:00
|
|
|
int is_open; /* Device open succeeded */
|
2013-05-16 09:11:32 +00:00
|
|
|
char * logfile; /* Use logfile rather than stderr for diagnostics */
|
2012-05-04 10:02:30 +00:00
|
|
|
enum updateflags uflags = UF_AUTO_ERASE; /* Flags for do_op() */
|
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
|
|
|
|
2007-10-29 22:46:45 +00:00
|
|
|
/*
|
|
|
|
* Set line buffering for file descriptors so we see stdout and stderr
|
|
|
|
* properly interleaved.
|
|
|
|
*/
|
|
|
|
setvbuf(stdout, (char*)NULL, _IOLBF, 0);
|
|
|
|
setvbuf(stderr, (char*)NULL, _IOLBF, 0);
|
|
|
|
|
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;
|
2011-08-26 20:30:26 +00:00
|
|
|
default_bitclock = 0.0;
|
2013-09-13 17:22:38 +00:00
|
|
|
default_safemode = -1;
|
2003-02-21 18:46:51 +00:00
|
|
|
|
2001-10-14 23:17:26 +00:00
|
|
|
init_config();
|
|
|
|
|
2012-01-17 20:56:37 +00:00
|
|
|
atexit(cleanup_main);
|
|
|
|
|
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) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: cannot initialize updater list\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
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2007-11-06 19:42:16 +00:00
|
|
|
extended_params = lcreat(NULL, 0);
|
|
|
|
if (extended_params == NULL) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: cannot initialize extended parameter list\n", progname);
|
2007-11-06 19:42:16 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2012-01-10 18:07:19 +00:00
|
|
|
additional_config_files = lcreat(NULL, 0);
|
|
|
|
if (additional_config_files == NULL) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: cannot initialize additional config files list\n", progname);
|
2012-01-10 18:07:19 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2001-10-14 23:17:26 +00:00
|
|
|
partdesc = NULL;
|
2012-01-30 17:08:48 +00:00
|
|
|
port = NULL;
|
2001-09-19 17:04:25 +00:00
|
|
|
erase = 0;
|
2006-10-09 14:34:24 +00:00
|
|
|
calibrate = 0;
|
2001-09-19 17:04:25 +00:00
|
|
|
p = NULL;
|
|
|
|
ovsigck = 0;
|
|
|
|
terminal = 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;
|
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 */
|
2010-01-13 12:44:54 +00:00
|
|
|
is_open = 0;
|
2013-05-16 09:11:32 +00:00
|
|
|
logfile = NULL;
|
2007-11-06 19:42:16 +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
|
|
|
|
*/
|
2013-05-16 09:11:32 +00:00
|
|
|
while ((ch = getopt(argc,argv,"?b:B:c:C:DeE:Fi:l:np:OP:qstU:uvVx:yY:")) != -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)) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: invalid baud rate specified '%s'\n",
|
2004-05-19 23:00:38 +00:00
|
|
|
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) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: invalid bit clock period specified '%s'\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
|
|
|
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) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: invalid isp clock delay specified '%s'\n",
|
2006-08-17 15:06:20 +00:00
|
|
|
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 */
|
2012-01-10 18:07:19 +00:00
|
|
|
if (optarg[0] == '+') {
|
|
|
|
ladd(additional_config_files, optarg+1);
|
|
|
|
} else {
|
|
|
|
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 */
|
2012-05-04 10:02:30 +00:00
|
|
|
uflags &= ~UF_AUTO_ERASE;
|
2003-08-29 23:17:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'e': /* perform a chip erase */
|
|
|
|
erase = 1;
|
2012-05-04 10:02:30 +00:00
|
|
|
uflags &= ~UF_AUTO_ERASE;
|
2003-08-29 23:17:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'E':
|
|
|
|
exitspecs = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'F': /* override invalid signature check */
|
|
|
|
ovsigck = 1;
|
|
|
|
break;
|
|
|
|
|
2013-05-16 09:11:32 +00:00
|
|
|
case 'l':
|
|
|
|
logfile = optarg;
|
|
|
|
break;
|
|
|
|
|
2001-01-19 02:46:50 +00:00
|
|
|
case 'n':
|
2012-05-04 10:02:30 +00:00
|
|
|
uflags |= UF_NOWRITE;
|
2001-01-19 02:46:50 +00:00
|
|
|
break;
|
|
|
|
|
2006-10-09 14:34:24 +00:00
|
|
|
case 'O': /* perform RC oscillator calibration */
|
|
|
|
calibrate = 1;
|
|
|
|
break;
|
|
|
|
|
2001-01-19 02:46:50 +00:00
|
|
|
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) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: error parsing update operation '%s'\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, 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;
|
|
|
|
|
2007-11-06 19:42:16 +00:00
|
|
|
case 'x':
|
|
|
|
ladd(extended_params, optarg);
|
|
|
|
break;
|
|
|
|
|
2002-08-01 01:00:03 +00:00
|
|
|
case 'y':
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: erase cycle counter no longer supported\n",
|
2013-09-03 20:13:37 +00:00
|
|
|
progname);
|
2002-08-01 01:00:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Y':
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: erase cycle counter no longer supported\n",
|
2013-09-03 20:13:37 +00:00
|
|
|
progname);
|
2002-08-01 01:00:03 +00:00
|
|
|
break;
|
|
|
|
|
2001-01-19 02:46:50 +00:00
|
|
|
case '?': /* help */
|
|
|
|
usage();
|
|
|
|
exit(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: invalid option -%c\n\n", progname, ch);
|
2001-01-19 02:46:50 +00:00
|
|
|
usage();
|
|
|
|
exit(1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-05-16 09:11:32 +00:00
|
|
|
if (logfile != NULL) {
|
|
|
|
FILE *newstderr = freopen(logfile, "w", stderr);
|
|
|
|
if (newstderr == NULL) {
|
|
|
|
/* Help! There's no stderr to complain to anymore now. */
|
|
|
|
printf("Cannot create logfile \"%s\": %s\n",
|
|
|
|
logfile, strerror(errno));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2014-06-13 20:07:40 +00:00
|
|
|
/*
|
|
|
|
* Print out an identifying string so folks can tell what version
|
|
|
|
* they are running
|
|
|
|
*/
|
|
|
|
avrdude_message(MSG_NOTICE, "\n%s: Version %s, compiled on %s at %s\n"
|
2014-05-18 08:41:46 +00:00
|
|
|
"%sCopyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/\n"
|
|
|
|
"%sCopyright (c) 2007-2014 Joerg Wunsch\n\n",
|
|
|
|
progname, version, __DATE__, __TIME__, progbuf, progbuf);
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_NOTICE, "%sSystem wide configuration file is \"%s\"\n",
|
2003-02-22 16:45:13 +00:00
|
|
|
progbuf, sys_config);
|
|
|
|
|
|
|
|
rc = read_config(sys_config);
|
2001-10-14 23:17:26 +00:00
|
|
|
if (rc) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: error reading system wide configuration file \"%s\"\n",
|
2014-05-18 08:41:46 +00:00
|
|
|
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) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_NOTICE, "%sUser configuration file is \"%s\"\n",
|
2003-02-22 16:45:13 +00:00
|
|
|
progbuf, usr_config);
|
|
|
|
|
|
|
|
rc = stat(usr_config, &sb);
|
|
|
|
if ((rc < 0) || ((sb.st_mode & S_IFREG) == 0)) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_NOTICE, "%sUser configuration file does not exist or is not a "
|
|
|
|
"regular file, skipping\n",
|
|
|
|
progbuf);
|
2003-02-22 16:45:13 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
rc = read_config(usr_config);
|
|
|
|
if (rc) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: error reading user configuration file \"%s\"\n",
|
2003-02-22 16:45:13 +00:00
|
|
|
progname, usr_config);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-01-10 18:07:19 +00:00
|
|
|
|
|
|
|
if (lsize(additional_config_files) > 0) {
|
|
|
|
LNODEID ln1;
|
|
|
|
const char * p = NULL;
|
|
|
|
|
|
|
|
for (ln1=lfirst(additional_config_files); ln1; ln1=lnext(ln1)) {
|
|
|
|
p = ldata(ln1);
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_NOTICE, "%sAdditional configuration file is \"%s\"\n",
|
|
|
|
progbuf, p);
|
2012-01-10 18:07:19 +00:00
|
|
|
|
|
|
|
rc = read_config(p);
|
|
|
|
if (rc) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: error reading additional configuration file \"%s\"\n",
|
2014-05-18 08:41:46 +00:00
|
|
|
progname, p);
|
2012-01-10 18:07:19 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-26 20:30:26 +00:00
|
|
|
// set bitclock from configuration files unless changed by command line
|
|
|
|
if (default_bitclock > 0 && bitclock == 0.0) {
|
|
|
|
bitclock = default_bitclock;
|
|
|
|
}
|
2003-02-22 16:45:13 +00:00
|
|
|
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_NOTICE, "\n");
|
2003-02-22 16:45:13 +00:00
|
|
|
|
2003-03-05 00:53:49 +00:00
|
|
|
if (partdesc) {
|
|
|
|
if (strcmp(partdesc, "?") == 0) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\n");
|
|
|
|
avrdude_message(MSG_INFO, "Valid parts are:\n");
|
2003-03-05 00:53:49 +00:00
|
|
|
list_parts(stderr, " ", part_list);
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\n");
|
2003-03-05 00:53:49 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (programmer) {
|
|
|
|
if (strcmp(programmer, "?") == 0) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\n");
|
|
|
|
avrdude_message(MSG_INFO, "Valid programmers are:\n");
|
2003-03-05 00:53:49 +00:00
|
|
|
list_programmers(stderr, " ", programmers);
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\n");
|
2003-03-05 00:53:49 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2012-01-31 17:03:43 +00:00
|
|
|
if (strcmp(programmer, "?type") == 0) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\n");
|
|
|
|
avrdude_message(MSG_INFO, "Valid programmer types are:\n");
|
2012-01-31 17:03:43 +00:00
|
|
|
list_programmer_types(stderr, " ");
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\n");
|
2012-01-31 17:03:43 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2003-03-05 00:53:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-21 21:07:43 +00:00
|
|
|
if (programmer[0] == 0) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\n%s: no programmer has been specified on the command line "
|
2014-05-18 08:41:46 +00:00
|
|
|
"or the config file\n",
|
|
|
|
progname);
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%sSpecify a programmer using the -c option and try again\n\n",
|
2014-05-18 08:41:46 +00:00
|
|
|
progbuf);
|
2003-02-21 21:07:43 +00:00
|
|
|
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) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\n");
|
|
|
|
avrdude_message(MSG_INFO, "%s: Can't find programmer id \"%s\"\n",
|
2014-05-18 08:41:46 +00:00
|
|
|
progname, programmer);
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\nValid programmers are:\n");
|
2003-02-22 16:45:13 +00:00
|
|
|
list_programmers(stderr, " ", programmers);
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\n");
|
2003-02-21 21:07:43 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2012-01-22 12:31:54 +00:00
|
|
|
if (pgm->initpgm) {
|
|
|
|
pgm->initpgm(pgm);
|
|
|
|
} else {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\n%s: Can't initialize the programmer.\n\n",
|
2014-05-18 08:41:46 +00:00
|
|
|
progname);
|
2012-01-22 12:31:54 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
main.c, pgm.c, pgm.h: Add setup and teardown hooks to the programmer
definition. If present, call the setup hook immediately after finding
the respective programmer object, and schedule the teardown hook to be
called upon exit. This allows the programmer implementation to
dynamically allocate private programmer data.
avr910.c, butterfly.c, jtagmkI.c, jtagmkII.c, stk500v2.c, usbasp.c,
usbtiny.c: Convert static programmer data into dynamically allocated
data.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@764 81a1dc3b-b13d-400b-aceb-764788c761c2
2007-11-07 20:36:12 +00:00
|
|
|
if (pgm->setup) {
|
|
|
|
pgm->setup(pgm);
|
|
|
|
}
|
|
|
|
if (pgm->teardown) {
|
|
|
|
atexit(exithook);
|
|
|
|
}
|
|
|
|
|
2007-11-06 19:42:16 +00:00
|
|
|
if (lsize(extended_params) > 0) {
|
|
|
|
if (pgm->parseextparams == NULL) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: WARNING: Programmer doesn't support extended parameters,"
|
2014-05-18 08:41:46 +00:00
|
|
|
" -x option(s) ignored\n",
|
|
|
|
progname);
|
2007-11-06 19:42:16 +00:00
|
|
|
} else {
|
|
|
|
if (pgm->parseextparams(pgm, extended_params) < 0) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: Error parsing extended parameter list\n",
|
2014-05-18 08:41:46 +00:00
|
|
|
progname);
|
2007-11-06 19:42:16 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-30 17:08:48 +00:00
|
|
|
if (port == NULL) {
|
|
|
|
switch (pgm->conntype)
|
|
|
|
{
|
|
|
|
case CONNTYPE_PARALLEL:
|
|
|
|
port = default_parallel;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CONNTYPE_SERIAL:
|
|
|
|
port = default_serial;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CONNTYPE_USB:
|
|
|
|
port = DEFAULT_USB;
|
|
|
|
break;
|
2001-10-14 23:17:26 +00:00
|
|
|
}
|
|
|
|
}
|
2012-01-30 17:08:48 +00:00
|
|
|
|
2001-10-14 23:17:26 +00:00
|
|
|
if (partdesc == NULL) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: No AVR part has been specified, use \"-p Part\"\n\n",
|
2014-05-18 08:41:46 +00:00
|
|
|
progname);
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "Valid parts are:\n");
|
2003-02-22 16:45:13 +00:00
|
|
|
list_parts(stderr, " ", part_list);
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\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) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: AVR Part \"%s\" not found.\n\n",
|
2014-05-18 08:41:46 +00:00
|
|
|
progname, partdesc);
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "Valid parts are:\n");
|
2003-02-22 16:45:13 +00:00
|
|
|
list_parts(stderr, " ", part_list);
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\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) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: WARNING: -E option not supported by this programmer type\n",
|
2014-05-18 08:41:46 +00:00
|
|
|
progname);
|
2002-11-30 14:09:12 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-13 17:22:38 +00:00
|
|
|
if (default_safemode == 0) {
|
|
|
|
/* configuration disables safemode: revert meaning of -u */
|
|
|
|
if (safemode == 0)
|
|
|
|
/* -u was given: enable safemode */
|
|
|
|
safemode = 1;
|
|
|
|
else
|
|
|
|
/* -u not given: turn off */
|
|
|
|
safemode = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isatty(STDIN_FILENO) == 0 && silentsafe == 0)
|
|
|
|
safemode = 0; /* Turn off safemode if this isn't a terminal */
|
|
|
|
|
|
|
|
|
2009-10-10 20:09:56 +00:00
|
|
|
if(p->flags & AVRPART_AVR32) {
|
|
|
|
safemode = 0;
|
|
|
|
}
|
|
|
|
|
2010-01-15 16:36:13 +00:00
|
|
|
if(p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_TPI)) {
|
2010-01-11 14:29:26 +00:00
|
|
|
safemode = 0;
|
|
|
|
}
|
|
|
|
|
2011-09-14 21:49:42 +00:00
|
|
|
|
|
|
|
if (avr_initmem(p) != 0)
|
|
|
|
{
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\n%s: failed to initialize memories\n",
|
2011-09-14 21:49:42 +00:00
|
|
|
progname);
|
|
|
|
exit(1);
|
|
|
|
}
|
2001-01-19 02:46:50 +00:00
|
|
|
|
2012-04-25 16:32:23 +00:00
|
|
|
/*
|
|
|
|
* Now that we know which part we are going to program, locate any
|
|
|
|
* -U options using the default memory region, and fill in the
|
|
|
|
* device-dependent default region name, either "application" (for
|
|
|
|
* Xmega devices), or "flash" (everything else).
|
|
|
|
*/
|
|
|
|
for (ln=lfirst(updates); ln; ln=lnext(ln)) {
|
|
|
|
upd = ldata(ln);
|
|
|
|
if (upd->memtype == NULL) {
|
|
|
|
const char *mtype = (p->flags & AVRPART_HAS_PDI)? "application": "flash";
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_NOTICE2, "%s: defaulting memtype in -U %c:%s option to \"%s\"\n",
|
|
|
|
progname,
|
|
|
|
(upd->op == DEVICE_READ)? 'r': (upd->op == DEVICE_WRITE)? 'w': 'v',
|
|
|
|
upd->filename, mtype);
|
2012-04-25 16:32:23 +00:00
|
|
|
if ((upd->memtype = strdup(mtype)) == NULL) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: out of memory\n", progname);
|
2012-04-25 16:32:23 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\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);
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%sSpecify a port using the -P option and try again\n\n",
|
2003-02-21 18:46:51 +00:00
|
|
|
progbuf);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (verbose) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_NOTICE, "%sUsing Port : %s\n", progbuf, port);
|
|
|
|
avrdude_message(MSG_NOTICE, "%sUsing Programmer : %s\n", progbuf, programmer);
|
2008-06-07 21:03:41 +00:00
|
|
|
if ((strcmp(pgm->type, "avr910") == 0)) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_NOTICE, "%savr910_devcode (avrdude.conf) : ", progbuf);
|
|
|
|
if(p->avr910_devcode)avrdude_message(MSG_INFO, "0x%x\n", p->avr910_devcode);
|
|
|
|
else avrdude_message(MSG_NOTICE, "none\n");
|
2014-05-18 08:41:46 +00:00
|
|
|
}
|
2003-02-21 18:46:51 +00:00
|
|
|
}
|
|
|
|
|
2004-05-19 23:00:38 +00:00
|
|
|
if (baudrate != 0) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_NOTICE, "%sOverriding Baud Rate : %d\n", progbuf, baudrate);
|
2004-05-19 23:00:38 +00:00
|
|
|
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) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_NOTICE, "%sSetting bit clk period : %.1f\n", progbuf, bitclock);
|
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) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_NOTICE, "%sSetting isp clock delay : %3i\n", progbuf, ispdelay);
|
2006-08-17 15:06:20 +00:00
|
|
|
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;
|
|
|
|
}
|
2010-01-13 12:44:54 +00:00
|
|
|
is_open = 1;
|
2001-01-19 02:46:50 +00:00
|
|
|
|
2006-10-09 14:34:24 +00:00
|
|
|
if (calibrate) {
|
|
|
|
/*
|
|
|
|
* perform an RC oscillator calibration
|
|
|
|
* as outlined in appnote AVR053
|
|
|
|
*/
|
2009-07-01 16:08:49 +00:00
|
|
|
if (pgm->perform_osccal == 0) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: programmer does not support RC oscillator calibration\n",
|
2014-05-18 08:41:46 +00:00
|
|
|
progname);
|
2009-07-01 16:08:49 +00:00
|
|
|
exitrc = 1;
|
|
|
|
} else {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: performing RC oscillator calibration\n", progname);
|
2009-07-01 16:08:49 +00:00
|
|
|
exitrc = pgm->perform_osccal(pgm);
|
|
|
|
}
|
2006-10-09 14:34:24 +00:00
|
|
|
if (exitrc == 0 && quell_progress < 2) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: calibration value is now stored in EEPROM at address 0\n",
|
2014-05-18 08:41:46 +00:00
|
|
|
progname);
|
2006-10-09 14:34:24 +00:00
|
|
|
}
|
|
|
|
goto main_exit;
|
|
|
|
}
|
|
|
|
|
2013-05-05 13:35:35 +00:00
|
|
|
if (verbose) {
|
|
|
|
avr_display(stderr, p, progbuf, verbose);
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_NOTICE, "\n");
|
2013-05-05 13:35:35 +00:00
|
|
|
programmer_display(pgm, progbuf);
|
|
|
|
}
|
|
|
|
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\n");
|
2005-09-16 21:52:42 +00:00
|
|
|
}
|
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
|
|
|
|
*/
|
2008-07-29 21:26:55 +00:00
|
|
|
init_ok = (rc = pgm->initialize(pgm, p)) >= 0;
|
|
|
|
if (!init_ok) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: initialization failed, rc=%d\n", progname, rc);
|
2003-08-31 15:40:59 +00:00
|
|
|
if (!ovsigck) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%sDouble check connections and try again, "
|
2003-08-31 15:40:59 +00:00
|
|
|
"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) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: AVR device initialized and ready to accept instructions\n",
|
2014-05-18 08:41:46 +00:00
|
|
|
progname);
|
2005-09-16 21:52:42 +00:00
|
|
|
}
|
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
|
|
|
*/
|
2009-10-10 20:09:56 +00:00
|
|
|
if(!(p->flags & AVRPART_AVR32)) {
|
2012-04-20 12:33:15 +00:00
|
|
|
int attempt = 0;
|
|
|
|
int waittime = 10000; /* 10 ms */
|
|
|
|
|
|
|
|
sig_again:
|
|
|
|
usleep(waittime);
|
2009-10-10 20:09:56 +00:00
|
|
|
if (init_ok) {
|
|
|
|
rc = avr_signature(pgm, p);
|
|
|
|
if (rc != 0) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: error reading signature data, rc=%d\n",
|
2009-10-10 20:09:56 +00:00
|
|
|
progname, rc);
|
|
|
|
exitrc = 1;
|
|
|
|
goto main_exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sig = avr_locate_mem(p, "signature");
|
|
|
|
if (sig == NULL) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: WARNING: signature data not defined for device \"%s\"\n",
|
2014-05-18 08:41:46 +00:00
|
|
|
progname, p->desc);
|
2008-07-29 21:26:55 +00:00
|
|
|
}
|
2001-11-21 02:46:55 +00:00
|
|
|
|
2009-10-10 20:09:56 +00:00
|
|
|
if (sig != NULL) {
|
|
|
|
int ff, zz;
|
2001-11-21 02:46:55 +00:00
|
|
|
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: Device signature = 0x", progname);
|
2009-10-10 20:09:56 +00:00
|
|
|
}
|
|
|
|
ff = zz = 1;
|
|
|
|
for (i=0; i<sig->size; i++) {
|
|
|
|
if (quell_progress < 2) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%02x", sig->buf[i]);
|
2009-10-10 20:09:56 +00:00
|
|
|
}
|
|
|
|
if (sig->buf[i] != 0xff)
|
|
|
|
ff = 0;
|
|
|
|
if (sig->buf[i] != 0x00)
|
|
|
|
zz = 0;
|
|
|
|
}
|
|
|
|
if (ff || zz) {
|
2012-04-20 12:33:15 +00:00
|
|
|
if (++attempt < 3) {
|
|
|
|
waittime *= 5;
|
|
|
|
if (quell_progress < 2) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, " (retrying)\n");
|
2012-04-20 12:33:15 +00:00
|
|
|
}
|
|
|
|
goto sig_again;
|
|
|
|
}
|
|
|
|
if (quell_progress < 2) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\n");
|
2012-04-20 12:33:15 +00:00
|
|
|
}
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: Yikes! Invalid device signature.\n", progname);
|
2009-10-10 20:09:56 +00:00
|
|
|
if (!ovsigck) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%sDouble check connections and try again, "
|
2009-10-10 20:09:56 +00:00
|
|
|
"or use -F to override\n"
|
|
|
|
"%sthis check.\n\n",
|
|
|
|
progbuf, progbuf);
|
|
|
|
exitrc = 1;
|
|
|
|
goto main_exit;
|
|
|
|
}
|
2012-04-20 12:33:15 +00:00
|
|
|
} else {
|
|
|
|
if (quell_progress < 2) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\n");
|
2012-04-20 12:33:15 +00:00
|
|
|
}
|
2001-11-21 02:46:55 +00:00
|
|
|
}
|
2012-04-20 12:33:15 +00:00
|
|
|
|
|
|
|
if (sig->size != 3 ||
|
|
|
|
sig->buf[0] != p->signature[0] ||
|
|
|
|
sig->buf[1] != p->signature[1] ||
|
|
|
|
sig->buf[2] != p->signature[2]) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: Expected signature for %s is %02X %02X %02X\n",
|
2014-05-18 08:41:46 +00:00
|
|
|
progname, p->desc,
|
|
|
|
p->signature[0], p->signature[1], p->signature[2]);
|
2012-04-20 12:33:15 +00:00
|
|
|
if (!ovsigck) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%sDouble check chip, "
|
2012-04-20 12:33:15 +00:00
|
|
|
"or use -F to override this check.\n",
|
|
|
|
progbuf);
|
|
|
|
exitrc = 1;
|
|
|
|
goto main_exit;
|
|
|
|
}
|
2006-02-27 17:18:42 +00:00
|
|
|
}
|
2001-01-19 02:46:50 +00:00
|
|
|
}
|
|
|
|
}
|
2005-02-10 16:34:55 +00:00
|
|
|
|
2008-07-29 21:26:55 +00:00
|
|
|
if (init_ok && 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 */
|
|
|
|
|
2009-10-10 20:09:56 +00:00
|
|
|
rc = safemode_readfuses(&safemode_lfuse, &safemode_hfuse,
|
2014-06-13 20:07:40 +00:00
|
|
|
&safemode_efuse, &safemode_fuse, pgm, p);
|
2007-05-02 23:05:21 +00:00
|
|
|
|
|
|
|
if (rc != 0) {
|
|
|
|
|
|
|
|
//Check if the programmer just doesn't support reading
|
2009-10-10 20:09:56 +00:00
|
|
|
if (rc == -5)
|
2007-05-02 23:05:21 +00:00
|
|
|
{
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_NOTICE, "%s: safemode: Fuse reading not support by programmer.\n"
|
|
|
|
" Safemode disabled.\n", progname);
|
2007-05-02 23:05:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: safemode: To protect your AVR the programming "
|
2007-05-02 23:05:21 +00:00
|
|
|
"will be aborted\n",
|
|
|
|
progname);
|
|
|
|
exitrc = 1;
|
|
|
|
goto main_exit;
|
|
|
|
}
|
2009-10-10 20:09:56 +00:00
|
|
|
} else {
|
|
|
|
//Save the fuses as default
|
|
|
|
safemode_memfuses(1, &safemode_lfuse, &safemode_hfuse, &safemode_efuse, &safemode_fuse);
|
2005-02-10 16:34:55 +00:00
|
|
|
}
|
2005-01-24 21:26:11 +00:00
|
|
|
}
|
2001-01-19 02:46:50 +00:00
|
|
|
|
2012-05-04 10:02:30 +00:00
|
|
|
if (uflags & UF_AUTO_ERASE) {
|
|
|
|
if ((p->flags & AVRPART_HAS_PDI) && pgm->page_erase != NULL &&
|
|
|
|
lsize(updates) > 0) {
|
|
|
|
if (quell_progress < 2) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: NOTE: Programmer supports page erase for Xmega devices.\n"
|
2014-05-18 08:41:46 +00:00
|
|
|
"%sEach page will be erased before programming it, but no chip erase is performed.\n"
|
|
|
|
"%sTo disable page erases, specify the -D option; for a chip-erase, use the -e option.\n",
|
|
|
|
progname, progbuf, progbuf);
|
2012-05-04 10:02:30 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
AVRMEM * m;
|
|
|
|
const char *memname = (p->flags & AVRPART_HAS_PDI)? "application": "flash";
|
2013-09-18 05:54:37 +00:00
|
|
|
|
|
|
|
uflags &= ~UF_AUTO_ERASE;
|
2012-05-04 10:02:30 +00:00
|
|
|
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, memname) == 0) && (upd->op == DEVICE_WRITE)) {
|
|
|
|
erase = 1;
|
|
|
|
if (quell_progress < 2) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: NOTE: \"%s\" memory has been specified, an erase cycle "
|
2014-05-18 08:41:46 +00:00
|
|
|
"will be performed\n"
|
|
|
|
"%sTo disable this feature, specify the -D option.\n",
|
|
|
|
progname, memname, progbuf);
|
2012-05-04 10:02:30 +00:00
|
|
|
}
|
|
|
|
break;
|
2005-09-16 21:52:42 +00:00
|
|
|
}
|
2003-08-29 23:17:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-29 21:26:55 +00:00
|
|
|
if (init_ok && erase) {
|
2004-01-03 18:04:54 +00:00
|
|
|
/*
|
|
|
|
* erase the chip's flash and eeprom memories, this is required
|
|
|
|
* before the chip can accept new programming
|
|
|
|
*/
|
2012-05-04 10:02:30 +00:00
|
|
|
if (uflags & UF_NOWRITE) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: conflicting -e and -n options specified, NOT erasing chip\n",
|
2014-05-18 08:41:46 +00:00
|
|
|
progname);
|
2008-11-04 12:10:28 +00:00
|
|
|
} else {
|
|
|
|
if (quell_progress < 2) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: erasing chip\n", progname);
|
2008-11-04 12:10:28 +00:00
|
|
|
}
|
2009-10-10 20:09:56 +00:00
|
|
|
exitrc = avr_chip_erase(pgm, p);
|
|
|
|
if(exitrc) goto main_exit;
|
2005-09-16 21:52:42 +00:00
|
|
|
}
|
2004-01-03 18:04:54 +00:00
|
|
|
}
|
|
|
|
|
2001-01-19 02:46:50 +00:00
|
|
|
if (terminal) {
|
|
|
|
/*
|
|
|
|
* terminal mode
|
2008-07-29 21:26:55 +00:00
|
|
|
*/
|
2002-11-30 14:09:12 +00:00
|
|
|
exitrc = terminal_mode(pgm, p);
|
2001-01-19 02:46:50 +00:00
|
|
|
}
|
|
|
|
|
2008-07-29 21:26:55 +00:00
|
|
|
if (!init_ok) {
|
|
|
|
/*
|
|
|
|
* If we came here by the -tF options, bail out now.
|
|
|
|
*/
|
|
|
|
exitrc = 1;
|
|
|
|
goto main_exit;
|
|
|
|
}
|
|
|
|
|
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);
|
2012-05-04 10:02:30 +00:00
|
|
|
rc = do_op(pgm, p, upd, uflags);
|
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 (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 */
|
2009-10-10 20:09:56 +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) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\n");
|
2005-09-16 21:52:42 +00:00
|
|
|
}
|
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,
|
2014-06-13 20:07:40 +00:00
|
|
|
&safemodeafter_efuse, &safemodeafter_fuse, pgm, p) != 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,
|
2014-06-13 20:07:40 +00:00
|
|
|
&safemodeafter_efuse, &safemodeafter_fuse, pgm, p) != 0) {
|
|
|
|
avrdude_message(MSG_INFO, "%s: safemode: Sorry, reading back fuses was unreliable. "
|
2014-05-18 08:41:46 +00:00
|
|
|
"I have given up and exited programming mode\n",
|
|
|
|
progname);
|
2005-02-10 16:34:55 +00:00
|
|
|
exitrc = 1;
|
2014-05-18 08:41:46 +00:00
|
|
|
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;
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: safemode: fuse changed! Was %x, and is now %x\n",
|
2005-09-21 00:20:32 +00:00
|
|
|
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;
|
|
|
|
|
2010-01-22 16:40:17 +00:00
|
|
|
if (tolower((int)(safemode_response[0])) == 'y') {
|
2005-09-21 00:20:32 +00:00
|
|
|
|
|
|
|
/* Enough chit-chat, time to program some fuses and check them */
|
|
|
|
if (safemode_writefuse (safemode_fuse, "fuse", pgm, p,
|
2014-06-13 20:07:40 +00:00
|
|
|
10) == 0) {
|
|
|
|
avrdude_message(MSG_INFO, "%s: safemode: and is now rescued\n", progname);
|
2005-09-21 00:20:32 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: and COULD NOT be changed\n", progname);
|
2005-09-21 00:20:32 +00:00
|
|
|
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;
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: safemode: lfuse changed! Was %x, and is now %x\n",
|
2005-09-21 00:20:32 +00:00
|
|
|
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;
|
|
|
|
|
2010-01-22 16:40:17 +00:00
|
|
|
if (tolower((int)(safemode_response[0])) == 'y') {
|
2005-09-21 00:20:32 +00:00
|
|
|
|
|
|
|
/* Enough chit-chat, time to program some fuses and check them */
|
|
|
|
if (safemode_writefuse (safemode_lfuse, "lfuse", pgm, p,
|
2014-06-13 20:07:40 +00:00
|
|
|
10) == 0) {
|
|
|
|
avrdude_message(MSG_INFO, "%s: safemode: and is now rescued\n", progname);
|
2005-09-21 00:20:32 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: and COULD NOT be changed\n", progname);
|
2005-09-21 00:20:32 +00:00
|
|
|
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;
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: safemode: hfuse changed! Was %x, and is now %x\n",
|
2005-09-21 00:20:32 +00:00
|
|
|
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;
|
2010-01-22 16:40:17 +00:00
|
|
|
if (tolower((int)(safemode_response[0])) == 'y') {
|
2005-09-21 00:20:32 +00:00
|
|
|
|
|
|
|
/* Enough chit-chat, time to program some fuses and check them */
|
|
|
|
if (safemode_writefuse(safemode_hfuse, "hfuse", pgm, p,
|
2014-06-13 20:07:40 +00:00
|
|
|
10) == 0) {
|
|
|
|
avrdude_message(MSG_INFO, "%s: safemode: and is now rescued\n", progname);
|
2005-09-21 00:20:32 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: and COULD NOT be changed\n", progname);
|
2005-09-21 00:20:32 +00:00
|
|
|
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;
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: safemode: efuse changed! Was %x, and is now %x\n",
|
2005-09-21 00:20:32 +00:00
|
|
|
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;
|
2010-01-22 16:40:17 +00:00
|
|
|
if (tolower((int)(safemode_response[0])) == 'y') {
|
2005-09-21 00:20:32 +00:00
|
|
|
|
|
|
|
/* Enough chit-chat, time to program some fuses and check them */
|
|
|
|
if (safemode_writefuse (safemode_efuse, "efuse", pgm, p,
|
2014-06-13 20:07:40 +00:00
|
|
|
10) == 0) {
|
|
|
|
avrdude_message(MSG_INFO, "%s: safemode: and is now rescued\n", progname);
|
2005-09-21 00:20:32 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: and COULD NOT be changed\n", progname);
|
2005-09-21 00:20:32 +00:00
|
|
|
failures++;
|
|
|
|
}
|
|
|
|
}
|
2005-02-10 16:34:55 +00:00
|
|
|
}
|
|
|
|
|
2005-09-16 21:52:42 +00:00
|
|
|
if (quell_progress < 2) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "%s: safemode: ", progname);
|
2005-09-16 21:52:42 +00:00
|
|
|
if (failures == 0) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "Fuses OK (E:%02X, H:%02X, L:%02X)\n",
|
2013-09-13 17:22:38 +00:00
|
|
|
safemode_efuse, safemode_hfuse, safemode_lfuse);
|
2005-09-16 21:52:42 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "Fuses not recovered, sorry\n");
|
2005-09-16 21:52:42 +00:00
|
|
|
}
|
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
|
|
|
|
2010-01-13 12:44:54 +00:00
|
|
|
if (is_open) {
|
|
|
|
pgm->powerdown(pgm);
|
2001-01-19 02:46:50 +00:00
|
|
|
|
2010-01-13 12:44:54 +00:00
|
|
|
pgm->disable(pgm);
|
2001-09-21 03:27:20 +00:00
|
|
|
|
2010-01-13 12:44:54 +00:00
|
|
|
pgm->rdy_led(pgm, OFF);
|
2001-02-08 01:42:09 +00:00
|
|
|
|
2014-02-27 07:35:15 +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) {
|
2014-06-13 20:07:40 +00:00
|
|
|
avrdude_message(MSG_INFO, "\n%s done. Thank you.\n\n", progname);
|
2005-09-16 21:52:42 +00:00
|
|
|
}
|
2001-01-19 02:46:50 +00:00
|
|
|
|
|
|
|
return exitrc;
|
|
|
|
}
|