bug #33114: Segfault after setting the DWEN fuse with Dragon

* jtagII.c (jtagmkII_getsync): Instead of exit()ing from
deep within the tree when detecting the "need debugWIRE"
situation, properly pass this up as a return code.
* jtagII_private.h (JTAGII_GETSYNC_FAIL_GRACEFUL): New constant.
* stk500v2.c (stk500v2_jtagmkII_open): Don't tell anything
anymore when receiving a JTAGII_GETSYNC_FAIL_GRACEFUL from
jtagmkII_getsync(); silently give up (all necessary has been
said already).



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@983 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch 2011-08-26 10:05:09 +00:00
parent a97f200ff7
commit 1f8dc4dc52
4 changed files with 24 additions and 5 deletions

View File

@ -1,3 +1,15 @@
2011-08-26 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
bug #33114: Segfault after setting the DWEN fuse with Dragon
* jtagII.c (jtagmkII_getsync): Instead of exit()ing from
deep within the tree when detecting the "need debugWIRE"
situation, properly pass this up as a return code.
* jtagII_private.h (JTAGII_GETSYNC_FAIL_GRACEFUL): New constant.
* stk500v2.c (stk500v2_jtagmkII_open): Don't tell anything
anymore when receiving a JTAGII_GETSYNC_FAIL_GRACEFUL from
jtagmkII_getsync(); silently give up (all necessary has been
said already).
2011-08-26 Joerg Wunsch <j.gnu@uriah.heep.sax.de> 2011-08-26 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
Reported by Jason Hecker: Reported by Jason Hecker:

View File

@ -843,12 +843,11 @@ int jtagmkII_getsync(PROGRAMMER * pgm, int mode) {
* program. * program.
*/ */
(void)jtagmkII_reset(pgm, 0x04); (void)jtagmkII_reset(pgm, 0x04);
jtagmkII_close(pgm);
fprintf(stderr, fprintf(stderr,
"%s: Target prepared for ISP, signed off.\n" "%s: Target prepared for ISP, signed off.\n"
"%s: Please restart %s without power-cycling the target.\n", "%s: Please restart %s without power-cycling the target.\n",
progname, progname, progname); progname, progname, progname);
exit(0); return JTAGII_GETSYNC_FAIL_GRACEFUL;
} }
} else { } else {
return -1; return -1;

View File

@ -356,3 +356,8 @@ struct device_descriptor
unsigned char EECRAddress[2]; /* EECR memory-mapped IO address */ unsigned char EECRAddress[2]; /* EECR memory-mapped IO address */
}; };
#endif /* JTAGMKII_PRIVATE_EXPORTED */ #endif /* JTAGMKII_PRIVATE_EXPORTED */
/* return code from jtagmkII_getsync() to indicate a "graceful"
* failure, i.e. an attempt to enable ISP failed and should be
* eventually retried */
#define JTAGII_GETSYNC_FAIL_GRACEFUL (-2)

View File

@ -2816,6 +2816,7 @@ static int stk500v2_jtagmkII_open(PROGRAMMER * pgm, char * port)
{ {
long baud; long baud;
void *mycookie; void *mycookie;
int rv;
if (verbose >= 2) if (verbose >= 2)
fprintf(stderr, "%s: stk500v2_jtagmkII_open()\n", progname); fprintf(stderr, "%s: stk500v2_jtagmkII_open()\n", progname);
@ -2856,9 +2857,11 @@ static int stk500v2_jtagmkII_open(PROGRAMMER * pgm, char * port)
mycookie = pgm->cookie; mycookie = pgm->cookie;
pgm->cookie = PDATA(pgm)->chained_pdata; pgm->cookie = PDATA(pgm)->chained_pdata;
if (jtagmkII_getsync(pgm, EMULATOR_MODE_SPI) != 0) { if ((rv = jtagmkII_getsync(pgm, EMULATOR_MODE_SPI)) != 0) {
fprintf(stderr, "%s: failed to sync with the JTAG ICE mkII in ISP mode\n", if (rv != JTAGII_GETSYNC_FAIL_GRACEFUL)
progname); fprintf(stderr,
"%s: failed to sync with the JTAG ICE mkII in ISP mode\n",
progname);
pgm->cookie = mycookie; pgm->cookie = mycookie;
return -1; return -1;
} }