2022-05-09 01:28 AM
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.
Solved! Go to Solution.
2022-05-09 05:52 AM
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 ;
2022-05-09 04:39 AM
There are more parameters to CRC than what you can click in CubeMX:
CRC 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
2022-05-09 05:44 AM
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
2022-05-09 05:52 AM