Bootloader size

Hello,

If you reduce the bootloader size on a 328p from 2kb to 1.5kb, is the .5kb available to the application? Is this space automatically available or do I have to change something on the Arduino IDE before I upload my code? Or do I need to upload using avrdude?

Thanks,

-ren

You need to change the fuse bits with an AVR programmer, see http://frank.circleofcurrent.com/fusecalc/fusecalc.php?chip=atmega328p

See here for allowable boot-sector sizes, and the corresponding fuse-settings. Beware: the units are 16-bit words, not bytes (caught me out :blush:) http://www.engbedded.com/fusecalc/

Thanks for the replies. Yes, I know to change the fuses and start address when I upload the bootloader using avrdude, but do I need to make any changes when I am uploading the application using the Arduino IDE? Is it set for the max size by default?

I do believe the IDE throws an error if your sketch is too big, the limit is set in boards.txt

OK, thanks!

If you reduce the bootloader size on a 328p from 2kb to 1.5kb, is the .5kb available to the application? Is this space automatically available or do I have to change something on the Arduino IDE before I upload my code? Or do I need to upload using avrdude?

First of all, optiboot is currently 512 bytes, so on an Uno (or other Arduino on which you've installed optiboot) you already have an additional 1.5k available.

The AVRs in use on on Arduinos have special support for a "bootloader section" whose size you can set via the BOOTSZ fuses. However, the size is always a power of two: 512, 1024, 2048, or 4096 bytes (on 328p; actual numbers vary with CPU type.) Reducing the bootloader size from 2k to 1.5k is thus useless; you would have to get down to less than 1k in order to change the fuse settings.

renasis:
Thanks for the replies. Yes, I know to change the fuses and start address when I upload the bootloader using avrdude, but do I need to make any changes when I am uploading the application using the Arduino IDE? Is it set for the max size by default?

The boards.txt file tells the IDE about actual memory size avalible for the various chip types/bootloader version:

Extract:

##############################################################

uno.name=Arduino Uno
uno.upload.protocol=stk500
uno.upload.maximum_size=32256 <<<
uno.upload.speed=115200
uno.bootloader.low_fuses=0xff
uno.bootloader.high_fuses=0xde
uno.bootloader.extended_fuses=0x05
uno.bootloader.path=optiboot
uno.bootloader.file=optiboot_atmega328.hex
uno.bootloader.unlock_bits=0x3F
uno.bootloader.lock_bits=0x0F
uno.build.mcu=atmega328p
uno.build.f_cpu=16000000L
uno.build.core=arduino

##############################################################

atmega328.name=Arduino Duemilanove or Nano w/ ATmega328

atmega328.upload.protocol=stk500
atmega328.upload.maximum_size=30720 <<<
atmega328.upload.speed=57600
atmega328.bootloader.low_fuses=0xFF
atmega328.bootloader.high_fuses=0xDA
atmega328.bootloader.extended_fuses=0x05
atmega328.bootloader.path=atmega
atmega328.bootloader.file=ATmegaBOOT_168_atmega328.hex
atmega328.bootloader.unlock_bits=0x3F
atmega328.bootloader.lock_bits=0x0F

atmega328.build.mcu=atmega328p
atmega328.build.f_cpu=16000000L
atmega328.build.core=arduino

##############################################################