I'm looking forward to reduce the size of the standard serial bootloader in order to make some room for a custom calibration routine. Is there any thing that may be removed/commented from the standard source file without altering the normal use of the bootloader? This is for a custom Atmega328p board running from the internal RC oscilator. Hence my wish to do some calibrations from the bootloader.
Thanks in advance!
Well I think there is little point in your request. As I understand it the current Uno bootloader already fits inside the smallest flash chunk size the AVR hardware can reserve for a protected bootloader space. I will let ours confirm that statement. If that is indeed the case, making the object size of the bootloader any smaller would not free up any available flash space for you users sketch. I seem to recall reading posted here that the current uno bootloader leaves only 3 bytes free from the size limit it uses for the smallest possible flash memory bootloader reserved area.
Or are you wishing to add your calibration function to the bootloader such that it runs only when the chip is first powered up or upon a hardware reset? If that is the case you could possibly add it to the existing bootloader source code, recompile it and then burn this new bootloading/self-calibrating program into the chip using the next larger size reserved bootloader section of the flash memory. The fuse settings tell the chip what size bootloader area to save and I think the choices are 256, 512, and 1024 bytes, but check the 328p datasheet to confirm that, as I'm pretty old and the old memory can play tricks on me.
I don't see an advantage to having your calibration function run inside a bootloader area, as just running it from the setup function of your sketch would accomplish the same thing, to be run just once at power up or reset time. But perhaps I'm not fully understanding your requirements?