DO818(3BSE069053R1)
ABBDO818(3BSE069053R1)ABBDO818(3BSE069053R1)ABBDO818(3BSE069053R1)O引言Flash是一种非易失存储器,它在掉电条件下仍然能够长期保持数据。由于它具有容量大、速度快、功耗低、抗震性能好等优点,近几年在U盘、SD卡、SSD硬盘等各种移动存储设备中得到了广泛的应用。本文给出了一款性能优异、成本低廉可用于SD卡的NANDflash控制芯片的设计方法。(本方法也同样适用于其他存储设备。文中集中探讨了一种高效管理物理块的算法,包括逻辑物理地址映射以及spare区的定义,另外,还有双缓冲器优化读写的方法等。1Flash简介1.1SLCflash与MLCflash的比较从架构上,flash可以分为SLC(Single-Level-Cell)flash和MLC(Multi-Level-Cell)flash两种。和SLCFlash相比较,MLCflash的优点是面积小、成本低:缺点是出错率高,寿命短(SLC的每个block能够擦写100,000次,而MLC能够擦写10,000次)。由于MLCflash具有成本低的优势,而其出错率高的缺陷又可以通过ECC(ErrorCorrectionCode)纠错来有效解决,寿命短的问题也可以通过磨损均衡来弥补,因此,MLCflash的应用更加广泛,但在一些高端应用仍然会使SLCflash。本设计就是针对MLCflash,但是,本方法对SLCflash也能够处理。1.2NANDflash结构不同厂商不同型号的flash的结构都大同小异,图l所示是三星K9G8G08UOA型号的flash结构图,图l中的1个flash芯片包含4096个物理块(block),每个物理块含有128个页(page),每个页包含2112(2048+64)字节其中多出的64字节用于存放纠错码及其他信息用。NANDflash结构1.3NANDflash的特点Flash可支持读(Read)操作、写(Program)操作和擦除(Erase)操作。其中读操作和写操作的基本单位是页,擦除操作的基本单位是块。对flash的写入操作只能在尚未写入的空闲页上进行,并且只能按照从低地址页到高地址页的顺序进行操作,而不能写了高地址页之后,再写低地址页。如果想要修改某个已经写过的页,只能先对整个物理块进行擦除,然后才能正确写入。2Flash管理算法2.1逻辑物理地址映射由于flash具有上述特点,因此,如果不采用逻辑物理地址映射,将会存在两个问题:其一是Flash中难免会有坏块,因而某些地址空间将是不可用的;其二,Flash读写的基本单位是页,擦除的基本单位是块,故在同一个页的两次写之间,就必须要进行一次擦除操作,而擦除会擦除掉整个块,这样,为了避免其他页的数据丢失,就得先把这些页中的数据暂存到其他地方备份起来,之后再和新数据一起重新写回到该块中,因此,整个过程会比较复杂,而且会造成速度降低。这样,一般都需要对flash加入逻辑物理地址映射管理算法,该算法的逻辑地址和物理地址的对应关系是变动的。2.2两级地址映射为了减少更新数据时原有数据的搬移,提高写操作的速度,本文提出了采用两级地址映射的机制,也就是在块级别逻辑物理地址映射的基础上引入页级别上的逻辑物理地址映射。一个逻辑块对应一个或两个物理块(称为母块和子块),逻辑块中的逻辑页对应一或两个物理块中的某个面。图2所示是其地址解析示意图。地址解析示意图在读写时,首先应将逻辑地址分为逻辑块地址和逻辑页地址,再根据块映射表将逻辑块地址映射到物理块地址,然后读取母块和子块中的sDare区,并据此建立页映射表,再根据逻辑页地址映射到物理页地址,从而完成从逻辑地址到物理地址的转换。其数据更新示意图如图3所示。数据更新示意图当需要更新数据时,写入的策略可分为两种情况。首先,当子块仍然有空闲页时,可直接将数据写到子块中的下一个空闲页中,并在spare区中记录该块对应的子块、该物理块对应的逻辑块以及该物理页对应的逻辑页,这样,当重新上电时,就可以建立逻辑物理映射关系。其次,当母块和子块都写满时,需要从空块池中取出一个新的子块。如果允许一个逻辑块对应三个或更多的物理块,一方面管理起来比较复杂,另外也会造成空物理块紧缺,因此,可以考虑将母块或者子块释放掉,这样,母块或者子块中原有的有效数据就需要搬移到新子块中并将该母块或子块擦除再释放到空块池。出于速度的考虑,选择母块和子块有效页数较少的块进行数据转移并释放。实践证明,这样操作对写文件速度有明显提高,特别是写小文件时,其速度提升可达9.2倍。2.3SPARE区和ECC校验Flash中每个页里的每个字节都是没有任何差别的,物理上并没有data区和spare区的区别,具体怎样划分data区和spare区,可由用户自己决定。本设计采用的划分办法如图ABBPM645AABB200-APB12ABB200-IT8ABBCI810AABBCI810V2ABBDFM02ABBRAIO-01ABBTU830ABBDSDO131ABBDSDO115ABBDSAX452ABBCI627200-BPN492897301200-C1485G492897601200-CICN492897801200-CIE492897701200-PSMG4928988013BSC950019R1TK520V0303BSC950055R1TK576V0503BSC950056R1TK576V1153BSC950073R273BSC950098R13BSE016239R1PM510V083BSE016240R1PM510V16AI6203BHT300005R1AI6253BHT300036R1AX6703BSE000566R1CI520V13BSE012869R1CI5223BSE012790R1CI522A3BSE018283R1CI5263BSE006085R1CI532V023BSE003827R1CI532V043BSE003829R1CI5403BSE001077R1CI5603BUC98002R0001CI5703BSE001440R1CI6103BHT300003R1CI615K013BSE000756R1CI6303BSE011000R1CI630K023BSE011002R1CI6703BHT300017R1CI810B3BSE020520R1CI820-23BSE013202A1CS5123BUR980009R1CS5133BSE000435R1CS513K023BSE004773R1CS513K043BSE055760R1DI6213BHT300012R1DO6103BHT00006R1DO6303BHT300007R1DSAI13357120001-PSDSAI11057120001-DPDSAI13057120001-PDSAI1455712001-HADSAI1463BSE007949R1DSAI15557120001-HZDSAI155A3BSE014162R1DSAO11057120001-ATDSAO13057120001-FGDSAO12057120001-EYDSAO120A3BSE018293R1DSBC17257310001-KD/5DSBC17357310001-KHDSBC173A3BSE005883R1DSCS14057520001-EVDSDI110A57160001-AAADSDO12057160001-AKDSDO11057160001-KDSDP15057160001-GFDSDX1803BSE003859R1DSDX180A3BSE018297R1DSDX4525716075-PDSPC45257310303-ADSPU1313BSE000355R1DSRF1993BSE019299R1DSRF1853BSE004382R1DSRF1863BSE004383R1DSRF1873BSE004985R1DSRF187A3BSE014452R1DSSR17048990001-PCDSSS1713BSE005003R1DSTA00157120001-PXDSTA001B3BSE018316R1DSTA002B3BSE018317R1DSTA13157120001-CVDSTAN0133BNP000177R1DSTA002P3BSE018331R1DSTC40657520001-DX/1DSTC4525751017-A/2DSTD10857160001-ABDDSTD1903BSE004723R1DSTD1973BSE004726R1DSTX1803BUR980025R1GJR5250000R035307KR91BGJR5251000R030307KP90GJR5251063P1GJR5251400R320207DC91GJR5251500R110107MK92GJR5252100R010107KT94CI8603BSE032444R1CI860K01AI8353BSE008520R1AI835A1SBP260052R1001ICMK14N11SNA645524R2300OBROC200-IA8S200-IA8200-IE8490176097S200-IE8200-TB3T490176065200C-IB10xOB6P492960133200C-IB16492933501200C-IE8492933801200C-OB16P4929337013BDH000032R1FI830F3BSC950192R1TK850V007GJR5252300R010107AC91GJR5252400R010107DI92GJR5252800R010007KT95GJR5252800R020007KT95GJR5253000R016007KT97CGJR5253000R020007KT97GJR5253000R026207KT97BGJR5253000R026807KT97BGJR5253000R027507KT97BGJR5253000R027807KT97BGJR5253100R016007KT98E2IH530EN3BSE001248R1IH532EN3BSE018795R1IH540DE3BSE003210R1IH540EN3BSE001252R1IH5703BSE001253R1IH5803BSC640001R1ISAP212000R0001TU516TU516APM150V083BSE003641R1PM253V01492943601PM5103BSE000270R1PM510V083BSE008373R1PM510V163BSE008358R1PM511V083BSE011180R1PM511V163BSE011181R1PM6323BSE005831R13BSE022255R13BSE022256R13BSE022257R13BSE049768R1AI210492953101AI8013BSE020512R1AI8103BSE008516R1AI8203BSE008544R1AI8303BSE008518R1AI830A3BSE040662R1AI8453BSE023675R1AI8903BSC690071R1AI8953BSC690087R1AM811F3BDH000050R1AO8013BSE020514R1AO8103BSE008522R1AO810V23BSE038415R1AO8203BSE008546R1AO8453BSE023676R1AO845A3BSE045584R1AO8903BSC690072R1AO8953BSC690087R1CI8013BSE022366R1CI810V13BSE008584R1CI8203BSE013200R1CI820-13BSE013201A1CI820V13BSE025255R1CI8303BSE013252R1CI8403BSE022457R1CI840A3BSE041882R1CI8543BSE025347R1CI854A3BSE030221R1CI854AK013BSE030220R1DI210492953401DI8013BSE020508R1DI8023BSE022360R1DI8033BSE022362R1DI8103BSE008508R1DI8113BSE008552R1DI8143BUR001454R1DI8203BSE008512R1DI8213BSE008550R1DI821Z3BSE035380R1DI8303BSE013210R1DI8313BSE013212R1DI8403BSE020836R1DI8853BSE013088R1DI8903BSC690073R1DO210492953501DO8013BSE020510R1DO8023BSE022364R1DO8103BSE008510R1DO8143BUR001455R1DO8153BSE013258R1DO8203BSE008514R1DO8213BSE013250R1DO8403BSE020838R1DO8903BSC690074R1DP8203BSE013228R1DP8403BSE028926R1EI803F3BDH000017R1EI813F3BDH000022R1FI810F3BDH000030R1FI820F3BDH000031R1FI840F3BDH000033R1LD800HSE3BDH000320R02PM803F3BDH000530R1PM2103BSE021386R2PM8613BSE018129R1PM861AK013BSE018157R1PM861K013BSE018105R1PM8643BSE018151R1PM864AK023BSE018164R1PU514A3BSE032400R1RLM013BDZ000398R1SA811F3BDH000013R1SD8223BSC610038R1SS8223BSC610042R1TB8053BSE008534R1TB8063BSE008536R1TB8073BSE008538R1TB8103BSE008560R1TB8153BSE013204R1TB8203BSE008555R1TB820V23BSE013208R1TB8403BSE021456R1TB8503BSC950193R1TK801V0033BSC950089R1TK801V0063BSC950089R2TK801V0123BSC950089R3TK811V0153BSC950107R1TK811V0503BSC950107R2TP8513BSE018118R1TP8543BSE025349R1TU8103BSE008524R1TU810V13BSE013230R1TU811V13BSE013231R1TU812V13BSE013232R1TU814V13BSE013233R1TU830V13BSE013234R1TU8313BSE008530R1TU831V13BSE013235R1TU835V13BSE013236R1TU836V13BSE013237R1TU837V13BSE013238R1TU8383BSE008572R1TU8393BSE046966R1TU8413BSE020848R1TU8423BSE020850R1TU8433BSE021443R1TU8443BSE021445R1TU8453BSE021447R1TU8473BSE022462R1TU8903BSC690075R1TU8913BSC840157R1GJR5250500R510123KT92RTU510DSDI11057160001-A/1357160001-AAO6103BHT300008R13BSE018184R107AI91GJR5251600R020207AI91C07DC91GJR5251400R020207KP93GJR5253200R11611SAP111100R0170TB511-ETH1SAP140100R0100PM581B11SAP240000R0001DI5241SAP250000R0001AX522A1SBP260150R1001TC501SAP250300R0001AI523AI523B41SBP260001R100186AR2301SBP260010R100107KR5107KR51-U3.61SBP260011R100107KR51-P3007KR51-F121SBP260012R100107KT5107KT51-U3.61SBP260014R100107KR51-A3.61SBP260021R100107CR41-c121SBP260051R1001ICMK14F1-H081SBP260020R100107CR4107cr41-l22DSTC12057520001-A/2IN5752-1001-E/03DSTC19057520001-ER/1IN5752-1001-BP/01GJR5253000R016207KT97D07KT97B07KT97CGJR5252100R016107KT94D07KT94K07KT94iGJR5252200R010107DC9207DC92E07DC92F07DC92BGJR5250200R107SK90R1GJR5250200R00011SBP260100R1001XI16E1-b10XI16E1-E4.0,XI16E1-D021SBP260101R1001XO08R1;XOO8R1-B041SBP260104R1001XK08F1XK08F1-A3.0XK08F1-A301SBP260105R1001XO16N1-b20XO16N1-C3.01SBP260110R1001XC32L1XC32L1-B4.01SBP260512R1001ICMK14F1ICMK14F1-I091SVR440621R5200LM012LM012-CXE18RAC)
厦门渤格电气技术有限公司
业务 QQ: 1982497648