|
楼主 |
发表于 2008-2-26 12:29:56
|
显示全部楼层
1. 下载u-boot-1.1.4.tar.bz2,并解压
2. 将arm-linux-2.95.3复制到/usr/local/arm/2.95.3/
3. 编辑u-boot跟目录的Makefile文件
- include $(TOPDIR)/config.mk
- CROSS_COMPILE=/usr/local/arm/2.95.3/bin/arm-linux-
- ifndef CROSS_COMPILE
复制代码
- smdk2410_config : unconfig
- @./mkconfig $(@:_config=) arm arm920t smdk2410 NULL s3c24x0
- sky2410_config : unconfig
- @./mkconfig $(@:_config=) arm arm920t sky2410 NULL s3c24x0
- SX1_config : unconfig
- @./mkconfig $(@:_config=) arm arm925t sx1
复制代码
4. 复制必要的文件
cp -arf board/smdk2410/ board/sky2410
mv board/sky2410/smdk2410.c board/sky2410/sky2410.c
cp include/configs/smdk2410.h include/configs/sky2410.h
5. 修改board/sky2410/Makefile
- LIB = lib$(BOARD).a
- OBJS := sky2410.o flash.o
- SOBJS := lowlevel_init.o
复制代码
6. make 测试一下
make sky2410_config
make
出现错误
cc1: Invalid option `abi=apcs-gnu'
修改文件cpu/arm920t/config.mk
- PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
复制代码
改成:
- PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,$(call cc-option,-mabi=apcs-gnu),)
复制代码
再make成功
7. 开始移植nand
修改cpu/arm920t/start.S
将从Flash启动改成从NAND Flash启动。
将以下U-Boot的重定向语句段:
- #ifndef CONFIG_SKIP_RELOCATE_UBOOT
- relocate: /* relocate U-Boot to RAM */
- adr r0, _start /* r0 <- current position of code */
- ldr r1, _TEXT_BASE /* test if we run from flash or RAM */
- cmp r0, r1 /* don't reloc during debug */
- beq stack_setup
- ldr r2, _armboot_start
- ldr r3, _bss_start
- sub r2, r3, r2 /* r2 <- size of armboot */
- add r2, r0, r2 /* r2 <- source end address */
- copy_loop:
- ldmia r0!, {r3-r10} /* copy from source address [r0] */
- stmia r1!, {r3-r10} /* copy to target address [r1] */
- cmp r0, r2 /* until source end addreee [r2] */
- ble copy_loop
- #endif /* CONFIG_SKIP_RELOCATE_UBOOT */
复制代码
替换成:
- #ifdef CONFIG_S3C2410_NAND_BOOT
- @ reset NAND
- mov r1, #NAND_CTL_BASE
- ldr r2, =0xf830 @ initial value
- str r2, [r1, #oNFCONF]
- ldr r2, [r1, #oNFCONF]
- bic r2, r2, #0x800 @ enable chip
- str r2, [r1, #oNFCONF]
- mov r2, #0xff @ RESET command
- strb r2, [r1, #oNFCMD]
- mov r3, #0 @ wait
- nand1:
- add r3, r3, #0x1
- cmp r3, #0xa
- blt nand1
- nand2:
- ldr r2, [r1, #oNFSTAT] @ wait ready
- tst r2, #0x1
- beq nand2
- ldr r2, [r1, #oNFCONF]
- orr r2, r2, #0x800 @ disable chip
- str r2, [r1, #oNFCONF]
- @ get read to call C functions (for nand_read())
- ldr sp, DW_STACK_START @ setup stack pointer
- mov fp, #0 @ no previous frame, so fp=0
- @ copy U-Boot to RAM
- ldr r0, =TEXT_BASE
- mov r1, #0x0
- mov r2, #0x20000
- bl nand_read_ll
- tst r0, #0x0
- beq ok_nand_read
- bad_nand_read:
- loop2: b loop2 @ infinite loop
- ok_nand_read:
- @ verify
- mov r0, #0
- ldr r1, =TEXT_BASE
- mov r2, #0x400 @ 4 bytes * 1024 = 4K-bytes
- go_next:
- ldr r3, [r0], #4
- ldr r4, [r1], #4
- teq r3, r4
- bne notmatch
- subs r2, r2, #4
- beq stack_setup
- bne go_next
- notmatch:
- loop3: b loop3 @ infinite loop
- #endif /* CONFIG_S3C2410_NAND_BOOT */
复制代码
在 “ _start_armboot: .word start_armboot ” 后加入:
- .align 2
- DW_STACK_START: .word STACK_BASE+STACK_SIZE-4
复制代码
8.
(I)修改board/sky2410/Makefile
OBJS := sky2410.o flash.o nand_read.o
(II)创建board/sky2410/nand_read.c文件
- #include <config.h>
- #define __REGb(x) (*(volatile unsigned char *)(x))
- #define __REGi(x) (*(volatile unsigned int *)(x))
- #define NF_BASE 0x4e000000
- #define NFCONF __REGi(NF_BASE + 0x0)
- #define NFCMD __REGb(NF_BASE + 0x4)
- #define NFADDR __REGb(NF_BASE + 0x8)
- #define NFDATA __REGb(NF_BASE + 0xc)
- #define NFSTAT __REGb(NF_BASE + 0x10)
- #define BUSY 1
- #ifndef NAND_SECTOR_SIZE
- #define NAND_SECTOR_SIZE 512
- #endif
- #ifndef
- #define NAND_BLOCK_MASK 511
- #endif
- inline void wait_idle(void) {
- int i;
- while(!(NFSTAT & BUSY))
- for(i=0; i<10; i++);
- }
- /* low level nand read function */
- int
- nand_read_ll(unsigned char *buf, unsigned long start_addr, int size)
- {
- int i, j;
- if ((start_addr & NAND_BLOCK_MASK) || (size & NAND_BLOCK_MASK)) {
- return -1; /* invalid alignment */
- }
- /* chip Enable */
- NFCONF &= ~0x800;
- for(i=0; i<10; i++);
- for(i=start_addr; i < (start_addr + size);) {
- /* READ0 */
- NFCMD = 0;
- /* Write Address */
- NFADDR = i & 0xff;
- NFADDR = (i >> 9) & 0xff;
- NFADDR = (i >> 17) & 0xff;
- NFADDR = (i >> 25) & 0xff;
- wait_idle();
- for(j=0; j < NAND_SECTOR_SIZE; j++, i++) {
- *buf = (NFDATA & 0xff);
- buf++;
- }
- }
- /* chip Disable */
- NFCONF |= 0x800; /* chip disable */
- return 0;
- }
复制代码
9.修改include/configs/sky2410.h
在文件的后部添加
- /*
- * Nandflash Boot
- */
- #define CONFIG_S3C2410_NAND_BOOT 1
- #define STACK_BASE 0x33f00000
- #define STACK_SIZE 0x8000
- //#define UBOOT_RAM_BASE 0x33f80000
- /* NAND Flash Controller */
- #define NAND_CTL_BASE 0x4E000000
- #define bINT_CTL(Nb) __REG(INT_CTL_BASE + (Nb))
- /* Offset */
- #define oNFCONF 0x00
- #define oNFCMD 0x04
- #define oNFADDR 0x08
- #define oNFDATA 0x0c
- #define oNFSTAT 0x10
- #define oNFECC 0x14
复制代码
10.
make 测试一下啊
到这里 u-boot 已经可以从nand启动了
[ 本帖最后由 zbluecn 于 2008-3-3 17:18 编辑 ] |
|