1. Technical Field
The present disclosure relates to an electronic device and method for initializing data storage.
2. Description of Related Art
Flash memory, such as Nand flash memory, is capable of being erased one block at a time. Generally, after manufacturing, the Nand flash memory may have some bad blocks. Before the Nand flash memory is delivered from the manufacturer, a block identifier is written to a predetermined location of each block to mark whether the block is a bad block. When the Nard flash memory is used by an OS for a first time, the block identifier of each block is read from the predetermined location of each block and is recorded to a bad-block table. The bad-block table is stored to a predetermined location of the Nand flash memory. When the Nand flash memory is used after the first time, the bad-block table is accessed to determine the bad blocks of the Nand flash memory. If another OS uses the Nand flash memory, because the other OS does not know the stored location of the bad-block table, the bad blocks of the Nand flash memory cannot be determined, thus the Nand flash memory cannot be used.
The components of the drawings are not necessarily drawn to scale, the emphasis instead being placed upon clearly illustrating the principles of the present disclosure. Moreover, in the drawings, like reference numerals designate corresponding parts throughout several views.
In this embodiment, as shown in
In this embodiment, the first operating system is set up in electronic device 1. The electronic device 1 includes a bad-block table reading module 11, a block erasing module 12, and a block identifier writing module 13. The bad-block table reading module 11 accesses the bad-block table 21 from the predetermined location of the data storage 2. The block erasing module 12 is for erasing data stored in the data storage 2. After the data storage 2 is erased, the block identifier writing module 13 obtains the block identifier of each block from the bad-block table 21 and writes the block identifier to the block marking area of each block. Thus the data storage 2 is initialized and can be accessed by other OS.
In step S302, the block erasing module 12 erases data stored in the data storage 2.
In step S303, after data stored on the data storage 2 is erased, the block identifier writing module 13 obtains the block identifier of each block from the bad-block table 21 and writes the read block identifier to a block marking area of each block.
Although, the present disclosure has been specifically described on the basis of preferred embodiments, the disclosure is not to be construed as being limited thereto. Various changes or modifications may be made to the embodiment without departing from the scope and spirit of the disclosure.
Number | Date | Country | Kind |
---|---|---|---|
201010296584.3 | Sep 2010 | CN | national |