cancel
Showing results for 
Search instead for 
Did you mean: 

Code size generation

gerardo
Associate II
Posted on November 21, 2014 at 18:47

Hi all,

I´m developing an application in Keil uVision with STM32L052C that is a uC that has 32KB of flash memory.

I add my ST libraries and per example STM32L0xx_hal_uart.c. This library uses some features with DMA but i will not use this.

 

Looking to compilation size I´ve notized that I could have Flash size problems, so my question is, how is the best way to delete this DMA functions. in all libraries?

Maybe there is an option in project propierties that avoids/removes unused functions from the image created.

Let see the .map file

Symbol Name                              Value     Ov Type        Size  Object(Section)

...

HAL_DMA_Init       0x08000cf1   Thumb Code   376  stm32l0xx_hal_dma.o(.text)

HAL_DMA_DeInit  0x08000e69   Thumb Code   672  stm32l0xx_hal_dma.o(.text)

HAL_DMA_Start     0x08001129   Thumb Code    78  stm32l0xx_hal_dma.o(.text)

HAL_DMA_Start_IT 0x08001177   Thumb Code   114  stm32l0xx_hal_dma.o(.text)

HAL_DMA_Abort   0x080011e9   Thumb Code   100  stm32l0xx_hal_dma.o(.text)

HAL_DMA_PollForTransfer 0x0800124d Thumb Code744 stm32l0xx_hal_dma.o(.text)

HAL_DMA_IRQHandler 0x08001535   Thumb Code   796  stm32l0xx_hal_dma.o(.text)

HAL_DMA_GetState  0x08001851   Thumb Code     8  stm32l0xx_hal_dma.o(.text)

HAL_DMA_GetError  0x08001859   Thumb Code     6  stm32l0xx_hal_dma.o(.text)

HAL_UART_Receive_DMA 0x0800341f Thumb Code 160 stm32l0xx_hal_uart.o(.text)

HAL_UART_DMAPause 0x080034bf   Thumb Code   114  stm32l0xx_hal_uart.o(.text)

HAL_UART_DMAResume 0x08003531 Thumb Code 126  stm32l0xx_hal_uart.o(.text)

HAL_UART_DMAStop    0x080035af   Thumb Code    62  stm32l0xx_hal_uart.o(.text)

and so on...

Image component sizes

      Code (inc. data)   RO Data    RW Data    ZI Data      Debug   Object Name

        40           0          0          0          0       5151   app.o

       176          4          0          0          0       1077   clock.o

       150         0          0          0          0       2019   gpqueue.o

       928                 60        440       0          0       6808   hal_gpio.o

        60                 28        192       0       1536      724   startup_stm32l052xx.o

       640                          40         0          4          0       5696   stm32l0xx_hal.o

       376                          26         0          0          0      10473  stm32l0xx_hal_cortex.o

      2932                 22         0          0          0       5012   stm32l0xx_hal_dma.o

       788                          28         0          0          0       3843   stm32l0xx_hal_gpio.o

       228                          10         0          0          0      27360  stm32l0xx_hal_msp.o

      3072                         76         28       25         0       5936   stm32l0xx_hal_rcc.o

      4766              102         0          0          0      12765  stm32l0xx_hal_uart.o

       652                           4          0          0          0       3458   stm32l0xx_hal_uart_ex.o

        36                            4          0          0          0     169573 stm32l0xx_it.o

       352                         34          0         29         0       1731   system_stm32l0xx.o

       560                         22         44         12       208    6075   uart.o

I have to put stm32l0xx_hal_dma.c to avoid compiling error using the others libraries that use DMA functions,

How can I avoid this piece of code?? Compiling switches modifying ST libraries?? Or with some compiler/project settings that dont waste size if I dont use unnused functions??
2 REPLIES 2
Posted on November 21, 2014 at 19:03

Maybe there is an option in project properties that avoids/removes unused functions from the image created. ... Or with some compiler/project settings that dont waste size if I dont use unused functions??

Should have natural dead code elimination at an object level. Make sure ''One ELF Section per Function'' is checked under C/C++ options tab.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
gerardo
Associate II
Posted on November 22, 2014 at 13:46

Great Clive1 😉