此篇文章是本人muge0913在上篇文章的基础上继续移植的,文章仅供技术交流请勿商用,转载请注明出处:
http://blog.csdn.net/muge0913/article/details/7168315
一、在include/configs/th6410.h添加宏定义
#define CONFIG_MEMORY_UPPER_CODE /*uboot首先打印的信息*/ #define CONFIG_IDENT_STRING " for th6410" /*配置串口频率*/ #define CONFIG_UART_66 /*配置nand,使支持nand中的代码拷贝*/ #define CFG_MAX_NAND_DEVICE 1 #define CFG_NAND_BASE (0x70200010) #define NAND_MAX_CHIPS 1 #define NAND_DISABLE_CE() (NFCONT_REG |= (1 << 1)) #define NAND_ENABLE_CE() (NFCONT_REG &= ~(1 << 1)) #define NF_TRANSRnB() do { while(!(NFSTAT_REG & (1 <<0))); } while(0) /*配置串口频率*/ #define CONFIG_UART_66 /*启动显示开发板信息*/ #define CONFIG_DISPLAY_BOARDINFO /*启动显示cpu信息*/ #define CONFIG_DISPLAY_CPUINFO /*启动cpu初始化*/ #define CONFIG_ARCH_CPU_INIT /*终端提示信息*/ #define CONFIG_SYS_PROMPT "muge0913-张同浩# " /* Monitor Command Prompt */二、添加nand flash拷贝函数(在nand_cp.c文件中),下面我们会有详细的代码分析
1、拷贝nand_cp.c文件到arch/arm/cpu/arm1176/中
2、修改链接文件
1)、arch/arm/cpu/arm1176/u-boot.lds
(为添加其他功能需要修改时,可再次修改):
2)、board/samsung/th6410/u-boot-nand.lds
(为添加其他功能需要修改时,可再次修改):
3、同时还要修改相应的makefile文件(在此不再叙述)
三、nand flash拷贝代码如下:
#include <common.h> #ifdef CONFIG_S3C64XX #include <asm/io.h> #include <linux/mtd/nand.h> #include <asm/arch/s3c6400.h> static int nandll_read_page (uchar *buf, ulong addr, int large_block) { int i; int page_size = 512; if (large_block) page_size = 2048; /*使能芯片*/ NAND_ENABLE_CE(); NFCMD_REG = NAND_CMD_READ0; /* Write Address */ NFADDR_REG = 0; if (large_block) NFADDR_REG = 0; NFADDR_REG = (addr) & 0xff; NFADDR_REG = (addr >> 8) & 0xff; NFADDR_REG = (addr >> 16) & 0xff; if (large_block) NFCMD_REG = NAND_CMD_READSTART; NF_TRANSRnB(); /* for compatibility(2460). u32 cannot be used. by scsuh */ for(i=0; i < page_size; i++) { *buf++ = NFDATA8_REG; } NAND_DISABLE_CE(); return 0; } static int nandll_read_blocks (ulong dst_addr, ulong size, int large_block) { uchar *buf = (uchar *)dst_addr; int i; uint page_shift = 9;//512 if (large_block) page_shift = 11;//2048 /* Read pages */ for (i = 0; i < (0x3c000>>page_shift); i++, buf+=(1<<page_shift)) { nandll_read_page(buf, i, large_block); } return 0; } int copy_uboot_to_ram (void) { int large_block = 0; int i; vu_char id; /*使能芯片*/ NAND_ENABLE_CE(); /*读取ID*/ NFCMD_REG = NAND_CMD_READID; NFADDR_REG = 0x00; /* 等待一会 */ for (i=0; i<200; i++); id = NFDATA8_REG; id = NFDATA8_REG; /*id>0x80则为大页*/ if (id > 0x80) large_block = 1; /*CONFIG_SYS_PHY_UBOOT_BASE拷贝地址,0x3c000为大小240K*/ return nandll_read_blocks(CONFIG_SYS_PHY_UBOOT_BASE, 0x3c000, large_block); } #endif 此篇文章是本人muge0913在上篇文章的基础上继续移植的,文章仅供技术交流请勿商用,转载请注明出处:
http://blog.csdn.net/muge0913/article/details/7168315