From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 1/4] ARM: i.MX: external nand boot: check for bad blocks
Date: Tue, 12 Mar 2013 10:29:54 +0100 [thread overview]
Message-ID: <1363080597-10510-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1363080597-10510-1-git-send-email-s.hauer@pengutronix.de>
The i.MX external NAND boot code checks for a bad block every
page, which is wrong. Instead, check for a bad block at the
beginning of each block.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-imx/external-nand-boot.c | 39 +++++++++++++++++++++++-----------
1 file changed, 27 insertions(+), 12 deletions(-)
diff --git a/arch/arm/mach-imx/external-nand-boot.c b/arch/arm/mach-imx/external-nand-boot.c
index 73c4ccd..bfefa3c 100644
--- a/arch/arm/mach-imx/external-nand-boot.c
+++ b/arch/arm/mach-imx/external-nand-boot.c
@@ -154,6 +154,14 @@ static int __maybe_unused is_pagesize_2k(void)
#endif
}
+static noinline void __bare_init imx_nandboot_get_page(void *regs,
+ u32 offs, int pagesize_2k)
+{
+ imx_nandboot_send_cmd(regs, NAND_CMD_READ0);
+ imx_nandboot_nfc_addr(regs, offs, pagesize_2k);
+ imx_nandboot_send_page(regs, NFC_OUTPUT, pagesize_2k);
+}
+
void __bare_init imx_nand_load_image(void *dest, int size)
{
u32 tmp, page, block, blocksize, pagesize;
@@ -227,26 +235,33 @@ void __bare_init imx_nand_load_image(void *dest, int size)
while (1) {
page = 0;
+
+ imx_nandboot_get_page(regs, block * blocksize +
+ page * pagesize, pagesize_2k);
+
+ if (pagesize_2k) {
+ if ((readw(spare0) & 0xff) != 0xff) {
+ block++;
+ continue;
+ }
+ } else {
+ if ((readw(spare0 + 4) & 0xff00) != 0xff00) {
+ block++;
+ continue;
+ }
+ }
+
while (page * pagesize < blocksize) {
debug("page: %d block: %d dest: %p src "
"0x%08x\n",
page, block, dest,
block * blocksize +
page * pagesize);
-
- imx_nandboot_send_cmd(regs, NAND_CMD_READ0);
- imx_nandboot_nfc_addr(regs, block * blocksize +
+ if (page)
+ imx_nandboot_get_page(regs, block * blocksize +
page * pagesize, pagesize_2k);
- imx_nandboot_send_page(regs, NFC_OUTPUT, pagesize_2k);
- page++;
- if (pagesize_2k) {
- if ((readw(spare0) & 0xff) != 0xff)
- continue;
- } else {
- if ((readw(spare0 + 4) & 0xff00) != 0xff00)
- continue;
- }
+ page++;
__memcpy32(dest, base, pagesize);
dest += pagesize;
--
1.8.2.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-03-12 9:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-12 9:29 [PATCH] fix i.MX external NAND boot bad block handling Sascha Hauer
2013-03-12 9:29 ` Sascha Hauer [this message]
2013-03-12 9:29 ` [PATCH 2/4] ARM: head: Add some space behind the image header Sascha Hauer
2013-03-12 9:41 ` Juergen Beisert
2013-03-12 9:29 ` [PATCH 3/4] ARM: i.MX: Add bbu handler for external NAND boot Sascha Hauer
2013-03-12 9:48 ` Juergen Beisert
2013-03-12 10:05 ` Sascha Hauer
2013-03-12 10:08 ` Juergen Beisert
2013-03-12 9:29 ` [PATCH 4/4] ARM: i.MX pcm043: register external nand boot handler Sascha Hauer
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=1363080597-10510-2-git-send-email-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