[solved] Gammon's "Sketch to detect Atmega chip types"

I bought a few Atmega 328P chips which are allegedly programmed with the Arduino bootloader. I cannot load sketches because the signature doesn't match up. I've tried pretty much every combination from the Arduino GUI to no avail.

So I figured I'd try reading what I DO have with:

The above doesn't specifically address connecting a 328P. Can a bare 328P chip be read in this way?I've hooked one up to an Uno

328P <-> Uno

Pin_1 <-> SS
SCK <-> SCK
MISO <-> MISO
MOSI <-> MOSI
VCC <-> VCC
GND <-> GND

and when it runs, I only get "Atmega chip detector" on the serial console. Nothing more.

Is there anything I need to add to communicate with a 328P that could be missing since Gammon chose the Tiny85 for his example?

Edit: Forgot to list the reset line to Pin 1 of the 328P

You need D10 to Reset also - that lets the programming device take over control of the device to be programmed.

CrossRoads:
You need D10 to Reset also - that lets the programming device take over control of the device to be programmed.

Ah, forgot to list that one. Yes, I have it connected, too.

JohnHoward:
I bought a few Atmega 328P chips which are allegedly programmed with the Arduino bootloader. I cannot load sketches because the signature doesn't match up. I've tried pretty much every combination from the Arduino GUI to no avail.

What error message are you reading that has led you to that assumption? If you are reading a failure message from avrdude, it would tell you what the target signature is that didn't match, if it could read anything from the chip at all.

More likely, avrdude is failing to get a response from the chip. There are a number of reasons why this could happen, but it would be faster if you posted the exact error message you are seeing from the gui. Select the verbose output options in preference for uploading to get as much info from avrdude as you can.

Here's an example of what avrdude reports when it gets an unexpected signature:

C:\atmel\avrdude510>avrdude -cusbasp -Pusb -pm88

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x1e9307
avrdude: Expected signature for ATMEGA88 is 1E 93 0A
         Double check chip, or use -F to override this check.

avrdude done.  Thank you.

Notice it tells you what the signature of the target chip is (0x1e9307, which a lookup will show that it is a atmega8, rather than the atmega88 that avrdude was told to expect. )

Holy craptastic. I see the Preferences has a checkbox for verbose 'upload'. Duh. Learned something new today. Now THAT is what I really needed. I can see what's going on for once:

What's more, the chip appears to have loaded and is running 'blink' successfully. Maybe the COM port was jammed up. I haven't rewired anything on my breadboard.

Sketch uses 1,116 bytes (3%) of program storage space. Maximum is 32,256 bytes.
Global variables use 11 bytes (0%) of dynamic memory, leaving 2,037 bytes for local variables. Maximum is 2,048 bytes.
C:\Program Files (x86)\Arduino/hardware/tools/avr/bin/avrdude -CC:\Program Files (x86)\Arduino/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -PCOM9 -b115200 -D -Uflash:w:C:\Users\donb\AppData\Local\Temp\build1302336530084855925.tmp/Blink.cpp.hex:i

avrdude: Version 5.11, compiled on Sep 2 2011 at 19:38:36
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is "C:\Program Files (x86)\Arduino/hardware/tools/avr/etc/avrdude.conf"

Using Port : COM9
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
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 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : Arduino
Description : Arduino
avrdude: Send: A [41] . [80] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [03]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [81] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [04]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [82] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [04]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [98] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [03]
avrdude: Recv: . [10]
Hardware Version: 3
Firmware Version: 4.4
avrdude: Send: A [41] . [84] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [03]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [85] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [03]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [86] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [03]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [87] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [03]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [89] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [03]
avrdude: Recv: . [10]
Vtarget : 0.3 V
Varef : 0.3 V
Oscillator : 28.800 kHz
SCK period : 3.3 us

avrdude: Send: A [41] . [81] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [04]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [82] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [04]
avrdude: Recv: . [10]
avrdude: Send: B [42] . [86] . [00] . [00] . [01] . [01] . [01] . [01] . [03] . [ff] . [ff] . [ff] . [ff] . [00] . [80] . [04] . [00] . [00] . [00] . [80] . [00] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: E [45] . [05] . [04] . [d7] . [c2] . [00] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: P [50] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: AVR device initialized and ready to accept instructions

Reading | avrdude: Send: u [75] [20]
avrdude: Recv: . [14] . [1e] . [95] . [0f] . [10]
################################################## | 100% 0.02s

avrdude: Device signature = 0x1e950f
avrdude: Send: V [56] . [a0] . [03] . [fc] . [00] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: V [56] . [a0] . [03] . [fd] . [00] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: V [56] . [a0] . [03] . [fe] . [00] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: V [56] . [a0] . [03] . [ff] . [00] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: reading input file "C:\Users\donb\AppData\Local\Temp\build1302336530084855925.tmp/Blink.cpp.hex"
avrdude: writing flash (1116 bytes):

Writing | avrdude: Send: U [55] . [00] . [00] [20]
avrdude: Recv: . [14]

[omitted because the post was too long otherwise]

| 100% 0.41s

avrdude: 1116 bytes of flash written
avrdude: verifying flash memory against C:\Users\donb\AppData\Local\Temp\build1302336530084855925.tmp/Blink.cpp.hex:
avrdude: load data flash data from input file C:\Users\donb\AppData\Local\Temp\build1302336530084855925.tmp/Blink.cpp.hex:
avrdude: input file C:\Users\donb\AppData\Local\Temp\build1302336530084855925.tmp/Blink.cpp.hex contains 1116 bytes
avrdude: reading on-chip flash data:

[omitted because the post was too long otherwise]

| 100% 0.38s

avrdude: verifying ...
avrdude: 1116 bytes of flash verified
avrdude: Send: Q [51] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]

avrdude done. Thank you.

"Code tags", not "Quote" tags, if you please. XD

Now the trick is to load the bootloader, which you may have wiped in the process, or at least muddled the reset vector.

Nope, the bootloader is fine. I think the problem originally was that the USB COM port was jammed up. That seems to happen fairly predictably if the Arduino is turned off without first closing the serial window -- and until either restarting the GUI or switching to a different port and back it remains in a confused state. I probably did that without realizing it, being set up on a breadboard and all.