CRC Calculation on STM32L072CZ
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:
- For each incoming chunk of data, I'm accumulating its CRC using the function: chunkDataCrcValue = HAL_CRC_Accumulate(&hcrc, (uint32_t*)dataBuffer, BUFFER_SIZE);
- Once all data chunks are downloaded and their CRCs accumulated, I calculate the final CRC using: uint32_t finalCrcValue = hcrc.Instance->DR;
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!
