In our design we are using Kinetis MKL03Z8 with only 8KB of flash. We have been able to program needed application from peripheral examples on test board FRDM-KL03Z (LPUART and I2C + using VLLS modes) but firmware is to large to fit into 8KB. I also try barebone SDK (v2.3.1) minimalistic example ("demo_apps->hello_world") inside MCUExpresso, but I could not get below 9KB PROGRAM_FLASH, even with optimization level for size (-Os). How can i further reduce program size (I assume examples have some ballast) or where I get driver/example files (e.g. MWE) with smallest footprint possible for LPUART, I2C master peripheral to fit into 8KB region space?
Hello Tomaz Lovrencic ,
Try to disable “printf()”, also don't include <stdio.h>, then the size of bare board project is almost 2k,
and you can also reduce the codes in drivers that don't use.
Hope it helps,
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Alice_Yang, thanks for the suggestion. If anyone will find this useful, I ended up with these modification steps (also including Alice_Yang suggestion), which greatly improves code size of the examples:
- use baremetal example and manually pasting only needed driver/other files,
- use Redlib(none) semihosting option,
- exclude <stdio.h> and printf() functions. For production stage use LPUART_WriteBlocking() for strings and LPUART_WriteByte() for bytes with LPUART_IRQHandler() for RX,
- remove preprocessor compiler directives: DEBUG, PRINTF_FLOAT_ENABLE, CR_INTEGER_PRINTF, PRINTF_ADVANCED_ENABLE. Instead use NDEBUG which supresses asserts and printfs throughout the whole project,
- set optimization level for size (-Os),
- debug level to None.
This way I managed to get down to 6KB including needed peripheral drivers and my code.