The data processing method of NAND FLASH
Technical field
The present invention relates to the semiconductor storage medium technical field, more particularly, relate to the data processing method of a kind of NAND FLASH.
Background technology
NAND FLASH (nonvolatile memory; The least unit of wiping the abbreviation flash memory) is piece (Block); The least unit that writes is page or leaf (Page); All user data write operations need to carry out based on an empty piece, carry out in the piece that promptly all write operations are not programmed after needing in FLASH, to be wiped free of.If will in one, write data with the Data Update in this piece according to logical address A, its flow process is roughly following:
At first, find an empty piece, the copying data in the page or leaf more than the old middle A address is arrived empty piece; For example, the corresponding page or leaf in A address is the 20th page in the piece of data if will write, then earlier with the 0th~19 page copying data in new piece;
The data that will write then, are written to page or leaf corresponding in the sky piece;
At last, other copying datas of old are arrived the relevant position of empty piece.
At present, in its file system, write one piece of data, at first want frequent its system file of modification based on NAND FLASH; For example; The FAT file system is wanted copied files, must upgrade FAT table, FDT table, at last updating user data; And User Data Length is generally longer, needs some pages of ability ccontaining.So in data writing process, the renewal of the frequent interruption of user data of file system, and insert the renewal operation of FAT table with the FDT table.At this moment, need to finish the operation of current block, and FAT table and FDT table are upgraded operation, the FAT table is consistent with the renewal operating process and the above-mentioned Data Update operating process of FDT table, promptly need repeat the step of above-mentioned user data update.After FAT and FDT have upgraded; When user data continues down to write; Must repeat above-mentioned data writing process again; Be written to data and the new piece of copying data to of the above page or leaf of logical address in the piece when being about to data interruption, will not write then be written to logical address corresponding page in, copy other data in old then.The wearing and tearing of the not only consuming time and FLASH of whole process but also big, special file number more for a long time, FAT, that FDT revises ratio is just higher, causes FLASH copied files speed slow excessively.
Summary of the invention
Fundamental purpose of the present invention is to the prior art defective data processing method of a kind of NAND FLASH to be provided, and is intended to reduce the wearing and tearing of FLASH, improves the document copying speed of FLASH.
The data processing method of NAND FLASH of the present invention may further comprise the steps:
According to logical address and the empty piece of physical address mapping table application, carry out the user data update operation;
When user data update is operated by FAT table or FDT table renewal interruption, the physical address and the operating environment of preserving empty piece;
Upgrade FAT table or FDT table, the mapping relations of record FAT table or FDT table;
The physical address and the operating environment of calling and obtaining user Data Update operation disruption space-time piece continue the user data update operation; Said operating environment comprises piece, loop variable, the state machine state that logical address is corresponding.
Preferably, said when user data update operation is interrupted by FAT table or FDT table, preserve in the step of physical address and operating environment of empty piece and comprise:
The setting data length threshold;
Length and data length threshold value that relatively FAT shows or FDT shows;
When the length of FAT table or FDT table is less than or equal to the data length threshold value, interrupt the user data update operation.
Preferably, said renewal FAT table or FDT table also comprise in the step of the mapping relations of record FAT table or FDT table:
In the FLASH redundancy, write down the logical address of FAT table or FDT table, and the mapping relations that record FAT shows or FDT shows in internal memory.
Preferably, above-mentioned data processing method is further comprising the steps of:
End data was upgraded operation when the data length of insertion was greater than said threshold value when programming;
The logical address and the physical address mapping table of application user data;
Preserve the end physical address and the operating environment of current operation.
Preferably, the physical address and the operating environment of said calling and obtaining user Data Update operation disruption space-time piece also comprise in the step of continuation Data Update operation:
Whether the physical address of judging current operation is consistent with the end physical address; If not, then interrupt the user data update operation according to the data length threshold value; If then continue to Update Information according to finishing physical address.
Preferably, also comprise in the said step of upgrading operation according to data length threshold value interrupt data following:
Compare User Data Length and threshold value;
When User Data Length during, interrupt the user data update operation less than threshold value.
By on can know; When the present invention was interrupted in data manipulation, record was when the physical address and the operating environment of space-time piece, after the renewal of file system is accomplished; Physical address and operating environment through transferring the sky piece again; Realization has reduced the wearing and tearing of FLASH to the operation of continuing of data, has improved the copying data speed of FLASH.
Description of drawings
Fig. 1 is the data processing method process flow diagram of NAND FLASH in an embodiment of the invention;
Fig. 2 interrupts user data update method of operating process flow diagram according to the data length threshold value among the embodiment of above-mentioned embodiment;
Fig. 3 interrupts user data update method of operating process flow diagram according to the data length threshold value among another embodiment of above-mentioned embodiment;
Fig. 4 is a method flow diagram of continuing user data in the above-mentioned embodiment.
In order to make the object of the invention, technical scheme and advantage clearer,, the present invention is further elaborated below in conjunction with accompanying drawing and embodiment.
Embodiment
Should be appreciated that specific embodiment described herein only in order to explanation the present invention, and be not used in qualification the present invention.
Known like those of ordinary skills institute; NAND FLASH is formed by one or more die package, comprises one or more rank (Plane) in each crystal grain, and each rank comprises several storage blocks (Block); Each storage block is made up of several pages or leaves (Page), and each page or leaf comprises a plurality of sectors.Writing data and be with the page or leaf is unit, and obliterated data is to be unit with the piece.When writing data, write in proper order by the sector of page or leaf.And, distribute the address to storage block in order, distributed the storage block of address to be called physical block, this address is called physical address; Be called logical address and storage block is divided into some pages virtual address, set up mapping relations through address mapping table between logical address and the physical address.
FAT shows (File Allocation Table, file allocation table), is used to represent the allocation of space information of disk file.FDT shows (File Directory Table, FDT), the start element of each file (catalogue) under the record root directory, the attribute of file etc.During the locating file position, operating system just can know that in conjunction with the FAT table particular location of file in hard disk is with big or small according to the start element among the DIR.
As shown in Figure 1, NAND FLASH data processing of multithread of the present invention may further comprise the steps:
Step S10 according to logical address and the empty piece of physical address mapping table application, carries out the user data update operation;
Step S20, when user data update is operated by FAT table or FDT table renewal interruption, the physical address and the operating environment of preserving empty piece;
Step S30 upgrades FAT table or FDT table, the mapping relations of record FAT table or FDT table;
Step S40, the physical address and the operating environment of calling and obtaining user Data Update operation disruption space-time piece continue the Data Update operation.
In one embodiment; If will user data be write in one so that this piece is carried out Data Update according to logical address A; At first found piece (because of any write operation of NAND FLASH device can only be carried out) in sky or the unit of having wiped according to logical address and physical address mapping table; If the operation that user data writes is interrupted by the renewal of FAT table or FDT table; Then be interrupted the physical address and the operating environment of space-time piece through the record of the microcontroller in flash memory write operation, this operating environment can comprise the corresponding piece of logical address, loop variable, state machine state etc., so that subsequent operation.
When FAT table or the renewal of FDT table; Record FAT table or FDT table upgrade the pairing logical address of corresponding page or leaf in the redundancy of FLASH; The mapping relations of record FAT table or FDT table in internal memory; Insert when FAT table or FDT table upgraded pairing page or leaf in the time of to find last time FAT table or FDT table to upgrade through logical address and mapping relations, thereby continued access renewal last time once more with convenient file system.
Treat that FAT table or the renewal of FDT table finish, physical address and operating environment when microcontroller interrupts according to data write operation find data write operation place piece last time, continue the Data Update operation.
The length of FAT table or FDT table is all fixed, and the FAT table is generally 0.5K, and the FDT table is generally 4K.Among the present invention; According to FAT table and the fixing characteristics of FDT table length is that unit upgrades FAT table and FDT table with the page or leaf; Redundant area at FLASH writes down its corresponding logical address to recover its mapping relations after making things convenient for power down, writes down the convenient use in service of its corresponding mapping relations simultaneously.The data that take place whole when so just avoiding FAT table or FDT table to upgrade copy again, when coming updating user data again after handling, only need to finish last time physical address and continue down to write with the operating environment reduction, just as once interruption takes place.Wearing and tearing number of times in system file district will reduce greatly like this, thereby the availability of raising NAND FLASH can be improved the speed of FLASH copied files simultaneously.
As shown in Figure 2, above-mentioned interrupt data is upgraded operation and can be realized through following method flow:
Step S21, the setting data length threshold;
Step S22, the relatively length and the data length threshold value of FAT table or FDT table;
Step S23, when the length of FAT table or FDT table during less than the data length threshold value, interrupt data is upgraded operation.
The length of FAT table, FDT table is fixed, and the FAT table is generally the 0.5K size, and the size of FDT table is generally 4K, and the length of user data is then often greater than the length of FAT table or FDT table.For example, when programming, general data length all surpasses 4K.Can in FLASH, reserve several physical blocks in every separated certain-length zone according to These characteristics, a data length threshold value is set simultaneously, so that whether judgment data is FAT table or FDT table.In one embodiment, this threshold value can be 4K, when file system is inserted the renewal operation of FAT table or FDT table and interrupt data when upgrading operation; Whether the data that this threshold decision capable of using is inserted are FAT table or FDT table; If data length is less than or equal to threshold value, then interrupt the user data update operation, carry out above-mentioned steps S30; Upgrade FAT table or FDT table, the mapping relations of record FAT table or FDT table.As shown in Figure 3, if data length greater than threshold value, then is judged as user data, carry out following steps:
Step S40, the operation of end user Data Update;
Step S50, the logical address and the physical address mapping table of application user data;
Step S60 preserves the end physical address and the operating environment of current operation.
When User Data Length and FAT table or the general size of FDT table; When not satisfying the condition of writing continuously, for example, when having only 0.5K as if data length; Then carry out the renewal operation of end data; Apply for the logical address and the physical address mapping table of this user data, preserve the end physical address and the operating environment of operation, so that continue.For example, when continuing, can be with the physical address of EO and the physical address comparison of operating environment and current operation; If both are consistent, then can continue the user data update operation, if both are inconsistent; Then interrupt the user data update operation, return and carry out above-mentioned steps S22.As shown in Figure 4, in the said method, continue the operation of user data when interrupting, can may further comprise the steps:
Step S70 judges whether the physical address of current operation is consistent with the end physical address;
Step S80 if not, then upgrades operation according to data length threshold value interrupt data; Return and carry out above-mentioned steps S22;
Step S90, if, then continue to Update Information according to finishing physical address, return and carry out above-mentioned steps S60.
The above is merely preferred embodiment of the present invention, not in order to restriction the present invention, all any modifications of within spirit of the present invention and principle, being done, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.