Hello!
I think the CRC32 library has a bug if the buffer size containing the data is 64k or bigger.
I wrote a little function in java running on a Linux PC calculating the CRC32 of a dummy data field(containing all 'A'):
The result of this routine is CRC: 2694514304
The same function on a Teensy 4.1:
shows CRC: 0
If I reduce the buffer size by 1 (bufSize = 1024 * 64 - 1) Java and the Teensy both show the same result ("CRC: 2660141191").
If I raise the bufferSize above 64k(e.g. +1) Java is calculating 1052870317 whereas my Teensy calculates 3554254475.
Did I miss something in the documentation? Is the Teensy CRC32 limited to 64k-1 or is it a bug?
Uwe
I think the CRC32 library has a bug if the buffer size containing the data is 64k or bigger.
I wrote a little function in java running on a Linux PC calculating the CRC32 of a dummy data field(containing all 'A'):
Code:
private static void testCrc() {
int bufSize = 1024 * 64;
byte[] buffer = new byte[bufSize];
CRC32 crc = new CRC32();
for (int i = 0; i < bufSize; i++) {
buffer[i] = 65;
}
crc.update(buffer, 0, bufSize);
long crcVal = crc.getValue();
System.out.println("CRC: " + crcVal);
}
The result of this routine is CRC: 2694514304
The same function on a Teensy 4.1:
Code:
FastCRC32 CRC32;
void testCrc(){
int bufSize = 1024 * 64;
uint8_t buffer[bufSize];
for (int i = 0; i < bufSize; i++) {
buffer[i] = 65;
}
uint32_t crc = CRC32.crc32(&buffer[0], bufSize);
Serial.print("CRC: ");
Serial.println(crc);
}
shows CRC: 0
If I reduce the buffer size by 1 (bufSize = 1024 * 64 - 1) Java and the Teensy both show the same result ("CRC: 2660141191").
If I raise the bufferSize above 64k(e.g. +1) Java is calculating 1052870317 whereas my Teensy calculates 3554254475.
Did I miss something in the documentation? Is the Teensy CRC32 limited to 64k-1 or is it a bug?
Uwe