Trouble burning bootloader with avrisp mkII

Trying to burn a bootloader to some ATMEGA328P chips I have but I'm not having any luck. When I choose the burn bootloader option from the arduino IDE I get this error:

avrdude: stk500v2_command(): command failed
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

Then I tried to burn a hex file I had directly from avrdude to make sure I hooked up the ISP right but I got the exact same error. I then switched chips with a new one right out of the packaging and tried to burn the same hex. It worked perfectly so I know everything is hooked up ok. Then I figured there might have been something wrong with the first chip so I tried to burn the bootloader again from the arduino IDE. Didn't work, got the same error as with the first chip. Went back to see if the hex would burn again after that and it WOULD NOT.

So in short something is happening when I try to burn the bootloader that is killing the chips. Anybody know what is going on here? there a way to restore the two chips I already screwed up back to how they were before. I don't have many left...

Are you connecting a 16MHz crystal (or resonator) to the target processor when you burn the bootloader?

I got the same error too when using the IDE. So, I try using AVR Studio (different drivers) to double check. It seems that the ISP clock speed was too low as I was playing with it earlier (but in AVR Studio it will still be able to read the chip although it's slow). Then, after adjusting the ISP back to default speed, it works on the Arduino IDE as expected. It might be different cause for your case but it's worth looking at. :slight_smile:

Yes I did have a 16MHz crystal connected to the chips.
Read through the "Stuff that can go wrong: AVR initilization failed" section.

...does that help?

Solved the issue. I pulled the chip out of an arduino board and replaced it with one of the chips I was using earlier. I was then able to burn the bootloader using the arvisp mkii so I concluded that my wiring was wrong on the breadboard attempt. After some snooping around I figured out that if I removed the decoupling caps connected to the crystal the sketch (default blink) would begin working. The caps were the right size (22pF) but for some reason they messed things up. I replaced them with some different ones I had and now everything is working great. Thanks for the ideas.