AnsweredAssumed Answered

How small can the bootloader be?  My target is 5K and I only need SPI.

Question asked by Don Willey on Mar 26, 2018
Latest reply on Mar 30, 2018 by Jing Pan

I use a Kinetis MKL16Z32VFT4 that has just 32K of flash.  My present application takes up all but 5K of this, and while I might be able to shrink what I use now, I may also need to add more features, so let's say my bootloader is targetted to 5K with any application optimizations used to add features to the application.

The ideas I know about include:

- Reduce number of peripherals (bootloader_config.h changes).

- Reduce number of supported commands (bootloader_config.h changes). 

- Use newlib nano?

- Debug on systems with larger flash, but test 32k target with only release builds with size optimizations maxed out.

- Reduced use of libraries to use fewer, most basic options (for example puts() instead of printf() if practical).

- Find repeated code sections and make them functions.

- Evaluate code for flexibility I won't need.  Trim down functions that support options, parameters, and indirection that give great run-time flexibility but won't be needed in my application. 

It is an extreme example, but I might need just one kind of flash erase that starts at address 0x1400 and ends at 0x7FFF, so potentially the erase does need any parameters and other erase functions like erase all can be eliminated along with error codes/handling for invalid address range, protect/unprotect flash, etc.  

All suggestions welcome.