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 763f49b4fa
commit b177acae71
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>
Reported by Jason Hecker:

View File

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

View File

@ -356,3 +356,8 @@ struct device_descriptor
unsigned char EECRAddress[2]; /* EECR memory-mapped IO address */
};
#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;
void *mycookie;
int rv;
if (verbose >= 2)
fprintf(stderr, "%s: stk500v2_jtagmkII_open()\n", progname);
@ -2856,8 +2857,10 @@ static int stk500v2_jtagmkII_open(PROGRAMMER * pgm, char * port)
mycookie = pgm->cookie;
pgm->cookie = PDATA(pgm)->chained_pdata;
if (jtagmkII_getsync(pgm, EMULATOR_MODE_SPI) != 0) {
fprintf(stderr, "%s: failed to sync with the JTAG ICE mkII in ISP mode\n",
if ((rv = jtagmkII_getsync(pgm, EMULATOR_MODE_SPI)) != 0) {
if (rv != JTAGII_GETSYNC_FAIL_GRACEFUL)
fprintf(stderr,
"%s: failed to sync with the JTAG ICE mkII in ISP mode\n",
progname);
pgm->cookie = mycookie;
return -1;