The content of the invention
Present invention solves the technical problem that be that a kind of method and system of test NFTL are provided, even if the test volume of NFTL
When very big, it is also possible to avoid damaging nand flash memory, so as to reduce the waste of resource.
For this purpose, the technical scheme that the present invention solves technical problem is:
The invention provides a kind of method of test NFTL, methods described is used in the system for test NFTL, the system
Including control unit and mechanical hard disk, described control unit arranges the individual of block according to the model of the target nand flash memory of test NFTL
The maximum erasing times of number, the block identification of each block and block, and the block identification correspondence of each block is stored in mechanical hard disk
Status indicator be initial marking, store each block the corresponding erasing times of block identification be initial number of times;
Methods described includes:
Control unit monitors whether the operational order for receiving NFTL, wherein, there is in the operational order action type
And operating parameter, at least there is in the operating parameter operation block identification;
If receiving the operational order of NFTL, the corresponding status indicator of operation block identification in the operational order is judged
Whether it is bad block identification, if it is, return operation bad block and pointing out and terminating flow process;If it is not, then according to the operational order
In action type and operating parameter mechanical hard disk is performed it is corresponding operate, and judge the operation class in the operational order
Whether type is erasing instruction, if erasing instruction, then by mechanical hard disk with the operational order in operation block identification pair
The erasing times answered add one;
Wherein, when the corresponding erasing times of arbitrary block identification of mechanical hard disk storage reach maximum erasing times, by machine
In tool hard disk, the corresponding status indicator of the block identification is stored as bad block identification.
Preferably, described control unit arranges the corresponding page of each block identification according to the model of the target nand flash memory of NFTL
Mark, and the page of each page identify corresponding read operation and be designated reading failure mark or read success flag, and mechanical hard
The page that each page is stored in disk identifies corresponding read operation mark;The operating parameter also includes that start page is identified and operates page
Number;
Corresponding behaviour is performed to mechanical hard disk in the action type and operating parameter according in the operational order then
Also include before work:
Judge whether the action type in the operational order is read operation, if read operation, then judges mechanical hard disk
In with operation block identification, start page mark and the read operation mark for operating corresponding each page of mark of page number corresponding whether
There is reading failure mark, if it is, terminating flow process.
Preferably, described control unit arranges the corresponding page of each block identification according to the model of the target nand flash memory of NFTL
Mark, and the page of each page identify corresponding write operation and be designated to write and unsuccessfully identify or write success flag, and mechanical hard
The page that each page is stored in disk identifies corresponding write operation mark;The operating parameter also includes that start page is identified and operates page
Number;
Corresponding behaviour is performed to mechanical hard disk in the action type and operating parameter according in the operational order then
Also include before work:
Judge whether the action type in the operational order is write operation, if write operation, then judges mechanical hard disk
In with operation block identification, start page mark and the write operation mark for operating corresponding each page of mark of page number corresponding whether
Presence is write and is unsuccessfully identified, if it is, terminating flow process.
Preferably, described control unit arranges the block identification correspondence of each block according to the model of the target nand flash memory of NFTL
Erasing operation be designated erasing and unsuccessfully identify or wipe success flag, and the block identification of each block is stored in mechanical hard disk
Corresponding erasing operation mark;
Corresponding behaviour is performed to mechanical hard disk in the action type and operating parameter according in the operational order then
Also include before work:
Judge whether the action type in the operational order is erasing operation, if erasing operation, then judge machinery
In hard disk, erasing operation corresponding with the operation block identification in operational order identifies whether unsuccessfully to identify for erasing, if it is,
Terminate flow process.
Preferably, described control unit arranges the corresponding page of each block identification according to the model of the target nand flash memory of NFTL
Identify, and the corresponding maximum of each block identification is stored in mechanical hard disk page is used for initial number of pages;The operating parameter is also
Identify including start page and operate page number;
Also include after the operational order for receiving NFTL:Judge whether the action type in the operational order is to write behaviour
Make,
If write operation, then in the action type and operating parameter according in the operational order to mechanical hard disk
Also include before performing corresponding operation:Judge whether the corresponding maximum of the operation block identification is initial number of pages using page, such as
Fruit is initial number of pages, then judge that the start page is identified whether as page 0, if not being page 0, it is not the to return write operation
The miscue of page 0, and terminate flow process;If being not initial number of pages, judge that the start page is identified whether as most ambassador
The sum for plus one with page, points out and terminates flow process if it is not, then returning and writing sequence error;
If write operation, then in the action type and operating parameter according in the operational order to mechanical hard disk
When performing corresponding operation, it is additionally included in mechanical hard disk and the corresponding maximum of operation block identification in operational order is stored using page
It is the number of the page mark that data are not write during all of page corresponding with the operation block identification is identified.
Preferably, the operating parameter is also identified including channel type, the operating block mark judged in the operational order
Knowing before whether corresponding status indicator is bad block identification also includes:Judge that the channel type is identified whether for double-deck mark, such as
Fruit is the operation block identification corresponding status indicator for then judging in the operational order also includes when whether being bad block identification:Sentence
Whether the corresponding status indicator of block identification that the disconnected operation block identification adds is bad block identification, if it is, it is bad to return operation
Block is pointed out and terminates flow process.
Preferably, the corresponding page mark of each block identification is set, and each page of mark correspondence is stored in mechanical hard disk
Data be primary data;
Corresponding operation is performed to mechanical hard disk according to the action type and operating parameter in the operational order then includes:
When the action type in the operational order is write operation, will be with operation block identification, starting in mechanical hard disk
Page mark and the data storage for operating corresponding each page of mark of page number corresponding are write data, wherein, the operation ginseng
Number also includes write data, start page mark and operates page number;
When the action type in the operational order is read operation, with operation block identification, starting in reading mechanical hard disk
Page mark and the data for operating corresponding each page of mark of page number corresponding, wherein, the operating parameter also includes start page
Mark and operation page number;
When the action type in the operational order is erasing operation, the corresponding all pages of marks of block identification will be operated to exist
In mechanical hard disk, corresponding data storage is primary data.
Preferably, it is characterised in that the operating parameter is also identified including layer;
When the action type in the operational order is write operation or read operation, if the layer mark in the operational order
It is for single-layer identification, then described with operation block identification, start page mark and to operate corresponding each page mark of page number to be specially:With
It is described to operate the corresponding page of block identification to be designated each interval page mark of [pageid, pageid+pagenum-1];If described
Layer in operational order is designated double-deck mark, then described corresponding with operation block identification, start page mark and operation page number
Each page mark is specially:Page corresponding with the operation block identification is designated [pageid, pageid+pagenum/2-1] area
Between each page identify, and corresponding with the block identification of the operation block identification+1 be designated [pageid, pageid+
Pagenum/2-1] each interval page identifies;Wherein, pageid is identified for start page, and pagenum is operation page number;
When the action type in the operational order is erasing operation, if the layer in the operational order is designated bilayer
Mark, then will operate corresponding all pages of block identification to identify when corresponding data storage in mechanical hard disk is primary data also
Including:It is initial by the block identification of operation block identification+1 corresponding all pages of corresponding data storages in mechanical hard disk of mark
Data.
The invention provides a kind of system of test NFTL, the system includes control unit and mechanical hard disk;
Described control unit arranges the block mark of the number of block, each block according to the model of the target nand flash memory of test NFTL
Know and block maximum erasing times, and the corresponding status indicator of the block identification of each block is stored in mechanical hard disk is initial
The corresponding erasing times of block identification for identifying, storing each block are initial number of times, and monitor whether to receive the operation of NFTL
Instruction;Wherein, there is action type and operating parameter in the operational order, at least there is in the operating parameter operating block mark
Know;
If described control unit receives the operational order of NFTL, during described control unit judges the operational order
Whether the corresponding status indicator of operation block identification is bad block identification, if it is, return operation bad block and pointing out and quitting work;Such as
It is really no, then corresponding operation is performed according to the action type and operating parameter in the operational order to mechanical hard disk, and sentenced
Whether the action type broken in the operational order is erasing instruction, if erasing instruction, then by mechanical hard disk with it is described
The corresponding erasing times of operation block identification in operational order add one;
Wherein, described control unit is additionally operable to reach most when the corresponding erasing times of arbitrary block identification of mechanical hard disk storage
During big erasing times, the corresponding status indicator of the block identification in mechanical hard disk is stored as into bad block identification.
Preferably, described control unit is additionally operable to the model of the target nand flash memory according to NFTL and arranges each block identification pair
The page mark answered, and store that each block identification is corresponding maximum to use page to be initial number of pages in mechanical hard disk;Wherein, it is described
Operating parameter also includes that start page is identified and operates page number;
Described control unit is additionally operable to, and after the operational order for receiving NFTL, judges the operation in the operational order
Whether type is write operation;
If write operation, then described control unit be additionally operable in the action type according in the operational order and
Before operating parameter performs corresponding operation to mechanical hard disk, judge that whether the corresponding maximum of the operation block identification using page is
Initial number of pages, if initial number of pages, then judges that the start page is identified whether as page 0, if being not page 0, returns
Write operation miscue not for page 0, and quit work;If being not initial number of pages, the start page mark is judged
Whether it is the maximum sum for adding using page, points out and quit work if it is not, then returning and writing sequence error;
If write operation, then described control unit be additionally operable in the action type according in the operational order and
When operating parameter performs corresponding operation to mechanical hard disk, will be the operation block identification in operational order corresponding most in mechanical hard disk
The number of the big page mark for being stored as in all of page mark corresponding with the operation block identification not writing data using page.
By above-mentioned technical proposal, the corresponding status indicator of block identification and erasing times are stored in mechanical hard disk,
After control unit monitors the operational order of NFTL, judge the corresponding status indicator of operation block identification in operational order whether
For bad block identification, if bad block identification, then return operation bad block and point out and terminate flow process, now understand that NFTL is held to bad block
Operation is gone;If not being bad block identification, according to action type and operating parameter corresponding reading and writing are performed to mechanical hard disk with
And erasing operation, and judge whether the action type of operational order is erasing operation, if it is, by mechanical hard disk with behaviour
Make the corresponding erasing times of block identification and add one.When the corresponding erasing times of any one block identification stored in mechanical hard disk reach
During maximum erasing times, the corresponding status indicator of the block identification in mechanical hard disk is stored as into bad block identification.That is, at this
In the technical scheme of invention, NFTL only need to send operation to control unit and refer to without the need for performing corresponding operation again to nand flash memory
Order, control unit perform corresponding operation in mechanical hard disk according to operational order, and by arranging the state mark of each block
Knowing the block for causing erasing times to reach maximum erasing times becomes bad block.Due to mechanical hard disk it is complete with the physical arrangement of nand flash memory
It is complete different, and mechanical hard disk does not have the restriction of maximum erasing times, therefore, technical scheme does not pass through
Nand flash memory tests NFTL, and mechanical hard disk also will not be damaged as erasing times, though NFTL test volume very
When big, it is also possible to avoid damaging mechanical hard disk, will not more damage nand flash memory, so as to reduce the wasting of resources.
Specific embodiment
Fig. 1 is referred to, the invention provides a kind of specific embodiment of the method for test NFTL, in this embodiment, institute
Stating method is used in the system for test NFTL, and the system includes control unit and mechanical hard disk.Specifically, the test NFTL
System can be computer (such as PC), embedded hardware plate etc., and control unit can be ARM (Advanced RISC
Machines), MCU (Micro Control Unit, microprocessor), FPGA (Field-Programmable Gate
Array, i.e. field programmable gate array) etc. the module with control function.Target NAND of the control unit according to test NFTL
The model of flash memory arranges the maximum erasing times of the number, the block identification of each block and block of block.Here, test the target of NFTL
Nand flash memory refers to the nand flash memory that can be used in testing the NFTL, and block identification is uniquely corresponding with each block of nand flash memory
Identification number.
And the corresponding status indicator of each block identification is stored in mechanical hard disk to be initial marking, store the block of each block
Corresponding erasing times are identified for initial number of times.Here, one is provided with to each block actually on mechanical hard disk
For the flag of the state of home block, and one data for the erasing times of record block is set to each block
Position.In the specific implementation, can be store in mechanical hard disk each block identification status indicator corresponding with the block identification and
Erasing times, can also be and store all of status indicator and erasing times in mechanical hard disk in sequence, for example,
One storage location of mechanical hard disk starts to deposit 0 corresponding status indicator of block identification successively, next storage 1 correspondence of block identification
Status indicator, by that analogy, until all of block identification corresponding status indicator is all stored, storage erasing times can
It is similar in the way of identifying with storage state, repeat no more here.
Methods described includes:
S101:Control unit monitors whether the operational order for receiving NFTL, wherein, there is in the operational order operation
Type and operating parameter, at least have operation block identification in the operating parameter.
Action type includes read operation, write operation and erasing operation.Due to performing read operation and write operation to nand flash memory
When, carried out in units of page, therefore action type is for, during read operation, operating parameter at least has operation block identification, rises
Beginning page is identified and operates page number;When action type is write operation, operating parameter at least has operation block identification, start page mark
Know, operate page number and write data.And to nand flash memory perform erasing operation when in units of block, therefore operate class
When type is erasing operation, operating parameter at least has operation block identification.Wherein, operating block identification to refer to NFTL needs to perform tool
The block identification of the object block of body reading and writing or erasing operation, start page mark refers to NFTL needs execution specifically to read or write
The page mark of the start page of the page object mark of operation, operation page number refers to NFTL to be needed to perform concrete reading or write operation
Page object mark mark number.
If after the control unit in the step receives the operational order of NFTL, performing S102.Here, if do not connect
To the operational order of NFTL, then can continuously carry out, can also S101 be performed by loop cycle of certain hour, not affect
The enforcement of the present invention.
S102:Judge whether the corresponding status indicator of operation block identification in the operational order is bad block identification, if
It is then to perform S103, now operates the corresponding status indicator of block identification to be bad block identification;If it is not, then performing S104, now grasp
It is not bad block identification to make the corresponding status indicator of block identification.
S103:Return operation bad block to point out and terminate flow process.Operating block mark in the operational order for now being sent due to NFTL
It is bad block to know corresponding, therefore terminates whole flow process.
S104:Corresponding operation is performed according to the action type and operating parameter in the operational order to mechanical hard disk,
And judge whether the action type in the operational order is erasing instruction, if erasing instruction, then performs S105.
S105:Erasing times store in mechanical hard disk, corresponding with the operation block identification in the operational order are added
One.
Below according to the classification of action type, introduce respectively
The step for concrete execution action.
When action type is write operation, the corresponding page mark of each block identification was set before step S104, then the step
The corresponding operation of mechanical hard disk execution is included according to the action type and operating parameter in the operational order in rapid S104:
By page mark corresponding with operation block identification, start page mark and operation page number corresponding data storage in mechanical hard disk
To write data.Wherein, page mark corresponding with operation block identification, operation page mark and operation page number is referred to and the behaviour
Make each page that block identification is corresponding, page is designated [pageid, pageid+pagenum-1] interval to identify.Wherein, pageid
Identify for the start page in operating parameter, pagenum is the operation page number in operating parameter.For example, operate block identification blkid
Be 4 for 2, pageid, operation page number pagenum is 5, then above-mentioned and operation block identification, operation page mark and operation page number
It is 2 corresponding that corresponding page mark refers to operation block identification blkid, page mark 4,5,6,7 and 8.
When action type is read operation, the corresponding page mark of each block identification was set before step S104, then the step
Rapid S104's includes to the corresponding operation of mechanical hard disk execution according to the action type and operating parameter in the operational order:Read
Take the corresponding data of each page of mark corresponding with operation block identification, start page mark and operation page number in mechanical hard disk.
Here the explanation to identifying with operation block identification, start page mark and corresponding each page of operation page number is identical with the preceding paragraph,
Therefore repeat no more.Before step S104, can with mechanical hard disk by each page mark corresponding to each block identification
Corresponding data storage is known for primary data, such as 0xff.
When action type is erasing operation, then in step S104 according to the action type in the operational order and
Operating parameter performs corresponding operation to mechanical hard disk to be included:In erasing mechanical hard disk, the operation block identification it is corresponding all
The corresponding data of page mark.If by each block identification in mechanical hard disk corresponding each page before step S104
The corresponding data storage of mark is primary data, such as 0xff, then in above-mentioned erasing mechanical hard disk, the operation block identification pair
Answer all pages corresponding data of mark can be specially by mechanical hard disk, the corresponding all pages of marks of the operation block identification
Corresponding data storage is known for primary data, such as 0xff.
In this embodiment, methods described also includes:When the corresponding erasing times of arbitrary block identification of mechanical hard disk storage
When reaching maximum erasing times, the corresponding status indicator of the block identification in mechanical hard disk is stored as into bad block identification.Specifically, sentence
The process of the block identification corresponding erasing times of breaking can be in this embodiment either step, due to only performing erasing
After operation, erasing times can just change, therefore above-mentioned judge process generally before an erase operation is performed or performs wiping
Division operation and erasing times are performed after adding one.It is concrete separately below to introduce:If performing before an erase operation is performed above-mentioned
Judge process, then specially when the judged result of step S101 be yes, and the execution before execution step S102:If the behaviour
It is erasing operation to make type, then judge whether the corresponding erasing times of operation block identification in the operational order reach maximum wiping
Except number of times, if reached, the corresponding status indicator of the block identification in mechanical hard disk is stored as into bad block identification.If performing wiping
Division operation and erasing times are performed after adding one, then it is specially described by mechanical hard disk with the operational order in operation
The corresponding erasing times of block identification also include after adding one:Judge that the corresponding erasing of operation block identification in the operational order is secondary
Whether number reaches maximum erasing times, if reached, the corresponding status indicator of the block identification in mechanical hard disk is stored as bad
Block identification.
By above-mentioned technical proposal, store in mechanical hard disk in the embodiment the corresponding status indicator of block identification and
Erasing times, after control unit monitors the operational order of NFTL, judge the corresponding shape of operation block identification in operational order
State is identified whether as bad block identification, if bad block identification, is then returned operation bad block and is pointed out and terminate flow process, now understand
NFTL performs operation to bad block;If not being bad block identification, mechanical hard disk is performed according to action type and operating parameter
Corresponding reading and writing and erasing operation, and judge whether the action type of operational order is erasing operation, if it is, will
In mechanical hard disk, erasing times corresponding with operation block identification add one.When any one block identification stored in mechanical hard disk it is corresponding
When erasing times have reached maximum erasing times, the corresponding status indicator of the block identification in mechanical hard disk is stored as into bad block mark
Know.That is, in technical scheme, NFTL, only need to be to control without the need for performing corresponding operation again to nand flash memory
Unit processed sends operational order, and control unit performs corresponding operation in mechanical hard disk according to operational order, and by setting
The status indicator of each block is put so that the block that erasing times reach maximum erasing times becomes bad block.And mechanical hard disk is dodged with NAND
The physical arrangement deposited is entirely different, and mechanical hard disk is compared with nand flash memory, with a very important characteristic, is exactly machine
Tool hard disk does not have the restriction of maximum erasing times, therefore, technical scheme is not tested by nand flash memory
NFTL, and also mechanical hard disk will not be damaged as erasing times, even if when the test volume of NFTL is very big, it is also possible to keep away
Exempt to damage mechanical hard disk, will not more damage nand flash memory, so as to reduce the wasting of resources.
And in prior art, due to directly being tested on nand flash memory, therefore test process cannot be adjusted
Examination, and caused it is difficult to judge to problem appear to is that during test by NFTL, or caused by nand flash memory in itself.And in this enforcement
In example, can also installation and debugging instrument in the system, such as visual c++ (VC) etc., to realize convenient trace debug
The debugging problem found in test, so that it is determined that whether the problem of test is caused by NFTL.
In fact, nand flash memory can have monolayer (plane) operation and double-deck (plane) operation, then now in operation
Also include layer (plane) type identification in parameter, wherein plane type identifications include two species of single-layer identification and double-deck mark
Type.Single plane operations and double plane operations of nand flash memory are introduced first.
Fig. 2 is the plane cutting figures of the nand flash memory of model K9LBG08U0M of a Samsung.Monolithic choosing
K9LBG08U0M has 8192 block, is split as 4 plane, respectively plane0, plane1, plane2 and
plane3.Wherein plane0 include block0, block2 ..., block4094 totally 2098 block, plane1 includes
Block1, block3 ..., block4095 totally 2098 block, plane2 include block4096, block4098 ...,
Block8190 totally 2098 block, plane3 include block4097, block4099 ..., block8191 totally 2098
block.Each block respectively includes page0 to page127 totally 128 page.
Wherein, the odd-even alternations each other of the block in plane0 and plane1, the block in plane2 and plane3 are also mutual
For odd-even alternation, a pair of plane of these odd-even alternations are known as pairedplane, at two of paired plane each other
Horizontal two block is in plane, referred to as with group block.For example:The block0's and plane1 of plane0
Block1 is the block with group;The block4 of the block3 and plane3 of plane2 is block with group etc..
For the normal operations of the nand flash memory for not being cache modes, when being all the operation, i.e. erasing operation of single plane
It is merely able to wipe a block of certain plane, read operation or write operation are then merely able to while reading or writing some plane
Certain block one of page.
Nand flash memory shown in Fig. 2 provides the operation of double plane in addition to providing the operation of list plane, also.It is worth explanation
, double plane operations can only be in operation in two plane of paired plane each other.Such as:Double plane erasing operations can
The block3 of the block2 and plane1 of plane0 is wiped simultaneously;Double plane read operations or write operation then can be right
Same one page of block2 and block3 is write or read operation.
Therefore, the operating parameter in the present embodiment can also include start page mark, operation page number and plane types
Mark, and corresponding page mark is set for each block identification before step S104.When plane type identifications are double-deck mark
When, illustrate now to need to perform operation to the block identification for being designated blkid and blkid+1.Wherein, blkid is operation block identification.
Therefore can also include before step S102:Judge that the channel type is identified whether for double-deck mark, if it is, performing step
Also include during rapid S102:Judge whether the corresponding status indicator of block identification that the operation block identification adds is bad block identification, such as
Fruit is then to return operation bad block to point out and terminate flow process.
Additionally, the step of the present embodiment in S104, when action type is read operation or write operation and the plane classes
When type is designated bilayer mark, then page mark corresponding with operation block identification, operation page mark and operation page number should refer to
It is that page corresponding with the operation block identification is designated each interval page mark of [pageid, pageid+pagenum/2-1],
And corresponding with the block identification of the operation block identification+1 it is designated [pageid, pageid+pagenum/2-1] interval each
Individual page mark.Wherein, pageid is identified for the start page, and pagenum is the operation page number.For example, operate block identification
It is 4 that blkid is 2, pageid, and operation page number pagenum is 6, then above-mentioned and operation block identification, operation page mark and operation page
It is 2 corresponding that the corresponding page mark of number refers to operation block identification blkid, and page identifies 4,5,6 and operation block identification blkid
For 3 corresponding page marks 4,5,6.When action type is erasing operation and when the plane type identifications are identified for bilayer,
Also include when then the data that the corresponding all pages of marks of block identification will be operated corresponding in mechanical hard disk are wiped:Will operation
The data that the corresponding all pages of marks of block identification of block identification+1 are corresponding in mechanical hard disk are wiped.Certainly, erasing is grasped here
Make to be replaced with primary data this operation is stored as.Detailed process is concrete referring to the related part of step 104
Description.
Why nand flash memory can be widely used, and one is exactly that there is nand flash memory power down not lose the reason for critically important
The characteristic of mistake, this is because OOB (the Out Of Band) information that all pieces of upper each pages are present on nand flash memory.OOB information
It is and then root after nand flash memory is started shooting again for the nand flash memory shutdown when data are write or the recovery data preserved during power down
The recovery operation of data is carried out according to the OOB information.Therefore in the present embodiment, operating parameter can also include start page mark,
Operation page number and OOB information.Then according to the action type and operating parameter in the operational order described in step S104
Also include when corresponding operation is performed to mechanical hard disk:
The action type in the operational order is judged for write operation, read operation or erasing operation, if write operation, then
The OOB information in operating parameter is write in mechanical hard disk according to operation block identification, start page mark and operation page number, wherein
Outside the operating parameter division operation block identification, also including start page mark, operation page number and OOB information;If read operation,
OOB information corresponding with operation block identification, start page mark and operation page number in mechanical hard disk is read then, wherein the operation
Outside parameter division operation block identification, also identify including start page and operate page number;If erasing operation, then mechanical hard disk is wiped
In the OOB information corresponding with the operation block identification corresponding all operations page mark, wherein the operating parameter includes behaviour
Make block identification.Certainly, erasing operation can also be replaced with primary data this operation is stored as here.Detailed process referring to
The specific descriptions of the related part of step S104.
Preferably, when the action type in operational order is read operation or write operation, need to read from mechanical hard disk
Take or write data.When read or write operation is performed, according to the model of target nand flash memory, if nand flash memory is supported
Cache modes, can also be operated using cache modes, i.e., disposably continuous multiple pages are performed simultaneously read operation or
Write operation.Wherein, cache modes are divided into the cache modes in the case of single plane, and the cache side in the case of double plane
Formula.Cache modes in the case of single plane can be performed simultaneously to the continuous some pages in certain block of certain plane
Read or write, and the cache modes in the case of double plane can be to same in two plane of paired plane each other
Perform some pages of read or write in group block simultaneously.For example, the cache modes in the case of single plane, can be to certain
All pages in certain block of plane are read or write simultaneously;As shown in figure 3, the cache modes in the case of double plane are read
Or write, then block2 and block3 can be read or write from page0 to page127 simultaneously.
In the present embodiment, methods described is used for the situation of single choosing, and in other embodiments, can also arrange many
Individual piece choosing.Specially:Control unit arranges the number of piece choosing, each piece always according to the model of the target nand flash memory of test NFTL
The piece choosing mark of choosing, and the corresponding block identification of piece choosing mark difference of each piece choosing is set.For example, piece select number be 4 when, respectively
The piece choosing mark of individual piece choosing is respectively chipid0, chipid1, chipid2, chipid3, wherein, the piece choosing mark of each piece choosing
The block mark of 4 block identifications of each correspondence, specially piece choosing mark chipid0 correspondence blkid0, blkid1, blkid2 and blkid3
Know, piece choosing identifies chipid1, chipid2 and chipid3 also each block for corresponding to blkid0, blkid1, blkid2 and blkid3
Mark.Now operating parameter also includes operating sheet choosing mark.
The fault-tolerant processing ability of various failures (reading failure, write failure and wipe failure), Ke Yi are processed to test NFTL
Store in mechanical hard disk each page page identify corresponding write operation mark, reading failure mark, and erasing unsuccessfully identify.Lead to below
Cross one embodiment to be illustrated.Here it should be noted that in following one embodiment, the test might as well be set
The system of NFTL is a PC, while the model of the target nand flash memory of NFTL determines that the nand flash memory has 4 blocks, each block
With 6 pages, the size of each page is 4 bytes.
Fig. 4 is referred to, present invention also offers the another specific embodiment of the method for a test NFTL, in the embodiment
In, methods described is used in a PC, and the PC includes control unit (being specifically as follows CPU) and mechanical hard disk.Control is single
Unit is 4 according to the number that the model of the target nand flash memory of test NFTL arranges block, each block identification respectively blkid0,
Blkid1, blkid2 and blkid3,6 page marks of each block identification correspondence, the corresponding page mark of each block identification are respectively
Pageid0, pageid1, pageid2, pageid3, pageid4 and pageid5.The maximum erasing times of block are 100.
The corresponding status indicator of each block identification is stored in mechanical hard disk for initial marking BLK_ERASEFLAG, storage
The corresponding erasing times of block identification of each block are initial value 0x00, and it is 0xff to store each page and identify corresponding primary data.
In the present embodiment, when storing initial mark, initial value, according to the 0th block to last blocks of order, i.e. block identification
The order of blkid0 to blkid3 is stored.During storing initial data, according to the 0th block to last blocks of order, often
In individual block according to the 0th page to last page order, i.e., page mark pageid0 to pageid5 order stored.At which
In his embodiment, the order of storage is without limitation.Fig. 5 is corresponding for corresponding each page mark of each block identification in the present embodiment
Primary data schematic diagram.
Control unit arranges the page of each page always according to the model of the target nand flash memory of NFTL and identifies corresponding read operation
Be designated reading failure mark or read success flag, arrange each page page identify corresponding write operation be designated write unsuccessfully mark or
The corresponding erasing operation of block identification write success flag and arrange each block is designated erasing and unsuccessfully identifies or wipe and successfully mark
Know, and the block identification that each page identifies corresponding read operation mark, write operation mark and each block is stored in mechanical hard disk
Corresponding erasing operation mark.For example, the needs according to test, can arrange the read operation mark of any page of nand flash memory
Identify for reading failure, remaining page identifies corresponding read operation and be designated reading success flag.
Methods described includes:
S401:Control unit monitors whether the operational order for receiving NFTL, wherein, there is in the operational order operation
Type and operating parameter, at least have operation block identification in the operating parameter.
Action type includes read operation, write operation and erasing operation.When action type is read operation, operating parameter is extremely
It is few that there is operation block identification, start page mark, operation page number and layer (plane) type identification;Action type is write operation
When, operating parameter at least have operation block identification, start page mark, operation page number, write data, plane type identifications and
OOB information;When action type is erasing operation, operating parameter at least has operation block identification and plane type identifications.
If after the control unit in the step receives the operational order of NFTL, performing S402.Here, if do not connect
To the operational order of NFTL, then can continuously carry out, can also S401 be performed by loop cycle of certain hour, not affect
The enforcement of the present invention.
S402:Judge whether the corresponding status indicator of operation block identification in the operational order is bad block identification BLK_
BADFLAG, if it is, performing S403, now operates the corresponding status indicator of block identification to be bad block identification BLK_BADFLAG;
If it is not, then performing S404, the corresponding status indicator of block identification is now operated not to be bad block identification BLK_BADFLAG.
S403:Return operation bad block to point out and terminate flow process.Operating block mark in the operational order for now being sent due to NFTL
It is bad block to know corresponding, therefore terminates whole flow process.
S404:The action type in operational order is judged for write operation, read operation or erasing operation, if writing behaviour
Make, then perform S405.If read operation, S408 is performed, if erasing operation, perform S411.
S405, now action type is write operation, judge in mechanical hard disk with the operating parameter in operation block identification,
Start page identifies and operates corresponding write operation in corresponding each page of mark of page number and identify whether that presence is write and unsuccessfully identifies,
If it is, S406 is performed, if it is not, then performing S407.
S406:Terminate flow process, and can also return to write when terminating flow process and unsuccessfully point out.
S407:Page corresponding with operation block identification, start page mark and operation page number is identified into institute in mechanical hard disk
Corresponding data storage is said write data, and according to operation block identification, start page mark and operates page number operate
In OOB information write mechanical hard disk in parameter.Terminate flow process.
S408:Now action type is read operation, judge in mechanical hard disk with the operating parameter in operation block identification,
Corresponding read operation during start page identifies and operate corresponding each page of mark of page number identifies whether there is reading failure mark,
If it is, S409 is performed, if it is not, then performing S410.
S409:Terminate flow process, and reading failure prompting when terminating flow process, can also be returned.
S410:Read each page mark corresponding with operation block identification, start page mark and operation page number in mechanical hard disk
Know corresponding data, and read OOB corresponding with operation block identification, start page mark and operation page number in mechanical hard disk
Information.Terminate flow process.
Wherein, in read operation and write operation with the operating parameter in operation block identification, start page mark and grasp
Make corresponding each page of page number to identify, when the plane type identifications in operating parameter are single-layer identification, refer to it is described
Operation block identification is corresponding, page is designated each interval page of [pageid, pageid+pagenum-1] and identifies.Work as operating parameter
In plane type identifications for double-deck mark when, refer to page corresponding with the operation block identification be designated [pageid,
Pageid+pagenum/2-1] each interval page is identified, and mark corresponding with the block identification of the operation block identification+1
Identify for each interval page of [pageid, pageid+pagenum/2-1].Wherein, pageid is identified for the start page,
Pagenum is the operation page number.Also, the operating block mark in read operation and write operation in the operating parameter of indication
Know, start page identifies and operate the corresponding relation of page number and the OOB information corresponding to which, with the operation ginseng described in this paragraph
Operation block identification, start page mark and operation page number in number is identical with the corresponding relation of the page mark corresponding to which, therefore
Repeat no more.
Preferably, can be with by the way of cache in the above-mentioned process for writing data or reading data.
S411:Now action type is erasing operation, judges plane type identifications for single-layer identification or double-deck mark, such as
Fruit is single-layer identification, then perform S412, if double-deck mark, then performs S416.
S412:Now plane type identifications are single-layer identification, judge in mechanical hard disk with operational order in operating block mark
Know corresponding erasing operation to identify whether unsuccessfully to identify for erasing, if it is, S413 is performed, if it is not, then performing S414.
S413:Terminate flow process, and erasing when terminating flow process, can also be returned unsuccessfully to point out.
S414:It is first by the data storage in mechanical hard disk, corresponding to the corresponding all pages of marks of the operation block identification
Beginning data 0xff, and by erasing times store in mechanical hard disk, corresponding with the operation block identification in the operational order
Plus one.
S415:Judge whether the corresponding erasing times of operation block identification in the operational order reach maximum erasing time
The corresponding status indicator of the block identification in mechanical hard disk, if reached, is stored as bad block identification BLK_BADFLAG by number.
That is, when the corresponding status indicator of block identification that erasing times reach 100 times is BLK_BADFLAG, it is impossible to again to the block mark
Know corresponding data and perform reading and writing or erasing operation.Terminate flow process.
S416:Now plane type identifications are double-deck mark, judge in mechanical hard disk with operational order in operating block mark
Unsuccessfully identify with the presence or absence of erasing in knowing the corresponding erasing operation mark of block identification that blkid and operation block identification blkid add,
If it is, S413 is performed, if it is not, then performing S417.
S417:By in mechanical hard disk, the operation block identification, and the operation block identification corresponding institute of block identification that adds one
The data storage for having page mark corresponding be primary data 0xff and by it is storing in mechanical hard disk, and the operational order in
The corresponding erasing times of operation block identification add one, and the operation block identification corresponding erasing times of block identification that add one are added
One.
S418:Judge whether the corresponding erasing times of operation block identification in the operational order reach maximum erasing time
The corresponding status indicator of the block identification in mechanical hard disk, if reached, is stored as bad block identification BLK_BADFLAG by number, with
And judge whether the corresponding erasing times of block identification that the operation block identification in the operational order adds reach maximum erasing time
Number, if reached, is stored as bad block identification by the corresponding status indicator of block identification that block identification adds is operated in mechanical hard disk
BLK_BADFLAG。
As can be seen that in the present embodiment, corresponding read operation mark is stored for each page of mark in mechanical hard disk
Know, write operation mark, and erasing operation stored for each block identification and identify, and in other embodiments, only can deposit
One in storage read operation mark, write operation mark and erasing operation mark or an arbitrarily combination, can also be only each page mark
Know and an operation mark is set, the operation mark can be specially reading failure mark READPAGE_FAIL, write and unsuccessfully identify
WRITEPAGE_FAIL, erasing unsuccessfully identify ERASEPAGE_FAIL, and operation success flag RWEPAGE_SUCCESS.When
Action type is write operation or during read operation, judges that process that read operation mark or write operation are identified is replaced with and sentence in step S404
The process of disconnected operation mark.When action type is erasing operation, judges in step S404 that the process of operation mark is replaced with and sentence
The process of the operation marks of corresponding some or certain the several pages of marks of disconnected operation block identification.For example, judge that operating block is designated
When whether the block identification of blkid0 is erasing failure, need to only judge operating block be designated blkid0 block identification it is corresponding 0th
Whether the operation mark of the page mark pageid0 of page is erasing failure.
To sum up, by read operation mark, write operation mark and erasing operation mark are stored in mechanical hard disk in the present embodiment
Know, realize that test NFTL processes the fault-tolerant processing ability of various failures (reading failure, write failure and wipe failure).
In the present embodiment, can be with installation and debugging instrument, such as VC etc., to realize convenient tracking and adjust in the system
The BUG found in examination test.
In current prior art, to the test of NFTL by directly carrying out on nand flash memory, when execution is write
During operation, also simply write data on the page that operating parameter is specified, whether can not meet NAND to the operational order of NFTL
The characteristic requirements of the write operation order of flash memory are tested.And in the next embodiment that the present invention is provided, it becomes possible to solve
The problems referred to above.Here it should be noted that in following one embodiment, the system of the test NFTL might as well be set as one
PC, while the model of the target nand flash memory of NFTL determines that the nand flash memory has 6 pages with 4 blocks, each block, each
The size of page is 4 bytes.
Fig. 6 is referred to, present invention also offers the another specific embodiment of the method for a test NFTL, in the embodiment
In, methods described is used in a PC, and the PC includes control unit (being specifically as follows CPU) and mechanical hard disk.Control is single
Unit is 4 according to the number that the model of the target nand flash memory of test NFTL arranges block, each block identification respectively blkid0,
Blkid1, blkid2 and blkid3,6 page marks of each block identification correspondence, the corresponding page mark of each block identification are respectively
Pageid0, pageid1, pageid2, pageid3, pageid4 and pageid5.The maximum erasing times of block are 100.
The corresponding status indicator of each block identification is stored in mechanical hard disk for initial marking BLK_ERASEFLAG, storage
The corresponding erasing times of block identification of each block are initial value 0x00, store each page of corresponding primary data of mark be 0xff,
It is initial number of pages 0xffff to store the corresponding maximum of each block identification and use page.
Methods described includes:
S601:Control unit monitors whether the operational order for receiving NFTL, wherein, there is in the operational order operation
Type and operating parameter, at least have operation block identification in the operating parameter.
Action type includes read operation, write operation and erasing operation.When action type is read operation, operating parameter is extremely
It is few that there is operation block identification, start page mark, operation page number and layer (plane) type identification;Action type is write operation
When, operating parameter at least has operation block identification, start page mark, operation page number, write data, channel type mark, and OOB
Information;When action type is erasing operation, operating parameter at least has operation block identification and channel type mark.
If after the control unit in the step receives the operational order of NFTL, performing S602.Here, if do not connect
To the operational order of NFTL, then can continuously carry out, can also S601 be performed by loop cycle of certain hour, not affect
The enforcement of the present invention.
S602:Judge whether the corresponding status indicator of operation block identification in the operational order is bad block identification BLK_
BADFLAG, if it is, performing S603, now operates the corresponding status indicator of block identification to be bad block identification BLK_BADFLAG;
If it is not, then performing S604, the corresponding status indicator of block identification is now operated not to be bad block identification BLK_BADFLAG.
S603:Return operation bad block to point out and terminate flow process.Operating block mark in the operational order for now being sent due to NFTL
It is bad block to know corresponding, therefore terminates whole flow process.
S604:Judge the action type in operational order for write operation, read operation or erasing operation.If writing behaviour
Make, perform S605, if read operation, perform S611, if erasing operation, perform S612.
S605:Now action type is write operation, judges whether the corresponding maximum of the operation block identification is just using page
Beginning number of pages, if initial number of pages, then performs S606, if being not initial number of pages, performs S608.
S606:Judge that the start page is identified whether as page 0, if being not page 0, perform S607;If the 0th
Page, then perform S610.
S607:Miscue of the write operation not for page 0 is returned, and terminates flow process.
S608:Judge that the start page identifies whether the sum for adding using page for maximum, if it is not, then S609 is performed, such as
Fruit is then to perform S610.
S609:Return is write sequence error and points out and terminate flow process.
S610:Page corresponding with operation block identification, start page mark and operation page number is identified into institute in mechanical hard disk
Corresponding data storage is said write data, and will be corresponding most with the operation block identification in operational order in mechanical hard disk
The number of the big page mark for being stored as in all of page mark corresponding with the operation block identification not writing data using page, and
And according to operation block identification, start page mark and page number is operated by the OOB information write mechanical hard disk in operating parameter.This
In the described page mark for not writing data refer to the page mark that write data are not stored in mechanical hard disk, and storing initial
The page mark of data is not the page mark for writing data.Terminate flow process.
S611:Now action type is read operation, identifies and operates with operation block identification, start page in reading mechanical hard disk
The corresponding data of corresponding each page of mark of page number, and identify with operation block identification, start page in reading mechanical hard disk
With the corresponding OOB information of operation page number.
Wherein, in read operation and write operation with the operating parameter in operation block identification, start page mark and grasp
Make corresponding each page of page number to identify, when the plane type identifications in operating parameter are single-layer identification, refer to it is described
Operation block identification is corresponding, page is designated each interval page of [pageid, pageid+pagenum-1] and identifies.Work as operating parameter
In plane type identifications for double-deck mark when, refer to page corresponding with the operation block identification be designated [pageid,
Pageid+pagenum/2-1] each interval page is identified, and mark corresponding with the block identification of the operation block identification+1
Identify for each interval page of [pageid, pageid+pagenum/2-1].Wherein, pageid is identified for the start page,
Pagenum is the operation page number.Also, the operating block mark in read operation and write operation in the operating parameter of indication
Know, start page identifies and operate the corresponding relation of page number and the OOB information corresponding to which, with the operation ginseng described in this paragraph
Operation block identification, start page mark and operation page number in number is identical with the corresponding relation of the page mark corresponding to which, therefore
Repeat no more.
Preferably, can be with by the way of cache in the above-mentioned process for writing data or reading data.
S612:Now action type is erasing operation, judges plane types for single-layer identification or double-deck mark, if
Single-layer identification, then perform S613, if double-deck mark, then performs S615.
S613:Now plane type identifications are single-layer identification, by mechanical hard disk, the corresponding institute of the operation block identification
The data storage for having page mark corresponding is primary data 0xff, and by store in mechanical hard disk, and the operational order
In the corresponding erasing times of operation block identification add one.
S614:Judge whether the corresponding erasing times of operation block identification in the operational order reach maximum erasing time
The corresponding status indicator of the block identification in mechanical hard disk, if reached, is stored as bad block identification BLK_BADFLAG by number.
That is, when the corresponding status indicator of block identification that erasing times reach 100 times is BLK_BADFLAG, therefore can not be to the block
Identify corresponding data and perform reading and writing or erasing operation.Terminate flow process.
S615:Now plane type identifications are double-deck mark, by mechanical hard disk, and the operation block identification, it is and described
The corresponding data storage of the corresponding all pages of marks of the operation block identification block identification that adds one is primary data 0xff and by machine
Erasing times store in tool hard disk, corresponding with the operation block identification in the operational order add one, and by operating block mark
The corresponding erasing times of block identification that knowledge Jia one add one.
S616:Judge whether operation block identification and corresponding erasing times in the operational order reach maximum erasing time
The corresponding status indicator of the block identification in mechanical hard disk, if reached, is stored as bad block identification BLK_BADFLAG by number, with
And judge whether the corresponding erasing times of block identification that the operation block identification in the operational order adds reach maximum erasing time
Number, if reached, is stored as bad block identification by the corresponding status indicator of block identification that block identification adds is operated in mechanical hard disk
BLK_BADFLAG。
The step of the present embodiment in S605, when action type is write operation, judge that the operation block identification is corresponding
Whether the step for whether maximum is initial number of pages using page can be with judging described to operate the corresponding status indicator of block identification to be
Initial marking BLK_ERASEFLAG replaces.And when the corresponding status indicator of the operation block identification is initial marking BLK_
During ERASEFLAG, then it is initial number of pages to use page equivalent to the corresponding maximum of the operation block identification.Now, then mechanical hard
Page mark corresponding with operation block identification, start page mark and operation page number corresponding data storage is write for described in disk
Also include when entering data:Status indicator corresponding with operation block identification is stored as into write state BLK_ in mechanical hard disk
DIRTYFLAG, and in step S612, when action type is erasing operation, when plane type identifications are single-layer identification
When, then in mechanical hard disk the corresponding status indicator of block identification will be operated to be stored as original state BLK_ERASEFLAG, when
Plane type identifications for double-deck mark when, then by mechanical hard disk, the operation block identification, and the operation block identification adds one
The corresponding status indicator of block identification be stored as original state BLK_ERASEFLAG.
In in the present embodiment the step of S605, when action type is write operation and operates the corresponding most ambassador of block identification
When being not initial number of pages with page, judge that start page identifies whether the sum for adding using page for maximum.In fact, when start page is identified
For maximum add one using page and when, illustrate the operational order of NFTL may have occurred backward write, skip write and covering write error.
With reference to Fig. 7, describe sequence continuity, backward in Fig. 7 from top to bottom successively and write, cover the block schematic diagram write with skip write.Wherein
Each grid is a page, is a block per ten page, block0, block1 and block2 are shown in Fig. 7,
The page for having oblique line is page with data, and the page for having horizontal line is the page of this write data.Backward write refer to by
Data are write in the block with the page before the most big page of data, covering write refer to write data into the block in write
In having the most big page of data, and after the page that skip write has added with the most big page of data in referring to write data into the block
Page in.
Write in order to determine whether whether the operational order of NFTL meets sequential write, skip write and the covering of nand flash memory
Characteristic requirements, the step of the present embodiment in S605, when action type be write operation when, judge that the start page is identified whether
Add one using page for maximum and can specially judge that the start page identifies whether to use page less than maximum, if it is,
Return backward write error and terminate flow process, judge that the start page identifies whether page to be used equal to maximum, if it is, return covering
Overwrite mistake simultaneously terminates flow process and judges that the start page identifies whether the sum for adding using page more than maximum, if it is,
Return skip write mistake and terminate flow process.
As can be seen that in the present embodiment, when performing writes, NAND sudden strains of a muscle whether can be met to the operational order of NFTL
The characteristic requirements of the write operation order deposited are tested.
A currently preferred specific embodiment is provided below.
Fig. 8 A and Fig. 8 B are referred to, present invention also offers the another specific embodiment of the method for a test NFTL, at this
In embodiment, methods described is used in a PC, and the PC includes control unit (being specifically as follows CPU) and mechanical hard disk.
It is 2 that control unit selects number according to the piece that the model of the target nand flash memory of test NFTL arranges block, each piece choosing mark difference
For chipid0 and chipid1, the number of the block of each piece choosing is 4, and each block identification is respectively blkid0, blkid1, blkid2
And blkid3,6 pages marks of each block identification correspondence, the corresponding page mark of each block identification be respectively pageid0, pageid1,
Pageid2, pageid3, pageid4 and pageid5.The maximum erasing times of block are 100.
3 files are generated for each piece choosing on the mechanical hard disk of PC, vnand.data is respectively designated as,
Vnand.blkstatus and vnand.spare.Vnand.data storages are the single numbers for choosing all pieces of upper each pages
According to, vnand.blkstatus records are that the single status indicator for choosing all pieces, erasing times and maximum use page,
Vnand.spare records are the single OOB information for choosing all pieces of upper each pages.That is, in the present embodiment, lead to
The mode that file realizes the real nand flash memory of simulation is crossed, therefore NFTL need not be tested with real nand flash memory.
The corresponding status indicator of each block identification is stored in vnand.blkstatus for initial marking BLK_
ERASEFLAG, the corresponding erasing times of block identification for storing each block are initial value 0x00 and store each block identification correspondence
Maximum using page be initial number of pages 0xffff.Each page of corresponding primary data of mark is stored in vnand.data is
0xff.In the present embodiment, when storing initial mark, initial value, according to the 0th block to last blocks of order, i.e. block mark
The order for knowing blkid0 to blkid5 is stored.During storing initial data, according to the 0th block to last blocks of order,
In each block according to the 0th page to last page order, i.e., page mark pageid0 to pageid5 order stored.
In other embodiment, the order of storage is without limitation.
Control unit always according to the target nand flash memory of NFTL model arrange each page page mark it is corresponding operation mark
Know for reading failure mark READPAGE_FAIL, write unsuccessfully identify WRITEPAGE_FAIL, erasing unsuccessfully identify ERASEPAGE_
FAIL, and operation success flag RWEPAGE_SUCCESS.0th page correspondence of the erasing operation state of each block by the block
Operation mark determine.
In addition it should be noted that the method provided in the present embodiment has 27 steps, wherein S801-S804, and
In fig. 8 a, S805-S815 in the fig. 8b, when the judged result of S804 is write operation in Fig. 8 A, then performs Fig. 8 B to S816-S827
In S805.
Methods described includes:
S801:Control unit monitors whether the operational order for receiving NFTL, wherein, there is in the operational order operation
Type and operating parameter, at least have operating sheet choosing mark and operate block identification in the operating parameter.
Action type includes read operation, write operation and erasing operation.When action type is read operation, operating parameter is extremely
There is operating sheet choosing mark, operation block identification, start page mark, operation page number and layer (plane) type identification less;Operation
When type is write operation, operating parameter at least have operating sheet choosing mark, operation block identification, start page mark, operation page number,
Write data, channel type mark, and OOB information;When action type is erasing operation, operating parameter at least has operating sheet choosing mark
Know, operation block identification and channel type are identified.
If after the control unit in the step receives the operational order of NFTL, performing S802.Here, if do not connect
To the operational order of NFTL, then can continuously carry out, can also S801 be performed by loop cycle of certain hour, not affect
The enforcement of the present invention.
S802:Judge that the operating sheet choosing in the operational order identifies the status indicator corresponding to corresponding operation block identification
Whether it is bad block identification BLK_BADFLAG, if it is, performing S803, now operates the corresponding status indicator of block identification to be bad
Block identification BLK_BADFLAG;If it is not, then performing S804, the corresponding status indicator of block identification is now operated not to be bad block identification
BLK_BADFLAG。
S803:Return operation bad block to point out and terminate flow process.Operating block mark in the operational order for now being sent due to NFTL
It is bad block to know corresponding, therefore terminates whole flow process.
S804:The action type in operational order is judged for write operation, read operation or erasing operation, if writing behaviour
Make, then perform S805, if read operation, then perform S817, if erasing operation, then perform S820.
S805:Now action type is write operation, judge in mechanical hard disk with the operating parameter in operation block identification,
During start page identifies and operate corresponding each page of mark of page number, corresponding operation mark is unsuccessfully identified with the presence or absence of writing
WRITEPAGE_FAIL, if it is, performing S806, presence in page mark now to be written is write and is unsuccessfully identified, if it is not, then holding
Row S807, page mark now to be written are operation success flag.
S806:Terminate flow process, and can also return to write when terminating flow process and unsuccessfully point out.
S807:Judge whether the corresponding maximum of the operation block identification is initial number of pages using page, if initial number of pages,
S808 is then performed, if being not initial number of pages, S810 is performed.
S808:Judge that the start page is identified whether as page 0, if being not page 0, perform S809, if the 0th
Page, then perform S816.
S809:Miscue of the write operation not for page 0 is returned, and terminates flow process,
S810:Judging, the start page identifies whether page to be used less than maximum, if it is, S811 is performed, if it is not, then
Perform S812.
S811:Return backward write error to point out and terminate flow process.
S812:Judge that the start page identifies whether to use page equal to maximum, if it is, perform S813 if it is not, then
Perform S814.
S813:Then return covering write error to point out and terminate flow process.
S814:Judge that the start page identifies whether the sum for adding using page more than maximum, if it is, S815 is performed,
If it is not, then performing S816.
S815:Return skip write miscue and terminate flow process.
S816:Will be with operating sheet choosing mark, operation block identification, start page mark and operation page number pair in mechanical hard disk
The corresponding data storage of the page mark answered is said write data, and mechanical hard disk by with operational order in operating sheet
Maximum corresponding to the corresponding operation block identification of choosing mark is stored as selecting the corresponding operating block of mark with the operating sheet using page
The number of the page mark of data is not write in the corresponding all of page mark of mark, and according to operating sheet choosing mark, operation
Block identification, start page mark and operation page number are by the OOB information write file vnand.spare in operating parameter.Terminate
Flow process.
S817:Now action type is read operation, is marked with the operating sheet choosing in the operating parameter in judging mechanical hard disk
Know, operation block identification, start page identify and operate whether corresponding operation mark during corresponding each page of page number is identified deposits
Identify in reading failure, if it is, S818 is performed, if it is not, then performing S819.
S818:Terminate flow process, and reading failure prompting when terminating flow process, can also be returned.
S819:Identify with operating sheet choosing mark, operation block identification, start page in reading mechanical hard disk and operate page number pair
The data corresponding to each page of mark answered, and mark, operating block mark are selected with operating sheet in then reading file vnand.spare
Know, start page identifies and operate the corresponding OOB information of page number.Terminate flow process.
Wherein, identifying, operate block identification, rise with the operating sheet choosing in the operating parameter in read operation and write operation
Beginning page identifies and operates corresponding each page of page number and identifies, when the plane type identifications in operating parameter are single-layer identification,
Refer to corresponding to operation block identification corresponding with operating sheet choosing mark, page and be designated [pageid, pageid+
Pagenum-1] each interval page identifies.When the plane type identifications in operating parameter are identified for bilayer, refer to and institute
State the corresponding page of the corresponding operation block identification of operating sheet choosing mark and be designated [pageid, pageid+pagenum/2-1] interval
Each page is identified, and the corresponding page of block identification of operation block identification+1 corresponding with operating sheet choosing mark is designated
Each [pageid, pageid+pagenum/2-1] interval page is identified.Wherein, pageid is identified for the start page,
Pagenum is the operation page number.Also, the operating sheet choosing in read operation and write operation in the operating parameter of indication
Mark, operation block identification, start page are identified and operate the corresponding relation of page number and the OOB information corresponding to which, with this section of institute
In the operating parameter stated operating sheet choosing mark, operation block identification, start page mark and operate page number and its corresponding to
Page mark corresponding relation it is identical, therefore repeat no more.
Preferably, can be with by the way of cache in the above-mentioned process for writing data or reading data.
S820:Now action type is erasing operation, judges plane types for single-layer identification or double-deck mark, if
Single-layer identification, then perform S821, if double-deck mark, then performs S825.
S821:Now plane type identifications are single-layer identification, are selected with the operating sheet in operational order in judging mechanical hard disk
The page of the corresponding pageid0 of the corresponding operation block identification of mark identifies whether corresponding operation mark is that erasing is unsuccessfully identified
ERASEPAGE_FAIL, if it is, S822 is performed, if it is not, then performing S823.
S822:Terminate flow process, and erasing when terminating flow process, can also be returned unsuccessfully to point out.
S823:By in mechanical hard disk, the operating sheet choosing mark it is corresponding it is described operation block identification it is corresponding all pages mark
It is primary data 0xff to know corresponding data storage, and by it is storing in mechanical hard disk, and the operational order in behaviour
Make the corresponding erasing times of block identification and add one, judge the corresponding operation block identification pair of operating sheet choosing mark in the operational order
Whether the erasing times answered reach maximum erasing times, if reached, perform S824.
S824:The corresponding status indicator of the corresponding block identification of operating sheet choosing mark in mechanical hard disk is stored as into bad block identification
BLK_BADFLAG。
S825:Now plane type identifications are double-deck mark, select with the operating sheet in operational order in judging mechanical hard disk
The page of the corresponding pageid0 of the corresponding operation block identification of mark identifies corresponding operation mark and the corresponding behaviour of operating sheet choosing mark
Make the corresponding operation mark of page mark that+1 corresponding pageid of block identification is 0 ERASEPAGE_ is unsuccessfully identified with the presence or absence of erasing
FAIL, if it is, S822 is performed, if it is not, then performing S826.
S826:The choosing mark of operating sheet described in mechanical hard disk corresponding, operation block identification, and the operation block identification are added
Data storage corresponding to the one corresponding all pages of marks of block identification is primary data 0xff and will store in mechanical hard disk
, erasing times corresponding with the operation block identification in the operational order add one, and will the operation block identification block mark that adds one
Know corresponding erasing times and add one.
S827:Judge whether the corresponding erasing times of operation block identification in the operational order reach maximum erasing time
The corresponding status indicator of the corresponding block identification of operating sheet choosing mark in mechanical hard disk, if reached, is stored as bad block mark by number
Know BLK_BADFLAG, and judge that the corresponding erasing times of block identification that block identification adds that operate in the operational order are
It is no to reach maximum erasing times, if reached, the corresponding operation block identification of operating sheet choosing mark in mechanical hard disk is added one
The corresponding status indicator of block identification is stored as bad block identification BLK_BADFLAG.
Fig. 9 is referred to, present invention also offers testing the specific embodiment of the system of NFTL, the system includes that control is single
Unit 901 and mechanical hard disk 902.
Can be with installation and debugging instrument, such as VC etc., to realize finding in convenient trace debug test in the system
Software defect, so can the convenient software defect that finds in trace debug test.Control unit can for ARM, MCU,
The module with control function such as FPGA.
Described control unit is for arranging the number of block, each block according to the model of the target nand flash memory of test NFTL
The maximum erasing times of block identification and block, and the corresponding status indicator of the block identification of each block is stored in mechanical hard disk be
Initial marking, the corresponding erasing times of block identification for storing each block are initial number of times, and monitor whether to receive NFTL's
Operational order;Wherein, there is action type and operating parameter in the operational order, at least there is in the operating parameter operation
Block identification.
If described control unit receives the operational order of NFTL, during described control unit judges the operational order
Whether the corresponding status indicator of operation block identification is bad block identification, if it is, return operation bad block and pointing out and quitting work;Such as
It is really no, then corresponding operation is performed according to the action type and operating parameter in the operational order to mechanical hard disk, and sentenced
Whether the action type broken in the operational order is erasing instruction, if erasing instruction, then by mechanical hard disk with it is described
The corresponding erasing times of operation block identification in operational order add one.
Wherein, described control unit is additionally operable to reach most when the corresponding erasing times of arbitrary block identification of mechanical hard disk storage
During big erasing times, the corresponding status indicator of the block identification in mechanical hard disk is stored as into bad block identification.
Preferably, described control unit is additionally operable to the model of the target nand flash memory according to NFTL and arranges each block identification pair
The page mark answered, and the page of each page identify corresponding read operation and be designated reading failure mark or read success flag, and
The page that each page is stored in mechanical hard disk identifies corresponding read operation mark;Wherein, the operating parameter also includes start page mark
Know and operate page number.
Described control unit is additionally operable in the action type and operating parameter according in the operational order to machinery
Before hard disk performs corresponding operation, judge whether the action type in the operational order is read operation, if read operation,
Then judge the corresponding reading of each page of mark corresponding with operation block identification, start page mark and operation page number in mechanical hard disk
Identify with the presence or absence of reading failure in operation mark, if it is, quitting work.
Preferably, described control unit is additionally operable to the model of the target nand flash memory according to NFTL and arranges each block identification pair
The page mark answered, and the page of each page identify corresponding write operation and be designated to write and unsuccessfully identify or write success flag, and
The page that each page is stored in mechanical hard disk identifies corresponding write operation mark;Wherein, the operating parameter also includes start page mark
Know and operate page number.
Described control unit is additionally operable in the action type and operating parameter according in the operational order to machinery
Before hard disk performs corresponding operation, judge whether the action type in the operational order is write operation, if write operation,
In then judging mechanical hard disk, each page corresponding with operation block identification, start page mark and operation page number identifies corresponding writing
Unsuccessfully identify with the presence or absence of writing in operation mark, if it is, quitting work.
Preferably, described control unit is additionally operable to the model of the target nand flash memory according to NFTL and arranges the block mark of each block
Know corresponding erasing operation and be designated erasing unsuccessfully mark or erasing success flag, and each block is stored in mechanical hard disk
The corresponding erasing operation mark of block identification.
Described control unit is additionally operable in the action type and operating parameter according in the operational order to machinery
Before hard disk performs corresponding operation, judge whether the action type in the operational order is erasing operation, if erasing
Operation, then in judging mechanical hard disk, erasing operation corresponding with the operation block identification in operational order is identified whether as erasing failure
Mark, if it is, quitting work.
Preferably, described control unit is additionally operable to the model of the target nand flash memory according to NFTL and arranges each block identification pair
The page mark answered, and store that each block identification is corresponding maximum to use page to be initial number of pages in mechanical hard disk;Wherein, it is described
Operating parameter also includes that start page is identified and operates page number.
Described control unit is additionally operable to, and after the operational order for receiving NFTL, judges the operation in the operational order
Whether type is write operation.
If write operation, then described control unit be additionally operable in the action type according in the operational order and
Before operating parameter performs corresponding operation to mechanical hard disk, judge that whether the corresponding maximum of the operation block identification using page is
Initial number of pages, if initial number of pages, then judges that the start page is identified whether as page 0, if being not page 0, returns
Write operation miscue not for page 0, and quit work;If being not initial number of pages, the start page mark is judged
Whether it is the maximum sum for adding using page, points out and quit work if it is not, then returning and writing sequence error;
If write operation, then described control unit be additionally operable in the action type according in the operational order and
When operating parameter performs corresponding operation to mechanical hard disk, will be the operation block identification in operational order corresponding most in mechanical hard disk
The number of the big page mark for being stored as in all of page mark corresponding with the operation block identification not writing data using page.
Preferably, described control unit is used to judge the start page identifies whether to add one using page for maximum and bag
Include:
Described control unit is used to judge that the start page identifies whether to use page less than maximum, if it is, returning inverse
Sequence write error simultaneously quits work, judges that the start page identifies whether to use page equal to maximum, if it is, return covering wrongly writing
Miss and quit work, and judge that the start page identifies whether the sum for adding using page more than maximum, if it is, return jumping
Write error simultaneously quits work.
It is for the system embodiment that the present invention is provided, identical with embodiment of the method, so describe fairly simple, phase
Close related description of the part referring to embodiment of the method.
The above is only the preferred embodiment of the present invention, it is noted that for the ordinary skill people of the art
For member, under the premise without departing from the principles of the invention, some improvements and modifications can also be made, these improvements and modifications also should
It is considered as protection scope of the present invention.