Where does the 30720 byte maximum size come from?

Hello,

I am a confused with regards to the 30720 byte maximum shown in the arduino ide when I upload a sketch. Where does that come from exactly? Why doesn't the ide indicate this or at least give some general reference? I think it should.

As you can imagine, I am getting close to this limit. I am using a bootloader with hfuse=DA or 1.5kb on the 328p arduino. I upload a sketch of ~29kb. If no ide error prompt and my sketch doesn't run then it is a sram issue, I understand that. However, sometimes I upload a sketch ~29kb and I get a ide sync error. I don't understand, 32-1.5=30.5kb, what's the problem?

Thanks,

-ren

Try optiboot, increases free space by a couple of k as it's smaller

I am using a bootloader with hfuse=DA or 1.5kb on the 328p arduino.

1.5kb for the bootloader is NOT one of the options (0.5, 1, 2, or 4k bytes...)

The Arduino Uno has 32768 bytes of memory. In theory, 512 bytes are used by the bootloader (Optiboot), leaving 32256 bytes for the sketch. However, there was a bug in the optiboot shipped with many Unos that causes uploads of more than about 28k to fail. This is fixed in recent Unos (but it's not clear you would get a "recent" Uno when you order from a random place.) Older Unos can be upgraded to a new version of Optiboot to fix the problem.

Prior to Uno/optiboot, m328-based Arduinos used a 2k (2048) bootloader, leaving 30720 bytes for the sketch. Presumably you have one of these. I don't know of any 28k-like bug with the old bootloader, but... If your failures with a 29kB sketch only occur "sometimes", that's pretty mysterious. Older 328-based Arduinos can be upgraded to Optiboot as well, after which you can call them "unos" in the board menu, and uploadt 32256 byte sketches.

westfw,

Thanks, yes, I see you are right about the bootloader size, DA=2048 bytes.

With regards to the sync failure at ~29kb. I should have been more clear. There is some point between 29kb and 30kb that I will get a sync failure. I am just not sure what that value is. I was not saying that I am getting inconsistent results. I was just trying to illustrate that I understand difference between sram and sync failure.

The Uno issue you mentioned got me curious, I tried uploading the same sketch that gave me a sync error onto another 328p arduino, it worked fine. So, I went back to the 328p that gave me the sync error, checked fuses with avrdude-gui, turns out hfuse was set wrong, I updated to DA and now sketch uploads fine.

Thanks for your help,

-ren