mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2024-11-01 10:22:48 +02:00
try to debug the nand_read
This commit is contained in:
parent
05afbb65a7
commit
12ba156cfb
@ -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<time;i++);
|
||||
return 0;
|
||||
int i=0;
|
||||
for(i=0;i<time;i++);
|
||||
return 0;
|
||||
}
|
||||
int set_GPB()
|
||||
{
|
||||
GPBCON = 0x5;
|
||||
GPBDW = 0xffff;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int orange_on(int times)
|
||||
{
|
||||
int count=0;
|
||||
set_GPB();
|
||||
|
||||
for(count=0;count<times;count++)
|
||||
{
|
||||
ORANGE_ON();
|
||||
delay(0xfffff);
|
||||
ORANGE_OFF() ;
|
||||
delay(0xfffff);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int blue_on(int times)
|
||||
{
|
||||
int count=0;
|
||||
set_GPB();
|
||||
|
||||
for(count=0;count<times;count++)
|
||||
{
|
||||
BLUE_ON();
|
||||
delay(0xfffff);
|
||||
BLUE_OFF();
|
||||
delay(0xfffff);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int blink_led()
|
||||
{
|
||||
GPBCON = 0x5;
|
||||
GPBDW = 0xffff;
|
||||
while(1)
|
||||
{
|
||||
LED3_ON();
|
||||
delay(0xfffff);
|
||||
LED3_OFF() ;
|
||||
delay(0xfffff);
|
||||
set_GPB();
|
||||
|
||||
LED4_ON();
|
||||
delay(0xfffff);
|
||||
LED4_OFF();
|
||||
delay(0xfffff);
|
||||
while(1)
|
||||
{
|
||||
ORANGE_ON();
|
||||
delay(0xfffff);
|
||||
ORANGE_OFF() ;
|
||||
delay(0xfffff);
|
||||
|
||||
BLUE_ON();
|
||||
delay(0xfffff);
|
||||
BLUE_OFF();
|
||||
delay(0xfffff);
|
||||
}
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,6 +23,19 @@
|
||||
#ifndef __BLINK_LED_H
|
||||
#define __BLINK_LED_H
|
||||
|
||||
#define GPBCON (*(volatile unsigned *)0x56000010)
|
||||
#define GPBDAT (*(volatile unsigned *)0x56000014)
|
||||
#define GPBDW (*(volatile unsigned *)0x56000018)
|
||||
#define ORANGE_OFF() (GPBDAT &= ~(0x1))
|
||||
#define BLUE_OFF() (GPBDAT &= ~(0x2))
|
||||
#define ORANGE_ON() (GPBDAT |= (0x1))
|
||||
#define BLUE_ON() (GPBDAT |= (0x2))
|
||||
|
||||
#define ORANGE 1;
|
||||
#define BLUE 0;
|
||||
|
||||
int orange_on(int times);
|
||||
int blue_on(int times);
|
||||
int blink_led();
|
||||
|
||||
#endif /* __BLINK_LED_H */
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <linux/mtd/nand.h>
|
||||
*/
|
||||
#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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user