patchAVR Downloader/UploaDEr - Patches: patch #7876, JTAGICE mkII fails to connect to...


You are not allowed to post comments on this tracker with your current authentication level.

patch #7876: JTAGICE mkII fails to connect to attiny if debugwire is enabled AND target has a very slow clock

Submitted by:  Malte <damaltor>
Submitted on:  Fri 26 Oct 2012 07:39:44 PM UTC  
Category: NonePriority: 5 - Normal
Status: DonePrivacy: Public
Assigned to: Joerg Wunsch <joerg_wunsch>Open/Closed: Closed

Fri 17 May 2013 04:26:18 PM UTC, comment #3:

I tried it with an ATtiny4313 mounted in an STK500. I could not
really recover from a too slow clock, because I always ran into a
"debugwire sync failed" situation. Had to use HVPP to recover the

Anyway, I think it's a good idea to retry with ISP immediately, so
I added the patch. I added a "safety belt" retry counter to avoid
the situation where it infinitely goes back and forth. I also added
a similar change to stk500v2.c for the JTAGICE3.

Joerg Wunsch <joerg_wunsch>
Project AdministratorIn charge of this item.
Fri 17 May 2013 11:13:41 AM UTC, comment #2:

I hate nabble, really. They are presenting other people's
content, but no reference to the original discussion, not
even a timestamp. :-((

FWIW, here's the link to our own mailinglist archive:

Joerg Wunsch <joerg_wunsch>
Project AdministratorIn charge of this item.
Fri 26 Oct 2012 07:44:19 PM UTC, comment #1:

Also, i forgot to mention that the idea came from here:
so, kudos go to John McCorquodale.

Malte <damaltor>
Fri 26 Oct 2012 07:39:44 PM UTC, original submission:

It is impossible to connect to attiny targets under said circumstances.

this is the procedure that made it possible to reproduce (for me). tested on 10 attiny13 chips:

-target: attiny13
-lowest possible internal clock speed selected
-CLKDIV8 enabled
-DWEN enabled

if i try to flash the chip now, avrdude states that the chip might be in debugwire mode (which is correct), that it is now put to isp mode, and asks me to restart without power cycling the target (which is the correct way to reflash a target with DWEN set).
doing so results in - nothing. on every run of avrdude, i get the same result and the same message.

i did also try to revive the chip inside avr studio, without (!) success.

after searching quite a while on google, i found out that this problem is (kinda) known, but more or less unsolved. the essence: due to the ultra slow clock of the attiny (1 MHz / 8 = 125 kHz), the debugwire connection is very slow. this somehow makes the chip reset when closing the connection to the jtagice. so, as the jtagice mkii tells the chip to switch to isp mode, it "forgets" that and starts up again in debugwire mode as soon as the jtagice disconnects. i could not verify if this problem persists with all attiny13 and all jtagice mkII. i can verify that the problem exists with at least some jtagice mkII (as i did find a few others with that problem) and 10 of 10 attiny13 which i put onto a pcb exactly for testing this. that means, i could lock all 10 up using the above procedure, and i could recover all of them using the patch provided. the 10 attiny13 are a random picked subset of 500 pcs i ordered around June 2011.

this can be fixed if the jtagice opens the connection, notices that the device does not respond to isp, connects via debugwire to put the chip into isp mode, and IMMEDIATELY retries isp connection (that means, before using jtagmkII_close() so that the jtagice does not power off).

the fix is easy, as the jtagmkII.c already has a bunch of labels and gotos, i just added another label and goto to make avrdude retry the isp connection immediately after switching the target to isp via debugwire.

this is more like a hack than a fix, because it might lock up avrdude when the target (1) does not accept isp and (2) does not accept debugwire. avrdude would then try both again and again.

see lines 821 and 846/850 for the changes.

the most interesting thing about this: i managed to revive ALL attiny chips which were not even recoverable by avr studio!!

Malte <damaltor>


Attached Files
file #26833:  jtagmkII.c added by damaltor (104KiB - text/x-csrc - see lines 821 and 846/850 for the changes.)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by joerg_wunsch (Posted a comment)
  • -unavailable- added by damaltor (Submitted the item)
  • -unavailable- added by damaltor

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 17 May 2013 04:26:18 PM UTCjoerg_wunschStatusNone=>Done
      Assigned toNone=>joerg_wunsch
    Fri 26 Oct 2012 07:39:44 PM UTCdamaltorAttached File-=>Added jtagmkII.c, #26833
      Carbon-Copy-=>Added damaltor

    Back to the top

    Powered by Savane 3.1-cleanup1