I have a Mega that gives me a timeout error when attempting to upload a new sketch.
I reuploaded the bootloader hoping that it would clean it up. It didn't fix the problem, but it did narrow down the issue.
After reuploading the bootloader, I then uploaded the Blink sketch just to test if it would take it, and it worked just fine. However, when I tried to upload a 2nd sketch, it went back to the timeout error. This leads me to believe that it is having problems overwriting the old sketch.
Do you have a programmer to write the bootloader via the ICSP header ?
Then you can also use that programmer to upload a sketch with "Upload Using Programmer" via the ICSP header.
Is there something wrong with the second sketch ?
Can you remove everything, only the USB connector to the board should be connected. Use a different USB cable. Can you measure the 5V pin ? It should be above 4.5V.
Can you upload the Blink sketch twice ?
Then try to upload a sketch that sends some text to the Serial Monitor. Can you see that text ?
If that works, then you can show your sketch that blocks the upload, although I think it is not possible to block the uploading with a sketch. It is more likely that you have connected something to pin 0 and 1 or that the board is damaged or the USB cable is too cheap.
The board can be damaged if you soldered a wire and heated the board for too long, or if you have used a motor with 12V and that 12V got somehow into the board.
auto reset stopped working on the Mega. it is not required when the flash is clean so you can upload once after burning the bootloader.
try the reset button while avrdude attempts to upload
I've done a little more testing with it and found that it will upload once per connection to my PC. Essentially, I just have to unplug and replug the usb cable. The reset button will not give the same result.