Hi, so I have this device that used STM32F030. I did use its CRC module before, but it was being verified against crc also generated by the MCU itself (user setting integrity checks and such).
This time i wanted to use this to verify firmware image uploaded via a custom bootloader. Obviously the CRC is being calculated on PC. Since The datasheet claims to use standard Ethernet CRC, I thought i was golden. Boy was I wrong.
I've downloaded some CRC32 code for c# and generated a CRC from few random bytes from this and from the MCU. No match.
I've checked several other implementations for the PC program as well as online calculators and they all aggreed, result from MCU is different.
4 hour of
later, I couldn't find any set of settings for the MCU CRC engine that would generate remotely similar result.
I then started brute-forcing all the combinations of all possible CRC engine settings. To no avail. And then I tried the same thing, but also reversing all the bits in the output ( xor 0xffffffff). One combination worked.
How to make it work?
-set input inversion to 8/16/32 bits, which one it doesn;t matter as long as you're doing byte-wise CRC. No idea about 16- or 32 bits at a time, only that they produce different output.
-set output inversion to enabled
-flip all the bits in the resulting CRC, the output will match the commonly available algorithms
<rant>
What the f** were they thinking. If they needed to implement the algorithm in some f**ed up way, they could've just published an appnote saying "do this, in order to convert out weird crc into something standard".
</rant>