Extremly long, "time out" upload on 2560

Hi Builders,
I've experienced a strange behaviour today. I have a code (45k compiled, 149 k raw .ino). The core of the code is a set of matrixes in const byte PROGMEM (almost 90% of the actual code is far over quota of 9500 characters, if you want to see this, visit this DropBox link please:
https://dl.dropboxusercontent.com/u/68351537/progmem_2560.ino
/* */ part were cut for testing).
The board is working flawlessly with smaller parts (half the size), but not with this huge code. I've got an "avrdude: stk500v2_ReceiveMessage(): timeout" error after about 5 minutes of waiting.

What did I do wrong?

Thanks for your suggestions,

Tom

What did I do wrong?

You posted your code on dropbox, instead of attaching it.

Yep, you're right.
And you didn't read my post from the beginning to the end:
actual code is far over quota of 9500 characters
As I wrote, sketch is 145 k long. This is over 15-times bigger. Let me know the cheating code to post 145 k long source here, and I'll do it.

Perhaps when you were typing your initial post and your diatribe, you noticed the Additional Options... link in orange, just below the window you were typing in. You could have used that link, and attached your code to your post.

Or not. It all depends on whether you want help, or not.

I'm reading this behind a firewall, through a proxy server that blocks access to dropbox and other potentially virus-infected sites.

By the way, here is what you’re looking for (seriously trimmed to fit):

#include "Tlc5940.h"
#include "avr/pgmspace.h"

/*
const byte leds1 [] PROGMEM = {
0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0,

// 490 lines of similar data here

0, 0, 0, 5, 16, 42, 63, 54, 27, 8, 0, 0, 0, 0, 0, 2
};

const byte leds2 [] PROGMEM = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 

// 490 lines of similar data here

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 145, 255
};

const byte leds3 [] PROGMEM = {
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 

// 490 lines of similar data here

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};

const byte leds4 [] PROGMEM = {
255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

// 490 lines of similar data here

255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0
};

const byte leds5 [] PROGMEM = {
0, 24, 50, 0, 0, 0, 30, 0, 0, 45, 6, 0, 0, 8, 3, 0, 

// 126 lines of similar data here

0, 35, 55, 0, 0, 36, 176, 0, 0, 164, 186, 0, 0, 29, 149, 0
};


int channel;
int line;
int intensity;
byte readout;
byte waiting = 100;


void setup()
{
  Tlc.init();   // initialize the TLC library
  Tlc.clear();  // turn off all the LEDs
}


void loop()
{
  for (line = 0; line <= 491; line ++)
  {
    for (channel = 0; channel < 16; channel ++)
    {
      readout = pgm_read_byte_near(&leds2[channel+line*16]);
      intensity = pow(readout,1.497);
      Tlc.set(channel, intensity);
    }
    Tlc.update();
    delay(waiting);
  } 
  for (line = 0; line <= 491; line ++)
  {
    for (channel = 0; channel < 16; channel ++)
    {
      readout = pgm_read_byte_near(&leds1[channel+line*16]);
      intensity = pow(readout,1.497);
      Tlc.set(channel, intensity);
    }
    Tlc.update();
    delay(waiting);
  }
  for (line = 0; line <= 491; line ++)
  {
    for (channel = 0; channel < 16; channel ++)
    {
      readout = pgm_read_byte_near(&leds3[channel+line*16]);
      intensity = pow(readout,1.497);
      Tlc.set(channel, intensity);
    }
    Tlc.update();
    delay(waiting);
  } 
leds_4();
leds_fade();
leds_gyertya();
}

void leds_4()
{
  for (line = 0; line <= 491; line ++)
  {
    for (channel = 0; channel < 16; channel ++)
    {
      readout = pgm_read_byte_near(&leds4[channel+line*16]);
      intensity = pow(readout,1.497);
      Tlc.set(channel, intensity);
    }
    Tlc.update();
    delay(waiting);
  } 
}

void leds_fade()
{
  for (int intensity = 0; intensity < 128; intensity ++)
  {
    Tlc.setAll(intensity*32);
    Tlc.update();
    delay(waiting/4);    
  }
  for (int intensity = 127; intensity >= 0; intensity --)
  {
    Tlc.setAll(intensity*32);
    Tlc.update();
    delay(waiting/4);    
  }
  
}

void leds_gyertya()
{
  for (line = 0; line <= 245; line ++)
  {
    for (channel = 0; channel < 16; channel ++)
    {
      readout = pgm_read_byte_near(&leds5[channel+line*16]);
      intensity = pow(readout,1.497);
      Tlc.set(channel, intensity);
    }
    Tlc.update();
    delay(waiting);
  } 
  for (line = 245; line <= 0; line --)
  {
    for (channel = 0; channel < 16; channel ++)
    {
      readout = pgm_read_byte_near(&leds5[channel+line*16]);
      intensity = pow(readout,1.497);
      Tlc.set(channel, intensity);
    }
    Tlc.update();
    delay(waiting);
  } 
}

By the way, here is what you're looking for (seriously trimmed to fit):

I have my Mega plugged in, and ready to try uploading code to, when you post code that compiles.

When asking for help with a coding problem, you need to post code that actually demonstrates the problem. Preferably the minimum code necessary to demonstrate the problem, although in this case the minimum code is probably still going to be quite large. You can attach it if it's too large to post inline.

Thanks, I hope, it will go through.
(File attached.)

progmem_2560.ino (146 KB)

The Mega bootloader switches to debug mode if it sees !!! in the code being uploaded. While your code does not have that, the ASCII value for ! is 33 and you do have 3 33's in a row in your data.

Changing the stream of 33's to 33, 32, 33, 32, 33, 32, etc. Allows the upload to proceed, but there is still a problem.

Binary sketch size: 43,712 bytes (of a 258,048 byte maximum)
avrdude: verification error, first mismatch at byte 0x616f
0xfe != 0xff
avrdude: verification error; content mismatch

I have not used this Mega since I reinstalled the OS and all the device drivers, so you may have better luck.

Dear Paul,
Based on your suggestion, I fixed the sketch. Thanks for the support.
About the error code you've got: it's also a memory issue. 0xFF (255) in some circumstances shows the end of available memory. Thats why upload failed with the original sketch. Now I've changed 255 to 254, and every 33, 33, 33 combination have been also changed.

Thanks, I really appreciate your support.

Yours sincerely,

Tom