cancel
Showing results for 
Search instead for 
Did you mean: 

How to import a hex file and read it at run time.

DSand.5
Associate III

I have a touchgfx project, and I need to send bytes from a hex file over uart to a different micro. Everything in this works, but I am using dummy data that I hardcoded into the program. I want to be able to add a .hex file to my project, have my program open it, read it, and then put it into a byte array for me to eventually send over.

I was going to use the process outlined in this link: HEX File to Array in C : 10 Steps - Instructables, however, I am not certain on the correct way to add the hex to the project and then properly read it especially in the STM32CubIDE environment.

2 REPLIES 2
MM..1
Chief II

Why hex why not bin ? What you mean as runtime? Runtime and STM32CubeIDE is complete different ...

RetroInTheShade
Associate III

Hi @DSand.5​ ,

If by “add a .hex file to my project�? you mean add prior to compiling, then you could look at adding a post build step in STM32CubIDE and use srec_cat to insert the contents of the .hex at a known location.

The result would be equivalent to your current hardcoded version.