Ok, an experiments with Lefty's code. I generated some exhaustive initialization just to see what would happen.
#include <avr/pgmspace.h> //To store arrays into flash rather then SRAM
// Simple sketch to create large sketch sizes for testing purposes
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
/*
Make arraysize = to 1500 for 328P chip, 4000 for 1280P chip?,
3600 for 644P chip, xxxx for 1284P, etc.
*/
const int arraysize= 3000; // value to mostly fill available flash capacity
long myInts0[arraysize] PROGMEM = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,
30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,... // up to 2999
long myInts1[arraysize] PROGMEM = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,
30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,... // up to 2999
//...
//...up to
long myInts9[arraysize]PROGMEM={//etc
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
int i = random(0,arraysize); // Work around any optimization for constant values
Serial.print(myInts0[i]); // Access some random element so the array can't be optimized away.
Serial.print(myInts1[i]); // Access some random element so the array can't be optimized away.
Serial.print(myInts2[i]); // Access some random element so the array can't be optimized away.
Serial.print(myInts3[i]); // Access some random element so the array can't be optimized away.
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
What I've noticed is that if the sketch size goes over 128K I start getting errors of the form:
warning: internal error: out of range error...That is, if I add a an additional array of [arraysize] longs where arraysize = 3000, bringing the number up to 11 arrays, each of 3000 long elements = 4*11*3000 = 132K bytes (then add the rest of the sketch ) I start getting that out of range error called on various libs. For instance the first place it shows up is as an out of range error on the do_random func random.o. If I comment out the call to random, it shows up in Hardware Serial.
If I stick to 10 initialized arrays the sketch size is 124,996 ( = 4*10*3000 + rest of sketch). No problems compiling/linking.
Now interestingly. suppose instead of long int I initialize each of the myInts array to 3000 4 byte null terminated strings thus:
char* myInts9[arraysize] PROGMEM ={"abc\0","abc\0","abc\0",//..etc for 3000 initializers
For 10 initialized arrays of 3000 four-byte-strings the IDE reports a sketch size of 64,646 bytes out of a 258,048 byte maximum. The same sketch initialized to longs is reported as 124,996.
For 20 initialized arrays of 3000 four-byte strings the IDE reports
arduino-1.0.3\hardware\arduino\cores\arduino/main.cpp:11: warning: internal error: out of range error
Binary sketch size: 136,682 bytes (of a 258,048 byte maximum)
If I take out 1 array I get no errors and
Binary sketch size: 130,646 bytes (of a 258,048 byte maximum)
I have not yet tried to load and run these sketches.
Cheers,
Joe