Here is a copy of another thread that I started detailing a better chronological order of events here.
Hey guys, firstly my apologies if a solution I'm looking for has already been posted here, I have looked around 10's of posts from this forum and have tried a few things but my scenario seems somewhat unique that may require more advice.
I have a self built embedded project that at the moment consists of a power supply, an ATmega1281V, an ICSP header and caps: 0.47uF across Vcc-GND (near PSU), 100nF across Vcc-GND (near atmega), 22pF across reset-GND (at ICSP header), 100nF across Vcc-GND (near ICSP header) and a 10k pull up resistor on the reset line.
I am trying to use avrdude to program my device (using arduino uno as programmer), but as of yet I haven't been unable to read a valid signature. My first few attempts using (avrdude -c avrisp -b 19200 -P COM3 -p ATmega1281) resulted in changing device signatures:
C:\>avrdude -c avrisp -b 19200 -P COM3 -p ATmega1281
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.07s
avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.
avrdude done. Thank you.
C:\>avrdude -c avrisp -b 19200 -P COM3 -p ATmega1281
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.08s
avrdude: Device signature = 0xffffff
avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.
avrdude done. Thank you. I stupidly read somewhere that the device signature might not be exactly what the avrdude expects and that you could try programming the device anyway with -F (dumb I know). Anywho, I ended up doing this:
C:\>avrdude -P COM3 -b 19200 -c avrisp -p ATmega1281 -U flash:w:gas.hex -F
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.06s
avrdude: Device signature = 0x00ffff
avrdude: Expected signature for ATMEGA1281 is 1E 97 04
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: current erase-rewrite cycle count is 1593835520 (if being tracked)
avrdude: erasing chip
avrdude: reading input file "gas.hex"
avrdude: input file gas.hex auto detected as Intel Hex
avrdude: writing flash (134 bytes):
Writing | ################################################## | 100% 0.15s
avrdude: 134 bytes of flash written
avrdude: verifying flash memory against gas.hex:
avrdude: load data flash data from input file gas.hex:
avrdude: input file gas.hex auto detected as Intel Hex
avrdude: input file gas.hex contains 134 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.10s
avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
0x0c != 0x00
avrdude: verification error; content mismatch
avrdude: safemode: lfuse changed! Was ff, and is now 0
Would you like this fuse to be changed back? [y/n] y
avrdude: safemode: and is now rescued
avrdude: safemode: hfuse changed! Was ff, and is now 0
Would you like this fuse to be changed back? [y/n] y
avrdude: safemode: and is now rescued
avrdude: safemode: efuse changed! Was ff, and is now 0
Would you like this fuse to be changed back? [y/n] y
avrdude: safemode: and is now rescued
avrdude: safemode: Fuses OK
avrdude done. Thank you. Now whenever I read my device signature, it's always 0x000000 and when I request the details of the chip I get this info:
C:\avrdude-6.0.1>avrdude -c avrisp -p atmega1281 -v -P com3 -b 19200
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 : com3
Using Programmer : avrisp
Overriding Baud Rate : 19200
AVR Part : ATMEGA1281
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PA0
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 10 8 0 no 4096 8 0 9000 9000 0x00 0x00
flash 65 10 256 0 yes 131072 256 512 4500 4500 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 9000 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 : STK500
Description : Atmel AVR ISP
Hardware Version: 2
Firmware Version: 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.07s
avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.
avrdude done. Thank you.Looking at the datasheet for my MCU, I can see that the default values for the fuses are 0x99 for high and 0x6F for low, however when I tried to change these back, I was unsuccessful. Note I also tried to slow down the SPI speed using -i 1000:
C:\avrdude-6.0.1>avrdude -b 19200 -i 1000 -p atmega1281 -c avrisp -P com3 -U lfuse:w:0x62:m -U hfuse:w:0x99:m -D -F
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.07s
avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
avrdude: Expected signature for ATMEGA1281 is 1E 97 04
avrdude: reading input file "0x62"
avrdude: writing lfuse (1 bytes):
Writing | | 0% 0.00s ***failed;
Writing | ################################################## | 100% 0.16s
avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0x62:
avrdude: load data lfuse data from input file 0x62:
avrdude: input file 0x62 contains 1 bytes
avrdude: reading on-chip lfuse data:
Reading | ################################################## | 100% 0.02s
avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
0x62 != 0x00
avrdude: verification error; content mismatch
avrdude: safemode: lfuse changed! Was 62, and is now 0
Would you like this fuse to be changed back? [y/n] n
avrdude: safemode: Fuses OK
avrdude done. Thank you. Assuming the fuses to be zero, that means the clock is being sourced externally, so I soldered on my external quartz oscillator and 22pF caps but this didnt affect anything. I tried probing the xtal pins when the board was on but I couldn't see any signal on the DSO (although I'm not 100% sure how to check this, is it from xtal1 to gnd? or xtal1 to xtal 2?).
So here I am now, not sure if it's my circuit that's wrong, or I've changed some fuses that disable programming, or if my SPI bus even works at all! There are too many factors that I can adequately dissect from one another to make an informed judgement about what to do next. Any advice guys? Thanks
