GENERAL: GENERATING HEX FILES WITH EVEN NUMBER OF BYTES
Information in this article applies to:
Is there any way to prevent the number of bytes for a data record from being an odd number in the generated Hex file? Our Flash memory is configured to use word mode which prevents us from writing one byte to it.
Yes, there is a project called SRecord hosted on sourceforge.net which contains utilities to manipulate 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 with Intel HEX files which were created by Keil OH51, OHX51, OH251 or OH166 Object-Hex converter. It has an option to fill up bytes with odd addresses. This tool always stores Intel HEX records in ascending address order.
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. µVision key sequences like '#H' can be used to specify the input hex file name. When using a command file for srec_cat.exe, be sure to double the '@' character, or µVision might interpret it as a key-sequence.
Useful options for srec_cat:
If you need an Intel HEX file with:
You can use the following command file:
# BL51 hex files are not sorted for ascending addresses. Suppress this warning -disable-sequence-warning # load input HEX file HexFile.hex -Intel # fill all incomplete 16-bit words with 0xFF. The range is limited to the application -fill 0xFF -within HexFile.hex -Intel -range-padding 2 # generate hex records with 16 byte data length (default 32 byte) -Output_Block_Size=16 #generate 16-bit address records. Do no use for address ranges > 64K -address-length=2 # generate a Intel hex file -o HexFilePadded.hex -Intel
You can then invoke srec_cat.exe with this command file:
Last Reviewed: Tuesday, July 17, 2018
of your data.