Summary of the invention
The technical matters that the present invention will solve provides a kind of storage of bad block meter of memory and method that reads and device, can improve the reliability that storer uses.
For solving the problems of the technologies described above, embodiments of the invention provide technical scheme following:
On the one hand, a kind of memory bad block table storing method is provided, comprises:
Whether each piece of judging storer is bad piece, produces judged result;
If said judged result is: said is bad piece, then generates bad block message;
The good piece of in said storer, searching predetermined quantity is as bad block table storing blocks;
Identifier according to said bad block message and bad block table storing blocks generates bad block table;
At least a said bad block table is write in the said bad block table storing blocks.
Described memory bad block table storing method also comprises:
According to said judged result, calculate bad number of blocks;
According to the quantity of bad block table reservation storage block in the quantity of bad block table storing blocks, said bad number of blocks and the said storer, calculate the quantity of the piece that has used in the said storer;
The quantity of the piece that has used in the said storer is recorded in the said bad block table.
Before the step of the quantity of the piece that has used in the said storer of said calculating, also comprise:
According to said bad block message, confirm the quantity of bad block table reservation storage block in the said storer.
In said storer, search before the step of good piece as bad block table storing blocks of predetermined quantity, also comprise:
According to said bad block message, confirm the backup quantity of bad block table;
According to the backup quantity of said bad block table, confirm said predetermined quantity;
The step that said identifier according to said bad block message and bad block table storing blocks generates bad block table is specially:
Generate bad block table according to the identifier of said bad block message, bad block table storing blocks and the backup quantity of said bad block table.
Said the step that a at least said bad block table writes in the said bad block table storing blocks is specially:
The a said bad block table of storage in said bad block table storing blocks;
According to the backup quantity of said bad block table, the said bad block table of backup in said bad block table storing blocks.
Said storer is NAND flash, NOR flash or ROM.
On the other hand, a kind of memory bad block table storing device is provided, comprises:
Judge module is used to judge whether each piece of storer is bad piece, produces judged result;
Bad block message generation module is used for if said judged result is: said is bad piece, then generates bad block message;
Search module, the good piece that is used for searching predetermined quantity at said storer is as bad block table storing blocks;
The bad block table generation module is used for generating bad block table according to the identifier of said bad block message and bad block table storing blocks;
Writing module is used for a at least said bad block table is write said bad block table storing blocks.
Described memory bad block table storing device also comprises:
First computing unit is used for calculating bad number of blocks according to said judged result;
Second computing unit is used for the quantity that the quantity according to bad block table storing blocks, said bad number of blocks and said storer bad block table are reserved storage block, calculates the quantity of the piece that has used in the said storer;
Record cell, the quantity of the piece that is used for said storer has been used is recorded in the said bad block table.
On the other hand, a kind of read method of bad block meter of memory is provided, comprises:
According to the identifier of bad block table storing blocks, from storer, search bad block table storing blocks;
From the said bad block table storing blocks that finds, read bad block table.
On the other hand, a kind of reading device of bad block meter of memory is provided, comprises:
Search module, be used for identifier, from storer, search bad block table storing blocks according to the storer bad block table storing blocks;
Read module is used for reading bad block table from the said bad block table storing blocks that finds.
Embodiments of the invention have following beneficial effect:
In the such scheme, judge whether each piece of storer is bad piece, produce judged result; If said judged result is: said is bad piece, then generates bad block message; The good piece of in said storer, searching predetermined quantity is as bad block table storing blocks; Identifier according to said bad block message and bad block table storing blocks generates bad block table; At least a said bad block table is write in the said bad block table storing blocks.Like this, the position of piece of storage bad block table is no longer fixing, has guaranteed bad block table storing on good piece, and when using storer, therefore the correctness of the bad block meter of memory data that guaranteed to read, has improved and make memory-aided reliability.
Embodiment
For technical matters, technical scheme and advantage that embodiments of the invention will be solved is clearer, will combine accompanying drawing and specific embodiment to be described in detail below.
Embodiments of the invention provide a kind of memory bad block table storing and the method and the device that read to the low problem of storer dependability in the prior art.
As shown in Figure 1, the process flow diagram for memory bad block table storing method one embodiment of the present invention comprises:
101, judge whether each piece of storer is bad piece, produce judged result;
In this step, can be for successively from front to back or from back to front, each piece of swept memory judges whether each piece has been piece.
102, if said judged result is: said is bad piece, then generates bad block message;
In this step, after whole storer is accomplished in scanning, generate bad block message.
103, the good piece of in said storer, searching predetermined quantity is as bad block table storing blocks;
In this step, can search piece as bad block table storing blocks according to judged result.
104, according to the identifier generation bad block table of said bad block message and bad block table storing blocks;
105, a at least said bad block table is write in the said bad block table storing blocks.
In the said method, can be directed against the processing that new storer or firm formative storer are created bad block table.The good piece of in said storer, searching predetermined quantity is as bad block table storing blocks; Like this, the position of piece of storage bad block table is no longer fixing, has guaranteed bad block table storing on good piece, and when using storer, therefore the correctness of the bad block meter of memory data that guaranteed to read, has improved and make memory-aided reliability.
As shown in Figure 2, the process flow diagram for another embodiment of memory bad block table storing method of the present invention comprises:
201, judge whether each piece of storer is bad piece, produce judged result;
In this step, can be for successively from front to back or from back to front, each piece of swept memory judges whether each piece has been piece.
202, if said judged result is: said is bad piece, then generates bad block message;
In this step, after whole storer is accomplished in scanning, generate bad block message.
203, according to said bad block message, confirm the backup quantity of bad block table;
The backup of bad block table is used for piece when a bad block table of storage when breaking down, and can from other back up the piece of bad block table, obtain bad block table, and the information of bad block table can not lost, and has improved to make memory-aided reliability.The backup quantity of bad block table is many more, and the reliability of storer is high more.In addition, the backup quantity of bad block table is not fixed, and can confirm according to the bad block message of storer; When the bad piece of storer is many; The mass ratio that memory chip is described is relatively poor, for the piece that prevents to store a bad block table breaks down, the backup quantity of more bad block table can be set; When the bad piece of storer is fewer, explain that the mass ratio of memory chip is better, the backup quantity of less bad block table can be set.The backup quantity of bad block table is set according to the chip quality of storer like this, flexibly.
204, according to the backup quantity of said bad block table, confirm predetermined quantity;
Wherein, the predetermined quantity of bad block table storing blocks can be unfixed, can confirm according to the bad block message of storer, when the bad piece of storer is many, the number of more bad block table storing blocks can be set; When the bad piece of storer is fewer, the number of less bad block table storing blocks can be set.The quantity of bad block table storing blocks is set according to the chip quality of storer like this, flexibly.
205, the good piece of in said storer, searching predetermined quantity is as bad block table storing blocks;
Can find out by top step, not fix, can be provided with flexibly as required as the predetermined quantity of the good piece of bad block table storing blocks.According to judged result, searched piece as bad block table storing blocks.
206, generate bad block table according to the identifier of said bad block message, bad block table storing blocks and the backup quantity of said bad block table.
Wherein, bad block message is used for the bad piece situation of instruction memory.The identifier of bad block table storing blocks is used to indicate this piece for preserving the piece of bad block table, in follow-up, finds the preservation bad block table storing blocks according to the identifier of bad block table storing blocks.The backup quantity of said bad block table is used to indicate the backup quantity of bad block table, when the piece of preserving a bad block table breaks down, can also continue to search the piece that other preserve bad block table according to the backup quantity of bad block table.In addition, bad block table also comprises version number, is used for the bad block table of identification renewal.
207, a at least said bad block table is write in the said bad block table storing blocks.
Wherein, this step is specially:
2071, a said bad block table of storage in said bad block table storing blocks;
2072, according to the backup quantity of said bad block table, the said bad block table of backup in said bad block table storing blocks.
Wherein, bad block table can be recorded in first page of reserved area (spare area) of piece, if some storer, for example the reserved area of NAND flash is too small, can be recorded in the 2nd, 3 page reserved area.
208, according to said judged result, calculate bad number of blocks;
In this step, calculate the quantity of all the bad pieces in the storer.
209, according to said bad block message, confirm the quantity of said bad block table reservation storage block.
It is to be used for that bad block table is reserved storage block, and when the piece of preserving bad block table broke down, bad block table was reserved storage block and preserved bad block table as bad block table storing blocks, like this, makes on the piece that bad block table is kept at all the time.Wherein, the quantity that bad block table is reserved storage block can be unfixed, can confirm according to the bad block message of storer, when the bad piece of storer is many, the number that more bad block table is reserved storage block can be set; When the bad piece of storer is fewer, the number that less bad block table is reserved storage block can be set.Like this, the chip quality according to storer is provided with the quantity that bad block table is reserved storage block flexibly.
210, according to the quantity of bad block table reservation storage block in the quantity of bad block table storing blocks, said bad number of blocks and the said storer, calculate the quantity of the piece that has used in the said storer;
The quantity of the piece that has used comprise storer bad number of blocks, preserve bad block table and the quantity of the piece that uses and be the summation of the quantity of preserving the bad block table reserved block, total the piece number of storer deducts the quantity that the quantity of the piece that has used is exactly the remaining block available of storer.
211, the quantity of the piece that has used in the said storer is recorded in the said bad block table.
Said storer can be NAND flash, NOR flash or ROM (ROM (read-only memory)) etc.ROM can be EEPROM (electricallyerasable ROM (EEROM)).
In the foregoing description; The fixing preservation position of bad block table not; The also fixing preservation umber of bad block table not; And be not fixed for preserving the quantity of the reserved block of bad block table yet,, still can read the data of storer reliably even under the environment of more abominable storer slice, thin piece (for example all there is a sheet of continuous bad piece the front and back of storer).Do not store bad block table owing to there is to use fixing piece number; So even a lot of pieces in back have all been gone bad; The meeting of the piece of record bad block table pushes away forward automatically; Though make that like this free space of whole storer is few, can guarantee that bad block table has been recorded on the piece, can not make mistakes when making read-write memory.
As shown in Figure 3, the present invention provides a kind of memory bad block table storing device 3, comprising:
Judge module 31 is used to judge whether each piece of storer is bad piece, produces judged result;
Bad block message generation module 32 is used for if said judged result is: said is bad piece, then generates bad block message;
Search module 33, the good piece that is used for searching predetermined quantity at said storer is as bad block table storing blocks;
Bad block table generation module 34 is used for generating bad block table according to the identifier of said bad block message and bad block table storing blocks;
Writing module 35 is used for a at least said bad block table is write said bad block table storing blocks.
Said storer can be NAND flash, NOR flash or ROM (ROM (read-only memory)) etc.ROM can be EEPROM (electricallyerasable ROM (EEROM)).
In the such scheme, can be directed against the processing that new storer or firm formative storer are created bad block table.The good piece of in said storer, searching predetermined quantity is as bad block table storing blocks; Like this, the position of piece of storage bad block table is no longer fixing, has guaranteed bad block table storing on good piece, and when using storer, therefore the correctness of the bad block meter of memory data that guaranteed to read, has improved and make memory-aided reliability.
As shown in Figure 4, the present invention also provides a kind of memory bad block table storing device 3, comprising:
Judge module 31 is used to judge whether each piece of storer is bad piece, produces judged result;
Bad block message generation module 32 is used for if said judged result is: said is bad piece, then generates bad block message;
Search module 33, the good piece that is used for searching predetermined quantity at said storer is as bad block table storing blocks;
Bad block table generation module 34 is used for generating bad block table according to the identifier of said bad block message and bad block table storing blocks;
Writing module 35 is used for a at least said bad block table is write said bad block table storing blocks.
First computing unit 36 is used for calculating bad number of blocks according to said judged result;
Second computing unit 37 is used for the quantity that the quantity according to bad block table storing blocks, said bad number of blocks and said storer bad block table are reserved storage block, calculates the quantity of the piece that has used in the said storer;
Record cell 38, the quantity of the piece that is used for said storer has been used is recorded in the said bad block table.
In the such scheme; The quantity of the piece that has used comprise storer bad number of blocks, preserve bad block table and the quantity of the piece that uses and be the summation of the quantity of preserving the bad block table reserved block, total the piece number of storer deducts the quantity that the quantity of the piece that has used is exactly the remaining block available of storer.In the subsequent treatment, can know the quantity of the block available that storer is remaining according to the quantity of the piece that has used of storer.
As shown in Figure 5, the present invention provides a kind of read method of bad block meter of memory, comprising:
501, according to the identifier of bad block table storing blocks, from storer, search bad block table storing blocks;
In this step, during each system start-up, (also can the invention is not restricted to this in the past backward) from behind forward, find the piece of preserving bad block table according to the identifier of bad block table storing blocks.
502, from the said bad block table storing blocks that finds, read bad block table.
Said bad block table can comprise: the quantity of the piece that has used in the identifier of said bad block message, bad block table storing blocks, the storer.
In this step, from bad block table, read the quantity of the piece that has used in the storer, in the subsequent treatment, can calculate block available number remaining in the storer according to the quantity of the piece that has used.
Said storer can be NAND flash, NOR flash or ROM (ROM (read-only memory)) etc.ROM can be EEPROM (electricallyerasable ROM (EEROM))
In the such scheme, when searching bad block meter of memory, be not fixed in and search top several or rearmost several of storer, but the piece in the storer is searched successively, till finding bad block table storing blocks.
As shown in Figure 6, the present invention provides a kind of reading device 6 of bad block meter of memory, comprising:
Search module 61, be used for identifier, from storer, search bad block table storing blocks according to bad block table storing blocks;
Read module 62 is used for reading bad block table from the said bad block table storing blocks that finds.
Said bad block table comprises: the quantity of the piece that has used in the identifier of said bad block message, bad block table storing blocks, the storer.In this scheme, from bad block table, read the quantity of the piece that has used in the storer, the quantity according to the piece that has used in the subsequent treatment can calculate remaining block available number.
In the such scheme, when searching bad block meter of memory, be not fixed in and search top several or rearmost several of storer, but the piece in the storer is searched successively, till finding bad block table storing blocks.
As shown in Figure 7, be the schematic flow sheet of storer in the system (is example with Nand flash) bad block table storing with the application scenarios that obtains, comprising:
701, elder generation's allocation space in internal memory is as the buffer zone of preserving bad block table information.
702, swept memory piece (the invention is not restricted to this, also swept memory piece) from front to back from back to front.
703, according to the identifier whether bad block table storing blocks is arranged, judge whether this piece is bad block table storing blocks.If then execution in step 704; If not, then execution in step 707.
704, find bad block table record block after, read the bad block table in the bad block table record block, and the buffer zone of the bad block table information of distributing before the data of the bad block table in this piece are covered.
705, from bad block table, read the piece number that has used.
706, memory-aided total block data deducts the piece number that has used, calculates the block available number of storer, and the block available number of this storer is passed to system.
707, call the fine or not state of judging this piece that drives.
708, judged result is recorded in the buffer zone of bad block table information.
709, judge whether to scan first, if for being that then execution in step 710; If, then return step 702, next piece is continued scanning for not.
710; If find first; Be much to seek bad piece record block, show that this is new storer or firm formative storer, according to the buffer zone of bad block table information from after search several good pieces forward and (the invention is not restricted to this; Also can search backward in the past), before be recorded in the buffer zone of bad block table information information write on these several good pieces of storer.
711, calculate the piece number that has used in the storer, write on these several good pieces of storer.
712, memory-aided total block data deducts the piece number that has used, obtains the block available number of storer, and the system that passes to uses with the block available number of this storer.
One of ordinary skill in the art will appreciate that all or part of step that realizes in the foregoing description method is to instruct relevant hardware to accomplish through program; Described program can be stored in the read/write memory medium of a portable terminal; This program is when carrying out; Comprise step, described storage medium etc. like above-mentioned method embodiment.
The above is a preferred implementation of the present invention; Should be pointed out that for those skilled in the art, under the prerequisite that does not break away from principle according to the invention; Can also make some improvement and retouching, these improvement and retouching also should be regarded as protection scope of the present invention.