Combine blocks of a Motorola S Record file into a single continuous address space and insert CRC

The Motorola S Record file generated by the build chain has divided the file into 2 separate blocks with different address spaces. ECU flashing utility needs this file to have a single continuous block with the CRC of the file inserted at the end.

How to combine these blocks and generate a S Record file with a continuous address space ?

The tool that we will be using is HexView. This is available in the standard Vector installation package. Its an amazing tool. Check out its documentation on Vector website.

1. First step is to convert the given S record file into a binary file and completely strip off the address information from the file.

path/to/hexview.exe path/to/source_file/sourceFile.srec /s /XN -o path/to/destination_file/intermediateFile.bin

2. Next step is to convert this binary file back to a S Record file, this file will now have a default continuous linear address and will not be divided into blocks.

path/to/hexview.exe path/to/source_file/intermediateFile.bin /s /XS:32 -o path/to/destination_file/cleanSrecFile.srec

3. Next step is to remap this S Record file to the desired address space

path/to/hexview.exe path/to/source_file/cleanSrecFile.srec /s /remap:BankStartAddress-BankEndAddress,LinearBaseAddress,BankSize,BankIncrement /XS:32 -o path/to/destination_file/cleanSrecFile_remaped.srec

for our case we use these values

path/to/hexview.exe path/to/source_file/cleanSrecFile.srec /s /remap:0x0–0x3bffff,0x80040000,0x3C0000,0x10000 /XS:32 -o path/to/destination_file/cleanSrecFile_remaped.srec

4. Inserting CRC at the end of the file.

path/to/hexview.exe path/to/source_file/cleanSrecFile_remaped.srec /s /CS9:@0x803FFFFC;0x80040000–0x803FFFFB /XS:32 -o path/to/destination_file/cleanSrecFile_remaped_CRC.srec

All of this can also be done directly using the HexView GUI. You can experiment with the GUI first and then update your build chain once the kinks are ironed out.

  1. To convert the file to binary : File > Export > Export Binary-Data

2. To convert the file to S Record : File > Export > Export as S-Record

3. To Remap the file : Edit > General Remapping

4. CRC calculation: Edit > Create Checksum

Resultant file should look something like this.

Notice the address space has changed but the length of the file is still the same. This process has not inserted any filler data into the file.

--

--

I stare at screens for a living.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store