Page MenuHomePhabricator

log: UART drivers and libraries are compiled in when log level is set to "silence"
Open, HighPublic


Assumption: there should be no need for files related to UART etc when logging is disabled (through TFM_PARTITION_LOG_LEVEL_SILENCE being chosen).

When building a project with log level set to TFM_PARTITION_LOG_LEVEL_SILENCE several unnecessary files are still being compiled and included in the binary.

This should be fixed by having these files being conditionally included based on the log level not being TFM_PARTITION_LOG_LEVEL_SILENCE.

Using the following build command on the current master (a0165475447d):

cmake .. 

Gives a binary of around ~32kb for tfm_s.bin

Below we can see that around ~2.5kB of this is spent on files related to logging.

~/tfm/trusted-firmware-m/build remotes/us/HEAD
❯ arm-none-eabi-nm --print-size --size-sort bin/tfm_s.elf  | rg "^00" | rg "(uart|stdio|USART|UART)"
00010b30 00000004 t ARM_USART_GetCapabilities
00010b46 00000006 t ARM_USART_SetModemControl
00010b34 00000006 t ARM_USART_Transfer
00010dc4 0000000c t ARM_USART1_Control
00010b64 0000000c t ARM_USART1_GetRxCount
00010b58 0000000c t ARM_USART1_GetTxCount
00010dd0 0000000c t ARM_USART1_PowerControl
00010c00 0000000c t ARM_USART1_Send
00010b4c 0000000c t ARM_USART_GetModemStatus
00010b3a 0000000c t ARM_USART_GetStatus
000113dc 00000010 T UARTE0_SPIM0_SPIS0_TWIM0_TWIS0_IRQHandler
000113ec 00000010 T UARTE1_SPIM1_SPIS1_TWIM1_TWIS1_IRQHandler
00010b70 00000014 t ARM_USART1_Uninitialize
00011238 00000018 T nrfx_uarte_tx_in_progress
00010b10 00000020 t ARM_USART_GetVersion
00010ae4 0000002c T stdio_init
00018004 00000038 R Driver_USART1
00010ddc 0000003c t ARM_USART1_Receive
00010c0c 00000040 t ARM_USART1_Initialize
00010b84 0000007c t ARM_USARTx_Send
00011250 000000a4 T nrfx_uarte_tx
000112f4 000000e8 T nrfx_uarte_rx
00010e32 00000102 t uarte_irq_handler
000110fc 0000013c T nrfx_uarte_uninit
00010c4c 00000178 t ARM_USARTx_Control
00010f34 000001c8 T nrfx_uarte_init

Event Timeline

hakonfam triaged this task as High priority.May 20 2021, 10:27 AM
hakonfam created this task.
ioannisg assigned this task to Anton-TF.Wed, May 26, 1:20 PM
ioannisg added a subscriber: ioannisg.

Anton, could you please, suggest an assignee for this one? Thanks!