- Python 98.3%
- C 1.7%
| .gitignore | ||
| bch4369.c | ||
| bch4369.h | ||
| bch4369.py | ||
| LICENSE | ||
| README.md | ||
BCH 4369 code for flash page EDAC
A flash chip like AT45DB161E provides pages of nonvolatile memory á 528 bytes. The chip can be configured to use 512 bytes pages, but why? This code makes use of the extra 16 bytes for Error Detection And Correction.
It turns out there is a Bose-Chaudhuri-Hocquenghem code that fits. The codeword has 4369 bits, including 128 bits parity. With messages of 4096 bits there are 145 bits of padding.
The python module galois by Matt Hostetter implements this code as
galois.BCH(4369, 4369-128, extension_field=galois.GF(2**16))
This code can correct up to 8 bit errors.
AVR
Here you find space efficient code for an AVR µC, in C and assembler.
Python
The python implementation can encode and check the parity without module galois. The data format is bytes(). It boils down to a simple numpy matrix multiplication. The galois module is only loaded when error correction is attempted.
Salt
The default .salt is b'\x01', i.e., the message length is 4097 bits with the leading bit set. A codeword off all zeros will see a correctable error in the salt. A real message of all zeros has nontrival parity. The python code can handle salts up to 18 bytes, 144 bits. The AVR could support longer salts by replacing bch5369_init by a memcpy. I do not know how usefull a salt is. I though it might be good to have nontrivial parity for an all zeros message.