Index: avrdude.1 =================================================================== RCS file: /sources/avrdude/avrdude/avrdude.1,v retrieving revision 1.72 diff -u -u -r1.72 avrdude.1 --- avrdude.1 29 Oct 2007 18:03:02 -0000 1.72 +++ avrdude.1 6 Nov 2007 14:41:56 -0000 @@ -19,7 +19,7 @@ .\" .\" $Id: avrdude.1,v 1.72 2007/10/29 18:03:02 joerg_wunsch Exp $ .\" -.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 @@ 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 @@ 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 Index: jtagmkII.c =================================================================== RCS file: /sources/avrdude/avrdude/jtagmkII.c,v retrieving revision 1.26 diff -u -u -r1.26 jtagmkII.c --- jtagmkII.c 30 Jan 2007 13:41:53 -0000 1.26 +++ jtagmkII.c 6 Nov 2007 14:41:57 -0000 @@ -71,6 +71,10 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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; } Index: main.c =================================================================== RCS file: /sources/avrdude/avrdude/main.c,v retrieving revision 1.128 diff -u -u -r1.128 main.c --- main.c 29 Oct 2007 22:46:45 -0000 1.128 +++ main.c 6 Nov 2007 14:41:59 -0000 @@ -72,6 +72,8 @@ static LISTID updates; +static LISTID extended_params; + /* * global options */ @@ -111,6 +113,7 @@ " fuses should be changed back.\n" " -t Enter terminal mode.\n" " -E [,] List programmer exit specifications.\n" + " -x Pass to programmer.\n" " -y Count # erase cycles in EEPROM.\n" " -Y Initialize erase cycle # in EEPROM.\n" " -v Verbose output. -v -v for more.\n" @@ -302,6 +305,12 @@ 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; @@ -324,7 +333,7 @@ ispdelay = 0; safemode = 1; /* Safemode on by default */ silentsafe = 0; /* Ask by default */ - + if (isatty(STDIN_FILENO) == 0) safemode = 0; /* Turn off safemode if this isn't a terminal */ @@ -372,7 +381,7 @@ /* * 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 @@ verify = 0; break; + case 'x': + ladd(extended_params, optarg); + break; + case 'y': do_cycles = 1; break; @@ -623,6 +636,22 @@ 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) || Index: pgm.c =================================================================== RCS file: /sources/avrdude/avrdude/pgm.c,v retrieving revision 1.24 diff -u -u -r1.24 pgm.c --- pgm.c 30 Jan 2007 13:41:53 -0000 1.24 +++ pgm.c 6 Nov 2007 14:41:59 -0000 @@ -125,6 +125,7 @@ pgm->set_varef = NULL; pgm->set_fosc = NULL; pgm->perform_osccal = NULL; + pgm->parseextparams = NULL; return pgm; } Index: pgm.h =================================================================== RCS file: /sources/avrdude/avrdude/pgm.h,v retrieving revision 1.34 diff -u -u -r1.34 pgm.h --- pgm.h 30 Jan 2007 13:41:53 -0000 1.34 +++ pgm.h 6 Nov 2007 14:41:59 -0000 @@ -99,6 +99,7 @@ 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 */ Index: doc/avrdude.texi =================================================================== RCS file: /sources/avrdude/avrdude/doc/avrdude.texi,v retrieving revision 1.67 diff -u -u -r1.67 avrdude.texi --- doc/avrdude.texi 29 Oct 2007 22:37:38 -0000 1.67 +++ doc/avrdude.texi 6 Nov 2007 14:42:00 -0000 @@ -244,13 +244,14 @@ @menu * Option Descriptions:: +* Programmers accepting extended parameters:: * Example Command Line Invocations:: @end menu @c @c Node @c address@hidden Option Descriptions, Example Command Line Invocations, Command Line Options, Command Line Options address@hidden Option Descriptions, Programmers accepting extended parameters, Command Line Options, Command Line Options @section Option Descriptions @noindent @@ -747,6 +748,12 @@ @item -V Disable automatic verify check when uploading data. address@hidden -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 @@ @c @c Node @c address@hidden Example Command Line Invocations, , Option Descriptions, Command Line Options address@hidden Programmers accepting extended parameters, Example Command Line Invocations, Option Descriptions, Command Line Options address@hidden Programmers accepting extended parameters + address@hidden @code + address@hidden JTAG ICE mkII address@hidden AVR Dragon + +When using the JTAG ICE mkII or AVR Dragon in JTAG mode, the +following extended parameter is accepted: address@hidden @code address@hidden @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. address@hidden table + address@hidden table + address@hidden address@hidden address@hidden Node address@hidden address@hidden Example Command Line Invocations, , Programmers accepting extended parameters, Command Line Options @section Example Command Line Invocations @noindent