Skip to content

Commit e0e65c5

Browse files
committed
README.md - Tried to word the error correction limits into the intro
1 parent 911d4ae commit e0e65c5

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,21 @@ Often overlooked, the humble [CRC][crc] can already provide a simple form
4646
of error detection and correction, capable of repairing a handful of
4747
bit-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+
4957
It does scale poorly, $O(n^e)$, but if you're only worried about the
5058
occasional one or two bit errors, it may be sufficient. It's hard to
5159
beat the simplicity, low-cost, and hardware availability of CRCs.
5260

5361
This block device uses littlefs's CRC-32, since we assume it's already
5462
available. 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

5865
A quick comparison of current ram-ecc-bds:
5966

@@ -70,7 +77,7 @@ See also:
7077
## RAM?
7178

7279
Right 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,
7481
in the meantime, a RAM-backed block device provides a simple example of
7582
error-correction that users may be able to reimplement in their own
7683
block devices.
@@ -205,13 +212,13 @@ away from the original codeword, and at least 3 bit-flips away from any
205212
other codeword. It's not until we have 2 bit-errors that the original
206213
codeword 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

213220
In 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

Comments
 (0)