main.c, pgm.c, pgm.h: Add the -x option to pass extended parameters to

the programmer backend.

jtagmkII.c: Implement the extended parameter jtagchain=
to support JTAG daisy-chains.

avrdude.1, doc/avrdude.texi: Document all of the above.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@761 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch 2007-11-06 19:42:16 +00:00
parent 7beb66e99c
commit f5c3910d48
8 changed files with 169 additions and 5 deletions

View File

@ -1,3 +1,14 @@
2007-11-06 Joerg Wunsch <j@uriah.heep.sax.de>
* main.c: Add the -x option to pass extended parameters to
the programmer backend.
* pgm.c: (Ditto.)
* pgm.h: (Ditto.)
* jtagmkII.c: Implement the extended parameter jtagchain=
to support JTAG daisy-chains.
* avrdude.1: Document all of the above.
* doc/avrdude.texi: (Ditto.)
2007-10-30 Joerg Wunsch <j@uriah.heep.sax.de>
* configure.ac (AC_INIT): Bump version for post-release.

5
NEWS
View File

@ -7,6 +7,11 @@ Approximate change log for AVRDUDE by version.
----------------------------------------------------------------------
Current:
* Add support for the -x option to pass extended parameters to the
programmer backend.
* Add support for JTAG daisy-chains, using the -x daisychain=
option.
Version 5.5:

View File

@ -19,7 +19,7 @@
.\"
.\" $Id$
.\"
.Dd DATE October 29, 2007
.Dd DATE November 6, 2007
.Os
.Dt AVRDUDE 1
.Sh NAME
@ -48,6 +48,7 @@
.Op Fl u
.Op Fl U Ar memtype:op:filename:filefmt
.Op Fl v
.Op Fl x Ar extended_param
.Op Fl V
.Op Fl y
.Op Fl Y
@ -578,6 +579,13 @@ does not have a colon in it.
Enable verbose output.
.It Fl V
Disable automatic verify check when uploading data.
.It Fl x Ar extended_param
Pass
.Ar extended_param
to the chosen programmer implementation as an extended parameter.
The interpretation of the extended parameter depends on the
programmer itself.
See below for a list of programmers accepting extended parameters.
.It Fl y
Tells
.Nm
@ -744,6 +752,27 @@ be accessed using normal ISP programming.
This sequence is automatically initiated by using the JTAG ICE mkII
or AVR Dragon in ISP mode, when they detect that ISP mode cannot be
entered.
.Ss Programmers accepting extended parameters
.Bl -tag -offset indent -width indent
.It Ar JTAG ICE mkII
.It Ar AVR Dragon
When using the JTAG ICE mkII or AVR Dragon in JTAG mode, the
following extended parameter is accepted:
.Bl -tag -offset indent -width indent
.It Ar jtagchain=UB,UA,BB,BA
Setup the JTAG scan chain for
.Ar UB
units before,
.Ar UA
units after,
.Ar BB
bits before, and
.Ar BA
bits after the target AVR, respectively.
Each AVR unit within the chain shifts by 4 bits.
Other JTAG units might require a different bit shift count.
.El
.El
.Sh FILES
.Bl -tag -offset indent -width /dev/ppi0XXX
.It Pa /dev/ppi0

View File

@ -244,13 +244,14 @@ Roth.
@menu
* Option Descriptions::
* Programmers accepting extended parameters::
* Example Command Line Invocations::
@end menu
@c
@c Node
@c
@node Option Descriptions, Example Command Line Invocations, Command Line Options, Command Line Options
@node Option Descriptions, Programmers accepting extended parameters, Command Line Options, Command Line Options
@section Option Descriptions
@noindent
@ -747,6 +748,12 @@ Enable verbose output.
@item -V
Disable automatic verify check when uploading data.
@item -x @var{extended_param}
Pass @var{extended_param} to the chosen programmer implementation as
an extended parameter. The interpretation of the extended parameter
depends on the programmer itself. See below for a list of programmers
accepting extended parameters.
@item -y
Tells AVRDUDE to use the last four bytes of the connected parts' EEPROM
memory to track the number of times the device has been erased. When
@ -774,7 +781,32 @@ should not be used.
@c
@c Node
@c
@node Example Command Line Invocations, , Option Descriptions, Command Line Options
@node Programmers accepting extended parameters, Example Command Line Invocations, Option Descriptions, Command Line Options
@section Programmers accepting extended parameters
@table @code
@item JTAG ICE mkII
@itemx AVR Dragon
When using the JTAG ICE mkII or AVR Dragon in JTAG mode, the
following extended parameter is accepted:
@table @code
@item @var{jtagchain=UB,UA,BB,BA}
Setup the JTAG scan chain for @var{UB} units before, @var{UA} units
after, @var{BB} bits before, and @var{BA} bits after the target AVR,
respectively.
Each AVR unit within the chain shifts by 4 bits.
Other JTAG units might require a different bit shift count.
@end table
@end table
@page
@c
@c Node
@c
@node Example Command Line Invocations, , Programmers accepting extended parameters, Command Line Options
@section Example Command Line Invocations
@noindent

View File

@ -71,6 +71,10 @@ static unsigned int eeprom_pagesize;
static int prog_enabled; /* Cached value of PROGRAMMING status. */
static unsigned char serno[6]; /* JTAG ICE serial number. */
/* JTAG chain stuff */
static unsigned char jtagchain[4];
/*
* The OCDEN fuse is bit 7 of the high fuse (hfuse). In order to
* perform memory operations on MTYPE_SPM and MTYPE_EEPROM, OCDEN
@ -1108,6 +1112,12 @@ static int jtagmkII_initialize(PROGRAMMER * pgm, AVRPART * p)
return -1;
}
if (jtagmkII_setparm(pgm, PAR_DAISY_CHAIN_INFO, jtagchain) < 0) {
fprintf(stderr, "%s: jtagmkII_initialize(): Failed to setup JTAG chain\n",
progname);
return -1;
}
/*
* Must set the device descriptor before entering programming mode.
*/
@ -1163,6 +1173,49 @@ static void jtagmkII_enable(PROGRAMMER * pgm)
return;
}
static int jtagmkII_parseextparms(PROGRAMMER * pgm, LISTID extparms)
{
LNODEID ln;
const char *extended_param;
int rv = 0;
for (ln = lfirst(extparms); ln; ln = lnext(ln)) {
extended_param = ldata(ln);
if (strncmp(extended_param, "jtagchain=", strlen("jtagchain=")) == 0) {
unsigned int ub, ua, bb, ba;
if (sscanf(extended_param, "jtagchain=%u,%u,%u,%u", &ub, &ua, &bb, &ba)
!= 4) {
fprintf(stderr,
"%s: jtagmkII_parseextparms(): invalid JTAG chain '%s'\n",
progname, extended_param);
rv = -1;
continue;
}
if (verbose >= 2) {
fprintf(stderr,
"%s: jtagmkII_parseextparms(): JTAG chain parsed as:\n"
"%s %u units before, %u units after, %u bits before, %u bits after\n",
progname,
progbuf, ub, ua, bb, ba);
}
jtagchain[0] = ub;
jtagchain[1] = ua;
jtagchain[2] = bb;
jtagchain[3] = ba;
continue;
}
fprintf(stderr,
"%s: jtagmkII_parseextparms(): invalid extended parameter '%s'\n",
progname, extended_param);
rv = -1;
}
return rv;
}
static int jtagmkII_open(PROGRAMMER * pgm, char * port)
{
@ -2026,6 +2079,7 @@ static int jtagmkII_setparm(PROGRAMMER * pgm, unsigned char parm,
case PAR_OCD_VTARGET: size = 2; break;
case PAR_OCD_JTAG_CLK: size = 1; break;
case PAR_TIMERS_RUNNING: size = 1; break;
case PAR_DAISY_CHAIN_INFO: size = 4; break;
default:
fprintf(stderr, "%s: jtagmkII_setparm(): unknown parameter 0x%02x\n",
progname, parm);
@ -2160,6 +2214,7 @@ void jtagmkII_initpgm(PROGRAMMER * pgm)
pgm->paged_load = jtagmkII_paged_load;
pgm->print_parms = jtagmkII_print_parms;
pgm->set_sck_period = jtagmkII_set_sck_period;
pgm->parseextparams = jtagmkII_parseextparms;
pgm->page_size = 256;
}
@ -2218,6 +2273,7 @@ void jtagmkII_dragon_initpgm(PROGRAMMER * pgm)
pgm->paged_load = jtagmkII_paged_load;
pgm->print_parms = jtagmkII_print_parms;
pgm->set_sck_period = jtagmkII_set_sck_period;
pgm->parseextparams = jtagmkII_parseextparms;
pgm->page_size = 256;
}

31
main.c
View File

@ -72,6 +72,8 @@ struct list_walk_cookie
static LISTID updates;
static LISTID extended_params;
/*
* global options
*/
@ -111,6 +113,7 @@ static void usage(void)
" fuses should be changed back.\n"
" -t Enter terminal mode.\n"
" -E <exitspec>[,<exitspec>] List programmer exit specifications.\n"
" -x <extended_param> Pass <extended_param> to programmer.\n"
" -y Count # erase cycles in EEPROM.\n"
" -Y <number> Initialize erase cycle # in EEPROM.\n"
" -v Verbose output. -v -v for more.\n"
@ -302,6 +305,12 @@ int main(int argc, char * argv [])
exit(1);
}
extended_params = lcreat(NULL, 0);
if (extended_params == NULL) {
fprintf(stderr, "%s: cannot initialize extended parameter list\n", progname);
exit(1);
}
partdesc = NULL;
port = default_parallel;
erase = 0;
@ -372,7 +381,7 @@ int main(int argc, char * argv [])
/*
* process command line arguments
*/
while ((ch = getopt(argc,argv,"?b:B:c:C:DeE:Fi:np:OP:qstU:uvVyY:")) != -1) {
while ((ch = getopt(argc,argv,"?b:B:c:C:DeE:Fi:np:OP:qstU:uvVx:yY:")) != -1) {
switch (ch) {
case 'b': /* override default programmer baud rate */
@ -484,6 +493,10 @@ int main(int argc, char * argv [])
verify = 0;
break;
case 'x':
ladd(extended_params, optarg);
break;
case 'y':
do_cycles = 1;
break;
@ -623,6 +636,22 @@ int main(int argc, char * argv [])
exit(1);
}
if (lsize(extended_params) > 0) {
if (pgm->parseextparams == NULL) {
fprintf(stderr,
"%s: WARNING: Programmer doesn't support extended parameters,"
" -x option(s) ignored\n",
progname);
} else {
if (pgm->parseextparams(pgm, extended_params) < 0) {
fprintf(stderr,
"%s: Error parsing extended parameter list\n",
progname);
exit(1);
}
}
}
if ((strcmp(pgm->type, "STK500") == 0) ||
(strcmp(pgm->type, "avr910") == 0) ||
(strcmp(pgm->type, "STK500V2") == 0) ||

1
pgm.c
View File

@ -125,6 +125,7 @@ PROGRAMMER * pgm_new(void)
pgm->set_varef = NULL;
pgm->set_fosc = NULL;
pgm->perform_osccal = NULL;
pgm->parseextparams = NULL;
return pgm;
}

1
pgm.h
View File

@ -99,6 +99,7 @@ typedef struct programmer_t {
int (*highpulsepin) (struct programmer_t * pgm, int pin);
int (*parseexitspecs) (struct programmer_t * pgm, char *s);
int (*perform_osccal) (struct programmer_t * pgm);
int (*parseextparams) (struct programmer_t * pgm, LISTID xparams);
char config_file[PATH_MAX]; /* config file where defined */
int lineno; /* config file line number */
char flag; /* for private use of the programmer */