CN117251116B - Erasing and writing method and device of nonvolatile memory - Google Patents
Erasing and writing method and device of nonvolatile memory Download PDFInfo
- Publication number
- CN117251116B CN117251116B CN202311514244.7A CN202311514244A CN117251116B CN 117251116 B CN117251116 B CN 117251116B CN 202311514244 A CN202311514244 A CN 202311514244A CN 117251116 B CN117251116 B CN 117251116B
- Authority
- CN
- China
- Prior art keywords
- power
- page
- target block
- control information
- protection control
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/0614—Improving the reliability of storage systems
- G06F3/0616—Improving the reliability of storage systems in relation to life time, e.g. increasing Mean Time Between Failures [MTBF]
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0646—Horizontal data movement in storage systems, i.e. moving data in between storage devices or systems
- G06F3/0652—Erasing, e.g. deleting, data cleaning, moving of data to a wastebasket
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0668—Interfaces specially adapted for storage systems adopting a particular infrastructure
- G06F3/0671—In-line storage system
- G06F3/0673—Single storage device
- G06F3/0679—Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Human Computer Interaction (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Techniques For Improving Reliability Of Storages (AREA)
Abstract
The embodiment of the application provides a method for erasing a nonvolatile memory, which comprises the following steps: determining one of a plurality of blocks of the non-volatile memory as a first target block; and storing standby power protection control information corresponding to each standby power process in pages of a first target block of a nonvolatile memory in sequence according to the occurrence sequence of the standby power processes, determining whether the first target block has idle pages in real time in the storage process, and performing erasing operation on the first target block under the condition of no idle pages, wherein the standby power protection control information comprises power-down protection control information and power-up protection control information in the standby power process of the electronic equipment. According to the method and the device, the problem that the service life of the nonvolatile memory is shortened due to the fact that the number of erasing times of the block of the nonvolatile memory is too large because the number of standby power is required to be adapted in the prior art is solved.
Description
Technical Field
Embodiments of the present invention relate to the field of computers, and in particular, to a method for erasing a nonvolatile memory, an apparatus for erasing a nonvolatile memory, a computer-readable storage medium, and an electronic device.
Background
At present, when the electronic equipment is powered down, the power-down protection control information and backup data of user data are written into a nonvolatile memory, when the electronic equipment is powered down, the backup data backed up into the nonvolatile memory are restored to a cache and fall on a disc according to the power-down protection control information, the power-down protection control information is erased, so that the user data loss caused by the power down of the electronic equipment is avoided, namely, when the electronic equipment is powered down once, the block storing the power-down protection control information in the nonvolatile memory is erased once, one erasing frequency of the nonvolatile memory is consumed, the erasing frequency of the block of the nonvolatile memory has an upper threshold, when the erasing frequency of the block of the nonvolatile memory reaches the upper threshold, the block of the nonvolatile memory is unavailable, and because the standby frequency is more in actual conditions, the erasing frequency of the block of the nonvolatile memory is more, the erasing frequency of the block of the nonvolatile memory reaches the upper threshold quickly, and the service life of the nonvolatile memory is shortened.
Disclosure of Invention
The embodiment of the application provides a method for erasing a nonvolatile memory, an apparatus for erasing a nonvolatile memory, a computer readable storage medium and an electronic device, so as to at least solve the problem that the service life of the nonvolatile memory is shortened due to excessive erasing times of a block of the nonvolatile memory caused by adapting to standby power times in the related technology.
According to an embodiment of the present application, there is provided a method of erasing a nonvolatile memory, the method including: determining one of a plurality of blocks of the non-volatile memory as a first target block; and storing standby power protection control information corresponding to each standby power process in pages of the first target block of the nonvolatile memory in sequence according to the occurrence sequence of the standby power processes, determining whether the first target block has idle pages or not in the storage process, and performing erasing operation on the first target block under the condition of no, wherein the standby power protection control information comprises power-down protection control information and power-up protection control information in the standby power processes of the electronic equipment.
In an exemplary embodiment, the nth power-up process includes an nth power-down process and an nth power-up process, N is a positive integer, and according to the occurrence sequence of the power-up processes, power-up protection control information corresponding to each power-up process is sequentially stored in a page of the first target block of the nonvolatile memory, and in the storing process, whether the first target block has an idle page is determined in real time, and in the case of no, an erasing operation is performed on the first target block, including: a storage step of storing the power-down protection control information of the Nth power-down process to a 2N-1 th page, storing the power-up protection control information of the Nth power-up process to a 2N-th page, wherein N is more than or equal to 1 and less than or equal to M/2, M is a positive integer, and M is the number of pages in the first target block; and repeating the storing step at least once until the first target block does not have free pages, and performing erasing operation on the first target block.
In one exemplary embodiment, storing the power down protection control information of the nth power down process to page 2N-1 includes: acquiring a first target number, wherein the first target number is the number of the power-down processes before the Nth power-down process occurs; acquiring the number of the 2N-1 th page, wherein the number of the 2N-1 th page is the product of the first target number and 2, and one page of the first target block is provided with one number; and storing the power-down protection control information of the Nth power-down process to the 2N-1 th page according to the number of the 2N-1 th page.
In an exemplary embodiment, the power down protection control information includes a first identifier, and acquiring a first target number includes: and determining that the first target number is 0 in the case that the first identifier does not exist on the 1 st page of the first target block.
In an exemplary embodiment, the power-down protection control information of the kth power-down process includes a first identifier and a kth standby power quantity, the power-up protection control information of the kth power-up process includes a second identifier and the kth standby power quantity, the kth standby power quantity is K, K is 1-K-M/2,K is a positive integer, and obtaining the first target quantity includes: under the condition that the first mark exists on the 1 st page of the first target block, a first detection step is executed, whether the first mark exists on the E th page of the first target block or not is detected according to a preset sequence, whether the second mark exists on the E th page of the first target block or not is detected, the preset sequence is the sequence from small to large of the numbers of the pages of the first target block, E is more than or equal to 2 and less than or equal to M, and E is a positive integer; and repeating the first detection step at least once until the first identifier does not exist in the E-th page and the second identifier does not exist in the E-th page, and determining the N-1 th standby power quantity of the power-on protection control information in the E-1 th page of the first target block as the first target quantity.
In one exemplary embodiment, before storing the power down protection control information of the nth power down process to page 2N-1, the method further includes: acquiring target backup data, wherein the target backup data is backup data of the Nth power-down process; the target backup data is stored to a second target block, the second target block being one of a plurality of blocks of the non-volatile memory, and the second target block being distinct from the first target block.
In an exemplary embodiment, the power-down protection control information of the kth power-down process includes a first identifier and a kth standby power amount, the power-up protection control information of the kth power-up process includes a second identifier and the kth standby power amount, the kth standby power amount is K, 1+.k+.m/2,K is a positive integer, and according to the number of the 2n_1st page, storing the power-down protection control information of the nth power-down process to the 2n_1st page includes: acquiring the number of a second target block and the byte number of target backup data, wherein the second target block is one of a plurality of blocks of the nonvolatile memory, the second target block is different from the first target block, the second target block stores the target backup data, the target backup data is the backup data of the Nth power-down process, and one block of the nonvolatile memory is provided with a number; calculating the sum of the first target quantity and 1 to obtain an N standby electricity quantity; and storing the first identifier, the N-th standby power quantity, the number of the second target block and the byte quantity of the target backup data to the 2N-1 th page according to the number of the 2N-1 th page.
In one exemplary embodiment, before storing the power-up protection control information of the nth power-up process to the 2 nth page, the method further includes: acquiring the number of a second target block and the byte number of target backup data from the 2N-1 th page, wherein the second target block is one of a plurality of blocks of the nonvolatile memory, and is different from the first target block, the target backup data are stored in the second target block, the backup data of the Nth power-down process are stored in the target backup data, and one block of the nonvolatile memory is provided with a number; and acquiring the target backup data from the second target block according to the number of the second target block and the byte number of the target backup data so as to restore the environment configuration of the electronic equipment.
In an exemplary embodiment, the power-down protection control information includes a first identifier, the power-up protection control information includes a second identifier, and the method further includes, before acquiring the number of the second target block and the byte count of the target backup data from the 2N-1 th page: a second detection step of detecting whether the first mark exists on the F-th page of the first target block according to a preset sequence, wherein F is more than or equal to 1 and less than or equal to 2N-1, and F is a positive integer; a third detecting step of detecting whether the second identifier exists on the f+1st page of the first target block in the case that the first identifier exists on the F-th page, wherein the preset sequence is the sequence from small to large of the numbers of the pages of the first target block; and repeating the second detection step and the third detection step at least once until the second mark does not exist on the F+1st page, and determining the F page as the 2N-1st page.
In one exemplary embodiment, storing the power-up protection control information of the nth power-up process to a 2 nth page includes: acquiring a third target number, wherein the third target number is the number of the power-on processes before the occurrence of the Nth power-on process; according to the formulaAcquiring the number of the 2N-th page, wherein ∈>For the number of the 2N-th page, -/-, for the number of the 2N-th page>For the third target number, a page of the first target block has a number; and storing the power-on protection control information of the Nth power-on process to the 2N pages according to the number of the 2N pages.
In an exemplary embodiment, the power-down protection control information of the kth power-down process includes a first identifier and a kth standby power quantity, the power-up protection control information of the kth power-up process includes a second identifier and the kth standby power quantity, the kth standby power quantity is K, K is 1-K-M/2,K is a positive integer, and obtaining a third target quantity includes: a fourth detection step of detecting whether the first identifier exists on the D-th page of the first target block according to a preset sequence; a fifth detection step of detecting whether the second mark exists on the (D+1) th page of the first target block or not in the case that the first mark exists on the (D) th page, wherein the preset sequence is the sequence from small to large of the numbers of the pages of the first target block, and D is more than or equal to 1 and less than or equal to M; and repeating the fourth detection step and the fifth detection step at least once until the second identifier does not exist in the (D+1) th page, and determining the (N-1) th standby power quantity of the power-down protection control information in the (D) th page as the third target quantity.
In an exemplary embodiment, the power-up protection control information of the kth power-up process includes a second identifier and a kth standby power number, where the kth standby power number is K, and K is 1-N and M/2,K is a positive integer, and storing the power-up protection control information of the nth power-up process to the 2 nth page according to the number of the 2 nth page includes: calculating the sum of the third target quantity and 1 to obtain the N standby electricity quantity; and storing the second identifier and the N standby power quantity to the 2N pages.
In an exemplary embodiment, storing the power-on protection control information of the nth power-on procedure to the 2 nth page according to the number of the 2 nth page includes: and storing the power-on protection control information of the Nth power-on process to the 2N < th > page according to the number of the 2N < th > page when the number of the 2N < th > page is smaller than M, wherein one page of the first target block has one number.
In an exemplary embodiment, storing the power-on protection control information of the nth power-on procedure to the 2 nth page according to the number of the 2 nth page includes: if the number of the 2N-th page is equal to M, determining that the first target block does not have a free page, wherein one page of the first target block has one number; and performing an erasing operation on the first target block.
In one exemplary embodiment, storing the power down protection control information of the nth power down process to the 2N-1 th page according to the number of the 2N-1 th page includes: and storing the power-down protection control information of the Nth power-down process to the 2N-1 th page according to the number of the 2N-1 th page under the condition that the number of the 2N-1 th page is smaller than M-1, wherein one page of the first target block is provided with one number.
In an exemplary embodiment, the power-up protection control information includes a second identifier, and storing the power-down protection control information of the nth power-down procedure to the 2N-1 th page according to the number of the 2N-1 th page includes: detecting whether the second identification exists on the 2N page or not under the condition that the number of the 2N-1 page is equal to M-1; the second identifier exists on the 2N page, it is determined that the first target block does not have a free page, and one page of the first target block has a number; and performing an erasing operation on the first target block.
In one exemplary embodiment, performing an erase operation on the first target block includes: an erasing step of erasing the power-down protection control information of the nth power-down process of the 2N-1 th page and erasing the power-up protection control information of the nth power-up process of the 2N-th page; the erasing step is repeated N times.
In one exemplary embodiment, determining one of a plurality of blocks of non-volatile memory as a first target block includes: a block numbered 0 in the non-volatile memory is determined as the first target block.
According to another embodiment of the present application, there is provided a erasing device of a nonvolatile memory, the device including: a determining module for determining one of a plurality of blocks of the non-volatile memory as a first target block; the erasing module is used for sequentially storing standby power protection control information corresponding to each standby power process in pages of the first target block of the nonvolatile memory according to the occurrence sequence of the standby power processes, determining whether the first target block has idle pages in real time in the storage process, and performing erasing operation on the first target block under the condition of no, wherein the standby power processes comprise a power-down process of the electronic equipment and a power-up process of the electronic equipment, and the standby power protection control information comprises power-down protection control information and power-up protection control information.
According to yet another embodiment of the present application, there is provided a computer readable storage medium having a computer program stored therein, wherein the computer program when executed by a processor implements the steps of the method of erasing a non-volatile memory.
According to still another embodiment of the present application, there is provided an electronic apparatus including: a non-volatile memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the method for erasing the non-volatile memory when executing the computer program.
In one exemplary embodiment, the electronic device is a disk array card.
Through the steps, the standby protection control information of each standby process is sequentially stored in the pages of the first target block of the nonvolatile memory according to the occurrence sequence of the standby processes until the first target block is free of free pages, namely the first target block is exhausted, and the first target block is erased.
Drawings
Fig. 1 is a hardware block diagram of a server apparatus of a method of erasing a nonvolatile memory according to an embodiment of the present application;
FIG. 2 is a flow chart of a method of erasing a non-volatile memory according to an embodiment of the present application;
FIG. 3 is a block diagram of the organization of the memory space of a non-volatile memory according to an embodiment of the present application;
FIG. 4 is a block diagram of the organization of the memory space of a non-volatile memory according to an embodiment of the present application;
FIG. 5 is a block diagram of the organization of the memory space of a non-volatile memory according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of an erasing device of a nonvolatile memory according to an embodiment of the present application.
Detailed Description
Embodiments of the present application will be described in detail below with reference to the accompanying drawings in conjunction with the embodiments.
It should be noted that the terms "first," "second," and the like in the description and claims of the present application and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order.
Nonvolatile memory: a non-volatile memory includes a plurality of Die: the Die is a basic unit for receiving and executing commands, only one command can be independently executed in one Die at a time, one Die comprises a plurality of planes, each Plane has a Cache Register and a Page Register which are independent, the size of each Plane is equal to that of one Page, one Plane comprises a plurality of blocks, the blocks are basic units for erasing operation of the nonvolatile memory, and one Block comprises a plurality of pages, and the pages are basic units for reading and writing operation of the nonvolatile memory.
Disk array card: redundant Array of Inexpensive Disks, RAID.
The method embodiments provided in the embodiments of the present application may be performed in a server device or similar computing device. Taking the example of running on a server device, fig. 1 is a block diagram of the hardware structure of a server device of a method for erasing a nonvolatile memory according to an embodiment of the present application. As shown in fig. 1, the server device may include one or more (only one is shown in fig. 1) processors 102 (the processor 102 may include, but is not limited to, a microprocessor MCU, a programmable logic device FPGA, or the like processing means) and a memory 104 for storing data, wherein the server device may further include a transmission device 106 for communication functions and an input-output device 108. It will be appreciated by those of ordinary skill in the art that the architecture shown in fig. 1 is merely illustrative and is not intended to limit the architecture of the server apparatus described above. For example, the server device may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.
The memory 104 may be used to store computer programs, such as software programs and modules of application software, such as computer programs corresponding to the method of erasing a nonvolatile memory in the embodiments of the present application, and the processor 102 executes the computer programs stored in the memory 104 to perform various functional applications and data processing, i.e., implement the methods described above. Memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory remotely located with respect to the processor 102, which may be connected to the server device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 106 is used to receive or transmit data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of a server device. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, simply referred to as NIC) that can connect to other network devices through a base station to communicate with the internet. In one example, the transmission device 106 may be a Radio Frequency (RF) module, which is configured to communicate with the internet wirelessly.
In this embodiment, there is provided a method for erasing a nonvolatile memory, and fig. 2 is a flowchart of the method for erasing a nonvolatile memory according to an embodiment of the present application, as shown in fig. 2, the flowchart includes the following steps:
step S201, one of a plurality of blocks of the nonvolatile memory is determined as a first target block;
step S202, storing backup protection control information corresponding to each backup process in a page of the first target block of the nonvolatile memory in sequence according to occurrence sequence of the backup processes, and determining whether the first target block has an idle page or not in the storing process, and if not, performing an erasing operation on the first target block, wherein the backup processes include a power-down process of the electronic device and a power-up process of the electronic device, and the backup protection control information includes power-down protection control information and power-up protection control information.
Through the steps, the standby protection control information of each standby process is sequentially stored in the pages of the first target block of the nonvolatile memory according to the occurrence sequence of the standby processes until the first target block is free of free pages, namely the first target block is exhausted, and the first target block is erased.
In order to avoid damage to the reserve protection control information, in an alternative embodiment, step S201 described above may be implemented as:
And determining a block numbered 0 in the nonvolatile memory as the first target block.
Specifically, as shown in fig. 3, each nonvolatile memory (NANDFLASH) includes 4 Die, which are respectively Die0, die1, die2 and Die3, where "0" in Die0 indicates that the number of Die is 0, each Die includes 4 dies, which are respectively Die0, die1, die2 and Die3, where "0" in Die0 indicates that the number of Die is 0, each Die includes 495 blocks, which are respectively Block0, block1, block2 and Block3 … Block494, where "0" in Block0 indicates that the number of Block is 0, each Block includes 768 pages, the manufacturer of each Page is 16kb+2048b, the Block0 of each Die can be ensured not to be a bad Block, and compared with other blocks, the Block0 is more stable, and thus the Block0 is controlled to be a target Block, and the Block0 is controlled to be protected, and the target Block is controlled in a certain control mode, and the target Block is protected in a certain mode, as shown in fig. 4, and the target Block0 is controlled to be protected.
The nth power-up process includes an nth power-down process and an nth power-up process, where N is a positive integer, and in an alternative embodiment, the step S202 may be implemented as follows:
Step S2021, a storing step, in which the power-down protection control information of the Nth power-down process is stored in the 2N-1 th pages, the power-up protection control information of the Nth power-up process is stored in the 2N-th pages, N is greater than or equal to 1 and less than or equal to M/2, M is a positive integer, and M is the number of pages in the first target block;
step S2022, repeating the storing step at least once until there is no free page in the first target block, and performing an erasing operation on the first target block.
Specifically, in some embodiments, the first target block includes 768 pages, the power-down protection control information of the 1 st power-down process is stored to the 1 st page, the power-up protection control information of the 1 st power-up process is stored to the 2 nd page, the power-down protection control information of the 2 nd power-down process is stored to the 3 rd page, the power-up protection control information of the 2 nd power-up process is stored to the 4 th page, and so on, the power-down protection control information of the 384 th power-down process is stored to the 767 th page, the power-up protection control information of the 384 th power-up process is stored to the 768 pages, then, the first target block is erased, that is, 384 standby powers are performed until the first target block is exhausted, that is, 384 standby powers are performed to consume one erasing times of the nonvolatile memory, so that the erasing times of the first target block are greatly reduced, and the service life of the nonvolatile memory is prolonged.
In an alternative embodiment, the storing of the power down protection control information of the nth power down procedure to the 2N-1 th page in the step S2021 may be implemented as:
step S20211, obtaining a first target number, where the first target number is the number of the power-down processes before the nth power-down process occurs;
step S20212, obtaining the number of the 2N-1 th page, wherein the number of the 2N-1 th page is the product of the first target number and 2, and one page of the first target block has one number;
step S20213, according to the number of the 2N-1 th page, stores the power-down protection control information of the N-th power-down process to the 2N-1 th page.
Specifically, as shown in fig. 5, in some embodiments, block0 in Plane0 in Die0 is determined as a first target Block and is used for storing power-down protection control information, where Block0 includes 768 pages, which are Page0, page1, page2, page3, page4, and Page5 … Page767, respectively, where "0" in Page0 indicates that Page number is 0, taking N as an example 2, power-down protection control information of the 2 nd power-down process should be stored to the 3 rd Page, first, the number of power-down processes before the 2 nd power-down process is determined to be 1 (first target number), then the number of the 3 rd Page is determined to be 2, and the power-down protection control information of the 2 nd power-down process is stored to the 3 rd Page (Page 2) according to the number of the 3 rd Page.
In an alternative embodiment, the power-down protection control information includes a first identifier, and the step S20211 may be implemented as:
and determining that the first target number is 0 in the case that the first flag does not exist on the 1 st page of the first target block.
Specifically, the standby power protection control information of each standby power process is sequentially stored in pages of a first target block of the nonvolatile memory according to the occurrence sequence of the standby power processes, if a first identifier does not exist on a 1 st page of the first target block, the 1 st page of the first target block does not store the power down protection control information, the Nth power down process is the 1 st power down process, and the number of power down processes (first target number) before the 1 st power down process is 0.
In an alternative embodiment, the power-down protection control information of the kth power-down process includes a first identifier and a kth standby power amount, the power-up protection control information of the kth power-up process includes a second identifier and the kth standby power amount, the kth standby power amount is K, and 1.ltoreq.k.ltoreq.m/2,K is a positive integer, and the step S20211 may be implemented as follows:
executing a first detection step when the first mark exists on the 1 st page of the first target block, detecting whether the first mark exists on the E th page of the first target block or not according to a preset sequence, detecting whether the second mark exists on the E th page of the first target block or not, wherein the preset sequence is a sequence from small to large of the numbers of the pages of the first target block, E is more than or equal to 2 and less than or equal to M, and E is a positive integer;
Repeating the first detecting step at least once until the first mark is not present on the E-th page and the second mark is not present on the E-th page, and determining that the N-1 th standby power number of the power-on protection control information in the E-1 th page of the first target block is the first target number.
Specifically, the power-down protection control information of the kth power-down process includes a kth standby power quantity, the power-up protection control information of the kth power-up process includes a kth standby power quantity, the kth standby power quantity indicates a quantity of power-down processes before the kth+1th power-down process, and since the present application sequentially stores the standby power protection control information of each standby power process into a page of a first target block of the nonvolatile memory according to a sequence of occurrence of the standby power processes, if a first identifier exists on a 1 st page of the first target block, the 1 st page of the first target block stores the power-down protection control information, the nth power-down process is not the 1 st power-down process, taking N as 2 as an example, a first detection step is performed, a second identifier is determined on a 2 nd page, then a first identifier is determined to be absent on a 3 rd page, and the 3 nd page does not have a second identifier, namely, the 2 nd standby power-down quantity of the power-up protection control information in the 2 nd page is determined to be the quantity of power-down processes before the 2 nd power-down process (the 1 st power-down process).
In an alternative embodiment, before storing the power down protection control information of the nth power down process to the 2N-1 th page in the step S2021, the method further includes:
acquiring target backup data, wherein the target backup data is backup data of the Nth power failure process;
and storing the target backup data into a second target block, wherein the second target block is one of a plurality of blocks of the nonvolatile memory, and the second target block is different from the first target block.
Specifically, before the power-down protection control information of the nth power-down process is stored in the 2N-1 th page, in order to avoid the user data loss caused by the power-down of the electronic device, the backup data of the nth power-down process needs to be stored in a block (second target block) other than the first target block in the nonvolatile memory.
In an alternative embodiment, the power-down protection control information of the kth power-down process includes a first identifier and a kth standby power amount, the power-up protection control information of the kth power-up process includes a second identifier and the kth standby power amount, the kth standby power amount is K, and 1.ltoreq.k.ltoreq.m/2,K is a positive integer, and the step S20213 may be implemented as follows:
Step S202131, obtaining the number of a second target block and the byte number of target backup data, wherein the second target block is one of a plurality of blocks of the nonvolatile memory, and is different from the first target block, the second target block stores the target backup data, the target backup data is the backup data of the nth power down process, and one block of the nonvolatile memory has a number;
step S202132, calculating the sum of the first target number and 1 to obtain the N standby electricity number;
and step S202133, storing the first mark, the N-1 th standby power quantity, the number of the second target block and the byte quantity of the target backup data into the 2N-1 th page according to the number of the 2N-1 th page.
Specifically, the power-down protection control information of the nth power-down process includes: the serial number of the block of the backup data of the nth power down process (the serial number of the second target block) and the byte number of the backup data of the nth power down process (the byte number of the target backup data) are stored, so that the backup data of the nth power down process stored in the nonvolatile memory can be restored to the electronic equipment according to the serial number of the block of the backup data of the nth power down process (the serial number of the second target block) and the byte number of the backup data of the nth power down process (the byte number of the target backup data) in the nth power up process, and the power down protection control information of the nth power down process comprises: the power-down protection control information of the (N+1) th power-down process is stored by the first identifier and the N-th standby power quantity, the number of the power-down processes before the (N+1) th power-down process is determined according to the first identifier and the N-th standby power quantity, and then the number of the page storing the power-down protection control information of the (N+1) th power-down process is determined.
Before storing the power-on protection control information of the nth power-on process to the 2 nth page in the step S2021, the method further includes:
step S302, obtaining the number of a second target block and the byte number of target backup data from the 2N-1 th page, wherein the second target block is one of a plurality of blocks of the nonvolatile memory, and is different from the first target block, the second target block stores the target backup data, the target backup data is the backup data of the Nth power-down process, and one block of the nonvolatile memory has a number;
step S303, according to the number of the second target block and the byte number of the target backup data, the target backup data is obtained from the second target block, so as to restore the environment configuration of the electronic device.
Specifically, taking N as 2 as an example, before the power-up protection control information of the 2 nd power-up process is stored in the 4 th page, the number of the block of the backup data of the 2 nd power-down process (the number of the second target block), the number of bytes of the backup data of the 2 nd power-down process (the number of bytes of the target backup data) are acquired from the 3 rd page, and the backup data of the 2 nd power-down process stored in the nonvolatile memory is restored to the electronic device according to the number of the block of the backup data of the 2 nd power-down process (the number of the second target block) and the number of bytes of the backup data of the 2 nd power-down process (the number of bytes of the target backup data) in the 2 nd power-up process.
In an alternative embodiment, the power-down protection control information includes a first identifier, the power-up protection control information includes a second identifier, and the method further includes, before the step S302:
a second detection step of detecting whether the first mark exists on the F-th page of the first target block according to a preset sequence, wherein F is more than or equal to 1 and less than or equal to 2N-1, and F is a positive integer;
a third detecting step of detecting whether or not the f+1th page of the first target block has the second flag, in a case where the first flag is present on the F-th page, the predetermined order being an order of decreasing numbers of pages of the first target block;
and repeating the second detecting step and the third detecting step at least once until the second mark does not exist on the F+1st page, and determining the F page as the 2N-1st page.
Specifically, the standby power protection control information of each standby power process is sequentially stored in pages of a first target block of the nonvolatile memory according to the occurrence sequence of the standby power processes, if a first identifier exists on a 1 st page of the first target block, the 1 st page of the first target block is indicated to store the power down protection control information, the nth power down process is indicated not to be the 1 st power down process, taking N as an example, a second detection step is performed to determine that the 1 st page has the first identifier, a third detection step is performed to determine that the 2 nd page has the second identifier, a second detection step is performed to determine that the 3 rd page has the first identifier, a third detection step is performed to determine that the 4 th page does not have the second identifier, and then the 3 rd page is determined.
In an alternative embodiment, the storing of the power-up protection control information of the nth power-up procedure in the nth page in the step S2021 may be implemented as:
step S20214, obtaining a third target number, where the third target number is the number of the power-up processes before the nth power-up process occurs;
step S20215, according to the formulaObtaining the number of the above page 2N, wherein->For the number of the above page 2N, -/-, is given>For the third target number, a page of the first target block has a number;
step S20216, according to the number of the nth page, stores the power-up protection control information of the nth power-up process in the nth page.
Specifically, as shown in fig. 5, in some embodiments, block0 in Plane0 in Die0 is determined as a first target Block and is used for storing power-up protection control information, where Block0 includes 768 pages, which are Page0, page1, page2, page3, page4, and Page5 … Page767, respectively, where "0" in Page0 indicates that Page number is 0, taking N as an example 2, power-down protection control information of the 2 nd power-up process should be stored to the 4 th Page, first, the number of power-up processes before the 2 nd power-up process is determined to be 1 (third target number), then the number of the 4 th Page is determined to be 3, and power-down protection control information of the 2 nd power-up process is stored to the 4 th Page (Page 3) according to the number of the 4 th Page.
In an alternative embodiment, the power-down protection control information of the kth power-down process includes a first identifier and a kth standby power amount, the power-up protection control information of the kth power-up process includes a second identifier and the kth standby power amount, the kth standby power amount is K, and 1.ltoreq.k.ltoreq.m/2,K is a positive integer, and the step S20214 may be implemented as follows:
a fourth detecting step of detecting whether the first mark exists on the D-th page of the first target block according to a preset sequence;
a fifth detecting step of detecting whether or not the (d+1) th page of the first target block has the second mark, in the case where the first mark is present on the (D) th page, wherein the predetermined order is an order of decreasing numbers of the pages of the first target block, and 1.ltoreq.d.ltoreq.m;
and repeating the fourth detection step and the fifth detection step at least once until the second identifier does not exist in the (D+1) th page, and determining the (N-1) th standby power quantity of the power failure protection control information in the (D) th page as the third target quantity.
Specifically, the power-on protection control information of the kth power-on process includes a kth standby power quantity, the kth standby power quantity indicates a quantity of power-on processes before the kth+1th power-on process, and since the power-on protection control information of each standby power-on process is sequentially stored in a page of a first target block of the nonvolatile memory according to a sequence of occurrence of the standby power-on processes, taking N as an example, a fourth detection step is performed to determine that the 1 st page has the first identifier, a fifth detection step is performed to determine that the 2 nd page has the second identifier, a fourth detection step is performed to determine that the 3 rd page has the first identifier, a fifth detection step is performed to determine that the 4 th page does not have the second identifier, that is to determine that the 2 nd standby power-on protection control information in the 4 th page has the quantity of power-on processes before the 2 nd power-on process (the first target quantity), and the 2 nd power-on protection control information in the 2 nd page has the 1 st power-on quantity.
In an alternative embodiment, the power-up protection control information of the kth power-up process includes a second identifier and a kth standby power number, where the kth standby power number is K, K is 1 and K is less than or equal to M/2,K and is a positive integer, and the step S20216 may be implemented as follows:
calculating the sum of the third target quantity and 1 to obtain the N standby electricity quantity;
and storing the second identifier and the N standby power quantity into the 2N pages.
Specifically, the power-on protection control information of the nth power-on procedure includes: the second identifier and the N standby power quantity are used for storing the power-on protection control information of the (N+1) th power-on process, the number of the power-on processes before the (N+1) th power-on process is determined according to the first identifier and the N standby power quantity, and then the number of the page storing the power-on protection control information of the (N+1) th power-on process is determined.
In an alternative embodiment, the step S20216 may be implemented as:
and storing the power-on protection control information of the nth power-on process to the 2N-th page according to the number of the 2N-th page when the number of the 2N-th page is smaller than M, wherein one page of the first target block has one number.
Specifically, if the number of pages in the first target block is M and the number of the nth page is smaller than M, it indicates that there is a free page in the first target block, and at this time, the erasing operation is not required for the first target block.
In an alternative embodiment, the step S20216 may be implemented as:
if the number of the nth page is equal to M, determining that the first target block does not have a free page, wherein one page of the first target block has a number;
and performing an erasing operation on the first target block.
Specifically, if the number of pages in the first target block is M and the number of the nth page is equal to M, it indicates that there is no free page in the first target block, and at this time, the erasing operation is performed on the first target block.
In an alternative embodiment, the step S20213 may be implemented as:
and storing the power-down protection control information of the Nth power-down process to the 2N-1 th page according to the number of the 2N-1 th page when the number of the 2N-1 th page is smaller than M-1, wherein one page of the first target block has one number.
Specifically, if the number of pages in the first target block is M and the number of the 2N-1 th page is smaller than M-1, it indicates that the first target block has free pages, and at this time, the first target block does not need to be erased.
In an alternative embodiment, the power-on protection control information includes a second identifier, and the step S20213 may be implemented as:
detecting whether the second mark exists on the 2N page or not under the condition that the number of the 2N-1 page is equal to M-1;
the second identifier exists on the 2N page, it is determined that the first target block does not have a free page, and one page of the first target block has a number;
and performing an erasing operation on the first target block.
Specifically, if the number of pages in the first target block is M, and if the number of the 2N-1 th page is equal to M-1, determining whether the second identifier exists on the 2N-th page, and if so, indicating that the first target block does not have a free page, performing an erase operation on the first target block.
The erasing operation on the first target block may be implemented as follows:
an erasing step of erasing the power-down protection control information of the nth power-down process of the 2N-1 th page and erasing the power-up protection control information of the nth power-up process of the 2N-th page;
the above erasing step is repeated N times.
From the description of the above embodiments, it will be clear to a person skilled in the art that the method according to the above embodiments may be implemented by means of software plus the necessary general hardware platform, but of course also by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk), including several instructions for causing a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the method of the embodiments of the present application.
The embodiment also provides an erasing device of the nonvolatile memory, which is used for implementing the above embodiment and the preferred implementation, and is not described again. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. While the means described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
Fig. 6 is a block diagram of a structure of an erasing device of a nonvolatile memory according to an embodiment of the present application, as shown in fig. 6, the device includes:
a determining module 22 for determining one of a plurality of blocks of the nonvolatile memory as a first target block;
the erasing module 24 is configured to store standby protection control information corresponding to each standby process in the pages of the first target block of the nonvolatile memory sequentially according to the occurrence sequence of the standby process, and determine whether the first target block has an idle page in the storage process, and if not, erase the first target block, where the standby process includes a power-down process of the electronic device and a power-up process of the electronic device, and the standby protection control information includes power-down protection control information and power-up protection control information.
Through the steps, the standby protection control information of each standby process is sequentially stored in the pages of the first target block of the nonvolatile memory according to the occurrence sequence of the standby processes until the first target block is free of free pages, namely the first target block is exhausted, and the first target block is erased.
In order to avoid damage to the reserve protection control information, in an alternative embodiment, the determination module is configured to:
and determining a block numbered 0 in the nonvolatile memory as the first target block.
The nth power-up process includes an nth power-down process and an nth power-up process, where N is a positive integer, and in an alternative embodiment, the erasing module includes:
a storage sub-module, configured to execute a storage step, store the power-down protection control information of the nth power-down process to a 2N-1 th page, store the power-up protection control information of the nth power-up process to a 2N-th page, where N is greater than or equal to 1 and less than or equal to M/2, M is a positive integer, and M is the number of pages in the first target block;
and the repeating sub-module is used for repeating the storage step at least once until the first target block does not have free pages, and performing erasing operation on the first target block.
In an alternative embodiment, the storage submodule includes:
the first acquisition unit is used for acquiring a first target number, wherein the first target number is the number of the power-down processes before the Nth power-down process occurs;
a second obtaining unit, configured to obtain the number of the 2N-1 th page, where the number of the 2N-1 th page is a product of the first target number and 2, and one page of the first target block has one number;
and the first storage unit is used for storing the power-down protection control information of the Nth power-down process to the 2N-1 th page according to the number of the 2N-1 th page.
In an alternative embodiment, the power-down protection control information includes a first identifier, and the first obtaining unit is configured to:
and determining that the first target number is 0 in the case that the first flag does not exist on the 1 st page of the first target block.
In an alternative embodiment, the power-down protection control information of the kth power-down process includes a first identifier and a kth standby power amount, the power-up protection control information of the kth power-up process includes a second identifier and the kth standby power amount, the kth standby power amount is K, 1.ltoreq.k.ltoreq.m/2,K is a positive integer, and the first obtaining unit includes:
a first detection subunit, configured to execute a first detection step when the first identifier exists on the 1 st page of the first target block, detect whether the first identifier exists on the E-th page of the first target block according to a preset sequence, detect whether the second identifier exists on the E-th page of the first target block, where the preset sequence is a sequence from small to large of numbers of pages of the first target block, and 2.ltoreq.e.ltoreq.m, where E is a positive integer;
and a first repeating subunit configured to repeat the first detecting step at least once until the first identifier does not exist on the E-th page and the second identifier does not exist on the E-th page, and determine that the N-1 th standby power number of the power-on protection control information in the E-1 th page of the first target block is the first target number.
In an alternative embodiment, the apparatus comprises:
the first acquisition module is used for acquiring target backup data, wherein the target backup data is the backup data of the Nth power failure process;
and the first storage module is used for storing the target backup data to a second target block, wherein the second target block is one of a plurality of blocks of the nonvolatile memory, and the second target block is different from the first target block.
In an alternative embodiment, the power-down protection control information of the kth power-down process includes a first identifier and a kth standby power amount, the power-up protection control information of the kth power-up process includes a second identifier and the kth standby power amount, the kth standby power amount is K, 1.ltoreq.k.ltoreq.m/2,K is a positive integer, and the first storage unit includes:
an obtaining subunit, configured to obtain a number of a second target block and a byte number of target backup data, where the second target block is one of a plurality of blocks of the nonvolatile memory, and the second target block is different from the first target block, where the second target block stores the target backup data, where the target backup data is backup data of the nth power down process, and where one block of the nonvolatile memory has a number;
The first calculating subunit is used for calculating the sum of the first target quantity and 1 to obtain the N standby electricity quantity;
and the first storage subunit is used for storing the first identifier, the N-1 th standby power quantity, the number of the second target block and the byte quantity of the target backup data into the 2N-1 th page according to the number of the 2N-1 th page.
In an alternative embodiment, the apparatus comprises:
a second obtaining module, configured to obtain, from the 2N-1 th page, a number of a second target block and a byte number of target backup data, where the second target block is one of a plurality of blocks of the nonvolatile memory, and the second target block is different from the first target block, where the second target block stores the target backup data, where the target backup data is backup data of the nth power down process, and where one block of the nonvolatile memory has a number;
and a third obtaining module, configured to obtain the target backup data from the second target block according to the number of the second target block and the byte number of the target backup data, so as to restore the environment configuration of the electronic device.
In an alternative embodiment, the power down protection control information includes a first identifier, and the apparatus includes:
the first detection module is used for executing a second detection step, and detecting whether the F page of the first target block has the first mark according to a preset sequence, wherein F is more than or equal to 1 and less than or equal to 2N-1, and F is a positive integer;
a second detecting module, configured to execute a third detecting step, where if the first identifier exists on the F-th page, detect whether the second identifier exists on the f+1st page of the first target block, where the preset order is an order from small to large of numbers of pages of the first target block;
and a first repeating module, configured to perform repeating the second detecting step and the third detecting step at least once until the second identifier does not exist on the f+1th page, and determine that the F-th page is the 2n_1th page.
In an alternative embodiment, the storage submodule includes:
a third obtaining unit, configured to obtain a third target number, where the third target number is the number of the power-up processes before the nth power-up process occurs;
a fourth acquisition unit for according to the formula Obtaining the number of the above page 2N, wherein->For the number of the above page 2N, -/-, is given>For the third target number, a page of the first target block has a number;
and a second storage unit configured to store the power-on protection control information of the nth power-on process to the 2 nd page according to the number of the 2 nd page.
In an alternative embodiment, the power-down protection control information of the kth power-down process includes a first identifier and a kth standby power amount, the power-up protection control information of the kth power-up process includes a second identifier and the kth standby power amount, the kth standby power amount is K, 1.ltoreq.k.ltoreq.m/2,K is a positive integer, and the third obtaining unit includes:
a second detecting subunit, configured to detect, in a fourth detecting step, whether the first identifier exists on the D-th page of the first target block according to a preset sequence;
a third detection subunit, configured to, in a fifth detection step, detect whether a (d+1) th page of the first target block has the second identifier if the (D) th page has the first identifier, where the preset order is an order from small to large of numbers of pages of the first target block, and 1.ltoreq.d.ltoreq.m;
And a second repeating subunit, configured to repeat the fourth detecting step and the fifth detecting step at least once until the second identifier does not exist on the (d+1) th page, and determine that the (N-1) th standby power amount of the power-down protection control information in the (D) th page is the third target amount.
In an alternative embodiment, the power-up protection control information of the kth power-up process includes a second identifier and a kth standby power number, where the kth standby power number is K, K is 1 and less than or equal to M/2,K and is a positive integer, and the second storage unit includes:
the second calculating subunit is used for calculating the sum of the third target quantity and 1 to obtain the N standby electricity quantity;
and the second storage subunit is used for storing the second identifier and the N-th standby power quantity into the 2N-th page.
In an alternative embodiment, the second storage unit is configured to:
and storing the power-on protection control information of the nth power-on process to the 2N-th page according to the number of the 2N-th page when the number of the 2N-th page is smaller than M, wherein one page of the first target block has one number.
In an alternative embodiment, the second storage unit further includes:
A first determining subunit, configured to determine that, when the number of the nth page is equal to M, the first target block does not have a free page, where one page of the first target block has a number;
and the first erasing subunit is used for erasing the first target block.
In an alternative embodiment, the first storage unit is configured to:
and storing the power-down protection control information of the Nth power-down process to the 2N-1 th page according to the number of the 2N-1 th page when the number of the 2N-1 th page is smaller than M-1, wherein one page of the first target block has one number.
In an alternative embodiment, the power-on protection control information includes a second identifier, and the first storage unit further includes:
a fourth detecting subunit, configured to detect whether the second identifier exists on the 2N-th page if the number of the 2N-1-th page is equal to M-1;
a second determining subunit, configured to determine that the second identifier exists on the nth page and that no free page exists on the first target block, where one page of the first target block has a number;
and the second erasing subunit is used for erasing the first target block.
The erasing operation on the first target block may be implemented as follows:
an erasing step of erasing the power-down protection control information of the nth power-down process of the 2N-1 th page and erasing the power-up protection control information of the nth power-up process of the 2N-th page;
the above erasing step is repeated N times.
It should be noted that each of the above modules may be implemented by software or hardware, and for the latter, it may be implemented by, but not limited to: the modules are all located in the same processor; alternatively, the above modules may be located in different processors in any combination.
Embodiments of the present application also provide a computer readable storage medium having a computer program stored therein, wherein the computer program is configured to perform the steps in the above-described embodiments of the method of erasing a non-volatile memory when run.
In one exemplary embodiment, the computer readable storage medium may include, but is not limited to: a usb disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a removable hard disk, a magnetic disk, or an optical disk, or other various media capable of storing a computer program.
The embodiment of the application also provides electronic equipment, which comprises: a non-volatile memory, a memory and a processor, the memory having stored therein a computer program, the processor being arranged to run the computer program to perform the steps of the above-described embodiments of the method of erasing the non-volatile memory.
In an exemplary embodiment, the electronic device may further include a transmission device connected to the processor, and an input/output device connected to the processor.
Specific examples in this embodiment may refer to the examples described in the foregoing embodiments and the exemplary implementation, and this embodiment is not described herein.
It will be appreciated by those skilled in the art that the modules or steps of the application described above may be implemented in a general purpose computing device, they may be concentrated on a single computing device, or distributed across a network of computing devices, they may be implemented in program code executable by computing devices, so that they may be stored in a storage device for execution by computing devices, and in some cases, the steps shown or described may be performed in a different order than that shown or described herein, or they may be separately fabricated into individual integrated circuit modules, or multiple modules or steps of them may be fabricated into a single integrated circuit module. Thus, the present application is not limited to any specific combination of hardware and software.
The foregoing description is only of the preferred embodiments of the present application and is not intended to limit the same, but rather, various modifications and variations may be made by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application should be included in the protection scope of the present application.
Claims (19)
1. A method of erasing a non-volatile memory, the method comprising:
determining one of a plurality of blocks of the non-volatile memory as a first target block;
storing standby power protection control information corresponding to each standby power process in pages of the first target block of the nonvolatile memory in sequence according to the occurrence sequence of the standby power processes, determining whether the first target block has idle pages or not in the storage process, and performing erasing operation on the first target block under the condition that the first target block has idle pages or not, wherein the standby power process is the next process comprising electronic equipmentThe standby power protection control information comprises power-down protection control information and power-up protection control information; the nth standby power process comprises an nth power-down process and an nth power-up process, N is a positive integer, standby power protection control information corresponding to each standby power process is sequentially stored in pages of the first target block of the nonvolatile memory according to the occurrence sequence of the standby power processes, whether the first target block has idle pages or not is determined in real time in the storage process, and if not, the first target block is subjected to erasing operation, wherein the steps include: a storage step of storing the power-down protection control information of the Nth power-down process to a 2N-1 th page, storing the power-up protection control information of the Nth power-up process to a 2N-th page, wherein N is more than or equal to 1 and less than or equal to M/2, M is a positive integer, and M is the number of pages in the first target block; repeating the storing step at least once until the first target block has no free page, and performing erasing operation on the first target block; storing the power-up protection control information of the nth power-up process to a 2 nth page, including: acquiring a third target number, wherein the third target number is the number of the power-on processes before the occurrence of the Nth power-on process; according to the formula Acquiring the number of the 2N-th page, wherein ∈>For the number of the 2N-th page, -/-, for the number of the 2N-th page>For the third target number, a page of the first target block has a number; storing the power-on protection control information of the Nth power-on process to the 2 nd page according to the number of the 2N th page; storing the power-on protection control information of the nth power-on process to the 2 nth page according to the number of the 2 nth page, including: in the case where the number of the 2N-th page is equal to MDetermining that the first target block does not have a free page, wherein one page of the first target block has a number; and performing an erasing operation on the first target block.
2. The method of claim 1, wherein storing the power down protection control information for the nth power down process to page 2N-1 comprises:
acquiring a first target number, wherein the first target number is the number of the power-down processes before the Nth power-down process occurs;
acquiring the number of the 2N-1 th page, wherein the number of the 2N-1 th page is the product of the first target number and 2, and one page of the first target block is provided with one number;
And storing the power-down protection control information of the Nth power-down process to the 2N-1 th page according to the number of the 2N-1 th page.
3. The method of claim 2, wherein the power down protection control information includes a first identification, and wherein obtaining the first target number comprises:
and determining that the first target number is 0 in the case that the first identifier does not exist on the 1 st page of the first target block.
4. The method of claim 2, wherein the power down protection control information of the kth power down process includes a first identifier and a kth standby power number, the power up protection control information of the kth power up process includes a second identifier and the kth standby power number, the kth standby power number is K, 1+.k+.m/2,K is a positive integer, and obtaining the first target number includes:
under the condition that the first mark exists on the 1 st page of the first target block, a first detection step is executed, whether the first mark exists on the E th page of the first target block or not is detected according to a preset sequence, whether the second mark exists on the E th page of the first target block or not is detected, the preset sequence is the sequence from small to large of the numbers of the pages of the first target block, E is more than or equal to 2 and less than or equal to M, and E is a positive integer;
And repeating the first detection step at least once until the first identifier does not exist in the E-th page and the second identifier does not exist in the E-th page, and determining the N-1 th standby power quantity of the power-on protection control information in the E-1 th page of the first target block as the first target quantity.
5. The method of claim 1, wherein prior to storing the power down protection control information for the nth power down process to page 2N-1, the method further comprises:
acquiring target backup data, wherein the target backup data is backup data of the Nth power-down process;
the target backup data is stored to a second target block, the second target block being one of a plurality of blocks of the non-volatile memory, and the second target block being distinct from the first target block.
6. The method of claim 2, wherein the power down protection control information of a kth power down process includes a first identifier and a kth standby power amount, the power up protection control information of a kth power up process includes a second identifier and the kth standby power amount, the kth standby power amount is K, 1+.k+.m/2,K is a positive integer, and storing the power down protection control information of the nth power down process to the 2N-1 th page according to the number of the 2N-1 th page includes:
Acquiring the number of a second target block and the byte number of target backup data, wherein the second target block is one of a plurality of blocks of the nonvolatile memory, the second target block is different from the first target block, the second target block stores the target backup data, the target backup data is the backup data of the Nth power-down process, and one block of the nonvolatile memory is provided with a number;
calculating the sum of the first target quantity and 1 to obtain an N standby electricity quantity;
and storing the first identifier, the N-th standby power quantity, the number of the second target block and the byte quantity of the target backup data to the 2N-1 th page according to the number of the 2N-1 th page.
7. The method of claim 2, wherein prior to storing the power-up protection control information for the nth power-up process to page 2N, the method further comprises:
acquiring the number of a second target block and the byte number of target backup data from the 2N-1 th page, wherein the second target block is one of a plurality of blocks of the nonvolatile memory, and is different from the first target block, the target backup data are stored in the second target block, the backup data of the Nth power-down process are stored in the target backup data, and one block of the nonvolatile memory is provided with a number;
And acquiring the target backup data from the second target block according to the number of the second target block and the byte number of the target backup data so as to restore the environment configuration of the electronic equipment.
8. The method of claim 7, wherein the power down protection control information comprises a first identification and the power up protection control information comprises a second identification, the method further comprising, prior to obtaining the number of a second target block and the number of bytes of target backup data from the page 2N-1:
a second detection step of detecting whether the first mark exists on the F-th page of the first target block according to a preset sequence, wherein F is more than or equal to 1 and less than or equal to 2N-1, and F is a positive integer;
a third detecting step of detecting whether the second identifier exists on the f+1st page of the first target block in the case that the first identifier exists on the F-th page, wherein the preset sequence is the sequence from small to large of the numbers of the pages of the first target block;
and repeating the second detection step and the third detection step at least once until the second mark does not exist on the F+1st page, and determining the F page as the 2N-1st page.
9. The method of claim 1, wherein the power down protection control information of the kth power down process includes a first identifier and a kth standby power amount, the power up protection control information of the kth power up process includes a second identifier and the kth standby power amount, the kth standby power amount is K, 1+.k+.m/2,K is a positive integer, and obtaining a third target amount includes:
A fourth detection step of detecting whether the first identifier exists on the D-th page of the first target block according to a preset sequence; a fifth detection step of detecting whether the second mark exists on the (D+1) th page of the first target block or not in the case that the first mark exists on the (D) th page, wherein the preset sequence is the sequence from small to large of the numbers of the pages of the first target block, and D is more than or equal to 1 and less than or equal to M;
and repeating the fourth detection step and the fifth detection step at least once until the second identifier does not exist in the (D+1) th page, and determining the (N-1) th standby power quantity of the power-down protection control information in the (D) th page as the third target quantity.
10. The method of claim 1, wherein the power-up protection control information of the kth power-up process includes a second identifier and a kth standby power number, the kth standby power number being K, 1+.k+.m/2,K being a positive integer, the storing the power-up protection control information of the nth power-up process to the 2 nth pages according to the number of the 2 nth pages comprising:
calculating the sum of the third target quantity and 1 to obtain the N standby electricity quantity;
And storing the second identifier and the N standby power quantity to the 2N pages.
11. The method of claim 1, wherein storing the power-up protection control information of the nth power-up process to the 2 nth page according to the number of the 2 nth page comprises:
and storing the power-on protection control information of the Nth power-on process to the 2N < th > page according to the number of the 2N < th > page when the number of the 2N < th > page is smaller than M, wherein one page of the first target block has one number.
12. The method of claim 2, wherein storing the power down protection control information of the nth power down procedure to the 2N-1 th page according to the number of the 2N-1 th page comprises:
and storing the power-down protection control information of the Nth power-down process to the 2N-1 th page according to the number of the 2N-1 th page under the condition that the number of the 2N-1 th page is smaller than M-1, wherein one page of the first target block is provided with one number.
13. The method of claim 2, wherein the power-up protection control information includes a second identifier, and storing the power-down protection control information of the nth power-down process to the 2N-1 th page according to the number of the 2N-1 th page includes:
Detecting whether the second identification exists on the 2N page or not under the condition that the number of the 2N-1 page is equal to M-1;
the second identifier exists on the 2N page, it is determined that the first target block does not have a free page, and one page of the first target block has a number;
and performing an erasing operation on the first target block.
14. The method of claim 1, wherein performing an erase operation on the first target block comprises:
an erasing step of erasing the power-down protection control information of the nth power-down process of the 2N-1 th page and erasing the power-up protection control information of the nth power-up process of the 2N-th page;
the erasing step is repeated N times.
15. The method of claim 1, wherein determining one of the plurality of blocks of non-volatile memory as the first target block comprises:
a block numbered 0 in the non-volatile memory is determined as the first target block.
16. A device for erasing a non-volatile memory, the device comprising:
a determining module for determining one of a plurality of blocks of the non-volatile memory as a first target block;
The erasing module is used for sequentially storing standby power protection control information corresponding to each standby power process in pages of the first target block of the nonvolatile memory according to the occurrence sequence of the standby power processes, determining whether the first target block has idle pages in real time in the storage process, and performing erasing operation on the first target block under the condition of no, wherein the standby power processes comprise a power-down process of the electronic equipment and a power-up process of the electronic equipment, and the standby power protection control information comprises power-down protection control information and power-up protection control information; the N-th standby power process comprises an N-th power-down process and an N-th power-up process, N is a positive integer, and the erasing module comprises: a storage sub-module, configured to perform a storage step, store the power-down protection control information of the nth power-down process to a 2n_1st page, store the power-up protection control information of the nth power-up process to a 2n_th page, where N is greater than or equal to 1 and less than or equal to M/2, M is a positive integer, and M is the number of pages in the first target block; a repeating sub-module, configured to repeat the storing step at least once until the first target block does not have a free page, and perform an erasing operation on the first target block; the storage submodule includes: a third acquisition unit for acquiring a third target number The third target number is the number of the power-up processes before the nth power-up process occurs; a fourth acquisition unit for according to the formulaAcquiring the number of the 2N-th page, wherein ∈>For the number of the 2N-th page, -/-, for the number of the 2N-th page>For the third target number, a page of the first target block has a number; a second storage unit, configured to store the power-on protection control information of the nth power-on process to the 2 nd page according to the number of the 2 nd page; the second storage unit further includes: a first determining subunit, configured to determine that, if the number of the nth page is equal to M, there is no free page in the first target block, where one page of the first target block has one number; and the first erasing subunit is used for erasing the first target block.
17. A computer readable storage medium, characterized in that a computer program is stored in the computer readable storage medium, wherein the computer program, when being executed by a processor, implements the steps of the method according to any of the claims 1 to 15.
18. An electronic device, comprising: a non-volatile memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the method of any one of claims 1 to 15 when the computer program is executed.
19. The electronic device of claim 18, wherein the electronic device is a disk array card.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202311514244.7A CN117251116B (en) | 2023-11-14 | 2023-11-14 | Erasing and writing method and device of nonvolatile memory |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202311514244.7A CN117251116B (en) | 2023-11-14 | 2023-11-14 | Erasing and writing method and device of nonvolatile memory |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN117251116A CN117251116A (en) | 2023-12-19 |
| CN117251116B true CN117251116B (en) | 2024-02-20 |
Family
ID=89135369
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202311514244.7A Active CN117251116B (en) | 2023-11-14 | 2023-11-14 | Erasing and writing method and device of nonvolatile memory |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN117251116B (en) |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101770809A (en) * | 2008-12-31 | 2010-07-07 | J·埃金顿 | Recovery after power down of non-volatile memory |
| CN102169462A (en) * | 2011-04-27 | 2011-08-31 | 中国科学院光电技术研究所 | Data recording method and recording controller based on NAND Flash |
| CN113785275A (en) * | 2020-12-17 | 2021-12-10 | 深圳杰睿联科技有限公司 | Flash data power-down protection method and device |
| CN114518845A (en) * | 2022-01-06 | 2022-05-20 | 中汽创智科技有限公司 | Data storage method, device, medium and device |
-
2023
- 2023-11-14 CN CN202311514244.7A patent/CN117251116B/en active Active
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101770809A (en) * | 2008-12-31 | 2010-07-07 | J·埃金顿 | Recovery after power down of non-volatile memory |
| CN102169462A (en) * | 2011-04-27 | 2011-08-31 | 中国科学院光电技术研究所 | Data recording method and recording controller based on NAND Flash |
| CN113785275A (en) * | 2020-12-17 | 2021-12-10 | 深圳杰睿联科技有限公司 | Flash data power-down protection method and device |
| CN114518845A (en) * | 2022-01-06 | 2022-05-20 | 中汽创智科技有限公司 | Data storage method, device, medium and device |
Also Published As
| Publication number | Publication date |
|---|---|
| CN117251116A (en) | 2023-12-19 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN112631516B (en) | FLASH file management system with service life management function | |
| US8402204B2 (en) | Methods for measuring usable lifespan and replacing an in-system programming code of a memory device, and data storage system using the same | |
| EP3262508B1 (en) | Patrol scrub periods based on power status | |
| CN109213448B (en) | Method, device, equipment and storage medium for erasing and writing data of smart card | |
| EP3667504B1 (en) | Storage medium management method, device and readable storage medium | |
| US11126376B2 (en) | Apparatus and method for performing recovery operation of memory system | |
| CN109582332B (en) | System upgrading method and device for Internet camera | |
| CN111221470A (en) | Data processing method, electronic device and storage medium | |
| CN111880745A (en) | Data processing method, device and equipment based on solid-state disk array and storage medium | |
| CN113360092A (en) | Data storage method, data storage device and electronic equipment | |
| CN116417025B (en) | Power failure processing method, solid state disk and computing device | |
| CN112188472A (en) | Method, device, computer equipment and medium for re-identifying SIM card after SIM card is dropped | |
| CN105868046B (en) | The method of management, write-in and loading firmware code in storage device | |
| US10007449B2 (en) | Memory management method, memory control circuit unit, and memory storage apparatus | |
| CN109582230B (en) | Matrix index-based data access method and access system | |
| CN117251116B (en) | Erasing and writing method and device of nonvolatile memory | |
| CN114327246B (en) | Method for storing data in storage medium, storage medium and computer device | |
| CN117493070A (en) | Method and system for processing storage bad blocks | |
| CN102237117A (en) | Method and device for calculating service life of mobile storage device | |
| CN116048392A (en) | Data storage method and system based on Internet of things equipment and electronic equipment | |
| CN110008059B (en) | Data update method, device and storage medium of non-volatile storage medium | |
| CN110007856B (en) | Data storage method and device and flash memory chip | |
| CN110333967B (en) | Method, device and equipment for preventing USB flash disk data loss and system damage | |
| CN118331506B (en) | Data writing implementation method and device | |
| CN114637626B (en) | Method, device and equipment for reducing read-write errors of EEPROM (electrically erasable programmable read-only memory) data and readable storage medium |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |