NandFlash data storage method and device, electronic equipment and storage medium
By using the random access memory partition in the NANDFLASH storage device as the data interactive area, the read -write data of the buffer storage storage and the application interacts with the application, and the data is stored to NANDFLASH after the preset period. The problem improves the service life of the equipment.
Patent Information
- Application Number
- CN202411458506.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-17
- Publication Date
- 2025-01-21
AI Technical Summary
The existing NandFlash storage devices have increased wear and a short service life due to frequent erasing and writing operations.
By mapping the data directory in the random access memory partition, the data in the file system area of NandFlash is copied to the data directory in the random access memory partition, and the data in the data directory is stored in the file system area of NandFlash after a preset period of time.
It reduces the frequency of writing to the NandFlash file system area, avoids the wear and tear on NandFlash caused by frequent erasing and writing, and improves the service life of NandFlash.
Smart Images

Figure CN119336656A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data storage, and in particular to a NandFlash data storage method, device, electronic device and storage medium. Background Art
[0002] The life of NandFlash is limited to its read and write times. Continuously writing and erasing the same storage unit will more easily cause permanent damage to the storage unit. At present, in order to avoid this situation, a wear-leveling algorithm is used in NandFlash storage. This algorithm evenly distributes the erase / write cycles to all storage units of NandFlash, thus avoiding continuous erase / write operations on the same storage unit. However, since the wear-leveling algorithm spreads the erase / write operations evenly across all blocks, if the data on all blocks is frequently updated, the wear-leveling operation will increase the system load and also increase the wear of the entire system, which is not conducive to improving the service life of NandFlash. Summary of the invention
[0003] The present application provides a NandFlash data storage method, device, electronic device and storage medium to solve the problem of how to improve the service life of NandFlash.
[0004] In a first aspect, the present application provides a NandFlash data storage method, the method comprising:
[0005] Mapping data directories in random access memory partitions;
[0006] Copying the data in the file system area of NandFlash to the data directory of the random access memory partition; wherein the data in the data directory is used to read and write data interactively with the application program;
[0007] At intervals of a preset time, the data in the current data directory is stored in the file system area of NandFlash.
[0008] Optionally, before copying the data of the file system area of NandFlash to the data directory of the random access memory partition, the method further includes:
[0009] A first storage area is allocated in NandFlash;
[0010] The first storage area is configured as the file system area.
[0011] Optionally, map the data directory in a random access memory partition, including:
[0012] In the case where it is determined that the random access memory partition is powered on again, a second storage area is divided in the random access memory partition;
[0013] The data directory is mapped in the second storage area.
[0014] Optionally, the second storage area is the random access memory partition.
[0015] Optionally, copying the data of the file system area of NandFlash to the data directory of the random access memory partition includes:
[0016] When it is determined that the random access memory partition is powered on again and the mapping of the random access memory partition to the data directory is completed, the data of the file system area of the NandFlash is copied to the data directory.
[0017] Optionally, storing the data in the current data directory to the file system area of NandFlash at a preset time interval includes:
[0018] When it is determined that the data in the data directory is updated, starting a timer;
[0019] After the timer counts for a preset period of time, the data in the current data directory is stored in the file system area of NandFlash, and the timer is reset.
[0020] Optionally, before allocating a first storage area in the NandFlash, the method further includes:
[0021] Determine whether the target file system area exists in NandFlash;
[0022] If the target file system area does not exist in the NandFlash, the steps of allocating a first storage area in the NandFlash and configuring the first storage area as the file system area are performed;
[0023] If the target file system area exists in NandFlash, the target file system area is used as the file system area.
[0024] In a second aspect, the present application provides a NandFlash data storage device, the device comprising:
[0025] A mapping module, used for mapping data directories in random access memory partitions;
[0026] A copy module, used to copy the data in the file system area of NandFlash to the data directory of the random access memory partition; wherein the data in the data directory is used to read and write data interactively with the application program;
[0027] The storage module is used to store the data in the current data directory into the file system area of NandFlash at intervals of a preset time.
[0028] In a third aspect, the present application 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 via the communication bus;
[0029] Memory, used to store computer programs;
[0030] The processor is used to implement the NandFlash data storage method described in any one of the embodiments of the first aspect when executing the program stored in the memory.
[0031] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the NandFlash data storage method as described in any one of the embodiments of the first aspect is implemented.
[0032] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the method provided by the embodiment of the present application maps the data directory in the random access memory partition; copies the data in the file system area of NandFlash to the data directory of the random access memory partition; wherein the data in the data directory is used to interact with the application to read and write data; at every preset time interval, the data in the current data directory is stored in the file system area of NandFlash. This method uses the random access memory partition as the data interaction area, buffers and stores the intermediate process data of interactive reading and writing with the application through the random access memory partition, and stores the data in the data directory of the random access memory partition in the file system area of NandFlash at a certain preset time interval, thereby reducing the writing frequency of the file system area of NandFlash, avoiding the wear of NandFlash caused by frequent erasing and writing, and improving the service life of NandFlash. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0035] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0036] Figure 1 A system architecture diagram of a NandFlash data storage method provided in one embodiment of the present application;
[0037] Figure 2 A flowchart of a NandFlash data storage method provided by an embodiment of the present application;
[0038] Figure 3 A schematic diagram of NandFlash and RAM mapping provided for an embodiment of the present application;
[0039] Figure 4 A schematic diagram of data replication provided for an embodiment of the present application;
[0040] Figure 5 A schematic diagram of reading and writing data between an application and an embodiment of the present application;
[0041] Figure 6 A schematic diagram of data directory storage provided for an embodiment of the present application;
[0042] Figure 7 A schematic diagram of the structure of a NandFlash data storage device provided in one embodiment of the present application;
[0043] Figure 8 A schematic diagram of the structure of an electronic device provided in accordance with an embodiment of the present application. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0045] The disclosure below provides many different embodiments or examples to implement the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0046] In order to solve the technical problem of how to improve the service life of NandFlash in the prior art, the present application provides a NandFlash data storage method, device, electronic device and storage medium, which can reduce the writing frequency to the file system area of NandFlash, avoid the wear of NandFlash caused by frequent erasing and writing, and improve the service life of NandFlash.
[0047] The first embodiment of the present application provides a NandFlash data storage method, which can be applied to Figure 1 The system architecture shown in the figure, the system architecture (also referred to as the system) includes at least NandFlash 101 and random access memory partition 102. NandFlash can also be called NandFlash chip, and the random access memory partition is RAM (Random Access Memory). RAM is an internal memory that does not save data when the system is powered off. Specifically, the system architecture can be a terminal device, such as a desktop computer, a tablet computer, a notebook, a supercomputer, etc., or a communication module with computing and storage functions, etc., without limitation.
[0048] Next, the NandFlash data storage method is described in detail based on the system architecture. Figure 2 , the NandFlash data storage method comprises:
[0049] Step 201, mapping a data directory in a random access memory partition.
[0050] In the initial state of the system, an area can be mapped in the RAM as a data directory (data directory), and a first storage area can be divided in the NandFlash; the first storage area is configured as a file system area, and the file system area can be a usrfs partition of the Linux system.
[0051] In one embodiment, before allocating a first storage area in NandFlash, the method also includes: determining whether a target file system area exists in NandFlash; if the target file system area does not exist in NandFlash, executing the step of allocating a first storage area in NandFlash; configuring the first storage area as a file system area; if the target file system area exists in NandFlash, using the target file system area as the file system area.
[0052] In this embodiment, before allocating a first storage area in NandFlash, it can be first determined whether a usrfs partition already exists in NandFlash. If so, the usrfs partition can be used as a file system area. If not, a first storage area is allocated in NandFlash and the first storage area is configured as a file system area, thereby avoiding additional partition division.
[0053] In one embodiment, mapping a data directory in a random access memory partition includes: when it is determined that the random access memory partition is powered on again, dividing a second storage area in the random access memory partition; and mapping the data directory in the second storage area.
[0054] In this embodiment, since the RAM does not save data when it is powered off, the data directory can be mapped in the RAM when the RAM is powered on again. Specifically, a second storage area can be divided in the RAM, and the data directory can be mapped in the second storage area. Specifically, the second storage area can be a part of the storage area of the RAM, or the entire storage area of the RAM, without limitation.
[0055] Step 202, copy the data in the file system area of NandFlash to the data directory of the random access memory partition; wherein the data in the data directory is used to interact with the application program to read and write data.
[0056] Copy the data of the usrfs partition of NandFlash to the data directory of RAM. The data directory can be used as a data exchange area for reading and writing data with the application, thereby avoiding erasing and writing of NandFlash every time it interacts with the application to read and write data, reducing the wear on NandFlash.
[0057] In one embodiment, copying data of the file system area of NandFlash to the data directory of the random access memory partition includes: when it is determined that the random access memory partition is powered on again and the random access memory partition mapping of the data directory is completed, copying data of the file system area of NandFlash to the data directory.
[0058] In this embodiment, since the RAM does not save data when it is powered off, the mapped data directory will also be lost after the RAM is powered off. Therefore, when it is determined that the RAM is powered on again and the RAM remapping of the data directory is completed, the data of the usrfs partition of NandFlash is copied to the data directory of the RAM to ensure that the data in the data directory as the data interaction area is consistent with the data in the usrfs partition of NandFlash, so that data can be interacted with the application to read and write data through the data in the data directory.
[0059] Step 203: at every preset time interval, store the data in the current data directory into the file system area of NandFlash.
[0060] The method uses a random access memory partition as a data interaction area, buffers and stores intermediate process data of interactive reading and writing with an application program through the random access memory partition, and stores data in a data directory of the random access memory partition in a file system area of NandFlash at certain preset time intervals, thereby reducing the writing frequency to the file system area of NandFlash, avoiding the wear of NandFlash caused by frequent erasing and writing, and prolonging the service life of NandFlash.
[0061] To ensure that the data in the current data directory has changed when it is stored in the file system area of NandFlash after each preset time interval, that is, to avoid unnecessary storage of data in the data directory that has not changed but has reached the preset time, the data in the data directory can be stored after it is determined that the data has been updated.
[0062] In one embodiment, data in the current data directory is stored in the file system area of NandFlash at intervals of a preset duration, including: when it is determined that the data in the data directory is updated, a timer is started; after the timer has counted for the preset duration, the data in the current data directory is stored in the file system area of NandFlash, and the timer is reset.
[0063] In this embodiment, when it is determined that the data in the data directory is updated, a timer can be started, and the timer can count down or count up without restriction. The data update in the data directory that occurs after the timer is started will not reset the timer, but after the timer counts for a preset time, the data in the current data directory is stored in the file system area of NandFlash, and then the timer is reset, thereby avoiding the situation where the data in the data directory is stored in the file system area of NandFlash every preset time interval when the system is in standby.
[0064] In a specific embodiment, the NandFlash data storage method includes:
[0065] Step S1, system initial state, such as Figure 3 , map a piece of NandFlash to store as the usrfs partition, and map a piece of RAM to the data directory.
[0066] Step S2: Since RAM does not save data when power is off, when the computer is powered on, Figure 4 , first copy the data of the usrfs partition to the data directory.
[0067] Step S3, when the application reads and writes data, Figure 5 , read and write data in the data directory of the RAM partition.
[0068] Step S4: After the data in the data directory is updated, after a specified time has passed, Figure 6 , save the data in the data directory to NandFlash.
[0069] This method uses RAM as a data exchange area to buffer and store intermediate process data in the reading and writing process through RAM, thereby reducing the writing frequency to the system file area of the NandFLash chip, improving the reading and writing speed of the chip, and at the same time balancing the wear of the chip and extending the service life of the NandFLash.
[0070] Based on the same technical concept, the second embodiment of the present application provides a NandFlash data storage device, such as Figure 7 , the device comprises:
[0071] A mapping module 701, used for mapping data directories in random access memory partitions;
[0072] A copy module 702 is used to copy the data in the file system area of NandFlash to the data directory of the random access memory partition; wherein the data in the data directory is used to read and write data interactively with the application program;
[0073] The storage module 703 is used to store the data in the current data directory into the file system area of NandFlash at intervals of a preset time.
[0074] The device uses a random access memory partition as a data interaction area, buffers and stores intermediate process data of interactive reading and writing with an application program through the random access memory partition, and stores data in a data directory of the random access memory partition in a file system area of NandFlash at certain preset time intervals, thereby reducing the writing frequency to the file system area of NandFlash, avoiding the wear of NandFlash caused by frequent erasing and writing, and increasing the service life of NandFlash.
[0075] like Figure 8 As shown, an embodiment of the present application 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.
[0076] Memory 113, used for storing computer programs;
[0077] In one embodiment of the present application, the processor 111 is used to execute the program stored in the memory 113 to implement the NandFlash data storage method provided by any of the above method embodiments, including:
[0078] Mapping data directories in random access memory partitions;
[0079] Copying the data in the file system area of NandFlash to the data directory of the random access memory partition; wherein the data in the data directory is used to read and write data interactively with the application program;
[0080] At intervals of a preset time, the data in the current data directory is stored in the file system area of NandFlash.
[0081] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0082] The communication interface is used for communication between the above terminal and other devices.
[0083] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0084] The above-mentioned processor 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, discrete hardware components.
[0085] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the NandFlash data storage method provided by any of the aforementioned method embodiments is implemented.
[0086] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0087] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0088] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.
[0089] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application. In the description, the suffixes such as "module", "component" or "unit" used to represent the elements are only used to facilitate the description of the present application and have no specific meaning in themselves. Therefore, "module", "component" or "unit" can be used in a mixed manner.
[0090] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.
Claims
1. A NandFlash data storage method, characterized in that: The method comprises: Mapping data directories in random access memory partitions; Copying the data in the file system area of NandFlash to the data directory of the random access memory partition; wherein the data in the data directory is used to read and write data interactively with the application program; At intervals of a preset time, the data in the current data directory is stored in the file system area of NandFlash.
2. The method according to claim 1, characterized in that: Before copying the data of the file system area of NandFlash to the data directory of the random access memory partition, the method further comprises: A first storage area is allocated in NandFlash; The first storage area is configured as the file system area.
3. The method according to claim 1, characterized in that Map data directories in random access memory partitions, including: In the case where it is determined that the random access memory partition is powered on again, a second storage area is divided in the random access memory partition; The data directory is mapped in the second storage area.
4. The method according to claim 3, characterized in that The second storage area is the random access memory partition.
5. The method according to claim 1, characterized in that: Copying the data of the file system area of NandFlash to the data directory of the random access memory partition includes: When it is determined that the random access memory partition is powered on again and the mapping of the random access memory partition to the data directory is completed, the data of the file system area of the NandFlash is copied to the data directory.
6. The method according to claim 1, characterized in that At each preset time interval, the data in the current data directory is stored in the file system area of NandFlash, including: When it is determined that the data in the data directory is updated, starting a timer; After the timer counts for a preset period of time, the data in the current data directory is stored in the file system area of NandFlash, and the timer is reset.
7. The method according to claim 2, characterized in that Before dividing a first storage area in the NandFlash, the method further includes: Determine whether the target file system area exists in NandFlash; If the target file system area does not exist in the NandFlash, the steps of allocating a first storage area in the NandFlash and configuring the first storage area as the file system area are performed; If the target file system area exists in NandFlash, the target file system area is used as the file system area.
8. A NandFlash data storage device, characterized in that: The device comprises: A mapping module, used for mapping data directories in random access memory partitions; A copy module, used to copy the data in the file system area of NandFlash to the data directory of the random access memory partition; wherein the data in the data directory is used to read and write data interactively with the application program; The storage module is used to store the data in the current data directory into the file system area of NandFlash at intervals of a preset time.
9. An electronic device, characterized in that: It includes 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; Memory, used to store computer programs; The processor is used to implement the NandFlash data storage method described in any one of claims 1 to 7 when executing the program stored in the memory.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the NandFlash data storage method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Data storage realizing method based on NOR FLASH chip
CN101118517A
Method, device and system for storing files
CN101577143A
Method for preventing flash subarea from being frequently read and written
CN103729302A
Data storage method and system based on Flash
CN104008065A
Cited By
Nandflash data storage method and apparatus, electronic device, and storage medium
WO2026081455A1