7 Replies Latest reply on Oct 12, 2018 2:10 AM by yixin.shen_3595981

    Psoc4200-M, programming error, Hex File Parsing failure

    yixin.shen_3595981

      When I tried download my software into my board, an error appeared as below.

      Error: dbg.M0023: There was an error while programming the device: PSoC Programmer reported error (100 - FAILED! Hex File parsing failure. Checksum of Main Flash does not match Hex Checksum record)

      Is there anyone know how to fix it?

      Thanks a lot.

       

        • 1. Re: Psoc4200-M, programming error, Hex File Parsing failure
          ddka

          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?

           

          Regards,

          Dheeraj

          • 2. Re: Psoc4200-M, programming error, Hex File Parsing failure
            bn880_3777296

            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)

            • 3. Re: Psoc4200-M, programming error, Hex File Parsing failure
              bn880_3777296

              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"

              2018-10-07_17h19_22.png

              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:

              2018-10-07_17h19_55.png

              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

              • 4. Re: Psoc4200-M, programming error, Hex File Parsing failure
                ddka

                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.

                 

                Regards,

                Dheeraj

                • 5. Re: Psoc4200-M, programming error, Hex File Parsing failure
                  yixin.shen_3595981

                  Hi ddka

                  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.

                  Thank you.

                  • 6. Re: Psoc4200-M, programming error, Hex File Parsing failure
                    bn880_3777296

                    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

                    • 7. Re: Psoc4200-M, programming error, Hex File Parsing failure
                      yixin.shen_3595981

                      Hi

                      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.