2018-02-02 10:45 PM
I want to calculate CRC for large file, the large file have been added the CRC value in the end of the whole .bin file(Get this CRC data via IAR tool). I read the file and calculate CRC of it in part(HAL_CRC_Calculate(&CrcHandle, (uint32_t *)data, len). So I will get lots of crc data because I read it in part.
1. How can I deal with these crc data then the final crc vlue will be equal to the one calculated in the IAR?
2. Will it be any prolem if the last file part is not divided to 4 bytes(
Considered the Byte alignment
), then cause the final CRC data is not equal to the one calculated in the IAR? How to deal with this problem?Solved! Go to Solution.
2018-02-03 01:31 AM
When doing CRC in parts, use HAL_CRC_Calculate(&CrcHandle, (uint32_t *)data, len) for the first part and then HAL_CRC_Accumulate (CRC_HandleTypeDef * hcrc, uint32_t pBuffer, uint32_t BufferLength) for subsequent parts. The CRC returned by the respective .._Accumulate calls will reflect the accumulated CRC.
2018-02-03 01:31 AM
When doing CRC in parts, use HAL_CRC_Calculate(&CrcHandle, (uint32_t *)data, len) for the first part and then HAL_CRC_Accumulate (CRC_HandleTypeDef * hcrc, uint32_t pBuffer, uint32_t BufferLength) for subsequent parts. The CRC returned by the respective .._Accumulate calls will reflect the accumulated CRC.
2018-02-03 05:29 AM
Do the computation in sections as needed.
The default 32-bit CRC in the STM32 parts really needs to work on aligned words. Where you lack natural alignment you should zero stuff.
There have been other threads were the application of the CRC in a 'PKZIP' type manner can be achieved, but it requires manipulation, and special handling of the odd bytes at the end. It would really require a better understanding of the math and data representation to get into a deep discussion about this.
2018-02-03 09:05 AM
https://community.st.com/0D50X00009XkbNMSAZ
2018-02-05 11:12 PM
I want to use a fix part(8020000-
80200C8
) which can divided by 4 byte to do the crc, so I can avoid the odd bytes. I tried to modify the configurations in IAR. But it has errors when make. How shold I do?2018-02-05 11:23 PM
0x8020000-0x80200C8 are 0xC9 bytes.
0x8020000-0x80200C7 are 0xC8 and hence dividable by 42019-06-20 08:08 AM