Uploading with programmer doesn't seem to let use more space

Hello,

I'm failing to compile/upload a sketch to upload to a Leonardo board, due to apparent lack of space:

I'm using a programmer, as recommended (I am new to using a programmer):

However, compilation fails, and maximum space doesn't seem to change when using a programmer.

The program size should fit into the storage space, if not using bootloader.

How can I upload my program? I can't really cut on the space, as it seems to be mostly used by the 2 libraries I have to open.

Thanks!

Compress your code down to use less functions or get a board with more space.

My bit of code is tiny.

2 Libraries use ~all the space. The support page suggests using a programmer, but I can't see how it's helping me in this case.

A programmer would obviate the need for a bootloader, allowing you to use all the program memory for your code.

1 Like

Uploading the sketch with a programmer via ISP will not need the bootloader space.

However, you need to change the fuses to tell the processor to not reserve the 4K for the bootloader and make it available for the sketch.

2 Likes

Thanks, I guess that's the (a?) missing piece of the puzzle. I can't find any info on what fuses to change for this though.

I've managed to upload a basic (blink) sketch on my Leonardo using "Arduino as ISP" as a programmer, but the available space does not increase. In fact, this fails on compilation, so does the arduino IDE (2.1.0) just not check available space on the board?

You will need to create a dedicated entry for a board that indicates the available memory. Locate boards.txt on your computer. I'm using Windows and can find it in C:\Users\myUserName\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6.

There is an entry for the Leonardo

leonardo.upload.tool=avrdude
leonardo.upload.tool.default=avrdude
leonardo.upload.tool.network=arduino_ota
leonardo.upload.protocol=avr109
leonardo.upload.maximum_size=28672  <<=================
leonardo.upload.maximum_data_size=2560
leonardo.upload.speed=57600
leonardo.upload.disable_flushing=true
leonardo.upload.use_1200bps_touch=true
leonardo.upload.wait_for_upload_port=true

That determines the size that the IDE will use and when you will be over the limit; I've added a pointer in above.

If you hack the boards.txt, be aware that an update of the AVR board package will undo your changes. There is a way using your own boards.txt but I'm not sure how.

I can't advise on the fuses.

1 Like

You might want to make a custom version of those libraries where you remove the unecessary code blocks, that might reduce the size.

The compiler/linker does a pretty good job of eliminating unused code.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.