cancel
Showing results for 
Search instead for 
Did you mean: 

I have a single hex file for F & G series microcontroller. What is the best way to detect the MCU and load the appropriate hex file section from the single hex file

Sara.T
Associate II

I will be able to detect if its an F series or G using DEV_ID register

7 REPLIES 7
TDK
Guru

Have two HEX files, read the DEV_ID to determine the chip, and load the correct one based on the result.

Any loader can load a HEX file, such as STM32CubeProgrammer.

If you feel a post has answered your question, please click "Accept as Solution".
Sara.T
Associate II

What are the cons of having a single hex file ?

It’s not compatible with the limitations of the format. Different chips require different code.
If you feel a post has answered your question, please click "Accept as Solution".

I am using #define to differentiate between the chips.

How exactly are you sending this "singular" .HEX file to the Target(s)?

Do you own the software delivering the file? ie Host side application

How is the Target storing/staging this?

How are you constructing the .HEX file? ie merging two divergent builds?

Why a .HEX file and not a binary image, or an object containing/identifying the two sections/builds?

If the Target STM32 has a loader that's injesting the .HEX it could perhaps differentiate based of the faux-address range each lives in, and then write the appropriate one into the application space whilst ignoring data from the other range.

https://community.st.com/s/question/0D53W00001BvkNnSAJ/i-have-a-single-hex-file-for-stm32f-and-stm32g-series-can-you-suggest-a-way-to-identify-if-the-microcontroller-is-a-f-or-g-series-to-load-the-appropriate-code

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I think you need to reevaluate the feasibility of what you're trying to achieve. How are you planning to make this singular HEX file with code from both chips?

If you feel a post has answered your question, please click "Accept as Solution".
MM..1
Chief II

When Sara ask how to use command line utility to achieve this then run an request parse output and then run next command ,

but when i rememmber stlink utility can validate ID then simply in one cmd script place flash G after this flash F and check results...