TW202213085A - Method and apparatus and computer program product for storing data in flash memory - Google Patents

Method and apparatus and computer program product for storing data in flash memory Download PDF

Info

Publication number
TW202213085A
TW202213085A TW109133806A TW109133806A TW202213085A TW 202213085 A TW202213085 A TW 202213085A TW 109133806 A TW109133806 A TW 109133806A TW 109133806 A TW109133806 A TW 109133806A TW 202213085 A TW202213085 A TW 202213085A
Authority
TW
Taiwan
Prior art keywords
data
area
flash memory
block
physical
Prior art date
Application number
TW109133806A
Other languages
Chinese (zh)
Other versions
TWI754396B (en
Inventor
柯冠宇
Original Assignee
慧榮科技股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 慧榮科技股份有限公司 filed Critical 慧榮科技股份有限公司
Priority to TW109133806A priority Critical patent/TWI754396B/en
Application granted granted Critical
Publication of TWI754396B publication Critical patent/TWI754396B/en
Publication of TW202213085A publication Critical patent/TW202213085A/en

Links

Images

Landscapes

  • Techniques For Improving Reliability Of Storages (AREA)
  • Read Only Memory (AREA)

Abstract

The invention relates to a method, an apparatus and a computer program product for storing data in a flash memory. The method is performed by a processing unit when loading and executing program code of a flash translation layer to include: dividing storage space of a flash module into a first region and a second region; writing data belonging to a first partition type received from a host side into first physical blocks of the first region only; and writing data belonging to a second partition type received from the host side into the first physical blocks of the first region and the second physical blocks of the second region. With the region division and the policy for writing data into the regions in terms of data characteristics of different partition types, storage space of the flash module would be used more efficient.

Description

快閃記憶體的資料儲存方法及裝置以及電腦程式產品Data storage method and device of flash memory and computer program product

本發明涉及儲存裝置,尤指一種快閃記憶體的資料儲存方法、裝置以及電腦程式產品。The present invention relates to a storage device, in particular to a data storage method, device and computer program product of a flash memory.

閃存通常分為NOR閃存與NAND閃存。NOR閃存為隨機存取裝置,中央處理器(Host)可於位址腳位上提供任何存取NOR閃存的位址,並及時地從NOR閃存的資料腳位上獲得儲存於該位址上的資料。相反地,NAND閃存並非隨機存取,而是序列存取。NAND閃存無法像NOR閃存一樣,可以存取任何隨機位址,中央處理器反而需要寫入序列的位元組(Bytes)的值到NAND閃存中,用於定義請求命令(Command)的類型(如,讀取、寫入、抹除等),以及用在此命令上的位址。位址可指向一個頁面(閃存中寫入作業的最小資料塊)或一個區塊(閃存中抹除作業的最小資料塊)。Flash memory is usually divided into NOR flash memory and NAND flash memory. NOR flash memory is a random access device. The central processing unit (Host) can provide any address for accessing NOR flash memory on the address pin, and obtain the data stored at the address from the data pin of NOR flash memory in time. material. In contrast, NAND flash memory is not random access, but sequential access. NAND flash memory cannot access any random address like NOR flash memory. Instead, the central processor needs to write the value of the sequence of bytes (Bytes) into the NAND flash memory to define the type of request command (Command) (such as , read, write, erase, etc.), and the address used on this command. The address can point to a page (the smallest block of data in flash for write operations) or a block (the smallest block of data in flash for erase operations).

有效地使用NAND閃存空間來儲存不同類型的主機資料,一直在閃存控制器中是個重要的議題。因此,本發明提出一種快閃記憶體的資料儲存方法及裝置以及電腦程式產品,適應於不同類型的主機資料。Efficient use of NAND flash space to store different types of host data has always been an important issue in flash controllers. Therefore, the present invention provides a flash memory data storage method and device and a computer program product, which are suitable for different types of host data.

有鑑於此,如何減輕或消除上述相關領域的缺失,實為有待解決的問題。In view of this, how to alleviate or eliminate the above-mentioned deficiencies in related fields is a problem to be solved.

本說明書涉及一種快閃記憶體的資料儲存方法,由處理單元載入並執行快閃記憶體翻譯層的程式碼時實施,包含:將閃存模組的儲存空間劃分為第一區和第二區;將從主機端接收的屬於第一分區類型的資料只寫入第一區中的第一實體塊;以及將從主機端接收的屬於第二分區類型的資料寫入第一區中的第一實體塊和第二區中的第二實體塊。This specification relates to a data storage method of a flash memory, which is implemented when a processing unit loads and executes the code of the translation layer of the flash memory, including: dividing the storage space of the flash memory module into a first area and a second area ; Only write the data of the first partition type received from the host to the first physical block in the first area; and write the data received from the host and belong to the second partition type into the first physical block in the first area A solid block and a second solid block in the second zone.

本說明書另涉及一種電腦程式產品,用於快閃記憶體的資料儲存,包含由處理單元載入並執行快閃記憶體翻譯層的程式碼。The present specification also relates to a computer program product for data storage in flash memory, including code loaded by a processing unit and executing a translation layer of the flash memory.

本說明書更另涉及一種快閃記憶體的資料儲存裝置,包含閃存介面、主機介面和處理單元。處理單元將閃存模組的儲存空間劃分為第一區和第二區;驅動閃存介面將通過主機介面從主機端接收的屬於第一分區類型的資料只寫入第一區中的第一實體塊;以及驅動閃存介面將通過主機介面從主機端接收的屬於第二分區類型的資料寫入第一區中的第一實體塊和第二區中的第二實體塊。The present specification further relates to a data storage device of flash memory, which includes a flash memory interface, a host interface and a processing unit. The processing unit divides the storage space of the flash memory module into a first area and a second area; the drive flash interface writes the data belonging to the first partition type received from the host through the host interface only to the first physical block in the first area and driving the flash memory interface to write the data belonging to the second partition type received from the host through the host interface into the first physical block in the first area and the second physical block in the second area.

第一區包含多個第一實體塊,第二區包含多個第二實體塊,每個第一實體塊只能使用單層式單元模式來寫入資料,每個第二實體塊能夠使用單層式單元模式或非單層式單元模式來寫入資料。單層式單元模式編程記憶單元以儲存二個狀態中的一個,非單層式單元模式編程記憶單元以儲存四個或更多狀態中的一個。The first area contains multiple first physical blocks, the second area contains multiple second physical blocks, each first physical block can only use the single-layer unit mode to write data, and each second physical block can use a single Layered cell mode or non-single-layered cell mode to write data. Single-level cell mode programs memory cells to store one of two states, and non-single-level cell mode programs memory cells to store one of four or more states.

上述實施例的優點之一,通過以上所述閃存模組的區域劃分和採用依據不同分區類型的資料特性來寫入資料的政策,可更有效地使用閃存模組的儲存空間。One of the advantages of the above embodiment is that the storage space of the flash memory module can be used more efficiently through the above-mentioned area division of the flash memory module and the policy of writing data according to the data characteristics of different partition types.

本發明的其他優點將搭配以下的說明和圖式進行更詳細的解說。Other advantages of the present invention will be explained in more detail in conjunction with the following description and drawings.

以下說明為完成發明的較佳實現方式,其目的在於描述本發明的基本精神,但並不用以限定本發明。實際的發明內容必須參考之後的權利要求範圍。The following description is a preferred implementation manner to complete the invention, and its purpose is to describe the basic spirit of the invention, but it is not intended to limit the invention. Reference must be made to the scope of the following claims for the actual inventive content.

必須了解的是,使用於本說明書中的「包含」、「包括」等詞,用以表示存在特定的技術特徵、數值、方法步驟、作業處理、元件以及/或組件,但並不排除可加上更多的技術特徵、數值、方法步驟、作業處理、元件、組件,或以上的任意組合。It must be understood that the words "comprising" and "comprising" used in this specification are used to indicate the existence of specific technical features, values, method steps, operation processes, elements and/or components, but do not exclude the possibility of adding More technical features, values, method steps, job processes, elements, components, or any combination of the above.

於權利要求中使用如「第一」、「第二」、「第三」等詞是用來修飾權利要求中的元件,並非用來表示之間具有優先順序,前置關係,或者是一個元件先於另一個元件,或者是執行方法步驟時的時間先後順序,僅用來區別具有相同名字的元件。The use of words such as "first", "second", "third", etc. in the claims is used to modify the elements in the claims, and is not used to indicate that there is a priority order, a prepositional relationship, or an element between them Prior to another element, or chronological order in which method steps are performed, is only used to distinguish elements with the same name.

必須了解的是,當元件描述為「連接」或「耦接」至另一元件時,可以是直接連結、或耦接至其他元件,可能出現中間元件。相反地,當元件描述為「直接連接」或「直接耦接」至另一元件時,其中不存在任何中間元件。使用來描述元件之間關係的其他語詞也可類似方式解讀,例如「介於」相對於「直接介於」,或者是「鄰接」相對於「直接鄰接」等等。It must be understood that when an element is described as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element, and intervening elements may be present. In contrast, when an element is described as being "directly connected" or "directly coupled" to another element, there are no intervening elements present. Other words used to describe the relationship between elements can also be interpreted in a similar fashion, such as "between" versus "directly interposed," or "adjacent" versus "directly adjoining," and the like.

參考圖1。電子裝置10包含主機端(Host Side)110、閃存控制器130及閃存模組150,並且閃存控制器130及閃存模組150可合稱為裝置端(Device Side)。電子裝置10可實施於個人電腦、筆記型電腦(Laptop PC)、平板電腦、手機、數位相機、數位攝影機等電子產品之中。主機端110與閃存控制器130的主機介面(Host Interface)137可以通用序列匯流排(Universal Serial Bus,USB)、先進技術附著(advanced technology attachment,ATA)、序列先進技術附著(serial advanced technology attachment,SATA)、快速周邊元件互聯(peripheral component interconnect express,PCI-E)、通用快閃記憶儲存(Universal Flash Storage UFS)、嵌入式多媒體卡(Embedded Multi-Media Card eMMC)等通訊協定彼此溝通。閃存控制器130的閃存介面(Flash Interface)139與閃存模組150可以雙倍資料率(Double Data Rate DDR)通訊協定彼此溝通,例如,開放NAND快閃(Open NAND Flash Interface ONFI)、雙倍資料率開關(DDR Toggle)或其他通訊協定。閃存控制器130包含處理單元134,可使用多種方式實施,如使用通用硬體(例如,單一處理器、具平行處理能力的多處理器、圖形處理器或其他具運算能力的處理器),並且在執行軟體以及/或韌體指令時,提供之後描述的功能。處理單元134通過主機介面131接收主機命令,例如讀取命令(Read Command)、寫入命令(Write Command)、抹除命令(Erase Command)等,排程並執行這些命令。閃存控制器130另包含隨機存取記憶體(Random Access Memory, RAM)136,可實施為動態隨機存取記憶體(Dynamic Random Access Memory,DRAM)、靜態隨機存取記憶體(Static Random Access Memory,SRAM)或上述兩者的結合,用於配置空間作為資料緩衝區,儲存從主機端110讀取並即將寫入閃存模組150的主機資料,以及從閃存模組150讀取並即將輸出給主機端110的主機資料。隨機存取記憶體136另可儲存執行過程中需要的資料,例如,變數、資料表、主機-閃存對照表(Host-to-Flash H2F Table)、閃存-主機對照表(Flash-to-Host F2H Table)等。閃存介面139包含NAND閃存控制器(NAND Flash Controller NFC),提供存取閃存模組150時需要的功能,例如命令序列器(Command Sequencer)、低密度奇偶校驗(Low Density Parity Check LDPC)等。Refer to Figure 1. The electronic device 10 includes a host side 110 , a flash memory controller 130 and a flash memory module 150 , and the flash memory controller 130 and the flash memory module 150 may be collectively referred to as a device side. The electronic device 10 can be implemented in electronic products such as personal computers, notebook computers (Laptop PCs), tablet computers, mobile phones, digital cameras, and digital video cameras. The host interface (Host Interface) 137 between the host terminal 110 and the flash memory controller 130 can be a Universal Serial Bus (USB), advanced technology attachment (ATA), serial advanced technology attachment (serial advanced technology attachment, SATA), peripheral component interconnect express (PCI-E), universal flash memory storage (Universal Flash Storage UFS), embedded multimedia card (Embedded Multi-Media Card eMMC) and other communication protocols communicate with each other. The flash interface (Flash Interface) 139 of the flash memory controller 130 and the flash memory module 150 can communicate with each other through a double data rate (Double Data Rate DDR) protocol, for example, Open NAND Flash Interface ONFI, double data rate rate switch (DDR Toggle) or other protocols. The flash controller 130 includes a processing unit 134, which may be implemented using a variety of means, such as using general-purpose hardware (eg, a single processor, a multiprocessor capable of parallel processing, a graphics processor, or other processor capable of computing), and When executing software and/or firmware instructions, the functions described later are provided. The processing unit 134 receives host commands through the host interface 131 , such as a read command, a write command, an erase command, and the like, and schedules and executes these commands. The flash memory controller 130 further includes a random access memory (Random Access Memory, RAM) 136, which can be implemented as a dynamic random access memory (DRAM), a static random access memory (Static Random Access Memory, SRAM) or a combination of the above two, is used to configure the space as a data buffer to store host data read from the host 110 and to be written to the flash memory module 150, and read from the flash memory module 150 and to be output to the host Host data of the terminal 110. The random access memory 136 can also store data required in the execution process, such as variables, data tables, host-to-Flash H2F Table, Flash-to-Host F2H Table), etc. The flash memory interface 139 includes a NAND flash controller (NAND Flash Controller NFC), which provides functions required for accessing the flash memory module 150, such as a command sequencer (Command Sequencer), a low density parity check (Low Density Parity Check LDPC), and the like.

閃存控制器130中可配置匯流排架構(Bus Architecture)132,用於讓元件之間彼此耦接以傳遞資料、位址、控制訊號等,這些元件包含主機介面131、處理單元134、RAM 136、直接記憶體存取(Direct Memory Access,DMA)控制器138、閃存介面139等。DMA控制器138可依據處理單元134的指令,通過匯流排架構132在元件間遷移資料,例如,將主機介面131或閃存介面139中特定資料緩存器(Data Buffer)的資料搬到RAM 136中的特定位址,將RAM 136中特定位址的資料搬到將主機介面131或閃存介面139中的特定資料緩存器等。A bus architecture 132 can be configured in the flash memory controller 130 for coupling elements to each other to transmit data, addresses, control signals, etc. These elements include a host interface 131, a processing unit 134, a RAM 136, A direct memory access (Direct Memory Access, DMA) controller 138, a flash memory interface 139, and the like. The DMA controller 138 can move data between elements through the bus structure 132 according to the instructions of the processing unit 134 , for example, move the data of a specific data buffer (Data Buffer) in the host interface 131 or the flash interface 139 to the data in the RAM 136 . For the specific address, the data of the specific address in the RAM 136 is moved to the specific data register in the host interface 131 or the flash memory interface 139, and so on.

閃存模組150提供大量的儲存空間,通常是數百個千兆位元組(Gigabytes,GB),甚至是數個兆兆位元組(Terabytes,TB),用於儲存大量的主機資料,例如高解析度圖片、影片等。閃存模組150中包含控制電路以及記憶體陣列,記憶體陣列中的記憶單元可在抹除後組態為單層式單元(Single Level Cells,SLCs)、多層式單元(Multiple Level Cells,MLCs)三層式單元(Triple Level Cells,TLCs)、四層式單元(Quad-Level Cells,QLCs)或上述的任意組合。處理單元134通過閃存介面139寫入主機資料到閃存模組150中的指定位址(目的位址),以及從閃存模組150中的指定位址(來源位址)讀取主機資料。閃存介面139使用數個電子訊號來協調閃存控制器130與閃存模組150間的資料與命令傳遞,包含資料線(Data Line)、時脈訊號(Clock Signal)與控制訊號(Control Signal)。資料線可用於傳遞命令、位址、讀出及寫入的資料;控制訊號線可用於傳遞晶片致能(Chip Enable,CE)、位址提取致能(Address Latch Enable,ALE)、命令提取致能(Command Latch Enable,CLE)、寫入致能(Write Enable,WE)等控制訊號。The flash memory module 150 provides a large amount of storage space, usually hundreds of gigabytes (Gigabytes, GB) or even several terabytes (Terabytes, TB), for storing a large amount of host data, such as High-resolution pictures, videos, etc. The flash memory module 150 includes a control circuit and a memory array. The memory cells in the memory array can be configured as single-level cells (Single Level Cells, SLCs) and multi-level cells (Multiple Level Cells, MLCs) after erasing Triple Level Cells (TLCs), Quad-Level Cells (QLCs) or any combination of the above. The processing unit 134 writes the host data to the specified address (destination address) in the flash memory module 150 through the flash memory interface 139 , and reads the host data from the specified address (source address) in the flash memory module 150 . The flash memory interface 139 uses several electronic signals to coordinate data and command transfer between the flash memory controller 130 and the flash memory module 150 , including a data line, a clock signal, and a control signal. Data lines can be used to transmit commands, addresses, read and written data; control signal lines can be used to transmit Chip Enable (CE), Address Latch Enable (ALE), Command Latch Enable Can (Command Latch Enable, CLE), write enable (Write Enable, WE) and other control signals.

參考圖2,閃存模組150中的介面151可包含四個輸出入通道(I/O channels,以下簡稱通道)CH#0至CH#3,每個通道連接四個NAND閃存單元,例如,通道CH#0連接NAND閃存單元153#0、153#4、153#8及153#12。每個NAND閃存單元可封裝為獨立的芯片(die)。閃存介面139可通過介面151發出致能訊號CE#0至CE#3中的一個來致能NAND閃存單元153#0至153#3、153#4至153#7、153#8至153#11、或153#12至153#15,接著以並行的方式從致能的NAND閃存單元讀取主機資料,或者寫入主機資料至致能的NAND閃存單元。Referring to FIG. 2 , the interface 151 in the flash memory module 150 may include four I/O channels (hereinafter referred to as channels) CH#0 to CH#3, and each channel is connected to four NAND flash memory cells, for example, a channel CH#0 is connected to NAND flash memory cells 153#0, 153#4, 153#8 and 153#12. Each NAND flash memory cell can be packaged as an independent die. The flash memory interface 139 can enable the NAND flash memory cells 153#0 to 153#3, 153#4 to 153#7, and 153#8 to 153#11 by issuing one of the enable signals CE#0 to CE#3 through the interface 151 , or 153#12 to 153#15, and then read host data from the enabled NAND flash memory cells in parallel, or write host data to the enabled NAND flash memory cells.

為了儲存不同類型的主機資料,NAND閃存單元153#0至153#15中的每一個可包含多個實體塊,並且每個實體塊可設置為SLC塊或非SLC塊(non-SLC Block)。NAND閃存單元153#0至153#15中的所有SLC塊可搜集起來稱為SLC區(SLC Region),而其中的所有非SLC塊可搜集起來稱為non-SLC區(non-SLC Region)。SLC塊中的每個記憶單元在抹除後只能以SLC模式編程,而non-SLC塊中的每個記憶單元在抹除後可以SLC、MLC、TLC或QLC等模式編程。MLC、TLC和QLC模式可統稱為非SLC模式。每個MLC、TLC或QLC能夠比一個SLC儲存更多位元的資料,但是,SLC的資料耐用性(Data Retention)和存取速度卻優於MLC、TLC或QLC。SLC塊、MLC塊、TLC塊及QLC塊中的每個記憶體單元可分別儲存兩個、四個、八個及十六個狀態中的一個。SLC塊中的每個字元線(Word Line)可儲存一個頁面的資料。MLC塊中的每個字元線可儲存兩個頁面的資料,包含最高有效位頁面(Most Significant Bit,MSB Page)及最低有效位頁面(Least Significant Bit,LSB Page)。TLC塊中的每個字元線可儲存三個頁面的資料,包含最高有效位頁面、中間有效位頁面(Center Significant Bit,CSB Page)及最低有效位頁面。QLC塊中的每個字元線可儲存四個頁面的資料,包含頂部有效位頁面(Top Significant Bit,TSB Page)、最高有效位頁面、中間有效位頁面及最低有效位頁面。In order to store different types of host data, each of the NAND flash memory cells 153#0 to 153#15 may include a plurality of physical blocks, and each physical block may be configured as an SLC block or a non-SLC block (non-SLC Block). All SLC blocks in the NAND flash memory cells 153#0 to 153#15 can be collected as SLC Regions, and all non-SLC blocks therein can be collected as non-SLC Regions. Each memory cell in an SLC block can only be programmed in SLC mode after erasing, while each memory cell in a non-SLC block can be programmed in SLC, MLC, TLC or QLC mode after erasing. MLC, TLC and QLC modes can be collectively referred to as non-SLC modes. Each MLC, TLC or QLC can store more bits of data than an SLC, but the data retention and access speed of SLC are better than MLC, TLC or QLC. Each memory cell in the SLC block, MLC block, TLC block, and QLC block can store one of two, four, eight, and sixteen states, respectively. Each word line (Word Line) in the SLC block can store a page of data. Each word line in the MLC block can store two pages of data, including the Most Significant Bit (MSB Page) and the Least Significant Bit (LSB Page). Each word line in the TLC block can store three pages of data, including the most significant bit page, the center significant bit page (Center Significant Bit, CSB Page) and the least significant bit page. Each word line in the QLC block can store four pages of data, including the Top Significant Bit (TSB Page), the most significant bit page, the middle significant bit page, and the least significant bit page.

參考圖3,主機端110會執行檔案系統(File System)300,實現資料的儲存、分級組織和存取等操作。例如,檔案系統300可對裝置端提供的儲存空間邏輯性分為第一和第二開機分區(Boot Partitions)310#1和310#2、重現保護記憶塊分區(Replay Protected Memory Block,RPMB Partition)310#3、第一至第四通用分區(General Purpose Partitions)310#4至310#7和使用者資料分區(User Data Partition)310#8。檔案系統300將邏輯性分區資訊傳送給閃存控制器130中執行的快閃記憶體翻譯層(Flash Translation Layer,FTL)350,這些資訊包含每個分區的編號和長度,而分區的長度通常以邏輯區塊位址(Logical Block Address,LBA)的數量表示。一個LBA編號可對應到固定長度的資料,例如512位元組的資料。通過檔案系統300,主機端110可儲存系統組態、開機程式在第一開機分區310#1,以及儲存驅動程式、作業系統在第二開機分區310#2。主機端110另可儲存各式各樣的應用程式到第一至第四通用分區(General Purpose Partitions)310#4至310#7,以及各式各樣的資料檔案到使用者資料分區310#8。舉例來說,當主機端110欲寫入開機程式到裝置端時,可發出主機寫命令給閃存控制器130,其中包含第一開機分區(Boot Partitions)310#1的編號、開始LBA編號、長度等資訊。當主機端110欲寫入視訊串流檔案到裝置端時,也可發出主機寫命令給閃存控制器130,其中包含使用者資料分區310#8的編號、開始LBA編號、長度等資訊。為了方便管理,在一些實施方式中,FTL 350依據主機資料的特性讓一部份分區的資料儲存在SLC區155#1,並且讓其他分區的資料儲存在non-SLC區155#3。FTL 350可依據主機寫命令中的分區編號將從主機端110接收的資料寫入到閃存模組150中的SLC區155#1或non-SLC區155#3中的一個或多個實體塊。詳細舉例來說,FTL 350將相應於第一和第二開機分區310#1和310#2和RPMB分區310#3的資料寫入SLC區155#1,並且將相應於第一至第四通用分區310#4至310#7和使用者資料分區310#8的資料寫入non-SLC區155#3。因此,SLC塊可用來儲存重要而不能出錯,且頻繁存取的系統資料,例如,作業系統、驅動程式、鍵值等等。non-SLC塊可用來儲存大容量的系統資料和使用者資料,例如各式各樣的應用程式、文字處理、試算表、簡報、影像、音訊、視訊等檔案。Referring to FIG. 3 , the host 110 executes a file system (File System) 300 to implement operations such as data storage, hierarchical organization, and access. For example, the file system 300 can logically divide the storage space provided by the device into first and second boot partitions (Boot Partitions) 310#1 and 310#2, Replay Protected Memory Block (RPMB Partition) ) 310#3, first to fourth General Purpose Partitions 310#4 to 310#7, and User Data Partition 310#8. The file system 300 transmits logical partition information to the Flash Translation Layer (FTL) 350 executed in the flash controller 130. The information includes the number and length of each partition, and the length of the partition is usually determined in logical order. The number of block addresses (Logical Block Address, LBA). An LBA number can correspond to fixed-length data, such as 512-byte data. Through the file system 300, the host 110 can store system configuration and boot programs in the first boot partition 310#1, and store drivers and operating systems in the second boot partition 310#2. The host 110 can also store various application programs in the first to fourth general purpose partitions (General Purpose Partitions) 310#4 to 310#7, and various data files in the user data partition 310#8 . For example, when the host side 110 wants to write the boot program to the device side, it can issue a host write command to the flash memory controller 130, which includes the number of the first boot partition (Boot Partitions) 310#1, the start LBA number, and the length. and other information. When the host side 110 wants to write the video stream file to the device side, it can also issue a host write command to the flash memory controller 130, which includes the number of the user data partition 310#8, the starting LBA number, the length and other information. For the convenience of management, in some embodiments, the FTL 350 stores data of some partitions in the SLC area 155#1 and stores data of other partitions in the non-SLC area 155#3 according to the characteristics of the host data. The FTL 350 can write the data received from the host 110 into one or more physical blocks in the SLC area 155#1 or the non-SLC area 155#3 in the flash memory module 150 according to the partition number in the host write command. For example in detail, the FTL 350 writes data corresponding to the first and second boot partitions 310#1 and 310#2 and the RPMB partition 310#3 into the SLC area 155#1, and writes data corresponding to the first to fourth general purpose Data of partitions 310#4 to 310#7 and user data partition 310#8 are written into non-SLC area 155#3. Therefore, the SLC block can be used to store important, error-free, and frequently accessed system data, such as operating systems, drivers, keys, and so on. Non-SLC blocks can be used to store large amounts of system data and user data, such as various applications, word processing, spreadsheets, presentations, images, audio, video and other files.

通常在初始時,FTL 350可配置超過第一和第二開機分區310#1和310#2和RPMB分區310#3的長度的空間給SLC區155#1。例如,雖然邏輯性分區資訊指出第一和第二開機分區310#1和310#2和RPMB分區310#3的總長度為8百萬位元組(Megabyte,MB),但是FTL 350配置了10MB的儲存空間給SLC區155#1。然而,因為第一和第二開機分區310#1和310#2和RPMB分區310#3的資料通常很少變動,造成SLC區155#1擁有許多餘裕的空間都不會使用到。就算第一至第四通用分區(General Purpose Partitions)310#4至310#7和使用者資料分區(User Data Partition)310#8的資料即將寫滿non-SLC區155#3,SLC區155#1的餘裕空間也不能被使用。Typically initially, the FTL 350 may allocate space to the SLC area 155#1 that exceeds the length of the first and second boot partitions 310#1 and 310#2 and the RPMB partition 310#3. For example, although the logical partition information indicates that the total length of the first and second boot partitions 310#1 and 310#2 and the RPMB partition 310#3 is 8 Megabytes (MB), the FTL 350 is configured with 10MB The storage space is given to SLC area 155#1. However, because the data of the first and second boot partitions 310#1 and 310#2 and the RPMB partition 310#3 usually change little, the SLC area 155#1 has a lot of spare space that is not used. Even if the first to fourth general purpose partitions (General Purpose Partitions) 310#4 to 310#7 and the user data partition (User Data Partition) 310#8 are about to fill the non-SLC area 155#3 and the SLC area 155# The headroom of 1 cannot be used either.

為了解決如上所述實施方式的問題,本發明實施例提出一種新的配置方式,用於更有效地使用閃存模組150的儲存空間。參考圖4,FTL 450依據主機資料的特性讓一部份分區的資料只能儲存在SLC區155#1,並且讓其他分區的資料可儲存在SLC區155#1或non-SLC區155#3。舉例來說,FTL 450讓相應於第一和第二開機分區310#1和310#2和RPMB分區310#3的資料只能寫入SLC區155#1,並且將相應於第一至第四通用分區310#4至310#7和使用者資料分區310#8的資料能夠寫入SLC區155#1和non-SLC區155#3。詳細來說,當處理單元134載入並執行FTL 450的程式碼時實施快閃記憶體的資料儲存方法,包含:將閃存模組150的儲存空間劃分為SLC區155#1和non-SLC區155#3;驅動閃存介面139將通過主機介面131從主機端110接收的屬於第一、第二開機分區310#1和310#2和RPMB分區310#3的資料只寫入SLC區155#1中的實體塊;以及驅動閃存介面139將通過主機介面131從主機端110接收的屬於第一至第四通用分區310#4至310#7和使用者資料分區10#8的資料寫入SLC區155#1中的實體塊和non-SLC區155#3中的第二實體塊。In order to solve the problems of the above-mentioned embodiments, the embodiment of the present invention proposes a new configuration method for using the storage space of the flash memory module 150 more efficiently. Referring to Figure 4, FTL 450 allows data of some partitions to be stored only in SLC area 155#1 according to the characteristics of host data, and allows data of other partitions to be stored in SLC area 155#1 or non-SLC area 155#3 . For example, the FTL 450 allows the data corresponding to the first and second boot partitions 310#1 and 310#2 and the RPMB partition 310#3 to be written only to the SLC area 155#1, and will correspond to the first to fourth The data of the general partitions 310#4 to 310#7 and the user data partition 310#8 can be written into the SLC area 155#1 and the non-SLC area 155#3. In detail, when the processing unit 134 loads and executes the code of the FTL 450, the data storage method of the flash memory is implemented, including: dividing the storage space of the flash memory module 150 into the SLC area 155#1 and the non-SLC area 155#3; the drive flash interface 139 writes the data belonging to the first and second boot partitions 310#1 and 310#2 and the RPMB partition 310#3 received from the host side 110 through the host interface 131 into only the SLC area 155#1 and the drive flash interface 139 writes the data belonging to the first to fourth general partitions 310#4 to 310#7 and the user data partition 10#8 received from the host 110 through the host interface 131 into the SLC area A physical block in 155#1 and a second physical block in non-SLC area 155#3.

在一些實施例中,FTL 450可讓相應於第一至第四通用分區310#4至310#7和使用者資料分區310#8的隨機資料(Random Data)寫入SLC區155#1,並且讓相應於第一至第四通用分區310#4至310#7和使用者資料分區310#8的連續資料(Continuous Data)寫入non-SLC區155#3。參考圖5所示的資料寫入方法的流程圖,此方法由處理單元134載入及執行FTL 450的程式碼時實施,詳細說明如下:In some embodiments, the FTL 450 may write random data (Random Data) corresponding to the first to fourth general purpose partitions 310#4 to 310#7 and the user data partition 310#8 into the SLC area 155#1, and Write continuous data (Continuous Data) corresponding to the first to fourth general-purpose partitions 310#4 to 310#7 and the user data partition 310#8 into the non-SLC area 155#3. Referring to the flowchart of the data writing method shown in FIG. 5, the method is implemented when the processing unit 134 loads and executes the code of the FTL 450, and the details are as follows:

步驟S510:通過主機介面131從主機端110接收主機寫入命令。Step S510 : Receive a host write command from the host terminal 110 through the host interface 131 .

步驟S520:判斷待寫入資料是否屬於特定分區類型(Partition-type)。如果是,流程繼續進行步驟S530的處理;否則,流程繼續進行步驟S540的處理。舉例來說,FTL 450將所有分區分成兩種類型:第一分區類型包含第一和第二開機分區310#1和310#2和RPMB分區310#3;第二分區類型包含第一至第四通用分區310#4至310#7和使用者資料分區310#8。以上所述的特定分區類型指第一分區類型。處理單元134可通過檢查主機寫入命令中攜帶的分區號碼來完成判斷。Step S520: Determine whether the data to be written belongs to a specific partition type (Partition-type). If yes, the flow continues to the processing of step S530; otherwise, the flow continues to the processing of step S540. For example, the FTL 450 divides all partitions into two types: the first partition type includes the first and second boot partitions 310#1 and 310#2 and the RPMB partition 310#3; the second partition type includes the first to fourth General partitions 310#4 to 310#7 and user data partition 310#8. The specific partition type described above refers to the first partition type. The processing unit 134 can complete the judgment by checking the partition number carried in the host write command.

步驟S530:寫入資料到SLC區155#1中當前塊(Current Block)的一個或多個實體頁面。SLC區155#1中的每個實體塊可標記為三種狀態中的一個:閒置塊(Spare Blocks)、當前塊(Current Blocks)和資料塊(Data Blocks)。任何實體塊在不包含有效資料之後就可成為閒置塊。針對每個NAND閃存單元,閃存控制器130可從其中的每個資料平面的閒置塊中挑選出一個來作為當前塊,用來寫入主機寫入命令所請求儲存的資料。當資料寫滿當前塊後,閃存控制器130關閉此實體塊不再寫入而只能讀取資料,此時,此實體塊稱為資料塊。接著,閃存控制器130從閒置塊中挑選出一個來作為新的當前塊,繼續新的資料寫入。FTL 450可在RAM 136中為每個當前塊維護實體-邏輯對照表(Physical-To-Logical,P2L Mapping Table),用於依實體頁面的順序儲存每個實體頁面的資料屬於哪個LBA編號的資訊。一旦當前塊關閉而成為資料塊時,FTL 450可驅動閃存介面139來寫入P2L對照表到閃存模組150的指定位置。此外,FTL 450另需要更新邏輯-實體對照表(Logical-To-Physical,L2P Mapping Table)中的相應內容。L2P對照表依LBA編號的順序儲存每個LBA編號的資料儲存在哪個實體位址的資訊,實體位址可包含實體塊編號、實體頁面編號等資訊。FTL 450更新L2P對照表中被更新LBA編號的實體位址,用於指到SLC區155#1中相應的實體位址。Step S530: Write data to one or more physical pages of the current block (Current Block) in the SLC area 155#1. Each physical block in SLC area 155#1 may be marked in one of three states: Spare Blocks, Current Blocks, and Data Blocks. Any physical block can become a free block after it contains no valid data. For each NAND flash memory cell, the flash memory controller 130 may select one of the free blocks in each data plane as the current block for writing the data requested by the host write command to be stored. When the current block is filled with data, the flash controller 130 closes the physical block and no longer writes data but can only read data. At this time, the physical block is called a data block. Next, the flash controller 130 selects one of the idle blocks as a new current block, and continues to write new data. The FTL 450 may maintain a Physical-To-Logical (P2L Mapping Table) in the RAM 136 for each current block, which is used to store the information of which LBA number the data of each physical page belongs to in the order of the physical pages . Once the current block is closed and becomes a data block, the FTL 450 can drive the flash interface 139 to write the P2L lookup table to the specified location of the flash module 150 . In addition, the FTL 450 also needs to update the corresponding content in the Logical-To-Physical (Logical-To-Physical, L2P Mapping Table). The L2P comparison table stores the information of which physical address the data of each LBA number is stored in in the order of the LBA numbers. The physical address may include the physical block number, physical page number and other information. The FTL 450 updates the physical address of the updated LBA number in the L2P comparison table to refer to the corresponding physical address in the SLC area 155#1.

在這裡需要注意的是,L2P對照表中的每個LBA編號會對應到一個分區編號,用於指出此LBA編號資料屬於哪個分區。此外,依據初始的組態,L2P對照表中的每個實體位址屬於SLC區155#1或non-SLC區155#3。在一些實施例中,FTL 450可掃描L2P對照表中屬於第一至第四通用分區310#4至310#7和使用者資料分區310#8的LBA編號的實體位址來知道第一至第四通用分區310#4至310#7和使用者資料分區310#8中的每一個LBA編號的資料儲存在SLC區155#1或non-SLC區155#3中。It should be noted here that each LBA number in the L2P comparison table corresponds to a partition number, which is used to indicate which partition the LBA number data belongs to. Furthermore, each entity address in the L2P lookup table belongs to the SLC area 155#1 or the non-SLC area 155#3 according to the initial configuration. In some embodiments, the FTL 450 may scan the physical addresses of the LBA numbers belonging to the first to fourth general partitions 310#4 to 310#7 and the user data partition 310#8 in the L2P lookup table to know the first to fourth Data for each LBA number in the four general purpose partitions 310#4 to 310#7 and the user data partition 310#8 is stored in the SLC area 155#1 or the non-SLC area 155#3.

在一些實施例中,FTL 450為了區分SLC區155#1中每個實體塊或資料塊的每個實體頁面的資料屬於哪種分區類型,FTL 450可另在RAM 136中為SLC區155#1中每個實體塊或資料塊維護一個分區類型位元表(Partition-type Bit Table),至少包含一個實體塊的全部頁面數目的位元,依實體位址的順序紀錄每個實體頁面屬於哪種分區類型的資訊。例如,當一個位元紀錄“1”時,代表相應實體頁面的資料屬於第二分區類型;當一個位元紀錄“0”時,代表相應實體頁面的資料屬於第一分區類型。當資料寫入完成,FTL 450更新分區類型位元表中相應於寫入實體頁面的位元值為“0”。In some embodiments, in order to distinguish which partition type the data of each physical block or each physical page of the data block in the SLC area 155#1 belongs to, the FTL 450 may additionally store the SLC area 155#1 in the RAM 136 Each physical block or data block maintains a partition-type bit table (Partition-type Bit Table), which contains at least the bits of the total number of pages of one physical block, and records which physical page belongs to in the order of physical addresses. Information about the partition type. For example, when a bit record is "1", the data representing the corresponding physical page belongs to the second partition type; when a bit record is "0", the data representing the corresponding physical page belongs to the first partition type. When the data writing is completed, the FTL 450 updates the bit value corresponding to the written physical page in the partition type bit table to "0".

步驟S540:判斷主機寫入命令是否為隨機寫入命令。如果是,流程繼續步驟S550的處理;否則,流程進行步驟S560的處理。FTL 450可依據主機寫入命令欲寫入資料的長度來判斷是否為隨機寫入命令。假設主機端110管理資料的最小單位為4千位元組(Kilobyte,KB),且每個實體頁面能夠儲存資料的長度為16KB時:當主機寫命令指示寫入短於16KB的資料時,FTL 450可判斷此主機寫入命令為隨機寫入命令。反之,表示此主機寫入命令為連續寫入命令,可能結合之前和/或之後的主機寫入命令,指示寫入一段長的連續資料。Step S540: Determine whether the host write command is a random write command. If yes, the flow proceeds to the processing of step S550; otherwise, the flow proceeds to the processing of step S560. The FTL 450 can determine whether it is a random write command according to the length of the data to be written by the host write command. Assuming that the minimum unit of data managed by the host 110 is 4 kilobytes (Kilobyte, KB), and each physical page can store data with a length of 16KB: when the host write command instructs to write data shorter than 16KB, the FTL 450 may determine that the host write command is a random write command. On the contrary, it indicates that the host write command is a continuous write command, and may be combined with previous and/or subsequent host write commands to instruct to write a long continuous data.

步驟S550:寫入資料到SLC區155#1中當前塊的一個實體頁面。關於寫入資料後更新P2L對照表和L2P對照表的技術細節,所屬技術領域人員可根據步驟S530的說明推測而得,為求簡明不再贅述。在一些實施例中,FTL 450可更新分區類型位元表中相應於寫入實體頁面的位元值為“1”,代表此實體頁面的資料屬於第二分區類型。Step S550: Write data to a physical page of the current block in the SLC area 155#1. The technical details of updating the P2L comparison table and the L2P comparison table after writing the data can be inferred by those skilled in the art according to the description of step S530, and will not be repeated for brevity. In some embodiments, the FTL 450 may update the bit table corresponding to the written physical page in the partition type bit table with a value of "1", indicating that the data of the physical page belongs to the second partition type.

步驟S560:寫入資料到non-SLC區155#3中當前塊的一個實體頁面。類似地,non-SLC區155#3中的每個實體塊可標記為三種狀態中的一個:閒置塊、當前塊和資料塊。關於non-SLC區155#3中改變每個實體塊的狀態的技術細節,所屬技術領域人員可根據步驟S530的說明推測而得,為求簡明不再贅述。此外,關於寫入資料到non-SLC區的當前塊後更新P2L對照表和L2P對照表的技術細節,所屬技術領域人員可根據步驟S530的說明推測而得,為求簡明不再贅述。Step S560: Write data to a physical page of the current block in the non-SLC area 155#3. Similarly, each physical block in non-SLC area 155#3 may be marked in one of three states: idle block, current block, and data block. The technical details of changing the state of each physical block in the non-SLC area 155#3 can be inferred by those skilled in the art according to the description of step S530, and will not be repeated for brevity. In addition, the technical details of updating the P2L lookup table and the L2P lookup table after writing data to the current block of the non-SLC area can be inferred by those skilled in the art according to the description of step S530, and will not be repeated for brevity.

在這裡需要注意的是,步驟S530、S550和S560所指的資料寫入操作並不一定驅動閃存介面139馬上寫入資料到閃存模組150中,而是先將適當的寫入指令儲存到閃存介面139的佇列中,然後讓閃存介面139決定這些寫入指令的執行時機,本發明並不因此侷限。It should be noted here that the data writing operations referred to in steps S530 , S550 and S560 do not necessarily drive the flash memory interface 139 to immediately write data into the flash memory module 150 , but rather store the appropriate write commands in the flash memory first. In the queue of the interface 139, and then let the flash memory interface 139 determine the execution timing of these write commands, the present invention is not limited to this.

當存取閃存模組150經過一段時間的存取後, SLC區155#1中的閒置塊數目會變動,FTL 450可維護一個閒置計數器,用來指出SLC區155#1中目前擁有的閒置塊的總數。每當SLC區155#1中的一個閒置塊變成當前塊時,閒置計數器減一。每當SLC區155#1中的一個資料塊變成閒置塊時,閒置計數器加一。此外,當存取閃存模組150經過一段時間的存取後,SLC區155#1中的許多實體頁面可能包含有效區段及無效區段(又稱為過期區段),其中,有效區段儲存有效資料,無效區段儲存無效(舊的)資料。當FTL 450偵測到計數器低於一個閥值時,可讀取並蒐集一個資料塊中屬於第二分區類型的有效區段中的資料,接著,驅動閃存介面139重新以MLC、TLC或QLC模式寫入蒐集起來的有效資料至non-SLC區155#3中當前塊的空實體頁面。此外,FTL 450可讀取並蒐集此資料塊中屬於第一分區類型的有效區段中的資料,接著,驅動閃存介面139重新以SLC模式寫入蒐集起來的有效資料至SLC區155#1中當前塊的空實體頁面,使得SLC區155#1中這些包含無效的使用者資料的資料塊可在抹除後變成為閒置區塊讓其他資料使用。如上所述的程序稱為跨區垃圾回收程序(Cross-region Garbage Collection,GC Process)。值得注意的是,跨區垃圾回收程序以MLC、TLC或QLC模式寫入有效資料到non-SLC區155#3中的實體頁面時,可釋放SLC區155#1中二個或以上的實體頁面(又可稱為SLC頁面)的儲存空間。在跨區垃圾回收程序中,FTL 450會根據寫入操作的執行結果更新P2L對照表和L2P對照表的內容。When the flash memory module 150 is accessed for a period of time, the number of free blocks in the SLC area 155#1 will change, and the FTL 450 can maintain a free counter to indicate the currently owned free blocks in the SLC area 155#1 total. Whenever an idle block in SLC area 155#1 becomes the current block, the idle counter is decremented by one. Whenever a data block in SLC area 155#1 becomes an idle block, the idle counter is incremented by one. In addition, when the flash module 150 is accessed for a period of time, many physical pages in the SLC area 155#1 may include valid sectors and invalid sectors (also called expired sectors), wherein the valid sectors Stores valid data, invalid section stores invalid (old) data. When the FTL 450 detects that the counter is lower than a threshold value, it can read and collect the data in the valid section belonging to the second partition type in a data block, and then drive the flash memory interface 139 in MLC, TLC or QLC mode again Write the collected valid data to the empty physical page of the current block in the non-SLC area 155#3. In addition, the FTL 450 can read and collect the data in the valid section belonging to the first partition type in the data block, and then drive the flash memory interface 139 to re-write the collected valid data in the SLC area 155#1 in the SLC mode The empty physical pages of the current block allow these data blocks containing invalid user data in the SLC area 155#1 to become free blocks for other data to use after erasing. The above program is called a cross-region garbage collection program (Cross-region Garbage Collection, GC Process). It is worth noting that when the cross-region garbage collection program writes valid data to the physical pages in the non-SLC area 155#3 in MLC, TLC or QLC mode, it can release two or more physical pages in the SLC area 155#1 (also known as SLC page) storage space. In the spanning garbage collection procedure, the FTL 450 updates the contents of the P2L comparison table and the L2P comparison table according to the execution result of the write operation.

參考圖6所示的儲存空間整理方法的流程圖,此方法由處理單元134載入及執行FTL 450的程式碼時實施,詳細說明如下:Referring to the flowchart of the storage space arrangement method shown in FIG. 6, the method is implemented when the processing unit 134 loads and executes the code of the FTL 450, and the detailed description is as follows:

步驟S610:偵測到觸發訊號。此觸發訊號可代表裝置端即將進入休眠模式,到達預先設定的時間點,或接收到主機寫入命令,或者是代表已經滿足其他預先設定的啟動偵測的觸發條件。Step S610: a trigger signal is detected. The trigger signal can represent that the device is about to enter the sleep mode, reaches a preset time point, or receives a host write command, or represents that other preset trigger conditions for enabling detection have been met.

步驟S620:讀取閒置計數器的值以獲得SLC區155#1中目前閒置塊的數目。Step S620: Read the value of the idle counter to obtain the current number of idle blocks in the SLC area 155#1.

步驟S630:判斷目前閒置塊的數目是否低於閥值。如果是,則流程繼續進行步驟S640的處理;否則,流程繼續進行步驟S610的處理。Step S630: Determine whether the current number of idle blocks is lower than a threshold. If yes, the flow continues to the process of step S640; otherwise, the flow continues to the process of step S610.

步驟S640:執行如上所述的跨區垃圾回收程序。Step S640: Execute the above-mentioned spanning garbage collection procedure.

在跨區垃圾回收程序中,為了判斷SLC區155#1中一個資料塊的每個實體頁面儲存的資料屬於第一分區類型或第二分區類型,在一些實施例中,FTL 450可搜索此資料塊的分區類型位元表來獲得此資料塊中哪些實體頁面的資料屬於第二分區類型。舉例來說,當此資料塊的分區類型位元表中一個位元為“1”時,代表相應實體頁面的資料屬於第二分區類型,FTL 450可搜集相應實體頁面中的有效資料。In the spanning garbage collection process, in order to determine whether the data stored in each physical page of a data block in the SLC area 155#1 belongs to the first partition type or the second partition type, in some embodiments, the FTL 450 may search for the data The partition type bit table of the block is used to obtain the data of which physical pages in this data block belong to the second partition type. For example, when a bit in the partition type bit table of the data block is "1", the data representing the corresponding physical page belongs to the second partition type, and the FTL 450 can collect valid data in the corresponding physical page.

在另一些實施例中,FTL 450可搜索L2P對照表中屬於第二分區類型的LBA編號的實體位址來知道哪些LBA編號的資料儲存在SLC區155#1中,並且搜集SLC區155#1中符合條件的實體位址的有效資料。In other embodiments, the FTL 450 may search the L2P lookup table for the physical addresses of the LBA numbers belonging to the second partition type to know which LBA numbers are stored in the SLC area 155#1, and collect the SLC area 155#1 Valid data for eligible physical addresses in .

為了讓SLC區155#1中的實體塊擁有接近的磨耗程度來延長使用壽命,FTL 450可適時地執行資料遷移程序。FTL 450可為每個實體塊紀錄一個抹除計數器,初始為0。在每次抹除一個實體塊後,將相應的抹除計數器加一。參考圖7所示的跨區磨耗平均(Cross-region Wear Leveling)方法的流程圖,此方法由處理單元134載入及執行FTL 450的程式碼時實施,詳細說明如下:In order to prolong the service life of the physical blocks in the SLC area 155#1 with a similar wear level, the FTL 450 may perform the data migration process in a timely manner. The FTL 450 may record an erase counter for each physical block, which is initially 0. After each physical block is erased, the corresponding erase counter is incremented by one. Referring to the flowchart of the Cross-region Wear Leveling method shown in FIG. 7, the method is implemented when the processing unit 134 loads and executes the code of the FTL 450, and the detailed description is as follows:

步驟S710:偵測到觸發訊號。此觸發訊號可代表裝置端即將進入休眠模式,或到達預先設定的時間點,或者是代表已經滿足其他預先設定的啟動偵測的觸發條件。Step S710: a trigger signal is detected. The trigger signal may represent that the device is about to enter the sleep mode, or reaches a preset time point, or represents that other preset trigger conditions for enabling detection have been met.

步驟S720:讀取SLC區155#1中第一個或下一個資料塊的抹除計數器的值,代表此資料塊已經抹除的次數。Step S720: Read the value of the erase counter of the first or next data block in the SLC area 155#1, which represents the number of times the data block has been erased.

步驟S730:判斷抹除計數器的值是否高於閥值。如果是,代表此資料塊的使用過熱,流程繼續進行步驟S740的處理;否則,代表此資料塊的使用正常,流程繼續進行步驟S750的處理。Step S730: Determine whether the value of the erasing counter is higher than the threshold. If yes, it means that the use of the data block is overheated, and the process continues to the process of step S740; otherwise, it means that the use of the data block is normal, and the process continues to the process of step S750.

步驟S740:標記此資料塊為遷移來源塊。FTL 450可在RAM 136中紀錄此資料塊的標記資訊。Step S740: Mark the data block as a migration source block. FTL 450 may record tag information for this block in RAM 136 .

步驟S750:判斷是否偵測完SLC區中的所有資料塊。如果是,流程繼續進行步驟S760的處理;否則,流程繼續進行步驟S720的處理。Step S750: Determine whether all data blocks in the SLC area have been detected. If yes, the flow continues to the processing of step S760; otherwise, the flow continues to the processing of step S720.

步驟S760:執行資料遷移程序。Step S760: Execute the data migration procedure.

在如步驟S760所述的資料遷移程序的一些實施例中,FTL 450可驅動閃存介面139將SLC區155#1中遷移來源塊中屬於第二分區類型的多個實體頁面的資料原封不動地以MLC、TLC或QLC模式寫入到non-SLC區155#3中一個當前塊的一個實體頁面,此當前塊的抹除次數為non-SLC區155#3中相對較低的。此外,FTL 450可驅動閃存介面139將SLC區155#1中遷移來源塊中屬於第一分區類型的每個實體頁面的資料原封不動地以SLC模式寫入到SLC區155#1中一個當前塊的一個實體頁面,此當前塊的抹除次數為SLC區155#1中相對較低的。值得注意的是,當資料遷移程序分別以MLC、TLC或QLC模式寫入SLC區155#1中遷移來源塊的二個、三個或四個實體頁面的資料到non-SLC區155#3中的non-SLC頁面時,可釋放SLC區155#1中二個或以上的實體頁面的儲存空間。In some embodiments of the data migration process as described in step S760, the FTL 450 can drive the flash memory interface 139 to transfer the data of the plurality of physical pages belonging to the second partition type in the migration source block in the SLC area 155#1 as they are. The MLC, TLC or QLC mode writes to a physical page of a current block in the non-SLC area 155#3, and the erasure count of the current block is relatively low in the non-SLC area 155#3. In addition, the FTL 450 can drive the flash memory interface 139 to write the data of each physical page belonging to the first partition type in the migration source block in the SLC area 155#1 into a current block in the SLC area 155#1 in the SLC mode. A physical page of the current block, the erasure count of this current block is relatively low in SLC area 155#1. It is worth noting that when the data migration program writes the data of two, three or four physical pages of the migration source block in the SLC area 155#1 to the non-SLC area 155#3 in MLC, TLC or QLC mode respectively When the non-SLC page is stored, the storage space of two or more physical pages in the SLC area 155#1 can be released.

在如步驟S760所述的資料遷移程序的另一些實施例中,FTL 450可驅動閃存介面139將SLC區155#1中遷移來源塊中屬於第二分區類型的多個實體頁面的有效資料搜集起來以MLC、TLC或QLC模式寫入到non-SLC區155#3中一個當前塊的一個實體頁面,此當前塊的抹除次數為non-SLC區155#3中相對較低的。此外,FTL 450可驅動閃存介面139將SLC區155#1中遷移來源塊中屬於第一分區類型的多個實體頁面的有效資料搜集起來以SLC模式寫入到SLC區155#1中一個當前塊的一個實體頁面,此當前塊的抹除次數為SLC區155#1中相對較低的。這樣,不但可達成磨耗平均的目的,還能夠進行垃圾回收,更有效地使用閃存模組150的儲存空間。In other embodiments of the data migration process described in step S760, the FTL 450 may drive the flash memory interface 139 to collect valid data of a plurality of physical pages belonging to the second partition type in the migration source block in the SLC area 155#1 A physical page of a current block in the non-SLC area 155#3 is written in MLC, TLC or QLC mode, and the erasure count of the current block is relatively low in the non-SLC area 155#3. In addition, the FTL 450 can drive the flash memory interface 139 to collect valid data of multiple physical pages belonging to the first partition type in the migration source block in the SLC area 155#1 and write them into a current block in the SLC area 155#1 in the SLC mode A physical page of the current block, the erasure count of this current block is relatively low in SLC area 155#1. In this way, not only can the purpose of wear leveling be achieved, but also garbage collection can be performed, and the storage space of the flash memory module 150 can be used more effectively.

在如步驟S760所述的資料遷移程序中,當遷移來源塊的資料寫入到non-SLC區155#3後,FTL 450可標記遷移來源塊為暫時不使用的實體塊,避免在短時間內被抹除後成為閒置塊。In the data migration process described in step S760, after the data of the migration source block is written into the non-SLC area 155#3, the FTL 450 can mark the migration source block as a temporarily unused physical block, so as to avoid a short period of time After being erased, it becomes a free block.

為了避免SLC區155#1中的實體塊因為讀取次數過多而造成其中儲存的資料毀損,FTL 450可適時地執行資料遷移程序。FTL 450可為每個資料塊紀錄一個讀取計數器,每次被抹除而成為閒置塊後設為0。在每次讀取一個資料塊中儲存的資料後,將相應的讀取計數器加一。參考圖8所示的跨區讀取刷新(Cross-region Read Refresh)方法的流程圖,此方法由處理單元134載入及執行FTL 450的程式碼時實施,詳細說明如下:In order to prevent the data stored in the physical block in the SLC area 155#1 from being damaged due to excessive reading times, the FTL 450 can execute the data migration process in a timely manner. The FTL 450 can record a read counter for each data block, which is set to 0 after each data block is erased and becomes an idle block. After each data stored in a data block is read, the corresponding read counter is incremented by one. Referring to the flowchart of the Cross-region Read Refresh method shown in FIG. 8, the method is implemented when the processing unit 134 loads and executes the code of the FTL 450, and the detailed description is as follows:

步驟S810:讀取SLC區155#1的一個資料塊的實體頁面中的資料。Step S810: Read the data in the physical page of a data block in the SLC area 155#1.

步驟S820:將此資料塊的讀取計數器加一。Step S820: Increase the read counter of the data block by one.

步驟S830:判斷讀取計數器的值是否高於閥值。如果是,代表此資料塊的讀取過多,流程繼續進行步驟S840的處理;否則,代表此資料塊的使用正常,流程繼續進行步驟S810的處理。Step S830: Determine whether the value of the read counter is higher than the threshold. If yes, it means that the data block has been read too much, and the flow continues to the processing of step S840; otherwise, it means that the data block is used normally, and the flow continues to the processing of step S810.

步驟S840:執行資料遷移程序。Step S840: Execute the data migration procedure.

在如步驟S840所述的資料遷移程序的一些實施例中,FTL 450可驅動閃存介面139將此資料塊中屬於第二分區類型的多個實體頁面的資料原封不動地以MLC、TLC或QLC模式寫入到non-SLC區155#3中一個當前塊的一個實體頁面。此外,FTL 450可驅動閃存介面139將此資料塊中屬於第一分區類型的每個實體頁面的資料原封不動地以SLC模式寫入到SLC區155#1中一個當前塊的一個實體頁面。值得注意的是,當資料遷移程序分別以MLC、TLC或QLC模式寫入SLC區155#1中遷移此資料塊的二個、三個或四個實體頁面的資料到non-SLC區155#3中的non-SLC頁面時,可釋放SLC區155#1中二個或以上的實體頁面的儲存空間。In some embodiments of the data migration process described in step S840, the FTL 450 can drive the flash memory interface 139 to transfer the data of the plurality of physical pages belonging to the second partition type in the data block to the MLC, TLC or QLC mode. Write to one physical page of a current block in non-SLC area 155#3. In addition, the FTL 450 can drive the flash interface 139 to write the data of each physical page belonging to the first partition type in the data block to a physical page of a current block in the SLC area 155#1 in SLC mode intact. It is worth noting that when the data migration program is written in the SLC area 155#1 in MLC, TLC or QLC mode, the data of two, three or four physical pages of this data block are migrated to the non-SLC area 155#3 When there are non-SLC pages in the SLC area, the storage space of two or more physical pages in the SLC area 155#1 can be released.

在如步驟S840所述的資料遷移程序的另一些實施例中,FTL 450可驅動閃存介面139將此資料塊中屬於第二分區類型的多個實體頁面的有效資料搜集起來以MLC、TLC或QLC模式寫入到non-SLC區155#3中一個當前塊的一個實體頁面。此外,FTL 450可驅動閃存介面139將此資料塊中屬於第一分區類型的多個實體頁面的有效資料搜集起來以SLC模式寫入到SLC區155#1中一個當前塊的一個實體頁面。這樣,不但可達成讀取刷新的目的,還能夠進行垃圾回收,更有效地使用閃存模組150的儲存空間。In other embodiments of the data migration process as described in step S840, the FTL 450 can drive the flash memory interface 139 to collect the valid data of the plurality of physical pages belonging to the second partition type in the data block to MLC, TLC or QLC The pattern is written to a physical page of a current block in the non-SLC area 155#3. In addition, the FTL 450 can drive the flash interface 139 to collect valid data of a plurality of physical pages belonging to the first partition type in the data block and write to a physical page of a current block in the SLC area 155#1 in SLC mode. In this way, not only the purpose of reading and refreshing can be achieved, but also garbage collection can be performed, and the storage space of the flash memory module 150 can be used more effectively.

此外,當資料塊因若干原因發生讀取干擾(Read Disturbance)時,可能造成其中儲存的資料包含過多的錯誤位元。一但偵測到資料塊中的一個或多個實體面頁包含了過多的錯誤位元,FTL 450可適時地為此資料塊執行資料遷移程序。參考圖9所示的跨區讀取再生(Cross-region Read Reclaim)方法的流程圖,此方法由處理單元134載入及執行FTL 450的程式碼時實施,詳細說明如下:In addition, when the data block has Read Disturbance due to several reasons, the data stored therein may contain too many erroneous bits. Once it is detected that one or more physical page pages in a data block contain too many erroneous bits, the FTL 450 may perform a data migration process for this data block in a timely manner. Referring to the flowchart of the Cross-region Read Reclaim method shown in FIG. 9, the method is implemented when the processing unit 134 loads and executes the code of the FTL 450, and the detailed description is as follows:

步驟S910:讀取SLC區155#1的一個資料塊的實體頁面中的資料。Step S910: Read the data in the physical page of a data block in the SLC area 155#1.

步驟S920:判斷錯誤修正率是否高於閥值。如果是,代表此資料塊可能發生讀取干擾,流程繼續進行步驟S930的處理;否則,代表此資料塊的使用正常,流程繼續進行步驟S910的處理。在資料讀取時,閃存介面139可使用相應的糾錯碼(Error-Correcting Code,ECC)來修正此實體頁面中的資料所包含的錯誤位元。糾錯碼可為低密度奇偶較驗碼(Low-Density Parity Check Code,LDPC)、BCH碼(Bose–Chaudhuri–Hocquenghem Code)等。以每1KB的資料為例,BCH碼可提供最多72個錯誤位元的修正能力,而LDPC可提供最多128個錯誤位元的修正能力。閥值可設定為使用糾錯碼的最大修正能力的50%到80%之間。Step S920: Determine whether the error correction rate is higher than a threshold. If yes, it means that the data block may have read interference, and the flow continues to the processing of step S930; otherwise, it means that the data block is used normally, and the flow continues to the processing of step S910. During data reading, the flash memory interface 139 can use the corresponding Error-Correcting Code (ECC) to correct the erroneous bits contained in the data in the physical page. The error correction code may be a low-density parity check code (Low-Density Parity Check Code, LDPC), a BCH code (Bose–Chaudhuri–Hocquenghem Code), and the like. Taking each 1KB of data as an example, the BCH code can provide a correction capability of up to 72 error bits, while the LDPC can provide a correction capability of a maximum of 128 error bits. The threshold can be set between 50% and 80% of the maximum correction capability using the error correction code.

步驟S930:執行資料遷移程序。步驟S930的資料遷移程序的詳細內容可參考步驟S840的說明,為求簡明不再贅述。Step S930: Execute a data migration program. For the details of the data migration procedure of step S930, reference may be made to the description of step S840, which will not be repeated for brevity.

在如步驟S760、S840和S930所述的資料遷移程序中,為了判斷SLC區155#1中一個遷移來源塊的每個實體頁面儲存的資料屬於第一分區類型或第二分區類型,FTL 450可搜索此遷移來源塊的分區類型位元表來獲得其中每個實體頁面的資料屬於第一分區類型或第二分區類型。In the data migration procedure described in steps S760, S840 and S930, in order to determine whether the data stored in each physical page of a migration source block in the SLC area 155#1 belongs to the first partition type or the second partition type, the FTL 450 may The partition type bit table of the migration source block is searched to obtain the data of each physical page belonging to the first partition type or the second partition type.

本發明所述的方法中的全部或部分步驟可以計算機指令實現,例如儲存裝置中的韌體轉換層(Firmware Translation Layer,FTL)、特定硬體的驅動程式等。此外,也可實現於其他類型程式。所屬技術領域具有通常知識者可將本發明實施例的方法撰寫成計算機指令,為求簡潔不再加以描述。依據本發明實施例方法實施的計算機指令可儲存於適當的電腦可讀取媒體,例如DVD、CD-ROM、USB碟、硬碟,亦可置於可通過網路(例如,網際網路,或其他適當載具)存取的網路伺服器。All or part of the steps in the method of the present invention can be implemented by computer instructions, such as a firmware translation layer (Firmware Translation Layer, FTL) in a storage device, a driver for a specific hardware, and the like. In addition, it can also be implemented in other types of programs. Those skilled in the art can compose the methods of the embodiments of the present invention into computer instructions, which will not be described for brevity. Computer instructions for implementing methods according to embodiments of the present invention may be stored in a suitable computer-readable medium, such as DVD, CD-ROM, USB disk, hard disk, or may be other suitable vehicles) to access the web server.

雖然圖1、圖2中包含了以上描述的元件,但不排除在不違反發明的精神下,使用更多其他的附加元件,已達成更佳的技術效果。此外,雖然圖5至圖9的流程圖採用指定的順序來執行,但是在不違反發明精神的情況下,熟習此技藝人士可以在達到相同效果的前提下,修改這些步驟間的順序,所以,本發明並不侷限於僅使用如上所述的順序。此外,熟習此技藝人士亦可以將若干步驟整合為一個步驟,或者是除了這些步驟外,循序或平行地執行更多步驟,本發明亦不因此而侷限。Although the above-described elements are included in FIG. 1 and FIG. 2 , it is not excluded that more other additional elements can be used to achieve better technical effects without violating the spirit of the invention. In addition, although the flowcharts of FIGS. 5 to 9 are executed in the specified order, those skilled in the art can modify the order of these steps under the premise of achieving the same effect without violating the spirit of the invention. Therefore, The present invention is not limited to using only the sequence described above. In addition, those skilled in the art can also integrate several steps into one step, or in addition to these steps, perform more steps sequentially or in parallel, and the present invention is not limited thereby.

雖然本發明使用以上實施例進行說明,但需要注意的是,這些描述並非用以限縮本發明。相反地,此發明涵蓋了熟習此技藝人士顯而易見的修改與相似設置。所以,申請權利要求範圍須以最寬廣的方式解釋來包含所有顯而易見的修改與相似設置。Although the present invention is described using the above embodiments, it should be noted that these descriptions are not intended to limit the present invention. On the contrary, this invention covers modifications and similar arrangements obvious to those skilled in the art. Therefore, the scope of the appended claims is to be construed in the broadest manner so as to encompass all obvious modifications and similar arrangements.

10:電子裝置 110:主機端 130:閃存控制器 131:主機介面 132:匯流排 134:處理單元 136:隨機存取記憶體 138:直接記憶體存取控制器 139:閃存介面 150:閃存模組 151:介面 153#0~153#15:NAND閃存單元 CH#0~CH#3:通道 CE#0~CE#3:致能訊號 300:檔案系統 310#1~310#8:分區 350,450:快閃記憶體翻譯層 155#1:單層式單元區 155#3:非單層式單元區 S510~S560:方法步驟 S610~S640:方法步驟 S710~S760:方法步驟 S810~S840:方法步驟 S910~S930:方法步驟 10: Electronics 110: Host side 130: Flash Controller 131:Host Interface 132: Busbar 134: Processing unit 136: Random Access Memory 138: Direct Memory Access Controller 139: Flash interface 150: Flash Module 151: Interface 153#0~153#15: NAND flash memory unit CH#0~CH#3: Channel CE#0~CE#3: Enable signal 300: File System 310#1~310#8: Partition 350,450: Flash memory translation layer 155#1: Single-level unit area 155#3: Non-single-level unit area S510~S560: method steps S610~S640: method steps S710~S760: Method steps S810~S840: Method steps S910~S930: Method steps

圖1為依據本發明實施例的電子裝置的系統架構圖。FIG. 1 is a system architecture diagram of an electronic device according to an embodiment of the present invention.

圖2為依據本發明實施例的閃存模組的示意圖。FIG. 2 is a schematic diagram of a flash memory module according to an embodiment of the present invention.

圖3為一些實施方式的主機分區和儲存區域間的對照示意圖。FIG. 3 is a schematic diagram of a comparison between host partitions and storage areas in some embodiments.

圖4為依據本發明實施例的主機分區和儲存區域間的對照示意圖。FIG. 4 is a schematic diagram illustrating a comparison between a host partition and a storage area according to an embodiment of the present invention.

圖5為依據本發明實施例的資料寫入的方法流程圖。FIG. 5 is a flowchart of a data writing method according to an embodiment of the present invention.

圖6為依據本發明實施例的儲存空間整理的方法流程圖。FIG. 6 is a flowchart of a method for organizing storage space according to an embodiment of the present invention.

圖7為依據本發明實施例的跨區磨耗平均的方法流程圖。FIG. 7 is a flowchart of a method for cross-area wear averaging according to an embodiment of the present invention.

圖8為依據本發明實施例的跨區讀取刷新的方法流程圖。FIG. 8 is a flowchart of a method for reading and refreshing across regions according to an embodiment of the present invention.

圖9為依據本發明實施例的跨區讀取再生的方法流程圖。FIG. 9 is a flowchart of a method for reading and regenerating across regions according to an embodiment of the present invention.

S510~S560:方法步驟 S510~S560: method steps

Claims (16)

一種快閃記憶體的資料儲存方法,由一處理單元載入並執行一快閃記憶體翻譯層的程式碼時實施,上述方法包含: 將一閃存模組的儲存空間劃分為一第一區和一第二區,其中,上述第一區包含多個第一實體塊,上述第二區包含多個第二實體塊,每個上述第一實體塊只能使用一單層式單元模式來寫入資料,每個上述第二實體塊能夠使用上述單層式單元模式或一非單層式單元模式來寫入資料,上述單層式單元模式用於編程一記憶單元以儲存二個狀態中的一個,上述非單層式單元模式用於編程一記憶單元以儲存四個或更多狀態中的一個; 將從一主機端接收的屬於一第一分區類型的資料只寫入上述第一區中的上述第一實體塊;以及 將從上述主機端接收的屬於一第二分區類型的資料寫入上述第一區中的上述第一實體塊和上述第二區中的上述第二實體塊。 A method for storing data in a flash memory is implemented when a processing unit loads and executes a program code of a translation layer in a flash memory, and the method includes: The storage space of a flash memory module is divided into a first area and a second area, wherein the first area includes a plurality of first physical blocks, the second area includes a plurality of second physical blocks, and each of the first A physical block can only use a single-layer cell mode to write data, each of the second physical blocks can use the single-layer cell mode or a non-single-layer cell mode to write data, the single-layer cell mode mode is used to program a memory cell to store one of two states, the above-mentioned non-single-level cell mode is used to program a memory cell to store one of four or more states; writing data of a first partition type received from a host to only the first physical block in the first region; and The data belonging to a second partition type received from the host side is written into the first physical block in the first area and the second physical block in the second area. 如請求項1所述的快閃記憶體的資料儲存方法,包含: 從上述主機端接收一主機寫入命令; 當上述主機寫入命令指示寫入屬於上述第一分區類型的一第一資料時,寫入上述第一資料到上述第一區中的一當前塊; 當上述主機寫入命令指示寫入屬於上述第二分區類型的一第二資料且上述主機寫入命令為一隨機寫入命令時,寫入上述第二資料到上述第一區中的一當前塊;以及 當上述主機寫入命令指示寫入屬於上述第二分區類型的一第三資料且上述主機寫入命令為一連續寫入命令時,寫入上述第三資料到上述第二區中的一當前塊。 The data storage method of the flash memory according to claim 1, comprising: Receive a host write command from the above host; When the above-mentioned host write command instructs to write a first data belonging to the above-mentioned first partition type, writing the above-mentioned first data to a current block in the above-mentioned first area; When the host write command instructs to write a second data belonging to the second partition type and the host write command is a random write command, write the second data to a current block in the first area ;as well as When the host write command instructs to write a third data belonging to the second partition type and the host write command is a continuous write command, write the third data to a current block in the second area . 如請求項2所述的快閃記憶體的資料儲存方法,其中,上述第二資料的長度短於一個實體頁面儲存資料的長度,以及上述第三資料的長度等於或長於一個實體頁面儲存資料的長度。The data storage method of a flash memory according to claim 2, wherein the length of the second data is shorter than the length of the data stored in one physical page, and the length of the third data is equal to or longer than the length of the data stored in one physical page length. 如請求項2所述的快閃記憶體的資料儲存方法,包含: 檢查上述主機寫入命令攜帶的一分區號碼來判斷上述主機寫入命令指示寫入屬於上述第一分區類型或上述第二分區類型的資料。 The data storage method of the flash memory according to claim 2, comprising: Check a partition number carried in the host write command to determine that the host write command instructs to write data belonging to the first partition type or the second partition type. 如請求項1所述的快閃記憶體的資料儲存方法,包含: 當上述第一區的閒置塊的數目低於一閥值時,讀取並搜集一資料塊中屬於上述第一分區類型的多個第一有效區段中的資料,並使用上述單層式單元模式寫入上述第一有效區段中的資料到上述第一區中的一當前塊;以及 當上述第一區的閒置塊的數目低於上述閥值時,讀取並搜集上述資料塊中屬於上述第二分區類型的第二有效區段中的資料,並使用上述非單層式單元模式寫入上述第二有效區段中的資料到上述第二區中的一當前塊。 The data storage method of the flash memory according to claim 1, comprising: When the number of idle blocks in the first area is lower than a threshold, read and collect data in a plurality of first valid blocks belonging to the first partition type in a data block, and use the single-layer unit mode writing the data in the first valid sector to a current block in the first zone; and When the number of idle blocks in the first area is lower than the threshold, read and collect the data in the second valid area belonging to the second partition type in the data block, and use the non-single-level cell mode Write the data in the second valid sector into a current block in the second area. 如請求項1所述的快閃記憶體的資料儲存方法,包含: 當上述第一區的一資料塊的一抹除次數或一讀取次數高於一閥值時,讀取上述資料塊中屬於上述第一分區類型的多個第一實體頁面中的所有資料或有效資料,並使用上述單層式單元模式寫入上述第一實體頁面的所有資料或有效資料到上述第一區中的一當前塊;以及 當上述第一區的上述資料塊的上述抹除次數或上述讀取次數高於上述閥值時,讀取上述資料塊中屬於上述第二分區類型的多個第二實體頁面的所有資料或有效資料,並使用上述非單層式單元模式寫入上述第二實體頁面的所有資料或有效資料到上述第二區中的一當前塊。 The data storage method of the flash memory according to claim 1, comprising: When an erasing count or a reading count of a data block in the first area is higher than a threshold, read all data in a plurality of first physical pages belonging to the first partition type in the data block or valid data, and write all data or valid data of the first physical page to a current block in the first area using the single-layer cell mode; and When the erasing count or the reading count of the data block in the first area is higher than the threshold, read all the data of a plurality of second physical pages belonging to the second partition type in the data block or valid data, and write all data or valid data of the second physical page to a current block in the second area using the non-single-level cell mode. 如請求項1所述的快閃記憶體的資料儲存方法,包含: 讀取上述第一區的一資料塊中的一實體頁面的資料; 當上述實體頁面的一錯誤修正率高於一閥值時,讀取上述資料塊中屬於上述第一分區類型的多個第一實體頁面中的所有資料或有效資料,並使用上述單層式單元模式寫入上述第一實體頁面的所有資料或有效資料到上述第一區中的一當前塊;以及 當上述實體頁面的上述錯誤修正率高於上述閥值時,讀取上述資料塊中屬於上述第二分區類型的多個第二實體頁面的所有資料或有效資料,並使用上述非單層式單元模式寫入上述第二實體頁面的所有資料或有效資料到上述第二區中的一當前塊。 The data storage method of the flash memory according to claim 1, comprising: reading data of a physical page in a data block of the first area; When an error correction rate of the physical page is higher than a threshold, read all data or valid data in the plurality of first physical pages belonging to the first partition type in the data block, and use the single-layer unit mode writing all data or valid data of the first physical page to a current block in the first area; and When the error correction rate of the physical page is higher than the threshold value, read all data or valid data of a plurality of second physical pages belonging to the second partition type in the data block, and use the non-single-layer unit The mode writes all data or valid data of the second physical page to a current block in the second area. 如請求項6至7中任一項所述的快閃記憶體的資料儲存方法,包含: 搜索上述資料塊的一分區類型位元表來獲得上述資料塊中屬於上述第一分區類型的上述第一實體頁面和屬於上述第二分區類型的上述第二實體頁面的資訊,其中,上述分區類型位元表包含多個位元,每個上述位元紀錄相應實體頁面屬於上述第一分區類型或上述第二分區類型的資訊。 The data storage method of the flash memory according to any one of claim 6 to 7, comprising: Searching a partition type bit table of the data block to obtain the information of the first physical page belonging to the first partition type and the second physical page belonging to the second partition type in the data block, wherein the partition type The bit table includes a plurality of bits, and each of the bits records the information that the corresponding physical page belongs to the first partition type or the second partition type. 一種電腦程式產品,用於快閃記憶體的資料儲存,包含由一處理單元載入並執行一快閃記憶體翻譯層的程式碼,用於: 將一閃存模組的儲存空間劃分為一第一區和一第二區,其中,上述第一區包含多個第一實體塊,上述第二區包含多個第二實體塊,每個上述第一實體塊只能使用一單層式單元模式來寫入資料,每個上述第二實體塊能夠使用上述單層式單元模式或一非單層式單元模式來寫入資料,上述單層式單元模式用於編程一記憶單元以儲存二個狀態中的一個,上述非單層式單元模式用於編程一記憶單元以儲存四個或更多狀態中的一個; 將從一主機端接收的屬於一第一分區類型的資料只寫入上述第一區中的上述第一實體塊;以及 將從上述主機端接收的屬於一第二分區類型的資料寫入上述第一區中的上述第一實體塊和上述第二區中的上述第二實體塊。 A computer program product for data storage in flash memory, comprising code loaded by a processing unit and executing a flash memory translation layer for: The storage space of a flash memory module is divided into a first area and a second area, wherein the first area includes a plurality of first physical blocks, the second area includes a plurality of second physical blocks, and each of the first A physical block can only use a single-layer cell mode to write data, each of the second physical blocks can use the single-layer cell mode or a non-single-layer cell mode to write data, the single-layer cell mode mode is used to program a memory cell to store one of two states, the above-mentioned non-single-level cell mode is used to program a memory cell to store one of four or more states; writing data of a first partition type received from a host to only the first physical block in the first region; and The data belonging to a second partition type received from the host side is written into the first physical block in the first area and the second physical block in the second area. 一種快閃記憶體的資料儲存裝置,包含: 一閃存介面,耦接一閃存模組; 一主機介面,耦接一主機端;以及 一處理單元,耦接上述閃存介面和上述主機介面,將上述閃存模組的儲存空間劃分為一第一區和一第二區,其中,上述第一區包含多個第一實體塊,上述第二區包含多個第二實體塊,每個上述第一實體塊只能使用一單層式單元模式來寫入資料,每個上述第二實體塊能夠使用上述單層式單元模式或一非單層式單元模式來寫入資料,上述單層式單元模式用於編程一記憶單元以儲存二個狀態中的一個,上述非單層式單元模式用於編程一記憶單元以儲存四個或更多狀態中的一個;驅動上述閃存介面將通過上述主機介面從上述主機端接收的屬於一第一分區類型的資料只寫入上述第一區中的上述第一實體塊;以及驅動上述閃存介面將通過上述主機介面從上述主機端接收的屬於一第二分區類型的資料寫入上述第一區中的上述第一實體塊和上述第二區中的上述第二實體塊。 A data storage device of flash memory, comprising: a flash memory interface, coupled to a flash memory module; a host interface, coupled to a host; and A processing unit, coupled to the flash memory interface and the host interface, divides the storage space of the flash memory module into a first area and a second area, wherein the first area includes a plurality of first physical blocks, the first area The second area includes a plurality of second physical blocks, each of the first physical blocks can only use a single-layer cell mode to write data, and each of the second physical blocks can use the single-layer cell mode or a non-single-layer cell mode. The layered cell mode is used to write data, the single-layered cell mode is used to program a memory cell to store one of two states, and the non-single-layered cell mode is used to program a memory cell to store four or more states one of the states; driving the flash memory interface to write the data belonging to a first partition type received from the host side through the host interface to only the first physical block in the first region; and driving the flash memory interface to pass The data belonging to a second partition type received by the host interface from the host side is written into the first physical block in the first area and the second physical block in the second area. 如請求項10所述的快閃記憶體的資料儲存裝置,其中,上述處理單元通過上述主機介面從上述主機端接收一主機寫入命令;當上述主機寫入命令指示寫入屬於上述第一分區類型的一第一資料時,驅動上述閃存介面寫入上述第一資料到上述第一區中的一當前塊;當上述主機寫入命令指示寫入屬於上述第二分區類型的一第二資料且上述主機寫入命令為一隨機寫入命令時,驅動上述閃存介面寫入上述第二資料到上述第一區中的一當前塊;以及當上述主機寫入命令指示寫入屬於上述第二分區類型的一第三資料且上述主機寫入命令為一連續寫入命令時,驅動上述閃存介面寫入上述第三資料到上述第二區中的一當前塊。The data storage device of the flash memory according to claim 10, wherein the processing unit receives a host write command from the host through the host interface; when the host write command indicates that the write belongs to the first partition When a first data of the above-mentioned type is driven, the flash memory interface is driven to write the first data to a current block in the first area; when the host write command instructs to write a second data belonging to the second partition type and When the host write command is a random write command, drive the flash memory interface to write the second data to a current block in the first area; and when the host write command indicates that the write belongs to the second partition type When a third data is stored and the host write command is a continuous write command, the flash memory interface is driven to write the third data to a current block in the second area. 如請求項11所述的快閃記憶體的資料儲存裝置,其中,上述第二資料的長度短於一個實體頁面儲存資料的長度,以及上述第三資料的長度等於或長於一個實體頁面儲存資料的長度。The data storage device of flash memory according to claim 11, wherein the length of the second data is shorter than the length of the data stored in one physical page, and the length of the third data is equal to or longer than the length of the data stored in one physical page length. 如請求項11所述的快閃記憶體的資料儲存裝置,其中,上述處理單元檢查上述主機寫入命令攜帶的一分區號碼來判斷上述主機寫入命令指示寫入屬於上述第一分區類型或上述第二分區類型的資料。The data storage device of the flash memory according to claim 11, wherein the processing unit checks a partition number carried by the host write command to determine that the host write command indicates that the write belongs to the first partition type or the above Data for the second partition type. 如請求項10所述的快閃記憶體的資料儲存裝置,其中,當上述第一區的閒置塊的數目低於一閥值時,上述處理單元驅動上述閃存介面讀取並搜集一資料塊中屬於上述第一分區類型的多個第一有效區段中的資料,並使用上述單層式單元模式寫入上述第一有效區段中的資料到上述第一區中的一當前塊;以及當上述第一區的閒置塊的數目低於上述閥值時,上述處理單元驅動上述閃存介面讀取並搜集上述資料塊中屬於上述第二分區類型的第二有效區段中的資料,並使用上述非單層式單元模式寫入上述第二有效區段中的資料到上述第二區中的一當前塊。The data storage device of flash memory according to claim 10, wherein when the number of idle blocks in the first area is lower than a threshold, the processing unit drives the flash memory interface to read and collect a data block data in a plurality of first valid sectors belonging to the first partition type, and writing the data in the first valid sectors into a current block in the first sector using the single-level cell mode; and when When the number of idle blocks in the first area is lower than the threshold, the processing unit drives the flash memory interface to read and collect data in the second valid sector belonging to the second partition type in the data block, and use the The non-single-level cell mode writes the data in the second valid sector to a current block in the second zone. 如請求項10所述的快閃記憶體的資料儲存裝置,其中,當上述第一區的一資料塊的一抹除次數或一讀取次數高於一閥值時,上述處理單元驅動上述閃存介面讀取上述資料塊中屬於上述第一分區類型的多個第一實體頁面中的所有資料或有效資料,並使用上述單層式單元模式寫入上述第一實體頁面的所有資料或有效資料到上述第一區中的一當前塊;以及當上述第一區的上述資料塊的上述抹除次數或上述讀取次數高於上述閥值時,上述處理單元驅動上述閃存介面讀取上述資料塊中屬於上述第二分區類型的多個第二實體頁面的所有資料或有效資料,並使用上述非單層式單元模式寫入上述第二實體頁面的所有資料或有效資料到上述第二區中的一當前塊。The data storage device of flash memory according to claim 10, wherein when an erasing count or a reading count of a data block in the first area is higher than a threshold, the processing unit drives the flash memory interface Read all data or valid data in a plurality of first physical pages belonging to the first partition type in the above-mentioned data block, and use the above-mentioned single-layer unit mode to write all the data or valid data of the above-mentioned first physical page to the above-mentioned A current block in the first area; and when the erasing times or the reading times of the data blocks in the first area are higher than the threshold, the processing unit drives the flash memory interface to read the data blocks belonging to the data blocks. All data or valid data of a plurality of second physical pages of the second partition type, and use the non-single-level cell mode to write all the data or valid data of the second physical page to a current one in the second area. yuan. 如請求項10所述的快閃記憶體的資料儲存裝置,其中,上述處理單元驅動上述閃存介面讀取上述第一區的一資料塊中的一實體頁面的資料;當上述實體頁面的一錯誤修正率高於一閥值時,上述處理單元驅動上述閃存介面讀取上述資料塊中屬於上述第一分區類型的多個第一實體頁面中的所有資料或有效資料,並使用上述單層式單元模式寫入上述第一實體頁面的所有資料或有效資料到上述第一區中的一當前塊;以及當上述實體頁面的上述錯誤修正率高於上述閥值時,上述處理單元驅動上述閃存介面讀取上述資料塊中屬於上述第二分區類型的多個第二實體頁面的所有資料或有效資料,並使用上述非單層式單元模式寫入上述第二實體頁面的所有資料或有效資料到上述第二區中的一當前塊。The data storage device of flash memory according to claim 10, wherein the processing unit drives the flash memory interface to read data of a physical page in a data block of the first area; when an error of the physical page When the correction rate is higher than a threshold, the processing unit drives the flash memory interface to read all data or valid data in a plurality of first physical pages belonging to the first partition type in the data block, and uses the single-level unit mode to write all data or valid data of the first physical page to a current block in the first area; and when the error correction rate of the physical page is higher than the threshold, the processing unit drives the flash memory interface to read Take all data or valid data of a plurality of second physical pages belonging to the second partition type in the above data block, and use the above non-single-level unit mode to write all the data or valid data of the above second physical page to the above first A current block in the second area.
TW109133806A 2020-09-29 2020-09-29 Method and apparatus and computer program product for storing data in flash memory TWI754396B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW109133806A TWI754396B (en) 2020-09-29 2020-09-29 Method and apparatus and computer program product for storing data in flash memory

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW109133806A TWI754396B (en) 2020-09-29 2020-09-29 Method and apparatus and computer program product for storing data in flash memory

Publications (2)

Publication Number Publication Date
TWI754396B TWI754396B (en) 2022-02-01
TW202213085A true TW202213085A (en) 2022-04-01

Family

ID=81329454

Family Applications (1)

Application Number Title Priority Date Filing Date
TW109133806A TWI754396B (en) 2020-09-29 2020-09-29 Method and apparatus and computer program product for storing data in flash memory

Country Status (1)

Country Link
TW (1) TWI754396B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI814590B (en) * 2022-09-26 2023-09-01 慧榮科技股份有限公司 Data processing method and the associated data storage device

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9363315B2 (en) * 2012-08-28 2016-06-07 Skyera, Llc Integrated storage and switching for memory systems
KR102252419B1 (en) * 2014-01-09 2021-05-14 한국전자통신연구원 System and method for efficient address translation on Flash memory device
US11099781B2 (en) * 2018-07-19 2021-08-24 Silicon Motion, Inc. Flash memory controller, flash memory module and associated electronic device
CN111399750B (en) * 2019-01-03 2023-05-26 慧荣科技股份有限公司 Flash memory data writing method and computer readable storage medium

Also Published As

Publication number Publication date
TWI754396B (en) 2022-02-01

Similar Documents

Publication Publication Date Title
US11593259B2 (en) Directed sanitization of memory
CN107844431B (en) Mapping table updating method, memory control circuit unit and memory storage device
US8930671B2 (en) Logical address offset in response to detecting a memory formatting operation
US8626996B2 (en) Solid state memory (SSM), computer system including an SSM, and method of operating an SSM
US20150347291A1 (en) Flash memory based storage system and operating method
US20190294345A1 (en) Data-Retention Controller Using Mapping Tables in a Green Solid-State-Drive (GNSD) for Enhanced Flash Endurance
US11983107B2 (en) Enhanced filesystem support for zone namespace memory
TWI718710B (en) Data storage device and non-volatile memory control method
US11860669B2 (en) Method and apparatus and computer program product for storing data in flash memory
KR101515621B1 (en) Solid state disk device and random data processing method thereof
JP2020191055A (en) Recovery processing method and device from instantaneous interruption, and computer readable storage medium
TWI754396B (en) Method and apparatus and computer program product for storing data in flash memory
CN115390747A (en) Storage device and operation method thereof
TWI820473B (en) Method and apparatuse and computer program product for handling sudden power off recovery
US20240078027A1 (en) Storage device including nonvolatile memory device and operating method of storage device
US20240070033A1 (en) Storage device including nonvolatile memory device and operating method of storage device
KR20220159270A (en) Storage device and operating method thereof
Firmware et al. A Beginner’s Guide to SSD Firmware