1. Field of the Invention
The present invention generally relates to a data writing method, in particular, to a data writing method for a non-volatile memory and a controller using the same.
2. Description of Related Art
Along with the widespread of digital cameras, camera phones, and MP3 in recently years, the consumers' demand to storage media has increased drastically too. Flash memory is one of the most adaptable memories for such battery-powered portable products due to its characteristics such as data non-volatility, low power consumption, small volume, and non-mechanical structure. Besides being applied in foregoing portable products, flash memory is also broadly applied to external products such as flash cards and flash drives, and an even larger market is provided since one can have more than one flash card and flash drive. Thereby, flash memory has become one of the most focused electronic products in recent years.
FIGS. 1A˜1D are detailed block diagrams illustrating a conventional non-volatile memory 100 and the operation thereof.
Referring to FIG. 1A, in the present example, in order to program (i.e. write or erase) the non-volatile memory 100 efficiently, blocks in the non-volatile memory 100 are logically grouped into a system area 102, a data area 104, and a spare area 106. Generally speaking, more than 90% of the blocks in the non-volatile memory 100 belong to the data area 104.
Blocks in the system area 102 are used for storing system data, such as the number of zones in the non-volatile memory 100, the number of blocks in each zone, the number of pages in each block, and a logical-physical mapping table etc.
Blocks in the data area 104 are used for storing user data. Generally speaking, these blocks are corresponding to the logical block addresses (LBAs) operated by a host (not shown).
Blocks in the spare area 106 are used for substituting blocks in the data area 104. Thus, the blocks in the spare area 106 are empty blocks, namely, no data is recorded in these blocks or data recorded in these blocks has been marked as invalid data. To be specific, an erase operation has to be performed before writing data into a position in which data has been recorded before. However, data is written into a flash memory in unit of pages while erased from the same in unit of blocks. Since an erase unit is larger than a write unit, those valid pages in a block have to be copied to another block before data is erased from this block. Accordingly, to write new data into a block M in the data area 104, a block S is first selected from the spare area 106. The valid data previously stored in the block M is copied to the block S, and the new data is also written into the block S. After that, the block M is erased and linked to the spare area 106, and meanwhile, the block S is linked to the data area 104 (as shown in FIG. 1A).
Generally, in order to use the non-volatile memory 100 more efficiently, blocks in the non-volatile memory 100 are further logically grouped into a substitute block 108 and a temporary block 110.
Referring to FIG. 1B, the substitute block 108 is used for substituting a block to be written in the data area 104. To be specific, when a block (for example, a block C) is selected from the spare area 106 for substituting a block (for example, the block M) in the data area 104, the new data is written into the block C, but the valid data in the block M is not copied to the block C instantly in order to erase the block M. This is because the valid data in the block M may become invalid in the next operation, so that moving the valid data in the block M instantly to the block C may become meaningless. Thus, in the present example, the block C containing the new data is temporarily linked as a substitute block, and the fact that multiple physical block addresses (PBAs) are mapped to one LBA is recorded. Namely, the combination of contents in the block M and the block C is the content of the corresponding logical block. As described above, the blocks in the non-volatile memory can be used more efficiently. Thereafter, two methods are usually used for combining the contents of the block M and the block C. According to the first method, the valid data in the block M is first copied to the block C, and then the block M is erased and linked to the spare area 106 and the block C is linked to the data area 104 (as shown in FIG. 1B). According to the other method, a blank block S is first selected from the spare area 106, and the valid data in both block M and block C are copied into the block S. After that, the block M and the block C are both erased and linked to the spare area 106, and the block S is linked to the data area 104 (as shown in FIG. 1C).
The function of the temporary block 110 is similar to that of the substitute block 108. When the non-volatile memory is a multi level cell (MLC) NAND flash memory, each page in the MLC NAND flash memory contains four sectors, namely, each page has four sectors of 512 bytes, which is 2048 bytes in total. As described above, data is written into a flash memory in unit of pages. Accordingly, four sectors have to be programmed each time when data is written into the MLC NAND flash memory, so that the memory space may be wasted when the data to be written is less than one page. The temporary block 110 is used for temporarily storing such data of small quantity. To be specific, if the data to be written into the substitute block 108 (for example, a block C) is less than one page, a block T is selected from the spare area 106 and the data is written into the block T. The block T is then linked to the temporary block 110. When subsequently the data to be written into the memory is enough for one page, the data is then written into the block C, and the block T is erased and linked to the spare area 106 (as shown in FIG. 1D).
Due to the physical characteristics of a flash memory, a block in the flash memory has to be erased every time before new data is written into the block. However, the block may still contain some valid data so that the valid data has to be moved away (or copied) before the block is erased. Accordingly, along with the development of flash memory and the increase in the storage capacity of each block, the data to be moved is getting more and more, and which may reduce the performance of the entire system.
Additionally, due to the physical characteristics of MLC NAND flash memory, charges in some pages of a MLC NAND flash memory are not very stable and which may even affect adjacent pages. Thus, even though the MLC NAND flash memory offers high storage capacity, the reliability thereof is not satisfactory.
To resolve foregoing programs, a data writing method which can improve the access efficiency and data reliability of a flash memory is needed.
USPTO Backgrounds
USPTO Backgrounds