Skip to main content
Explorer
September 23, 2024
Solved

How generate hex file without link files Hal_drivers

  • September 23, 2024
  • 3 replies
  • 4300 views

Hello,

When I builed the project, I had seen the Hal drivers files links in the end file *.HEX.

How can I change the project configuration not to put this links in file because it use flash memory unnecessarily ?

Thanks 

    This topic has been closed for replies.
    Best answer by Andrew Neil

    You can get rid of it by not defining USE_FULL_ASSERT .

    Or you could change your assert_param definition to not use __FILE__ and, thus, not require that the filenames be stored.

    3 replies

    Super User
    September 23, 2024

    What optimisation level are you using?

    By default, 'discard unused sections' should be enabled - so unused functions shouldn't appear in the final image.

    AndrewNeil_0-1727082105941.png

    AndrewNeil_1-1727082142076.png

     

    FredoliveAuthor
    Explorer
    September 23, 2024

    Hi Andrew,

    I have -O1 optimisation and your configuration setting.

    I give an example of my end Hex file :

    0x8005FD0 ........../Drivers/STM32G4xx_Hal_Driver/Src/stm32g4xx_hal_wwdg.c .....

    This link in hex file isn't necessarily...

     

     

    Super User
    September 23, 2024

    @Fredolive wrote:

    I give an example of my end Hex file :

    0x8005FD0 ........../Drivers/STM32G4xx_Hal_Driver/Src/stm32g4xx_hal_wwdg.c .....


    You mean your ELF file? The Hex file wouldn't have any symbol information...

    Super User
    September 23, 2024

    If you don't define USE_FULL_ASSERT these filenames are just for debug information. They do not occupy room in the flash.

     

    FredoliveAuthor
    Explorer
    September 23, 2024

    If Debug level is different of "None" then these roots filenames are in rom flash.

    The only solution is the "None" choice to have any root filename.

    Super User
    September 23, 2024

    What do you mean by, "Debug level" ?

    Super User
    September 23, 2024

    @Fredolive wrote:

    How can I change the project configuration not to put this links in file because it use flash memory unnecessarily ? 


    Note that it's just putting the file names in as string literals - it's not linking any code.

    FredoliveAuthor
    Explorer
    September 23, 2024

    Yes, it is rigth. But it used rom flash to anything. 

    Super User
    September 23, 2024

    You can get rid of it by not defining USE_FULL_ASSERT .

    Or you could change your assert_param definition to not use __FILE__ and, thus, not require that the filenames be stored.