2025-08-10 8:52 PM - last edited on 2025-08-12 7:59 AM by Andrew Neil
Is there an available routine? The file I need to burn is in HEX format, but I haven't been able to find any relevant sample code on the internet. Most of the materials only provide implementation schemes for burning BIN files.
2025-08-12 8:07 AM
See Application note AN4657, STM32 in-application programming (IAP) using the USART:
@RainNu wrote:The file I need to burn is in HEX format, but I haven't been able to find any relevant sample code on the internet. Most of the materials only provide implementation schemes for burning BIN files.
There's a good reason for that: fully handling all the possible variations & options of the Intel HEX format is very much a non-trivial exercise - forums are littered with incomplete or simplistic implementations which fall over with any deviation from their own very limited interpretation of the format.
Also, Intel Hex format is quite inefficient.
So, often, a BIN is a better choice.
Having said that, Intel Hex is long-established, well-documented and widely-used - you should certainly be able to find something to interpret it.
Or work from scratch:
https://en.wikipedia.org/wiki/Intel_HEX
https://developer.arm.com/documentation/ka003292/latest/
The Intel Hex interpretation is entirely separate from the STM32 IAP stuff ...
2025-08-12 8:31 AM
.HEX has a 40 year history, parsing ASCII as a software engineer should be something doable with a secondary school level grasp of file processing.
People tend to favour .BIN as it's more efficient, especially with 8-bit file storage system and memories, about 2.5x smaller than equivalent binary, rather than 7-bit paper tape or serial interfaces..
STMicro has Ethernet, Serial and USB-MSC examples for IAP