mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 3/3] imx-bbu-nand-fcb: Workaround ROM checking fingerprint before correcting bitflips
Date: Tue, 25 Sep 2018 09:58:47 +0200	[thread overview]
Message-ID: <20180925075847.4585-4-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20180925075847.4585-1-s.hauer@pengutronix.de>

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") which is used by the ROM to detect
if a FCB is present on that block or not. Here the ROM chooses to check
for the fingerprint *before* running the ECC correction. Thus a FCB is
not used by the ROM anymore when it has a bitflip in the fingerprint
marker. 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 <s.hauer@pengutronix.de>
---
 common/imx-bbu-nand-fcb.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/common/imx-bbu-nand-fcb.c b/common/imx-bbu-nand-fcb.c
index 15ddf5d7b0..aaa796bc81 100644
--- a/common/imx-bbu-nand-fcb.c
+++ b/common/imx-bbu-nand-fcb.c
@@ -318,6 +318,16 @@ 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 before correcting
+	 * bitflips. This means we cannot allow bitflips in the fingerprint and
+	 * 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)
+		return ERR_PTR(-EINVAL);
+
 	for (i = 0; i < 512; i++) {
 		parity = ecc[i];
 		np = calculate_parity_13_8(fcb[i]);
-- 
2.19.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2018-09-25  7:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-25  7:58 [PATCH 0/3] i.MX6 NAND boot ROM workarounds Sascha Hauer
2018-09-25  7:58 ` [PATCH 1/3] imx-bbu-nand-fcb: Improve error message Sascha Hauer
2018-09-25  7:58 ` [PATCH 2/3] imx-bbu-nand-fcb: Workaround ROM not being able to handle bad blocks properly Sascha Hauer
2018-09-25  7:58 ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180925075847.4585-4-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox