cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with CRC32 module on STM32G483

EPHIL.1
Associate II

Hi,

I'm computing CRC32 with 04C11DB7 polynomial with different methods : through python binascii.crc32(...), on the following website " https://simplycalc.com/crc32-text.php ", and with ST embedded module on STM32G483.

On basic strings such as "0123456789", i get the same CRC from the python library and the website but not from ST (python/web : 2 793 719 750; ST : 4 171 674 919).

I enabled ST CRC through CubeMX with a config as in the linked pic, and call it in my code as the following :

 uint8 data[] = "0123456789";

 uint32 crc = HAL_CRC_Calculate(&hcrc, (uint32*)data, 10u);

I tried modifying the output and intput data inversion, changing the string and its size, but I can never get the same result as the python/web one which always get the same. I don't really get what could be happening here.

Any idea where I could be going wrong? Thank you for your time.

1 ACCEPTED SOLUTION

Accepted Solutions
EPHIL.1
Associate II

Thank you for your answer, I managed to get the same result with the CRC from ST by making changes in CubeMX and modifying the code as follow :

 uint32 crc = HAL_CRC_Calculate(&hcrc, (uint32*)data, 10u) * 0xFFFFFFFF -1uL ;

View solution in original post

3 REPLIES 3

There are more parameters to CRC than what you can click in CubeMX:

0693W00000NpcHdQAJ.pngCRC module in STM32 is surprisingly big endian (see how data are fed into CRC->DR in the 8-bit version of the function you are calling - HAL/Cube is open source so you can look at it closely), so you may need to byte-swap the result. Decimal is a less usable number base in programming.

JW

Isn't the parameter a count of 32-bit words, not bytes?

Problem with online calculators are they impart no understanding of the mechanics.​ CRC are sensitive to bit pattern level differences in how data is represented and organized, ie endian and msb/lsb, etc

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
EPHIL.1
Associate II

Thank you for your answer, I managed to get the same result with the CRC from ST by making changes in CubeMX and modifying the code as follow :

 uint32 crc = HAL_CRC_Calculate(&hcrc, (uint32*)data, 10u) * 0xFFFFFFFF -1uL ;