Skip to main content
Markobar
Associate
October 14, 2020
Solved

Differences between using hex and bin files to program an STM32

  • October 14, 2020
  • 3 replies
  • 5367 views

Hello!

I have generated with STM32CubeIDE the BIN file and the HEX file from the same application.

Then I used STM32CubeProgrammer to program the MCU, first using the BIN file, and then the HEX file. After each time the MCU is programmed, I have read the flash memory.

I was expecting these two memory dumps to be exactly the same. However, there are 8 bytes that in one of them are zeros (00), and in the other one are ones (FF). It is only 8 bytes out of 131071, but I would like to know why this happens.

Thanks!

This topic has been closed for replies.
Best answer by Tesla DeLorean

HEX files can be sparse, unwritten areas of flash will retain their 0xFF erased state. The BIN decribes all bytes, with 0x00 being chosen as the fill byte in this case.​

3 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
October 14, 2020

HEX files can be sparse, unwritten areas of flash will retain their 0xFF erased state. The BIN decribes all bytes, with 0x00 being chosen as the fill byte in this case.​

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Guillaume K
ST Employee
October 14, 2020

Also with .bin file you have to tell the start address to the programming tool (e.g. 0x8000000 in most cases). With .hex files the addresses are indicated inside.

Markobar
MarkobarAuthor
Associate
October 14, 2020

That's great, thanks a lot for the info! That explains it.