1
0
mirror of git://projects.qi-hardware.com/xburst-tools.git synced 2024-11-01 10:15:19 +02:00

file a way to debug the nand_read.c

if it's work the one led will be always on
if something wrong blink two led under Power Button
This commit is contained in:
xiangfu 2008-07-12 22:57:57 -04:00
parent fa9c4976fa
commit 50aa233b9a
6 changed files with 82 additions and 14 deletions

View File

@ -22,7 +22,7 @@ IMAGE = ../image
CFLAGS = -Wall -I $(INCLUDE) -g -c -o
START = start.o lowlevel_init.o
COBJS = start_kboot.o nand_read.o
COBJS = start_kboot.o nand_read.o blink_led.o
SRCS := $(START: .o=.S) $(COBJS: .o=.c)
@ -30,6 +30,7 @@ all:start.S lowlevel_init.S nand_read.c start_kboot.c
$(CC) $(CFLAGS) start.o start.S
$(CC) $(CFLAGS) lowlevel_init.o lowlevel_init.S
$(CC) $(CFLAGS) nand_read.o nand_read.c
$(CC) $(CFLAGS) blink_led.o blink_led.c
$(CC) $(CFLAGS) start_kboot.o start_kboot.c
$(LD) -T$(LDS) -g $(START) $(COBJS) -o start_kboot_all.o
$(OBJCOPY) -O binary -S start_kboot_all.o $(IMAGE)/start

View File

@ -19,6 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#include "blink_led.h"
#define GPBCON (*(volatile unsigned *)0x56000010)
#define GPBDAT (*(volatile unsigned *)0x56000014)
#define GPBDW (*(volatile unsigned *)0x56000018)

23
qiboot/src/blink_led.h Normal file
View File

@ -0,0 +1,23 @@
/*
* (C) Copyright 2007 OpenMoko, Inc.
* Author: xiangfu liu <xiangfu@openmoko.org>
*
* Configuation settings for the FIC Neo GTA02 Linux GSM phone
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
int blink_led();

View File

@ -15,10 +15,12 @@
* Author: Harald Welte <laforge@openmoko.org>
*/
/*#include <common.h>
#include <linux/mtd/nand.h>
*/
#include "nand_read.h"
#define NAND_CMD_READ0 0
#define NAND_CMD_READ1 1
/* Extended commands for large page devices */
#define NAND_CMD_READSTART 0x30
#define __REGb(x) (*(volatile unsigned char *)(x))
@ -39,7 +41,8 @@
static inline void nand_wait(void)
{
int i=0;
int i;
while (!(NFSTAT & NFSTAT_BUSY))
for (i=0; i<10; i++);
}
@ -49,7 +52,7 @@ static inline void nand_wait(void)
#define NAND_PAGE_SIZE 2048
#define BAD_BLOCK_OFFSET NAND_PAGE_SIZE
#define NAND_BLOCK_MASK (NAND_PAGE_SIZE - 1)
#define NAND_BLOCK_SIZE (NAND_PAGE_SIZE * 64)#endif
#define NAND_BLOCK_SIZE (NAND_PAGE_SIZE * 64)
static int is_bad_block(unsigned long i)
{
@ -81,6 +84,7 @@ static int nand_read_page_ll(unsigned char *buf, unsigned long addr)
nand_clear_RnB();
NFCMD = NAND_CMD_READ0;
page_num = addr >> 11; /* addr / 2048 */
/* Write Address */
NFADDR = 0;
@ -95,11 +99,12 @@ static int nand_read_page_ll(unsigned char *buf, unsigned long addr)
*ptr16 = NFDATA16;
ptr16++;
}
return NAND_PAGE_SIZE;
}
/* low level nand read function */
int nand_read_ll(unsigned char *buf, unsigned long start_addr, int size)
int nand_read_ll(unsigned char *buf, unsigned long start_addr, int size)
{
int i, j;
@ -112,6 +117,17 @@ static int nand_read_page_ll(unsigned char *buf, unsigned long addr)
for (i=0; i<10; i++);
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)) {
/* Bad block */
i += NAND_BLOCK_SIZE;
size += NAND_BLOCK_SIZE;
continue;
}
}
j = nand_read_page_ll(buf, i);
i += j;
buf += j;
@ -122,3 +138,4 @@ static int nand_read_page_ll(unsigned char *buf, unsigned long addr)
return 0;
}

18
qiboot/src/nand_read.h Normal file
View File

@ -0,0 +1,18 @@
/*
* nand_read.c: Simple NAND read functions for booting from NAND
*
* This is used by cpu/arm920/start.S assembler code,
* and the board-specific linker script must make sure this
* file is linked within the first 4kB of NAND flash.
*
* Taken from GPLv2 licensed vivi bootloader,
* Copyright (C) 2002 MIZI Research, Inc.
*
* Author: Hwang, Chideok <hwang@mizi.com>
* Date : $Date: 2004/02/04 10:37:37 $
*
* u-boot integration and bad-block skipping (C) 2006 by OpenMoko, Inc.
* Author: Harald Welte <laforge@openmoko.org>
*/
int nand_read_ll(unsigned char *buf, unsigned long start_addr, int size);

View File

@ -19,7 +19,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#include "blink_led.h"
#include "nand_read.h"
/*
unsigned char buf[]={
0x0d,0xc0,0xa0,0xe1,0x00,0xd8,0x2d,0xe9,0x04,0xb0,0x4c,0xe2,0x4c,0x20,0x9f,0xe5,
0x05,0x30,0xa0,0xe3,0x00,0x30,0x82,0xe5,0x44,0x20,0x9f,0xe5,0x44,0x30,0x9f,0xe5,
@ -29,16 +31,22 @@ unsigned char buf[]={
0x00,0x30,0x82,0xe5,0x0c,0x00,0x9f,0xe5,0x04,0x00,0x00,0xeb,0xf0,0xff,0xff,0xea,
0x10,0x00,0x00,0x56,0x18,0x00,0x00,0x56,0xff,0xff,0x00,0x00,0x14,0x00,0x00,0x56,
0x01,0x00,0x50,0xe2,0xfd,0xff,0xff,0x1a,0x0e,0xf0,0xa0,0xe1,0x0a};
*/
unsigned char buf[124];
#define ADDR ((volatile unsigned *)&buf)
int start_kboot()
{
/* nand_read_ll(buf, 0, sizeof(buf));*/
if(nand_read_ll(buf, 0, sizeof(buf))==-1) {
blink_led();
}
/*
void (*fp)(void)=(void (*)(void))&buf;
(fp)();
*/
asm volatile("mov pc, %0\n"
: /* output */
:"r"(ADDR) /* input */