avrdude: ATtiny45 unresponsive after writing to flash

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello all,
I just recently started playing with microcontrollers so I'm quite ignorant about them, but I'm learning. :)

I have a couple of ATtiny45s, a couple of ATtiny2313s and several ATmega8s and ATmega8Ls. So far I'm focusing on the tinies to learn the basics and whatnot. My set-up consists of an AVRISP from DigiKits.com (essentially a CP2101 USB-to-UART adapter, with an ISP connector built-in and connected to the right pins; it is seen as an STK500v2) and avr-gcc + avrdude on OS X.

With the ATtiny2313, everything went fine and I actually built a little thing it. With the ATtiny45, though, I have some serious problems I can't figure out.
When I flash a small program, say under 150 bytes or so, everything goes smoothly: it erases, flashes and verifies perfectly. For instance, this hex works:

:100000000EC028C027C026C025C024C023C022C0DF
:1000100021C020C01FC01EC01DC01CC01BC0112499
:100020001FBECFE5D1E0DEBFCDBF10E0A0E6B0E05F
:10003000E4E6F0E003C0C89531960D92A036B10712
:10004000D1F710E0A0E6B0E001C01D92A036B107E4
:10005000E1F701C0D5CFCFE5D1E0DEBFCDBF8FEF57
:0400600087BBFFCF8C
:00000001FF

When I try to flash something bigger, the programmer enters a coma state right after sending the bytes to be flashed, to the point that avrdude reports timeouts from the programmer. At that point I can't even kill it, and ps (the process viewer!) reports it as "E", which means "trying to exit but not really succeeding".
This is a hex file that does that:

:100000000EC028C027C026C025C024C023C022C0DF
:1000100021C020C01FC01EC01DC01CC01BC0112499
:100020001FBECFE5D1E0DEBFCDBF10E0A0E6B0E05F
:10003000E0EBF0E003C0C89531960D92A036B10711
:10004000D1F710E0A0E6B0E001C01D92A036B107E4
:10005000E1F723C0D5CFC198882311F4C09801C01F
:10006000C09AC19A08951F93CF93DF93182FC0E0D1
:10007000D0E0812F99270C2E02C0880F991F0A9477
:10008000E2F7E9DF2196C830D10599F7DF91CF91EA
:100090001F910895C298C29A0895CFE5D1E0DEBFBE
:1000A000CDBF8FEF87BB84E6DEDFC298C29AFFCF59
:00000001FF

The flash write seems to work (I'm not entirely sure as I was building that program a piece at a time, checking that everything worked as expected), but the flash read for the verification process doesn't even start. Inhibiting the verification stage times out anyway, as it can't read the fuses.
I put a log (with -vvvv) of what happens at http://jollino.it/stk500ko.txt, maybe someone can make some sense out of it.

I am running avrdude 5.3.1 installed through macports, but I also compiled 5.5 on my own and the problem doesn't change.

From the little understanding I have (so far) of microcontrollers, it can't be related to bugs in the source code of the hex file, as avrdude merely send streams of data to the chip to have it flashed into its memory. Then why does this happen?
I also noticed a weird thing: with the ATtiny2313, the programmer worked fine even without powering the circuit (isn't that weird?). With the ATtiny45, it has to be powered up otherwise it will not work at all.
I have been researching on the net, but I haven't found anything that could apply to my problem. Of course, it might also be a matter of not searching properly... in which case I apologize.

Any hints would be greatly appreciated. :)

Thank you very much in advance!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This seems to be an issue with your programmer. Is there a chance you
upgrade its firmware?

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Apparently it should automatically prompt for an upgrade if there is one when I connect it through AVR Studio 4 (I just launched windows in a virtual machine for it), but it doesn't, and I can't seem to start the manual upgrade procedure.
However, flashing the same file with AVR Studio seems to work fine. :(

edit: I managed to upgrade the firmware with AVR studio (using the 'board' function) but nothing changed, as avrdude still chokes after programming. The firmware version didn't change either (it was 2.10 and it's still 2.10). The problem seems to be with avrdude, though. Is there any way to make it wait a little after flashing?
I tried increasing the bit clock period, but that doesn't seem to change anything...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Cross-posting in several forums at the same time is considered impolite.

I just tried your hex file on an ATtiny45, once with an STK500 and another
time with an AVRISPmkII. Both work fine here.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I merely posted here and on avr-chat as the issue seems quite rare (I couldn't find anyone else with the same problem by googling it up), I apologize if this caused any apocalypse. ;)

May I ask what operating system you are using? Apparently, it's a OS X / Darwin only bug.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The problem with cross-posting is that you've now started two
threads, with partially different people thinking about your
problem, with no way to join both threads again so all those
who responded could read all of the messages.

I've tested it on FreeBSD.

If it's an OS X bug, then it must be somehow related to the
response from the programmer. Just for reference, I'm
attaching the -vvvv output from flashing your hex file into
an ATtiny45 here through an Atmel AVRISPmkII.

Attachment(s): 

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm using AVRDUDE with an ISPmkII with no problem on a (intel)Mac running OSX. I'm using the "AVR MacPack" distribution, with great success so far. If you're not using it, you might want to give it a go.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.