cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_RCC_OscConfig function takes too much space

Erkan Ersoy
Associate II
Posted on November 15, 2017 at 11:09

Hello 

After I face some fitting to flash problem I saw my largest function is HAL_RCC_OscConfig.

I thouht a function that writes static variables to registers should be smaller. Am I doing something wrong or is there a setting for it?

I am using GCC 6_2017q2 with System workbench

#program-size #hal #flash #cube-hal
11 REPLIES 11
elliotwoods
Associate II

waclawek.jan mentioned thed that the compiler can't optimise away the contents of HAL_RCC_OscConfig because it's in a separate file than where it is called, so the compiler is unaware of what it can optimise away because it only considers one file at a time.

Therefore I tried copying the function into a separate c file and having another function in that file call it with known arguments. That increased the total size of flash by 8 bytes, so it doesn't seem to have resulted in any optimisation.

Then I went back to original, and then tried hardcoding the struct at the top of the function call itself in stm32g0xx_hal_rcc.c. This increases the program size by 280 (quite strange). No simple luck yet

 

RShah.2
Associate II

I recently faced the same issue of HAL_RCC_OscConfig() taking too much space in flash. I solved the issue with a very simple trick. 

Just change HAL to LL for RCC driver selection in CubeMX code generator in Advanced setting.

Magically, It reduced Code size by almost 40%. 

 

Screenshot 2024-05-03 105326.png

 

Hope this helps!