Abstract:
The present invention provides a method for accessing a flash memory, where a block of the flash memory includes pages whose quantity is (2 N +M), N and M are positive integers. The method includes: writing a data stream into 1 st -(2 N ) th  pages, and backing up data of a portion of the 1 st -(2 N ) th  pages into (2 N +1) th -(2 N +M) th  pages.

Description:
CROSS REFERENCE TO RELATED APPLICATIONS  
       [0001]    This application claims the benefit of U.S. provisional application No. 61/660,825, filed on Jun. 18, 2012 and incorporated herein by reference. 
     
    
     BACKGROUND OF THE INVENTION 
       [0002]    1. Field of the Invention 
         [0003]    The disclosed embodiments of the present invention relate to a method for accessing a flash memory, and more particularly, to a method for backing up a portion of data stored in the flash memory and related memory device. 
         [0004]    2. Description of the Prior Art 
         [0005]    In some of flash memory designs, especially Triple-Level Cell (TLC) flash memories, the number of pages in each of blocks does not exactly equal power of two. However, a block usually exploits 2 N  pages for data access in respect of the design and access speed of the flash memory controller. For instance, supposing a block possesses 258 pages, only the first 256 (2 8 ) pages are actually utilized for storing data, and the last two pages are left unused. That is to say, capacity of the last two pages is wasted. 
       SUMMARY OF THE INVENTION 
       [0006]    Therefore, one of the objectives of the present invention is to provide a method for accessing a flash memory, so as to exploit the originally unused pages for backing up data. Therefore, the issue of page wasting in the prior art can be solved. 
         [0007]    According to an embodiment of the present invention, a method for accessing a flash memory is disclosed, wherein a block of the flash memory includes (2 N +M) pages, and both of N and M are positive integers. The method comprises: writing a data stream into 1 st -(2 N ) th  pages; and backing up data of a portion of the 1 st -(2 N ) to pages into (2 N +1) th -(2 N +M) th  pages. 
         [0008]    According to another embodiment of the present invention, a memory device is disclosed. The memory device includes a flash memory and a controller. The flash memory includes a plurality of blocks, and each of the blocks including (2 N +M) pages, wherein both of N and M are positive integers. The controller is arranged for writing a data stream into 1 st -(2 N ) th  pages, and backing up data of a portion of the 1 st -(2 N ) th  pages into (2 N +1) th -(2 N +M) th  pages. 
         [0009]    According to yet another embodiment of the present invention, a method for accessing a flash memory is disclosed, wherein a block of the flash memory includes (2 N +M) pages, and (2 N +1) th -(2 N +M) th  pages are arranged for backing up data of a portion of 1 st -(2 N ) th  pages, and both of N and M are positive integers. The method comprises: reading data of at least one page from the portion of the pages into 1 st -(2 N ) th  pages; and selectively reading pages arranged for backing up the at least one page from the (2 N +1) th -(2 N +M) th  pages to act as data of at least one page. 
         [0010]    According to still yet another embodiment of the present invention, a memory device is disclosed. The memory device includes a flash memory and a controller. The flash memory includes a plurality of blocks, and each of the blocks including (2 N +M) pages, and (2 N +1) th -(2 N +M) th  pages are arranged for backing up data of a portion of 1 st -(2 N ) th  pages, and both of N and M are positive integers. The controller is arranged for selectively reading pages arranged for backing up the at least one page from the (2 N +1) th -(2 N +M) th  pages to act as data of at least one page. 
         [0011]    These and other objectives of the present invention will no doubt become obvious to those of ordinary skill in the art after reading the following detailed description of the preferred embodiment that is illustrated in the various figures and drawings. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0012]      FIG. 1  is a diagram illustrating a memory device according to an embodiment of the present invention. 
           [0013]      FIG. 2  is a diagram illustrating a block in a flash memory according to an embodiment of the present invention. 
           [0014]      FIG. 3  is a flowchart illustrating a method of writing data into a flash memory according to an embodiment of the present invention. 
           [0015]      FIG. 4  is a diagram illustrating backing up data in the block. 
           [0016]      FIG. 5  is a flowchart illustrating a method of reading data from a flash memory according to an embodiment of the present invention. 
       
    
    
     DETAILED DESCRIPTION 
       [0017]    Certain terms are used throughout the description and following claims to refer to particular components. As one skilled in the art will appreciate, manufacturers may refer to a component by different names. This document does not intend to distinguish between components that differ in name but not function. In the following description and in the claims, the terms “include” and “comprise” are used in an open-ended fashion, and thus should be interpreted to mean “include, but not limited to . . . ”. Also, the term “couple” is intended to mean either an indirect or direct electrical connection. Accordingly, if one device is electrically connected to another device, that connection may be through a direct electrical connection, or through an indirect electrical connection via other devices and connections. 
         [0018]    Please refer to  FIG. 1 , which is a diagram illustrating a memory device  100  according to an embodiment of the present invention. The memory device  100  in this embodiment is a portable memory device (e.g., a memory card complying with SD/MMC, CF, MS or XD standard). The memory device  100  includes a flash memory  120  and a controller, wherein the controller may be a memory controller  110 , and is arranged for accessing the flash memory  120 . According to this embodiment, the memory controller  110  includes a micro processor  112 , a read only memory (ROM)  112 M, a control logic  114 , a buffer memory  116  and an interface logic  118 . The ROM  112 M is arranged for storing a program code  112 C, and the micro processor  112  is arranged for executing the program code  112 C to control access of the flash memory  120 . 
         [0019]    In a typical case, the flash memory  120  includes a plurality of blocks, and the controller (e.g., the memory controller  110 , which executes the program code  112 C through the micro processor  112 ) performs block-based copying process, erasing process, merging process, etc. upon the flash memory  120 . Further, a specific number of pages can be recorded in a block, where the controller (e.g., the memory controller  110 , which executes the program code  112 C through the micro processor  112 ) performs page-based data writing process upon the flash memory  120 . 
         [0020]    In practice, the memory controller  110 , which executes the program code  112 C through the micro processor  112 , may utilize built-in components to carry out a lot of control operations. For instance, the control logic  114  is utilized to control the access of the flash memory  120  (more particularly, the access of at least one block or at least one page), the buffer memory  116  is utilized to carry out the desired buffer process, and the interface logic  118  is utilized to communicate with a host device. 
         [0021]    Please refer to  FIG. 2 , which is a diagram illustrating a block  200  in a flash memory  120  according to an embodiment of the present invention. As shown in  FIG. 2 , the block  200  is a TLC. That is to say, each of the storage units (i.e. each of the transistors) has storage capacity of three bits. The block  200  possesses 86 word line WL0-WL85, where each word line constitutes three pages. Hence, the block  200  has total 258 pages P0-P257. In the following paragraphs, the block size shown in  FIG. 2  is employed for illustrating features of the present invention. However, this is for illustrative purposes only, and is not meant to be a limitation of the present invention. In other embodiments of the present invention, the block  200  may have a different number of pages. 
         [0022]    Please refer to  FIG. 3  and  FIG. 4  in conjunction with  FIG. 1 .  FIG. 3  is a flowchart illustrating a method of writing data into a flash memory according to an embodiment of the present invention.  FIG. 4  is a diagram illustrating backing up data in the block  200 . The flow in  FIG. 3  is described as follows. 
         [0023]    In step  300 , the flow starts. Next, in step  302 , the memory controller  110  writes a data stream into pages P0-P255 of block  200 , sequentially. After writing the data stream into the pages P0-P255, the flow enters step  304 . In step  304 , the memory controller  110  backs up data stored in two of the pages P0-P255 into pages P256 and P257. 
         [0024]    Specifically, in step  304 , the memory controller  110  can determine data in which two pages should be backed up into the pages P256 and P257 according to predefined location information. The predefined location information may bb determined by a designer according to the quality of the flash memory  120  or other testing data. That is to say, the predefined location information can be utilized to indicate which two pages in the pages P0-P255 have poor storage quality. In an embodiment of the present invention, because the block  200  is a TLC, each of the word lines WL0-WL85 of the block  200  includes a Most Significant Bit Page (MSB page), a Central Significant Bit Page (CSB page) and a Least Significant Bit Page (LSB page). In addition, since the MSB pages usually have higher error rate, the memory controller  110  may back up data corresponding to MSB pages of two word lines into the pages 256 and 257, or backing up data corresponding to CSB pages of two word lines into the pages 256 and 257, or backing up data corresponding to a CSB page and an LSB page of one or two word lines into the pages 256 and 257. 
         [0025]    Furthermore, with respect to backing up data of two pages in the pages P0-P255 into the pages P256 and P257, please refer to  FIG. 4 . Suppose data of the page P3 needs to be backed up into the page P256. The memory controller  110  may copy the data of the page P3 to the page buffer  410  in accordance with a copy-back command, and then copy the data in the page buffer  410  to the page P256. Next, it is followed by backing up data of another page into the page P257 in the same manner. Besides, in another embodiment of the present invention, the memory controller  110  may also copy the data of the page P3 to the page buffer  410  in accordance with a normal read/write command, transfer the copied data to the buffer in the memory controller  110 , and then write the buffered data from the memory controller  110  into the page P256. 
         [0026]    In summary, since the pages P256 and P257 in the block  200  may be utilized for data back-up, the capacity of the block  200  therefore is completely exploited when compared with the prior art design. 
         [0027]    In addition, the embodiments shown in  FIG. 2-FIG .  4  are for illustrative purposes only, and are not meant to be limitations of the present invention. In other embodiments of the present invention, as long as the number of pages of a block is (2 N +M) and the memory controller  110  backs up data of a portion of the 1 st -(2 N ) th  pages into the (2 N +1) th -(2 N +M) th  pages, appropriate modifications may be made to the proposed flow in the present invention. These alternative designs all belong to the scope of the present invention. 
         [0028]    Next, please refer to  FIG. 5  in conjunction with  FIG. 1  and  FIG. 2 .  FIG. 5  is a flowchart illustrating a method of reading data from a flash memory according to an embodiment of the present invention. The flow in  FIG. 3  is followed by the descriptions below with respect to  FIG. 5 , that is to say, the flow shown in  FIG. 5  is to read data from the block  200 , where the pages P256 and P257 in the block  200  have backed up data in two pages of the pages P0-P255. The flow in  FIG. 5  is described as follows. 
         [0029]    In step  500 , the flow starts. Next, in step  502 , the memory controller  110  reads data of at least one page from the pages P0-P255 in accordance with a command, wherein the data of the at least one page is backed up in the page P256 or P257. Then, in step  504 , the memory controller  110  selectively reads the pages P256 and P257 according to condition of reading the at least one page, so as to use the read data as the data of the at least one page. 
         [0030]    Specifically, in step  504 , suppose that the page P256 possesses backup data of the page P3, and the memory controller  110  reads the page P3. If the memory controller  110  determines the page P3 is not able to be successfully read (i.e. the desired data is seriously damaged and the error correction code is not able to recovery it), or it takes too long to recover the data of the page P3 by error correction code and therefore exceeds a predetermined time period, the memory controller  110  may directly read the data in the page P256 to be the data of the page P3. Furthermore, if the memory controller has successfully read the data of the page P3, there is no need to read the page P256 in such a case. 
         [0031]    The present invention may be briefly summarized as follows. With respect to the method for accessing a flash memory according to the present invention, data of a portion of the 1 st -(2 N ) th  pages of a block is backed up into the (2 N +1) th -(2 N +M) th  pages. Therefore, each of pages in the block can be fully utilized. In addition, when the data of the portion of the 1 st -(2 N ) th  pages has error bits and cannot be read successfully, it is possible to recover the data by referring to the backup data in the (2 N +1) th -(2 N +M) th  pages, thus achieving faster and more accurate data access of the flash memory. 
         [0032]    Those skilled in the art will readily observe that numerous modifications and alterations of the device and method may be made while retaining the teachings of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims.