Can't upload to Mega2560

I'm trying to upload the Mozzi sinewave example to my Mega2560 in preparation for messing around with it myself. But when I tell it to upload, it doesn't work; I'll describe the errors here:

Initially begins to upload fine, with TX and RX blinking quickly and L on constantly, as normal Then L turns off and TX and RX stop blinking quickly and begin blinking very slowly -- approximately 0.25 Hz, always both at the same time.

When I disconnect the board, a series of errors appear on the screen that likely should have appeared earlier, all from avrdude giving timeouts on stk500v2_recievemessage, with a few failed writes in between.

The code is 10848 bytes in size, and compiles perfectly.

Posting the code and the full error messages would be a good start for getting help with this.

It actually appears to have nothing to do with the code, rather just with the size of the code. Smaller programs upload fine, larger ones and ones about the same size do not. I’ll include the code below, and the errors as an attachment (verbose output on).

Edit: also, the loopback test reveals that there is nothing wrong with the USB interface.

I find it hilarious that it repeatedly sends “Bootloader>Huh?” and I think that there might be a problem with the bootloader, which is odd because it works fine with smaller sketches.

/*  Example playing a sinewave at a set frequency,
 *  using Mozzi sonification library.
 *  Demonstrates the use of Oscil to play a wavetable.
 *  Circuit: Audio output on digital pin 9.
 *  Tim Barrass 2012.
 *  This example code is in the public domain.

#include <MozziGuts.h>
#include <Oscil.h> // oscillator template
#include <tables/sin8192_int8.h> // sine table for oscillator

// use: Oscil <table_size, update_rate> oscilName (wavetable)

// use #define for CONTROL_RATE, not a constant
#define CONTROL_RATE 64 // powers of 2 please

void setup(){
  startMozzi(CONTROL_RATE); // set a control rate of 64 (powers of 2 please)
  aSin.setFreq(440u); // set the frequency with an unsigned int or a float

void updateControl(){
  // put changing controls in here

int updateAudio(){
  return; // return an int signal centred around 0

void loop(){
  audioHook(); // required here

Bumping this because I really need a fix... It's starting to occur with smaller programs too. Is this a problem with the IDE or with my Arduino? Or perhaps I myself am doing something stupid.

There is a bug in the Mega 2560 bootloader that causes uploads to fail if your compiled sketch binary contains the string "!!!" (because this triggers a serial terminal). This might be happening by chance with this code, e.g. in an array or lookup table or just by coincidence.

That can't be it, it happens with any code larger than about 10 kilobytes.

Having the same Problem with Mozzi.
I’m getting this in the verbose output, the bootloader switches to monitor mode, but there is no “!!!” in the code:

The sequence can be anywhere in the hex file that gets uploaded. If you have a byte array that contains the three or more bytes in a row, that will trigger it.

Look for any array that has 0x21 0x21 0x21 or the decimal equivalent 33 33 33

It might be this file:

its the table used in the sample to generate the sinwave and contains 33 multiple times in an array.

With the sin2048_int8.h table, the code gets smaller than 10kb but the loader still switches to monitor mode, so it doesnt seem to depend on filesize but it also contains 33 3 times in a row.

With the sin1024_int8.h table, everything works perfectly fine, no errors. It does NOT contain 33 more than 2 times in a row.

Is there a way to fix this?