2020-01-10 10:33 AM
Hi,
I have a general question regarding CRC32 for data read from flash. For example I am reading 2048 bytes of data total 512 bytes chunk each time. My question is
Thanks,
****
2020-01-10 12:04 PM
CRC at each 512 byte point would be different, it you let is accumulate over the 4 blocks the value should be the same as 1 block of 2048 bytes
ie
crc = 0xFFFFFFFF
crc = CRC32(crc, &p[0], 512);
crc = CRC32(crc, &p[512], 512);
crc = CRC32(crc, &p[1024], 512); // intermediate values not same as final (typically, depends on patterns)
crc = CRC32(crc, &p[1536], 512);
printf("%08lX\n", crc);
crc = 0xFFFFFFFF
crc = CRC32(crc, &p[0], 2048);
printf("%08lX\n", crc); // final value same
2020-01-10 12:33 PM
Thanks for response.
So the key is accumulate all of the 2048 bytes. What's wrong of not accumulate all?
2020-01-10 02:16 PM
You can implement it like this:
CRC_Begin();
while (NewData) {
CRC_Process();
}
CRC_End();
2020-01-10 02:52 PM
>>What's wrong of not accumulate all?
Not sure I understand the underlying question here.
The CRC will be done over the data you tell it too. It is like the remainder to a long-division, the remainder at any instance will depend on the data feed thru it to that point.
2020-01-10 02:59 PM
My question is if each 512 block CRC32 are correct, is it possible the 2048 data as whole still has error didn't find by the process as supposed to check whole 2048 bytes?
2020-01-10 03:49 PM
> My question is if each 512 block CRC32 are correct, is it possible the 2048 data as whole still has error didn't find by the process as supposed to check whole 2048 bytes?
OK, you mean separate CRC for each block? Generally smaller blocks are "better protected" compared to larger blocks, because larger blocks have a larger probability of getting a false positive - a CRC match for a corrupted data. Also remember that CRC or any other checksum can't guarantee 100% correctness. In fact absolutely nothing can guarantee it at all...
Strongly recommended:
https://www.slideshare.net/PhilipKoopman/crc-and-checksum-presentation-for-faa
2020-01-10 04:25 PM
OK. Thanks a lot.
2020-01-10 06:22 PM
It is possible, but less probable.
2020-02-11 03:08 PM
As long as you don"t reset the result of the previous chunk, the end result will be the same. You can test to see that it doesn't make any difference.
Regards,
Michel