Non-volatile flash memory protection method and apparatus, electronic device, and storage medium

By mapping the frequently read/write partitions of non-volatile flash memory into memory and synchronizing the data under synchronous trigger events, the bad block problem caused by frequent erase/write operations of NOR FLASH is solved, improving read/write efficiency and extending flash memory lifespan.

CN118689392BActive Publication Date: 2026-03-10INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-30
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

The frequent erase and write operations of traditional NOR FLASH can cause irreversible physical bad blocks in the flash memory chip, affecting the normal operation of the device.

Method used

By identifying frequently read/write partitions in non-volatile flash memory, mapping them to memory, and synchronizing memory data to non-volatile flash memory under a synchronization trigger event, direct write operations to FLASH are reduced.

Benefits of technology

It improves data read and write efficiency, reduces the FLASH erase and write frequency, and extends the lifespan of flash memory.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118689392B_ABST
    Figure CN118689392B_ABST
Patent Text Reader

Abstract

The application provides a non-volatile flash memory protection method, device, system, server and medium, and relates to the technical field of computers, and the method comprises the following steps: identifying a frequently read and written partition in a non-volatile flash memory; mapping the frequently read and written partition to a memory when a device starts, so that read and write operations on the frequently read and written partition are converted into read and write operations on the memory; and in response to a synchronization trigger event, synchronizing data in the memory to the non-volatile flash memory. Since reading and writing the memory directly is more efficient than reading and writing the FLASH directly, the read and write efficiency of FLASH data is improved, and the write operation of the FLASH is only performed when the synchronization trigger event occurs, so that the erasing and writing frequency of the FLASH is reduced, and the service life of the FLASH is prolonged.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, and in particular to a non-volatile flash memory protection method and device, electronic equipment and storage medium. BACKGROUND

[0002] Flash EEPROM Memory (FLASH) is a kind of storage chip, and the data in it can be modified through a specific program. The modification of data involves the erasing of FLASH. FLASH can be divided into two specifications, namely, NAND FLASH and NOR FLASH. NAND FLASH is generally used for storing data, and the chip capacity is large, which can reach 2 Gb or even larger. NOR FLASH is generally used for storing program code, and microprocessors can directly read it, but the chip capacity is low. FLASH is erased in blocks, and each block has a certain limit on the number of erasures. The number of erasures of NOR FLASH is about 100,000 times, and the number of erasures of NAND FLASH is about 1,000,000 times. In traditional applications, the NOR FLASH in the baseboard management controller is only used for storing firmware, and a read-write operation is performed on the NOR FLASH when the device starts to load the firmware. As the baseboard management controller undertakes more and more business, more and more data needs to be accessed, and the data read-write is more and more frequent. Frequent read-write operations on the NOR FLASH chip will cause the FLASH chip to have irreversible physical bad blocks. During the operation of the device, the bad blocks of the FLASH may cause the loss of device information, abnormal restart of the device, and even direct failure of the device to run due to damage to the internal image of the device. SUMMARY

[0003] The present application provides a non-volatile flash memory protection method, device, electronic equipment and storage medium, which solves the problem that the traditional NOR FLASH lacks protection measures, frequent read-write operations cause the service life of the FLASH to be shortened or bad blocks to appear, and affects the normal operation of the device.

[0004] The present application provides a non-volatile flash memory protection method, which comprises the following steps:

[0005] Identifying a frequently read-write partition in the non-volatile flash memory, and mapping the frequently read-write partition to the memory when the device starts, so that the read-write operation on the frequently read-write partition is converted to a read-write operation on the memory.

[0006] In response to a synchronization trigger event, synchronizing the data in the memory to the non-volatile flash memory.

[0007] According to the non-volatile flash memory protection method provided by the present application, the step of synchronizing the data in the memory to the non-volatile flash memory in response to a synchronization trigger event comprises the following steps:

[0008] The synchronization trigger event is when the device is normally powered off or restarted, the data in the memory is synchronized to the non-volatile flash memory; the synchronization trigger event is when the device is abnormally restarted, a data synchronization flag is obtained, and when the data synchronization flag is a first preset value, the data in the memory is synchronized to the non-volatile flash memory.

[0009] According to a non-volatile flash memory protection method provided by the present invention, the step of synchronizing the data in the memory to the non-volatile flash memory in response to a synchronization trigger event further includes:

[0010] During the bootloader phase, the data synchronization flag is obtained. If the data synchronization flag is a first preset value, the data in memory is synchronized to the non-volatile flash memory. If the data synchronization flag is set to a second preset value, the data synchronization flag is synchronized to the non-volatile memory.

[0011] Determine if the external power supply is normal. If so, proceed to the system kernel loading stage; otherwise, control the baseboard management controller to stop service operation.

[0012] During the system kernel loading stage, if the baseboard management controller is normally powered off or restarted, the frequently read / write partition is mapped into memory, so that the read / write operations on the frequently read / write partition of the non-volatile flash memory are converted into read / write operations on memory during the operation of the baseboard management controller; at the same time, the data is synchronously marked to a first preset value and synchronously marked into the non-volatile memory.

[0013] When the baseboard management controller restarts abnormally, the memory data is written into the non-volatile flash memory, the data synchronization flag is set to the second preset value, and the data synchronization flag is synchronized to the non-volatile memory.

[0014] According to a non-volatile flash memory protection method provided by the present invention, when the external power supply is abnormal, it further includes: supplying power to the substrate management controller and the memory through a supercapacitor.

[0015] According to a non-volatile flash memory protection method provided by the present invention, after mapping the frequently read / write partition into memory, the method further includes:

[0016] The data in the frequently read / write partition is read into memory. After the memory detects the read data, it creates a temporary memory file system and mounts the read data into the memory file system.

[0017] According to a non-volatile flash memory protection method provided by the present invention, before mapping the frequently read / write partition to memory, the method further includes:

[0018] The non-volatile flash memory in the read / write destination address parameter of the baseboard management controller's file read / write program is rewritten to memory.

[0019] According to a non-volatile flash memory protection method provided by the present invention, the identification of frequently read / write partitions in the non-volatile flash memory includes:

[0020] Obtain the identifier or address of the preset configuration information storage partition, and designate the partition corresponding to the identifier or address of the preset configuration information storage partition as the frequently read / write partition;

[0021] And / or, obtain the identifier or address of the preset log information storage partition, and designate the partition corresponding to the identifier or address of the preset log information storage partition as the frequently read / write partition.

[0022] The present invention also provides a non-volatile flash memory protection device, comprising:

[0023] The data mapping service module is used to identify frequently read / write partitions in non-volatile flash memory. When the device starts up, the frequently read / write partitions are mapped to memory so that read / write operations on the frequently read / write partitions are converted into read / write operations on memory.

[0024] The data synchronization service module is used to synchronize the data in the memory to the non-volatile flash memory in response to a synchronization trigger event.

[0025] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the non-volatile flash memory protection method as described in any of the preceding claims.

[0026] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the non-volatile flash memory protection method described in any of the preceding claims.

[0027] The non-volatile flash memory protection method, apparatus, electronic device, and storage medium provided by this invention identify frequently read / write partitions in the non-volatile flash memory. Upon device startup, these frequently read / write partitions are mapped into memory, transforming read / write operations on the frequently read / write partitions into read / write operations on the memory. In response to a synchronization trigger event, data in the memory is synchronized to the non-volatile flash memory. Since directly reading / writing to memory is more efficient than directly reading / writing to the flash memory, the efficiency of reading / writing flash data is improved. Furthermore, since write operations to the flash memory are only performed when a synchronization trigger event occurs, the flash memory erase / write frequency is reduced, extending the flash memory's lifespan. Attached Figure Description

[0028] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0029] Figure 1 This is a flowchart illustrating the non-volatile flash memory protection method provided in an embodiment of the present invention;

[0030] Figure 2 This is a data mapping diagram provided in an embodiment of the present invention;

[0031] Figure 3 This is a data synchronization diagram provided in an embodiment of the present invention;

[0032] Figure 4 This is a schematic diagram of the bootloader stage workflow provided in an embodiment of the present invention;

[0033] Figure 5 This is a schematic diagram of the system kernel operation phase workflow provided in an embodiment of the present invention;

[0034] Figure 6 This is a functional structure diagram of the non-volatile flash memory protection device provided in an embodiment of the present invention;

[0035] Figure 7 This is a functional structure diagram of the electronic device provided in an embodiment of the present invention. Detailed Implementation

[0036] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention 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 invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0037] Figure 1 A flowchart of a non-volatile flash memory protection method provided in an embodiment of the present invention is shown below. Figure 1 As shown, the non-volatile flash memory protection method provided in this embodiment of the invention includes:

[0038] Step 101: Identify frequently read / write partitions in the non-volatile flash memory. When the device starts up, map the frequently read / write partitions into memory so that read / write operations on the frequently read / write partitions are converted into read / write operations on memory.

[0039] In this embodiment of the invention, the non-volatile flash memory includes NOR flash memory, and the frequent read / write partition is determined based on the product lifespan and the maximum daily access volume of the partition. For example, if the product lifespan is 5 years and the daily access volume of the partition exceeds 55 times, then the partition is defined as the frequent read / write partition.

[0040] Step 102: In response to the synchronization trigger event, synchronize the data in the memory to the non-volatile flash memory.

[0041] In traditional baseboard management controllers, the NOR flash memory is only used to store firmware, and a single read / write operation is performed when the device boots up and loads the firmware. As the baseboard management controller handles more and more tasks, the amount of data that needs to be accessed also increases, and the data read / write operations become more frequent. Frequent erase / write operations on the NOR flash memory chip can lead to irreversible physical bad blocks in the flash memory chip. During device operation, bad blocks in the flash memory may cause data loss, abnormal device restarts, or even damage to the internal image of the device, rendering it completely inoperable.

[0042] The non-volatile flash memory protection method provided in this invention identifies frequently read / write partitions in the non-volatile flash memory. During device startup, these frequently read / write partitions are mapped into memory, transforming read / write operations on the partitions into read / write operations on the memory. In response to a synchronization trigger event, data in the memory is synchronized to the non-volatile flash memory. Since directly reading / writing to memory is more efficient than directly reading / writing to the flash memory, the efficiency of reading and writing flash data is improved. Furthermore, since write operations to the flash memory are only performed when a synchronization trigger event occurs, the flash memory erase / write frequency is reduced, extending the flash memory's lifespan.

[0043] Based on any of the above embodiments, identifying frequently read / write partitions in non-volatile flash memory includes:

[0044] Obtain the identifier or address of the preset configuration information storage partition, and designate the partition corresponding to the identifier or address of the preset configuration information storage partition as the frequently read / write partition;

[0045] And / or, obtain the identifier or address of the preset log information storage partition, and designate the partition corresponding to the identifier or address of the preset log information storage partition as the frequently read / write partition.

[0046] Non-volatile flash memory is typically divided into multiple partitions before use, each potentially for a different purpose (e.g., bootloader, operating system, user data, etc.). Partition information is usually stored in a structure called a partition table. During system startup, this partition table is read to determine the location and size of each partition. When an application requests access to a file, the file system uses its internal records to find the file's physical address and issues read / write commands to the flash memory via the driver. Alternatively, each partition can be pre-defined with a unique identifier, allowing for the identification of frequently accessed partitions.

[0047] In some embodiments of the present invention, the NOR FLASH includes multiple partitions, namely, a system boot file partition (boot partition), a configuration information storage partition (CONF partition), a log information storage partition (LOG partition), a recovery partition for the pre-installed computer system (OSIMAGE partition), and a root file system analysis partition (ROOTFS partition), etc. After identifying the frequently read and written partitions in the non-volatile flash memory, the contents of the frequently read and written FLASH partitions are read and written to the memory file. For example, the frequently read and written partitions in the baseboard management controller are the CONF partition and the LOG partition; the CONF partition stores the configuration information of the baseboard management controller; the LOG partition stores the logs generated during the operation of the baseboard management controller; therefore, these two partitions can be read and written to memory during the boot process, such as... Figure 2 As shown.

[0048] When the device is powered off, restarted, or loses power, the CONF and LOG contents in memory need to be written back to the CONF and LOG partitions of the NOR FLASH. Figure 3 As shown.

[0049] Based on any of the above embodiments, the non-volatile flash memory protection method provided by the present invention includes:

[0050] Step 201: Change the non-volatile flash memory in the read / write destination address parameter of the baseboard management controller to memory;

[0051] Step 202: Identify frequently read / write partitions in the non-volatile flash memory, and map the frequently read / write partitions into memory when the device starts up;

[0052] Step 203: Read the data in the frequently read / write partition into memory. After detecting the read data, the memory creates a temporary memory file system and mounts the read data into the memory file system, so that the read / write operation on the frequently read / write partition is converted into a read / write operation on memory.

[0053] In this embodiment of the invention, FLASH partitions, such as areas storing configuration data, logs, or temporary files, may be frequently read and written. To reduce direct read and write operations to FLASH, this frequently accessed data can be read into memory. Memory (RAM) read and write speeds are generally much faster than FLASH. Once the data is read into memory, a temporary file system can be created in memory. The memory file system can be used like a regular disk file system, but all read and write operations are actually performed in memory. From the user's or application's perspective, they may not realize that the data is actually in memory rather than on FLASH. This is because the memory file system and the physical file system provide similar interfaces and functionalities. However, from a system and performance perspective, read and write operations on memory files are significantly faster than read and write operations on FLASH. This is because the latency of memory access is much lower than the latency of FLASH access.

[0054] Furthermore, reducing read and write operations on the FLASH memory can extend its lifespan, because the number of write operations on the FLASH memory is limited, and therefore the number of times each storage unit can be written is limited.

[0055] Based on any of the above embodiments, the step of synchronizing the data in memory to the non-volatile flash memory in response to a synchronization trigger event includes:

[0056] The synchronization trigger event is when the device is normally powered off or restarted, the data in the memory is synchronized to the non-volatile flash memory; the synchronization trigger event is when the device is abnormally restarted, a data synchronization flag is obtained, and when the data synchronization flag is a first preset value, the data in the memory is synchronized to the non-volatile flash memory.

[0057] In this embodiment of the invention, the data synchronization flag indicates whether memory data needs to be synchronized to NOR FLASH; the data synchronization flag is stored in a non-volatile memory, such as EEPROM; 0: indicates that memory data does not need to be synchronized to FLASH; 1: indicates that memory data needs to be synchronized to FLASH.

[0058] In some embodiments of the present invention, the step of synchronizing the data in memory to the non-volatile flash memory in response to a synchronization trigger event further includes:

[0059] During the bootloader phase, the data synchronization flag is obtained. If the data synchronization flag is a first preset value, the data in memory is synchronized to the non-volatile flash memory. If the data synchronization flag is set to a second preset value, the data synchronization flag is synchronized to the non-volatile memory.

[0060] Determine if the external power supply is normal. If so, proceed to the system kernel loading stage; otherwise, control the baseboard management controller to stop service operation.

[0061] During the system kernel loading stage, if the baseboard management controller is normally powered off or restarted, the frequently read / write partition is mapped into memory, so that the read / write operations on the frequently read / write partition of the non-volatile flash memory are converted into read / write operations on memory during the operation of the baseboard management controller; at the same time, the data is synchronously marked to a first preset value and synchronously marked into the non-volatile memory.

[0062] When the baseboard management controller restarts abnormally, the memory data is written into the non-volatile flash memory, the data synchronization flag is set to the second preset value, and the data synchronization flag is synchronized to the non-volatile memory.

[0063] In this embodiment of the invention, the workflow of the bootloader stage (uboot stage) is as follows: Figure 4 As shown, during a normal shutdown or restart in the system kernel phase, the baseboard management controller automatically copies the data from memory to FLASH and sets the data synchronization flag to 0. However, if the baseboard management controller restarts or resets abnormally during the system kernel phase, it will not perform the above operation. Therefore, the baseboard management controller needs to obtain the data synchronization flag during the bootloader phase. When the data synchronization flag is 1, the data in memory is copied to FLASH.

[0064] The system kernel runtime process is as follows: Figure 5 As shown, when the baseboard management controller reaches the system kernel running stage, it copies the FLASH partition that needs to be frequently read and written to into memory. During the operation of the baseboard management controller, the partition that is frequently read and written to NORFLASH is changed to the memory. The data synchronization flag is marked as 1 and stored in non-volatile memory. When the baseboard management controller restarts, shuts down, or experiences an external power failure, it writes the memory data to FLASH, marks the data synchronization flag as 0, and stores it in non-volatile memory to avoid data synchronization again during the bootloader stage.

[0065] Based on any of the above embodiments, when the external power supply malfunctions, the method further includes:

[0066] The baseboard management controller and the memory are powered by a farad capacitor.

[0067] The working principle of the added supercapacitor in the board management controller circuit is as follows: When the external power supply is normal, it can supply power to the supercapacitor; when the external power supply stops, the supercapacitor can release its stored electricity to supply power to the board management controller; the supercapacitor supplies power to the board management controller and memory through hardware; the supercapacitor can cycle hundreds of thousands of times, while the battery life is only a few hundred cycles; the supercapacitor can be charged quickly and has a relatively wide charging range; the supercapacitor can store more energy compared to a traditional capacitor of similar size; the battery is limited to operating within a narrow voltage range due to its own chemical reaction, and over-discharge may cause permanent damage.

[0068] After the external power supply is stopped, the baseboard management controller can work normally due to the presence of the supercapacitor. However, the purpose of adding the supercapacitor is to ensure that the memory data can be synchronized to the FLASH normally, not for the baseboard management controller to work. Therefore, the baseboard management controller needs to determine whether the external power supply is normal during the boot loading stage. When the external power supply is abnormal, the baseboard management controller will no longer perform subsequent operations.

[0069] The non-volatile flash memory protection method provided in this invention changes the process from directly reading and writing to FLASH to directly reading and writing to memory; this improves the read / write speed; directly reading and writing to memory is more efficient than directly reading and writing to FLASH; it reduces the FLASH erase / write frequency, extending the FLASH lifespan; it changes the process from reading and writing to FLASH every time to erasing and writing only during reboot and reset; it adds a data synchronization flag and a farad capacitor to power the baseboard management controller, ensuring that memory data can be written back to FLASH normally under any circumstances; in the data mapping service, the frequently read and written FLASH partition content is read and written to a memory file, and this file in memory is mounted as a memory file system; thus, the read / write operation of the memory file is no different from the read / write operation of FLASH; in the data synchronization service, there is its own data synchronization in the uboot and kernel stages, and the main function is the same, which is to write memory file data to NOR FLASH; the data mapping service maps FLASH data to memory, and the data synchronization service completes the copying of memory data back to FLASH. Data synchronization is achieved through data synchronization markers and farad capacitors, ensuring that memory data can be written back to FLASH normally under any circumstances, including when the baseboard management controller is reset or when the baseboard management controller is powered off.

[0070] The non-volatile flash memory protection device provided by the present invention is described below. The non-volatile flash memory protection device described below can be referred to in correspondence with the non-volatile flash memory protection method described above.

[0071] Figure 6This is a schematic diagram of a non-volatile flash memory protection device provided in an embodiment of the present invention, as shown below. Figure 6 As shown, the non-volatile flash memory protection device provided in this embodiment of the invention includes:

[0072] The data mapping service module 601 is used to identify frequently read and write partitions in non-volatile flash memory. When the device starts up, it maps the frequently read and write partitions into memory so that read and write operations on the frequently read and write partitions are converted into read and write operations on memory.

[0073] The data synchronization service module 602 is used to synchronize the data in the memory to the non-volatile flash memory in response to a synchronization trigger event.

[0074] In this embodiment of the invention, synchronizing the data in memory to the non-volatile flash memory in response to a synchronization trigger event includes:

[0075] The synchronization trigger event is when the device is normally powered off or restarted, the data in the memory is synchronized to the non-volatile flash memory; the synchronization trigger event is when the device is abnormally restarted, a data synchronization flag is obtained, and when the data synchronization flag is a first preset value, the data in the memory is synchronized to the non-volatile flash memory.

[0076] In this embodiment of the invention, the step of synchronizing the data in memory to the non-volatile flash memory in response to a synchronization trigger event further includes:

[0077] During the bootloader phase, the data synchronization flag is obtained. If the data synchronization flag is a first preset value, the data in memory is synchronized to the non-volatile flash memory. If the data synchronization flag is set to a second preset value, the data synchronization flag is synchronized to the non-volatile memory.

[0078] Determine if the external power supply is normal. If so, proceed to the system kernel loading stage; otherwise, control the baseboard management controller to stop service operation.

[0079] During the system kernel loading stage, if the baseboard management controller is normally powered off or restarted, the frequently read / write partition is mapped into memory, so that the read / write operations on the frequently read / write partition of the non-volatile flash memory are converted into read / write operations on memory during the operation of the baseboard management controller; at the same time, the data is synchronously marked to a first preset value and synchronously marked into the non-volatile memory.

[0080] When the baseboard management controller restarts abnormally, the memory data is written into the non-volatile flash memory, the data synchronization flag is set to the second preset value, and the data synchronization flag is synchronized to the non-volatile memory.

[0081] In this embodiment of the invention, when the external power supply malfunctions, the method further includes:

[0082] The baseboard management controller and the memory are powered by a farad capacitor.

[0083] According to a non-volatile flash memory protection method provided by the present invention, the step of mapping the frequently read / write partition into memory includes:

[0084] The data in the frequently read / write partition is read into memory. After detecting the read data, the memory creates a temporary memory file system and mounts the read data into the memory file system.

[0085] In this embodiment of the invention, the file read / write procedure is modified so that read / write operations on the frequently read / write partition are converted into read / write operations on memory.

[0086] According to a non-volatile flash memory protection method provided by the present invention, the identification of frequently read / write partitions in the non-volatile flash memory includes:

[0087] Obtain the identifier or address of the preset configuration information storage partition, and designate the partition corresponding to the identifier or address of the preset configuration information storage partition as the frequently read / write partition;

[0088] And / or, obtain the identifier or address of the preset log information storage partition, and designate the partition corresponding to the identifier or address of the preset log information storage partition as the frequently read / write partition.

[0089] In this embodiment of the invention, the non-volatile flash memory is a NOR flash memory.

[0090] The non-volatile flash memory protection device provided in this embodiment of the invention identifies frequently read / write partitions in the non-volatile flash memory. When the device starts up, it maps the frequently read / write partitions to memory, so that read / write operations on the frequently read / write partitions are converted into read / write operations on memory. In response to a synchronization trigger event, the data in memory is synchronized to the non-volatile flash memory. Since directly reading and writing to memory is more efficient than directly reading and writing to FLASH, the read / write efficiency of FLASH data is improved. Furthermore, FLASH write operations are only performed when a synchronization trigger event occurs, reducing the FLASH erase / write frequency and extending the lifespan of the flash memory.

[0091] Figure 7 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 7As shown, the server may include a processor 710, a communications interface 720, a memory 730, and a communication bus 740. The processor 710, communications interface 720, and memory 730 communicate with each other via the communication bus 740. The memory 730 includes computer programs, an operating system, and acquired graph structure data. The processor 710 can call logical instructions in the memory 730 to execute a non-volatile flash memory protection method. This method includes: identifying frequently read / write partitions in the non-volatile flash memory; mapping the frequently read / write partitions to memory during device startup, so that read / write operations on the frequently read / write partitions are converted to read / write operations on memory; and synchronizing data in memory to the non-volatile flash memory in response to a synchronization trigger event.

[0092] Furthermore, the logical instructions in the aforementioned memory 730 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to related technologies, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0093] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When executed by a processor, the computer program is implemented to perform the non-volatile flash memory protection method provided by the above methods. The method includes: identifying frequently read / write partitions in the non-volatile flash memory; mapping the frequently read / write partitions to memory when the device starts up, so that read / write operations on the frequently read / write partitions are converted into read / write operations on memory; and synchronizing data in the memory to the non-volatile flash memory in response to a synchronization trigger event.

[0094] 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. Those skilled in the art can understand and implement this without any creative effort.

[0095] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by 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 software products. 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.

[0096] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for protecting non-volatile flash memory, the method comprising: The method comprises the following steps: identifying a frequently read and written partition in a non-volatile flash memory, mapping the frequently read and written partition to a memory when a device is started, so that read and write operations on the frequently read and written partition are converted into read and write operations on the memory; in response to a synchronization trigger event, synchronizing data in the memory to the non-volatile flash memory, comprising: when the synchronization trigger event is normal shutdown or restart of the device, synchronizing data in the memory to the non-volatile flash memory; when the synchronization trigger event is abnormal restart of the device, obtaining a data synchronization marker, and when the data synchronization marker is a first preset value, synchronizing data in the memory to the non-volatile flash memory; obtaining the data synchronization marker in the bootloader stage, if the data synchronization marker is the first preset value, synchronizing data in the memory to the non-volatile flash memory; setting the data synchronization marker to a second preset value, and synchronizing the data synchronization marker to the non-volatile memory; determining whether external power supply is normal, if yes, entering a system kernel loading stage, otherwise, controlling a baseboard management controller to stop business running; in the system kernel loading stage, if the baseboard management controller is normally shut down or restarted, mapping the frequently read and written partition to the memory, so that read and write operations on the frequently read and written partition of the non-volatile flash memory are converted into read and write operations on the memory during running of the baseboard management controller; and setting the data synchronization marker to the first preset value, and synchronizing the data synchronization marker to the non-volatile memory; when the baseboard management controller is abnormally restarted, writing data in the memory to the non-volatile flash memory, setting the data synchronization marker to the second preset value, and synchronizing the data synchronization marker to the non-volatile memory.

2. The non-volatile flash protection method of claim 1, wherein, when the external power supply is abnormal, the method further comprises: supplying power to the baseboard management controller and the memory through a farad capacitor.

3. The non-volatile flash protection method of claim 1, wherein, after the frequently read and written partition is mapped to the memory, the method further comprises: reading data in the frequently read and written partition to the memory, and creating a temporary memory file system after the memory monitors the read data, and mounting the read data to the memory file system.

4. The non-volatile flash protection method of claim 1, wherein, before the frequently read and written partition is mapped to the memory, the method further comprises: rewriting the non-volatile flash memory in a read and write destination address parameter in a baseboard management controller read and write file program to the memory.

5. The non-volatile flash protection method of claim 1, wherein, the method of identifying the frequently read and written partition in the non-volatile flash memory comprises: obtaining an identifier or address of a preset configuration information storage partition, and taking a partition corresponding to the identifier or address of the preset configuration information storage partition as the frequently read and written partition; and / or, obtaining an identifier or address of a preset log information storage partition, and taking a partition corresponding to the identifier or address of the preset log information storage partition as the frequently read and written partition.

6. A non-volatile flash protection device, comprising: The method comprises the following steps: a data mapping service module is configured to identify a frequently read and written partition in a non-volatile flash memory, and map the frequently read and written partition to a memory when a device is started, so that read and write operations on the frequently read and written partition are converted into read and write operations on the memory; a data synchronization service module is configured to synchronize data in the memory to the non-volatile flash memory in response to a synchronization trigger event, comprising: when the synchronization trigger event is normal shutdown or restart of the device, synchronizing data in the memory to the non-volatile flash memory; when the synchronization trigger event is abnormal restart of the device, obtaining a data synchronization marker, and when the data synchronization marker is a first preset value, synchronizing data in the memory to the non-volatile flash memory. The synchronization trigger event is normal shutdown or restart of the device, and the data in the memory is synchronized to the non-volatile flash memory; The synchronization trigger event is abnormal restart of the device, a data synchronization mark is acquired, and when the data synchronization mark is a first preset value, the data in the memory is synchronized to the non-volatile flash memory; The data synchronization mark is acquired in a bootloader stage, when the data synchronization mark is the first preset value, the data in the memory is synchronized to the non-volatile flash memory, the data synchronization mark is set to a second preset value, and the data synchronization mark is synchronized to the non-volatile memory; It is judged whether external power supply is normal, if yes, a system kernel loading stage is entered, otherwise, a baseboard management controller is controlled to stop business running; In the system kernel loading stage, when the baseboard management controller is normally shutdown or restarted, the frequently read and written partition is mapped to the memory, so that read and write operations on the frequently read and written partition of the non-volatile flash memory are converted to read and write operations on the memory in the running process of the baseboard management controller; meanwhile, the data synchronization mark is set to the first preset value, and the data synchronization mark is synchronized to the non-volatile memory; When the baseboard management controller is abnormally restarted, the memory data is written to the non-volatile flash memory, the data synchronization mark is set to the second preset value, and the data synchronization mark is synchronized to the non-volatile memory.

7. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the program to implement the non-volatile flash memory protection method in any one of claims 1 to 5.

8. A non-transitory readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the non-volatile flash memory protection method in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Data reading method for flash memory and controller and storage system of same

    CN101546298A

  • Method for preventing flash subarea from being frequently read and written

    CN103729302A