GENERAL: SORTING INTEL HEX FILES
Information in this article applies to:
Is there a utility to sort Intel HEX files so that the records are written in ascending address order?
Yes, there is a project called SRecord hosted on sourceforge.net which contains utilities to convert Intel HEX files in many ways. The free of charge Windows version 1.64 or later can be downloaded here: https://sourceforge.net/projects/srecord/files/srecord-win32
The command line utility srec_cat.exe is part of this package. It can be used to read an Intel HEX file which was created by Keil OH51, OHX51, OH251 or OH166. srec_cat.exe always stores Intel HEX records in ascending order. So you just need to load an Intel HEX file into srec_cat.exe and store it to a new Intel HEX file.
You can execute this tool after each project build/rebuild by specifying its invocation in the µVision dialog Options for Target - User - After Build/Rebuild. The key sequence '#H' can be used for the input hex file name.
srec_cat.exe UnsortedHexFile.hex -Intel -o SortedHexFile.hex -Intel
Useful options for srec_cat:
Example: If you need an Intel HEX file with address records sorted in ascending order where all gaps are filled with value 0xFF and with an exact size of 32K, you can use the following command file:
-Disable_Sequence_Warnings #disable warning about hex records not in ascending order MyInputFile.hex #input file name -Intel #read input file in intel hex format -fill 0xFF 0x0000 0x8000 #fill gaps from 0x0000-0x7FFF (32K) with value 0xFF -Output_Block_Size=16 #generate hex records with 16 byte data length (default 32 byte) -address-length=2 #generate 16-bit address records (no extended adress records type 04) -o MyOutputFile.hex #output file name -Intel #generate intel hex output file
You can then invoke srec_cat.exe with this command file:
The following Discussion Forum threads may provide information related to this topic.
Last Reviewed: Tuesday, July 17, 2018
of your data.