This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2340R5: How to calculate CRC32 for flash programming

Part Number: CC2340R5
Other Parts Discussed in Thread: UNIFLASH

Tool/software:

Hi team,

One programming tool vendor is developing tool for CC2340R5. They study the Uniflash. However, they cannot understand how Uniflash generate the CRC32 value. Please help provide. 

Refer to CC2340 TRM, https://www.ti.com/lit/ug/swcu193a/swcu193a.pdf chap 8. It describes as below. However, the tool vendor follow below rule to calculate. The value they calculated is different from Uniflash. 

   CRC Calculation and Location

  The CRCs use CRC-32, which has the following implementation:

  • The polynomial is x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1
  • The hexadecimal representation of the polynomial is 0x04C11DB7.• The initial value is 0xFFFFFFFF.
  • Hi,

    However, they cannot understand how Uniflash generate the CRC32 value.

    How are they looking at the CRC32 value of Uniflash? Are they using the value reported at the Flash Image box?

    If so, this CRC is calculated for the entire .hex file.

    The CRC32 calculation shown in the CC2340 TRM is only for the CCFG memory area of the .hex file, therefore they will be different.

    Hope this helps,

    Rafael

  • Hi,Rafael:

    I am a programming tool provider,
    Hex file I can calculate the CRC32 checksum value.
    But what we receive from the client is a bin file,
    Calculating the CRC32 checksum will give different values,
    How can I get the same bin file CRC32 checksum value as UniFlash?


    Thanks for all your help

  • Hi Jerry, Alex,

    As noted by Rafael, the CRC32 calculation is calculated on the data in the entire file. So the value will not be the same between the .bin version of the file, and the hex version of the same program file, as the data in the file would be different.

    As for the calculation, it is based on the CRC-32/ISO-HDLC algorithm, which has the same polynomial of 0x04C11DB7 as previously noted.

    You can use the following site to check on the value that UniFlash gets by opening your binary file in a text editor, copying the ASCII/Hex data into the input box, and copying the Result value with what is calculated in UniFlash.

    Please let me know if you have any additional questions on this.
    Thanks,
    Ricky
  • Hi,Ricky


    I tried using CRC-32/ISO-HDLC and other CRC32 algorithms but did not get the same CRC32 Checksum as UniFlash: 0x6E2A5B23.



    Thanks for all your help

  • Alex,

    Thanks for the report. I'll take a look at the implementation in UniFlash and see if there is a bug with the calculation. I will keep you updated.

    Regards,

    Ricky

  • I found a bug in the UniFlash CRC32 calculation code. I have filed a bug to track this, and this will be fixed in the next UniFlash release (v9.2 in June).

    Thanks,

    Ricky

  • Hi,Ricky

    Thanks for your help in verifying the UniFlash CRC32 calculation.

    I appreciate your help.

    Alex