ArduinoISP failure, device signature 0x0000, programmer is not responding

Hey Guys

So I ordered a bunch of Atmega328P's from china. They arrived yesterday. They are definately 328P's because 1) That is the number written on the chip and 2) Device signature matches.

Now I tried to flash a bootloader on them using ArduinoISP sketch, however, I don't know what I am doing wrong because arduino IDE tells me that burning is done, however when I replace the original chip with the new chip, I am not able to upload sketch. Gives me a "stk500_recv(): programmer is not responding" error message.

After this, I took an usbasp and followed Sparkfun's tutorial and flashed optiboot_atmega328.hex manually through avr dude.

avrdude -b 19200 -c usbasp -p m328p -v -e -U efuse:w:0x05:m -U hfuse:w:0xD6:m -U lfuse:w:0xFF:m
avrdude -b19200 -c usbasp -p m328p -v -e -U flash:w:hexfilename.hex -U lock:w:0x0F:m

Got no error message, except a SCK cant sync warning.

I uploaded the blinky sketch to it using the Upload using programmer option. When I replace this chip, the LED blinks, but when I tried to flash the same or any other sketch via the normal Upload option, it again gives me the programmer is not responding message.

I am really clueless as to what is going on here.

To check things, I hit the command
avrdude -c avrisp -p m328p -P /dev/ttyACM0 -v
This i when Arduino ISP is being used and only that is connected.
I get device signature as 0x0000.

Kindly help

When you use "Upload Using Programmer" your sketch overwrites the bootloader. To go back to using the bootloader to upload you have to do a "Burn Bootloader".

Then after burning the boot loader, am I supposed to replace the atmega that came with my arduino with the new chip and then upload sketches?

I will try that, but if I remember correctly, I think that did not work.

Apart from that, what about the device signature bring 0x0000 and the boot loader flashes in seconds. Should that be a cause of concern?

sk1989:
Apart from that, what about the device signature bring 0x0000 and the boot loader flashes in seconds. Should that be a cause of concern?

The signature being 000000 probably means a bad ICSP connection or maybe the system clock isn't running. Once you burn an Arduino bootloader you need a 16 MHz crystal connected to get the processor clock running.

So the bootloader bit worked, thanks for that!

I flash on a breadboard with a 16Mhz crystal connected.
This might be a little off topic, but I tried to upgrade a usbasp programmer using the Arduino and i got the same signature from that as well.

FYI if you click burn bootloader without a crystal, it will just change the fuse settings and not actually flash the bootloader. For some reason they decided to make the IDE first erase the chip and set the fuses, then reset the chip, then try and burn the bootloader, rather than doing it all in one step. This means that after the fuse is changed, avrdude can no longer read the chip without a crystal and so cannot actually upload the bootloader.