I have 5 of these Atmel ATMega328P-U chips, and I've been trying everything I can do to program them with either a USBASP or even using a Nano as an ISP, and Avrdude always complains that the signature isn't right ... sometimes it's all zeros, sometimes 0's and FF's ... but here's the weird thing, when I put it in a UNO board, and program it through the UNO USB port, the signature reads correctly 0x1e950f ... but take it out of the uno and no dice ...
What gives? Does anyone know?
The other thing that's weird is that the sketch I uploaded while it was in the uno board (blink) works in the uno but as soon as I take the chip out and put it on the bread board ... I get no pins going on and off... very strange.
When going through the Uno USB port, you are using the bootloader, which is a completely different pathway than ISP programming.
I'm just guessing, but the bootloader might not even attempt to read the ID. This Arduino program will read out and dump the "boot signature block":
//found this code here
//https://gist.github.com/speters/f889faec42b510052a6ab4be437d38ca
//Purpose is to simply run a memory check on ATMEGA238P to test for counterfeit parts
#include <avr/boot.h>
#define SIGRD 5
void setup() {
Serial.begin(9600);
Serial.println("");
Serial.println("boot sig dump");
int newLineIndex = 0;
for (uint8_t i = 0; i <= 0x1F; i += 1) {
Serial.print(boot_signature_byte_get(i), HEX);
Serial.print("\t");
newLineIndex++;
if (newLineIndex == 8) {
Serial.println("");
newLineIndex = 0;
}
}
Serial.println();
}
void loop() {
}
Here is the output from the sketch upload through the Unos USB port (well, the tail end of the output anyway) ... it does give the signature that it found.
Standard USBASP programmers, and an Arduino as ISP, setups can be a bit sensitive to wiring layouts, and you get the errors indicated. Can be possibly be made worse if your processors are not geniune parts.
I gave up on using the above methods some time back and now use a Pololu USB ASP programmer, it just works. Low cost too. Its advantage is that it can be slowed right down which makes it work as a programmer when others will not.
Usually a connection issue (wired up wrong, bad/intermittent connections) or a clocking issue (clock configured wrong &&/|| programmer actually out of sync with the target &&|| hardware clock issue such as no/wrong capacitors around the crystal / wrong clock source selected).
They might have ... I don't remember, I bought them a few years ago.
Well, so my goal was to be able to run the chip in low power mode and be able to program it with a USBASP programmer ... so this is what I ended up doing since I made this post:
I bought some 16Mhz crystals and 22 puff caps... then I built a circuit with a ZIF socket on some pegboard with a 10-pin header for the USBASP cable. With the crystal connected etc. it reported the correct signature to avrdude ... so I took things a step further and started looking into how to configure the chip for low power modes then that led to reading up on fuses and how to set those, which led to downloading the GUI interface for avrdude - which is REALLY NICE ... could use some 'nice-to-haves' such as being able to save configurations, etc, but it's a VERY powerful GUI for that program....
Ultimately, I ended up getting the fuses set properly, then I learned that I had to set my serial port to 19200 when running on an 8Mhz clock in order to achieve 9600 baud actual rate on the serial port and once that was dialed in, I'm good to go ... just need to read up on the low power stuff cause I have a separate project that I need that for.