ATMega2560 - Unable to reprogram, how to clear memory?

I was working on a sketch this morning and I was dealing with pointers and callbacks and something obviously went wrong as the Arduino 2560 is continually looping after about 1 second. My script had a delay of 1000ms before it was trying to do some extra work and then not long later it starts again from the start (I assume it is rebooting).

I can see the output in the serial monitor so it is basically working, but then the code restarts and it does this forever.

I can not upload a new sketch as it fails with a verifiy error after the upload

Binary sketch size: 1,632 bytes (of a 258,048 byte maximum) avrdude: verification error, first mismatch at byte 0x0000 ** 0x01 != 0x14** avrdude: verification error; content mismatch

I assume it is rebooting/resetting during the upload or something?

Is there any way to get this device back? I have no idea how to proceed.

Chris =(

Under File:Preferences, turn on verbose outputs.

Press & hold the reset button, start the download. When the IDE shows "Compiled xxx of 128xxx bytes" (or similar) release the reset button. May take a few tries to get the timing right. Try downloading a simple sketch like Blink so that you are not blasting a ton of stuff out of the serial port.

CrossRoads: Under File:Preferences, turn on verbose outputs.

Press & hold the reset button, start the download. When the IDE shows "Compiled xxx of 128xxx bytes" (or similar) release the reset button. May take a few tries to get the timing right. Try downloading a simple sketch like Blink so that you are not blasting a ton of stuff out of the serial port.

Are you meaning both Compile + Upload?

Or just compile?

I am trying no luck yet.

It either uploads really quickly and then shows verify errors. Or a message about uploading and then the following

avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_getsync(): timeout communicating with programmer avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_getsync(): timeout communicating with programmer avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_getsync(): timeout communicating with programmer avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_getsync(): timeout communicating with programmer avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_getsync(): timeout communicating with programmer avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_getsync(): timeout communicating with programmer avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_getsync(): timeout communicating with programmer avrdude: stk500v2_command(): failed miserably to execute command 0x10 avrdude: initialization failed, rc=-1 Double check connections and try again, or use -F to override this check.

Chris

Is there some low level way to remove the current program?

How about re applying the boot loader? Does that clear memory?

Would that even work?

chris

Back up a step then - does the Loopback test work?

Yes, reloading the bootloader clears the existing program.

I tried the loopback from http://forum.arduino.cc/index.php?topic=73748.0 and it worked fine.

I tried to do a bootloader via the ICSP port form a UNO to the 2560 and it failed with a verify failure.

I then tried to upload the blink using the UNO to the 2560 and it said it worked.

But it now does even less. No blink and still fails to upload using a normal arduino upload.

Chris