Got into a strange problem with a Mega2560.
It run one sketch (avrdude: 16696 bytes of flash verified).
I then made a new sketch based on the first one but with a few changes (avrdude: 17324 bytes of flash verified).
Now the controller run until in the middle of the setup() function and the restart. Just before it restart part of a Serial.println(F("Some test")); is printed and with some special characters behind (od in linux say octal values 342 270 256).
I thought it could be a bug in the function being called from the setup(), so I added a few more Serial.println(...) in the code and uploaded it (avrdude: 17454 bytes of flash verified). Now the controller won't start at all. Nothing happens.
My first though is that the flash memory is bad, but the verification process that avrdude is doing - isn't that done to verify that the content of the flash memory is correct?