Summary of the invention
In view of above-mentioned traditional flash memory more existing defectives when rewriting, the invention provides a kind of novel flash memory structure and method of operating.
The present invention will provide a kind of novel flash memory structure, so that flash memory performance under the normal conditions operation, can be more approaching with Electrically Erasable Read Only Memory, and then can promote its performance to 436 times (when the data allocations piece is 256 bytes) or 870 times (when the data allocations piece is 128 bytes).
The present invention will provide a kind of novel flash memory structure, when rewriting, not can because of have a power failure, when machine, substitute situation such as flash memory, cause data to lose in a large number, give full play to the characteristic of flash memory, and improve the stability of system.
The present invention will provide a kind of novel flash memory structure, can keep within a certain period of time (the relative recording that given data is revised by remaining storage size, and when chasing after vertical or restore data, suitable data can be provided, make the operator can search required data, the maybe data recovery that will lose easily.
An object of the present invention is to provide a kind of method of operating of novel flash memory, it is mainly when rewriting, rewrite in content and the old allocation block original content synthetic after, write in the new allocation block, change the new allocation block of index point simultaneously, with the allocation block of new allocation block replace old, so, not only must not wipe whole data allocations piece earlier, and not can because of have a power failure, when machine, substitute situation such as flash memory, cause data to lose in a large number.
A further object of the present invention provides a kind of method of operating of novel flash memory, it can be retained in the relative recording of the data modification in the certain hour (storage size by remaining flash memory is decided), so that when following the trail of, can provide suitable data.
Therefore, the method for operating of novel flash memory provided by the invention comprises the following step:
First step: search allocation block wherein in the master-slave mode file allocation table that CPU (central processing unit) to flash memory is set up in advance:
Second step: when CPU (central processing unit) obtains new allocation block, can read in the content in the former allocation block that stores legacy data earlier after, revise the content in the former allocation block again, and the part that desire is upgraded added;
Third step: will write together in the new allocation block through the amended content of second step;
The 4th step: the master file allocation table that is indexed to new allocation block that duplicates former allocation block master file allocation table;
The 5th step: revise the index direction from file allocation table of former allocation block, make it point to new allocation table, so, promptly finish the work of rewriting;
In CPU (central processing unit) when looking for new allocation block, can obtain another allocation block by the master file allocation table retrieval of the allocation block at the original data of this allocation block place, as long as the allocation block that retrieves is not empty from file allocation table, just use the allocation block that points to from file allocation table to substitute original allocation block, so circulation is gone down, up to finding empty allocation block.
Embodiment
This discovery provides a kind of novel flash memory structure and method of operating, please refer to Figure 1A, 1B, 1C figure, it mainly is a kind of defective of wanting sheet to wipe when rewriting at flash memory, and when rewriting, the mode of index is set up in employing, as far as possible duplicating to substitute sheet with the allocation block of small pieces wipes, briefly, promptly be when rewriting, the content that will rewrite and the old original content of allocation block synthetic after, write in the new allocation block, change the new allocation block of index point simultaneously, with the allocation block of new allocation block replace old.
Structure of the present invention includes: master-slave mode file allocation table (FAT) and logical page (LPAGE), wherein, logical page (LPAGE) is that the erase block with flash memory is that logical page (LPAGE) is a foundation, the monoblock flash memory is divided into a series of logical page (LPAGE), and for each page or leaf adds a logical page number (LPN) with identification, it is exchange page or leaf (shown in 5A, B) that one page is wherein arranged.
In addition, the master-slave mode file allocation table then is to set up two parts of the same file allocation table in flash memory, is FAT1 and FAT2 in the present embodiment.Wherein, FAT1 is master file allocation table (FAT), as the foundation of data recording, and FAT2 is from file allocation table, usefulness during as the correction of master file allocation table is dispersed in file allocation table (FAT) in each logical page (LPAGE) again, to disperse the risk (shown in Fig. 2 A) of erase operation.Please refer to shown in Fig. 2 B, it mainly is that the flash memory (size of its erase block is 16K) of TC58F400 is set up allocation table according to aforesaid way with the model of TOSHIBA.
Please refer to shown in Figure 3, when in CPU (central processing unit) cooperates, having the flash memory work of master-slave mode allocation table and logical page (LPAGE) structure, it mainly is by master file allocation table (FAT) with from the single chain structure of data allocation table (FAT) with master-slave mode file allocation table (FAT), the tree structure that constitutes with complementation substitutes, and its each piece (containing three allocation blocks) is represented a file allocation table (FAT); Wherein, first allocation block is represented the data allocations piece of the representative of this document allocation table (FAT) own, does not in fact exist in data structure and method of operating, and it is by the implicit expression in the position of this document allocation table (FAT) own; Second allocation block then is meant the next file allocation table (FAT) that file allocation table (FAT) is pointed to, and this is the structure of general known file allocation table, just master file allocation table (FAT); In addition, the 3rd allocation block promptly is so-called from file allocation table (FAT).
For further understanding aforesaid operations, be described as follows for an embodiment now:
For example: desire is during with the content update in the data allocations piece of 0x801, the CPU (central processing unit) (not shown) need earlier by the flash memory that establishes the master-slave mode file allocation table in advance from file allocation table, obtain a new data allocations piece (for example 0x900), and 0x801 data allocations piece from file allocation table (FAT), write down new data allocations piece (for example 0x900), again with content useful in the 0x801 data allocations piece and the content replication that will write to new data allocations piece, allow master file allocation table (FAT) in the new data allocations piece point to master file allocation table (FAT) place pointed of 0x801 data allocations piece again.
When CPU (central processing unit) is being analyzed file allocation table (FAT) in the flash memory, if this data allocations piece is empty from data allocation table (FAT), then go down along master file allocation table (FAT) table bonding analysis:, then use from file allocation table (FAT) and point to alternative former of new data allocations piece if this data allocations piece is not empty from file allocation table (FAT) according to common method of operating.
Itself also can form chained list this situation, and as shown in Figure 3, wherein 0x802 → 0x901 → 0x902 is exactly owing to repeatedly revise the modification chained list that forms.
By as can be known aforementioned, as long as also have living space, CPU (central processing unit) need not equally to carry out as is known erase operation consuming time, as long as it is all right to move the data of small pieces.So, not only the time of update content be can save, and large stretch of data, the just action that can rewrite need not to wipe earlier.
But as CPU (central processing unit) at the Study document allocation table, when can not get new data allocations piece, CPU (central processing unit) promptly can reclaim discarded data allocations piece (as the 0x801 among Fig. 4 to the file allocation table in flash memory, 0x802, work 0x901); Generally speaking, CPU (central processing unit) can reclaim the situation of discarded data allocations piece, and two kinds of situations are arranged:
First CPU (central processing unit) (CPU) free time treats, at this moment can during not in other work of processing, start the program that reclaims discarded data allocations piece in CPU (central processing unit), does recovery operation.
It two is when distributing new data allocations piece failure, also can start the program that reclaims discarded data allocations piece, the work of reclaiming.
And the principle of work of the data allocations piece that recovery is discarded, then be by whole file allocation table in the CPU (central processing unit) scanning flash memory (comprising that main money file allocation table reaches from file allocation table), if find certain data allocations piece from file allocation table when empty, promptly revise the index of the master file allocation table of this data allocations piece, make it directly to point to amended correct data allocations piece, constantly repeat above-mentioned steps, up to the correct file allocation table of all index point, deleting all more above-mentioned is not empty file allocation table (shown in power 4) from file allocation table.
Please refer to shown in Fig. 5 A, when exchanging when logical page (LPAGE) cooperation master-slave mode file table work, the CPU (central processing unit) platform gives initialization earlier with logical page (LPAGE)s all in the flash memory that is mated, and in each allocation block, make an array respectively, these arrays are to arrange in regular turn with logical page number (LPN), its content is the true address of this page, to exchange page or leaf again and place the last of these logical page (LPAGE)s, logical page number (LPN) and the numbering of this allocation block in page or leaf are mixed, like this no matter this logical page (LPAGE) is moved to what place, we can pass through file allocation table, know the allocation block that will operate in which logical page (LPAGE) where, and can know that this logical page (LPAGE) somewhere, so, when CPU (central processing unit) when rewriting the content of flash memory, it is mainly a job of carrying out the page or leaf exchange, rather than the data of change are write on the position at original data place.
Moreover, please refer to shown in Fig. 5 B, duplicate during new data best friend in the storer skips, the exchange exchange page or leaf and the address of wiping page or leaf so, are wiped page or leaf and will have been become new exchange page or leaf, and wipe exchange again, have also removed its logical page number (LPN) sign.
Moreover the method for operating of a kind of novel flash memory of the present invention is to cooperate the structure of aforesaid novel flash memory and the flow process of carrying out, and the step of its flow process is as follows:
Please contrast shown in Figure 7, when the data material in the CPU (central processing unit) desire renewal flash memory, at first, search allocation block in the master-slave mode file allocation table that CPU (central processing unit) to flash memory is set up in advance, and judge the conflict whether allocation block found can write, as not, just directly more new data write in this allocation block, so, get final product power cut-off.
In this way, then CPU (central processing unit) can continue to look for other allocation block, as when obtaining a new allocation block, CPU (central processing unit) can be read in the content in the former allocation block that stores legacy data earlier, revise the content in the former allocation block again, and after the part adding with the desire renewal, amended content is write in the new allocation block together, then behind the master file allocation table of again that the index copy of former allocation block master file allocation table is extremely new allocation block, revise the index direction from file allocation table of former allocation block, make it point to new allocation block, so, promptly finish the work of rewriting.
As for, how to inquire about the action of next allocation block, please refer to shown in Figure 6, allocation block master file allocation table by the original data of this allocation block place is retrieved another allocation block that obtains, as long as the allocation block that retrieves is not empty from file allocation table, just use the allocation block that points to from file allocation table to substitute original allocation block, so circulation is gone down, up to finding empty allocation block.As the allocation block that retrieves from the data allocation table for empty, promptly finish the action of looking for.
Moreover, all searched as all allocation blocks, and when failing to find free allocation block, CPU (central processing unit) promptly can be discarded the work that allocation block reclaims, as fail to obtain the piecemeal piece of any recovery, the information of failure and power cut-off promptly appear.
Otherwise, if can successfully obtain the allocation block that reclaims, then the allocation block that reclaims is become a new allocation block.
As for how discarding the work that allocation block reclaims, please refer to shown in Figure 8.At first, search for all logical page (LPAGE)s in flash memory,, promptly finish search work as all logical page (LPAGE) search are finished.
As not, then carry out the switching motion of logical page (LPAGE), and when the exchange work of carrying out logical page (LPAGE), CPU (central processing unit) can be according to real-life operational situation, judge the requirement of flash memory being sent shut-down operation, so that CPU (central processing unit) is unlikely occupied of a specified duration excessively, and then the normal work of influence.In this way, promptly quit work; As not, then continue the logical page (LPAGE) of search in flash memory, carry out the exchange work of logical page (LPAGE) simultaneously.
Exchange work as for how carrying out logical page (LPAGE) please refer to shown in Figure 9.At first judge whether to lock successfully, as not, then proceed the work that locks, till success by CPU (central processing unit).
In this way, can make then that processing procedure is unlikely to be interrupted, and proceed original allocation block in the search logic page or leaf, and judge whether allocation block searches all in this logical page (LPAGE) to be finished by CPU (central processing unit).In this way, then read in the file allocation table of old logical page (LPAGE), and after will wherein all data from the data allocation table emptying sky, the content of revising is write to the position of the file allocation table of new logical page (LPAGE), duplicate the opposite position of the logical page number (LPN) of old logical page (LPAGE), the exchange of the page or leaf location of carrying out old logical page (LPAGE) again and page location of new logical page (LPAGE) to new logical page (LPAGE), then with in the old logical page (LPAGE) the data erase that elder generation set up, carry out release work again, after finishing, get final product power cut-off.
As not, whether what then CPU (central processing unit) can continue to judge the allocation table that searches is empty from file allocation table, in this way, then this allocation block is copied on the opposite position of new logical page (LPAGE), finishes up to all allocation block searches.
In sum, the structure and the method for operating of a kind of novel flash memory of the present invention not only can be improved the various shortcomings of known technology, and can promote effect in the use, have characteristics such as practicality.