Atmega1284p upload error! avrdude: verification error

I'm currently working on a robot arm, that's driven by three L298 H-bridges. I needed a lot of IO pins in a DIP package, so I landed on the 1284p. I've compiled the latest optiboot v5, and flashed it with a USBasp. this have been working like a charm, until now. Today, when I tried to upload some new code to it, I got the error below by the Arduino IDE (1.0.6):

atmega1284 avrdude: verification error, first mismatch at byte 0x004a 
        0xd2 != 0xd1
avrdude: verification error; content mismatch

The old program was still running though. I thought maybe the bootloader was damaged in some way, so I hooked up my USBasp and tried to upload the bootloader again. After about two minutes with bootloader-burning, I get this error:

avrdude: verification error, first mismatch at byte 0x0000
         0xff != 0x0c
avrdude: verification error; content mismatch

Is this AVR dead? Can the bootloader be burned somewhere else in the memory, so the corrupted memory(?) isn't used by the bootloader or my sketches?

Before you pitch it, check for simple things. Is anything loading the pins used for programming? Is anything loading the supply that might be causing the voltage to dip during programming? Are the bypass caps present? Things like that can cause glitches during programming that result in problems programming it.

The AVR was originally used in a custom controller board, but I could easily program to it while sitting in its socket. When I burned the bootloader again, I took out the microcontroller and put it on a breadboard with a 16MHz crystal and two 22pF caps, and wired up the USBasp. There shouldn't be anything that may cause voltage dips.

So it stopped working when you moved it from the controller board to the breadboard?

I didn't see you mention the 0.1uf decoupling cap between vcc and gnd on the breadboard. Is that present? If not, that could be causing the problem.

I guess something happened on the robot PCB. I was testing the enable pin on the L298 with a wire, and that's when it happened. Then I took out the microcontroller, put it on a breadboard, and trid to burn the bootloader. Yes, I got a 0.1uF cap across Vcc and Gnd.

Have you got a 0.1uF on both power inputs to the chip? (there are two, either side of the board)

Also, have you got it wired in the breadboard as per a breadboarded example? With a 10K pull up on reset, the cap for the reset line you would connect to RTS/DTR etc?

Try a different programmer. Not all will handle the larger memory size (>64K) such as found on 1284P.
I use Atmel AVR ISP MKii for my 1284P bootloading (and programming if not using a bootloader).

You can still get them new

I don't know if the latest Arduino ISP will do 1284Ps. I imagine it would if it can do 2560s:

I've been using Arduino as ISP with IDE v1.0.5 and 1284P chips for 2 years. Works fine.

I hooked up the ArduinoISP, and Now I get this error: I got a 0.1uF cap at each side, and the reset line directly connected to pin 10 on the Arduino. This setup used to work before.. :confused:

 ***failed;  
avrdude: verification error, first mismatch at byte 0x0000
         0x3f != 0x0f
avrdude: verification error; content mismatch

If using a breadboard, it sounds like it's still wired wrong. All in all, those things are a disaster, best to avoid completely. I have pcbs laid out to mount 1284s, and never have any problems with wiring or programming.

Also, with the 1284 chips, there is a problem [in some cases] with the RX0 line to the chip - as mentioned in dozens of other posts. The solution is a small RC-filter, eg 1K series-R and 100pF cap to gnd on the RX0 pin.