# US 10,120,795 B2 · Wear-leveling nandflash memory reading/writing method

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 10,120,795 B2
- Document ID: US10120795B2
- Status: Granted
- Kind: B2
- Application number: 15/699,763
- Filed: 2017-09-08
- Published: 2018-03-22
- Granted: 2018-11-06
- Earliest claimed: 2016-09-21
- Assignees: Institute of Geology and Geophysics, Chinese Academy of Sciences
- Applicants: Institute of Geology and Geophysics, Chinese Academy of Sciences
- Inventors: Yongyou Yang; Wenxuan Chen; Qingyun Di; Wenxiu Zhang; Yuntao Sun; Jian Zheng
- Web page: https://patentgrep.com/patent/US10120795B2

## CPC

- G06F 12/0246: {in block erasable memory, e.g. flash memory}
- G06F 12/0292: {using tables or multilevel address translation means (G06F12/023 takes precedence; address translation in virtual memory systems G06F12/10)}
- G06F 12/126: with special data handling, e.g. priority of data or instructions, handling errors or pinning
- G06F 2212/7204: Capacity control, e.g. partitioning, end-of-life degradation
- G06F 2212/7207: management of metadata or control data
- G06F 2212/7208: Multiple device management, e.g. distributing data over multiple flash devices
- G06F 2212/7211: Wear leveling
- Y02D 10/00: Energy efficient computing, e.g. low power processors, power management or thermal management
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- Y02D: CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE

## Abstract

A wear-leveling NandFlash memory reading/writing method can identify a bad block, avoid the bad block, and equalize writing operations to ensure that all the blocks are identical in number of the writing operations so as to guarantee wear-leveling NandFlash memory reading and writing of the entire memory. This method has characteristics of low computational and small RAM cost, is suitable for the application scenario like operating a single file for a long time with an imbedded system with low cost and poor hardware resource, and can provide a complete file system solution.

## Claims

### Claim 1

A method of writing data in a wear-leveling NandFlash memory, a storage space of the NandFlash memory including a storage information area, a file information area, a data area and a swap area, the method comprising:
creating a new file information table in the file information area, and reading all other file information tables to determine a writing starting address of a new file;
determining whether the writing starting address of the new file is in a starting address of a block;
in response to the writing starting address of the new file being in the starting address of the block, erasing the block, and determining a return status of an erasure operation;
in response to an error being returned, indicating that the block is a bad block, finding a replacement block in the swap area to replace the bad block, and updating a bad block registration table in the storage information area;
storing to-be-written data into a data buffer of a memory;
in response to data of one page having been stored sufficiently in the data buffer, writing the data into a block in the data area, and determining a return status of the writing;
in response to an error being returned, indicating that the block where this page is located is a bad block, finding a replacement block in the swap area to replace the bad block, updating the bad block registration table in the storage information area, and copying contents of a current page and its previous page of the bad block into the replacement block;
in response to the pages being successfully written, updating the file information table, which comprises file storage starting and ending addresses, file sizes and file updating time;
repeating steps including the storing to-be-written data through the updating the file information table, until a user ends a writing operation;
determining whether any remaining data exists in the data buffer, in response to any remaining data existing in the data buffer, writing all the data remaining in the buffer into a block in the data area; and
updating the file information table.

### Claim 2 (depends on 1)

The method according to claim 1, further comprising:
deleting information on a to-be-deleted file in the file information table to perform a file deletion operation; and
if there are files stored at a location with a higher logical address than the end address of a deleted file, sequentially copying those files at a location with a lower logical address than the starting address of the last file.

### Claim 3 (depends on 1)

The method according to claim 1, further comprising:
continuing writing at a tail of the file to perform a file addition writing operation;
if there are no other files at a location with a higher logical address than the end address of an additionally written file, directly continuing the writing, and; and
if there are other files at a location with a higher logical address than the end address of the additionally written file, firstly executing a file movement process to move the additionally written file to the tail-most end of a used storage space, and then continuing the writing at the tail of the file.

### Claim 4 (depends on 1)

The method according to claim 1,
wherein the storage information area is configured to store a bad block registration swap table and is-divided into a plurality of blocks, each of which is used in turn;
wherein the file information area is configured to store information on bad blocks in the file information table and is located in the first several blocks of a physical address of the memory, the file information area being internally divided into a plurality of blocks, each of which is used in turn;
wherein the data area is configured to store data and is located in the middle of the physical address of the memory; and
wherein the swap area is configured to swap a bad block in the data area with a replacement block in the swap area and is located in the last several blocks of the physical address of the memory, the bad block being a block in the data area to which data cannot be written.

### Claim 5 (depends on 4)

The method according to claim 4, wherein information on the bad block is stored in the plurality of blocks in the storage information area, which is used in turn.

### Claim 6 (depends on 1)

The method according to claim 1, further comprising:
reading a file information table in the file information area;
determining a starting address and an ending address of a file storage according to the file information table;
in response to the starting address being an address of a block that has not been previously written to, determining whether a to-be-read block is a bad block;
finding an address of a replacement block of the bad block in response to the to-be-read block being the bad block;
in response to the starting address not being an address of a block that has not been previously written to, reading a page of data once;
determining whether all the files are read according to the file information table;
in response to all the files not being read, determining whether contents of blocks of all the pages are read;
in response to the contents of blocks of all the pages not being read, continuing to perform reading a page of data once with an increased page address by 1; and
in response to the contents of blocks of all the pages being read, continuing to perform determining whether a to-be-read block is a bad block with an increased block address by 1.
