0

AVRDude: signature & lfuse issues
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

AVRDude: signature & lfuse issues

by robodude666 on Fri Nov 26, 2010 1:15 pm

Hey guys,

So... I got into the crazy world of hand SMD soldering. I built the Circuit Skills kit, and now moved on to something that blinks: the Blinken Button (beginner version, of course). I've managed to solder it up, in what seems to be a successful manner. I don't see any shorts, and nothing smokes when applying power. Multimeter (resistance, continuity, etc.) also seems to agree with the schematic.

I'm now up to the part where I have to program the QFP32 package ATMega168, and this is where things aren't working so well. I am using AVRDude on my Mac with an AVR Isp mkII USB programmer. Running the following command:

Code: Select all | TOGGLE FULL SIZE
avrdude -p m168 -c avrispmkII -P usb -t -v


gets me this most of the time:

Code: Select all | TOGGLE FULL SIZE
avrdude: Version 5.8cvs, compiled on Jan 15 2010 at 17:27:01
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/usr/local/CrossPack-AVR-20100115/etc/avrdude.conf"
         User configuration file is "/Users/robodude666/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : avrispmkII
avrdude: usbdev_open(): Found AVRISP mkII, serno: 000200029302
         AVR Part                      : ATMEGA168
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     5     4    0 no        512    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     16384  128    128  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : STK500V2
         Description     : Atmel AVR ISP mkII
         Programmer Model: AVRISP mkII
         Hardware Version: 1
         Firmware Version Master : 1.12
         Vtarget         : 3.0 V
         SCK period      : 4.00 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e0106
avrdude: Expected signature for ATMEGA168 is 1E 94 06
         Double check chip, or use -F to override this check.

avrdude done.  Thank you.


In other words, it reads the device signature incorrectly. Most of the time, 2 of the 3 bytes are correct and one of them is wrong. Rarely does it give me all FFs or other completely wrong signatures.

Once in a while (every 3-4 attempts) it will match the device signature, but get snagged at the following:

Code: Select all | TOGGLE FULL SIZE
avrdude: Version 5.8cvs, compiled on Jan 15 2010 at 17:27:01
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/usr/local/CrossPack-AVR-20100115/etc/avrdude.conf"
         User configuration file is "/Users/robodude666/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : avrispmkII
avrdude: usbdev_open(): Found AVRISP mkII, serno: 000200029302
         AVR Part                      : ATMEGA168
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     5     4    0 no        512    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     16384  128    128  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : STK500V2
         Description     : Atmel AVR ISP mkII
         Programmer Model: AVRISP mkII
         Hardware Version: 1
         Firmware Version Master : 1.12
         Vtarget         : 3.0 V
         SCK period      : 4.00 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9406
avrdude: safemode: Verify error - unable to read lfuse properly. Programmer may not be reliable.
avrdude: safemode: To protect your AVR the programming will be aborted

avrdude done.  Thank you.


Now it complains that the lfuse cannot be read properly.

I tried using the -F and -u flags to ignore these cases, but nothing good comes out of it. It either complains it was unable to read the AVR, or that there was a mismatch.

I have a fresh CR2032 battery, and the ISP cable is connected in the right orientation. What could be wrong? Could a small solder bridge that I can't see cause this, or does this seem more like I applied too much heat and killed the chip?

Of course here is the picture of the board, though it doesn't do much good because it's not super sharp. The other side of the board just has the battery holder and a battery (not pictured).

Image
(click for higher-res)

Cheers,
-robodude666
robodude666
 
Posts: 118
Joined: Sun Mar 28, 2010 12:12 am

Re: AVRDude: signature & lfuse issues

by robodude666 on Sat Nov 27, 2010 12:26 pm

Any ideas? I don't have any extra PCBs or spare ATMega168s to test.

Has anyone encountered this, or a similar, issue before?
robodude666
 
Posts: 118
Joined: Sun Mar 28, 2010 12:12 am

Re: AVRDude: signature & lfuse issues

by oPossum on Sat Nov 27, 2010 12:33 pm

Is the CR2032 fresh? Try powering it with a bench supply or 2 x AA.
I am the Possum, and I approve of this message. Sent from MacBook Wheel Sorry for my bad German.
User avatar
oPossum
 
Posts: 636
Joined: Fri Oct 26, 2007 12:42 am
Location: Michigan, USA

Re: AVRDude: signature & lfuse issues

by robodude666 on Sat Nov 27, 2010 12:36 pm

At first I was using a relatively old (1 year old from a motherboard) battery. After noticing this issue, I went out to buy a brand new CR2032 battery but this problem still remains. I'll desolder the CR2032 holder and solder in some regular leads and try other battery sources. Should I still be able to power the ATMega168 from a +5v supply, or does it have to be 3v?
robodude666
 
Posts: 118
Joined: Sun Mar 28, 2010 12:12 am

Re: AVRDude: signature & lfuse issues

by oPossum on Sat Nov 27, 2010 12:49 pm

5 volts is fine. No need to desolder the batt holder. Carefully solder some small wires to C1, C2 or pins 2 & 6 of the ICSP connector for power. Make sure polarity is correct.
I am the Possum, and I approve of this message. Sent from MacBook Wheel Sorry for my bad German.
User avatar
oPossum
 
Posts: 636
Joined: Fri Oct 26, 2007 12:42 am
Location: Michigan, USA

Re: AVRDude: signature & lfuse issues

by robodude666 on Sat Nov 27, 2010 2:54 pm

I'd like you to meet my little friend:

Image

Got it working!

I connected a +5v power supply (The Breadboard PSU kit from SparkFun) and repeatedly attempted to program the fuses ignoring any warnings:

Code: Select all | TOGGLE FULL SIZE
avrdude -c avrispmkII -P usb -p atmega168 -v -F -u -Ulfuse:w:0xe2:m -Uhfuse:w:0xdf:m -Uefuse:w:0x1:m


avrdude was configured to ignore signature and ignore safemode tests. After 4 or 5 attempts, it was able to set the fuses and verify them successfully. After this was done, I was able to easily upload the program without any problem. I first uploaded the test program to verify that all of the I/O were functioning as expected. I then put the CD2032 holder back on, soldered on the 8x8 matrix, popped in the CR2032 battery, programmed it again with the real program and tada! Works like a charm. I'm super pleased to find out my (second attempt at) SMD soldering went very well.

-robodude666
robodude666
 
Posts: 118
Joined: Sun Mar 28, 2010 12:12 am

Re: AVRDude: signature & lfuse issues

by chatham on Fri Dec 03, 2010 1:50 am

I'm glad you got this working, and I'm sorry I didn't read this earlier. One thing I've found to give this problem (incorrect signature reads) is programming it too fast via ISP. All the AVR's I've ever played with are factory-clocked to the internal 8MHz oscillator, with CLKDIV8 set, so the effective clock rate is 1MHz.

From what I can tell (sorry, I'm lame and use AVR Studio to program), AVRDude is programming at 250000 baud, which is juuust at the CLK/4 or lower recommended ISP programming speed. So lowering the ISP bitrate might have been the fix you were looking for...Hope it helps in the future!

And from the AVR Studio user's guide, "Using an ISP frequency of less than 1/5 of the target clock is recommended". I didn't know that, just looked it up now. Learn something new everyday!

Of course, maybe this wasn't your problem at all. However, when you changed your fuses, did you wind up clocking it from an external oscillator, or turning off the CLKDIV8 fuse?
OpenChord.org - Open Source kits to let you play Guitar Hero with a real guitar, or build your own Wii/banned/USB controllers.

chatham
 
Posts: 144
Joined: Thu Feb 04, 2010 2:30 am

Re: AVRDude: signature & lfuse issues

by robodude666 on Fri Dec 03, 2010 7:50 am

I programmed the fuse to disable CKDIV8 so the clock runs at the full 8MHz internal. Next time I run into this problem, I'll try adjusting the bitrate instead of forcing the fuses to be programmer via a series of brute force attempts. :).

Thanks!

-robodude666
robodude666
 
Posts: 118
Joined: Sun Mar 28, 2010 12:12 am

Please be positive and constructive with your questions and comments.