the last couple of weeks, i struggled with this problem as well, now i found a solution, maybe it can help you
After programming in my Adruino Mega 2560 (r3) + Ethernetshield (r3) (osx) i couldn't upload anything to my board and received this error:
avrdude: stk500v2_ReceiveMessage(): timeout
Removing the ethernetshield and all wires didnt change a thing.
Removing and reinserting the usb cable, after which i CAN upload the 'blink example' !
'Succes' so i tought!
When trying to upload my sketch : avrdude: stk500v2_ReceiveMessage(): timeout
Once this happens, nothing (i.e.'blink') is able to be uploaded again (until I remove and reinsert the usb cable)
In my sketch there is a line : client.println("FORWARD!!!");
if i remove one exclamation mark, the problem is solved ! ...
That specific problem is the result of the mega2560/1280 bootloader having a useless 'monitor' function where if it sees three consective ! characters in the upload data stream it stops programming the chip an just waits for the user to enter monitor commands which will never happen in an arduino setup. Just changing that statement to:
client.println("FORWARD!"); would also solve that specific problem. There is newer modified bootloader code for the mega boards that fix the root cause but they are not part of the arduino IDE and don't ship with anyone selling mega boards.