Sketch doesn't upload with specific array data (test case included)

I have run into a problem uploading a sketch to my Arduino Mega 2560.

Reduced test case and verbose output from uploader: Arduino Mega 2560 sketch that hangs on upload · GitHub

When I hit upload, it builds and starts uploading, but then hangs during the upload. TX/RX lights halt, my program does not start (although it does run, incorrectly, the next time I power on the device).

In the code, I have a large PROGMEM array (wavelet) which contains some sample data. When this is replaced with a different set of sample data of the same length, it uploads fine and behaves properly. The other set of sample data is included in the source that I posted above; just move the comments and build.

I get the same behavior when not using PROGMEM array, ie. uint8_t const wavelet[] = { ... };

Windows 7 64-bit, Arduino 1.0.1 software, Arduino Mega 2560 board, nothing attached except USB to dev machine.

Any suggestions for fixes or workarounds?

You've hit the "!!!" bug but in your case it's the '0x21 0x21 0x21' bug. Three bytes of '!' in a row triggers the firmware monitor and prompts for commands.

If you can change one of those three consecutive 0x21 bytes to something else you code should upload.