我的nandflash的分区:
0-128k(20000)???????????????????????? u-boot1.1.4
128k(20000)-192k(30000) param
192k(30000)-5M(500000)????????????? kernel
5M(500000)-10M(a00000)??????????? jffs2
10M(a00000)-20M(1400000)?????? cramfs (暂时放的ramdisk)
20M-64M (0x1400000-0x4000000,大小0x2C00000)?"YAFFS",??
注意:u-boot1.1.4的修改和u-boot1.1.6的有些不一样,u-boot1.1.4只有一个cmd_nand.c ,而u-boot1.1.6是在derivers/nand里面改nand_legecy.c
1.首先打开uboot1.1.4(include/configs/smdk2410.h)的CONFIG_CMD_NAND 支持 ????
末尾加上???
#define CONFIG_CMD_MTDPARTS
#define CONFIG_MTD_DEVICE
#define CONFIG_MTD_PARTITIONS
#define MTDIDS_DEFAULT "nand0=K9F1208U0B_nand"
#define MTDPARTS_DEFAULT???? "mtdparts=K9F1208U0B_nand:128K@0(user),"
??????????????????????????????????? "64K(user),"
??????????????????????????????????? "4F28K(linux),"
??????????????????????????????????? "5M@5M(jffs2),"
??????????????????????????????????? "10M@10M(cramfs),"
??????????????????????????????????? "44M@20M(yaffs2)"
及
/*-----------------------------------------------------------------------
?* NAND flash settings
?*/
#if (CONFIG_COMMANDS & CFG_CMD_NAND)
#define CFG_MAX_NAND_DEVICE???? 1?????? /* Max number of NAND devices?????????? */
#define SECTORSIZE 512
#define ADDR_COLUMN 1
#define ADDR_PAGE 2
#define ADDR_COLUMN_PAGE 3
#define NAND_ChipID_UNKNOWN???? 0x00
#define NAND_MAX_FLOORS 1
#define NAND_MAX_CHIPS 1
#define NAND_WAIT_READY(nand)?? NF_WaitRB()
#define NAND_DISABLE_CE(nand)?? NF_SetCE(NFCE_HIGH)
#define NAND_ENABLE_CE(nand)??? NF_SetCE(NFCE_LOW)
#define WRITE_NAND_COMMAND(d,adr)????? NF_Cmd(d)
#define WRITE_NAND_COMMANDW(d,adr)???? NF_CmdW(d)
#define WRITE_NAND_ADDRESS(d,adr)????? NF_Addr(d)
#define WRITE_NAND(d,adr)????????????? NF_Write(d)
#define READ_NAND(adr)????????????????? NF_Read()
/* 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)
/* #undef CONFIG_MTD_NAND_VERIFY_WRITE */
#endif? /* CONFIG_COMMANDS & CFG_CMD_NAND */
2在common/cmd_nand.c添加
typedef enum {
?NFCE_LOW,
?NFCE_HIGH
} NFCE_STATE;
#if(CONFIG_SMDK2410)
#include<s3c2410.h>
static inlinevoid NF_Conf(u16 conf)
{
?S3C2410_NAND * const nand =S3C2410_GetBase_NAND();
?nand->NFCONF= conf;
}
static inlinevoid NF_Cmd(u8 cmd)
{
?S3C2410_NAND * const nand =S3C2410_GetBase_NAND();
?nand->NFCMD= cmd;
}
static inlinevoid NF_CmdW(u8 cmd)
{
?NF_Cmd(cmd);
?udelay(1);
}
static inlinevoid NF_Addr(u8 addr)
{
?S3C2410_NAND * const nand =S3C2410_GetBase_NAND();
?nand->NFADDR= addr;
}
static inlinevoid NF_SetCE(NFCE_STATE s)
{
?S3C2410_NAND * const nand =S3C2410_GetBase_NAND();
?switch (s){
??case NFCE_LOW:
???nand->NFCONF &=~(1<<11);
???break;
??caseNFCE_HIGH:
???nand->NFCONF |=(1<<11);
???break;
?}
}
static inlinevoid NF_WaitRB(void)
{
?S3C2410_NAND * const nand =S3C2410_GetBase_NAND();
?while(!(nand->NFSTAT &(1<<0)));
}
static inlinevoid NF_Write(u8 data)
{
?S3C2410_NAND * const nand =S3C2410_GetBase_NAND();
?nand->NFDATA= data;
}
static inline u8NF_Read(void)
{
?S3C2410_NAND * const nand =S3C2410_GetBase_NAND();
?return(nand->NFDATA);
}
static inlinevoid NF_Init_ECC(void)
{
?S3C2410_NAND * const nand =S3C2410_GetBase_NAND();
?nand->NFCONF|= (1<<12);
}
static inline u32NF_Read_ECC(void)
{
?S3C2410_NAND * const nand =S3C2410_GetBase_NAND();
?return(nand->NFECC);
}
extern ulongnand_probe(ulong physadr);
static inlinevoid NF_Reset(void)
{
??? int i;
???NF_SetCE(NFCE_LOW);
??? NF_Cmd(0xFF);??
??? for(i = 0; i < 10;i++);?
??? NF_WaitRB();??
??? NF_SetCE(NFCE_HIGH);
}
static inlinevoid NF_Init(void)
{
#if 0
#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));
???
???
???
???NF_Reset();
}
voidnand_init(void)
{
?S3C2410_NAND * const nand =S3C2410_GetBase_NAND();
?NF_Init();
#ifdef DEBUG
?printf("NAND flash probing at 0x%.8lXn",(ulong)nand);
#endif
?printf ("%4lu MBn",nand_probe((ulong)nand)>> 20);
}
#endif
3.烧写uboot_1.1.4
先在norflash下启动,操作nand
jimmy smdk2410x》nand erase 0 20000
jimmy smdk2410x》tftp 30800000 u_boot_1.1.4_mtdpart.bin (大小1c164)
jimmy smdk2410x》nand write 30800000 0 1c164
4.操作nand
在nandflash下启动,操作nand