Forum Discussion

Dennis_Nedry's avatar
Dennis_Nedry
Icon for New Contributor rankNew Contributor
26 days ago

Manual checksum verification of CFM0

I am working on some post-build scripting for generating firmware update programming files for the Max 10 series FPGA.  My goal is to generate 2 separate files:

  1. POF file, for use with USB Blaster.
  2. Proprietary file, for use through a different communication channel.

The POF file is easy; the file is basically auto-generated when you compile in Quartus.  When loading the POF into the Quartus programmer software, it shows "Checksum" and "Usercode Checksum".  The usercode checksum can also be found in the RPT file.  So I have used my post-build scripting to make a copy of the POF file, with the usercode checksum appended to the POF filename.  That is all working great and goal #1 is satisfied.

I have been working on the proprietary file.  In this case, I would be storing something that amounts to the raw data that will end up written to the CFM0 section of the FPGA.  To get the raw data, I used quartus_cpf to generate RPD files from the compiled SOF file.  The raw data can then make its way into the FPGA's CFM0 section through undisclosed means other than USB-Blaster.  All of that is OK, but the problem I have is that I wish to use the SAME usercode checksum as the POF file for consistency, and I have not been able to figure out how to correctly calculate that.

One thing that I did where I got close was, I added this argument to the quartus_cpf command when generating the MAP file:  

-o memory_map_file=on

The MAP file generated shows a totally different checksum.  However, when I do a simple 32-bit checksum on the RPD data (just adding all 32-bit words of the file and coming to a 32-bit result), it DOES exactly match the checksum in the MAP file.

In summary:

I want the consistency between one of the POF's checksums shown in Quartus Programmer, vs. what I can calculate from the raw RPD data.  Since both methods of programming the FPGA should produce identical results, I want to be able to have the same checksum in both methods.  How may I correctly use the RPD data to calculate the same checksum shown in Quartus programmer when loading the POF file?

6 Replies

  • Farabi's avatar
    Farabi
    Icon for Regular Contributor rankRegular Contributor

    Hello, 

     

    Every bitstream generated will have different checksum. This is the default mechanism. 

    To have same checksum - only for same bitstream. 

     

    regards,
    Farabi

  • My idea is, since POF and RPD (raw data) contain all the same data and produce identical end results loaded into FPGA's flash memory, then it should be possible to calculate the same checksum.

    In order to do something like this, I need to know how the usercode checksum is calculated in the POF file.  Then I can emulate the same procedure for the raw data for our consistency.

  • Farabi's avatar
    Farabi
    Icon for Regular Contributor rankRegular Contributor

    Hello, 

     

    Do you have further question? 

     

    regards,

    Farabi

  • Yes,

    How is the usercode checksum calculated, as shown in the Quartus Programmer?

  • FvM's avatar
    FvM
    Icon for Super Contributor rankSuper Contributor

    Hi Dennis,

    a .pof file is a container holding multiple configuration bitstreams, e.g. ufm, cfm0 and cfm1, additional describing text. Checksum is calculated over complete file, therefore it's always different from checksum of individual configuration streams and can't be related to it. User code is contained in .pof header but I don't know how the default value is generated. I believe it can be optionally set to a dedicated number in project options. But it's not copied to binary configuration bitstreams as far as I know.

    Regards Frank

  • Thanks Frank.  I noticed there are 2 checksums shown in the programmer, "checksum" and "usercode".  When I converted my SOF file into RPD and MAP files, I was able to open the RPD file in a hex editor and locate the UFM section.  It was all FFs.  I had inserted some customized data into this section with the hex editor, and used the same tool to repack a new POF file, which now contains the customized UFM data and the original CFM and ICB data.

    Comparing the original POF to the repacked POF, I don't directly see my customized data in there.  (It may be encoded differently or compressed or something, and POF file format is not publicly specified, I understand.).  When I load each POF file into the programmer, the "Checksum" is different, consistent with what you are describing.  However, the "Usercode" checksum, is still the same, leading me to believe that it applies specifically for the CFM data and not the POF file as a whole.  So this is the actual reason why I focused on the usercode checksum; it can remain the same despite different POF file when repacked differently.

    So my goal is to understand how the "usercode" checksum works, should that be documented somewhere or if someone knows.