Missing 512 Bytes When Using External Programmer

We are running tight on space for our sketch, and so I figured I would use an external programmer which if my understanding is correct will erase the bootloader and free up 512 Bytes on the Uno.

However, whether I use the USB connection or the External Programmer, the IDE reports the same statistic

31,964 bytes (of a 32,256 byte maximum)

What am I misunderstanding here?

The IDE is pretty stupid when it comes to this.
The issue is that the board type specifies the flash space available
and there is no information as to how large the bootloader is.
So if the same board type is used, for both types of programming,
the amount of space that the ide “sees” as available is the same
regardless of whether an external programmer or bootloader is used to upload the sketch.

So to get around this you will have to
modify the boards.txt file which is down under
{installdir}/hardware/arduino

The key line is:

uno.upload.maximum_size=32256

You can either modify the existing entry for a larger size
or create a separate board type for ISP programming (which is what I’d recommend)

I created my own new entry so that I can just select that board type rather
than having to select using an external programmer.
Example:

##############################################################
# note: while this board type does not use a bootloader,
# the optiboot bootloader is specified to allow using it burn
# a bootloader
##############################################################

m328ISP.name=Arduino Uno w/USBasp
m328ISP.upload.using=usbasp
m328ISP.upload.maximum_size=32768
m328ISP.bootloader.low_fuses=0xff
m328ISP.bootloader.high_fuses=0xdf
m328ISP.bootloader.extended_fuses=0x05
m328ISP.bootloader.path=optiboot
m328ISP.bootloader.file=optiboot_atmega328.hex
#m328ISP.bootloader.path=empty
#m328ISP.bootloader.file=emptyatmega328.hex
m328ISP.bootloader.unlock_bits=0x3F
m328ISP.bootloader.lock_bits=0x3F
m328ISP.build.mcu=atmega328p
m328ISP.build.f_cpu=16000000L
m328ISP.build.core=arduino

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

Depending on which programmer you are using, you may
have to change the avrdude protocol specified in the
upload.using line.

— bill

Hi Bill

Thanks for spelling out that clever shortcut. In the file though, I presume these lines are incorrect?

m328ISP.bootloader.path=optiboot
m328ISP.bootloader.file=optiboot_atmega328.hex
#m328ISP.bootloader.path=empty
#m328ISP.bootloader.file=emptyatmega328.hex

ie the first two lines should be the ones commented and the last two lines should not?

Thanks again,
Geoff

Technically you are correct, however
note the comment at the top.
I created an a new entry that doesn't use the bootloader
but can burn one if you want to put one back without having
to change board types.

One thing to keep in mind is that if you have a totally blank part, you will need to set the fuses.
If you want to use the IDE to set the fuses you have to burn a bootloader
as I believe that the IDE doesn't have a way to just set the fuses.
If it doesn't find the bootloader, it will error off and won't properly
set the fuses.
I probably should update the comment to be a bit clearer:

# the optiboot bootloader is specified to allow using it burn
# a bootloader as well as set the fuses.

I think I've seen an empty .hex file floating around, but it
isn't included in the bootloaders directory.
You could manually create one by hand if you want to.
I just was lazy and use the optiboot hex image.

--- bill

Thanks bill. I will try this out tonight for sure.

Hey! Thanks so much for the detailed reply. This is very helpful.

Steve

bperrybap:
The IDE is pretty stupid when it comes to this.
The issue is that the board type specifies the flash space available
and there is no information as to how large the bootloader is.
So if the same board type is used, for both types of programming,
the amount of space that the ide "sees" as available is the same
regardless of whether an external programmer or bootloader is used to upload the sketch.

Depending on which programmer you are using, you may
have to change the avrdude protocol specified in the
upload.using line.

--- bill