PSoC Programmer is not designed to use a pure hex file. Cypress tools (PSoC Creator) generate a standard hex file plus some additional information to identify the intended target, and to provide a quick checksum. In effect, it makes the standard hex file more robust - it can't end up on the wrong chip and cause failure.
Can you tell me how you generated the Hex File?
Similar to the user above I am trying to write a "raw" hex file. It is a backup for the image on a device which is notorious for corrupting its firmware. I would like the ability to flash back the hex, and can get as far as generating the hex file with device ID, and row checksums. However information is needed on how to compute overall flash checksum which is required at the bottom of the .hex file, as well as any extra bits that might render PSoC programmer useless to write the file. This is essentially to perform device repairs.
For me it is very strange coming from a long history of writing/changing/burning firmwares to have this kind of restriction on a programmer :/ Why not add a consent mechanism for users to allow writing raw HEX that wasn't necessarily generated with PSoC Designer/Creator? (confusing)
Hi Yixin Shen, I finally figured this out today as it was also blocking me.
You need to calculate the 16bit checksum of the Bytes that will be programmed to flash only, ignoring checksum bytes at end of each line, addressing headers, colons, protection area, metadata etc. So for 16kb Flash device you should have for example exactly 16384 Bytes Binary file.
So if you save your firmware as a BIN (binary file), you can calculate the checksum easily with something like HexWorkshop Checksum Generator
It is the "Checksum (16bit)" one, and you use the result under "Checksum/Digest"
In my case that was 3112h
If you need help converting your HEX to BIN file for checksum calculation let me know.
Then you write that in the second to last line in the HEX file that you have similar to: :020000003112bb Notice the last 2 bytes of data contain 3112 and then the bb is the checksum for the line itself. You need to recalculate the 'bb' - last 2 bytes as checksum for the entire line. Sum all the bytes excluding colon and checksum and two's compliment of that.
This is easy, just do using calculator in hex: NOT(02h + 31h + 12h) + 1h which in my case comes out to BBh
See below at line 516:
Or there is an online calculator for the checksum on each line: Checksum Calculator
More info on the Intel format here: http://www.cppblog.com/coloerful/archive/2009/07/17/90390.html
You can use custom programmers to flash your hex in case you are generating the hex using third party tools. PSoC Programmer was designed to use PSoC Creator generated standard hex files to prevent device damage. But the suggestion is truly welcome.
I appreciate the effort you put in to get it working, but it is not recommended. It may cause damage in case the calculations go wrong.
I generated the hex file by Psoc Creator 4.2. This hex file located at ...\Psoc_dev_test.cydsn\CortexM0\ARM_GCC_541\Debug. It should be a standard hex file conclude checksum, right? It's strange to meet this error.
Unfortunately people also own Cypress programmers and would like to flash custom HEX files. Its a very strange restriction to not have override is all I am saying. But thanks for the info. Seems the OP has a bug actually not related to custom hex file after all. I don't mean to hijack the thread
I fixed this error by deleting custom linker script in build setting. Though it's not my purpose, the custom linker script may change hex file format and it caused wrong checksum.