diff --git a/qiboot/Makefile b/qiboot/Makefile index 4d7bb46..bfd6245 100644 --- a/qiboot/Makefile +++ b/qiboot/Makefile @@ -14,10 +14,46 @@ # MA 02111-1307 USA # -all : - cd src ; make all +include config.mk + +LDS = src/kboot-stage1.lds +INCLUDE = include +IMAGE_DIR = image +#CFLAGS = -Wall -I $(INCLUDE) -msoft-float -g -c +CFLAGS = -Wall -I $(INCLUDE) -g -c +LDFLAGS = +#START = start.o lowlevel_init.o +S_SRCS = src/start.S src/lowlevel_init.S +S_OBJS = $(patsubst %.S,%.o, $(S_SRCS)) +C_SRCS = $(wildcard src/*.c) +C_OBJS = $(patsubst %.c,%.o, $(C_SRCS)) + +#SRCS := $(START: .o=.S) $(COBJS: .o=.c) +SRCS = ${S_SRCS} ${C_SRCS} +OBJS = ${S_OBJS} ${C_OBJS} + +TARGET = src/start_kboot_all +IMAGE = $(IMAGE_DIR)/start + +%.o: %.S + @$(CC) $(CFLAGS) -o $@ $< + +%.o: %.c + @$(CC) $(CFLAGS) -o $@ $< + +all:${TARGET} + +${OBJS}:${SRCS} + +${TARGET}:${OBJS} + $(LD) ${LDFLAGS} -T$(LDS) -g $(OBJS) -o ${TARGET} + $(OBJCOPY) -O binary -S ${TARGET} ${IMAGE} + $(OBJDUMP) -D ${TARGET} >${IMAGE}.dis + +blink_led:src/led_on.S + $(CC) $(CFLAGS) led_on.o led_on.S + $(LD) -g led_on.o -o led_on_temp.o + $(OBJCOPY) -O binary -S led_on_temp.o $(IMAGE)/led_on clean: - cd src ; make clean - - + rm -f src/*.o src/*~ ${IMAGE}* ${TARGET} diff --git a/qiboot/config.mk b/qiboot/config.mk index b45478e..52c0148 100644 --- a/qiboot/config.mk +++ b/qiboot/config.mk @@ -1,6 +1,7 @@ # # Include the make variables (CC, etc...) # +#CROSS_COMPILE=arm-softfloat-linux-gnu- CROSS_COMPILE=arm-angstrom-linux-gnueabi- AS = $(CROSS_COMPILE)as diff --git a/qiboot/include/blink_led.h b/qiboot/include/blink_led.h new file mode 100644 index 0000000..8485404 --- /dev/null +++ b/qiboot/include/blink_led.h @@ -0,0 +1,41 @@ +/* + * (C) Copyright 2007 OpenMoko, Inc. + * Author: xiangfu liu + * + * 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 + */ + +#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(void); + +#endif /* __BLINK_LED_H */ diff --git a/qiboot/include/nand_read.h b/qiboot/include/nand_read.h new file mode 100644 index 0000000..71aeda5 --- /dev/null +++ b/qiboot/include/nand_read.h @@ -0,0 +1,22 @@ +/* + * 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 + * Date : $Date: 2004/02/04 10:37:37 $ + * + * u-boot integration and bad-block skipping (C) 2006 by OpenMoko, Inc. + * Author: Harald Welte + */ +#ifndef __NAND_READ_H +#define __NAND_READ_H + +int nand_read_ll(unsigned char *buf, unsigned long start_addr, int size); + +#endif /* __NAND_READ_H */ diff --git a/qiboot/include/serial.h b/qiboot/include/serial.h new file mode 100644 index 0000000..053c712 --- /dev/null +++ b/qiboot/include/serial.h @@ -0,0 +1,32 @@ +/* + * (C) Copyright 2007 OpenMoko, Inc. + * Author: xiangfu liu + * + * 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 + */ + +#define rUTXH0 (*(volatile unsigned char *)0x50000023) +#define UTRSTAT (*(volatile unsigned char *)0x50000010) + +/* +#define PUT_CHAR() (rUTXH0 +#define ORANGE_OFF() (GPBDAT &= ~(0x1)) +*/ + +void serial_puti (const int i); + diff --git a/qiboot/src/blink_led.c b/qiboot/src/blink_led.c index ed906aa..fa4482e 100644 --- a/qiboot/src/blink_led.c +++ b/qiboot/src/blink_led.c @@ -66,7 +66,7 @@ int blue_on(int times) return 0; } -int blink_led() +int blink_led(void) { set_GPB(); diff --git a/qiboot/src/kboot-stage1.lds b/qiboot/src/kboot-stage1.lds index 6393fdb..8cc49f6 100644 --- a/qiboot/src/kboot-stage1.lds +++ b/qiboot/src/kboot-stage1.lds @@ -32,23 +32,35 @@ SECTIONS . = ALIGN(4); .text : { - start.o (.text) - lowlevel_init.o(.text) - start_kboot.o (.text) + src/start.o (.text) + src/lowlevel_init.o(.text) + src/start_kboot.o (.text) *(.text) } . = ALIGN(4); - .rodata : { *(.rodata) } + .rodata : + { + *(.rodata) + } . = ALIGN(4); - .data : { *(.data) } + .data : + { + *(.data) + } . = ALIGN(4); - .got : { *(.got) } + .got : + { + *(.got) + } . = ALIGN(4); __bss_start = .; - .bss : { *(.bss) } + .bss : + { + *(.bss) + } _end = .; } diff --git a/qiboot/src/serial.c b/qiboot/src/serial.c new file mode 100644 index 0000000..66fe066 --- /dev/null +++ b/qiboot/src/serial.c @@ -0,0 +1,33 @@ +/* + * (C) Copyright 2007 OpenMoko, Inc. + * Author: xiangfu liu + * + * 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 + */ + +# include + +/* + * Output a single byte to the serial port. + */ +void serial_puti (const int i) +{ + while (!(UTRSTAT & 0x2)); + + rUTXH0 |= i; +} diff --git a/qiboot/src/start_kboot.c b/qiboot/src/start_kboot.c index f1f8bec..935be30 100644 --- a/qiboot/src/start_kboot.c +++ b/qiboot/src/start_kboot.c @@ -21,6 +21,7 @@ */ #include "blink_led.h" #include "nand_read.h" +#include "serial.h" /* unsigned char buf[]={ 0x0d,0xc0,0xa0,0xe1,0x00,0xd8,0x2d,0xe9,0x04,0xb0,0x4c,0xe2,0x4c,0x20,0x9f,0xe5, @@ -36,14 +37,19 @@ unsigned char buf[2048]; #define ADDR ((volatile unsigned *)&buf) -int start_kboot() +int start_kboot(void) { - if(nand_read_ll(buf, 0x32000000, sizeof(buf))==-1) - { - while(1){blink_led(1);} + /*1 say hello to uart */ + serial_puti (123); + blue_on(1); + /*2. test nand flash */ + if(nand_read_ll(buf, 0x40000, sizeof(buf))==-1) { + while(1) { + blink_led(); + } } - asm volatile("mov pc, %0\n" + asm volatile("mov pc, %0\n" : /* output */ :"r"(ADDR) /* input */ );