home/book/Desktop/u-boot-1.1.6/include/linux/mtd/nand.h:412: error: `NAND_MAX_CHIPS' undeclared here (not in a function)
home/book/Desktop/u-boot-1.1.6/include/linux/mtd/nand.h:412: error: `NAND_MAX_CHIPS' undeclared here (not in a function)在mini2440.h中添加以上宏定义:
/*NAND FLASH*/
#define CFG_MAX_NAND_DEVICE 1
#define CFG_NAND_BASE 0x0
#define NAND_MAX_CHIPS 1
/*NAND FLASH*/ #define CFG_MAX_NAND_DEVICE 1 #define CFG_NAND_BASE 0x0 #define NAND_MAX_CHIPS 1三者分别表示:
nand设备数量;
nand基地址,无实际意义,在board_nand_init函数中会被重新指定;
每个nand设备有1个nand芯片;
再次编译,出现错误为:
drivers/nand/libnand.a(nand.o)(.text+0x24): In function `nand_init':
/home/book/Desktop/u-boot-1.1.6/drivers/nand/nand.c:50: undefined reference to `board_nand_init'
意思是board_nand_init函数未定义。上电后nand的初始化过程为:start_armboot函数调用nand_init,nand_init函数在 /drivers/nand/nand.c中实现,nand_init函数调用同文件中nand_init_chip函数,nand_init_chip函数会首先调用board_nand_init函数来初始化nand设备。此函数是硬件相关,需要自己写。下一步实现此函数。
2) 实现board_nand_init函数。
在 /cpu/arm920t/s3c24x0/ 目录下建立文件nand_flash.c,文件内容为:
/*
* Nand flash interface of s3c2410/s3c2440
*/
#include <common.h>
#if (CONFIG_COMMANDS & CFG_CMD_NAND) && !defined(CFG_NAND_LEGACY)
#include <s3c2410.h>
#include <nand.h>
DECLARE_GLOBAL_DATA_PTR;
#define S3C2410_NFSTAT_READY (1<<0)
#define S3C2410_NFCONF_nFCE (1<<11)
#define S3C2440_NFSTAT_READY (1<<0)
#define S3C2440_NFCONT_nFCE (1<<1)
/* select chip, for s3c2410 */