Skip to contentSkip to conversation

Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

PATCH New apgmoorthy 5 participants 20 messages Mar 23, 2009 – Apr 28, 2009

lore
Share & tools
lore

apgmoorthy

author
#0 lore raw

PATCH 1/2 Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

Hi Scott,

Quoted 3 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	if (page < 2 && (onenand_readw(THIS_ONENAND(ONENAND_SPARERAM)) != 0xffff))

Line length.

- Corrected.

Quoted 19 lines

Review

Quoted 2 lines
(quoted diff) +1 -0
 	int pagesize = ONENAND_PAGE_SIZE;
+	int nblocks = CONFIG_SYS_MONITOR_LEN / ONENAND_BLOCK_SIZE;

Shouldn't nblocks be rounded up?

Review

Quoted 3 lines
(quoted diff) +2 -0
 		pagesize <<= 1;
+		nblocks = (nblocks + 1) >> 1;
+	}

Hmm, might be clearer to just do this:

if (onenand_readw(THIS_ONENAND(ONENAND_REG_TECHNOLOGY))) {
	pagesize = 4096;
	pageshift = 12;
} else {
	pagesize = 2048;
	pageshift = 11;
}
Quoted 1 line

nblocks = (CONFIG_SYS_MONITOR_LEN + pagesize - 1) >> pageshift;

- Right , But the above line dosent give the nblocks , used erasesize and erase_shift.

Quoted 2 lines

ONENAND_PAGE_SIZE as a constant should go away since it's not always true.

- Removed it.

Quoted 11 lines

Review

Quoted 8 lines
(quoted diff) +8 -0
+	for (; block < nblocks; block++) {
+		for (; page < ONENAND_PAGES_PER_BLOCK; page++) {
+			if (onenand_read_page(block, page, buf + offset, pagesize)) {
+				/* This block is bad. Skip it and read next block */
+				nblocks++;
+				break;
+			}
+			offset += pagesize;

If you find a bad block marker in the second page of a block, shouldn't you rewind offset to the beginning of the block?

- Correct , have reverted back.

Quoted 2 lines

BTW, if we're going to have "onenand_readw" and "onenand_writew" wrappers, can we make them useful by combining them with THIS_ONENAND?

- Corrected , Now onenand_readw/onenand_writew conatins THIS_ONENAND.

Please do find the updated patch below.

With Regards
Moorthy

Currently OneNAND initial program loader (ipl) reads only block 0 ie 128KB. However, u-boot image for apollon board is 195KB making the board unbootable with OneNAND.

Fix ipl to read CONFIG_SYS_MONITOR_LEN. CONFIG_SYS_MONITOR_LEN macro holds the U-Boot image size.

---

onenand_ipl/onenand_boot.c +1 -1
index 86428cc..63995ce 100644
@@ -36,7 +36,7 @@ void start_oneboot(void)
 
 	buf = (uchar *) CONFIG_SYS_LOAD_ADDR;
 
-	onenand_read_block0(buf);
+	onenand_read_block(buf);
 
 	((init_fnc_t *)CONFIG_SYS_LOAD_ADDR)();
 
onenand_ipl/onenand_ipl.h +1 -1
index c5a722d..412572a 100644
@@ -31,5 +31,5 @@
 #define READ_INTERRUPT()                                                \
 	onenand_readw(THIS_ONENAND(ONENAND_REG_INTERRUPT))
 
-extern int onenand_read_block0(unsigned char *buf);
+extern int onenand_read_block(unsigned char *buf);
 #endif
onenand_ipl/onenand_read.c +37 -19

88 lines not on this page · raw message

#1 lore raw

PATCH 1/2 Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

Quoted 4 lines · apgmoorthy
Quoted 1 line

nblocks = (CONFIG_SYS_MONITOR_LEN + pagesize - 1) >> pageshift;

- Right , But the above line dosent give the nblocks , used erasesize and erase_shift.

D'oh, right.

Quoted 1 line

Please do find the updated patch below.

It's easier if updated patches are sent separately from the reply (both to avoid getting lost, and to avoid having to manually strip discussion from the changelog).

The patch looks good other than some style nits:

Quoted 2 lines

The signed-off-by lines should go in chronological order of handling; thus, yours should be at the bottom (as the most recent one to touch or forward the patch).

onenand_ipl/onenand_read.c static inline int onenand_read_page(ulong block, ulong page, · line 77

Quoted 3 lines
onenand_ipl/onenand_read.c +3 -0
+	/* Check for invalid block mark */
+	if (page < 2 && (onenand_readw(ONENAND_SPARERAM) != 0xffff))
+		return 1;

Unnecessary parens.

onenand_ipl/onenand_read.c static inline int onenand_read_page(ulong block, ulong page, · line 97

Quoted 10 lines

#ifdef __HAVE_ARCH_MEMCPY32

onenand_ipl/onenand_read.c +2 -1
 	/* 32 bytes boundary memory copy */
 	memcpy32(buf, base, pagesize);
@@ -89,25 +93,39 @@ static inline int onenand_read_page(ulong block, ulong page,
 #define ONENAND_PAGES_PER_BLOCK		64
 
 /**
- * onenand_read_block - Read a block data to buf
+ * onenand_read_block - Read First 'n' consecutive Good blocks holding 
+ *                      data to buf

"Read SYS_MONITOR_LEN from beginning of OneNAND, skipping bad blocks"

Quoted 4 lines
onenand_ipl/onenand_read.c +1 -1
  * @return 0 on success
  */
-int onenand_read_block0(unsigned char *buf)
+int onenand_read_block(unsigned char *buf)

onenand_ipl/onenand_read.c static inline int onenand_read_page(ulong block, ulong page, · line 104

Quoted 10 lines
onenand_ipl/onenand_read.c +3 -6
 {
-	int page, offset = 0;
-	int pagesize = ONENAND_PAGE_SIZE;
-
-	/* MLC OneNAND has 4KiB page size */
-	if (onenand_readw(THIS_ONENAND(ONENAND_REG_TECHNOLOGY)))
-		pagesize <<= 1;
+	int block = 0, page = ONENAND_START_PAGE, offset = 0;
+	int pagesize = 0, erase_shift =0;
+	int erasesize = 0, nblocks = 0;

s/=0/= 0/

onenand_ipl/onenand_read.c static inline int onenand_read_page(ulong block, ulong page, · line 106

Quoted 2 lines
onenand_ipl/onenand_read.c +2 -0
+
+	if(onenand_readw(ONENAND_REG_TECHNOLOGY)) {

Space after "if".

onenand_ipl/onenand_read.c static inline int onenand_read_page(ulong block, ulong page, · line 114

Quoted 8 lines
onenand_ipl/onenand_read.c +8 -0
+		pagesize = 4096; /* MLC OneNAND has 4KiB pagesize */
+		erase_shift = 18;
+	} else {
+		pagesize = 2048;
+		erase_shift = 17;
+	}
+	erasesize = ONENAND_PAGES_PER_BLOCK * pagesize;
+	nblocks = (CONFIG_SYS_MONITOR_LEN + erasesize -1) >> erase_shift;

Blank line after the closing brace at the end of a block (except with a hanging else, or similar).

s/-1/- 1/

onenand_ipl/onenand_read.c static inline int onenand_read_page(ulong block, ulong page, · line 119

Quoted 2 lines
onenand_ipl/onenand_read.c +2 -0
+	for (; block < nblocks; block++) {
+		for (; page < ONENAND_PAGES_PER_BLOCK; page++) {

Why not do block = 0 and page = 0 here, rather than at the beginning of the function and (in the case of page)@the end of the loop?

onenand_ipl/onenand_read.c static inline int onenand_read_page(ulong block, ulong page, · line 121

Quoted 2 lines
onenand_ipl/onenand_read.c +2 -0
+			if (onenand_read_page(block, page, buf + offset, pagesize)) {
+				/* This block is bad. Skip it and read next block */

Line length.

-Scott

#2 lore raw

PATCH 1/2 Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

Dear Scott Wood,

Quoted 6 lines · In message <[email protected]> you wrote:

onenand_ipl/onenand_read.c static inline int onenand_read_page(ulong block, ulong page, · line 77

Quoted 4 lines
onenand_ipl/onenand_read.c +3 -0
+	/* Check for invalid block mark */
+	if (page < 2 && (onenand_readw(ONENAND_SPARERAM) != 0xffff))
+		return 1;

Unnecessary parens.

Where? I find them pretty useful. Please keep!

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I don't want to be young again, I just don't want to get any older.
#3 lore raw

PATCH 1/2 Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

Quoted 9 lines · Wolfgang Denk

Dear Scott Wood,

Quoted 4 lines · In message <[email protected]> you wrote:

onenand_ipl/onenand_read.c static inline int onenand_read_page(ulong block, ulong page, · line 77

Quoted 3 lines
onenand_ipl/onenand_read.c +3 -0
+	/* Check for invalid block mark */
+	if (page < 2 && (onenand_readw(ONENAND_SPARERAM) != 0xffff))
+		return 1;

Unnecessary parens.

Where? I find them pretty useful.

Around the second comparison. Why "if (a < b && (c != d))" and not "if (a < b && c != d)", or if the parens are preferred, "if ((a < b) && (c != d))"? Is it because "c" is a function call?

Quoted 1 line

Please keep!

OK -- I guess this is another of the unwritten points on which U-boot's style deviates from that which is typical in Linux.

-Scott

#4 lore raw

PATCH 1/2 Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

Dear Scott,

Quoted 10 lines · In message <[email protected]> you wrote:
Quoted 6 lines
Quoted 4 lines

onenand_ipl/onenand_read.c static inline int onenand_read_page(ulong block, ulong page, · line 77

Quoted 3 lines
onenand_ipl/onenand_read.c +2 -0
+	if (page < 2 && (onenand_readw(ONENAND_SPARERAM) != 0xffff))
+		return 1;

Unnecessary parens.

Where? I find them pretty useful.

Around the second comparison. Why "if (a < b && (c != d))" and not "if (a < b && c != d)", or if the parens are preferred, "if ((a < b) && (c != d))"? Is it because "c" is a function call?

Actually I'd probably write this as

	if ((page < 2) && (onenand_readw(ONENAND_SPARERAM) != 0xffff))

for consistency, but being lazy I guess I might use the same code as the OP.

Quoted 2 lines

OK -- I guess this is another of the unwritten points on which U-boot's style deviates from that which is typical in Linux.

Actually this is not some formal style (at least no rule that I know of), but personal taste :-)

When I parse something like

	if (page < 2 && onenand_readw(ONENAND_SPARERAM) != 0xffff)

I can eaisly see the "page < 2" expression because it is relatively short. But I have to look twice for the "onenand_readw(ONENAND_SPARE- RAM) != 0xffff" part because it is long and includes nested parens. So I feel tempted to make this easier to read by surrounding it with parens - like the OP did.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
I'm frequently appalled by the low regard you Earthmen have for life.
	-- Spock, "The Galileo Seven", stardate 2822.3
#5 lore raw

PATCH 1/2 Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

Hi Wolfgang,
----- Original Message -----
From: "Wolfgang Denk" <[email protected]>
To: "Scott Wood" <[email protected]>
Cc: <[email protected]>; "apgmoorthy" <[email protected]>
Sent: Tuesday, March 24, 2009 4:16 AM
Subject: Re: [U-Boot] [PATCH 1/2] Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

Quoted 38 lines

Dear Scott,

Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines

+ if (page < 2 && (onenand_readw(ONENAND_SPARERAM) != 0xffff))
+ return 1;

Unnecessary parens.

Quoted 7 lines
Quoted 1 line

Where? I find them pretty useful.

Around the second comparison. Why "if (a < b && (c != d))" and not "if
(a < b && c != d)", or if the parens are preferred, "if ((a < b) && (c
!= d))"? Is it because "c" is a function call?

Actually I'd probably write this as

if ((page < 2) && (onenand_readw(ONENAND_SPARERAM) != 0xffff))

for consistency, but being lazy I guess I might use the same code as
the OP.

Quoted 3 lines

OK -- I guess this is another of the unwritten points on which U-boot's
style deviates from that which is typical in Linux.

Actually this is not some formal style (at least no rule that I know
of), but personal taste :-)

When I parse something like

if (page < 2 && onenand_readw(ONENAND_SPARERAM) != 0xffff)

Quoted 9 lines

I can eaisly see the "page < 2" expression because it is relatively
short. But I have to look twice for the "onenand_readw(ONENAND_SPARE-
RAM) != 0xffff" part because it is long and includes nested parens.
So I feel tempted to make this easier to read by surrounding it with
parens - like the OP did.

I agree with for better readabilty we will chnage and resend it today only.
We will try to improve readability of code.

Thanks for suggestion.
Amit

Quoted 19 lines

Best regards,

Wolfgang Denk

Signature · 13 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & 
Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 
Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: 
wd at denx.de
I'm frequently appalled by the low regard you Earthmen 
have for life.
-- Spock, "The Galileo Seven", stardate 2822.3
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot 
author
#6 lore raw

PATCH 1/2 Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

In reply to Scott Wood

Hi Scott,

On Tuesday, March 24, 2009 2:55 AM , Scott Wood wrote

Quoted 10 lines
Quoted 1 line

Please do find the updated patch below.

It's easier if updated patches are sent separately from the reply (both to avoid getting lost, and to avoid having to manually strip discussion from the changelog).

Quoted 2 lines

The signed-off-by lines should go in chronological order of handling;
thus, yours should be at the bottom (as the most recent one to touch or forward the patch).

- Thanks, Will take care.

Quoted 5 lines

onenand_ipl/onenand_read.c static inline int onenand_read_page(ulong block, ulong page, · line 77

Quoted 3 lines
onenand_ipl/onenand_read.c +3 -0
+	/* Check for invalid block mark */
+	if (page < 2 && (onenand_readw(ONENAND_SPARERAM) != 0xffff))
+		return 1;

Unnecessary parens.

- I think , parens make it more readable.

Quoted 5 lines
Quoted 3 lines

- * onenand_read_block - Read a block data to buf
+ * onenand_read_block - Read First 'n' consecutive Good blocks holding
+ * data to buf

"Read SYS_MONITOR_LEN from beginning of OneNAND, skipping bad blocks"

- Changed it in Function Header.

Quoted 9 lines

onenand_ipl/onenand_read.c static inline int onenand_read_page(ulong block, ulong page, · line 104

Quoted 3 lines
onenand_ipl/onenand_read.c +3 -0
+	int block = 0, page = ONENAND_START_PAGE, offset = 0;
+	int pagesize = 0, erase_shift =0;
+	int erasesize = 0, nblocks = 0;

s/=0/= 0/

onenand_ipl/onenand_read.c static inline int onenand_read_page(ulong block, ulong page, · line 106

Quoted 1 line
onenand_ipl/onenand_read.c +1 -0
+	if(onenand_readw(ONENAND_REG_TECHNOLOGY)) {

Space after "if".

- Corrected them.

Quoted 10 lines

onenand_ipl/onenand_read.c static inline int onenand_read_page(ulong block, ulong page, · line 114

Quoted 6 lines
onenand_ipl/onenand_read.c +6 -0
+	} else {
+		pagesize = 2048;
+		erase_shift = 17;
+	}
+	erasesize = ONENAND_PAGES_PER_BLOCK * pagesize;
+	nblocks = (CONFIG_SYS_MONITOR_LEN + erasesize -1) >> erase_shift;

Blank line after the closing brace at the end of a block (except with a hanging else, or similar).

s/-1/- 1/

- Changed them.

Quoted 5 lines

onenand_ipl/onenand_read.c static inline int onenand_read_page(ulong block, ulong page, · line 119

Quoted 2 lines
onenand_ipl/onenand_read.c +2 -0
+	for (; block < nblocks; block++) {
+		for (; page < ONENAND_PAGES_PER_BLOCK; page++) {

Why not do block = 0 and page = 0 here, rather than at the beginning of the function and (in the case of page) at the end of the loop?

- Initialized block in the for. With 'page' we need to start with page 1 in Block 0.

Quoted 4 lines

onenand_ipl/onenand_read.c static inline int onenand_read_page(ulong block, ulong page, · line 121

Quoted 2 lines
onenand_ipl/onenand_read.c +2 -0
+			if (onenand_read_page(block, page, buf + offset, pagesize)) {
+				/* This block is bad. Skip it and read next block */

Line length.

- Resolved.

With Regards
Moorthy

author
#7 lore raw

PATCH 1/2 Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

In reply to Scott Wood

Currently OneNAND initial program loader (ipl) reads only block 0 ie 128KB. However, u-boot image for apollon board is 195KB making the board unbootable with OneNAND.

Fix ipl to read CONFIG_SYS_MONITOR_LEN. CONFIG_SYS_MONITOR_LEN macro holds the U-Boot image size.

---
 onenand_boot.c |    2 -
 onenand_ipl.h  |    8 ++-----
 onenand_read.c |   58 +++++++++++++++++++++++++++++++++++++++------------------
 3 files changed, 44 insertions(+), 24 deletions(-) 
onenand_ipl/onenand_boot.c +1 -1
index 86428cc..63995ce 100644
@@ -36,7 +36,7 @@ void start_oneboot(void)
 
 	buf = (uchar *) CONFIG_SYS_LOAD_ADDR;
 
-	onenand_read_block0(buf);
+	onenand_read_block(buf);
 
 	((init_fnc_t *)CONFIG_SYS_LOAD_ADDR)();
 
onenand_ipl/onenand_ipl.h +3 -5
index 57e54f5..412572a 100644
@@ -23,15 +23,13 @@
 
 #include <linux/mtd/onenand_regs.h>
 
-#define onenand_readw(a)        readw(a)
-#define onenand_writew(v, a)    writew(v, a)
+#define onenand_readw(a)        readw(THIS_ONENAND(a))
+#define onenand_writew(v, a)    writew(v, THIS_ONENAND(a))
 
 #define THIS_ONENAND(a)         (CONFIG_SYS_ONENAND_BASE + (a))
 
 #define READ_INTERRUPT()                                                \
 	onenand_readw(THIS_ONENAND(ONENAND_REG_INTERRUPT))
 
-#define ONENAND_PAGE_SIZE                       2048
-
-extern int onenand_read_block0(unsigned char *buf);
+extern int onenand_read_block(unsigned char *buf);
 #endif
onenand_ipl/onenand_read.c +40 -18

91 lines not on this page · raw message

#8 lore raw

PATCH 1/2 Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

Quoted 9 lines · apgmoorthy

Currently OneNAND initial program loader (ipl) reads only block 0 ie 128KB. However, u-boot image for apollon board is 195KB making the board unbootable with OneNAND.

Fix ipl to read CONFIG_SYS_MONITOR_LEN. CONFIG_SYS_MONITOR_LEN macro holds the U-Boot image size.

Applied to u-boot-nand-flash, with the below whitespace errors fixed:

Applying RE: [U-Boot] [PATCH 1/2] Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN
.dotest/patch:128: trailing whitespace.

                                 /* This block is bad. Skip it
.dotest/patch:130: space before tab in indent.
                                 offset -= page * pagesize;

warning: 2 lines add whitespace errors.

Note that there are a couple of board files (apollon and nmdk8815) that use the OneNAND loader that do not define CONFIG_SYS_MONITOR_LEN. I've added the maintainers to the Cc: list.

-Scott

#9 lore raw

PATCH 1/2 Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

Hi Rubini,

AS suggested by scott , Please share your views regarding CONFIG_SYS_MONITOR_LEN
because image size getting bigger then 1 block we have to use this macro for uboot image size.

----- Original Message -----
From: "Scott Wood" <[email protected]>
To: "apgmoorthy" <[email protected]>
Cc: <[email protected]>; <[email protected]>
Sent: Tuesday, March 31, 2009 4:03 AM
Subject: Re: [U-Boot] [PATCH 1/2] Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

Quoted 26 lines
Quoted 6 lines · apgmoorthy

Currently OneNAND initial program loader (ipl) reads only block 0 ie 128KB.
However, u-boot image for apollon board is 195KB making the board
unbootable with OneNAND.

Quoted 6 lines

Fix ipl to read CONFIG_SYS_MONITOR_LEN. CONFIG_SYS_MONITOR_LEN macro holds the U-Boot image size.

Signed-off-by Gangheyamoorthy

<[email protected]>

Applied to u-boot-nand-flash, with the below whitespace errors fixed:

Applying RE: [U-Boot] [PATCH 1/2] Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN
.dotest/patch:128: trailing whitespace.

                                /* This block is bad. Skip 
it
.dotest/patch:130: space before tab in indent.
                                offset -= page * pagesize;

warning: 2 lines add whitespace errors.

Quoted 7 lines

Note that there are a couple of board files (apollon and nmdk8815) that
use the OneNAND loader that do not define CONFIG_SYS_MONITOR_LEN. I've
added the maintainers to the Cc: list.

-Scott

Thanks
Amit

Quoted 4 lines

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#10 lore raw

PATCH 1/2 Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

In reply to Scott Wood

Hello.

Quoted 3 lines

Note that there are a couple of board files (apollon and nmdk8815) that use the OneNAND loader that do not define CONFIG_SYS_MONITOR_LEN. I've added the maintainers to the Cc: list.

Sorry for the delay.

In the nomadik board the OneNAND driver is not yet present, a few init lines are still missing (I have an error to fix before submitting those lines). I'll take care of CONFIG_SYS_MONITOR_LEN together with that.

Note however that on the Nomadik we don't use the IPL, since u-boot is loaded by other code (a proprietary IPL that onlocks the CPU before handing control to ours) so u-boot isn't even in the first sector of OneNAND.

/alessandro

#11 lore raw

PATCH 1/2 Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

Quoted 8 lines · Alessandro Rubini

Hello.

Quoted 3 lines

Note that there are a couple of board files (apollon and nmdk8815) that use the OneNAND loader that do not define CONFIG_SYS_MONITOR_LEN. I've added the maintainers to the Cc: list.

Sorry for the delay.

Quoted 8 lines

In the nomadik board the OneNAND driver is not yet present, a few init lines are still missing (I have an error to fix before submitting those lines). I'll take care of CONFIG_SYS_MONITOR_LEN together with that.

Note however that on the Nomadik we don't use the IPL, since u-boot is loaded by other code (a proprietary IPL that onlocks the CPU before handing control to ours) so u-boot isn't even in the first sector of OneNAND.

OK, sorry about that. I ran into the issue when building apollon, and nmdk8815 looked like it was in a similar situation from grepping config files.

-Scott

#12 lore raw

PATCH 1/2 Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

Hi Scott,

----- Original Message -----
From: "Scott Wood" <[email protected]>
To: "Alessandro Rubini" <[email protected]>
Cc: <[email protected]>; <[email protected]>
Sent: Tuesday, March 31, 2009 9:43 PM
Subject: Re: [U-Boot] [PATCH 1/2] Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

Quoted 33 lines
Quoted 17 lines · Alessandro Rubini

Hello.

Quoted 5 lines

Note that there are a couple of board files (apollon and nmdk8815) that
use the OneNAND loader that do not define CONFIG_SYS_MONITOR_LEN. I've
added the maintainers to the Cc: list.

Sorry for the delay.

In the nomadik board the OneNAND driver is not yet present, a few init
lines are still missing (I have an error to fix before submitting those
lines). I'll take care of CONFIG_SYS_MONITOR_LEN together with that.

Quoted 7 lines

Note however that on the Nomadik we don't use the IPL, since u-boot is
loaded by other code (a proprietary IPL that onlocks the CPU before
handing control to ours) so u-boot isn't even in the first sector
of OneNAND.

OK, sorry about that. I ran into the issue when building apollon, and
nmdk8815 looked like it was in a similar situation from grepping config
files.

-Scott

#13 lore raw

PATCH 1/2 Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

Quoted 4 lines · Amit Kumar Sharma

From Alessandro mail it is claear CONFIG_SYS_MONITOR_LEN only used by apollon
that can be changed by Apollon users independently. we will check othe rissue of white space and release patch.

No need; I've already fixed the whitespace and applied the patch (as noted in the previous e-mail).

-Scott

author
#14 lore raw

PATCH 1/2 Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

In reply to Scott Wood

Hi Scott,

On Tuesday, March 31, 2009 4:04 AM Scott Wood Wrote :

Quoted 2 lines
Quoted 2 lines

Note that there are a couple of board files (apollon and nmdk8815) that use the OneNAND loader that do not define CONFIG_SYS_MONITOR_LEN. I've added the maintainers to the Cc: list.

CONFIG_SYS_MONITOR_LEN is not defined in include/configs/apollon.h as of now.

This is done by the Post : [U-Boot] [PATCH 2/2] Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

What do you feel about getting this one inside u-boot-nand-flash ?

With Regards
Moorthy

#15 lore raw

PATCH 1/2 Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

Quoted 4 lines · apgmoorthy

Hi Scott,

On Tuesday, March 31, 2009 4:04 AM Scott Wood Wrote :

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

Note that there are a couple of board files (apollon and nmdk8815) that use the OneNAND loader that do not define CONFIG_SYS_MONITOR_LEN. I've added the maintainers to the Cc: list.

CONFIG_SYS_MONITOR_LEN is not defined in include/configs/apollon.h as of now.

This is done by the Post : [U-Boot] [PATCH 2/2] Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

What do you feel about getting this one inside u-boot-nand-flash ?

Such a change should go through the board maintainer, who knows better what the actual length is.

-Scott

#16 lore raw

PATCH 1/2 Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

Hi Kyungmin,
----- Original Message -----
From: "Scott Wood" <[email protected]>
To: "apgmoorthy" <[email protected]>
Cc: <[email protected]>; <[email protected]>
Sent: Friday, April 24, 2009 4:09 AM
Subject: Re: [U-Boot] [PATCH 1/2] Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

Quoted 16 lines
Quoted 15 lines · apgmoorthy

Hi Scott,

On Tuesday, March 31, 2009 4:04 AM Scott Wood Wrote :

Quoted 4 lines
Quoted 4 lines

Note that there are a couple of board files (apollon and nmdk8815) that use the OneNAND loader that do not define CONFIG_SYS_MONITOR_LEN. I've added the maintainers to the Cc: list.

CONFIG_SYS_MONITOR_LEN is not defined in
include/configs/apollon.h as of now.

This is done by the Post : [U-Boot] [PATCH 2/2] Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN

Quoted 8 lines
Quoted 2 lines

What do you feel about getting this one inside
u-boot-nand-flash ?

Such a change should go through the board maintainer, who knows better
what the actual length is.

-Scott

Please provide your comments,
Are you using Apollon board now days.

Thanks
Amit

author
#17 lore raw

PATCH 1/1 Bad Block Capable environment for OneNAND

In reply to Scott Wood

Hi,
With OneNAND ipl reading CONFIG_SYS_MONITOR_LEN , Environment Area should start after CONFIG_SYS_MONITOR_LEN.
Environment is made Bad Block cpapable too. These are done in the patch.
And fix 'onenand test' command to skip Bootloader and Environment Blocks.

With Regards
Moorthy

Makes Environment to start after CONFIG_SYS_MONITOR_LEN Environment is made to be Bad Block aware/capable.
Fix 'onenand test' command to skip Bootloader and Environment Blocks.

---
 common/cmd_onenand.c      |   12 ++++--
 common/env_onenand.c      |   96 +++++++++++++++++++++++++++++++++------------
 include/configs/apollon.h |    2 +-
 include/onenand_uboot.h   |    4 ++
 4 files changed, 84 insertions(+), 30 deletions(-)
common/cmd_onenand.c +8 -4
index 5832ff8..c366935 100644
@@ -206,6 +206,7 @@ static int onenand_block_test(u32 start, u32 size)
 	u_char *buf;
 	u_char *verify_buf;
 	int ret;
+	int badblocklen = 0;
 
 	buf = malloc(blocksize);
 	if (!buf) {
@@ -219,13 +220,16 @@ static int onenand_block_test(u32 start, u32 size)
 		return -1;
 	}
 
+	/* Protect boot-loader and environment variables from badblock testing */
+	while (start < CONFIG_SYS_MONITOR_LEN + CONFIG_ENV_SIZE + badblocklen) {
+		if (mtd->block_isbad(&onenand_mtd, start))
+			badblocklen += blocksize;
+		start += blocksize;
+	}
+
 	start_block = start >> this->erase_shift;
 	end_block = (start + size) >> this->erase_shift;
 
-	/* Protect boot-loader from badblock testing */
-	if (start_block < 2)
-		start_block = 2;
-
 	if (end_block > (mtd->size >> this->erase_shift))
 		end_block = mtd->size >> this->erase_shift;
 
common/env_onenand.c +71 -25

131 lines not on this page · raw message

include/configs/apollon.h +1 -1
index 2e8198f..cf41e01 100644
@@ -75,7 +75,7 @@
 /*
  * Size of malloc() pool
  */
-#define	CONFIG_ENV_SIZE SZ_128K	/* Total Size of Environment Sector */
+#define	CONFIG_ENV_SIZE SZ_256K	/* Total Size of Environment Sector */
 #define	CONFIG_SYS_MALLOC_LEN	(CONFIG_ENV_SIZE + SZ_1M)
 /* bytes reserved for initial data */
 #define	CONFIG_SYS_GBL_DATA_SIZE	128
include/onenand_uboot.h +4 -0
index 49da9d0..dbac25b 100644
@@ -38,6 +38,10 @@ extern int onenand_erase(struct mtd_info *mtd, struct erase_info *instr);
 
 extern char *onenand_print_device_info(int device, int version);
 
+extern int onenand_block_isbad(struct mtd_info *mtd, loff_t ofs);
+
+extern int onenand_block_markbad(struct mtd_info *mtd, loff_t ofs);
+
 /* S3C64xx */
 extern void s3c64xx_onenand_init(struct mtd_info *);
 extern void s3c64xx_set_width_regs(struct onenand_chip *);
#18 lore raw

PATCH 1/1 Bad Block Capable environment for OneNAND

common/cmd_onenand.c static int onenand_block_test(u32 start, u32 size) · line 228

Quoted 6 lines · apgmoorthy
common/cmd_onenand.c +6 -0
+	/* Protect boot-loader and environment variables from badblock testing */
+	while (start < CONFIG_SYS_MONITOR_LEN + CONFIG_ENV_SIZE + badblocklen) {
+		if (mtd->block_isbad(&onenand_mtd, start))
+			badblocklen += blocksize;
+		start += blocksize;
+	}

You need to start at zero to determine the number of bad blocks used by the boot image -- otherwise, if start points in the middle of the image, it is assuming that there were no bad blocks prior to that location.

Plus, if "start" was not block-aligned (is that allowed?), this should round up to the next block rather than jumping to the middle of the next block.

common/env_onenand.c uchar env_get_char_spec(int index) · line 71

Quoted 12 lines
common/env_onenand.c +3 -2
+#define ONENAND_ENV_END   (CONFIG_SYS_MONITOR_LEN + CONFIG_ENV_SIZE)
+
 char *env_name_spec = "OneNAND";
 
 #ifdef ENV_IS_EMBEDDED
@@ -58,23 +68,31 @@ uchar env_get_char_spec(int index)
 
 void env_relocate_spec(void)
 {
-	unsigned long env_addr;
-	int use_default = 0;
+	unsigned long env_addr = CONFIG_SYS_MONITOR_LEN;

As above, you have to check for bad blocks from the beginning. You do this in saveenv...

common/env_onenand.c uchar env_get_char_spec(int index)

Quoted 9 lines
common/env_onenand.c +6 -1
+	int use_default = 1;
 	size_t retlen;
+	int blocksize = onenand_mtd.erasesize;
 
-	env_addr = CONFIG_ENV_ADDR;
+	/* Find environment block. */
+	while (onenand_mtd.writesize && (env_addr < ONENAND_ENV_END)) {
+		if (onenand_block_isbad(&onenand_mtd, env_addr)) {
+			printf("Skip bad block at 0x%x\n", (u32)env_addr);

Why not just use %lx?

common/env_onenand.c void env_relocate_spec(void) · line 132

Quoted 3 lines
common/env_onenand.c +3 -0
+	 /* update crc */
+	 env_ptr->crc =
+	     crc32(0, env_ptr->data, ONENAND_ENV_SIZE(onenand_mtd));

There's an extra space in the above indent.

common/env_onenand.c void env_relocate_spec(void) · line 162

Quoted 1 line
common/env_onenand.c +1 -0
+	 return 0;

Here too.

<record state="broken">
Any consolidation we can do between env_nand and env_onenand would be appreciated... even if they don't share code yet, let's keep the logic similar.
</record>

-Scott

author
#19 lore raw

[U-Boot] OneNand support broken for apollon

In reply to Scott Wood

On Apr 05, 2009 01:40 Jean-Christophe Wrote :

Quoted 3 lines

Your patch Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN brake the appolon
Could you take a look?

- Can you please do let me know , where exactly do you see a problem ?

With Regards
Moorthy