cancel
Showing results for 
Search instead for 
Did you mean: 

Difference between bin, hex and elf file and their sizes

AKuma.2074
Associate III

Dear members,

After fiddling a bit with stm32cube ide, I found that after project compilation, I have 3 files generated i.e. elf, hex and bin, in my debug folder.

But the size of all three varies.

Elf is 925kb

Bin is 13kb

Hex is 36 kb

I know elf have lots of extra data + debug info

Bin is raw file without address

Hex is raw file with address

Now my question is, when i look into memory regions of build analyzer, and console output values of text, data and bss sizes, what does it represent?

It it the breakdown of bin or hex or elf file?

By default settings which file is sent to uc, through ide?

Elf, bin or hex?

Thanks and regards

Avinash

5 REPLIES 5

The .BIN file is the most representative of the data written into the MCUs memory.

From this flash image it unpack the data content into RAM, and zeros the BSS​ beyond that.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
  1. BIN is a byte-by-byte binary image of what goes into the target memory
  2. HEX is a text representation of the image; it has addresses and checksums - so it can be "sparse"
  3. 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.

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

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

This is all general stuff - nothing specific to ST or STM32 or CubeIDE

Ok. This part is clear to me, but what is the answer to 2nd part of the question?

Ok. This part is clear to me, but what is the answer to 2nd part of the question?

"text, data and bss sizes, what does it represent?"

That's really an entirely different question!

Again, this is standard stuff; not specific to STM32 - or even embedded:

https://www.google.com/search?q=what+are+text+data+and+bss

It's all contained in the ELF, but is irrelevant to Hex or Bin.