Skip to main content
Associate II
September 23, 2024
Solved

How generate hex file without link files Hal_drivers

  • September 23, 2024
  • 21 replies
  • 4434 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.

21 replies

Andrew Neil
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

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
FredoliveAuthor
Associate II
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...

 

 

Andrew Neil
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...

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Pavel A.
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
Associate II
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.

Andrew Neil
Super User
September 23, 2024

What do you mean by, "Debug level" ?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Andrew Neil
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.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
FredoliveAuthor
Associate II
September 23, 2024

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

Andrew Neil
Andrew NeilBest answer
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.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.