Btw, I've been always confused by the info on the available flash - why we see the figures for the _total_ flash_on_the_chip when the bootloader eats a bit of it ?
Code: Select all
// Sketch uses 17,164 bytes (3%) of program storage space. Maximum is 524,288 bytes.
The same with other boards too..
The bootloader only uses the RAM while it is running, (so uploading something to flash) once it finishes uploading, the RAM that was used for the bootloader can be reused by the main program with no ill effects.
The bootloader will only run again after a reset, at which point the ram will be initialized, so there is no reason to reserve memory for it.
In the old leaflabs linker scripts RAM was being reserved for some reasons, I believe one was that the old bootloader allowed to upload a program to RAM, so to avoid the bootloader overwriting it's own memory while still uploading a program to RAM. I believe there were some other reasons, related to how the first bootloader managed the usb serial, a bit long to explain and honestly I dont remember all the details, but when we started working on the stm32duino bootloader we decided upload to ram with 20K made little sense, so that option was removed. Between that and some other optimizations we also reduced the bootloader size to leave more flash available for the sketch. There are a few old threads with those discussions and tests we made, probably in the General forum.
EDIT: Sorry, I just noticed you were talking about flash. I will leave the explanation above in case help clarify anyone doubts. Regarding the flash, Arduino calculates the total flash available thru some parameter in the boards file or one other of the text files, don't remember of the top of my head which one, but in the past, and probably still, some boards may have that value wrong in that config file.
For boards with bootloader upload option, the flash size should be reduced, I believe the latest bootloader size was under 8K, so that much should not be available for the sketch.
If you select a board option for stlink upload, then all flash is available for the sketch.