Arduino sketch size != than upload size

Hello,

I have custom bootloader with BOOTSZ set to 512W_3E00, of course I changed in boards.txt the max sketch size to 31744 (so sketch going to address 7BFF max) according the size of my custom bootloader.

With a big sketch, Arduino IDE 1.0.5 tells me that :

Binary sketch size: 31,632 bytes (of a 31,744 byte maximum)

But looking in hex file generated, I've got code going above 0x7C00 (starting code of by bootloader)
and of course uploading fails with :

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x7c00
         0x6f != 0xcd
avrdude: verification error; content mismatch
avrdude: Send: Q [51]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 

avrdude done.  Thank you.

So I looked with avr-size

\Arduino-1.0.5\hardware\tools\avr\bin\avr-size RF_Gateway.cpp.elf
   text    data     bss     dec     hex filename
  31632     440     764   32836    8044 RF_Gateway.cpp.elf

Did someone already encountered this wrong size issue ?
I have a lot of Print(F("string")) so I suspect the size does not take into account these Flash code (may be in data section), but I'm not really sure.

Any ideas are welcome

Size in flash is text+data=32072 IDE should display this. Weird, I don't remember that it displayed only text size in 1.0.5.
Anyway. this exceeds available flash memory so you have to do some code optimization. Or try the newest version which has newer compiler it could produce less of code.
For example, I'm using 1.0.6 but have replaced toolchain with avr-gcc 4.7.2 which produce smaller code than original in 1.0.6.

Budvar,

Well, in fact I could optimize the code but there is a lot of debug code inside so it won't be a problem. But I was really surprised, because I did not protected my bootloader code and this erased a part of it.

I've also tried with IDE 1.5.8 that is really generating smaller code, but unfortunately compiled code does some strange issues and sometimes my Arduino fall into reset without any reason. But I'm using some complex trick such as calling function located into bootloader code and values also located into bootloader, so may be it's related to this.

I did not investigate on this point, continuing to compile with 1.0.5 for now, but I solved my issue learning in deep Lock Fuse, setting BLB1 to SPM Disable avoid bootloader erasing :wink:

If you want to take a look of what I'm really doing with bootloader code just see the dedicated post here

thank you for your help

Interesting reading you've posted. Great job. Have a +1.