On Tue, May 5, 2009 at 2:35 AM, Dmitry Kurochkin
<dmitry.kuroch...@gmail.com> wrote:
> Hi Nelson, Werner.
>
> Can you please review and apply the patch?
>

Dmitry: I applied the patch and Qi boots.

I'm attaching the committed patch with your Signed-off-by. I hope it's
OK. Next time try to send a valid patch so that you have control over
the text :-)

Thanks for fixing the bug.
From: Dmitry Kurochkin <dmitry.kuroch...@gmail.com>
Date: Fri, 10 Apr 2009 00:14:49 +0400
Subject: [PATCH] Bad magic when booting from NAND

Qi fails to boot from NAND. Qi booting from SD goes fine. Booting NAND
from NOR works as well.

I have found the problem. The error was because we check if the
current block is bad or the next one is bad. And skip the current
block even if only the next one is bad. This way we skip good block
before a bad one.

This patch fixes the bug.

Signed-off-by: Dmitry Kurochkin <dmitry.kuroch...@gmail.com>

diff --git a/src/cpu/s3c2442/nand_read.c b/src/cpu/s3c2442/nand_read.c
index 06ec24d..8206717 100644
--- a/src/cpu/s3c2442/nand_read.c
+++ b/src/cpu/s3c2442/nand_read.c
@@ -119,7 +119,6 @@ int nand_read_ll(unsigned char *buf, unsigned long start_block512,
 								  int blocks512)
 {
 	int i, j;
-	int bad_count = 0;
 
 	/* chip Enable */
 	nand_select();
@@ -129,11 +128,10 @@ int nand_read_ll(unsigned char *buf, unsigned long start_block512,
 		;
 
 	while (blocks512 > 0) {
-		if (s3c2442_nand_is_bad_block(start_block512) ||
-				s3c2442_nand_is_bad_block(start_block512 + 4)) {
+		if (s3c2442_nand_is_bad_block(start_block512)) {
 			start_block512 += 4;
-			blocks512 += 4;
-			if (bad_count++ == 4)
+			if (start_block512 >> 2 > BAD_BLOCK_OFFSET)
+				/* end of NAND */
 				return -1;
 			continue;
 		}

Reply via email to