avrdude-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avrdude-dev] Dragon DW->ISP USB reset question


From: John McCorquodale
Subject: Re: [avrdude-dev] Dragon DW->ISP USB reset question
Date: Thu, 16 Dec 2010 15:28:09 -0800
User-agent: Mutt/1.5.20 (2009-06-14)

> That's what I think is the case.  I cannot remember though, I think
> this is not written down anywhere in an official Atmel document but
> I've been explained that upon a request to Atmel many years ago.
> That's why I implemented it the way it is now.

For what it's worth, I made a simple change to get avrdude to restart without
closing down after doing the DW->ISP protocol and things now work beautifully!
This may be a Dragon-only thing, but it does let you use dragon_isp without
thinking and without any special double-invocations even when DWEN is set,
without an external PS.  So it's useful when you have your atmel in the
Dragon's prototype area rather than in-system.

> That's bad.  I thought I've been fixing all those pointer confusions.
> Please file a bug report for it (of course, if you've got a fix, I'd

With this patch, the core dump goes away.  Looks like the problem was
cloberage or something being unitialized on the exit path right after the
"goto retry" below.

This gives me the avrdude I really want for my situation, but more subtlety
is probably called for in order to take the idea into the mainline.  If you
care to clue me in on what the issues are, I can see about getting a patch
together.

For reference here's the fix around jtagmkII.c:822:

  retry:
    /* Turn the ICE into JTAG or ISP mode as requested. */
    buf[0] = mode;
    if (jtagmkII_setparm(pgm, PAR_EMULATOR_MODE, buf) < 0) {
      if (mode == EMULATOR_MODE_SPI) {
        fprintf(stderr,
                "%s: jtagmkII_getsync(): "
                "ISP activation failed, trying debugWire\n",
                progname);
        buf[0] = EMULATOR_MODE_DEBUGWIRE;
        if (jtagmkII_setparm(pgm, PAR_EMULATOR_MODE, buf) < 0)
          return -1;
        else {
          /*
           * We are supposed to send a CMND_RESET with the
           * MONCOM_DISABLE flag set right now, and then
           * restart from scratch.
           *
           * As this will make the ICE sign off from USB, so
           * we risk losing our USB connection, it's easier
           * to instruct the user to restart AVRDUDE rather
           * than trying to cope with all this inside the
           * program.
           */
          (void)jtagmkII_reset(pgm, 0x04);
          fprintf(stderr,
                  "%s: Target prepared for ISP, signed off.\n",
                  progname);
  goto retry;
          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);
        }
      } else {
        return -1;
      }
    }

I'm stoked it was that simple and I get everything I want!  Again, avrdude
is my buddy.  I totally owe you a beer or twelve!
  
Cheers,

-mcq



reply via email to

[Prev in Thread] Current Thread [Next in Thread]