u-boot-2012.04.01移植到TQ2440(五):支持NAND FLASH读写
一、????支持NAND FLASH读写 修改配置文件includeconfigstq2440.h打开之前注释掉的NAND相关的宏 #defineCONFIG_CMD_NAND #define CONFIG_ENV_IS_IN_NAND 编译出错 iteral-Wno-format-security????? -os3c2410_nand.o s3c2410_nand.c -c s3c2410_nand.c: In function's3c2410_hwcontrol': s3c2410_nand.c:57: warning:implicit declaration of function 's3c2410_get_base_nand' s3c2410_nand.c:57: warning:initialization makes pointer from integer without a cast s3c2410_nand.c:72: error:dereferencing pointer to incomplete type s3c2410_nand.c:72: error:dereferencing pointer to incomplete type s3c2410_nand.c:75: error:dereferencing pointer to incomplete type s3c2410_nand.c:75: error:dereferencing pointer to incomplete type s3c2410_nand.c: In function's3c2410_dev_ready': s3c2410_nand.c:85: warning:initialization makes pointer from integer without a cast s3c2410_nand.c:87: error:dereferencing pointer to incomplete type s3c2410_nand.c: In function'board_nand_init': s3c2410_nand.c:129: warning:initialization makes pointer from integer without a cast s3c2410_nand.c:150: error:dereferencing pointer to incomplete type s3c2410_nand.c:153: error:dereferencing pointer to incomplete type s3c2410_nand.c:154: error:dereferencing pointer to incomplete type make[1]: ***[s3c2410_nand.o] Error 1 make[1]: Leaving directory`/home/work/u-boot-2012.04.01/drivers/mtd/nand' make: ***[drivers/mtd/nand/libnand.o] Error 2 将drivers/mtd/nand/s3c2410_nand.c拷贝为drivers/mtd/nand/s3c2440_nand.c root@zjh:/home/work/u-boot-2012.04.01#cp drivers/mtd/nand/s3c2410_nand.c drivers/mtd/nand/s3c2440_nand.c 在drivers/mtd/nand/Makefile文件中增加一行 COBJS-$(CONFIG_NAND_S3C2440)+= s3c2440_nand.o 将s3c2440_nand.c中所有的2410替换为2440 修改配置文件includeconfigstq2440.h #define CONFIG_NAND_S3C2440 #define CONFIG_SYS_S3C2440_NAND_HWECC 修改driversmtdnands3c2440_nand.c中的board_nand_init()函数 #ifdefined(CONFIG_S3C24XX_CUSTOM_NAND_TIMING) ? tacls? =CONFIG_S3C24XX_TACLS; ? twrph0 = CONFIG_S3C24XX_TWRPH0; ? twrph1 =?CONFIG_S3C24XX_TWRPH1; #else ? tacls = 0; ? twrph0 =?1; ? twrph1 = 0; #endif ? #if 0 ? cfg = S3C2440_NFCONF_EN; ? cfg |= S3C2440_NFCONF_TACLS(tacls - 1); ? cfg |= S3C2440_NFCONF_TWRPH0(twrph0 - 1); ? cfg |= S3C2440_NFCONF_TWRPH1(twrph1 - 1); #endif ?cfg = (tacls << 12)|(twrph0 << 8)|(twrph1 << 4); ? writel(cfg,&nand_reg->nfconf); /*初始化ECC、禁止片选、使能NANDFLASH控制器*/ ? writel((1 << 4)|(1 << 1)|(1<< 0),&nand_reg->nfcont); nand->select_chip = s3c2440_nand_select; 添加函数s3c2440_nand_select static voids3c2440_nand_select(struct mtd_info *mtd,int chipnr) { ? ?????? structs3c2440_nand *nand = s3c2440_get_base_nand(); ? ?????? switch(chipnr) { ? ?????? case-1: /* 取消选中 */ ? ?????? ?????? nand->nfcont |= (1<<1); ???????? ?????? break; ? ?????? case0:? /* 选中 */ ???????? ?????? nand->nfcont&= ~(1<<1); ???????? ?????? break; ? ?????? default: ???????? ?????? BUG(); ? ?????? } } 修改s3c2440_hwcontrol()函数 /* ** ctrl:表示做什么(选中芯片/取消选中,发命令还是发地址) ** cmd:命令值或地址值 */ static voids3c2440_hwcontrol(struct mtd_info *mtd,int cmd,unsigned int ctrl) { ? ?????? struct s3c2440_nand*nand = s3c2440_get_base_nand(); ? ?????? if(ctrl & NAND_CLE) { ???????? ?????? /*发命令 */ ???????? ?????? writeb(cmd,&nand->nfcmd); ? ?????? }else if (ctrl & NAND_ALE) { ? ?????? ?????? /* 发地址 */ ???????? ?????? writeb(cmd,&nand->nfaddr);???????????? ? ?????? } } 重新编译烧到NOR FLASh执行 TQ2440 # tftp 32000000u-boot.bin dm9000 i/o: 0x20000000,id:0x90000a46 DM9000: running in 16 bitmode MAC: 00:0c:29:4d:e4:f4 Using dm9000 device TFTP from server172.28.12.60; our IP address is 172.28.12.10 Filename 'u-boot.bin'. Load address: 0x32000000 Loading: T ################ done Bytes transferred = 226588(3751c hex) TQ2440 # pro off all Un-Protect Flash Bank # 1 TQ2440 # erase 0 +40000 ? ....... done Erased 7 sectors TQ2440 # cp.b 32000000 040000 Copy to Flash...9....8....7....6....5....4....3....2....1....done TQ2440 # res resetting ... ? ? U-Boot 2012.04.01 (Dec 292012 - 21:53:59) ? CPUID: 32440001 FCLK:????? 400 MHz HCLK:????? 100 MHz PCLK:?????? 50 MHz DRAM:? 64 MiB WARNING: Caches not enabled Flash: 2 MiB NAND:? 256 MiB *** Warning - bad CRC,usingdefault environment ? In:??? serial Out:?? serial Err:?? serial Net:?? dm9000 TQ2440 # 测试 将SDRAM的0x32000000地址的0xff字节数据写到NAND FLASH的0地址 TQ2440 # nand write 320000000 ff?? NAND write: device 0 offset0x0,size 0xff ?255 bytes written: OK 从NAND FLASH的0地址读0xff字节数据到SDRAM的0x31000000地址 TQ2440 # nand read 310000000 ff NAND read: device 0 offset0x0,size 0xff ?255 bytes read: OK 比较 TQ2440 # cmp.b 3100000032000000 ff Total of 255 byteswere the same (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |