If entering JTAG mode fails with a bad JTAG ID message, retry with

external reset applied (in case the target is in sleep mode or has
asserted the JTD bit).



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@926 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch 2010-01-17 17:31:10 +00:00
parent a8d23ba1e8
commit 046db1aa07
2 changed files with 52 additions and 30 deletions

View File

@ -1,3 +1,9 @@
2010-01-15 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* jtagmkII.c: If entering JTAG mode fails with a bad JTAG ID
message, retry with external reset applied (in case the target
is in sleep mode or has asserted the JTD bit).
2010-01-15 Joerg Wunsch <j.gnu@uriah.heep.sax.de> 2010-01-15 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
Submitted by Aurelien Jarno: Submitted by Aurelien Jarno:

View File

@ -1090,10 +1090,12 @@ static int jtagmkII_program_enable(PROGRAMMER * pgm)
{ {
int status; int status;
unsigned char buf[1], *resp, c; unsigned char buf[1], *resp, c;
int use_ext_reset;
if (PDATA(pgm)->prog_enabled) if (PDATA(pgm)->prog_enabled)
return 0; return 0;
for (use_ext_reset = 0; use_ext_reset <= 1; use_ext_reset++) {
buf[0] = CMND_ENTER_PROGMODE; buf[0] = CMND_ENTER_PROGMODE;
if (verbose >= 2) if (verbose >= 2)
fprintf(stderr, "%s: jtagmkII_program_enable(): " fprintf(stderr, "%s: jtagmkII_program_enable(): "
@ -1123,10 +1125,23 @@ static int jtagmkII_program_enable(PROGRAMMER * pgm)
"%s: jtagmkII_program_enable(): " "%s: jtagmkII_program_enable(): "
"bad response to enter progmode command: %s\n", "bad response to enter progmode command: %s\n",
progname, jtagmkII_get_rc(c)); progname, jtagmkII_get_rc(c));
if (c == RSP_ILLEGAL_JTAG_ID) if (c == RSP_ILLEGAL_JTAG_ID) {
if (use_ext_reset == 0) {
unsigned char parm[] = { 1};
if (verbose > 0)
fprintf(stderr,
"%s: retrying with external reset applied\n",
progname);
(void)jtagmkII_setparm(pgm, PAR_EXTERNAL_RESET, parm);
continue;
}
fprintf(stderr, "%s: JTAGEN fuse disabled?\n", progname); fprintf(stderr, "%s: JTAGEN fuse disabled?\n", progname);
return -1; return -1;
} }
}
}
PDATA(pgm)->prog_enabled = 1; PDATA(pgm)->prog_enabled = 1;
return 0; return 0;
@ -2365,6 +2380,7 @@ static int jtagmkII_setparm(PROGRAMMER * pgm, unsigned char parm,
case PAR_OCD_VTARGET: size = 2; break; case PAR_OCD_VTARGET: size = 2; break;
case PAR_OCD_JTAG_CLK: size = 1; break; case PAR_OCD_JTAG_CLK: size = 1; break;
case PAR_TIMERS_RUNNING: size = 1; break; case PAR_TIMERS_RUNNING: size = 1; break;
case PAR_EXTERNAL_RESET: size = 1; break;
case PAR_DAISY_CHAIN_INFO: size = 4; break; case PAR_DAISY_CHAIN_INFO: size = 4; break;
case PAR_PDI_OFFSET_START: case PAR_PDI_OFFSET_START:
case PAR_PDI_OFFSET_END: size = 4; break; case PAR_PDI_OFFSET_END: size = 4; break;