CN101127004A - System and method for accessing data on flash memory - Google Patents

System and method for accessing data on flash memory Download PDF

Info

Publication number
CN101127004A
CN101127004A CNA2007101615249A CN200710161524A CN101127004A CN 101127004 A CN101127004 A CN 101127004A CN A2007101615249 A CNA2007101615249 A CN A2007101615249A CN 200710161524 A CN200710161524 A CN 200710161524A CN 101127004 A CN101127004 A CN 101127004A
Authority
CN
China
Prior art keywords
piece
page
index
copy
storage block
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.)
Granted
Application number
CNA2007101615249A
Other languages
Chinese (zh)
Other versions
CN100555246C (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.)
Nanjing ZTE New Software Co Ltd
Original Assignee
ZTE Corp
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 ZTE Corp filed Critical ZTE Corp
Priority to CNB2007101615249A priority Critical patent/CN100555246C/en
Publication of CN101127004A publication Critical patent/CN101127004A/en
Application granted granted Critical
Publication of CN100555246C publication Critical patent/CN100555246C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

The utility model relates to a method for accessing data from flash memories, which comprises the following steps: a) dividing flash memories into a plurality of segments, each segment stores the wear counting of the erasing times of the segment into a byte on the first page; the segments are subdivided into pages, and each page stores the occupation mark of the page into the initial byte; providing a effective index through checking for each access data copy stored sequentially to memorize the page address and length information of the copies; b) conducting initialization, determining the location of head and the tail segments according to the wear counting of segments, and determining the system wear counting according to the wear counting of the head and the tail segments; c) writing data into and reading data from the flash memory, and distributing the blank page according to the conditions of tail segment, and writing the copy and the index together into the page; or finding effective index according to the location of the tail segment to read the copy. The utility model is suitable for NOR FLASH and NAND FLASH in which the wear balance is achieved through wear counting, and the power failure protection is realized by checking copy index.

Description

A kind of on flash memory the system and method for access data
Technical field
The present invention relates to the numerical information field of storage, relate in particular to a kind of on flash memory the system and method for access data.
Background technology
Along with the development of infotech, the smart machine of internal processor is more and more, and the progress of semiconductor technology makes the price of flash memory (FLASH) constantly reduce again, and smart machine uses FLASH to store data then becomes a kind of natural trend.
Present FLASH mainly is divided into two kinds of NOR FLASH and NAND FLASH, and the both is that unit is wiped with the piece, but NOR FLASH can be that unit writes with the byte, and the data in it can directly read; NAND FLASH then is divided into a plurality of page or leaf with one and is that unit writes with the page or leaf, all must be by special interface to any visit of data.Because these characteristics of FLASH are stored data thereon and need be designed targetedly.
The FLASH piece to wipe the life-span limited, must guarantee during use that the erasing times of each piece is consistent or more approaching, this is referred to as abrasion equilibration; For a lot of smart machines, the unexpected power down during running software is very normal, the data protection when being necessary to realize unexpected power down; In addition, resource-constraineds such as the processor ability of a lot of smart machines, memory span also require code (management software of FLASH or the program code of the file system) size (being length) can be a little bit smaller as far as possible.
JFFS (The Journalling Flash File System: daily record FLASH file system) be a file system towards the FLASH design, the all functions that possess universal document system, but it adopts the form storage data of daily record, along with the growth of revising number of times, load time can be more and more longer, influences the toggle speed of entire equipment.YAFFS (Yet Another Flash File System: another kind of FLASH file system) have the function same, but it can't be applied to NOR FLASH specially at NAND FLASH design with JFFS.Except above problem, these file system are in order to realize all functions of universal document system, and the code size of software is also very big, and toggle speed is slower, can't be applied in that some are not high but require the occasion of code volume height compactness to functional requirement.
Chinese patent CN200610069707 " a kind of method of NAND FLASH storer being carried out the Virtual Space management " adopts mapping table, virtual continuous available logical block is mapped on discrete available physical blocks, and mapping table stored in the administration module of Virtual Space, the bad piece processing section of incoherent each program module can be omitted, simplify the exploitation of upper layer application.This patent focuses on the management of bad piece of FLASH, and the data protection when failing to the abrasion equilibration of utilogic piece and unexpected power down provides solution.
Chinese patent CN200610104289 " management method and the system of the FLASH file in a kind of flash memory " sets up corresponding index according to the attribute of file, be each file memory allocated space on FLASH statically, the FLASH space junk that has produced when having avoided file modification.This patent focuses on the memory allocation of each file on FLASH, and the data protection when failing to the abrasion equilibration of the employed FLASH piece of file and unexpected power down provides solution.
Chinese patent CN01142240 " FLASH storage file management method " is divided into file index district and file data district with FLASH, and the assignment information of the employed FLASH piece of each file is preserved in the index area, and the file data district then is used for store file data.This patent does not provide solution to abrasion equilibration and power-down data protection equally.
United States Patent (USP) WO2007028026 " FLASH DRIVE FAST WEAR LEVELING " adopts the abrasion equilibration table to store the information relevant with the FLASH abrasion equilibration, so that realize abrasion equilibration.This patent need be preserved the abrasion equilibration table separately, and the data protection when not relating to unexpected power down.
U.S. Pat 2006069847 " Corruption tolerant method and system fordeploying and modifyng data in flash memory " is packaged into the data structure storage of consolidation form to FLASH with file content, and determine file modifying by an atomic operation, can when unexpected power down, guarantee the integrality of file data.The data length that this patent is written on the FLASH at every turn changes, so can't implement on NAND FLASH.
European patent EP 1351151A2 " System and method for achieving uniform wearlevels in a flash memory device " recycles each FLASH piece; can guarantee abrasion equilibration; but power-down protection need carry out at least twice write operation to same sector, so its power-down protection can't be realized on NAND FLASH.
Generally speaking, store on FLASH at present in the solution of data, the FLASH file system realizes complicated and bulky, is not suitable for the not high lightweight application scenario of ask for something; And the data protection of some comparatively simple implementations when often being unrealized abrasion equilibration and power down.
Summary of the invention
Technical matters to be solved by this invention provide a kind of on flash memory the system and method for access data, can overcome prior art access data on flash memory implements complicated huge, shortcoming such as perhaps function is imperfect, system and method provided by the invention is simple, is common to NOR FLASH and NAND FLASH; And have abrasion equilibration and power-down protection simultaneously.
In order to solve the problems of the technologies described above, provided by the invention a kind of on flash memory the system of access data, comprise the flash memory structure division module and the initialization module that are connected with flash memory respectively, and the data writing module and the data read module that are connected with initialization module respectively; Wherein:
Flash memory structure is divided module, is used for flash memory is divided into a plurality of storage blocks, as the base unit of erase operation, and preserves the wearing and tearing counting in first page therein; Storage block is divided into a plurality of memory pages again,, and in one or more initial storage unit of memory page, preserves the busy flag of memory page as the base unit of write operation; For sequential storage each data trnascription on flash memory is settled an index;
Initialization module is used for flash memory is carried out initialization operation, promptly determines the position of a piece and tail piece according to the wearing and tearing counting of storage block on the flash memory, determines the system wear counting according to the wearing and tearing counting of a piece or tail piece again;
The data writing module, being used for according to the block condition of the current tail of flash memory is that data trnascription distributes blank page, and data trnascription is write in the described blank page of distribution with the index order;
Data read module is used for finding according to the current tail piece of flash memory position the index of the data trnascription that will read, and according to the information reading of data copy in the index.
Further, initialization module:
With first sky piece of flash memory as the tail piece; If the storage block behind first sky piece still is empty piece, then first storage block is a piece, and the system wear counting is 1; If the storage block behind first sky piece be empty piece, in two kinds of situation: when empty piece is not last storage block, the storage block behind the then empty piece be a piece, and the wearing and tearing of this piece are counted and added 1 and be system wear and count; And work as empty piece is last storage block, and then first storage block is a piece, and the wearing and tearing counting of this piece is the system wear counting;
Perhaps, there is not empty piece in flash memory, counts for described system wear with the wearing and tearing counting of tail piece; When existing two adjacent memory blocks wearing and tearing to count the boundary that diminishes, the storage block of boundary front is the tail piece, and the storage block of boundary back is a piece; If there is not boundary, be the tail piece then with last storage block, be a piece with first storage block.
Further, the data writing module further comprises copy segmentation writing module, page or leaf distribution module and the piece distribution module that connects successively, comprises that also the copy index that is connected with copy segmentation writing module generates and the verification module, wherein:
Copy segmentation writing module is connected with flash memory, be used for the data trnascription content being cut into plurality of sections according to the capacity of memory page, be that each section is distributed a blank page to the application of page or leaf distribution module then, content in the section is write blank page together with system wear counting or busy flag; And the address information of preserving the shared page or leaf of first section first byte and final stage trail byte, or preserve the page address that first section first byte take and the length information of copy; The copy index generate and verification module ghost index and check information thereof after, copy index and check information thereof write but a blank page distributing in;
The page or leaf distribution module is connected with initialization module, is used to copy segmentation writing module order assignment blank page, promptly when the tail piece is not full piece, with the blank page of endpage as distribution; When the tail piece is full piece, distribute an empty piece to the application of piece distribution module, and first page of blank page as distribution in the empty piece that will distribute;
The piece distribution module is connected with initialization module, is used for dividing timing at the empty piece of page or leaf distribution module application, is storage block of its order assignment: promptly when the tail piece be not last storage block, with thereafter a storage block as the piece that distributes; When the tail piece is described last storage block, count then with the piece of first storage block, and with system wear to add 1 as distribution; If the piece that distributes is a current piece, then a piece is moved to the next storage block of the piece of distribution; Dispense as new tail piece after the piece that will distribute is wiped at last;
The copy index generates and the verification module, the length information that is used for page address that the first byte according to copy takies and copy generates the index about copy, or the page address information that takies of the page address that takies according to the first byte of copy and last byte thereof generates the index about copy; Simultaneously, the index of copy is carried out verification forming effective index, and generate check information in view of the above, pass to copy segmentation writing module together in company with the copy index.
Further, data read module further comprises indexed search module, index read module and the copy read module that connects successively, wherein:
The indexed search module is used for from the tail BOB(beginning of block) to a block search, and traversal is each memory page wherein, until the index that finds first effective index for the data trnascription that will read;
The index read module, be used for reading the index of up-to-date data trnascription from effective index, obtain the page address that the copy first byte takies and the length information of described copy, perhaps obtain the page address information that page address that described copy first byte takies and its last byte take;
The copy read module is connected with flash memory, is used for the information according to the index that obtains, and reads the content of copy from the memory page of correspondence.
Further, piece does not all find effective index if the indexed search module is searched for to the end always, and then failure is read in report; Perhaps, if first page address that the copy that reads takies has exceeded the scope that covers to the tail piece when the front piece, then failure is read in report.
In order to solve the problems of the technologies described above, provided by the invention a kind of on flash memory the method for access data, comprise the steps:
(a) divide flash memory, the specified data structure, promptly
Flash memory is divided into a plurality of storage blocks, as the base unit of each erase operation; Every is distributed one or more byte to be used for wearing and tearing counting, the information of storing relevant memory block erasing number of times in first page; Again storage block further is divided into a plurality of memory pages, as the base unit of each write operation; Whether every page of busy flag that uses initial byte units as this page has been written into data in order to discern this page or leaf;
For sequential storage each data trnascription on flash memory is settled an index;
(b) system initialization promptly according to the definite piece of wearing and tearing counting of storage block on the flash memory and the position of tail piece, is determined the system wear counting according to the wearing and tearing counting of a piece or tail piece again;
(c) on flash memory, carry out writing of data trnascription or read operation, promptly distribute blank page, and data trnascription is write in the blank page of distribution with the index order according to the situation of tail piece according to the tail piece; Perhaps, find the index of the data trnascription that will read according to tail piece position, and according to the information reading of data copy in this index.
Further, step (b) also comprises step:
If there is empty piece in flash memory, with first sky piece of flash memory as the tail piece; If the storage block behind first sky piece still is empty piece, then first storage block is a piece, and the system wear counting is 1; If the storage block behind first sky piece be empty piece, in two kinds of situation: when empty piece is not last storage block, the storage block behind the then empty piece be a piece, and the wearing and tearing of this piece are counted and added 1 and be system wear and count; And work as empty piece is last storage block, and then first storage block is a piece, and the wearing and tearing counting of this piece is the system wear counting;
If there is not empty piece in flash memory, counting with the wearing and tearing of tail piece is the system wear counting; When existing two adjacent memory blocks wearing and tearing to count the boundary that diminishes, the storage block of this boundary front is the tail piece, and the storage block of boundary back is a piece; If there is not boundary, then last storage block is the tail piece, and first storage block is a piece.
Further, the write operation of step (c) data trnascription also comprises the steps:
(c1) capacity according to memory page is cut into a plurality of sections with the data trnascription content, be followed successively by blank page of each section distribution then, and content in the section write blank page together with system wear counting or busy flag, simultaneously, preserve the page address information that first section first byte and final stage trail byte take, or preserve the page address that first section first byte take and the length information of copy;
(c2) length information of page address that takies according to the first byte of copy and copy generates the index about described copy, or the page address information that takies of the page address that takies according to the first byte of copy and last byte thereof generates the index about copy; Simultaneously, verification and the relevant check information of generation that index is carried out;
(c3) distribute a blank page, and index and check information are write this blank page, form effective index.
Further, in the preceding step that also comprises of step (c1): according to effective index reading of data copy content and make amendment.
Further, step (c1) and step (c3) distribute the operation of a blank page to comprise the steps: if the tail piece is not full piece, then with the blank page of the endpage in the tail piece as distribution; If the tail piece is full piece, then distribute an empty piece, and first page that should the sky piece is as the blank page that distributes.
Further, distribute the operation of an empty piece to comprise the steps:
(1) if the tail piece is not last storage block, then general's storage block thereafter is as the piece that distributes; As if the tail piece is last storage block, counts then with the piece of first storage block as distribution, and with system wear to add 1;
(2) dispense as new tail piece after the piece that will distribute is wiped.
Further, step (1) also comprises step: if the piece that distributes is a current piece, then a piece is moved to the next storage block of the piece of distribution.
Further, step (c) data trnascription read operation also comprises the steps:
(c1) from the tail BOB(beginning of block) to a block search, wherein each memory page of traversal is up to the effective index that finds first by verification;
(c2) from effective index, read up-to-date index, obtain the page address that the copy first byte takies and the length information of copy, perhaps obtain the page address information that page address that the copy first byte takies and its last byte take;
(c3) information in the basis index that reads reads the content of described data trnascription from the memory page of correspondence.
Further, step (c1) is from the last page of tail piece, move forward the direction search of one page backward to a piece at every turn, up to finding an occupied memory page, and judge that according to the index mark value of memory page the content of memory page is an index, and judge that according to the check information of this index it is effective index; Piece does not all find effective index if search for to the end always, and then failure is read in report; Perhaps, if first page address that the described copy that reads takies has exceeded the scope that covers to the tail piece when the front piece, then failure is read in report.
Further, step (c3) reads each memory page to the direction of tail piece successively from first page beginning that copy takies, peel off after busy flag and the index mark, remaining byte is carried out assembly unit and recovered the copy content, and the byte number that last page participates in assembly unit takies page address by the last byte of the length of the copy of preserving in effective index or copy and calculates.
Further, initial two bytes with storage block first memory page are used for storage wearing and tearing counting, the storage mode that adopts every negate to write again; Initial two bytes of memory page are used for busy flag,, show that promptly this page or leaf is occupied as long as wherein content is not complete 1; The wearing and tearing counting while is as the busy flag of first memory page; The 3rd byte of memory page be as the value of statistical indicant of index, wherein, with first this page of value representation storage be an index, with second this page of value representation storage is the copy content; The interior perhaps index of data trnascription begins storage from the 4th byte of each memory page.
Further, 32 cyclic redundancy check (CRC) mechanism are adopted in the verification of index.
Carry out the flash data storage with system and method provided by the invention, principle is simple, adopts the date storage method of piece, page or leaf hierarchical data structure and built-in block wearing and tearing counting can be common to NOR FLASH and NAND FLASH; Abrasion equilibration and power-down protection also are provided simultaneously, promptly adopt order assignment page or leaf, piece and wearing and tearing counting to realize the abrasion equilibration of FLASH, adopt copy index and verification scheme thereof that the power down protection merit is provided.The present invention compared with prior art can save the development time, reduces cost of products, enhances product performance, and needing in the smart machine to be very suitable for the storage of the frequent low volume data of revising.
Description of drawings
Fig. 1 a is a system architecture diagram of storing data on FLASH provided by the invention;
Fig. 1 b is that the present invention draws the formed hierarchical chart of Block Paging to FLASH;
Fig. 2 has provided the relation between the present invention's piece, tail piece and wearing and tearing counting and each storage block;
Mapping relations when Fig. 3 has provided data trnascription of the present invention and stores in page or leaf;
Fig. 4 is the process flow diagram that the present invention determines a piece, tail piece and system wear counting;
Fig. 5 is the process flow diagram that the present invention distributes blank page.
Embodiment
The method that goes up access data at flash memory (FLASH) of the present invention is based on a kind of like this thinking:
(1) adopt piece, page or leaf hierarchical data structure and built-in block wearing and tearing counting: the FLASH that will be used for data storage is divided into several " storage blocks ", as the base unit of each erase operation; Again storage block further is divided into several " memory pages ", as the base unit of each write operation.Wherein, every is distributed some bytes to be used for " wearing and tearing counting ", the information of relevant this piece erasing times of storage in first page; Whether every page of " busy flag " that also will use initial some bytes as this page has been written into data in order to discern this page or leaf.
(2) adopt empty piece order assignment mechanism: page or leaf order assignment in piece, all pages or leaves all distribute in the if block, then need to distribute a new piece, and piece also adopts the mode of order assignment; If be assigned to last piece, then wipe first and be used for distributing.
(3) adopt copy index and verification scheme thereof: data are kept on the FLASH with the form of copy, if data have been carried out any modification, all data must be saved in the new copy again each copy sequential storage on FLASH.Each copy all has the index of a correspondence, contains the relevant informations such as page address that this copy takies.Index is write and is fashionablely taked verification scheme so that verify the validity of this index when reading later on.
During reading of data, earlier according to effective index of copy, the information such as page address of obtaining copy length and taking read the content of copy then from the page or leaf of correspondence according to this information of obtaining.
When writing data, the copy content is cut into plurality of sections, is followed successively by every section then and distributes a blank page and content in the section is write this page or leaf, preserve first and the address information of shared page of final stage simultaneously respectively according to the capacity of page or leaf; Generate index according to the information such as length of this page address information and copy, generate check information according to the verification scheme of being taked simultaneously about this index about this copy; At last, distribute a blank page, and index and check information thereof are write this page or leaf.
The present invention realizes the abrasion equilibration of FLASH by the wearing and tearing counting, i.e. wearing and tearing countings can under any circumstance (comprise powered-off fault) positioning head piece and tail piece, and the distribution mechanism of empty piece can guarantee that each piece is recycled order and wipes, thereby guarantees each piece erasing times about equally.In addition, the present invention provides power-down protection at data by copy index and verification scheme thereof, i.e. power down in the copy ablation process is not owing to write index; Or power down in copy index ablation process, because this index can't pass through data check information, all can make corresponding copy can not be read.
Below in conjunction with specific embodiments and the drawings, elaborate technique scheme of the present invention.
Before being described in detail technical solution of the present invention, define several technical terms first:
Piece: expression FLASH goes up the oldest storage block of content;
Tail piece: represent that the last content of FLASH is up-to-date or can be the storage block that next write operation provides memory page;
Piece unrolls: after from the beginning piece order backward operation finishes last storage block on the expression FLASH, forward the process of the enterprising line operate of first storage block again to, and the inverse process of said process;
Empty piece: the storage block that does not write any content behind the FLASH is as yet wiped in expression;
Blank page: the memory page that does not write any content behind the FLASH is as yet wiped in expression;
Full piece: the storage block that does not comprise blank page on the expression FLASH;
Endpage: expression FLASH goes up first blank page in the tail piece;
Wearing and tearing counting: represent that relevant storage block is wiped free of the information of number of times, uses some bytes store;
System wear counting: the wearing and tearing counting of representing current distributed store blocks (tail piece);
Busy flag: whether the expression memory page has been written into the information of data, uses some bytes store;
Copy: be illustrated in FLASH and go up the form of preserving data;
Any modification of FLASH being gone up data all must be stored as a new copy on FLASH;
The copy index: the page address that is taken by the copy first byte and the length (is unit with the byte) of copy are formed; Perhaps the page address that takies of page address that is taken by the copy first byte and the last byte of copy is formed;
Index is write and fashionablely must be carried out verification to index, and generates the check information about this index in view of the above, so that verify the validity of this index when reading index later on.
Effective index: can be correctly index by data check.
As shown in Figure 1a, provided by the invention on FLASH the system 100 (among the figure shown in the empty frame) of storage data comprise: the flash memory structure division module 110 and the initialization module 120 that are connected with flash memory respectively, and data read module 130 that is connected with initialization module 120 respectively and data writing module 140.Wherein:
Flash memory structure is divided module 110, is used for FLASH is divided into several storage blocks, as the base unit of each erase operation, and preserves the wearing and tearing counting in its first page, shown in Fig. 1 b; Storage block is divided into several memory pages again,, and in its several initial storage unit, preserves busy flag as the base unit of each write operation;
Fig. 1 b has provided FLASH divided block of the present invention and the formed hierarchical structure of page or leaf.The whole FLASH101 that is used for data storage is divided into several storage blocks 103, and preserves wearing and tearing counting 102 in its first page; Each storage block further is divided into several memory pages 105 again, and preserves busy flag 104 in its several initial storage unit.
Initialization module 120 is used for when FLASH powers on it being carried out initialization operation, determines a piece, tail piece and the system wear counting of FLASH; Promptly count the position of finding a piece and tail piece, determine the system wear counting according to the wearing and tearing counting of a piece or tail piece again according to the wearing and tearing on the storage block.
The present invention's piece, tail piece position and the corresponding wearing and tearing counting in FLASH sees also Fig. 2.First storage block 201 and several storage blocks 202 subsequently are N up to the wearometer number average of M piece 203; M+1 piece 204 and several storage blocks 205 subsequently to the last the wearometer number average of a storage block 206 are N-1; Wherein, M piece 203 is the tail piece, and M+1 piece 204 is a piece, and four-headed arrow 207 expression piece between first storage block 201 and last storage block 206 and the piece between the tail piece unroll.Fig. 2 provides be generally a piece and the distribution of tail piece, just brought into use or during powered-off fault, it is complicated that situation will become at FLASH.
Therefore, initialization module 120 need be when FLASH one powers on, and can accurately locate a piece, tail piece and the system wear counting of FLASH at various situations (as shown in the table 1 of back), so that make sufficient preparation for subsequent order memory allocated page or leaf and storage block.
The present invention proposes a kind of but is not limited to the implementation of this initialization module 120:
With first sky piece of FLASH as the tail piece; If the storage block behind this first sky piece is not empty piece (promptly only having an empty piece), in two kinds of situation: when this sky piece is not last storage block, the storage block after then should the sky piece be a piece, and the wearing and tearing counting of this piece adds 1 and is system wear and counts; And work as this sky piece is last storage block, and then first storage block is a piece (piece takes place to unroll), and the wearing and tearing counting of this piece is the system wear counting; If the storage block behind this first sky piece still is empty piece (having two empty pieces at least), then first storage block is a piece, and the system wear counting is 1;
Perhaps, if there is not empty piece in FLASH, counting with the wearing and tearing of tail piece is the system wear counting; When existing two adjacent memory blocks wearing and tearing to count the boundary that diminishes, the storage block of this boundary front is the tail piece, and the storage block of this boundary back is a piece; If there is not this boundary, be the tail piece then with last storage block, first storage block is a piece.
Data writing module 130 is used for according to the current tail piece of FLASH data trnascription being write the memory page of storage block with the copy index; This module further comprises copy segmentation writing module 131, page or leaf distribution module 132 and the piece distribution module 133 that connects successively, comprises that also the copy index that is connected with copy segmentation writing module 131 generates and verification module 134, wherein:
Copy segmentation writing module 131 is connected with FLASH, be used for the data trnascription content being cut into plurality of sections according to the capacity of FLASH memory page, distribute a blank page to 132 applications of page or leaf distribution module for each section then, and copy content in the section write this blank page together with system wear counting or busy flag, preserve the address information of the shared page or leaf of first section and final stage simultaneously respectively; Behind the generation of copy index and verification module 134 ghost index and check information thereof, for it distributes a blank page it is write this page or leaf again;
Data of the present invention are kept on the FLASH with the form of copy, if data have been carried out any modification (revising a part or whole no matter be), all data must be saved in again in the new copy each copy sequential storage on FLASH.Each copy all has the index of a correspondence, wherein contain the relevant informations such as page address that this copy takies, Index List is monopolized and is used one page, and then the copy of its sensing storage, and distinguished by the sign in the page or leaf, index is write and fashionablely must be taked verification scheme, so that verify the validity of this index when reading later on.
Page or leaf distribution module 132 is connected with initialization module 120, is used to copy segmentation writing module 131 order assignment blank pages; When the tail piece is not full piece, with endpage as distribution result; When the tail piece is full piece, distribute an empty piece to piece distribution module 133 application, and in should the sky piece first page is as allocation result;
Page or leaf of the present invention is as basic allocation unit order assignment in piece of storage space, and all pages or leaves all distribute in the if block, then need to distribute a new piece, and piece also adopts the mode of order assignment, if be assigned to last piece, then wipe first and is used for distributing.
Piece distribution module 133 is connected with initialization module 120, is used for being empty piece of its order assignment when the empty piece of page or leaf distribution module 132 applications;
When the tail piece is not last storage block, with thereafter a piece as distribution result; When the tail piece is last storage block, then with first storage block as distribution result, and the system wear counting added 1; If the piece that distributes is a current piece, then a piece is moved to the next piece (piece may take place to unroll) of the piece of distribution; Dispense as new tail piece after the piece that will distribute is wiped at last.
The copy index generates and verification module 134, the information such as length that are used for the page address information of preserving according to copy segmentation writing module 131 and copy generate the index about this copy, simultaneously this index is carried out verification, for example adopt 32 cyclic redundancy check (CRC), and generate check information in view of the above about this index, pass to copy segmentation writing module 131 together in company with the copy index.
Data read module 140 is used for reading from FLASH the data trnascription of access; This module further comprises connection successively:
Indexed search module 141, the tail BOB(beginning of block) that is used for determining from initialization module 120 is to a block search (piece may take place to unroll), and traversal is each memory page wherein, until the effective index that finds first by verification;
Index read module 142 is used for reading from effective index the index of up-to-date data trnascription, the information such as page address of obtaining copy length and taking;
Copy read module 143 is connected with FLASH, is used for the page address that takies according to the copy first byte that reads and copy length information read copy from the memory page of correspondence content; Perhaps read the copy content according to the copy page address that reads (comprising that first byte takies and last byte takies) information.
The present invention's data storing method step on flash memory is as follows:
Step 1: divide FLASH, the specified data structure comprises following substep:
The FLASH that will be used for data storage is divided into several " storage blocks ", as the base unit of each erase operation; Every is distributed some bytes to be used for " wearing and tearing counting ", the information of relevant this piece erasing times of storage in first page; Again storage block further is divided into several " memory pages ", as the base unit of each write operation; Every page also will be used initial some bytes whether to be written into data as " busy flag " of this page in order to discern this page or leaf; The busy flag of conduct page or leaf is simultaneously counted also in wearing and tearing;
Data are kept on the FLASH with the form of copy, each copy sequential storage on FLASH.Each copy all has the index of a correspondence, wherein contain the page address that this copy takies and the relevant informations such as length of copy, Index List is monopolized and is used one page, and then the copy of its sensing storage, and distinguished by the sign in the page or leaf, index is write and fashionablely must be taked verification scheme, so that verify the validity of this index when reading later on;
Mapping relations when Fig. 3 has provided data trnascription of the present invention and stores in page or leaf, the copy A among the figure has represented two kinds of different mapped modes respectively with copy B:
Copy A does the storage continuously of as a whole order in FLASH, it has occupied from L page or leaf 305 to the some pages or leaves the M+1 page or leaf 308, wherein 305 storages of L page or leaf are its 1st page, the 2nd page of L+1 page or leaf 306 storage ... last 1 page of M page or leaf 307 storages, M+1 page or leaf 308 has then been stored the index of copy A;
Copy B then is divided into two parts and is stored among the FLASH, and to last 1 page 311 a preceding part of storing copy B, wherein the 1st page of N page or leaf 309 stored copies B, the N+1 page or leaf is stored the 2nd page from N page or leaf 309 ... last page 311 storage H pages or leaves.Then stored a back part from the 1st page 301 up to K+1 page or leaf 304, wherein the H+1 page or leaf of the 1st page of 301 stored copies B is stored the H+2 page or leaf for the 2nd page 302 ... last 1 page of K page or leaf 303 storages, the index of K+1 page or leaf 304 stored copies B, obviously, copy B has experienced piece and has unrolled in storing process.
For example present embodiment selects for use NAND FLASH as storage medium, directly divide storage block according to the length of its physical block, and memory page also is to divide according to the length of its Physical Page, and promptly storage block is consistent with memory page with FLASH piece physically and page or leaf.
Every two initial bytes are counted as wearing and tearing, it is defined as the number of times that writes data when this piece of forward direction, the wearing and tearing counting is exactly the erasing times of this piece under the normal condition, and under situations such as powered-off fault, then may repeatedly wipe same and just write data then.The storage of wearing and tearing counting adopts every negate to write the mode of FLASH again, and like this for empty piece, its wearing and tearing that read counting will be null value, can discern the clearancen piece in view of the above.
Two bytes of every start of Page as busy flag, as long as wherein content is not complete 1, are shown that promptly this page or leaf is occupied.According to the definition and the storage mode thereof of wearing and tearing counting, it can serve as the busy flag of interior first page of piece simultaneously.
The index of copy is made up of the length (is unit with the byte) of this copy, the page address that its first byte takies, the page address that its last byte takies, the sign that uses every page the 3rd byte to be used as distinguishing copy index and content is an index mark, what null value was represented this page storage is an index, what nonzero value was then represented to store is the part of copy content, and it is CRC32 that the verification scheme of index adopts 32 cyclic redundancy check (CRC).Because preceding two bytes of page or leaf have been used for busy flag, the 3rd byte is used for index mark, so the content of copy and index all can only begin storage from every page the 4th byte.
With respect to the length of copy, the capacity of FLASH is must be enough big, so that when wiping certain piece and being used to reallocate, the copy that this piece is stored is out-of-date, has stored newer complete copy in piece thereafter.
Step 2: system initialization, determine that a piece, tail piece and the system wear of FLASH counted, promptly search the position of a piece and tail piece according to the wearing and tearing counting of storage block, determine the system wear counting according to the wearing and tearing counting of a piece or tail piece again;
Because the present invention is by keeping memory page, storage block order assignment and wearing and tearing counting the abrasion equilibration of FLASH, therefore, step 2 of the present invention is by following substep but be not limited to such substep, realize that FLASH is comprising the power-up initializing in any case of unexpected power down, thereby order assignment memory page, storage block and sense data copy are ready when writing data trnascription:
If there is empty piece in FLASH, with first sky piece of FLASH as the tail piece; If the storage block behind this first sky piece is not empty piece (promptly only having an empty piece), in two kinds of situation: when this sky piece is not last storage block, the storage block after then should the sky piece be a piece, and the wearing and tearing counting of this piece adds 1 and is system wear and counts; And work as this sky piece is last storage block, and then first storage block is a piece (piece takes place to unroll), and the wearing and tearing counting of this piece is the system wear counting; If the storage block behind this first sky piece still is empty piece (promptly having two empty pieces at least), then first storage block is a piece, and the system wear counting is 1;
If there is not empty piece in FLASH, counting with the wearing and tearing of tail piece is the system wear counting; When existing two adjacent memory blocks wearing and tearing to count the boundary that diminishes, the storage block of this boundary front is the tail piece, and the storage block of this boundary back is a piece; If there is not this boundary, be the tail piece then with last storage block, first storage block is a piece.
For above initialization substep, numerous embodiments can be arranged:
(a) a kind of is to count the boundary that diminishes to search for two adjacent memory blocks wearing and tearing, runs into the sky piece in search procedure, then handles by above-mentioned empty piece processing mode, for example following substep:
(1) begin to search backward successively from first storage block, navigate to the boundary that former and later two adjacent block wearing and tearing countings diminish, then the piece of this boundary front is the tail piece, and the piece of back is a piece, and the wearing and tearing counting of tail piece is counted as system wear;
(2) (the wearing and tearing counting of empty piece will be a particular value if run into an empty piece in the search process of substep (1), such as 0xFF), should the sky piece be the tail piece then, back one (piece may take place to unroll) is a piece, if should the sky piece be last storage block, just directly with the wearing and tearing counting of a piece as the system wear counting, otherwise the wearing and tearing counting of a piece is added that 1 counts as system wear;
(3) if in substep (1), found continuous plural empty piece, then first storage block is a piece, and first sky piece is the tail piece, if a piece is exactly empty piece, it is 1 that system wear counting then is set, otherwise the wearing and tearing counting of getting a piece is counted as system wear.
Handle like this is because actual search is seldom to the probability of empty piece: a kind of situation is that equipment is brought into use and piece did not also take place unrolled, and another situation is exactly just power down after having wiped empty piece.Thereby, serve as that main the processing can make the efficient of system initialization higher with the search boundary.
(b) another kind is to have or not the sky piece on the search FLASH earlier, searches for the boundary that whether exists former and later two adjacent blocks wearing and tearing countings to diminish then under the situation that does not have empty piece again.Because being a particular value, the wearing and tearing of empty piece counting (for example is 0xFF, the 0x00 negate obtains), so this hunting action is fairly simple, equipment bring into use also do not take place piece unroll and took place just wiping empty piece after the situation of power down, adopt this mode velocity ratio very fast.But when do not exist on the FLASH empty piece (taken place piece unroll and empty piece did not take place to have wiped after the situation of power down) time, then this mode may cause will traveling through for every time just can finish initialization operation twice.
(c) another is used in combination above-mentioned dual mode exactly, such as the flow process shown in Fig. 4, and this flow process will describe in detail in the application example in the back.Perhaps, take place piece unroll before (representing) with a zone bit based on mode b, and after the generation piece unrolls (removing this zone bit) based on mode a.In conjunction with the advantage of dual mode, can make that all the initialization efficient of system is more excellent like this.
The invention provides above-mentioned initialized numerous embodiments, but be not limited to these modes, the embodiment of any embodiment connotation of the present invention is all within protection domain of the present invention.
Tell about the enforcement of above-mentioned initialization operation below in conjunction with a concrete application example.
Just brought into use or during powered-off fault, situation can be different with normal use at FLASH.In table 1, according to the definition and the storage mode thereof of wearing and tearing counting, consider the powered-off fault in the operating process again, the value combination is counted in the wearing and tearing of each piece be divided into following several modes:
Table 1 (N in the table is the natural number greater than 1)
Pattern 1 N N N N N 0
Illustrate: last piece is the sky piece, and the wearing and tearing counting of all the other pieces all is an identical value N;
Occurrence condition: power down after when distributing empty piece, wiping last piece; The processing mode of correspondence in Fig. 4: step 405
Pattern 2 0 0 0 0 0 0
Illustrate: all pieces are sky piece occurrence condition: the processing mode of the correspondence in Fig. 4 of initialization for the first time: step 407
Mode 3 1 1 0 0 0 0
Illustrate: the wearing and tearing counting that the front is some is 1, and the back has at least two to be empty piece; Occurrence condition: just bring into use, do not use last piece (comprising powered-off fault) as yet; The processing mode of correspondence in Fig. 4: step 407
Pattern 4 0 N N N N N
Illustrate: first is empty piece, and the wearometer number average of all pieces subsequently is an identical value N; Occurrence condition: distribute empty piece generation piece to unroll powered-off fault after having wiped first; The processing mode of correspondence in Fig. 4: step 408
Pattern 5 N+1 N+1 N+1 0 N N
Illustrate: the wearing and tearing counting that the front is some is N+1, and subsequently one is empty piece, and remaining piece wearometer number average is N; Occurrence condition: power down after distributing empty piece to wipe middle a certain; The processing mode of correspondence in Fig. 4: step 408
Pattern 6 N+1 N+1 ?… N+1 N N N
Illustrate: the wearing and tearing counting that the front is some is N+1, and remaining piece wearometer number average is N; Occurrence condition: normally use and piece took place and unroll; The processing mode of correspondence in Fig. 4: step 410
Mode 7 N N N N N N
Illustrate: the wearing and tearing counting of all pieces all is N; Occurrence condition: the normal use just uses last piece; The processing mode of correspondence in Fig. 4: step 413
The several modes of the wearing and tearing of each piece shown in the table 1 counting can be handled according to the flow process of determining a piece, tail piece and system wear counting shown in Figure 4, and it is that this flow process comprises the steps: to the specializing of above-mentioned initialization operation mode c
401: beginning;
402: first piece as current block, is begun traversal;
403: judge that whether current block is the sky piece, is then to change 404, otherwise changes 419;
404: judge that whether current block is last piece, is then to change 405, otherwise changes 406;
405: as the tail piece, first is a piece with current block, and a piece wearing and tearing counting adds 1 as the system wear counting, changes 414;
406: judge that whether back one also be the sky piece, is then to change 407, otherwise changes 408;
407: as the tail piece, first is a piece with current block, and it is 1 that the system wear counting is set, and changes 414;
408: as the tail piece, back one is a piece with current block, and a piece wearing and tearing counting adds 1 as the system wear counting, changes 414;
409: judge that whether current block is that the 1st and wearing and tearing counting are littler than last, is then to change 410, otherwise changes 411;
410: with current block is a piece, and last is the tail piece, and the wearing and tearing counting of tail piece changes 414 as the system wear counting;
411: judge that whether current block is last piece, is then to change 413, otherwise changes 412;
412: next piece as new current block, is changeed 403;
413: current block is the tail piece as a piece with first, and the wearing and tearing counting of tail piece is counted as system wear;
414: finish.
Step 3: write, the practical operation of reading of data
The present invention writes data can be subdivided into following substep:
(1) capacity according to page or leaf is cut into plurality of sections with the copy content, is followed successively by blank page of each section distribution then and the section content is write this page or leaf, preserve respectively simultaneously first with last section shared the page or leaf address information;
(2) information such as length of page address information of being preserved according to substep (1) and copy generate the index about this copy, generate check information about this index according to the verification scheme of being taked simultaneously;
(3) distribute a blank page, and with index extremely check information write this page or leaf.
Attention: in above-mentioned substep (1) and (3), system wear counting and busy flag will be write together when " writing this page or leaf ".
Because page or leaf of the present invention is as basic allocation unit order assignment in piece of storage space, all pages or leaves all distribute in the if block, then need to distribute a new piece, and piece also adopts the mode of order assignment, if be assigned to last piece, then wipe first and be used for distributing.Therefore, need by following regular allocation blank page or empty piece.
In the aforementioned substep 1 and 3, the substep that " distributing a blank page " comprises is as follows:
(1) if the tail piece is not full piece, then with endpage as distribution result;
(2) if the tail piece is full piece, then distribute an empty piece, with this piece first the page or leaf as distribution result.
Fig. 5 distributes the process flow diagram of blank page for the present invention, and it is that flow process comprises the steps: among the figure to the specializing of above-mentioned substep
501: beginning;
502: judge that whether the tail piece has been write completely, is then to change 504, otherwise changes 503;
503: endpage as allocation result, and is changeed 510;
504: judge that whether the tail piece is last storage block, is then to change 506, otherwise changes 505;
505: the next piece behind the tail piece as new tail piece, and is changeed 507;
506: with first storage block as new tail piece and increase progressively system wear counting;
507: judge that whether the tail piece overlaps with a piece, is then to change 508, otherwise changes 509;
508: a piece is adjusted a piece (piece may take place to unroll) to the direction of tail piece;
509: find new tail piece and with first page of tail piece as allocation result;
510: finish.
The substep that " distributes an empty piece " in the above-mentioned distribution blank page process is as follows:
(1) if the tail piece is not last storage block, then general's piece thereafter is as distribution result; If the tail piece is last storage block, then with first storage block as distribution result, and system wear counting added 1;
(2) if the piece that substep (1) distributes is a current piece, then a piece is moved to the next piece (piece may take place to unroll) of the piece of distribution;
(3) dispense as new tail piece after the piece that substep (1) is distributed is wiped.
It should be noted that because the existence of the piece mechanism of unrolling need be limited the length of copy, for simplicity, can limit it and be no more than FLASH capacity 1/3rd.
Reading of data of the present invention can be subdivided into following substep:
(1) from the tail BOB(beginning of block) to a block search (piece may take place to unroll), the traversal wherein each the page or leaf, up to the effective index that finds first by verification;
Promptly from the last page of tail piece, move forward the direction search (piece may take place unroll) of one page backward to a piece, be zero (expression is an index) and have expression by till the check information of CRC32 verification up to having found occupied, the index mark of certain page or leaf at every turn.
Piece does not all find satisfactory index if search for to the end always, then reads failure.
If first page address that the copy that reads takies has exceeded when the scope of front piece to the covering of tail piece, then read failure.
(2) read the index of up-to-date data trnascription from effective index, the information such as page address of obtaining copy length and taking are perhaps obtained the page address information that page address that the copy first byte takies and its last byte take;
(3) from the page or leaf of correspondence, read the content of copy according to the index information that reads.
Read each FLASH page or leaf to the direction of tail piece successively from first page beginning that copy takies, peel off after the busy flag and index mark of first three byte, recover the copy content thereby remaining byte is carried out assembly unit, the byte number that last page participates in assembly unit is calculated by the copy size of preserving in the index.
The present invention realizes being common to the data storage of NOR FLASH and NAND FLASH by piece/page or leaf hierarchical data structure of FLASH; Adopt the abrasion equilibration of the distribution mechanism realization FLASH of wearing and tearing counting and empty piece, can guarantee under any circumstance that promptly (comprising powered-off fault) each piece is recycled order and wipes, thereby guarantee each piece erasing times about equally; In addition, adopt copy index and verification scheme thereof that power-down protection at data is provided, i.e. power down in the copy ablation process owing to do not write index, thus this copy can not be read, and can only then read the copy that has the copy index; And power down in the index ablation process, owing to the check information that does not generate about this index, so this index can't pass through data check, corresponding copy can not be read yet.
Though the present invention discloses as above with preferred embodiment; right its is not in order to limiting the present invention, anyly has the knack of this skill person, without departing from the spirit and scope of the present invention; when can doing a little change and retouching, thus protection scope of the present invention when with aforementioned claims the person of being defined be as the criterion.

Claims (17)

1. the system of an access data on flash memory comprises the flash memory structure division module and the initialization module that are connected with described flash memory respectively, and the data writing module and the data read module that are connected with described initialization module respectively; Wherein:
Described flash memory structure is divided module, is used for described flash memory is divided into a plurality of storage blocks, as the base unit of erase operation, and preserves the wearing and tearing counting in first page therein; Described storage block is divided into a plurality of memory pages again,, and in one or more initial storage unit of described memory page, preserves the busy flag of described memory page as the base unit of write operation; For sequential storage each data trnascription on described flash memory is settled an index;
Described initialization module, be used for described flash memory is carried out initialization operation, promptly determine the position of described piece and described tail piece, determine described system wear counting according to the wearing and tearing counting of described piece or described tail piece again according to the wearing and tearing counting of described the above storage block of flash memory;
Described data writing module, being used for according to the block condition of the current tail of described flash memory is that described data trnascription distributes blank page, and described data trnascription is write in the described blank page of distribution with described index order;
Described data read module is used for finding according to the current tail piece of described flash memory position the index of the data trnascription that will read, and reads described data trnascription according to the information in the described index.
2. according to the described system of claim 1, it is characterized in that described initialization module:
With first sky piece of described flash memory as described tail piece; If the storage block behind described first sky piece still is empty piece, then first storage block is a described piece, and described system wear counting is 1; If the storage block behind described first sky piece be empty piece, in two kinds of situation: when described empty piece is not last storage block, the storage block behind the then described empty piece is a described piece, and the wearing and tearing counting of this piece adds 1 and is described system wear and counts; And work as described empty piece is last storage block, and then described first storage block is a described piece, and the wearing and tearing counting of this piece is the system wear counting;
Perhaps, there is not empty piece in described flash memory, counts for described system wear with the wearing and tearing counting of tail piece; When existing two adjacent memory blocks wearing and tearing to count the boundary that diminishes, the storage block of described boundary front is described tail piece, and the storage block of described boundary back is a described piece; If there is not described boundary, be described tail piece then with described last storage block, be described piece with described first storage block.
3. according to claim 1 or 2 described systems, it is characterized in that, described data writing module further comprises copy segmentation writing module, page or leaf distribution module and the piece distribution module that connects successively, comprises that also the copy index that is connected with copy segmentation writing module generates and the verification module, wherein:
Described copy segmentation writing module is connected with described flash memory, be used for described data trnascription content being cut into plurality of sections according to the capacity of described memory page, be that each section is distributed a blank page to the application of described page or leaf distribution module then, content in described section is counted together with described system wear or described busy flag writes described blank page; And the address information of preserving the shared page or leaf of first section first byte and final stage trail byte, or preserve the page address that described first section first byte take and the length information of described copy; Described copy index generate and verification module ghost index and check information thereof after, described copy index and check information thereof write but a blank page distributing in;
Described page or leaf distribution module is connected with described initialization module, is used to described copy segmentation writing module order assignment blank page, promptly when described tail piece is not full piece, with the blank page of endpage as distribution; When the tail piece is full piece, distribute an empty piece to described distribution module application, and with first page in the empty piece of the described distribution blank page as distribution;
Described distribution module is connected with described initialization module, is used for dividing timing at the empty piece of described page or leaf distribution module application, is storage block of its order assignment: promptly when described tail piece be not last storage block, with thereafter a storage block as the piece that distributes; When described tail piece is described last storage block, count then with the piece of first storage block, and with described system wear to add 1 as distribution; If the piece of described distribution is a current piece, then described piece moved to the next storage block of the piece of described distribution; At last the piece of described distribution being wiped the back dispenses as new tail piece;
Described copy index generates and the verification module, the length information that is used for page address that the first byte according to described copy takies and described copy generates the described index about described copy, or the page address information that takies of the page address that takies according to the first byte of described copy and last byte thereof generates the described index about described copy; Simultaneously, the index of described copy is carried out verification forming effective index, and generate check information in view of the above, pass to described copy segmentation writing module together in company with described copy index.
4. according to the described system of claim 3, it is characterized in that described data read module further comprises indexed search module, index read module and the copy read module that connects successively, wherein:
Described indexed search module is used for from described tail BOB(beginning of block) to a block search, and traversal is each memory page wherein, until the index that to find first described effective index be the described data trnascription that will read;
Described index read module, be used for reading the index of up-to-date data trnascription from described effective index, obtain the page address that described copy first byte takies and the length information of described copy, perhaps obtain the page address information that page address that described copy first byte takies and its last byte take;
Described copy read module is connected with described flash memory, is used for the information according to the described index that obtains, and reads the content of copy from the memory page of correspondence.
5. according to the described system of claim 4, it is characterized in that, described indexed search module, piece does not all find described effective index if search for to the end always, and then failure is read in report; Perhaps, if first page address that the described copy that reads takies has exceeded the scope that covers to the tail piece when the front piece, then failure is read in report.
6. the method for an access data on flash memory comprises the steps:
(a) divide described flash memory, the specified data structure, promptly
Described flash memory is divided into a plurality of storage blocks, as the base unit of each erase operation; Every is distributed one or more byte to be used for the wearing and tearing counting in first page, the information of the relevant described memory block erasing number of times of storage; Again storage block further is divided into a plurality of memory pages, as the base unit of each write operation; Whether every page of busy flag that uses initial byte units as this page has been written into data in order to discern this page or leaf;
For sequential storage each data trnascription on described flash memory is settled an index;
(b) system is carried out initialization, promptly determine the position of described piece and described tail piece, determine described system wear counting according to the described wearing and tearing counting of described piece or described tail piece again according to the described wearing and tearing counting of described the above storage block of flash memory;
(c) on described flash memory, carry out writing of data trnascription or read operation, promptly distribute blank page, and described data trnascription is write in the described blank page of distribution with described index order according to the situation of described tail piece according to described tail piece; Perhaps, find the index of the data trnascription that will read, and read described data trnascription according to the information in this index according to described tail piece position.
7. in accordance with the method for claim 6, it is characterized in that step (b) further comprises step:
If there is empty piece in described flash memory, with first sky piece of described flash memory as described tail piece; If the storage block behind described first sky piece still is described empty piece, then first storage block is a described piece, and described system wear counting is 1; If the storage block behind described first sky piece be described empty piece, in two kinds of situation: when described empty piece is not last storage block, the storage block behind the then described empty piece is a described piece, and the wearing and tearing counting of this piece adds 1 and is described system wear and counts; And work as described empty piece is last storage block, and then described first storage block is a described piece, and the wearing and tearing counting of this piece is described system wear counting;
If there is not empty piece in described flash memory, count for described system wear with the wearing and tearing counting of tail piece; When existing two adjacent memory blocks wearing and tearing to count the boundary that diminishes, the storage block of described boundary front is described tail piece, and the storage block of described boundary back is a described piece; If not having described boundary, then described last storage block is described tail piece, described first storage block is a described piece.
8. in accordance with the method for claim 6, it is characterized in that the described data trnascription write operation of step (c) further comprises the steps:
(c1) capacity according to described memory page is cut into a plurality of sections with described data trnascription content, be followed successively by blank page of each section distribution then, and content in described section write described blank page together with described system wear counting or described busy flag, simultaneously, preserve the page address information that first section first byte and final stage trail byte take, or preserve the page address that first section first byte take and the length information of described copy;
(c2) length information of page address that takies according to the first byte of described copy and described copy generates the described index about described copy, or the page address information that takies of the page address that takies according to the first byte of described copy and last byte thereof generates the described index about described copy; Simultaneously, verification and the relevant check information of generation that described index is carried out;
(c3) distribute a blank page, and described index and described check information are write this blank page, form effective index.
9. in accordance with the method for claim 8, it is characterized in that, in the preceding step that also comprises of step (c1): read described data trnascription content and make amendment according to described effective index.
10. in accordance with the method for claim 8, it is characterized in that the operation of a step (c1) and a blank page of the described distribution of step (c3) comprises the steps: if described tail piece is not full piece, then with the blank page of the endpage in the described tail piece as distribution; If described tail piece is full piece, then distribute an empty piece, and first page that should the sky piece is as the blank page that distributes.
11. in accordance with the method for claim 10, it is characterized in that the operation of an empty piece of described distribution comprises the steps:
(1) if described tail piece is not last storage block, then general's storage block thereafter is as the piece that distributes; As if described tail piece is last storage block, counts then with the piece of first storage block as distribution, and with system wear to add 1;
(2) piece of described distribution being wiped the back dispenses as new tail piece.
12. in accordance with the method for claim 11, it is characterized in that step (1) further comprises step:, then described piece moved to the next storage block of the piece of described distribution if the piece of described distribution is a current piece.
13. in accordance with the method for claim 8, it is characterized in that the described data trnascription read operation of step (c) further comprises the steps:
(c1) from described tail BOB(beginning of block) to a block search, wherein each described memory page of traversal is up to the described effective index that finds first by verification;
(c2) from described effective index, read up-to-date described index, obtain the page address that described copy first byte takies and the length information of described copy, perhaps obtain the page address information that page address that described copy first byte takies and its last byte take;
(c3) information in the basis described index that reads reads the content of described data trnascription from the memory page of correspondence.
14. in accordance with the method for claim 13, it is characterized in that, step (c1) is from the last page of described tail piece, move forward the direction search of one page backward to a piece at every turn, up to finding an occupied described memory page, and judge that according to the index mark value of described memory page the content of described memory page is described index, and judge that according to the described check information of this index it is described effective index; Piece does not all find described effective index if search for to the end always, and then failure is read in report; Perhaps, if first page address that the described copy that reads takies has exceeded the scope that covers to the tail piece when the front piece, then failure is read in report.
15. in accordance with the method for claim 13, it is characterized in that, step (c3) reads each memory page to the direction of described tail piece successively from first page beginning that described copy takies, peel off after described busy flag and the described index mark, remaining byte is carried out assembly unit and recovered described copy content, and the byte number that last page participates in assembly unit takies page address by the last byte of the length of the described copy of preserving in described effective index or described copy and calculates.
16. according to claim 6 to 8 or 13,14 each described methods, it is characterized in that, initial two bytes of described storage block first memory page be used to store described wearing and tearing counting, the storage mode that adopts every negate to write again; Initial two bytes of described memory page are used for described busy flag,, show that promptly this page or leaf is occupied as long as wherein content is not complete 1; The described wearing and tearing counting while is as the described busy flag of described first memory page; The 3rd byte of described memory page be as the value of statistical indicant of index, wherein, with first this page of value representation storage be an index, with second this page of value representation storage is the copy content; The interior perhaps described index of described data trnascription begins storage from the 4th byte of each memory page.
17. in accordance with the method for claim 8, it is characterized in that 32 cyclic redundancy check (CRC) mechanism are adopted in described verification to index.
CNB2007101615249A 2007-09-24 2007-09-24 A kind of on flash memory the system and method for access data Expired - Fee Related CN100555246C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2007101615249A CN100555246C (en) 2007-09-24 2007-09-24 A kind of on flash memory the system and method for access data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2007101615249A CN100555246C (en) 2007-09-24 2007-09-24 A kind of on flash memory the system and method for access data

Publications (2)

Publication Number Publication Date
CN101127004A true CN101127004A (en) 2008-02-20
CN100555246C CN100555246C (en) 2009-10-28

Family

ID=39095050

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2007101615249A Expired - Fee Related CN100555246C (en) 2007-09-24 2007-09-24 A kind of on flash memory the system and method for access data

Country Status (1)

Country Link
CN (1) CN100555246C (en)

Cited By (29)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2010148985A1 (en) * 2009-11-24 2010-12-29 中兴通讯股份有限公司 Rfid reader and data storage method thereof
CN101650692B (en) * 2009-07-02 2011-01-05 北京飞天诚信科技有限公司 Method and device for modifying data in memory
CN101620575B (en) * 2008-07-02 2011-07-27 慧国(上海)软件科技有限公司 Flash card and method for flash memory to prevent data from being damaged
CN102323907A (en) * 2011-08-19 2012-01-18 长安大学 Method for embedded ARM (advanced RISC machines) processor to store and delete NANDFLASH data
CN102656567A (en) * 2009-12-17 2012-09-05 国际商业机器公司 Data management in solid state storage devices
CN102662852A (en) * 2012-03-20 2012-09-12 山东省科学院自动化研究所 Method for storing nonvolatile data by using MCU internal data Flash
CN102012869B (en) * 2009-09-04 2012-11-14 威刚科技股份有限公司 Data recording method of flash memory storage system
CN101539891B (en) * 2008-03-17 2012-12-05 锐迪科微电子(上海)有限公司 Embedded type flash memory, storage system and method for power fail safeguard of data
CN103123609A (en) * 2013-03-13 2013-05-29 中国科学院上海微系统与信息技术研究所 Blocking management method of storer
CN103514101A (en) * 2012-06-18 2014-01-15 慧荣科技股份有限公司 Method for accessing flash memory and related memory device
CN103559140A (en) * 2013-10-29 2014-02-05 深圳创维数字技术股份有限公司 Flash data storage method and device
CN104317671A (en) * 2014-10-24 2015-01-28 杭州帅锐电子科技有限公司 Power-down data storage and recovery algorithm prolonging service life of non-volatile memory
CN104537075A (en) * 2014-12-30 2015-04-22 宁波三星电气股份有限公司 Method for applying Yaffs file system to NorFlash
CN104919433A (en) * 2013-01-11 2015-09-16 英派尔科技开发有限公司 Page allocation for flash memories
CN106023342A (en) * 2016-05-11 2016-10-12 安徽江淮汽车股份有限公司 Data management method and system for nonvolatile store of automatic gearbox
CN106415505A (en) * 2014-06-19 2017-02-15 株式会社电装 Storage device, flash memory control device, and program
CN106598875A (en) * 2015-10-19 2017-04-26 深圳市华百安智能技术有限公司 Method for rapidly processing NOR FLASH records in embedded system
CN107168647A (en) * 2017-04-17 2017-09-15 武汉永力科技股份有限公司 FLASH data read-write methods and system
CN107256197A (en) * 2017-05-18 2017-10-17 深圳市晟碟半导体有限公司 A kind of date storage method, storage device and intelligent terminal
CN108255436A (en) * 2018-01-25 2018-07-06 广东美的制冷设备有限公司 Data access method, access device, home appliance and readable storage medium storing program for executing
CN108710578A (en) * 2018-04-20 2018-10-26 深圳市战音科技有限公司 Date storage method based on flash memory and device
CN108984423A (en) * 2017-05-31 2018-12-11 龙芯中科技术有限公司 A kind of the address space verification method and system of system level chip
CN111078136A (en) * 2019-10-22 2020-04-28 安徽力高新能源技术有限公司 Method for preventing flash service life reduction caused by BMS dynamic data storage
CN111324488A (en) * 2020-02-12 2020-06-23 浙江大华技术股份有限公司 Program backup processing method and device
WO2021035555A1 (en) * 2019-08-27 2021-03-04 华为技术有限公司 Data storage method and apparatus for solid state disk and solid state disk (ssd)
CN113204316A (en) * 2021-05-19 2021-08-03 中国人民解放军93216部队 Method for high-efficiency data storage by using FLASH
CN113485974A (en) * 2021-06-02 2021-10-08 翱捷科技股份有限公司 Method and device for using YAFFS (flash architecture) for NOR flash memory
CN113641629A (en) * 2017-03-27 2021-11-12 珠海极海半导体有限公司 File writing and reading method of FLASH memory
CN114415942A (en) * 2021-12-21 2022-04-29 联芸科技(杭州)有限公司 L2P mapping table rebuilding method and solid state disk

Cited By (51)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101539891B (en) * 2008-03-17 2012-12-05 锐迪科微电子(上海)有限公司 Embedded type flash memory, storage system and method for power fail safeguard of data
CN101620575B (en) * 2008-07-02 2011-07-27 慧国(上海)软件科技有限公司 Flash card and method for flash memory to prevent data from being damaged
CN101650692B (en) * 2009-07-02 2011-01-05 北京飞天诚信科技有限公司 Method and device for modifying data in memory
CN102012869B (en) * 2009-09-04 2012-11-14 威刚科技股份有限公司 Data recording method of flash memory storage system
CN102073832A (en) * 2009-11-24 2011-05-25 中兴通讯股份有限公司 Fixed RFID reader and data storage method thereof
WO2010148985A1 (en) * 2009-11-24 2010-12-29 中兴通讯股份有限公司 Rfid reader and data storage method thereof
CN102073832B (en) * 2009-11-24 2014-03-12 中兴通讯股份有限公司 Fixed RFID reader and data storage method thereof
CN102656567B (en) * 2009-12-17 2015-02-25 国际商业机器公司 Data management in solid state storage devices
US9176817B2 (en) 2009-12-17 2015-11-03 International Business Machines Corporation Data management in solid state storage devices
CN102656567A (en) * 2009-12-17 2012-09-05 国际商业机器公司 Data management in solid state storage devices
US8904261B2 (en) 2009-12-17 2014-12-02 International Business Machines Corporation Data management in solid state storage devices
TWI497293B (en) * 2009-12-17 2015-08-21 Ibm Data management in solid state storage devices
CN102323907A (en) * 2011-08-19 2012-01-18 长安大学 Method for embedded ARM (advanced RISC machines) processor to store and delete NANDFLASH data
CN102662852B (en) * 2012-03-20 2015-05-27 山东省科学院自动化研究所 Method for storing nonvolatile data by using MCU internal data Flash
CN102662852A (en) * 2012-03-20 2012-09-12 山东省科学院自动化研究所 Method for storing nonvolatile data by using MCU internal data Flash
US9384125B2 (en) 2012-06-18 2016-07-05 Silicon Motion Inc. Method for accessing flash memory having pages used for data backup and associated memory device
CN103514101A (en) * 2012-06-18 2014-01-15 慧荣科技股份有限公司 Method for accessing flash memory and related memory device
CN104919433B (en) * 2013-01-11 2017-10-31 英派尔科技开发有限公司 The page for flash memory is distributed
CN104919433A (en) * 2013-01-11 2015-09-16 英派尔科技开发有限公司 Page allocation for flash memories
CN103123609B (en) * 2013-03-13 2015-07-15 中国科学院上海微系统与信息技术研究所 Blocking management method of storer
CN103123609A (en) * 2013-03-13 2013-05-29 中国科学院上海微系统与信息技术研究所 Blocking management method of storer
CN103559140B (en) * 2013-10-29 2016-07-20 深圳创维数字技术有限公司 A kind of method for flash data storage and device
CN103559140A (en) * 2013-10-29 2014-02-05 深圳创维数字技术股份有限公司 Flash data storage method and device
CN106415505A (en) * 2014-06-19 2017-02-15 株式会社电装 Storage device, flash memory control device, and program
CN106415505B (en) * 2014-06-19 2019-06-18 株式会社电装 Storage device and flash memories control device
CN104317671A (en) * 2014-10-24 2015-01-28 杭州帅锐电子科技有限公司 Power-down data storage and recovery algorithm prolonging service life of non-volatile memory
CN104537075A (en) * 2014-12-30 2015-04-22 宁波三星电气股份有限公司 Method for applying Yaffs file system to NorFlash
CN104537075B (en) * 2014-12-30 2017-11-28 宁波三星医疗电气股份有限公司 Application process of the Yaffs file system in NorFlash
CN106598875A (en) * 2015-10-19 2017-04-26 深圳市华百安智能技术有限公司 Method for rapidly processing NOR FLASH records in embedded system
CN106023342A (en) * 2016-05-11 2016-10-12 安徽江淮汽车股份有限公司 Data management method and system for nonvolatile store of automatic gearbox
CN113641629A (en) * 2017-03-27 2021-11-12 珠海极海半导体有限公司 File writing and reading method of FLASH memory
CN113641630A (en) * 2017-03-27 2021-11-12 珠海极海半导体有限公司 FLASH memory
CN107168647A (en) * 2017-04-17 2017-09-15 武汉永力科技股份有限公司 FLASH data read-write methods and system
CN107168647B (en) * 2017-04-17 2020-10-23 武汉永力科技股份有限公司 FLASH data read-write method and system
CN107256197A (en) * 2017-05-18 2017-10-17 深圳市晟碟半导体有限公司 A kind of date storage method, storage device and intelligent terminal
CN107256197B (en) * 2017-05-18 2019-02-01 深圳市晟碟半导体有限公司 A kind of date storage method, storage device and intelligent terminal
CN108984423A (en) * 2017-05-31 2018-12-11 龙芯中科技术有限公司 A kind of the address space verification method and system of system level chip
CN108984423B (en) * 2017-05-31 2020-10-27 龙芯中科技术有限公司 System-level chip address space verification method and system
CN108255436A (en) * 2018-01-25 2018-07-06 广东美的制冷设备有限公司 Data access method, access device, home appliance and readable storage medium storing program for executing
CN108710578B (en) * 2018-04-20 2022-07-26 深圳市战音科技有限公司 Data storage method and device based on flash memory
CN108710578A (en) * 2018-04-20 2018-10-26 深圳市战音科技有限公司 Date storage method based on flash memory and device
WO2021035555A1 (en) * 2019-08-27 2021-03-04 华为技术有限公司 Data storage method and apparatus for solid state disk and solid state disk (ssd)
CN111078136A (en) * 2019-10-22 2020-04-28 安徽力高新能源技术有限公司 Method for preventing flash service life reduction caused by BMS dynamic data storage
CN111078136B (en) * 2019-10-22 2023-05-05 力高(山东)新能源技术股份有限公司 Method for preventing flash life reduction caused by BMS dynamic data storage
CN111324488A (en) * 2020-02-12 2020-06-23 浙江大华技术股份有限公司 Program backup processing method and device
CN111324488B (en) * 2020-02-12 2023-12-08 浙江大华技术股份有限公司 Program backup processing method and device
CN113204316A (en) * 2021-05-19 2021-08-03 中国人民解放军93216部队 Method for high-efficiency data storage by using FLASH
CN113485974A (en) * 2021-06-02 2021-10-08 翱捷科技股份有限公司 Method and device for using YAFFS (flash architecture) for NOR flash memory
CN113485974B (en) * 2021-06-02 2023-08-01 翱捷科技股份有限公司 Method and device for using YAFFS (gamma ray source flash memory)
CN114415942A (en) * 2021-12-21 2022-04-29 联芸科技(杭州)有限公司 L2P mapping table rebuilding method and solid state disk
CN114415942B (en) * 2021-12-21 2022-11-04 联芸科技(杭州)股份有限公司 L2P mapping table reconstruction method and solid state disk

Also Published As

Publication number Publication date
CN100555246C (en) 2009-10-28

Similar Documents

Publication Publication Date Title
CN100555246C (en) A kind of on flash memory the system and method for access data
US10067881B2 (en) Compression and caching for logical-to-physical storage address mapping tables
CN102779096B (en) Page, block and face-based three-dimensional flash memory address mapping method
CN102841851B (en) Flash memory management method and flash memory device
CN101501623B (en) Filesystem-aware block storage system, apparatus, and method
CN104461391B (en) A kind of storage device metadata management approach and system
CN101221534B (en) Method and system for controlling computer readable memory
US7774565B2 (en) Methods and apparatus for point in time data access and recovery
US10877898B2 (en) Method and system for enhancing flash translation layer mapping flexibility for performance and lifespan improvements
CN101968795B (en) Cache method for file system with changeable data block length
US20140115384A1 (en) Fast data recovery from hdd failure
CN101777017B (en) Rapid recovery method of continuous data protection system
CN101241471A (en) Flash memory system and garbage collection method thereof
CN101526927B (en) Data processing method and data processing device of Flash file system
US20160291881A1 (en) Method and apparatus for improving disk array performance
CN104461390A (en) Method and device for writing data into imbricate magnetic recording SMR hard disk
CN107239526A (en) File system implementation method, scrap cleaning method, operating position localization method
CN108228471A (en) Manage the method and system of the entity information of memory cell in memory device
CN111414320B (en) Method and system for constructing disk cache based on nonvolatile memory of log file system
CN102880553B (en) The reading/writing method of the outer FLASH file system of a kind of sheet based on MCU
US20140047161A1 (en) System Employing MRAM and Physically Addressed Solid State Disk
CN108717395B (en) Method and device for reducing memory occupied by dynamic block mapping information
CN111338846B (en) Method and device for recovering L2P (L2P) table based on multiple cores
CN115525605A (en) Transmission system and method of file system
CN116009761A (en) Data writing method and related equipment

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
ASS Succession or assignment of patent right

Owner name: NANJING ZHONGXING NEW SOFTWARE CO., LTD

Free format text: FORMER OWNER: ZTE CORPORATION

Effective date: 20150518

C41 Transfer of patent application or patent right or utility model
COR Change of bibliographic data

Free format text: CORRECT: ADDRESS; FROM: 518057 SHENZHEN, GUANGDONG PROVINCE TO: 210012 NANJING, JIANGSU PROVINCE

TR01 Transfer of patent right

Effective date of registration: 20150518

Address after: Yuhuatai District of Nanjing City, Jiangsu province 210012 Bauhinia Road No. 68

Patentee after: Nanjing Zhongxing New Software Co., Ltd.

Address before: 518057 Nanshan District high tech Industrial Park, Guangdong, South Road, science and technology, ZTE building, legal department

Patentee before: ZTE Corporation

CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20091028

Termination date: 20160924

CF01 Termination of patent right due to non-payment of annual fee