Hopefully a simple question.
When compiling on the Arduino IDE, and the compiler ends its messages with the estimated Flash and RAM used by the program. Does this take into account a bootloader at all, or is this assuming a blank processor?
Using an Arduino Mega, I had it reporting 96% full, 245832 bytes. Compiled fine, but would not download the hex fine and resulted in a verification error.
Commented out some code, compiled at 245004 bytes, still 96%, and that hex loaded in fine.
The only thing I can assume is the bootloader is not taken into consideration - which is fine.
Sketch uses 244,844 bytes (96%) of program storage space. Maximum is 253,952 bytes.
Global variables use 6,581 bytes (80%) of dynamic memory, leaving 1,611 bytes for local variables. Maximum is 8,192 bytes.
This compiles and loads.
but go to 245832 and it didnt. That should still be 8120byte off... hmm
Thanks for the idea about MegaCore. I will look into that.
That is strange. I've never gotten that close to filling up the ATmega2560. The only thing that comes to my mind is that maybe the fuses aren't set correctly on your microcontroller. If you have a programmer or can set up an Arduino as ISP easily you could try doing a Tools > Burn Bootloader on your Mega, which will make sure that the fuses are as expected.
Unless you have checked the fuses or set them yourself you can never be sure what they are set to. The easiest way to set them to a known state is via Tools > Burn Bootloader.