Keil Logo

GENERAL: CREATING MOTOROLA S-RECORD FILES


Information in this article applies to:

  • MDK-ARM All Versions
  • C166 All Versions
  • C251 All Versions
  • C51 All Versions

QUESTION

My device programmer only supports the Motorola S-Record file format. How can I convert the HEX files created by the object-HEX converters into S-Record files?

ANSWER

For ARM devices, the Fromelf utility included in MDK-ARM will convert an AXF file into a variety of different formats. Use the --m32 or --m32combined command line option to generate a S-Record.

For all other microcontroller devices, we recommend to use the free utility srec_cat.exe, which is part of the SRecord project hosted on sourceforge.net. This utility is available as Windows EXE file from https://sourceforge.net/projects/srecord/files/srecord-win32. You can manipulate one or multiple HEX files in many ways and then convert it to a Motorola S-Record file.

You can invoke srec_cat.exe from a Windows command prompt or Make tool:

srec_cat.exe HexFile.hex -Intel -o MotorolaFile.srec -Motorola

You can also invoke this tool after each project build/rebuild by specifying its invocation in the µVision dialog Options for Target - User - After Build/Rebuild. In this example, the HEX file which is generated by a µVision project build/rebuild is converted to a Motorola S-Record file in the same folder. Please see the description of µVision key sequences for more details. If many parameters are needed, it may be easier to use a command file. When using a command file for srec_cat.exe, be sure to double the '@' character, or µVision might interpret it as a key-sequence.

For a full description of all srec_cat.exe parameters, refer to the SRecord Reference Manual. Here are some options which are useful with Keil tools:

  • -Disable_Sequence_Warnings
    This option suppresses a warning if records of the input Intel HEX file are not sorted in ascending address order. HEX file generated by OH51 or OHX51 are not sorted in ascending address order.
  • -address-length= 2 or 3 or 4
    Specifies the number of address bytes in the Motorola S-Record output file. By default, the smalles possible address length is emitted. '2' means S19 format for up to 64 KB of data, '3' means S28 format for up to 16 MB of data and '4' means S37 format for up to 4 GB of data.
  • -fill FillValue StartAddress EndAddress
    Fills unused areas with the specified constant value. A fill value of 0xFF is often used with this option because it corresponds to erased Flash.
  • -crop StartAddress EndAddress
    Only loads the specified address area from the previous input file. This option can be combined with -offset.
  • -offset Offset
    Adds an address offset to the previous input file. Positive or negative values are allowed. This option can be combined with -crop.
  • -Intel
    Can be used after an input or output filename to specify that an input file should be interpreted as an Intel HEX file or an output file should be generated as an Intel HEX file.
  • -Binary
    Can be used after an input or output filename to specify that an input file should be interpreted as a binary file or an output file should be generated as a binary file.
  • -Motorola
    Can be used after an input or output filename to specify that an input file should be interpreted as a Motorola S-Record file or an output file should be generated as a Motorola S-Record file.
  • @CommandFile
    A command file can contain some or all invocation parameters of srec_cat.exe. You can even use comments starting with '#' extending to the end of the line.


MORE INFORMATION

SEE ALSO

Last Reviewed: Tuesday, July 17, 2018


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.