avrdude: Device signature = 0x000000

Hi, I have a servo controller I'm trying to put together with a 328P, but it seems almost every time I try to program it I get this error: avrdude: Device signature = 0x000000, then the yikes, invalid device sig, etc. Interesting thing is, I've had multiple boards fail with this same exact message. The last one started uploading using arduino as ISP, but failed at the read (data mismatch at the end), now gives this error. Some earlier boards uploaded fine a few times, then started giving this error.

My contacts are soldered in tight, so I doubt it's a contact issue. Oscillator works, the board has clean 5V of power from a switching regulator.

Am I somehow bricking my 328P every time I try to use it? It doesn't even get very hot (tiny bit of warmth). Another possible issue? Any help would be appreciated, I'm really tired of making these for them to fail every time.

You may be bricking them with inappropriate fuse settings?

Common causes:

  • One of the SPI pins shorted to ground.
  • Oscillator not working (how do you know it's working? Did you put a scope on it? Is it wired correctly, with proper loading caps?
  • Fuses set to use a clock source that is not present (for example, using a crystal when you don't have one connected, or using external clock).
  • Chip generally not functioning - Common gotchas with standalone '328p: you must have 0.1uf ceramic cap between Vcc and Gnd, and between AVcc and Gnd as close to the chip as possible (this is clearly stated in the datasheet, but unfortunately some guides on using standalone '328p omit these), otherwise all sorts of unexpected behavior is possible. Vcc must be connected to AVcc, AREF must not be connected to Vcc or AVcc.

Post schematic and the fuse settings you're trying to use.

Hi, thanks for your reply.

  • SPI pins are0 not shorted to ground. Checked with multimeter.
  • Put a scope on oscillator to check that it’s working. It has proper loading caps.
  • I didn’t change fuse settings. Sketches loaded in the beginning, so I doubt inappropriate fuse settings are to blame.
  • I went through about 10 of these with similar results. Have all these that you mentioned except a 10uF between VCC and ground: I didn’t see that before, perhaps I should reread the datasheet.

My design is attached below. I didn’t fiddle at all with the fuse settings, just used factory defaults.

Servo_controller.pdf (67.7 KB)

Hmmm, factory default fuses, which are set for internal oscillator, but you have an external oscillator attached. i'm not sure what impact that would have. There is a fuse setting for using an external oscillator.

Is the auto reset disabled on the Arduino you are using as a programmer? The typical way to do that is to put a 10uF capacitor between GND and RESET after uploading the ArduinoISP sketch. Does your Arduino as ISP program a standalone ATmega328P on a breadboard with a crystal, or program another Arduino OK?

I am thinking your ATmega328P should not get warm at all, so you should check your design and current use of the pins.

Ok, I'll study up on how to set the fuses properly then. I'm wondering if mine are already in the right configuration though, based on it having programmed successfully a few times.

Auto reset is not disabled. Should I try that? The arduino as ISP does program a standalone 328P successfully. Also didn't fiddle with the fuses btw, and used a 16MHz oscillator successfully.

Warm is maybe a tiny bit above room temp, I'm just guessing based on what the tip of my nose is feeling there.

Thanks for the detailed answer, I'll get back as soon as I've tried changing the fuses.

anvoice:
Ok, I'll study up on how to set the fuses properly then. I'm wondering if mine are already in the right configuration though, based on it having programmed successfully a few times.

Auto reset is not disabled. Should I try that? The arduino as ISP does program a standalone 328P successfully. Also didn't fiddle with the fuses btw, and used a 16MHz oscillator successfully.

Warm is maybe a tiny bit above room temp, I'm just guessing based on what the tip of my nose is feeling there.

Thanks for the detailed answer, I'll get back as soon as I've tried changing the fuses.

Many questions:
1: on your schematic, the part U2 is a "5032" is that a SJK Oscillator? if so, why do you have a 0.01uf cap inline with the output?
2: do you have the CKSEL fuses set to 0000
3: Why did you label MISO; MISO/INT? unless you are using a PinChange interrupt library Arduino doesn't know how to use it as an interrupt?

The 6pin ISP header needs MISO, VCC, SCK, MOSI, !Reset, GND. In that order.

You have VCC, SCK and SCL (labeled as SCL), SDA and MOSI(labeled SDA), MISO, !Reset, GND.

is U1 a 2x3 header? You are going to have to wire a custom ISP connector.

Chuck.

Hi,

  1. I don't believe it's actually SJK (no SJK label on it) but Nextal, which is possibly a knockoff or otherwise similar looking product. I do believe I've consulted with the supplier (ebay, so no guarantees) for capacitor value choice and placement. If you believe that might be my problem, I can try getting rid of it, but the clock outputs a clean-looking 20MHz signal right now.
  2. As mentioned, I didn't change fuse settings (I'll try doing that), but sketches did upload fine a few times.
  3. MISO/INT is merely there for the possibility of using an interrupt: the project I based this off, openservo, has a similar function. As is it's only being used as MISO.

Yes, it's a 2x3 header, and I know I'll need to wire a custom connector, the locations are based on how it was most comfortable to route the PCB. That's not a problem for me. Right now I have everything connected exactly as it should be (yes, quadruple-checked) to the arduino ISP, i.e. MISO wire goes to MISO, etc.

anvoice:
Hi,

  1. I don’t believe it’s actually SJK (no SJK label on it) but Nextal, which is possibly a knockoff or otherwise similar looking product. I do believe I’ve consulted with the supplier (ebay, so no guarantees) for capacitor value choice and placement. If you believe that might be my problem, I can try getting rid of it, but the clock outputs a clean-looking 20MHz signal right now.
  2. As mentioned, I didn’t change fuse settings (I’ll try doing that), but sketches did upload fine a few times.
  3. MISO/INT is merely there for the possibility of using an interrupt: the project I based this off, openservo, has a similar function. As is it’s only being used as MISO.

Yes, it’s a 2x3 header, and I know I’ll need to wire a custom connector, the locations are based on how it was most comfortable to route the PCB. That’s not a problem for me. Right now I have everything connected exactly as it should be (yes, quadruple-checked) to the arduino ISP, i.e. MISO wire goes to MISO, etc.

if you have the 328p programmed to use an external oscillator, the XTAL1 is a TTL compatible input. You should be able to directly connect the oscillator to it without a capacitor in-line.

Can you 'scope pin 8 (XTAL2). Depending out how you have the CKSEL programmed, you should see an inverted XTAL1 signal. That might give you some indication if the chip is seeing a good clock.

The only times I have had a device signature errors has traced back to either RESET being driven to hard (ISP unable to take it low) or no VCC.

try using avrdude in command line mode.

Under windows 7, AvrDude.exe was located in “\Program files\Arduino\hardware\tools\avr\bin”

cd to that directory,

Here is the command line I used to talk to an embedded 328P-AU, using an ATMEL AVRISPmkII (USB)

arvdude -c avrispmkII -p m328p -P usb -U lfuse:r:-:i -v

If you are not using a AVRISPmkII, you will have to change the -c and -P parameters.

If you are using “Arduino as ISP”
-c stk500v1 -P{serial.port} -b19200

C:\WinAVR-20100110\bin>avrdude -c avrispmkII -p m328p -Pusb

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e950f

avrdude: safemode: Fuses OK

avrdude done.  Thank you.


C:\WinAVR-20100110\bin>avrdude -c avrispmkII -p m328p -Pusb -U lfuse:r:-:i -v

avrdude: Version 5.10, compiled on Jan 19 2010 at 10:45:23
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"


         Using Port                    : usb
         Using Programmer              : avrispmkII
avrdude: usbdev_open(): Found AVRISP mkII, serno: 000200130751
         AVR Part                      : ATMEGA328P
         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       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  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.23
         Vtarget         : 5.1 V
         SCK period      : 8.00 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e950f
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DE
avrdude: safemode: efuse reads as 5
avrdude: reading lfuse memory:

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

avrdude: writing output file "<stdout>"
:01000000FF00
:00000001FF

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DE
avrdude: safemode: efuse reads as 5
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

Chuck.

Scoped pin 8, no signal there.

I tried your command line arguments and got the following errors back:
avrdude: can't open config file "": Invalid argument
avrdude: error reading system wide configuration file

Did I do something wrong there?

anvoice:
Scoped pin 8, no signal there.

I tried your command line arguments and got the following errors back:
avrdude: can't open config file "": Invalid argument
avrdude: error reading system wide configuration file

Did I do something wrong there?

No, you did not do anything wrong, I have an avr tool chain installed. That installation setup a path variable to arvdude's config file on my computer, you will have to explicitly tell avrdude where to find it's config file. The -C argument is how you pass the config file to avrdude. Here is an example:

Change directory to C:\Program Files\Arduino\hardware\tools\avr\bin

avrdude -C"C:\Program Files\Arduino\hardware\tools\avr\etc\avrdude.conf" -c avrispmkII -p m328p -Pusb -U lfuse:r:-:i -v

This will explicitly direct it to it's config file.

Also adjust the -c and -P to fit your actual programmer.

Chuck.

Thanks, that certainly worked, at least for a while.

I got the all-ok messages, tried to program the controller again, but got this in the end (i.e. it started fine again):
avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
0x00 != 0x0c
avrdude: verification error; content mismatch

Now it's back to signature = 0x00000000, even with the command line... Perhaps I bricked it the first time after all? I'll make another PCB and try the command line arguments first before using Arduino as ISP to program it.

DrAzzy:
'328p: you must have 0.1uf ceramic cap between Vcc and Gnd, and between AVcc and Gnd as close to the chip as possible

If Vcc and AVcc are connected, a single 0.1uF capacitor to ground can apparently be used, as long as it’s very close to the chip. As per the UNO - it uses a single capacitor according to the schematic. (R3) (That’s what I’ve always done.)

Vcc-AVcc cap.JPG

Finally have my new controller ready. Before I blow that one (also one of the final few boards and component sets I have), I'd like to clarify: will using the -U lfuse:r:-:i option in command line set the fuses appropriately for my external clock? Or should I use something else?
Thanks in advance.

anvoice:
Finally have my new controller ready. Before I blow that one (also one of the final few boards and component sets I have), I’d like to clarify: will using the -U lfuse:r:-:i option in command line set the fuses appropriately for my external clock? Or should I use something else?
Thanks in advance.

That :r: just READS the values of the fuses. It does not attempt to change anything. I am interested in what the values are before you change them.

use this:

-U lfuse:r:-:i -U hfuse:r:-:i -U efuse:r:-:i

this is my example reading from a 328p-AU (TQFP)

C:\Users\user>avrdude -p m328p -cavrispmkii -U lfuse:r:-:i -U hfuse:r:-:i -U efuse:r:-:i -Pusb

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e950f
avrdude: reading lfuse memory:

Reading | ################################################## | 100% 0.01s

avrdude: writing output file "<stdout>"
:01000000FF00
:00000001FF
avrdude: reading hfuse memory:

Reading | ################################################## | 100% 0.01s

avrdude: writing output file "<stdout>"
:01000000DE21
:00000001FF
avrdude: reading efuse memory:

Reading | ################################################## | 100% 0.01s

avrdude: writing output file "<stdout>"
:0100000005FA
:00000001FF

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

the Important bits are after the “avrdude: writing output file”

lfuse = 0xFF
hfuse = 0xDE
efuse = 0x05

the -U command structure is

fuse:operation:filename:format

Where:
fuse can be lfuse, hfuse, efuse
operation can be r = read, w=write, v=verify
filename is file to read, write or verify against, or - for stdout
format is i = intel format (standard), h = hex format

I would recommend trying to read from the fuses before attempting to change them.

Chuck.

p.s. Lady Ada has a very good Into at AVR Tutorial

chucktodd:
That :r: just READS the values of the fuses. It does not attempt to change anything. I am interested in what the values are before you change them.

I would recommend trying to read from the fuses before attempting to change them.

Chuck.

p.s. Lady Ada has a very good Into at AVR Tutorial

I got this output:

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude: Device signature = 0x1e950f
avrdude: reading lfuse memory:

Reading | ################################################## | 100% 0.02s

avrdude: writing output file "<stdout>"
:01000000629D
:00000001FF
avrdude: reading hfuse memory:

Reading | ################################################## | 100% 0.01s

avrdude: writing output file "<stdout>"
:01000000D926
:00000001FF
avrdude: reading efuse memory:

Reading | ################################################## | 100% 0.02s

avrdude: writing output file "<stdout>"
:0100000007F8
:00000001FF

avrdude: safemode: Fuses OK (H:07, E:D9, L:62)

avrdude done.  Thank you.

So my settings are apparently:
lfuse: 62
hfuse: D9
efuse: 07

Thanks, will read the tutorial.

anvoice:
I got this output:

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude: Device signature = 0x1e950f
avrdude: reading lfuse memory:

Reading | ################################################## | 100% 0.02s

avrdude: writing output file “”
:01000000629D
:00000001FF
avrdude: reading hfuse memory:

Reading | ################################################## | 100% 0.01s

avrdude: writing output file “”
:01000000D926
:00000001FF
avrdude: reading efuse memory:

Reading | ################################################## | 100% 0.02s

avrdude: writing output file “”
:0100000007F8
:00000001FF

avrdude: safemode: Fuses OK (H:07, E:D9, L:62)

avrdude done.  Thank you.




So my settings are apparently:
lfuse: 62
hfuse: D9
efuse: 07

Thanks, will read the tutorial.

So, base on your fuses, and this Avr Fuse Calculator

Your chip is currently programmed thusly:

Internal RC oscillator, 8MHZ, Startup time/PWRDWN/RESET 6ck/14ck +65ms
Divide clock by 8 (1mhz)
Bootflash size 2048words (4k bytes)
Serial Program downloae (SPI) enable ********** ALWAYS have this SET Else you will need a HV programmer to recover the chip.
Brown out Disabled.

If you use the external oscillator and plan on using OptiBoot (serial programming (UART)) you should change:

lfuse = 0xF7 // full swing xtal osciallator 16kck+ 64ms
hfuse = 0xDE // SPI programming enabled, BootReset Vector, 256Word boot block
efuse = 0x05 // brownout level 2.7v

Chuck.

Thanks, got the fuse programming to work. However, still got this error in the end of uploading:

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0x00 != 0x0c
avrdude: verification error; content mismatch

Perhaps I can also try programming it from the CLI? Not sure what the commands for that would be though. Otherwise I'm a bit lost right now.

anvoice:
Thanks, got the fuse programming to work. However, still got this error in the end of uploading:

avrdude: verifying ...

avrdude: verification error, first mismatch at byte 0x0000
        0x00 != 0x0c
avrdude: verification error; content mismatch



Perhaps I can also try programming it from the CLI? Not sure what the commands for that would be though. Otherwise I'm a bit lost right now.

I still question your clock. try rereading the fuses from command line.

try running avrdude in terminal mode. you can directly read and write the chip

the following is my avrdude command line using a avrispmkii usb programmer

avrdude -c avrispmkii -p m328p -P usb -t

C:\Users\user>avrdude -c avrispmkII -Pusb -p m328p -t

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f
avrdude>

at the:
avrdude>

prompt just type help for command hints.

dump lfuse will display the current value for the low fuse.

What were the fuse settings you used?

With that capacitor inline with the clock source, a full swing fuse setting may not work?

I would try jumpering across that 0.01uf capacitor you have between the oscillator and the AVR chip.

Chuck.

I used your suggested fuse settings:
lfuse = 0xF7
hfuse = 0xDE
efuse = 0x05
I reread them, they’re the ones I programmed.

I tried jumpering the cap: still content mismatch, though this time not at byte 0:

avrdude: verification error, first mismatch at byte 0x0c00
         0x00 != 0xed
avrdude: verification error; content mismatch

Update: Success! I managed to program it by trying again. There is PWM where there should be, so clearly the program uploaded.
I don’t know if I can consider this problem solved, it almost seems like an accident that it worked, but it’s good news nonetheless. Thanks so much Chucktodd for all your help, couldn’t have done this alone.

anvoice:
I used your suggested fuse settings:
lfuse = 0xF7
hfuse = 0xDE
efuse = 0x05
I reread them, they're the ones I programmed.

I tried jumpering the cap: still content mismatch, though this time not at byte 0:

avrdude: verification error, first mismatch at byte 0x0c00

0x00 != 0xed
avrdude: verification error; content mismatch



Update: Success! I managed to program it by trying again. There is PWM where there should be, so clearly the program uploaded.
I don't know if I can consider this problem solved, it almost seems like an accident that it worked, but it's good news nonetheless. Thanks so much Chucktodd for all your help, couldn't have done this alone.

Here is another thing to try,

If you change the lfuse to 0xE2, that will ignore the external oscillator, and use the internal 8mhz R/C oscillator. It will be a little slower :slight_smile: but it will work for uploads and downloads. If you then can successfully upload your software, you will know that it is a clock issue. If the problem doesn't change we will have to look elsewhere.

Unless you create/update a new entry in the boards.txt the Arduino environment will assume a 16MHz clock, by actually using the slower clock, all of the Serial.begin() speeds, millis(), micros() will be off.

Also, the R/C clock makes high speed (>9600 baud) serial traffic unreliable.

Hopefully, You will find the error, and be able to use your external oscillator.

Chuck.