This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

BCH4 syndrome calculation

Many TI chips ship with a GPMC containing an incorrect polynomial for BCH-4, rendering error location impossible.  The errata in each case state "Workaround: none".

I just had a flash of insight that in fact there's a very easy workaround:

Background: the BCH calculation done by GPMC is essentially the same as a CRC, i.e. it reduces the input modulo some polynomial over GF(2).  The BCH codes however use a much bigger polynomial, chosen with special properties which enable error correction rather than just error detection as with plain CRC.

The BCH-4 and BCH-8 (and in later devices, BCH-16) codes used are all part of a single family of closely related polynomials.  Specifically, using the terminology of the BCH wikipedia page, they are primitive narrow-sense BCH codes with q=2, m=13, and d=2*(number of bits of error correction desired), with the generator α being any root of m1 = x13 + x4 + x3 + x + 1 in GF(213).

The BCH-k polynomial is the product of the minimum polynomials of the first k odd powers of α, which means in particular that the BCH-4 polynomial is a factor of the BCH-8 polynomial, which itself is a factor of the BCH-16 polynomial.  This implies that you can calculate a BCH-4 code for given input from the BCH-8 code for the same input simply by reducing it modulo the BCH-4 polynomial.

This immediately leads to the simple workaround: just configure the GPMC to calculate the BCH-8 code, and perform the final reduction to the BCH-4 code in software.

I wrote a simple conversion routine and tested it against GPMC-produced values on a DM814x (which has correctly working BCH-4).  It appears to work: when fed a BCH-8 code from the GPMC it produces an output which matches the code produced by the GPMC when configured to use BCH-4.  See attachment: 8284.bch8_to_bch4.c

 

Addendum:  Note that with in a similar way you can reduce to intermediate BCH codes, so for example you can reduce to BCH-6 which fits in 10 bytes.  On devices with ELM you can reduce such codes first to BCH-4 which is supported by ELM, and if that fails (> 4 errors) fall back to doing error location in software to get the full 6 bits of error correction.