cancel
Showing results for 
Search instead for 
Did you mean: 

Differences between using hex and bin files to program an STM32

Markobar
Associate II

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!

1 ACCEPTED SOLUTION

Accepted Solutions

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 Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3

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 Venmo
Up vote any posts that you find helpful, it shows what's working..
Guillaume K
ST Employee

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
Associate II

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