Yes, it's a known bug in the mega bootloader program (where if an upload data stream has three consecutive ! characters (and that can either be constant string or char values in your sketch, or just three equivalent byte values is the code part of the uploading the sketch) that causes the bootloader to jump into a 'monitor mode' awaiting user monitor commands (which will never come) thus hanging the up load operation. The other known mega bootloader bug is that it doesn't handle watch dog timer interrupts correct as they did fix in the Uno's bootloader. There has been corrected/updated mega bootloaders available for some time now (not sure where to find it though) but at present a 'fixed' mega bootloader is still not shipping with mega board, nor does the IDE have a updated mega bootloader as part of the arduino IDE distribution. Simply put the arduino mega just has received no love from the arduino company for a long while now. This bug has existed for at least as long as the original mega1280 started shipping several years ago.
Hi,
it is not important to have three exclamation marks in this text. The problem was i did some minor programm changes in a running system. Suddenly I was not able to write a new programm in the mega. I could not imagine that this change in a string could cause this problem. Therefor I checked everything, from powersupply to casing. I also ordered a second Mega 2560 (Freaduino) and was not deliverd in two weeks. I found an old usbprog in my "spare part stock". Which I have had to flash befor the first use. Finally I could programm the mega thru ISP (with three exclamation marks in source code).
This bug took me a lot of time and nerves. Nevertheless I am very satisfied with the Arduino Mega.