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 db26deb038
commit b75ab66c85
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,42 +1090,57 @@ 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;
buf[0] = CMND_ENTER_PROGMODE; for (use_ext_reset = 0; use_ext_reset <= 1; use_ext_reset++) {
if (verbose >= 2) buf[0] = CMND_ENTER_PROGMODE;
fprintf(stderr, "%s: jtagmkII_program_enable(): "
"Sending enter progmode command: ",
progname);
jtagmkII_send(pgm, buf, 1);
status = jtagmkII_recv(pgm, &resp);
if (status <= 0) {
if (verbose >= 2) if (verbose >= 2)
fprintf(stderr, "%s: jtagmkII_program_enable(): "
"Sending enter progmode command: ",
progname);
jtagmkII_send(pgm, buf, 1);
status = jtagmkII_recv(pgm, &resp);
if (status <= 0) {
if (verbose >= 2)
putc('\n', stderr);
fprintf(stderr,
"%s: jtagmkII_program_enable(): "
"timeout/error communicating with programmer (status %d)\n",
progname, status);
return -1;
}
if (verbose >= 3) {
putc('\n', stderr); putc('\n', stderr);
fprintf(stderr, jtagmkII_prmsg(pgm, resp, status);
"%s: jtagmkII_program_enable(): " } else if (verbose == 2)
"timeout/error communicating with programmer (status %d)\n", fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status);
progname, status); c = resp[0];
return -1; free(resp);
} if (c != RSP_OK) {
if (verbose >= 3) { fprintf(stderr,
putc('\n', stderr); "%s: jtagmkII_program_enable(): "
jtagmkII_prmsg(pgm, resp, status); "bad response to enter progmode command: %s\n",
} else if (verbose == 2) progname, jtagmkII_get_rc(c));
fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status); if (c == RSP_ILLEGAL_JTAG_ID) {
c = resp[0]; if (use_ext_reset == 0) {
free(resp); unsigned char parm[] = { 1};
if (c != RSP_OK) { if (verbose > 0)
fprintf(stderr, fprintf(stderr,
"%s: jtagmkII_program_enable(): " "%s: retrying with external reset applied\n",
"bad response to enter progmode command: %s\n", progname);
progname, jtagmkII_get_rc(c));
if (c == RSP_ILLEGAL_JTAG_ID) (void)jtagmkII_setparm(pgm, PAR_EXTERNAL_RESET, parm);
fprintf(stderr, "%s: JTAGEN fuse disabled?\n", progname); continue;
return -1; }
fprintf(stderr, "%s: JTAGEN fuse disabled?\n", progname);
return -1;
}
}
} }
PDATA(pgm)->prog_enabled = 1; PDATA(pgm)->prog_enabled = 1;
@ -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;