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 to be wiped free of in FLASH.If will write data with the Data Update in this piece in one according to logical address A, its flow process is roughly as follows:
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 page or leaf of A address correspondence is the 20th page in the piece of data if will write, then earlier with the 0th~19 page copying data in new piece;
Then, the data that will write 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, to in its file system, write one piece of data based on NAND FLASH, at first want frequent its system file of modification, 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, the data in the piece and the new piece of copying data to of the above page or leaf of logical address have been written to when being about to data interruption, in the page or leaf of will not write then that is written to the logical address correspondence, 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, it is just higher that FAT, FDT revise ratio, causes FLASH copied files speed slow excessively.
Summary of the invention
Fundamental purpose of the present invention is to provide the data processing method of a kind of NAND FLASH at the prior art defective, 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 operation is shown by FAT or the FDT table upgrades when interrupting 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.
Preferably, describedly shown by FAT or FDT table when interrupting, preserve in the step of the physical address of empty piece and operating environment and comprise when user data update operation:
The setting data length threshold;
The length and the data length threshold value that compare FAT table or FDT table;
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, described 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:
When User Data Length during greater than described threshold value end data upgrade operation;
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 described 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 more new data according to finishing physical address.
Preferably, also comprise in the described step of interrupting the Data Update operation according to the data length threshold value following:
Compare User Data Length and threshold value;
When User Data Length during, interrupt the user data update operation less than threshold value.
As from the foregoing, when the present invention is interrupted in data manipulation, record is when the physical address and the operating environment of space-time piece, after the renewal of file system is finished, physical address and operating environment by 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.
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 as those of ordinary skills institute, NAND FLASH is formed by one or more die package, comprise one or more rank (Plane) in each crystal grain, each rank comprises several storage blocks (Block), each storage block is made 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 by 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, File Directory Table), 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 have been known the particular location of file in hard disk and size according to the start element among the DIR in conjunction with the FAT table.
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 is when user data update operation is shown by FAT or the FDT table upgrades when interrupting 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 NANDFLASH 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 shown by FAT or the renewal of FDT table is interrupted, then be interrupted the physical address and the operating environment of space-time piece by the record of the microcontroller in flash memory write operation, this operating environment can comprise the piece of logical address correspondence, loop variable, state machine state etc. are 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, when inserting FAT table or the renewal of FDT table once more with convenient file system, pairing page or leaf in the time of can finding last time FAT table or FDT table to upgrade by logical address and mapping relations, thus continued access was upgraded last time.
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 interruption Data Update operation flow process realization by the following method:
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, interrupts the Data Update 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, in the certain-length zone, reserve several physical blocks 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 when the renewal operation of FAT table or FDT table interrupted the Data Update operation, whether the data that can utilize this threshold decision to insert 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 if data length has only 0.5K, 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 unanimities 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 interrupts the Data Update operation according to the data length threshold value; Return and carry out above-mentioned steps S22;
Step S90, if, then continue more new data according to finishing physical address, return and carry out above-mentioned steps S60.
The above only is preferred embodiment of the present invention, not in order to restriction the present invention, all any modifications of being done within the spirit and principles in the present invention, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.