- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I changed some flash data in hex,and I fail to download because of the wrong checksum in the end of hex. How can I calculate the checksum of the whole flash.
Solved! Go to Solution.
- Labels:
-
PSoC 4 MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @mjt_4825471 ,
Can you please let me know why you require modifying the hex file?
Let me start by saying this cannot be done. Even if you do calculate the right checksum, it will still not work with PSoC Programmer.
Here's a long story on why this won't work. You can modify the data in the hex, but you need to take care about two things. Every row in the hex file follows the Intel Hex Format. You can understand more about it in the Appendix section of the Programming Specification.
So, firstly each of the rows has a checksum calculated at the end of the record. You need to modify this as well to align with the changes you made.
Secondly, we calculate the checksum of the entire flash and store it in the location 0x90300000 in the hex. Check the Organization of the Hex File section in the link provided above. So, you will need to modify this as well to align with the changes and also the checksum of the checksum 🙂
But, the metadata section at 0x90500000 contains some proprietary information that is used to guarantee the integrity of the hex file. Hence, you will not be able to program the hex file even though we tried to modify it to make it seem legitimate.
Just for your knowledge, I can tell you how you can calculate the flash checksum. You can write a simple C program to do this. Parsing the hex is slightly complicated, so it is better to convert the hex to a bin file using hex2bin and then run a simple c program to calculate the checksum for the entire flash.
Here are the steps to use the C program to calculate the checksum:
1) Please find attached the bat script. Extract the bat script into the Debug directory of your project where the hex file exists.
2) Right-click on the bat script and edit it to add your project name, flash size of the device. Save it.
3) Run the bat script by double-clicking it. It will generate the bin file for you.
4) Modify the C Program to add the filename of the bin and run the C program
5) It will give you the checksum of the entire flash.
All the necessary files are attached.
Hope this helps 🙂
Regards,
Dheeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @mjt_4825471 ,
Can you please let me know why you require modifying the hex file?
Let me start by saying this cannot be done. Even if you do calculate the right checksum, it will still not work with PSoC Programmer.
Here's a long story on why this won't work. You can modify the data in the hex, but you need to take care about two things. Every row in the hex file follows the Intel Hex Format. You can understand more about it in the Appendix section of the Programming Specification.
So, firstly each of the rows has a checksum calculated at the end of the record. You need to modify this as well to align with the changes you made.
Secondly, we calculate the checksum of the entire flash and store it in the location 0x90300000 in the hex. Check the Organization of the Hex File section in the link provided above. So, you will need to modify this as well to align with the changes and also the checksum of the checksum 🙂
But, the metadata section at 0x90500000 contains some proprietary information that is used to guarantee the integrity of the hex file. Hence, you will not be able to program the hex file even though we tried to modify it to make it seem legitimate.
Just for your knowledge, I can tell you how you can calculate the flash checksum. You can write a simple C program to do this. Parsing the hex is slightly complicated, so it is better to convert the hex to a bin file using hex2bin and then run a simple c program to calculate the checksum for the entire flash.
Here are the steps to use the C program to calculate the checksum:
1) Please find attached the bat script. Extract the bat script into the Debug directory of your project where the hex file exists.
2) Right-click on the bat script and edit it to add your project name, flash size of the device. Save it.
3) Run the bat script by double-clicking it. It will generate the bin file for you.
4) Modify the C Program to add the filename of the bin and run the C program
5) It will give you the checksum of the entire flash.
All the necessary files are attached.
Hope this helps 🙂
Regards,
Dheeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thankyou for your reply. Yes, metedata will fail.I want store the checksum of whole flash by CRC16 in the end of hex.After power on,my code will check the falsh data and compare the result with the checksum which I put in the hex.