path: root/common/imx-bbu-nand-fcb.c
diff options
authorSascha Hauer <>2018-09-24 16:46:49 +0200
committerSascha Hauer <>2018-09-25 11:14:17 +0200
commitce2484df6a520b1e5bcb7a00c5022d490ef083a8 (patch)
tree40c111745874c5345a83c8ba7922463e58d32312 /common/imx-bbu-nand-fcb.c
parent1994145c105700d2a3d54b611ffdefc95d693fe1 (diff)
imx-bbu-nand-fcb: Workaround ROM checking fingerprint before correcting bitflips
The FCB block is protected with a ECC code which can correct 1bit errors and detect 2bit errors. This works fine for all fields except the fingerprint marker (Containing "FCB") and the version field. Here the ROM chooses to check the correct value of the fields *before* running the ECC correction. Thus a FCB is not used by the ROM anymore when it has a bitflip in the fingerprint or version. For us this means we have to rewrite the FCB in this case, so reject the faulty FCB in read_fcb_hamming_13_8() which triggers a rewrite during the check operation. Signed-off-by: Sascha Hauer <>
Diffstat (limited to 'common/imx-bbu-nand-fcb.c')
1 files changed, 11 insertions, 0 deletions
diff --git a/common/imx-bbu-nand-fcb.c b/common/imx-bbu-nand-fcb.c
index 15ddf5d..8842ba6 100644
--- a/common/imx-bbu-nand-fcb.c
+++ b/common/imx-bbu-nand-fcb.c
@@ -318,6 +318,17 @@ struct fcb_block *read_fcb_hamming_13_8(void *rawpage)
fcb = rawpage + 12;
ecc = rawpage + 512 + 12;
+ /*
+ * The ROM does the check for the correct fingerprint and version before
+ * correcting bitflips. This means we cannot allow bitflips in the
+ * fingerprint and version. We bail out with an error if it's not correct.
+ * This is currently done in the i.MX6qdl path. It needs to be checked if
+ * the same happens in the BCH encoded variants (i.MX6ul(l)) aswell.
+ */
+ if (((struct fcb_block *)fcb)->FingerPrint != 0x20424346 ||
+ ((struct fcb_block *)fcb)->Version != 0x01000000)
+ return ERR_PTR(-EINVAL);
for (i = 0; i < 512; i++) {
parity = ecc[i];
np = calculate_parity_13_8(fcb[i]);