Skip to main content
simoBen47
Associate III
August 3, 2018
Question

How can i read Hex file from STM32

  • August 3, 2018
  • 3 replies
  • 8943 views

hey everyone,

I need to get access to device of STM32 board to read Hex file. any idea please ?

I am using STM32F401RE.

Simo

3 replies

Tesla DeLorean
Guru
August 3, 2018

Use the ST-LINK Utilities, read memory, save as a .HEX file.

Use Keil Debugger, and SAVE command at console.

Use the System Loader, pull data with protocol and save to file.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
simoBen47
simoBen47Author
Associate III
August 3, 2018

Thank you for your reply.

What I need exactly, is to be able to manipulate in real time the firmware after having programmed STM32.

For example read it and check its integrity...

Simo

rclar.6
Associate III
February 12, 2024

Exactly what I am trying to do. I have read in the binary modified it to contain a CRC32

and now want to read my modified hex file in, with the symbols coming from the

'elf' file. But the only file types I seem to be offered are elf and something called 'axf'.

 

I want to be able to use the hex file because that is what production get

Andrew Neil
Super User
February 12, 2024

@rclar.6 wrote:

the only file types I seem to be offered are elf and something called 'axf'.

I want to be able to use the hex file because that is what production get


Tools are available to convert from AXF or ELF to HEX; eg, objcopy

https://ftp.gnu.org/old-gnu/Manuals/binutils-2.12/html_node/binutils_5.html 

https://stackoverflow.com/questions/19458031/how-to-create-a-executable-hex-from-elf-file-format

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
rclar.6
Associate III
February 12, 2024

me too. I know it used to read the hex file for the flash data and the lef file for the symbols. so you could debug the actual hex file that had , say, a CRC32 checksum in it.

 

Tesla DeLorean
Guru
February 12, 2024

If you need to debug, either have an option to debug without the CRC / Signing, or write something to post-process the ELF, expanding the right sections so you can add the CRC / Signing at the end, or refactoring the ELF to consolidate sections, and add the CRC / Signing to the larger monolithic section.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
rclar.6
Associate III
February 13, 2024

OK but we have scripts that post process the binary into hex files, using objcopy. This produces a hex file (useful for production later in the development stages) with a CRC32 in the final FLASH section

With the old STM IDE I used to be able to download the binary image from the hex file and the symbols from the elf. The new GUI does not seem to give the option of reading a hex file.

That way I could debug with a pre calculated CRC32 (and make sure the CRC32 parameters were producing the correct CRC32 variant b[byte-reversed, xor's with 0xFFFFFFFF are two examples of variants]).