From: Rohit Hagargundgi <h.rohit@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2] Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN
Date: Mon, 09 Mar 2009 19:45:40 +0530 [thread overview]
Message-ID: <200903091945.40885.h.rohit@samsung.com> (raw)
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.
Signed-off-by: Rohit Hagargundgi <h.rohit@samsung.com>
---
onenand_ipl/onenand_read.c | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/onenand_ipl/onenand_read.c b/onenand_ipl/onenand_read.c
index 6d04943..c3b63ed 100644
--- a/onenand_ipl/onenand_read.c
+++ b/onenand_ipl/onenand_read.c
@@ -72,6 +72,10 @@ static inline int onenand_read_page(ulong block, ulong page,
while (!(READ_INTERRUPT() & ONENAND_INT_READ))
continue;
+ /* Check for invalid block mark*/
+ if (page < 2 && (onenand_readw(THIS_ONENAND(ONENAND_SPARERAM)) != 0xffff))
+ return 1;
+
#ifdef __HAVE_ARCH_MEMCPY32
/* 32 bytes boundary memory copy */
memcpy32(buf, base, pagesize);
@@ -87,6 +91,7 @@ static inline int onenand_read_page(ulong block, ulong page,
#define ONENAND_START_PAGE 1
#define ONENAND_PAGES_PER_BLOCK 64
+#define ONENAND_BLOCK_SIZE (ONENAND_PAGES_PER_BLOCK * ONENAND_PAGE_SIZE)
/**
* onenand_read_block - Read a block data to buf
@@ -94,20 +99,28 @@ static inline int onenand_read_page(ulong block, ulong page,
*/
int onenand_read_block0(unsigned char *buf)
{
- int page, offset = 0;
+ int block = 0, page = ONENAND_START_PAGE, offset = 0;
int pagesize = ONENAND_PAGE_SIZE;
+ int nblocks = CONFIG_SYS_MONITOR_LEN / ONENAND_BLOCK_SIZE;
/* MLC OneNAND has 4KiB page size */
- if (onenand_readw(THIS_ONENAND(ONENAND_REG_TECHNOLOGY)))
+ if (onenand_readw(THIS_ONENAND(ONENAND_REG_TECHNOLOGY))) {
pagesize <<= 1;
+ nblocks = (nblocks + 1) >> 1;
+ }
/* NOTE: you must read page from page 1 of block 0 */
/* read the block page by page*/
- for (page = ONENAND_START_PAGE;
- page < ONENAND_PAGES_PER_BLOCK; page++) {
-
- onenand_read_page(0, page, buf + offset, pagesize);
- offset += pagesize;
+ 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;
+ }
+ page = 0;
}
return 0;
next reply other threads:[~2009-03-09 14:15 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-09 14:15 Rohit Hagargundgi [this message]
2009-03-09 19:42 ` [U-Boot] [PATCH 1/2] Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN Scott Wood
-- strict thread matches above, loose matches on Subject: below --
2009-03-23 9:02 apgmoorthy
2009-03-23 21:25 ` Scott Wood
2009-03-23 22:09 ` Wolfgang Denk
2009-03-23 22:22 ` Scott Wood
2009-03-23 22:46 ` Wolfgang Denk
2009-03-25 4:13 ` Amit Kumar Sharma
2009-03-25 15:49 ` apgmoorthy
2009-03-27 9:15 ` apgmoorthy
2009-03-30 22:33 ` Scott Wood
2009-03-31 4:12 ` Amit Kumar Sharma
2009-03-31 16:08 ` Alessandro Rubini
2009-03-31 16:13 ` Scott Wood
2009-04-01 4:10 ` Amit Kumar Sharma
2009-04-01 21:55 ` Scott Wood
2009-04-12 7:55 ` apgmoorthy
2009-04-23 22:39 ` Scott Wood
2009-04-24 5:05 ` Amit Kumar Sharma
[not found] <22617689.32781240550892435.JavaMail.weblogic@epml08>
2009-04-24 5:57 ` Kyungmin Park
2009-04-24 15:21 ` Scott Wood
2009-04-24 21:47 ` Jean-Christophe PLAGNIOL-VILLARD
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=200903091945.40885.h.rohit@samsung.com \
--to=h.rohit@samsung.com \
--cc=u-boot@lists.denx.de \
/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