CN100580811C - Dirty block recovery method for flash memory device - Google Patents

Dirty block recovery method for flash memory device Download PDF

Info

Publication number
CN100580811C
CN100580811C CN200510101856A CN200510101856A CN100580811C CN 100580811 C CN100580811 C CN 100580811C CN 200510101856 A CN200510101856 A CN 200510101856A CN 200510101856 A CN200510101856 A CN 200510101856A CN 100580811 C CN100580811 C CN 100580811C
Authority
CN
China
Prior art keywords
sector
flash memory
piece
dirty
memory device
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN200510101856A
Other languages
Chinese (zh)
Other versions
CN1815629A (en
Inventor
张建文
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Konka Group Co Ltd
Original Assignee
Konka Group Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Konka Group Co Ltd filed Critical Konka Group Co Ltd
Priority to CN200510101856A priority Critical patent/CN100580811C/en
Publication of CN1815629A publication Critical patent/CN1815629A/en
Application granted granted Critical
Publication of CN100580811C publication Critical patent/CN100580811C/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Techniques For Improving Reliability Of Storages (AREA)
  • Memory System (AREA)
  • Read Only Memory (AREA)

Abstract

The method includes forced reclaiming step carried out in time of writing sector, and conditional reclaiming step carried out after time of deleting sector. The forced reclaiming step reclaims blocks with most dirty sectors. Conditional reclaiming step is divided into two situations: for reclaiming blocks with number of dirty sectors being reached to a threshold value of dirty sectors; for reclaiming blocks with minimal erasure number. Advantages are: as far as possible to reduce number for erasing blocks, even erasure to make all physical blocks have even service life.

Description

A kind of dirty block recovery method of flash memory device
[technical field]
The present invention relates to the semiconductor storage field, relate in particular to a kind of dirty block recovery method of flash memory device.
[background technology]
Flash memory (Flash Memory) has high density and good advantages such as access speed, is the memory device that built-in field is most widely used, and belongs to EEPROM (electrically erasable programmable ROM) type.Flash media commonly used has two kinds of nand flash and nor flash, and they are divided into storage space the erase block of specific size, as 16KB, 64KB etc.They are similar with common SRAM storer aspect reading, and generally can realize reading of completely random, and maximum difference is the write operation aspect.The write operation of Flash storer needs through " wipe---write " two operating process.Write fashionable if wish to some unit, at first must carry out erase operation to the sector (Sector) or the piece (Block) at this storage unit place, disposable position with an erase block all is changed to " 1 " when carrying out erase operation, after erase operation completes successfully, the data content of whole sector or piece all is cleared, the piece that is wiped free of is called dirty, and the erase operation process is called recovery.Then the sector or the piece at place, purpose unit are carried out write operation, " 1 " of single position can be written as " 0 " when carrying out write operation, but " 0 " cannot be write as " 1 ".So common write the flash memory action and will wipe the original content of whole erase block earlier, write new data again.
General flash provides sector erasing (Sector-Erase), piece to wipe (Block-Erase) and three kinds of erase mode of chip erase (Chip-Erase).Chip-Erase wipes entire flash, and content is set to 1; Block-Erase and Sector-Erase are the deletion flash of unit with piece and sector respectively.The erasing times of flash is limited, is limited to each piece on usually can wipe 100,000~1,000,000 time.When a piece or sector reach in advance erasing times on will cause whole flash to use in limited time.Before other piece, reach this limit for fear of any one piece, file system or FMM (Flash Media manager, it is flash memory storage management, its effect mainly is the physical characteristics at Flash self, utilize some specific algorithms to improve the service efficiency of Flash, the frequency of utilization of the speed that speeds operations and each unit of management Flash) must guarantee that erasing times as far as possible evenly distributes between each erase block, this process is called " balance abrasion (WearLeveling) ".
Now, people take to remove the method for piece, promptly earlier move the effective content in former to another piece, and then former is wiped.Wherein, when new piece resettlement and writing data, all will be by the information of marking, to accomplish power down protection and restore data.But which piece of this selection reclaims on earth, and different manufacturers has different strategies, but all only lays particular stress in a certain respect, or reduces the erasing times of piece as far as possible, or accomplishes evenly to wipe, so that the life-span equilibrium of all physical blocks.Cause the whole utilization ratio of flash memory device not high like this.
[summary of the invention]
Fundamental purpose of the present invention is exactly in order to solve prior art problems, and a kind of dirty block recovery method of flash memory device is provided, and can reduce the erasing times of piece as far as possible, can accomplish again evenly to wipe, so that the life-span equilibrium of all physical blocks.
For achieving the above object, the invention discloses a kind of dirty block recovery method of flash memory device, comprise the pressure recycling step that carries out when writing the sector and delete the condition recycling step that carries out behind the sector;
Described pressure recycling step may further comprise the steps:
A1, flash memory device receive the write operation instruction;
The writeable free sector of flash memory storage management module searches in B1, the flash memory device;
If C1 does not have enough free sector, then the flash memory storage management module searches goes out the maximum piece in dirty sector and reclaims.
Described condition recycling step may further comprise the steps:
A2, flash memory device receive delete instruction, and the flash memory storage management module is deleted designated sector;
B2, flash memory storage management module produce the random number in one 0~99 at random;
C2, this random number and predefined probability separation are compared, if this random number is more than or equal to the probability separation, execution in step E2 then is if this random number is less than the probability separation, execution in step D2 then, wherein the span of probability separation is 1~100;
D2, the dirty sector number and the predefined dirty sector threshold value of each piece compared, for the piece execution in step F2 of dirty sector number greater than dirty sector threshold value, its apoplexy involving the solid organs sector threshold value is the positive integer less than the sector number that each piece comprised;
E2, flash memory storage management module searches go out minimum piece of erasing times and execution in step F2;
F2, this piece is reclaimed.
After steps A 2, also comprise the step that this deleted sector is added " dirty " mark.
Preferably, described probability separation is 97.
The step that after step D2 or E2, before the step F 2, also comprises the piece number that returns this piece.
Comprise also that after step F 2 erasing times with this piece adds 1 step.
The present invention can either reduce the erasing times of piece as far as possible, can accomplish again evenly to wipe, so that the life-span equilibrium of all physical blocks, thereby has prolonged serviceable life of flash memory device, the reasons are as follows:
At first, this programme adopts two kinds of take-back models to determine piece to be recycled, forces to reclaim down and looks for the maximum piece in dirty sector to reclaim.Condition reclaims down, has segmented two kinds of situations again, and promptly the piece that under most probability dirty sector number is reached dirty sector threshold value reclaims, and this has considered the least possible piece erasing times; And under very little chance, reclaiming the piece of erasing times minimum, this has considered uniform wear.
Secondly, two kinds of take-back models use under different situations again more than.Force recovery no free sector in writing the sector process to adopt, and dirty recovery carried out in the recovery of ability employing condition behind the deletion sector with under the situation.
At last, probability separation under the condition take-back model and dirty sector threshold value obtain through a large amount of experiments, can both represent the normal operating position of flash memory device, accurately, reliably.
Feature of the present invention and advantage will be elaborated in conjunction with the accompanying drawings by embodiment.
[description of drawings]
Fig. 1 is the composition synoptic diagram of flash memory device;
Fig. 2 is the institutional framework synoptic diagram of flash memory device storage block and sector;
Fig. 3 is condition recovery process figure of the present invention;
Fig. 4 is pressure recovery process figure of the present invention.
[embodiment]
Flash memory device comprises MCU (microcontroller), storage array, bottom layer driving module, flash memory storage management module and file system, as shown in Figure 1, file system receive outside (for example external application) reading and writing, wipe request, arrive storage array by flash memory storage management module, bottom layer driving module, MCU carries out reading and writing, erase operation according to the setting output signal of bottom layer driving module to storage array.The flash memory storage management module is responsible for finishing work such as the balanced and bad block management of erasable number of times between each piece, and it carries out various operations by the bottom layer driving module to storage array.Storage array comprises a plurality of, and each piece is made of a plurality of sectors, is also sometimes referred to as " page or leaf ", and each sector is divided into memory block and redundant area, as shown in Figure 2.Have a specific region to store the state of the erasing times of this piece, each sector and the information such as logic number of each sector in each piece, for example whether each sector is deleted and add " dirty " mark, whether be marked as free sector etc.
In order to reduce the erasing times of piece as far as possible, can accomplish again evenly to wipe, present embodiment comes piece is reclaimed by two kinds of ways of recycling, promptly forces to reclaim and the condition recovery.Force to reclaim when being used for write operation, when not having enough free sector to write data, flash memory storage management module controls bottom layer driving module is carried out the maximum piece of storage array apoplexy involving the solid organs sector number and is wiped.Condition reclaims and is used for after carrying out the sector deletion, and the flash memory storage management module is wiped qualified execution in the storage array according to the condition control bottom layer driving module of setting.
Wherein, the idiographic flow of condition recovery is as shown in Figure 3:
In step 201, the flash memory storage management module receives the signal of outside deletion designated sector, the sector of appointment is deleted, and this sector is added " dirty " mark, represents that the data in this sector are invalid, has possessed the necessary condition that reclaims; Execution in step 202 then;
In step 202, the flash memory storage management module produces a positive numerical value at random, and this numerical value is removed with 100, gets its remainder, and then this remainder is to be positioned at a random number of 0~99, and execution in step 203 then;
In step 203, whether the flash memory storage management module judges this random number less than predefined probability separation, and the probability separation is generally the value greater than 50, if this random number less than the probability separation, then execution in step 204; If this random number is more than or equal to the probability separation, then execution in step 205;
In step 205, the flash memory storage management module reads the erasing times in each piece, and the erasing times of all pieces is compared, and finds out the minimum piece of erasing times, and as dirty to be recycled, execution in step 207 then with this piece;
In step 204, whether the sector that the flash memory storage management module reads in each piece has " dirty " mark, adds up the number of sectors that has " dirty " mark in each piece, and execution in step 206 then;
In step 206, whether judge dirty number of sectors in each piece more than or equal to dirty sector threshold value, if dirty number of sectors more than or equal to dirty sector threshold value, then with this or these piece as dirty to be recycled, execution in step 207 then; If dirty number of sectors is less than dirty sector threshold value, then execution in step 210;
In step 207, return piece to be recycled dirty number, execution in step 208 then;
In step 208, the flash memory storage management module will all be changed to " 1 " with the position of the piece that returns number corresponding, this piece be carried out be reclaimed, and execution in step 209 then;
In step 209, the erasing times that the flash memory storage management module will be carried out the piece that reclaims adds 1, and is kept at the specific region of this piece, and execution in step 210 then;
In step 210, the termination condition reclaimer operation.
Probability separation in the above-mentioned steps and dirty sector threshold value all are the experiment conclusion values, determine in conjunction with Mathematical Statistics Analysis method and Flash actual motion effect again, can obtain by the following method: at first fix tentatively one in two running parameters, such as earlier the probability separation being made as 97, allow file system under different dirty sector threshold values, (suppose 1Block=128Sectors, so dirty sector threshold value desirable 127,126,125,124 or the like) operation a period of time, print the erasing times of each piece, and add up maximum erasing times, minimum erasing times, average erasing times.So repeatedly, less in average erasing times, and under maximum erasing times, minimum erasing times and the more approaching situation of average erasing times, determine dirty sector threshold value.Then, change probability separation (desirable 99,98,97,96 or the like), the operation above repeating.Finally obtain an experiment optimum value.
The also available mathematical method of the experiment optimum value that obtains is above carried out analysis verification.With top binary random function of a large amount of measured value structures, be two variablees with probability separation and dirty sector threshold value, be functional value with average erasing times.Utilize data analysis software,, obtain theoretical optimal value, make average erasing times minimum as SPSS or SAS.Then, compare theoretical optimal value and experiment optimum value, see both deviation sizes.
Probability separation and dirty sector threshold value can be input in the flash memory storage management module after determining.
For example the application of probability separation and dirty sector threshold value is described below: through experiment, setting the probability separation earlier is 97.1 piece (block) is 64KB, and calculate by 512 bytes 1 sector (sector), and this piece one has 128 sectors.At this, setting dirty sector threshold value is 120, that is to say, as long as a block apoplexy involving the solid organs sector number is equal to or greater than 120, illustrates that then this piece has reached the condition that condition reclaims.Generate a number at random, remove mould with 100, then obtain the number in 0~99.If the number behind the mould is less than 97, also promptly under 97% probability, seek piece internal organ sector number and be equal to or greater than 120 piece, return piece after finding and number reclaim, if do not find, do not process.Otherwise,, return piece after finding and number reclaim if the number behind the mould more than or equal to 97, also promptly under 3% probability, is sought the piece of erasing times minimum.Reclaim once this piece, the erasing times of this piece is added 1, this value is kept at the ad-hoc location of piece.
The idiographic flow that force to reclaim is as shown in Figure 4:
In step 301, the flash memory storage management module receives outside write operation instruction, and execution in step 302 then;
In step 302, the flash memory storage management module reads the state of each sector, finds out idle sector, and execution in step 303 then;
In step 303, the flash memory storage management module judges whether enough free sector for writing, if having then execution in step 308, does not all have enough free sector for writing if seek all over whole storage array, and then execution in step 304;
In step 304, whether the sector that flash memory storage management module flash memory management module reads in each piece has " dirty " mark, adds up the number of sectors that has " dirty " mark in each piece, finds out the maximum piece in dirty sector, as dirty to be recycled, execution in step 305 then with this piece;
In step 305, return piece to be recycled dirty number, execution in step 306 then;
In step 306, the flash memory storage management module will all be changed to " 1 " with the position of the piece that returns number corresponding, this piece be carried out be reclaimed, and execution in step 307 then;
In step 307, the erasing times that the flash memory storage management module will be carried out the piece that reclaims adds 1, and is kept at the specific region of this piece, and execution in step 308 then;
In step 308, the termination condition reclaimer operation.
After piece is reclaimed, in the available block that reclaims, write data, carry out the modification of logical address simultaneously to the physical address corresponding tables.In reclaiming the process of dirty and write data,,, carry out the data recovery after the power down all by tagged method for preventing unexpected power down.

Claims (6)

1. the dirty block recovery method of a flash memory device is characterized in that: comprise the pressure recycling step that carries out when writing the sector and delete the condition recycling step that carries out behind the sector; Described pressure recycling step may further comprise the steps:
A1, flash memory device receive the write operation instruction;
The writeable free sector of flash memory storage management module searches in B1, the flash memory device;
If C1 does not have enough free sector, then the flash memory storage management module searches goes out the maximum piece in dirty sector and reclaims; Described condition recycling step may further comprise the steps:
A2, flash memory device receive delete instruction, and the flash memory storage management module is deleted designated sector;
B2, flash memory storage management module produce the random number in one 0~99 at random;
C2, this random number and predefined probability separation are compared, if this random number is more than or equal to the probability separation, execution in step E2 then is if this random number is less than the probability separation, execution in step D2 then, wherein the span of probability separation is 1~100;
D2, the dirty sector number and the predefined dirty sector threshold value of each piece compared, for the piece execution in step F2 of dirty sector number greater than dirty sector threshold value, its apoplexy involving the solid organs sector threshold value is the positive integer less than the sector number that each piece comprised;
E2, flash memory storage management module searches go out minimum piece of erasing times and execution in step F2;
F2, this piece is reclaimed.
2. the dirty block recovery method of flash memory device as claimed in claim 1 is characterized in that: also comprise the step that this deleted sector is added " dirty " mark after steps A 2.
3. the dirty block recovery method of flash memory device as claimed in claim 1 is characterized in that: the production method of described random number is to generate any positive integer, with 100 removals, gets its remainder as random number then.
4. the dirty block recovery method of flash memory device as claimed in claim 1, it is characterized in that: described probability separation is 97.
5. as the dirty block recovery method of each described flash memory device in the claim 1 to 4, it is characterized in that: the step that after step D2 or E2, before the step F 2, also comprises the piece number that returns this piece.
6. the dirty block recovery method of flash memory device as claimed in claim 5 is characterized in that: comprise also that after step F 2 erasing times with this piece adds 1 step.
CN200510101856A 2005-11-25 2005-11-25 Dirty block recovery method for flash memory device Active CN100580811C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN200510101856A CN100580811C (en) 2005-11-25 2005-11-25 Dirty block recovery method for flash memory device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN200510101856A CN100580811C (en) 2005-11-25 2005-11-25 Dirty block recovery method for flash memory device

Publications (2)

Publication Number Publication Date
CN1815629A CN1815629A (en) 2006-08-09
CN100580811C true CN100580811C (en) 2010-01-13

Family

ID=36907754

Family Applications (1)

Application Number Title Priority Date Filing Date
CN200510101856A Active CN100580811C (en) 2005-11-25 2005-11-25 Dirty block recovery method for flash memory device

Country Status (1)

Country Link
CN (1) CN100580811C (en)

Families Citing this family (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101436431B (en) * 2007-11-14 2013-01-02 深圳市朗科科技股份有限公司 Data storage method of flash memory medium
US8195870B2 (en) * 2007-11-29 2012-06-05 Silicon Motion, Inc. Memory card and method for handling data updating of a flash memory
CN101339808B (en) * 2008-07-28 2011-02-09 华中科技大学 Erasing method and apparatus of memory block
CN101640069B (en) * 2008-08-01 2013-12-18 群联电子股份有限公司 Average wear method and average wear system for flash memory
CN101751995B (en) * 2008-12-10 2014-10-01 宇瞻科技股份有限公司 Storage device with flash memory and storage method of flash memory
TWI409819B (en) 2009-03-03 2013-09-21 Silicon Motion Inc Method of evenly using a plurality of blocks of a flash memory, and associated memory device and controller thereof
CN101989458B (en) * 2009-07-31 2013-10-30 慧帝科技(深圳)有限公司 Method and memory device for averagely using plurality of blocks of flash memory, and controller
CN102004697B (en) * 2010-10-21 2012-09-19 北京握奇数据系统有限公司 Flash recovery method and device
CN102033945A (en) * 2010-12-21 2011-04-27 中兴通讯股份有限公司 Method and device for recovering garbage
CN102222046B (en) * 2011-06-09 2013-09-18 清华大学 Abrasion equilibrium method and device
CN102253894B (en) * 2011-06-14 2013-09-04 沈阳建筑大学 Method for file storage in continuous space of flash memory in equal probability manner
CN105512049B (en) * 2015-11-23 2019-04-23 联想(北京)有限公司 A kind of memory data recovery method, apparatus and system
CN108153481B (en) * 2016-12-05 2021-08-03 北京兆易创新科技股份有限公司 NAND storage block recovery method and device
CN107092563B (en) * 2017-04-20 2021-02-26 新华三信息技术有限公司 Garbage recovery method and device
CN110968268B (en) * 2019-11-15 2023-03-17 成都智邦科技有限公司 Storage management method and storage structure based on spiflash
CN112181303A (en) * 2020-09-29 2021-01-05 广东艾科技术股份有限公司 Data storage method and device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN1815629A (en) 2006-08-09

Similar Documents

Publication Publication Date Title
CN100580811C (en) Dirty block recovery method for flash memory device
CN102841851B (en) Flash memory management method and flash memory device
CN100565477C (en) A kind of dynamic management approach of NAND Flash storer
CN101425041B (en) Optimizing method for establishing FAT file systems on NAND FLASH memory
CN101980177B (en) Method and device for operating Flash
CN102163175B (en) Hybrid address mapping method based on locality analysis
CN101634967B (en) Block management method for flash memory, storage system and controller
CN101493794B (en) Flash memory data processing method and device
CN100501868C (en) Method for realizing memory file system based on NAND Flash
CN102737715B (en) For the method for power fail safeguard of data of NOR flash memory
US20100185805A1 (en) Method And Apparatus For Performing Wear Leveling In Memory
CN100511166C (en) High-speed storage device and method for high-speed updating data
CN101231617B (en) Method for processing data of flash memory equipment
CN101169760B (en) Electronic hard disk storage room management method
CN101673245A (en) Information processing device including memory management device and memory management method
CN100533408C (en) Flashmemory safety read-write method
TWI434175B (en) Method for performing block management, and associated memory device and controller thereof
CN103336744A (en) Garbage recovery method for solid-state storage device and system for garbage recovery method
CN101923448A (en) Method for reading and writing conversion layer of NAND flash memory
CN101640069A (en) Average wear method, storage system and controller used for flash memory
CN102063380A (en) Method and device for writing data in non-volatile memory
CN102981972A (en) Wear-leveling method for phase change memory
CN102880553B (en) The reading/writing method of the outer FLASH file system of a kind of sheet based on MCU
CN100456263C (en) Method for treating broken block when using flash memory in tax-controlled cashing machine
CN102004697B (en) Flash recovery method and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant