ShenzhenFarsightInc.10012010-5-10————————————————————————————————————————10012010-5-101Nand_flash10012010-5-10----------------------------------------------------------------------------------------------------------------------FlashPCFlashNANDFlashNorFlashNANDFlashEDC/ECC/BBM(fs2410,NANDFLASHk9f1208u0m64M8bit1page512B,1block32page4096Blocklinux-2.6.14u-boot-1.3.1NANDflashShenzhenFarsightInc.10012010-5-10————————————————————————————————————————10012010-5-102NandflashNANDFlashbitmemorycellcellbitcell816bitlinebyte(x8)/word(x16)NANDDeviceLinePage(NANDFlashNANDFlashK9F1208,K9F1208U0M)528Bytes(512byte(MainArea)+16byte(SpareArea))32pageBlock(32*528B)flashBlockk9f1208U0M4096block4096*32*528B=66MB2MBECC64MBK9F1208U0MShenzhenFarsightInc.10012010-5-10————————————————————————————————————————10012010-5-103NANDFLASHs3c410NANDFLASHcpus3c24108I/Os3c2410DATA0–DATA78NANDFLASH6R/B,/RE,/WE,/CE,CLE,ALES3C2410R/nB,nFRE,nFWE,nCE,CLE,ALE,ShenzhenFarsightInc.10012010-5-10————————————————————————————————————————10012010-5-104/WP/wp/WPNANDFLASH1NANDFLASH2NANDFLASHNANDFALSH3TACLS,TWRPH0,TWRPH1NANDFLASH()TACLSCLE&ALECLE/ALETACLSCLE/ALECLE/ALEk9f1208u0mtclstals10ns10nsminTWRPH0/WEPLUSEWIDTH/WEk9f1208u0mtwp25nsminTWRPH1/WEhigtholdtime(/WE)k9f1208u0mtWH15nsminNOTE:1.IftCS10ns,tWP=35ns,otherwisetWP=minimum25ns.NANDFLASHNFCONFNANDFALSHECCShenzhenFarsightInc.10012010-5-10————————————————————————————————————————10012010-5-105nandFlashNANDflashNandFlashNandFlashColumnAddressPageAddress.ColumnAddress:ColumnAddressPageByteBytePageAddress512Bytes90FlashRead1NandFlashsrc_addrColumnAddressPageAddresscolumn_addr=src_addr%512;//columnaddresspage_address=(src_addr9);//pageaddressNandFlashA0~A7column_addrA9~A25PageAddress(A8Read14Cycle00h01h00h01h4Cycle1st.CycleColumnAddress2nd.Cycle,3rd.Cycle4th.CyclePageAddress817PageAddress34CycleNANDFLASHNANDflashk9f1208NANDflashs3c2410NANDflashSFRs3c2410NANDflashdriver/mtd/nand/smc_core.cNANDflashNANDflashNANDflashinclude/mtd/nand.hstructnand_chip{#ifdefCONFIG_MTD_NANDY/*=y*/void(*hwcontrol)(intcmd);void(*write_cmd)(u_charval);void(*write_addr)(u_charval);u_char(*read_data)(void);void(*write_data)(u_charval);void(*wait_for_ready)(void);ShenzhenFarsightInc.10012010-5-10————————————————————————————————————————10012010-5-106intpage_shift;u_char*data_buf;u_char*data_cache;intcache_page;structnand_smc_dev*dev;u_charspare[SMC_OOB_SIZE];#else/*CONFIG_MTD_NANDY*/……#ifdefCONFIG_MTD_NAND_ECCu_charecc_code_buf[6];u_charreserved[2];#endif#endif/*CONFIG_MTD_NANDY*/};NANDflashreadwriteeraseNANDflash#definenand_select()this-hwcontrol(NAND_CTL_SETNCE);nand_command(mtd,NAND_CMD_RESET,-1,-1);udelay(10);hwcontrol(NAND_CTL_SETNCE)2410NANDFLASHCONFIGURATION(NFCONF)REGISTERNANDFlashMemorychipenable0NANDflash1nand_command(mtd,NAND_CMD_RESET,-1,-1)flashresetNANDflash10usflashNANDFLASHI/O0~I/O7NANDFLASH8I/ONANDFLSHNand_command()smc_core.cNANDflashShenzhenFarsightInc.10012010-5-10————————————————————————————————————————10012010-5-107NAND_CMD_READ00NAND_CMD_READ11NAND_CMD_PAGEPROG0x10NAND_CMD_READOOB0x50OOBNAND_CMD_ERASE10x60NAND_CMD_STATUS0x70NAND_CMD_STATUS_MULTI0x71AND_CMD_SEQIN0x80NAND_CMD_READID0x90FlashIDNAND_CMD_ERASE20xd0NAND_CMD_RESEToxffNFADDR=addr&0xff8NFADDR=(addr9)&0xff98NFADDR=(addr17)&0xff1716NFADDR=(addr25)&0xff25244readwriteerase5NANDFLASHNANDFLASH1NANDFlashNANDMemoryArrayNAND/PageProgramBlockEraseStatusRegister21pagesparearea6byte0xff2NANDFlashBlockErasePageProgrampagesparearea6Byte0xff3NANDFlashspareareachecksparearea6byte0xff0xff“”ShenzhenFarsightInc.10012010-5-10————————————————————————————————————————10012010-5-108NANDpage“”BlockErase“”ECCNANDFlashBlockPagePage512Bytesbit——ECCECCECC256ECC2416512ECCNANDFlashpage256ECCECCPAGEOOBout-of-bandeccpos[]ECCOOBECCECCECC11OOB1.spareareabyteNANDFlashSamsung,Toshiba,STMicroelectronicsByte2.0xffNandFlash1(bit)10010XFFNANDFLASH1aNANDFLASHBLOCKBLOCKBLOCKBLOCK2048FFhBLOCKFFhBLOCKEraseProgramming,BShenzhenFarsightInc.10012010-5-10————————————————————————————————————————10012010-5-109PROGRAMERASE100000cyclesBLOCKbootcodeBLOCKBLOCKECCCBBT,shortbbt[4095]NANDFLASH0-409510page(102340954086102340951023BBTShenzhenFarsightInc.10012010-5-10————————————————————————————————————————10012010-5-1010BBTBBT