Skip to main content
DSand.5
Associate II
June 28, 2022
Question

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

  • June 28, 2022
  • 2 replies
  • 1205 views

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.

This topic has been closed for replies.

2 replies

MM..1
Super User
June 29, 2022

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

RetroInTheShade
Associate
June 30, 2022

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.