2017-11-15 02:09 AM
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-hal2023-08-10 01:17 AM
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
2024-05-02 10:24 PM
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%.
Hope this helps!