Skip to main content
cjaya.2
Associate III
August 27, 2024
Solved

difference between .elf and .bin file to program STM32

  • August 27, 2024
  • 4 replies
  • 2197 views

Hi, what is the difference between .elf file and .bin file to program STM32. If I load up the .bin file and program STM32, will it contain all the necessary such as program data and flash data. Is there a application to program individually the .bin file separately apart from STM32CUBE IDE.

Best answer by mƎALLEm

Hello,


@cjaya.2 wrote:

If I load up the .bin file and program STM32, will it contain all the necessary such as program data and flash data.


It contains the program. Data such as letteral pool and const declared variables will be in the bin file.


Is there a application to program individually the .bin file separately apart from STM32CUBE IDE.

You can do it with STM32CubeProgrammer but you need to put the first address of the flash as .bin file does not contain the addresses like HEX file.

SofLit_0-1724792617235.png

 

4 replies

STTwo-32
Technical Moderator
August 27, 2024

Hello @cjaya.2 

  • BIN is a byte-by-byte binary image of what goes into the target memory
  • HEX is a text representation of the image; it has addresses and checksums - so it can be "sparse"
  • ELF is the full build output - it contains symbol information, debug information, etc, in addition to the code itself.

BIN and HEX are generated from the ELF.

More details available here.

If you are looking to program the .bin file on your MCU, you have to generate it using CubeIDE and programme it using CubeProgrammer.

Best Regards.

STTwo-32 

mƎALLEm
mƎALLEmBest answer
Technical Moderator
August 27, 2024

Hello,


@cjaya.2 wrote:

If I load up the .bin file and program STM32, will it contain all the necessary such as program data and flash data.


It contains the program. Data such as letteral pool and const declared variables will be in the bin file.


Is there a application to program individually the .bin file separately apart from STM32CUBE IDE.

You can do it with STM32CubeProgrammer but you need to put the first address of the flash as .bin file does not contain the addresses like HEX file.

SofLit_0-1724792617235.png

 

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."
cjaya.2
cjaya.2Author
Associate III
August 27, 2024

Hi,

I found this application to program the .bin file. https://www.st.com/en/development-tools/stsw-link004.html.

Is this application ok?

mƎALLEm
Technical Moderator
August 27, 2024

No this is an old and depricated tool called STLINK-Utility.

This is the link to STM32CubeProgrammer: https://www.st.com/en/development-tools/stm32cubeprog.html

And please "accept as solution" the comment that you feel it answered your question.

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."
Tesla DeLorean
Guru
August 27, 2024

In the business we call the .ELF an "Object File"

https://en.wikipedia.org/wiki/Object_file

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Andrew Neil
Super User
August 28, 2024

@cjaya.2 wrote:

Hi, what is the difference between .elf file and .bin file to program STM32.


The others have explained the differences.

Note that this is entirely general - not specific to STM32.

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.