CRC32 questions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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
- does it make any difference if I check CRC32 for every 512 bytes read or after read of 2048 bytes?
Thanks,
****
- Labels:
-
CRC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-01-10 2:16 PM
You can implement it like this:
CRC_Begin();
while (NewData) {
CRC_Process();
}
CRC_End();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-01-10 2: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.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-01-10 2: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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-01-10 3: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-01-10 4:25 PM
OK. Thanks a lot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-01-10 6:22 PM
It is possible, but less probable.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-02-11 3: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
