1、uboot for yangchu总结U-BOOT FOR 阳初2410 v2.3 BY wmmwang 8/29/2007工作环境: RedHat Linux 9交叉编译器: 自己编译的交叉编译器arm-linux-gcc 4.1.1(glibc2.3.2)U-BOOT版本: 1.2.0目标板: 阳初2410开发板,v2.3版此文包含4部分:1、NAND FLASH启动部分2、NAND FLASH驱动部分3、SAVEENV到NAND FLASH部分4、UBOOT引导内核部分参考文章:1、 NAND FLASH启动部分: 2、 NAND FLASH驱动部分: 3、 SAVEENV到NAND F
2、LASH部分: 注意文中的红色部分,为添加或修改或值得注意部分!前奏:1、建立阳初2410的配置: (1)拷贝board/smdk2410到board/yangchu2410; (2)拷贝include/configs/smdk2410.h到include/configs/yangchu2410.h2、修改文件: (1)include/configs/yangchu2410.h: 修改: # define CFG_PROMPT “SMDK2410#” 为: # define CFG_PROMPT “YANGCHU2410#” (2)Makefile: smdk2410_config : unc
3、onfig $(MKCONFIG) $(:_config=) arm arm920t smdk2410 NULL s3c24x0yangchu2410_config : unconfig $(MKCONFIG) $(:_config=) arm arm920t yangchu2410 NULL s3c24x0一、 使U-BOOT能从NAND FLASH启动起来添加的代码主要来自于VIVI。1、 在cpu/arm920t/start.s中修改如下:#ifndef CONFIG_SKIP_RELOCATE_UBOOTrelocate: /* relocate U-Boot to RAM */ ad
4、r r0, _start /* r0 - current position of code */ ldr r1, _TEXT_BASE /* test if we run from flash or RAM */ cmp r0, r1 /* dont 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_loo
5、p: 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#ifdef CONFIG_S3C2410_NAND_BOOT bl copy_myself#endif /*CONFIG_S3C2410_NAND_BOOT*/这个一定要放在堆栈设置之前,否则添加NANDFLASH驱动后U-BOOT启动时会死掉#endif /*CONFI
6、G_SKIP_RELOCATE_UBOOT*/ /* * * copy u-boot to ram * * */ /这段代码放在start.s的靠后的适当位置#ifdef CONFIG_S3C2410_NAND_BOOT copy_myself: copy u-boot to ramcopy_myself: mov r10, lr 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 c
7、hip str r2, r1, #oNFCONF mov r2, #0xff RESET command strb r2, r1, #oNFCMD mov r3, #0 wait 1: add r3, r3, #0x1 cmp r3, #0xa blt 1b2: ldr r2, r1, #oNFSTAT wait ready tst r2, #0x1 beq 2b ldr r2, r1, #oNFCONF orr r2, r2, #0x800 disable chip str r2, r1, #oNFCONF get read to call C functions ldr sp, DW_ST
8、ACK_START setup stack pointer mov fp, #0 no previous frame, so fp=0 copy UBOOT to RAM ldr r0, _TEXT_BASE mov r1, #0x0 mov r2, #0x20000 bl nand_read_ll teq r0, #0x0 beq ok_nand_readbad_nand_read: 1: b 1b infinite loop ok_nand_read: verify mov r0, #0 ldr r1, _TEXT_BASE mov r2, #0x400 4 bytes * 1024 =
9、4K-bytesgo_next: ldr r3, r0, #4 ldr r4, r1, #4 teq r3, r4 bne notmatch subs r2, r2, #4 beq done_nand_read bne go_nextnotmatch:1: b 1bdone_nand_read: mov pc, r10#endif CONFIG_S3C2440_NAND_BOOTDW_STACK_START: .word STACK_BASE+STACK_SIZE-42、 修改include/configs/yangchu2410.h#ifndef _CONFIG_H#define _CONF
10、IG_H/* * High Level Configuration Options * (easy to change) */#define CONFIG_ARM920T 1 /* This is an ARM920T Core */#define CONFIG_S3C2410 1 /* in a SAMSUNG S3C2410 SoC */#define CONFIG_SMDK2410 1 /* on a SAMSUNG SMDK2410 Board */*- * FLASH and environment organization */#define CONFIG_AMD_LV400 1
11、/* 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 */#ifdef CONFIG_AMD_LV800#define PHYS_FLASH_SIZE 0x00100000 /* 1MB */#define CFG_MAX_FLASH_SECT (19) /* max nu
12、mber of sectors on one chip */#define CFG_ENV_ADDR (CFG_FLASH_BASE + 0x0F0000) /* addr of environment */#endif#ifdef CONFIG_AMD_LV400#define PHYS_FLASH_SIZE 0x00080000 /* 512KB */#define CFG_MAX_FLASH_SECT (11) /* max number of sectors on one chip */#define CFG_ENV_ADDR (CFG_FLASH_BASE + 0x070000) /
13、* addr of environment */#endif/* 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_FLASH 1#define CFG_ENV_SIZE 0x10000 /* Total Size of Environment Sector */*-
14、* NAND FLASH BOOT */#define CONFIG_S3C2410_NAND_BOOT 1#define STACK_BASE 0x33f00000#define STACK_SIZE 0x8000#define NAND_CTL_BASE 0x4e000000#define bINT_CTL(Nb) _REG(INT_CTL_BASE+(Nb)#define oNFCONF 0x00#define oNFCMD 0x04#define oNFADDR 0x08#define oNFDATA 0x0c#define oNFSTAT 0x10#define oNFECC 0x1
15、4/*- * NAND flash settings */#define NAND_MAX_CHIPS 13、 在board/yangchu2410/中添加nand_read.c文件:#include #include linux/mtd/mtd.h#include linux/mtd/nand.h/#define LARGEPAGE_FLASH#define _REGb(x) (*(volatile unsigned char *)(x)#define _REGi(x) (*(volatile unsigned int *)(x)#define NF_BASE 0x4e000000#defi
16、ne 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 1inline void wait_idle(void) int i; while(!(NFSTAT & BUSY) for(i=0; i SZ_1M)*/) return -1; /* invalid alignment */ /*
17、 chip Enable */ NFCONF &= 0x800; for(i=0; i10; i+); for(i=start_addr; i 9) & 0xff; NFADDR = (i 17) & 0xff; NFADDR = (i 25) & 0xff;#else NFADDR = i & 0xff; NFADDR = (i 8) & 0x07; NFADDR = (i 11) & 0xff; NFADDR = (i 19) & 0xff; NFADDR = (i 27) & 0x3; NFCMD = NAND_CMD_READSTART;#endif wait_idle(); for(
18、j=0; j NAND_SECTOR_SIZE; j+) *buf = (NFDATA & 0xff); buf+; i += NAND_SECTOR_SIZE; /* chip Disable */ NFCONF |= 0x800; /* chip disable */ return 0;4、 修改board/yangchu2410/Makefile:COBJS := smdk2410.o flash.o nand_read.o /添加nand_read.oOK,这边就编译一下,就可以烧到NAND FLASH运行了。二、 为U-BOOT添加NAND FLASH驱动,能够使CFG_CMD_NA
19、ND的命令奏效添加的代码主要来自于U-BOOT中其他的板子(board/mpl/vcma9)1、在drivers/nand_legacy/nand_legacy.c 中添加如下:这边所有添加的代码放在nand_legacy.c文件的开头部分,因为下面有函数要调用到这边添加的函数;否则,会出错/*/* My ADD */#if (CONFIG_SMDK2410)#include #if (CONFIG_COMMANDS & CFG_CMD_NAND)/*typedef enum NFCE_LOW, NFCE_HIGH NFCE_STATE;*/static inline void NF_Conf
20、(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
21、nand = S3C2410_GetBase_NAND(); nand-NFADDR = addr;/static inline void NF_SetCE(NFCE_STATE s)static inline void NF_SetCE(int s) S3C2410_NAND * const nand = S3C2410_GetBase_NAND(); switch (s) case NFCE_LOW: nand-NFCONF &= (1NFCONF |= (1NFSTAT & (1NFDATA = data;static inline u8 NF_Read(void) S3C2410_NA
22、ND * const nand = S3C2410_GetBase_NAND(); return(nand-NFDATA);static inline void NF_Init_ECC(void) S3C2410_NAND * const nand = S3C2410_GetBase_NAND(); nand-NFCONF |= (1NFECC);extern ulong nand_probe(ulong physadr);static inline void NF_Reset(void) int i; NF_SetCE(NFCE_LOW); NF_Cmd(0xFF); /* reset co
23、mmand */ for(i = 0; i 10; i+); /* tWB = 100ns. */ NF_WaitRB(); /* wait 200500us; */ NF_SetCE(NFCE_HIGH);static inline void NF_Init(void)#if 1#define TACLS 0#define TWRPH0 3#define TWRPH1 0#else#define TACLS 0#define TWRPH0 4#define TWRPH1 2#endif NF_Conf(115)|(014)|(013)|(112)|(111)|(TACLS8)|(TWRPH04)|(TWRPH1NFCONF = (115)|(114)|(113)|(112)|(111)|(TACLS8)|(TWRPH04)|(TWRPH1 20);#endif /*CONFIG_COMMANDS & CFG_CMD_NAND*/#endif /*CONFIG_SMDK23410*/2、修改include/configs/yan
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1