Nandflash data storage method and apparatus, electronic device, and storage medium
By mapping the data directory in the random access memory partition and periodically storing the data back to NandFlash, the problem of accelerated NandFlash wear in the prior art is solved, resulting in a longer service life and more stable operation.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- FIBOCOM AUTO INC
- Filing Date
- 2025-04-29
- Publication Date
- 2026-04-23
AI Technical Summary
In existing technologies, while the wear leveling algorithm of NandFlash avoids excessive erasure and writing of a certain memory cell, it increases the system load and reduces the lifespan of NandFlash.
By mapping the data directory to the random access memory partition, the data of the file system area of the NandFlash is copied to the data directory of the random access memory partition, and the data is stored back to the file system area at preset intervals, thereby reducing the frequency of writing to the file system area of the NandFlash.
This reduces the frequency of erase and write operations on the NandFlash, extends its lifespan, and improves the stability and reliability of the system.
Smart Images

Figure CN2025091933_23042026_PF_FP_ABST
Abstract
Description
NandFlash data storage methods, devices, electronic equipment, and storage media
[0001] Citation of relevant applications
[0002] This disclosure claims the entire benefits of Chinese Patent Application No. 202411458506.7, filed on October 17, 2024, with the State Intellectual Property Office of the People's Republic of China, entitled "NandFlash Data Storage Method, Apparatus, Electronic Device and Storage Medium", the entire contents of which are incorporated herein by reference.
[0003] field
[0004] This disclosure generally relates to the field of data storage technology, and more specifically to NandFlash data storage methods, apparatus, electronic devices and storage media. Background Technology
[0005] The lifespan of Nand Flash memory is limited by its read / write cycles. Repeatedly writing and erasing the same memory cell will more easily lead to permanent damage. Currently, to avoid this, Nand Flash memory employs a wear-leveling algorithm. This algorithm distributes erase / write cycles evenly across all Nand Flash memory cells, thus preventing continuous erase / write operations on the same cell. However, because the wear-leveling algorithm spreads erase / write operations across all blocks, if the data on all blocks is frequently updated, this wear-leveling operation increases the system load and accelerates overall system wear, which is detrimental to extending the lifespan of the Nand Flash memory.
[0006] Overview
[0007] In a first aspect, this disclosure provides a NandFlash data storage method, which includes:
[0008] Map data directories in the random access memory partition;
[0009] Data from the NandFlash file system area is copied to the data directory of the random access memory partition; wherein, the data in the data directory is used for interactive reading and writing of data with the application; and
[0010] At preset intervals, the data in the current data directory is stored in the file system area of NandFlash.
[0011] In some implementations, the NandFlash data storage method further includes, before copying data from the file system area of the NandFlash to the data directory of the random access memory partition:
[0012] Allocate a first storage area in the NandFlash;
[0013] Configure the first storage area as the file system area.
[0014] In some implementations, the random access memory partition maps a data directory, including:
[0015] If it is determined that the random access memory partition has been powered on again, a second memory area is allocated in the random access memory partition;
[0016] The data directory is mapped in the second storage area.
[0017] In some implementations, the second storage area is the random access memory partition.
[0018] In some implementations, copying data from the file system area of the NandFlash to the data directory of the random access memory partition includes:
[0019] Once it is determined that the random access memory partition has been powered on again and the data directory mapping of the random access memory partition has been completed, the data of the file system area of the NandFlash is copied to the data directory.
[0020] In some implementations, at preset time intervals, the data in the current data directory is stored in the file system area of the NandFlash, including:
[0021] If it is determined that the data in the data directory has been updated, a timer will be started.
[0022] After the timer has elapsed for a preset duration, the data in the current data directory is stored in the file system area of NandFlash, and the timer is reset.
[0023] In some implementations, the NandFlash data storage method further includes, before allocating a first storage area in the NandFlash:
[0024] Determine if the target file system area exists in the NandFlash;
[0025] If the target file system area does not exist in the NandFlash, then the steps of allocating a first storage area in the NandFlash and configuring the first storage area as the file system area are performed.
[0026] If a target file system area exists in the NandFlash, then the target file system area will be used as the file system area.
[0027] Secondly, this disclosure provides a NandFlash data storage device, which includes:
[0028] The mapping module is configured to map data directories in random access memory partitions;
[0029] The copy module is configured to copy data from the file system area of the NandFlash to the data directory of the random access memory partition; wherein the data in the data directory is used for interactive reading and writing of data with the application; and
[0030] The storage module is configured to store the data in the current data directory to the file system area of NandFlash at preset intervals.
[0031] Thirdly, this disclosure provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;
[0032] Memory, configured to store computer programs;
[0033] When a processor is configured to execute a program stored in memory, it implements the NandFlash data storage method described in this disclosure.
[0034] Fourthly, this disclosure provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the NandFlash data storage method described in this disclosure.
[0035] In some implementations, a random access memory (RAM) partition is used as a data interaction area. Intermediate process data for reading and writing with the application is buffered and stored in the RAM partition. Data in the data directory of the RAM partition is stored in the file system area of the NandFlash at preset intervals. This reduces the frequency of writing to the file system area of the NandFlash, avoids wear and tear on the NandFlash caused by frequent erase and write operations, and improves the lifespan of the NandFlash.
[0036] Brief description of the attached figures
[0037] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0038] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, those skilled in the art can obtain other drawings based on these drawings without creative effort.
[0039] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.
[0040] Figure 1 is a system architecture diagram of a NandFlash data storage method provided in an embodiment of this disclosure;
[0041] Figure 2 is a flowchart illustrating a NandFlash data storage method according to an embodiment of this disclosure;
[0042] Figure 3 is a schematic diagram of NandFlash and RAM mapping provided in an embodiment of this disclosure;
[0043] Figure 4 is a schematic diagram of data copying provided in an embodiment of this disclosure;
[0044] Figure 5 is a schematic diagram of reading and writing data between an application and an embodiment of this disclosure;
[0045] Figure 6 is a schematic diagram of the data directory storage provided in an embodiment of this disclosure;
[0046] Figure 7 is a schematic diagram of the structure of a NandFlash data storage device provided in an embodiment of the present disclosure; and
[0047] Figure 8 is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure.
[0048] Detailed Explanation
[0049] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this disclosure. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0050] The following disclosure provides numerous different embodiments or examples for implementing various structures of this disclosure. To simplify this disclosure, specific examples of components and arrangements are described below. Of course, these are merely examples and are not intended to limit the scope of this disclosure. Furthermore, reference numerals and / or letters may be repeated in different examples. Such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.
[0051] This disclosure provides a NandFlash data storage method, apparatus, electronic device, and storage medium, which can reduce the writing frequency to the NandFlash file system area, avoid wear and tear on the NandFlash caused by frequent erase and write operations, and improve the lifespan of the NandFlash.
[0052] The first embodiment of this disclosure provides a NandFlash data storage method, which can be applied to the system architecture shown in Figure 1. This system architecture (also referred to as the system) includes at least a NandFlash 101 and a random access memory partition 102. NandFlash can also be called a NandFlash chip, and the random access memory partition is RAM (Random Access Memory). RAM is internal memory that does not retain data when the system loses power. Specifically, this system architecture can be a terminal device, such as a desktop computer, tablet computer, laptop, supercomputer, etc., or a communication module with computing and storage functions, etc., without limitation.
[0053] In some implementations, the NandFlash data storage method is described in detail based on the system architecture, as shown in Figure 2. The NandFlash data storage method includes:
[0054] Step 201: Map the data directory in the random access memory partition;
[0055] Step 202: Copy the data from the NandFlash file system area to the data directory of the random access memory partition; wherein, the data in the data directory is used for interactive reading and writing of data with the application; and
[0056] Step 203: At preset intervals, store the data in the current data directory to the file system area of NandFlash.
[0057] In some implementations, in the initial state of the system, a region in RAM can be mapped as a data directory, and a first storage area is allocated in NandFlash; the first storage area is configured as a file system area, which can be a usrfs partition of a Linux system.
[0058] In some implementations, before allocating a first storage area in the NandFlash, the method further includes: determining whether a target file system area exists in the NandFlash; if the target file system area does not exist in the NandFlash, then allocating a first storage area in the NandFlash; configuring the first storage area as a file system area; if the target file system area exists in the NandFlash, then using the target file system area as a file system area.
[0059] In some implementations, before allocating a first storage area in the NandFlash, it can be determined whether a usrfs partition already exists in the NandFlash. If it exists, the usrfs partition can be used as a file system area. If it does not exist, a first storage area can be allocated in the NandFlash and configured as a file system area, thereby avoiding additional partitioning.
[0060] In some implementations, mapping a data directory in a random access memory partition includes: partitioning a second storage area within the random access memory partition when it is determined that the random access memory partition has been powered on again; and mapping the data directory in the second storage area.
[0061] In some implementations, since RAM does not retain data when power is lost, a data directory can be mapped into the RAM when power is restored. Specifically, a second storage area can be allocated in the RAM, and the data directory can be mapped into this second storage area. The second storage area can be a portion of the RAM's storage area or the entire RAM storage area; there are no restrictions.
[0062] In some implementations, copying the data from the NandFlash usrfs partition to the data directory in RAM allows the data directory to serve as a data exchange area for reading and writing data with the application. This avoids erasing and writing data to the NandFlash every time it interacts with the application, reducing wear and tear on the NandFlash.
[0063] In some implementations, copying data from the file system area of the NandFlash to the data directory of the random access memory partition includes: copying the data from the file system area of the NandFlash to the data directory after determining that the random access memory partition has been powered on again and the random access memory partition has completed mapping the data directory.
[0064] In some implementations, since RAM does not retain data when it loses power, the mapped data directory will also be lost after RAM loses power. Therefore, when it is determined that RAM has been powered on again and the data directory has been remapped, the data of the NandFlash usrfs partition is copied to the data directory of RAM. This ensures that the data in the data directory, which serves as the data interaction area, is consistent with the data in the NandFlash usrfs partition, so that the application can interact with the data in the data directory to read and write data.
[0065] In some implementations, a random access memory (RAM) partition is used as a data interaction area. Intermediate process data for reading and writing with the application is buffered and stored in the RAM partition. Data in the data directory of the RAM partition is stored in the file system area of the NandFlash at preset intervals. This reduces the frequency of writing to the file system area of the NandFlash, avoids wear and tear on the NandFlash caused by frequent erase and write operations, and improves the lifespan of the NandFlash.
[0066] In some implementations, to ensure that the data in the current data directory has changed by the time the data is stored in the NandFlash file system area after each preset time interval, thus avoiding unnecessary storage of data in the data directory that has not changed but has been stored for the preset time interval, storage can be performed only after it is determined that the data in the data directory has been updated.
[0067] In some implementations, data in the current data directory is stored in the file system area of NandFlash at preset intervals, including: starting a timer when it is determined that the data in the data directory has been updated; after the timer has run for the preset time, storing the data in the current data directory in the file system area of NandFlash and resetting the timer.
[0068] In some implementations, when a data update in the data directory is detected, a timer can be started. The timer can count down or count forward without restriction. Data updates in the data directory that occur after the timer has started will not reset the timer. Instead, the timer will only reset after the preset timeout period has elapsed, when the data in the current data directory is stored in the NandFlash file system area. This avoids the situation where, during system standby, data in the data directory is stored in the NandFlash file system area at preset intervals.
[0069] In some implementations, the NandFlash data storage method includes:
[0070] Step S1, initial system state, as shown in Figure 3, map a block of NandFlash as a usrfs partition, and map a block of RAM as a data directory;
[0071] Step S2: Since RAM does not retain data when it loses power, when the device is powered on, as shown in Figure 4, the data of the usrfs partition is first copied to the data directory.
[0072] Step S3, when applying data read / write, as shown in Figure 5, reads and writes data in the data directory of the RAM partition; and
[0073] Step S4: After the data in the data directory is updated, and after a specified period of time, as shown in Figure 6, the data in the data directory is saved to NandFlash.
[0074] In some implementations, RAM is used as a data exchange area to buffer and store intermediate process data during reading and writing. This reduces the frequency of writing to the system file area of the NandFLash chip, improves the chip's read and write speed, balances chip wear, and extends the lifespan of the NandFLash.
[0075] The second embodiment of this disclosure provides a NandFlash data storage device, as shown in FIG7, the device comprising:
[0076] Mapping module 701 is configured to map a data directory in a random access memory partition;
[0077] Copy module 702 is configured to copy data from the file system area of the NandFlash to the data directory of the random access memory partition; wherein the data in the data directory is used for interactive reading and writing of data with the application; and
[0078] Storage module 703 is configured to store the data in the current data directory to the file system area of NandFlash at preset intervals.
[0079] In some implementations, a random access memory (RAM) partition is used as a data interaction area. Intermediate process data for reading and writing with the application is buffered and stored in the RAM partition. Data in the data directory of the RAM partition is stored in the file system area of the NandFlash at preset intervals. This reduces the frequency of writing to the file system area of the NandFlash, avoids wear and tear on the NandFlash caused by frequent erase and write operations, and improves the lifespan of the NandFlash.
[0080] As shown in Figure 8, this embodiment of the present disclosure provides an electronic device, including a processor 111, a communication interface 112, a memory 113, and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.
[0081] Memory 113 is configured to store computer programs;
[0082] When processor 111 is configured to execute a program stored in memory 113, it implements a NandFlash data storage method, which includes:
[0083] Map data directories in the random access memory partition;
[0084] Data from the NandFlash file system area is copied to the data directory of the random access memory partition; wherein, the data in the data directory is used for interactive reading and writing of data with the application; and
[0085] At preset intervals, the data in the current data directory is stored in the file system area of NandFlash.
[0086] In some implementations, the communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the figure, but this does not indicate that there is only one bus or one type of bus.
[0087] The communication interface is configured for communication between the aforementioned terminal and other devices.
[0088] In some embodiments, the memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0089] In some implementations, the processor mentioned above can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0090] This disclosure also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the NandFlash data storage method described in this disclosure.
[0091] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0092] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software plus a general-purpose hardware platform, or of course, using hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0093] It should be understood that the terminology used herein is for the purpose of describing particular exemplary embodiments only and is not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms “a,” “an,” and “described” as used herein may also include the plural forms. The terms “comprising,” “including,” “containing,” and “having” are inclusive and therefore indicate the presence of the stated features, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, elements, components, and / or combinations thereof. The method steps, processes, and operations described herein are not construed as requiring them to be performed in a particular order described or illustrated unless the order of performance is explicitly indicated. It should also be understood that additional or alternative steps may be used.
[0094] It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this disclosure. In the description, suffixes such as “module,” “part,” or “unit” used to denote elements are used solely for illustrative purposes and have no specific meaning in themselves. Therefore, “module,” “part,” or “unit” may be used interchangeably.
[0095] The above description is merely a specific embodiment of this disclosure, enabling those skilled in the art to understand or implement it. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this disclosure. Therefore, this disclosure is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. NandFlash data storage methods, including: Map data directories in the random access memory partition; Data from the NandFlash file system area is copied to the data directory of the random access memory partition; wherein, the data in the data directory is used for interactive reading and writing of data with the application; and At preset intervals, the data in the current data directory is stored in the file system area of NandFlash.
2. The NandFlash data storage method as described in claim 1, wherein before copying the data from the NandFlash file system area to the data directory of the random access memory partition, the method further includes: Allocate a first storage area in the NandFlash; as well as Configure the first storage area as the file system area.
3. The NandFlash data storage method as described in claim 1 or 2, wherein mapping a data directory in a random access memory partition includes: If it is determined that the random access memory partition has been powered on again, a second memory area is allocated in the random access memory partition; as well as The data directory is mapped in the second storage area.
4. The NandFlash data storage method as described in claim 3, wherein the second storage area is the random access memory partition.
5. The method according to any one of claims 1 to 4, wherein copying data from the file system area of the NandFlash to the data directory of the random access memory partition comprises: Once it is determined that the random access memory partition has been powered on again and the data directory mapping of the random access memory partition has been completed, the data of the file system area of the NandFlash is copied to the data directory.
6. The NandFlash data storage method according to any one of claims 1 to 5, wherein at preset time intervals, the data in the current data directory is stored in the NandFlash file system area, comprising: If it is determined that the data in the data directory has been updated, a timer will be started. as well as After the timer has elapsed for a preset duration, the data in the current data directory is stored in the file system area of NandFlash, and the timer is reset.
7. The NandFlash data storage method according to any one of claims 2 to 6, wherein before allocating a first storage area in the NandFlash, the NandFlash data storage method further includes: Determine if the target file system area exists in the NandFlash; If the target file system area does not exist in the NandFlash, then a first storage area will be allocated in the NandFlash. The step of configuring the first storage area as the file system area; If a target file system area exists in the NandFlash, then the target file system area will be used as the file system area.
8. A NandFlash data storage device, comprising: The mapping module is configured to map data directories in random access memory partitions; The copy module is configured to copy data from the file system area of the NandFlash to the data directory of the random access memory partition; wherein the data in the data directory is used for interactive reading and writing of data with the application. as well as The storage module is configured to store the data in the current data directory to the file system area of NandFlash at preset intervals.
9. An electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein, The processor, the communication interface, and the memory communicate with each other via the communication bus; The memory is configured to store computer programs; When the processor is configured to execute a program stored in the memory, it implements the NandFlash data storage method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the NandFlash data storage method of any one of claims 1 to 7.
Citation Information
Patent Citations
Flash memory device and management system and method thereof
CN101727395A
Method for preventing flash subarea from being frequently read and written
CN103729302A
Method and system for storing data in screen end plate of modular television
CN105812891A
Processing method and device of cache data and terminal
CN107861886A
NandFlash data storage method and device, electronic equipment and storage medium
CN119336656A