Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

Checksum generation for ModusToolbox™ hex file - KBA236086

lock attach
Attachments are accessible only for community members.

Checksum generation for ModusToolbox™ hex file - KBA236086

Community Manager
Community Manager
Community Manager
1000 replies posted First like given 750 replies posted

Community Translation: ModusToolbox™ hex ファイルのチェックサム生成 - KBA236086

Version: **

It is often a requirement for a custom programmer tool to detect any tamperings with the hex file that is to be flashed into a PSoC™ device. In such situations, it is helpful if the programmer software can calculate the checksum of the hex file and compare this value with the checksum at address location 0x90300000 and if both match, then it indicates that the hex file is tamper-free.

The checksum for the hex file generated in ModusToolbox™ can be generated and loaded in address location 0x90300000 by using the python script.

To use the python script, do the following:

  1. Extract and copy the ‘hexCheckSumScript.py’ file to the folder containing the hex file, such as ‘mtb-example.hex’, whose checksum is to be calculated.
  2. Open a command prompt (Win Key + R and open ‘cmd’)
  3. Navigate to the folder containing ‘hexCheckSumScript.py’ and the ‘mtb-example.hex’ using the command “cd <path to folder >”
  4. Run the following command to get the checksum of the hex file:
  •        python   hexCheckSumScript.py   <Name of hex file>

After the script runs, it generates a new hex file with the prefix “csout_” in the same folder in which the python script and the input hex file are located.

Example operation:


Figure 1  Script execution & output hex file generation                    

Verify if the checksum has been added to the hex file by checking the last three lines of the generated hex file as shown in Figure 2.

Figure 2   Location of checksum in generated hex

The custom programmer software verifies if the hex file has been corrupted/modified by calculating the checksum of the hex file and comparing the same with the hex file value mentioned in the second last line ( 0xD07C as shown in Figure2).

Note:  Python version tested on v3.10.4