From 12ba156cfbeef221771540561ca8c194fd1f61d8 Mon Sep 17 00:00:00 2001 From: xiangfu Date: Sun, 13 Jul 2008 13:20:35 -0400 Subject: [PATCH] try to debug the nand_read --- qiboot/src/blink_led.c | 80 ++++++++++++++++++++++++++++------------ qiboot/src/blink_led.h | 13 +++++++ qiboot/src/nand_read.c | 54 +++++++++++++-------------- qiboot/src/start_kboot.c | 12 ++---- 4 files changed, 101 insertions(+), 58 deletions(-) diff --git a/qiboot/src/blink_led.c b/qiboot/src/blink_led.c index bd43a52..ed906aa 100644 --- a/qiboot/src/blink_led.c +++ b/qiboot/src/blink_led.c @@ -20,36 +20,70 @@ * MA 02111-1307 USA */ #include "blink_led.h" -#define GPBCON (*(volatile unsigned *)0x56000010) -#define GPBDAT (*(volatile unsigned *)0x56000014) -#define GPBDW (*(volatile unsigned *)0x56000018) -#define LED3_ON() (GPBDAT &= ~(0x1)) -#define LED4_ON() (GPBDAT &= ~(0x2)) -#define LED3_OFF() (GPBDAT |= (0x1)) -#define LED4_OFF() (GPBDAT |= (0x2)) int delay(int time) { - int i=0; - for(i=0;i */ #include "nand_read.h" +#include "blink_led.h" #define NAND_CMD_READ0 0 #define NAND_CMD_READSTART 0x30 @@ -106,36 +107,35 @@ static int nand_read_page_ll(unsigned char *buf, unsigned long addr) /* low level nand read function */ int nand_read_ll(unsigned char *buf, unsigned long start_addr, int size) { - int i, j; + int i, j; - if ((start_addr & NAND_BLOCK_MASK) || (size & NAND_BLOCK_MASK)) - return -1; /* invalid alignment */ + if ((start_addr & NAND_BLOCK_MASK) || (size & NAND_BLOCK_MASK)) + return -1; /* invalid alignment */ - /* chip Enable */ - nand_select(); - nand_clear_RnB(); - for (i=0; i<10; i++); + /* chip Enable */ + nand_select(); + nand_clear_RnB(); + for (i=0; i<10; i++); - for (i=start_addr; i < (start_addr + size);) { + for (i=start_addr; i < (start_addr + size);) { + if (i % NAND_BLOCK_SIZE == 0) { + if (is_bad_block(i) || + is_bad_block(i + NAND_PAGE_SIZE)) { + orange_on(1); + i += NAND_BLOCK_SIZE; + size += NAND_BLOCK_SIZE; + continue; + } + } + blue_on(1); + j = nand_read_page_ll(buf, i); + i += j; + /* buf += j;*/ + } - if (i % NAND_BLOCK_SIZE == 0) { - if (is_bad_block(i) || - is_bad_block(i + NAND_PAGE_SIZE)) { - /* Bad block */ - i += NAND_BLOCK_SIZE; - size += NAND_BLOCK_SIZE; - continue; - } - } - - j = nand_read_page_ll(buf, i); - i += j; - buf += j; - } - - /* chip Disable */ - nand_deselect(); - - return 0; + /* chip Disable */ + nand_deselect(); + + return 0; } diff --git a/qiboot/src/start_kboot.c b/qiboot/src/start_kboot.c index 70b262d..f1f8bec 100644 --- a/qiboot/src/start_kboot.c +++ b/qiboot/src/start_kboot.c @@ -38,19 +38,15 @@ unsigned char buf[2048]; int start_kboot() { - if(nand_read_ll(buf, 0x32000000, sizeof(buf))==-1) { - blink_led(); + if(nand_read_ll(buf, 0x32000000, sizeof(buf))==-1) + { + while(1){blink_led(1);} } - /* - void (*fp)(void)=(void (*)(void))&buf; - (fp)(); - */ - asm volatile("mov pc, %0\n" : /* output */ :"r"(ADDR) /* input */ ); + return 0; } -