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.