@@ -46,14 +46,21 @@ Often overlooked, the humble [CRC][crc] can already provide a simple form
4646of error detection and correction, capable of repairing a handful of
4747bit-errors.
4848
49+ Assuming a [ Hamming distance] [ hamming-distance ] ` HD ` for a given codeword
50+ size, ramcrc32bd can correct up to ` floor((HD-1)/2) ` bit errors. In its
51+ current configuration, ramcrc32bd can correct:
52+
53+ - 1 bit error up to ~ 512 KiB codewords (HD=3 up to 4294967263 bits)
54+ - 2 bit errors up to 371 byte codewords (HD=5 up to 2974 bits)
55+ - 3 bit errors up to 21 byte codewords (HD=7 up to 171 bits)
56+
4957It does scale poorly, $O(n^e)$, but if you're only worried about the
5058occasional one or two bit errors, it may be sufficient. It's hard to
5159beat the simplicity, low-cost, and hardware availability of CRCs.
5260
5361This block device uses littlefs's CRC-32, since we assume it's already
5462available. But the same idea can be extended to any other CRC, as long
55- as it has a sufficient [ Hamming distance] [ hamming-distance ] for the
56- expected number of bit-errors.
63+ as it has a sufficient Hamming distasnce for the desired codeword size.
5764
5865A quick comparison of current ram-ecc-bds:
5966
@@ -70,7 +77,7 @@ See also:
7077## RAM?
7178
7279Right now, [ littlefs's] [ littlefs ] block device API is limited in terms of
73- composability. It would be great to fix this on a major API change, but
80+ composability. While it would be great to fix this on a major API change,
7481in the meantime, a RAM-backed block device provides a simple example of
7582error-correction that users may be able to reimplement in their own
7683block devices.
@@ -205,13 +212,13 @@ away from the original codeword, and at least 3 bit-flips away from any
205212other codeword. It's not until we have 2 bit-errors that the original
206213codeword becomes ambiguous.
207214
208- But this is only an 8-bit CRC. With more bits, we can find a better CRC.
209- littlefs's 32-bit CRC, for example, has a Hamming distance of 7 up to
210- 171 bits (21 bytes), which means for any message <=21 bytes we can
211- reliably correct up to 3 bit-errors.
215+ But this is only an 8-bit CRC. With more bits, we can usually find a
216+ better CRC. littlefs's 32-bit CRC, for example, has a Hamming distance of
217+ 7 up to 171 bits (21 bytes), which means for any message <=21 bytes we
218+ can reliably correct up to 3 bit-errors.
212219
213220In general the number of bits we we can reliably correct is
214- $\left\lfloor\frac{HD -1}{2}\right\rfloor$.
221+ $\left\lfloor\frac{\text{HD} -1}{2}\right\rfloor$.
215222
216223### There's always brute force
217224
0 commit comments