2024-02-20 11:02 PM
Hey STM32 Community, I'm currently working on a project involving the STM32L072CZ microcontroller and could use some guidance on CRC calculation procedures. Here's a rundown of what I'm trying to accomplish: I'm downloading a FOTA .bin file in 1024-byte chunks, totaling 60kb. These chunks are stored in a data buffer, and my task is to calculate the CRC of the entire file for verification purposes. Here's the approach I've taken so far:
I'm seeking confirmation on whether this procedure is correct. Additionally, I need to determine the correct CRC (expected CRC) of the .bin file to ensure file integrity. I've kept default settings for both polynomial and initial values, and the CRC used is CRC 32. I've tried using J-Flash to generate the CRC of the .bin file, but the results don't match those obtained using the HAL function in STM32 Cube IDE. I'm not sure if J-Flash uses the same polynomial as the default polynomial set in STM32 Cube IDE. Any insights or recommendations you can provide would be greatly appreciated. If there are alternative applications or methodologies available for generating the CRC of the file, I'm all ears. Looking forward to your responses!
2024-02-21 05:12 AM
> I'm seeking confirmation on whether this procedure is correct.
Confirmed, procedure is correct.
> Any insights or recommendations you can provide would be greatly appreciated.
First perform a CRC on a few bytes, say 4 bytes, and ensure the value matches your expectations based on online CRC calculators. Note that 32-bit values are stored in little endian format, so bytes may need swapped depending on what calculation you're expecting. If you don't care about how it calculates, only that it gets a CRC, this is less important.
> I'm not sure if J-Flash uses the same polynomial as the default polynomial set in STM32 Cube IDE.
Also not sure. Surely J-Flash documentation has this written down.