Go Down

Topic: Larger binary sketch size? (Read 675 times) previous topic - next topic

sonofabell

What determines the maximum binary sketch size?  How can it be increased?

bens

The size of the flash of your MCU determines the maximum sketch size.  The mega168 has 16,384 bytes of flash, so that's the largest program you can fit on there.  The Arduino also has a 2kB bootloader that is used to program the rest of the flash, so in reality, you only have 14,336 bytes of flash for your program.  If you want you can recoup the 2kB of bootloader space by deleting the Arduino bootloader and using ICSP to program your Arduino.  If you do this, you also avoid having to wait for the bootloader delay on power-up and reset.

Other considerations if you want to fit more on your mega168: don't include libraries that you aren't using in your sketch as this is wasted space, and consider writing your program outside the Arduino environment if you need every last byte of flash.  There are things the Arduino environment sets up automatically, like timers and the UART, which will take up some flash space.  If you don't need timers or the UART in your program, this is also wasted space.


- Ben

Go Up