一、在U-Boot中建立自己的开发板类型,并测试编译。
我为开发板取名叫: tekkaman2410 --------------------------------------------------------------------------------
0 在工作目录下解压U-Boot。 $tar zxvf u-boot.git.tar.gz -------------------------------------------------------------------------------- 1 进入U-Boot目录,修改Makefile $cd u-boot.git/ $vi Makefile #为tekkaman2410建立编译项 smdk2410_config : unconfig
@$(MKCONFIG) $(@:_config=) arm arm920t smdk2410 NULL s3c24x0 tekkaman2410_config : unconfig
@$(MKCONFIG) $(@:_config=) arm arm920t tekkaman2410 tekkaman s3c24x0 各项的意思如下: arm: CPU的架构(ARCH) arm920t: CPU的类型(CPU),其对应于cpu/arm920t子目录。 tekkaman2410: 开发板的型号(BOARD),对应于board/tekkaman/tekkaman2410目录。 tekkaman: 开发者/或经销商(vender)。 s3c24x0: 片上系统(SOC)。 同时在“ifndef CROSS_COMPILE ”之前 加上自己交叉编译器的路径,比如我使用crosstool-0.43制作的基于2.6.22.2内核和gcc-4.1.0-glibc-2.3.2的ARM9TDMI交叉编译器,则:
CROSS_COMPILE=/home/tekkaman/working/crosstool-gcc410-k26222/gcc-4.1.0-glibc-2.3.2/arm-9tdmi-linux-gnu/bin/arm-9tdmi-linux-gnu-
--------------------------------------------------------------------------------
2 在/board子目录中建立自己的开发板tekkaman2410目录 由于我在上一步板子的开发者/或经销商(vender)中填了 tekkaman ,所以开发板tekkaman2410目录一定要建在/board子目录中的tekkaman目录下 ,否则编译会出错。
$cd board
$mkdir tekkaman tekkaman/tekkaman2410 $cp -arf smdk2410/* tekkaman/tekkaman2410/ $cd tekkaman/tekkaman2410 $mv smdk2410.c tekkaman2410.c 还要记得修改自己的开发板tekkaman2410目录下的Makefile文件,不然编译时会出错: COBJS := tekkaman2410.o flash.o $vi Makefile -------------------------------------------------------------------------------- 3 在include/configs/中建立配置头文件
$cd ../../.. $cp include/configs/smdk2410.h include/configs/tekkaman2410.h --------------------------------------------------------------------------------
4 测试编译能否成功
$make tekkaman2410_config Configuring for tekkaman2410 board... (如果出现: $ make tekkaman2410_config Makefile:1927: *** 遗漏分隔符 。 停止。 请在U-boot的根目录下的Makefile的 @$(MKCONFIG) $(@:_config=) arm arm920t tekkaman2410 tekkaman) 前加上“Tab”键) $make 我到这一步测试交叉编译成功!!
-------------------------------------------------------------------------------- -------------------------------------------------------------------------------- 二、修改U-Boot中的文件,以匹配博创的2410-S实验箱(网卡驱动有问题,以后有空一定解决)。
1 修改/cpu/arm920t/start.S (1)修改中断禁止部分
# if defined(CONFIG_S3C2410)
ldr r1, =0x7ff //根据2410芯片手册,INTSUBMSK有11位可用, //vivi也是0x7ff,不知为什么U-Boot一直没改过来。 ldr r0, =INTSUBMSK str r1, [r0] # endif --------------------------------------------------------------------------------
(2)修改时钟设置(可以不修改,因为后面的board_init函数也会将时钟设为202.8MHz)
/* FCLK:HCLK:PCLK = 1:2:4 */ /* default FCLK is 120 MHz ! */ ldr r0, =CLKDIVN mov r1, #3 str r1, [r0] mrc p15, 0, r1, c1, c0, 0 /*read ctrl register tekkaman*/
orr r1, r1, #0xc0000000 /*Asynchronous tekkaman*/ mcr p15, 0, r1, c1, c0, 0 /*write ctrl register tekkaman*/ /*now, CPU clock is 202.8 Mhz tekkaman*/
mov r1, #CLK_CTL_BASE /* tekkaman*/ mov r2, #MDIV_200 /* mpll_200mhz tekkaman*/ add r2, r2, #PSDIV_200 /* mpll_200mhz tekkaman*/ str r2, [r1, #0x04] /* MPLLCON tekkaman */ #endif /* CONFIG_S3C2400 || CONFIG_S3C2410 */
红色部分是我添加的,因为 U-Boot 使用的是 /* default FCLK is 120 MHz ! */
我利用博创提供的vivi的代码,将其设为202.8MHz 并在前面加上: #elif defined(CONFIG_S3C2410)
# define pWTCON 0x53000000 # define INTMSK 0x4A000008 /* Interupt-Controller base addresses */ # define INTSUBMSK 0x4A00001C # define CLKDIVN 0x4C000014 /* clock divisor register */ #define CLK_CTL_BASE 0x4C000000 /* tekkaman */ #define MDIV_200 0xa1 << 12 /* tekkaman */ #define PSDIV_200 0x31 /* tekkaman */ --------------------------------------------------------------------------------
(3)将从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 @tekkaman@@@@@@@@@@@@@@@@SSSSSSSSSSSSS
@ 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 @tekkaman@@@@@@@@@@@@@@@@@@EEEEEEEEE
在 “ _start_armboot: .word start_armboot ” 后加入:
.align 2 DW_STACK_START: .word STACK_BASE+STACK_SIZE-4 --------------------------------------------------------------------------------
附:顺便提一下,在start.S文件的注释部分有个小错误(红色部分:原来是2):
cpu_init_crit: ...... /* * disable MMU stuff and caches */ mrc p15, 0, r0, c1, c0, 0 bic r0, r0, #0x00002300 @ clear bits 13, 9:8 (--V- --RS) bic r0, r0, #0x00000087 @ clear bits 7, 2:0 (B--- -CAM) orr r0, r0, #0x00000002 @ set bit 1 (A) Align ...... --------------------------------------------------------------------------------
2 在board/tekkaman/tekkaman2410加入NAND Flash读函数,建立nand_read.c文件,加入如下内容(copy from vivi): #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 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; } -------------------------------------------------------------------------------- 3 修改board/tekkaman/tekkaman2410/Makefile文件 ...... OBJS := tekkaman2410.o nand_read.o ...... --------------------------------------------------------------------------------
4 修改include/configs/tekkaman2410.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 #endif /* __CONFIG_H */ --------------------------------------------------------------------------------
5 修改board/tekkaman/tekkaman2410/lowlevel_init.S文件 依照开发箱的内存区的配置情况, 修改board/tekkaman/tekkaman2410/lowlevel_init.S文件,我利用博创提供的vivi源码里的信息做了如下更改: ...... #define B1_BWSCON (DW16) /*@tekkaman*/ #define B2_BWSCON (DW16) #define B3_BWSCON (DW16) /*@tekkaman*/ #define B4_BWSCON (DW16) #define B5_BWSCON (DW16) #define B6_BWSCON (DW32) #define B7_BWSCON (DW32) ...... #define B3_Tacs 0x0 /* 0clk */ #define B3_Tcos 0x0 /* 0clk @tekkaman*/ #define B3_Tacc 0x7 /* 14clk */ #define B3_Tcoh 0x0 /* 0clk @tekkaman*/ #define B3_Tah 0x0 /* 0clk */ #define B3_Tacp 0x0 /*@tekkaman*/ #define B3_PMC 0x0 /* normal */ ...... 注:之所以Bank3的改动较大,是因为smdk2410的网卡是在Bank3,而博创的2410-S是在Bank2。至于AX88796的驱动,我现在还没搞定,以后搞定了一定上传。有那位大侠搞定了一定通知一声,小的不甚感激! ...... .word ((B7_MT<<15)+(B7_Trcd<<2)+(B7_SCAN)) .word ((REFEN<<23)+(TREFMD<<22)+(Trp<<20)+(Trc<<18)+(Tchr<<16)+REFCNT) .word 0xb2 /*@tekkaman*/ .word 0x30 .word 0x30 --------------------------------------------------------------------------------
6 修改/board/tekkaman/tekkaman2410/tekkaman2410.c 因为博创2410-S和smdk2410的GPIO连接有所不同,我依旧利用博创配的vivi,修改其对GPIO的配置(具体原因请参阅博创2410-S的硬件说明和2410芯片手册): ...... gpio->GPEUP = 0x0000FFFF; gpio->GPFCON = 0x000051aa; //0x000055AA; tekkaman gpio->GPFUP = 0x000000ef; //0x000000FF; tekkaman gpio->GPGCON = 0xfd95ffba; //0xFF95FFBA; tekkaman gpio->GPGUP = 0x0000efff; //0x0000FFFF; tekkaman gpio->GPHCON = 0x0016faaa; //0x002AFAAA; tekkaman gpio->GPHUP = 0x000007FF; ...... --------------------------------------------------------------------------------
7 为了实现NAND Flash的读写,再次修改/include/configs/tekkaman2410.h
(请格外注意:如果编译时报错,请在Linux用KWrite看看文件的注释是不是为灰色,如果不是,则将注释删除。因为#define后面的注释被认为是程序的一部分。建议注释和#define分行写) ...... /* * Hardware drivers */ //#define CONFIG_DRIVER_CS8900 1 /* we have a CS8900 on-board */ //#define CS8900_BASE 0x19000300 //#define CS8900_BUS16 1 /* the Linux driver does accesses as shorts */ #define CONFIG_DRIVER_NE2000 #define CONFIG_DRIVER_NE2000_BASE (0x10000000+0x200) ...... /***********************************************************
* Command definition ***********************************************************/ #define CONFIG_COMMANDS \ (CONFIG_CMD_DFL | \ CFG_CMD_CACHE | \ CFG_CMD_NAND | \ CFG_CMD_NET | \ /*CFG_CMD_EEPROM |*/ \ /*CFG_CMD_I2C |*/ \ /*CFG_CMD_USB |*/ \ CFG_CMD_PING | \ CFG_CMD_ENV | \ CFG_CMD_REGINFO | \ CFG_CMD_DATE | \ CFG_CMD_ELF) /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
......
#define CFG_LONGHELP
/* undef to save memory */ #define CFG_PROMPT "[Tekkaman2410]#" /*Monitor Command Prompt */ #define CFG_CBSIZE 256 /* Console I/O Buffer Size */ ...... #define CFG_LOAD_ADDR 0x30000000 /* default load address */ ......
//#define PHYS_FLASH_1 0x00000000 /* Flash Bank #1 */
//#define CFG_FLASH_BASE PHYS_FLASH_1
/*-----------------------------------------------------------------------
* FLASH and environment organization */ #define CFG_NO_FLASH 1 #if 0 #define CONFIG_AMD_LV400 1 /* uncomment this if you have a LV400 flash */ //#if 0 #define CONFIG_AMD_LV800 1 /* uncomment this if you have a LV800 flash */ #endif //#define CFG_MAX_FLASH_BANKS 1 /* max number of memory banks */
...... /* timeout values are in ticks */
//#define CFG_FLASH_ERASE_TOUT (5*CFG_HZ) /* Timeout for Flash Erase */ //#define CFG_FLASH_WRITE_TOUT (5*CFG_HZ) /* Timeout for Flash Write */ #define CFG_ENV_IS_IN_NAND 1
#define CFG_ENV_OFFSET 0X20000 //#define ENV_IS_EMBEDDED 1 #define CFG_NAND_LEGACY #define CFG_ENV_SIZE 0x10000
/* Total Size of Environment Sector */ #if (CONFIG_COMMANDS & CFG_CMD_NAND)
#define CFG_NAND_BASE 0x4E000000 /* NandFlash控制器在SFR区起始寄存器地址 */ #define CFG_MAX_NAND_DEVICE 1 /* 支持的最在Nand Flash数据 */ #define SECTORSIZE 512 /* 1页的大小 */ #define NAND_SECTOR_SIZE SECTORSIZE #define NAND_BLOCK_MASK 511 /* 页掩码 */ #define ADDR_COLUMN 1 /* 一个字节的Column地址 */ #define ADDR_PAGE 3 /* 3字节的页块地址!!!!!*/ #define ADDR_COLUMN_PAGE 4 /* 总共4字节的页块地址!!!!! */ #define NAND_ChipID_UNKNOWN 0x00 /* 未知芯片的ID号 */ #define NAND_MAX_FLOORS 1 #define NAND_MAX_CHIPS 1 /* Nand Flash命令层底层接口函数 */ #define WRITE_NAND_COMMAND(d, adr) {rNFCMD = d;} #define WRITE_NAND_ADDRESS(d, adr) {rNFADDR = d;} #define WRITE_NAND(d, adr) {rNFDATA = d;} #define READ_NAND(adr) (rNFDATA) #define NAND_WAIT_READY(nand) {while(!(rNFSTAT&(1<<0)));} #define NAND_DISABLE_CE(nand) {rNFCONF |= (1<<11);} #define NAND_ENABLE_CE(nand) {rNFCONF &= ~(1<<11);} /* the following functions are NOP's because S3C24X0 handles this in hardware 一定要加上 */
#define NAND_CTL_CLRALE(nandptr)
#define NAND_CTL_SETALE(nandptr)
#define NAND_CTL_CLRCLE(nandptr)
#define NAND_CTL_SETCLE(nandptr)
/* 允许Nand Flash写校验 */ #define CONFIG_MTD_NAND_VERIFY_WRITE 1 *
* 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 #define rNFCONF (*(volatile unsigned int *)0x4e000000)
#define rNFCMD (*(volatile unsigned char *)0x4e000004) #define rNFADDR (*(volatile unsigned char *)0x4e000008) #define rNFDATA (*(volatile unsigned char *)0x4e00000c) #define rNFSTAT (*(volatile unsigned int *)0x4e000010) #define rNFECC (*(volatile unsigned int *)0x4e000014) #define rNFECC0 (*(volatile unsigned char *)0x4e000014) #define rNFECC1 (*(volatile unsigned char *)0x4e000015) #define rNFECC2 (*(volatile unsigned char *)0x4e000016) #endif /* CONFIG_COMMANDS & CFG_CMD_NAND*/
#endif /* __CONFIG_H */
--------------------------------------------------------------------------------
8 在 include/linux/mtd/nand_ids.h的结构体nand_flash_ids加入
static struct nand_flash_dev nand_flash_ids[] = { ...... {"Samsung KM29N16000",NAND_MFR_SAMSUNG, 0x64, 21, 1, 2, 0x1000, 0}, {"Samsung K9F1208U0M", NAND_MFR_SAMSUNG, 0x76, 26, 0, 3, 0x4000, 0}, {"Samsung unknown 4Mb", NAND_MFR_SAMSUNG, 0x6b, 22, 0, 2, 0x2000, 0}, ...... {NULL,} }; --------------------------------------------------------------------------------
9 修改/lib_arm中的board.c。
static int display_banner (void) { printf ("\n\n%s\n\n", version_string); debug ("U-Boot code: %08lX -> %08lX BSS: -> %08lX\n", _armboot_start, _bss_start, _bss_end); printf ("U-Boot code: %08lX -> %08lX BSS: -> %08lX\n", //tekkaman _armboot_start, _bss_start, _bss_end); //tekkaman #ifdef CONFIG_MODEM_SUPPORT debug ("Modem Support enabled\n"); #endif #ifdef CONFIG_USE_IRQ debug ("IRQ Stack: %08lx\n", IRQ_STACK_START); debug ("FIQ Stack: %08lx\n", FIQ_STACK_START); #endif return (0);
} --------------------------------------------------------------------------------
10 修改common/env_nand.c
...... #ifdef CONFIG_INFERNO #error CONFIG_INFERNO not supported yet #endif int nand_legacy_rw (struct nand_chip* nand, int cmd,
size_t start, size_t len, size_t * retlen, u_char * buf); extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE]; extern int nand_legacy_erase(struct nand_chip *nand, size_t ofs, size_t len, int clean); /* info for NAND chips, defined in drivers/nand/nand.c */
extern nand_info_t nand_info[CFG_MAX_NAND_DEVICE]; ......
#else /* ! CFG_ENV_OFFSET_REDUND */
int saveenv(void) { ulong total; int ret = 0; puts ("Erasing Nand...");
//if (nand_erase(&nand_info[0], CFG_ENV_OFFSET, CFG_ENV_SIZE)) if (nand_legacy_erase(nand_dev_desc + 0, CFG_ENV_OFFSET, CFG_ENV_SIZE, 0))
return 1; puts ("Writing to Nand... "); total = CFG_ENV_SIZE; //ret = nand_write(&nand_info[0], CFG_ENV_OFFSET, &total, (u_char*)env_ptr); ret = nand_legacy_rw(nand_dev_desc + 0,
0x00 | 0x02, CFG_ENV_OFFSET, CFG_ENV_SIZE, &total, (u_char*)env_ptr); if (ret || total != CFG_ENV_SIZE)
return 1; puts ("done\n");
return ret; ...... #else /* ! CFG_ENV_OFFSET_REDUND */ /* * The legacy NAND code saved the environment in the first NAND device i.e., * nand_dev_desc + 0. This is also the behaviour using the new NAND code. */ void env_relocate_spec (void) { #if !defined(ENV_IS_EMBEDDED) ulong total; int ret; total = CFG_ENV_SIZE;
//ret = nand_read(&nand_info[0], CFG_ENV_OFFSET, &total, (u_char*)env_ptr); ret = nand_legacy_rw(nand_dev_desc + 0, 0x01 | 0x02, CFG_ENV_OFFSET, CFG_ENV_SIZE, &total, (u_char*)env_ptr); ......
--------------------------------------------------------------------------------
11 在/board/tekkaman/tekkaman2410/tekkaman2410.c文件的末尾添加对Nand Flash 的初始化函数(在后面Nand Flash的操作都要用到)
u-boot运行至第二阶段进入start_armboot()函数。其中nand_init()函数是对nand flash的最初初始化函数。Nand_init()函数在两个文件中实现。其调用与CFG_NAND_LEGACY宏有关,如果没有定义这个宏,系统调用 drivers/nnd/nand.c中的nand_init();否则调用自己在board/smdk2410/smdk2410.c中的nand_init()函数。这里我选择第二种方式。
#if (CONFIG_COMMANDS & CFG_CMD_NAND) typedef enum { NFCE_LOW, NFCE_HIGH } NFCE_STATE; static inline void NF_Conf(u16 conf) { S3C2410_NAND * const nand = S3C2410_GetBase_NAND(); nand->NFCONF = conf; } static inline void NF_Cmd(u8 cmd) { S3C2410_NAND * const nand = S3C2410_GetBase_NAND(); nand->NFCMD = cmd; } static inline void NF_CmdW(u8 cmd) { NF_Cmd(cmd); udelay(1); } static inline void NF_Addr(u8 addr) { S3C2410_NAND * const nand = S3C2410_GetBase_NAND(); nand->NFADDR = addr; } static inline void NF_SetCE(NFCE_STATE s) { S3C2410_NAND * const nand = S3C2410_GetBase_NAND(); switch (s) { case NFCE_LOW: nand->NFCONF &= ~(1<<11); break; case NFCE_HIGH: nand->NFCONF |= (1<<11); break; } } static inline void NF_WaitRB(void) { S3C2410_NAND * const nand = S3C2410_GetBase_NAND(); while (!(nand->NFSTAT & (1<<0))); } static inline void NF_Write(u8 data) { S3C2410_NAND * const nand = S3C2410_GetBase_NAND(); nand->NFDATA = data; } static inline u8 NF_Read(void) { S3C2410_NAND * const nand = S3C2410_GetBase_NAND(); return(nand->NFDATA); } static inline void NF_Init_ECC(void) { S3C2410_NAND * const nand = S3C2410_GetBase_NAND(); nand->NFCONF |= (1<<12); } static inline u32 NF_Read_ECC(void) { S3C2410_NAND * const nand = S3C2410_GetBase_NAND(); return(nand->NFECC); } #endif /* * NAND flash initialization.
*/ #if (CONFIG_COMMANDS & CFG_CMD_NAND) extern ulong nand_probe(ulong physadr); static inline void NF_Reset(void)
{ int i; NF_SetCE(NFCE_LOW); NF_Cmd(0xFF); /* reset command */ for(i = 0; i < 10; i++); /* tWB = 100ns. */ NF_WaitRB(); /* wait 200~500us; */ NF_SetCE(NFCE_HIGH); } static inline void NF_Init(void)
{ #if 0 /* a little bit too optimistic */ #define TACLS 0 #define TWRPH0 3 #define TWRPH1 0 #else #define TACLS 0 #define TWRPH0 4 #define TWRPH1 2 #endif NF_Conf((1<<15)|(0<<14)|(0<<13)|(1<<12)|(1<<11)|(TACLS<<8)|(TWRPH0<<4)|(TWRPH1<<0)); /*nand->NFCONF = (1<<15)|(1<<14)|(1<<13)|(1<<12)|(1<<11)|(TACLS<<8)|(TWRPH0<<4)|(TWRPH1<<0); */ /* 1 1 1 1, 1 xxx, r xxx, r xxx */ /* En 512B 4step ECCR nFCE=H tACLS tWRPH0 tWRPH1 */ NF_Reset(); } void nand_init(void) { S3C2410_NAND * const nand = S3C2410_GetBase_NAND(); NF_Init(); #ifdef DEBUG printf("NAND flash probing at 0x%.8lX\n", (ulong)nand); #endif printf ("%4lu MB\n", nand_probe((ulong)nand) >> 20); } #endif -------------------------------------------------------------------------------- 12 修正U-Boot的NE2000驱动的低级错误(虽然暂时驱动还有问题,但还是先编进去,以后改好了再make就好了) 将第45行: at */ 真是TNND汗死!!!!
--------------------------------------------------------------------------------
13 因为没有Nor Flash芯片,所以注释掉/common/cmd_bootm.c中关于imls命令的程序段和/common/cmd_flash.c中的程序。不然,按上面的修改,编译会出错。 /common/cmd_bootm.c第91行:(“0”后面一定要换行!!!不然还会错!!!)
#if 0 (CONFIG_COMMANDS & CFG_CMD_IMLS) #include <flash.h> extern flash_info_t flash_info[]; /* info for FLASH chips */ static int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); #endif /common/cmd_bootm.c第1237行:(“0”后面一定要换行!!!不然还会错!!!)
#if 0 (CONFIG_COMMANDS & CFG_CMD_IMLS) /*----------------------------------------------------------------------- * List all images found in flash. */ int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { flash_info_t *info; int i, j; image_header_t *hdr; ulong data, len, checksum; for (i=0, info=&flash_info[0]; i<CFG_MAX_FLASH_BANKS; ++i, ++info) {
if (info->flash_id == FLASH_UNKNOWN) ...... /common/cmd_flash.c开头几行:(“0”后面一定要换行!!!不然还会错!!!)
......
#if 0 (CONFIG_COMMANDS & CFG_CMD_FLASH) #if (CONFIG_COMMANDS & CFG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
#include <jffs2/jffs2.h> ...... --------------------------------------------------------------------------------
-------------------------------------------------------------------------------- 三、交叉编译U-Boot。 在U-Boot的根目录下 $make 一阵English飘过~~~~~~~~~~~~~~~~~~~~~~~ 严格按上面的修改,应该是会成功的,因为我本着认真负责的态度,按上面的步骤又做了一遍,改了一遍,且编译成功。 如果你还遇到错误,可以找我讨论 QQ:78027228。 不过我建议:在看懂U-Boot的基础上移植,不然当有错误时你会狂郁闷,不知如何下手! 声明:tftp相关命令有问题,因为NE2000的驱动还没改过,以后。。。
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/hongjiujing/archive/2007/09/19/1790834.aspx
|
|