Closed jmalmari closed 1 week ago
Hi @jmalmari, thanks for creating a PR.
This is probably equivalent to inverting the crc before and after calculation:
uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size) {
return ~my_crc(~crc, buffer, size);
}
If you're looking to use a different polynomial/checksum, that's a bit of a different question that would create compatibility issues for other littlefs tooling. Required a source-level change is probably warranted in this case for now.
Right, I did not spot that connection. User side change is probably better. Takes only a few extra cycles.
To be fair, the inverted form is more common, since it can also detect prefixed zero bytes.
Long term, it would be nice to move to the inverted form (or even a better polynomial, such as crc32c), but since this would require disk-breaking changes, it's sort of out of the question.
LFS format failed because CRC=0 is, in the general case, a wrong value to test against. For example, valid zlib CRC-32 match value would be 0x2144df1c.