DCP CRC32 not matching CRC in python/ubuntu

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DCP CRC32 not matching CRC in python/ubuntu

625 Views
bp1979
Senior Contributor I

Dear NXP,

We are trying to calculate the CRC of some files we store in flash. We are using the DCP driver. The SHA256 is matching perfectly, but the CRC is not.

With the input string "abcdef" python calculates the CRC "05b367b3", while NXP SDK example calculates "735c1ca1".

After some digging in the SDK example/driver, I found this comment:

    /* Expected CRC-32 for the message.
     * CRC-32 params:
     * width=32 poly=0x04c11db7 init=0xffffffff refin=false refout=false xorout=0x00000000
     * http://reveng.sourceforge.net/crc-catalogue/
     */

 

Are the parameters different than the "standard" CRC32 which is done in both ubuntu native and python running in ubuntu? Is it possible to change the parameters in registers so that the CRC32 hash matches with ubuntu / python / any CRC methd I am using so far?

 

0 Kudos
Reply
10 Replies

564 Views
MultipleMonomials
Contributor IV

Hi, we have observed that the CRC implemented in the DCP matches CRC32/MPEG-2, which is documented e.g. here (ctrl-F for MPEG-2).  We've had success using the mkCrcFun() function from the crcmod python module to generate a CRC calculator using these parameters whose output matches the CRC performed by the DCP peripheral.  It can take a bit of messing around, but it definitely does match an existing CRC-32 implementation.

0 Kudos
Reply

591 Views
mayliu1
NXP Employee
NXP Employee

Hi @bp1979 ,

 

Thank you for your interest in the NXP MIMXRT product, I would  like to provide service for you.

Question: Are the parameters different than the "standard" CRC32 which is done in both ubuntu native and python running in ubuntu?

Answer:  Polynomial 0x04C11DB7 is adopted by the IEEE 802.3 standard.              

Question: Is it possible to change the parameters in registers so that the CRC32 hash matches with ubuntu / python / any CRC methd I am using so far?

Answer: I have consulted an expert about this question.  I will sync the latest update to you. Please keep patience.

Wish you a nice day!

 

Best Regards

mayliu

 

0 Kudos
Reply

582 Views
mayliu1
NXP Employee
NXP Employee

Hi @bp1979 ,

 

Hi,  I have consulted an expert in this field , and the reply is  CRC in DCP is implemented to that fixed parameters, its not possible to change it.

 

Wish you a nice day!

 

Best Regards

mayliu

0 Kudos
Reply

574 Views
bp1979
Senior Contributor I

@mayliu1 

Thanks for getting back to this. Could you do me a huge favor, and confirm

that python gives a different CRC checksum than the DCP unit on an imx rt1024?

If you use the SDK example with a defined input (e.g. "abcdef"), and calculate the CRC on the IMX, and you would do the same on python, do you also get different results?

I just want to be 100% sure that I am not making any stupid mistake.

0 Kudos
Reply

550 Views
mayliu1
NXP Employee
NXP Employee

Hi @bp1979 ,

Thank you for your updated information.

Dear bp1979, I can support you any question  about NXP chip MIMXRT1024 and SDK library.

But I am sorry that question about CRC32 of python is out of my scope.

I suggest you to check the difference of CRC32  parameters between NXP DCP and Python.

 

Wish you a nice day!

 

Best Regards

mayliu

0 Kudos
Reply

536 Views
bp1979
Senior Contributor I

Hi @mayliu1 

I've came a little bit further. DCP / CRC32 indeed calculates a CRC of "CRC-32/MPEG-2" (thanks for the input there @MultipleMonomials !), but... it ONLY does that, when I supply an input which has a length % 4 == 0.

So for the input string "aaaa" it calculates 0x77EDCC59 which matches perfectly with the algo online

We can repeat this with any string, as long as the length is a factor of 4.

Can you help explaining why a random length fails? Is this a bug in the DCP driver? Or does this go wrong in hardware?

0 Kudos
Reply

480 Views
mayliu1
NXP Employee
NXP Employee

Dear @bp1979 ,

 

Dear bp1979, Thanks for your replay.

I do a validation for input different length of CRC32. 

I use  a CRC32 checksum URL for comparison.

mayliu1_0-1731926734200.png

1:  If I input string length is multiple of 4, the result is same.

2: If I input “abcde”,length is 5,NXP DCP CRC32 calculate  the result is different from Web .

I will submit a request ticket  for support from the relevant module owner.

Please keep patience, Thanks very much.

 

Best Regards

mayliu

0 Kudos
Reply

427 Views
mayliu1
NXP Employee
NXP Employee

Hi @bp1979 ,

 

Thanks for your patience.

In the Security Reference Manual for the i.MX RT102X Processor, It describe as following Fig.

If user data is not 4bytes-aligned, HW will pad it with zeros.

mayliu1_0-1732092243358.png

So it is not a bug,  SRM have describe this.

Wish it helps you.
If you still have question about it, please kindly let me know.

 

Best Regards

mayliu

0 Kudos
Reply

392 Views
bp1979
Senior Contributor I

Hi @mayliu1 

 

Thanks a lot for that comment! It had to be something like that, given the test results.

I would LOVE to get my hands on that document you are referring to. Where can I find it? Googled for it and clicked around a bit on NXP site, but couldn't find it.

0 Kudos
Reply

371 Views
mayliu1
NXP Employee
NXP Employee

Hi @bp1979 ,

Please refer to the following, It shows detail information to help you download SRM.

i.MX RT1020 | Crossover MCU with ARM Cortex-M7 up to 500 MHz | NXP Semiconductors

mayliu1_2-1732238191690.png

 

If your problem is solved, Please tell me to close this case, thanks.

Wish you a nice day!

 

Best Regards

mayliu

0 Kudos
Reply