Mega 2560 randomly hanging

Stan09:
Interesting. What exactly 3 characters? Any link to more detailed info on this?

The ! ASCII character, as in 0x21. So three 0x21 bytes sent in a row anywhere in the upload data stream locks up the bootloader waiting for user monitor commands from the PC which will never come. As far as more detailed info, there has been a lot posted in the forum over the years sense the original mega1280 board was released, but I'm not aware of any 'official' document posted on the arduino web site. There is mostly likely a old and mouldy bug report in the arduino developers bug reporting archive list wherever one finds that.

The source code for the mega bootloader is included in the IDE software distribution if you want to seek it out and read about this wonderful feature included in the mega bootloader code.

Lefty