WO2020113440A1 - Data storage method, flash device, intelligent battery, and movable platform - Google Patents

Data storage method, flash device, intelligent battery, and movable platform Download PDF

Info

Publication number
WO2020113440A1
WO2020113440A1 PCT/CN2018/119230 CN2018119230W WO2020113440A1 WO 2020113440 A1 WO2020113440 A1 WO 2020113440A1 CN 2018119230 W CN2018119230 W CN 2018119230W WO 2020113440 A1 WO2020113440 A1 WO 2020113440A1
Authority
WO
WIPO (PCT)
Prior art keywords
storage unit
data
reserved
flash memory
memory device
Prior art date
Application number
PCT/CN2018/119230
Other languages
French (fr)
Chinese (zh)
Inventor
张华森
江帆
Original Assignee
深圳市大疆创新科技有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 深圳市大疆创新科技有限公司 filed Critical 深圳市大疆创新科技有限公司
Priority to CN201880041365.5A priority Critical patent/CN110799935A/en
Priority to PCT/CN2018/119230 priority patent/WO2020113440A1/en
Publication of WO2020113440A1 publication Critical patent/WO2020113440A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0614Improving the reliability of storage systems
    • G06F3/0616Improving the reliability of storage systems in relation to life time, e.g. increasing Mean Time Between Failures [MTBF]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0238Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
    • G06F12/0246Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/10Address translation
    • G06F12/1009Address translation using page tables, e.g. page table structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0629Configuration or reconfiguration of storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0646Horizontal data movement in storage systems, i.e. moving data in between storage devices or systems
    • G06F3/0652Erasing, e.g. deleting, data cleaning, moving of data to a wastebasket
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0679Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]

Definitions

  • the embodiments of the present invention relate to the field of storage technologies, and in particular, to data storage methods, flash memory devices, smart batteries, and removable platforms.
  • the flash memory flash memory device has been widely used in the embedded field because it has the characteristics of erasable, programmable, no loss of power-off data and support for fast read access.
  • the flash memory device must first perform an erase operation when writing data, and the erase operation is based on the smallest erase unit (sector) as a unit. Since the number of erasures of each minimum erasing unit is limited, usually only 100,000 times, it is necessary to manage the erasure times of each minimum erasing unit, so as to ensure that the erasure times are balanced.
  • Flash, Transform, Layer, FTL Flash memory
  • the current Flash conversion layer needs to track and manage the number of erasures for each minimum erase unit, and requires more storage space and computing resources.
  • the Flash conversion layer For electronic devices using a single-chip MCU as a microprocessor, it is more difficult to implement the Flash conversion layer due to limited storage space and computing resources.
  • the embodiments of the present invention provide a data storage method, a flash memory device, a smart battery, and a removable platform.
  • an embodiment of the present invention provides a data storage method, including:
  • an embodiment of the present invention provides a flash memory device, including a processor, a memory, and a flash memory device.
  • the flash memory device is provided with a plurality of minimum storage units, and the processor implements after reading executable instructions from the memory:
  • an embodiment of the present invention provides a smart battery, including a processor, a memory, and a flash memory device.
  • the flash memory device is provided with a plurality of minimum storage units, and the processor implements after reading executable instructions from the memory:
  • an embodiment of the present invention provides a movable platform, including the smart battery described in the third aspect.
  • an embodiment of the present invention provides a readable storage medium that stores a number of computer instructions, and when the computer instructions are executed, the steps of the method of the first aspect are implemented.
  • the storage times of the flash memory device can be determined. Then, it is compared whether the storage times and the times threshold are equal, and then, it is determined whether to perform address conversion on the reserved storage unit in the flash memory device according to the comparison result.
  • FIG. 1 is a schematic flowchart of a data storage method according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of a process for obtaining storage times provided by an embodiment of the present invention
  • FIG. 3 is another schematic flowchart of acquiring storage times provided by an embodiment of the present invention.
  • FIG. 4 is a schematic flowchart of writing data according to a storage state of a first storage unit according to an embodiment of the present invention
  • FIG. 5(a) to FIG. 5(b) are schematic diagrams of the results of writing data when the first storage unit provided by the embodiment of the present invention is not full of data;
  • 6(a) to 6(c) are schematic diagrams of a process of writing data when the first storage unit provided by the embodiment of the present invention has filled with data;
  • FIG. 7 is a schematic diagram of a process of writing data before address conversion provided by an embodiment of the present invention.
  • 8(a) to 8(f) are schematic diagrams of a process of writing data first and then address conversion provided by an embodiment of the present invention.
  • FIG. 9 is a schematic flowchart of address conversion before writing data according to an embodiment of the present invention.
  • FIG. 10(a) to FIG. 10(d) are schematic diagrams of a process of address conversion before writing data when the first storage unit is full of data provided by an embodiment of the present invention
  • 11(a) to 11(c) are schematic diagrams of a process of address conversion before writing data when the first storage unit is not full of data according to an embodiment of the present invention
  • FIGS. 13(a) to 13(d) are schematic diagrams of a process of simultaneously performing address conversion and writing data when the first storage unit is full of data according to an embodiment of the present invention
  • FIG. 14 is a schematic flowchart of a data storage method according to an embodiment of the present invention.
  • 15(a) to 15(b) are schematic diagrams of a process for excluding bad blocks from being a first storage unit according to an embodiment of the present invention
  • 16(a)-FIG. 16(b) are schematic diagrams of a process of removing bad blocks to reserve storage units provided by an embodiment of the present invention.
  • 17(a) to 17(b) are schematic diagrams of a process for excluding bad blocks from being a second storage unit according to an embodiment of the present invention
  • 18(a) to 18(h) are schematic process diagrams of a data storage method provided by an embodiment of the present invention.
  • FIG. 19 is a block diagram of a flash memory device provided by an embodiment of the present invention.
  • 20 is a block diagram of a smart battery provided by an embodiment of the present invention.
  • the conversion layer FTL needs to manage the erasure times of each minimum erasure unit to avoid some minimum erasure units reaching the erasure times soon The upper limit and part of the smallest erasing unit has not been erased or rarely erased.
  • the embodiments of the present invention provide a data storage method, which can use FTL software to perform equalization processing on the number of erasures of each minimum erasing unit in the flash memory device.
  • the inventive concept is to set a reserved storage unit and then store it in the flash memory. When the storage frequency of the device reaches the threshold of the number of times, address conversion is performed on the reserved storage unit. The address conversion avoids writing data to the same minimum storage unit multiple times, so that the probability of data storage in each minimum storage unit tends to be consistent, even if each minimum storage unit The number of erasures tends to be consistent to achieve a balanced effect.
  • mapping relationship between the logical address (LA) and the physical address (PA) may be stored in the flash memory device in advance.
  • the physical address refers to the first address of the smallest storage unit
  • the logical address refers to the first address of the logical block that has a mapping relationship with the smallest storage unit.
  • mapping relationship including the logical address and the physical address may be stored in any minimum storage unit in the flash memory device.
  • the mapping relationship is stored in the last smallest storage unit of the flash memory device.
  • the technician can also store the mapping relationship in an external storage, cloud, etc., and in the case where the solution of this embodiment can be implemented, the corresponding solution falls within the protection scope of the present application.
  • the minimum storage unit refers to the smallest physical area (ie, the minimum erase unit) that can be operated each time the flash memory device is erased, for example, 4K bits.
  • the technician can also adjust the size of the minimum storage unit according to the specific scenario, and the corresponding solution falls within the protection scope of the present application.
  • FIG. 1 is a schematic flowchart of a data storage method according to an embodiment of the present invention.
  • a data storage method includes steps 101 to 103, where:
  • step 101 if a data storage request is received, the number of storage times of the flash memory device is determined.
  • the FTL software in the flash memory device can interact with the application software.
  • the user can select a location to store data through the application software, and the location may include one logical address or multiple logical addresses.
  • the process of writing data to each logical address still starts from the first logical address, which is similar to the writing scheme of one logical address, so the subsequent embodiment chooses a scenario description scheme of logical addresses .
  • the flash memory device may receive the data storage request of the application software.
  • the data storage request includes a first logical address, and the first logical address may be mapped to a physical address, and the physical address represents a head address of a minimum storage unit, and may also indicate head addresses of a plurality of minimum storage units.
  • the FTL software each time a data storage request is received, the FTL software records the data storage request or modifies the number of times the flash memory device has stored data, so that the number of times the flash memory device is stored can be determined. It should be noted that when determining the storage times, the records can be obtained first, and then the storage times can be determined in conjunction with the data storage request; the data storage requests can also be recorded first, and then the storage times of the flash memory device can be determined. Technicians can make settings according to specific scenarios, which are not limited here.
  • the storage times may include: the number of times data has been written to the flash memory device from the perspective of the storage device.
  • determining the storage times of the flash memory device may include:
  • the FTL software adjusts the recorded storage times (corresponding to step 201).
  • the adjustment method can be to record the data storage request, and then count the data storage request that has been recorded, so as to obtain the storage times; or add 1 to the previous storage times, and use the adjusted times as the determined storage times. Then, the recorded storage times are read to obtain the storage times of the flash memory device (corresponding to step 202).
  • the storage times may further include: from the perspective of the smallest storage unit, the number of times data has been written to the first storage unit.
  • determining the storage times of the flash memory device may include:
  • the first logical address is obtained in the data storage request, and the first logical address refers to a logical address that the user desires to write data.
  • the FTL software adjusts the storage times of the first logical address in the data storage request, and the storage times of the first logical address refers to the number of times the data has been written in the first logical address (corresponding to step 301). Then, the FTL software reads the storage times of the first logical address in the data storage request to obtain the storage times of the flash memory device (corresponding to step 302).
  • step 102 the stored number of times is compared with a preset number of times threshold to obtain a comparison result.
  • the threshold of times can be set in advance, and the threshold of times can be adjusted according to the specifics, for example, according to empirical values, for example, according to the statistics of big data, the longest life of the flash memory device or the minimum storage unit
  • the threshold value of the number of times corresponding to the same erasure times, the similarity, or the smallest difference corresponds to the threshold number of times in this embodiment.
  • the technician can also set the threshold of the number of times according to other methods. In the case where the scheme of the present application can be realized, the corresponding scheme falls within the protection scope of the present application.
  • the threshold of the number of times may be stored in any minimum storage unit in the flash memory device.
  • the number of times threshold is stored in the last smallest storage unit of the flash memory device.
  • the FTL software can compare the storage times and the threshold of the times to obtain a comparison result.
  • the comparison result may include that the storage times and the threshold are equal, or the storage times and the thresholds are not equal.
  • the FTL software when the number of storage times is equal to the threshold of the number of times, in this embodiment, the FTL software also clears the number of storage times.
  • the method of clearing may include deleting the recorded storage data storage request, marking the recorded storage data storage request, and resetting the storage frequency variable to zero.
  • step 103 it is determined according to the comparison result whether to perform address conversion on the reserved storage unit in the flash memory device.
  • the FTL software may determine whether to perform address conversion on the reserved storage unit in the flash memory device according to the comparison result, which may include:
  • the comparison result is that the number of storage times is not equal to the number of times threshold, it is determined to maintain the current mapping relationship of the storage unit and store the data to the first storage unit mapped to the first logical address in the data storage request.
  • maintaining the current mapping relationship of the reserved storage unit means that no address conversion is performed on the mapping relationship between the reserved address and the reserved storage unit.
  • the FTL software stores the data to the first storage unit mapped to the first logical address in the data storage request, referring to FIG. 4, may include:
  • the FTL software may determine the storage state of the first storage unit, where the storage state may include data indicating that the first storage unit is not full and data indicating that the first storage unit is full (corresponding to step 401).
  • the FTL software determines whether the storage status indicates that the first storage unit is not full of data or that the first storage unit is full of data (corresponding to step 402).
  • the FTL software After that, if the storage status indicates that the first storage unit is not full of data, the FTL software writes the data to the tail of the stored data (corresponding to step 403), that is, directly writes data to the first storage unit, without the need for the first storage
  • the cell is erased. 5(a) to 5(b), taking the first logical address as the first logical address LA0 in the logical address space as an example, the FTL software determines that the data XX0 already stored in the first storage unit PA1 and the data XX0 The size of is smaller than the size of the first storage unit PA1, that is, the first storage unit PA1 is not full of data, the FTL software writes data from the end of the data XX0, and obtains the result shown in FIG. 5(b).
  • the FTL software erases the first storage unit, and then writes data to the first storage unit (corresponding to step 404). 6(a) to 6(c), continue to take the first logical address as the first logical address LA0 of the logical address space as an example, the FTL software determines the data XX1 already stored in the first storage unit PA1, and the data The size of XX1 is equal to the size of the first storage unit PA1, that is, the first storage unit PA1 has been filled with data, FTL software erases the data XX1 in the first storage unit PA1, using FF to indicate that no data is stored, the result is shown in Figure 6(b ) As shown. Then, the FTL software writes data to the first storage unit PA1, and the result is shown in FIG. 6(c).
  • FIG. 5(a) to FIG. 5(b) and FIG. 6(a) to FIG. 6(c) are shown by adding groups and underlining.
  • Scenario 1 If the result of the comparison is that the number of storage times is equal to the threshold of number of times, then it is determined to perform address conversion on the reserved storage unit. Address translation can include the following methods:
  • the FTL software writes data to the first storage unit (corresponding to step 701).
  • the scenario of writing data may consider that the first storage unit has full data or not full data, see FIG. 5(a ) To FIG. 5(b) and FIG. 6(a) to FIG. 6(c), which will not be repeated here.
  • the FTL software erases the reserved storage unit and copies the data in the first storage unit to the reserved storage unit (corresponding to step 702).
  • the FTL software maps the first logical address to the reserved storage unit and the reserved address to the first storage unit to complete the address conversion (corresponding to step 703).
  • FTL software erases the first memory cell PA1.
  • Data XX1 becomes data FF, and the result is shown in Figure 8(b).
  • the FTL software writes data into the first storage unit PA1, and the result is shown in FIG. 8(c).
  • the FTL software erases the reserved memory cell PA0, and the data in the reserved memory cell PA0 changes from XX2 to FF.
  • FIG. 8(d) The result is shown in FIG. 8(d).
  • the FTL software to copy the data in the first storage unit PA1 PA0 to retain the storage unit, the reservation data storage unit PA0 from FF to the data, the results shown in FIG 8 (e) in FIG.
  • the FTL software maps the first logical address LA0 to the reserved storage unit PA0 and the reserved address RS to the first storage unit PA1 to complete the address conversion. The result is shown in FIG. 8(f).
  • FIG. 8(a) to FIG. 8(f) are shown by adding groups and underlining.
  • the FTL software maps the first logical address to the reserved storage unit and the reserved address to the first storage unit to complete address conversion (corresponding to step 901). Then, the FTL software stores the data in the reserved storage unit mapped to the first logical address (corresponding to step 902).
  • step 902 it may include a case: Case 1, if the reserved storage unit is not full of data, data is written from the end of the stored data. Case 2: If the reserved storage unit is full of data, the reserved storage unit is erased and data is written.
  • FIG. 10(a) In the case where the reserved storage unit is full of data, refer to FIG. 10(a), continue to map the reserved address RS to the reserved storage unit PA0, and the first logical address LA0, and take the data XX1 stored in the first storage unit PA1 as an example .
  • the FTL software maps the first logical address LA0 to the reserved storage unit PA0 and the reserved address RS to the first storage unit PA1 to complete the address conversion.
  • the result is shown in FIG. 10(b).
  • the FTL software erases the data XX2 in the reserved memory cell PA0 into data FF, and the result is shown in FIG. 10(c).
  • the FTL software to write data to the reserved memory unit PA0, the results shown in FIG 10 (d) shown in FIG.
  • FIG. 11(a) In the case where the reserved storage unit is not full of data, refer to FIG. 11(a), continue to map the reserved address RS to the reserved storage unit PA0, and the first logical address LA0, and use the stored data XX1 in the first storage unit PA1 as example.
  • the FTL software maps the first logical address LA0 to the reserved storage unit PA0 and the reserved address RS to the first storage unit PA1 to complete the address conversion. The result is shown in FIG. 11(b). Then, FTL software writes data retained in the storage unit after the data PA0 XX2, the results shown in FIG 11 (c) shown in FIG.
  • FIG. 10(a) to FIG. 10(d) and FIG. 11(a) to FIG. 11(c) are shown by adding groups and underlining.
  • address translation may include:
  • the FTL software writes data to the first storage unit (corresponding to step 1201).
  • step 1201 For the manner of writing data to the first storage unit, reference may be made to the contents of FIG. 5(a) to FIG. 5(b) and FIG. 6(a) to FIG. 6(c), which will not be repeated here.
  • the FTL software erases the reserved memory cells to erase the reserved memory cells (corresponding to step 1202). Then, the FTL software copies the data in the second storage unit to the reserved storage unit (corresponding to step 1203). Finally, the FTL software maps the reserved address to the second storage unit and the second logical address to the reserved storage unit to complete the address conversion (corresponding to step 1204).
  • step 1201 can precede step 1202 to step 1204, step 1201 can follow step 1202 to step 1204, and step 1201 can be simultaneously with step 1202 to step 1204 carried out.
  • step 1201 is executed simultaneously with steps 1202 to 1204 as an example for description.
  • the reserved address RS is mapped to the reserved memory unit PA0, and the second logical address LA0 is mapped to the second memory unit PA1, the first logical address LA5 is mapped to the first memory unit PA5, and the reserved memory unit PA0
  • the data XX2 is stored, the second storage unit PA1 stores data XX3, and the first storage unit PA5 stores data XX1.
  • the FTL software erases the data XX1 in the first memory cell PA5 into data FF, and erases the data XX2 in the reserved memory cell PA0 into data FF, and the result is shown in FIG. 13(b).
  • the FTL software writes the data in the first storage unit PA5, and copies the data XX3 in the second storage unit PA1 to the reserved storage unit PA0, that is, the data FF in the reserved storage unit PA0 becomes XX3, and the result is shown in FIG. 13 (c) shown.
  • the FTL software reserved address RS is mapped to the second storage unit PA1 and the second logical address LA0 is mapped to the reserved storage unit PA0 to complete the address conversion. The result is shown in FIG. 13(d).
  • the storage times of the flash memory device can be determined. Then, it is compared whether the storage times and the times threshold are equal, and then, it is determined whether to perform address conversion on the reserved storage unit in the flash memory device according to the comparison result. It can be seen that in this embodiment, by setting the threshold of the number of times of storage, when the threshold of the number of times is reached, the address conversion is performed on the reserved storage unit in the flash memory device, thereby avoiding writing data to the same minimum storage unit multiple times, so that each minimum storage unit in the flash memory device The probability of being erased tends to be consistent, so as to achieve the effect of balancing the number of erases, which is beneficial to prolong the service life of flash memory devices. In addition, in this embodiment, only part of the data of the smallest storage unit is processed, and the requirements on storage space and computing resources are relatively low, which is suitable for a flash memory device using a single-chip MCU as a processor.
  • state information may be set for each smallest storage unit, and the state information may be used to record the health status and status information of each smallest storage unit. At least include the health state and other states. Other states include at least one of the following: read failure, write failure, and erase failure.
  • a data storage method may further include:
  • the FTL software obtains the status information of each minimum storage unit of the flash memory device (corresponding to step 1401).
  • the FTL software can obtain the status information of all the smallest storage units in the flash memory device, so that the status information of any one of the smallest storage units can be quickly queried.
  • the FTL software can also obtain the minimum storage unit related to the data storage and address conversion, so that the amount of data obtained is small and the query speed is fast.
  • the FTL software determines that the status information of each minimum storage unit is healthy, it performs a step of determining whether to perform address conversion on the reserved storage unit in the flash memory device according to the comparison result (corresponding to step 1402).
  • the comparison result For the content of the comparison result to determine whether to perform address conversion on the reserved storage unit in the flash memory device, reference may be made to FIG. 1 and related content, which will not be repeated here.
  • the FTL software determines that the state information of the first storage unit mapped by the first logical address is other than the healthy state
  • the first storage unit is replaced and the determination according to the comparison result is performed.
  • the step of performing address conversion on the storage unit reserved in the flash memory device For the content of determining whether to perform address conversion on the reserved storage unit in the flash memory device according to the comparison result, refer to FIG. 1 and related content, and details are not described herein again.
  • replacing the first storage unit may include: referring to FIG. 15(a), because the status information of the first storage unit PA1 is other states, the FTL software will replace the third storage unit PA2 adjacent to the first storage unit PA1 As the first storage unit after replacement, a mapping relationship between the first logical address LA0 and the first storage unit after replacement (ie, the third storage unit PA2) is then established, and the result is shown in FIG. 15(b).
  • the first storage unit PA in FIG. 15(a) is a bad block, which is shown on a gray background, and the third logical address in FIG. 15(b) does not have a mapping relationship, and is also shown on a gray background.
  • bad blocks i.e., the first storage unit PA1
  • the third logical address LA1 is removed from the mapping relationship, so as to ensure the relationship between the logical address and each minimum storage unit in the mapping relationship.
  • the minimum storage unit in which the FTL software obtains status information further includes a reserved storage unit. If the status information of the reserved storage unit is other states, the FTL software uses the smallest storage unit closest to the reserved storage unit as the reserved storage unit after replacement, and establishes the mapping relationship between the reserved address and the reserved storage unit after replacement. Referring to FIG. 16(a), when the state information of the reserved storage unit PA0 is detected to be other states, the FTL software detects that the nearest smallest storage unit of the reserved storage unit PA0 is the second storage unit PA1, so the FTL software stores the second storage unit The unit PA1 serves as a reserved storage unit after replacement and establishes a mapping relationship between the reserved address RS and the second storage unit PA1. The result is shown in FIG. 16(b).
  • the reserved storage unit PA0 before replacement is a bad block and is eliminated from the mapping relationship; the second logical address LA0 has no minimum storage unit mapped to it, and the deleted content is shown on a gray background.
  • the minimum storage unit for obtaining status information by the FTL software further includes a second storage unit. If the status information of the second storage unit is other states, the FTL software uses the smallest storage unit closest to the second storage unit as the reserved storage unit after replacement, and establishes the mapping relationship between the reserved address and the replaced storage unit after replacement. Referring to FIG.
  • the FTL software detects that the nearest smallest storage unit of the second storage unit PA1 is the fourth storage unit PA2, so the FTL software will
  • the four storage units PA2 are used as reserved storage units after replacement, and the mapping relationship between the reserved address RS and the fourth storage unit PA2 is established, and the second storage unit PA1 and the fourth logical address LA1 indicated by the gray background are removed, and the result is as shown in the figure 17(b).
  • the last smallest storage unit of the reserved storage unit RS after replacement is changed from the second storage unit PA1 to the fourth storage unit PA2. If the reserved storage unit RS needs address conversion, it can be converted according to the address conversion method shown in FIG. 4 or FIG. 7, which will not be repeated here.
  • the data storage method provided by the embodiments of the present invention will be described below with reference to the embodiments and the accompanying drawings.
  • the threshold value of the number of times is 1, that is, each time the user writes data to the flash memory device, the address RS is reserved for address conversion.
  • the FTL software can display the logical address to the user, and the user selects the logical address into which the data is stored. For convenience of description, in this embodiment, the solution of this embodiment is described in a manner that a user sequentially selects logical addresses.
  • the reserved address RS is mapped to the reserved memory unit PA0, and the logical addresses LA to N-1 are sequentially mapped to the smallest memory units PA to 1 to PA, in which the smallest memory unit SA stores all the information required by the FTL software.
  • the smallest storage unit SA is not visible (shown by a slanted background).
  • the FTL software when storing data for the first time, the FTL software detects that the user chooses to write data to the first logical address LA0, and at this time the first logical address is mapped to PA1. Since the storage number of the flash memory device reaches 1 and the status information of each minimum storage unit is healthy, the FTL software performs address conversion on the reserved storage unit and writes data XX0. The result is shown in FIG. 18(c).
  • the logical address LA0 is mapped to the smallest storage unit PA0, and the save address is mapped to the smallest storage unit PA1, that is, the smallest storage unit PA1 becomes a reserved storage unit.
  • the FTL software when storing data for the second time, the FTL software detects that the user selects to write data to the first logical address LA1, and at this time the first logical address is mapped to PA2. Since the storage number of the flash memory device reaches 1, the FTL software detects that the first storage unit PA2 is a bad block (the status information is other status), as shown in FIG. 18(d). The FTL software first replaces the first storage unit. Since the closest storage unit of the minimum storage unit PA2 is the minimum storage unit PA3, the minimum storage unit PA3 is used as the first storage unit after replacement. The result is shown in FIG. 18(e). Then, the FTL software performs address conversion on the reserved storage unit PA1 and writes data XX1. The result is shown in FIG. 18(f). At this time, the logical address LA1 is mapped to the smallest storage unit PA1, and the stored address RS is mapped to the smallest storage unit. PA3, the smallest storage unit PA3, becomes a reserved storage unit.
  • FIGS. 18(a) to 18(h) show the cyclic process in which the reserved memory cells pass through the smallest memory cells PA0, PA1, PA3, ..., PA-1, and then return to the smallest memory cell PA0.
  • the data written by the user can be guaranteed to be stored in different minimum storage units, which can prevent the user from writing the data to the same logical address multiple times, the same minimum storage unit erasure times increase too fast The situation achieves the effect of balancing the number of erasures of each memory cell.
  • the FTL software in the scenario where data is written without address conversion, the FTL software only manages the first storage unit mapped by the first logical address; in the scenario where data is written and address conversion is required, the FTL software Only the first storage unit and the reserved storage unit (the two are adjacent) are managed; in the scenario where data is written, address conversion is required, and the first storage unit and the reserved storage unit are not adjacent, the FTL software only stores the first storage unit Units, reserved storage units and second storage units are managed, that is, the number of storage units managed by the FTL software each time is greatly reduced, and the demand for storage resources and computing resources is low, which is suitable for the scenario where a single-chip microcomputer is used as a processor.
  • FIG. 19 is a block diagram of a flash memory device according to an embodiment of the present invention.
  • a flash memory device 1900 includes a processor 1901, a memory 1902, and a flash memory device 1904.
  • the flash memory device is provided with a plurality of minimum storage units, and each storage unit can be used for data.
  • the processor 1901 passes a communication bus 1903. Communicating with the memory 1902, the processor 1901 realizes after reading the executable instructions from the memory 1902:
  • the processor 1901 is configured to determine the storage times of the flash memory device includes:
  • the processor 1901 is configured to determine the storage times of the flash memory device includes:
  • the number of times of storing the first logical address refers to the number of times data has been written in the first logical address
  • the processor 1901 is configured to determine whether to perform address translation on the reserved storage unit in the flash memory device according to the comparison result includes:
  • the comparison result is that the storage times are not equal to the times threshold, it is determined to maintain the current mapping relationship of the reserved storage unit and store the data to the first storage mapped to the first logical address in the data storage request unit.
  • the first storage unit of the first logical address mapping used by the processor 1901 to store data in the data storage request includes:
  • the storage state indicates that the first storage unit is full of data, the first storage unit is erased and data is written.
  • the processor 1901 is configured to determine whether to perform address translation on the reserved storage unit in the flash memory device according to the comparison result includes:
  • the processor 1901 is configured to perform address conversion on the reserved storage unit including:
  • the first logical address is mapped to the reserved storage unit and the reserved address is mapped to the first storage unit to complete address conversion.
  • the flash memory device includes a reserved storage unit mapped to a reserved address; if the reserved storage unit is adjacent to the first storage unit mapped to the first logical address in the data storage request, the processor 1901 is used to perform address conversion on the reserved storage unit including:
  • the reserved storage unit used by the processor 1901 to store data to the first logical address map includes:
  • the reserved storage unit is full of data, the reserved storage unit is erased and data is written.
  • the flash memory device includes a reserved storage unit mapped to a reserved address and a second storage unit mapped to a second logical address, the reserved storage unit is adjacent to the second storage unit and is The first storage units are not adjacent, and the processor 1901 for performing address conversion on the reserved storage unit includes:
  • the reserved address is mapped to the second storage unit and the second logical address is mapped to the reserved storage unit to complete address conversion.
  • the processor 1901 is further configured to:
  • the state information is used to record the health state of each minimum storage unit; the state information includes at least a health state;
  • a step of determining whether to perform address conversion on the storage unit reserved in the flash memory device is performed according to the comparison result.
  • each of the minimum storage units includes a first storage unit.
  • the processor 1901 is used to obtain status information of each minimum storage unit in the flash memory device, it is also used to:
  • the processor 1901 for replacing the first storage unit includes:
  • a third storage unit adjacent to the first storage unit is used as the replaced first storage unit, and a mapping relationship between the first logical address and the replaced first storage unit is established.
  • each of the minimum storage units includes a reserved storage unit
  • the processor 1901 is used to obtain status information of each minimum storage unit in the flash memory device, and is also used to:
  • the smallest storage unit closest to the reserved storage unit is used as the reserved storage unit after replacement, and the mapping relationship between the reserved address and the replaced reserved storage unit is established.
  • each of the minimum storage units includes a second storage unit adjacent to the reserved storage unit, and the processor 1901 is used to obtain status information of each minimum storage unit in the flash memory device and then use to:
  • the fourth storage unit adjacent to the second storage unit is used as the replaced second storage unit, and the second logical address and the replaced The mapping relationship of the second storage unit.
  • the other states include at least one of the following: read failure, write failure, and erase failure.
  • any storage unit in the flash memory device stores a mapping relationship between the first logical address and the first storage unit and a mapping relationship between the reserved address and the reserved storage unit.
  • the any storage unit is the last storage unit in the flash memory device.
  • FIG. 19 is a block diagram of a smart battery according to an embodiment of the present invention.
  • a smart battery 2000 is characterized by including a processor 2001, a memory 2002, and a flash memory device 2004.
  • the flash memory device 2004 is provided with a plurality of minimum storage units.
  • the processor 2001 reads from the memory 2002 After the executable instruction is realized:
  • the processor 2001 is used to determine the storage times of the flash memory device includes:
  • the processor 2001 is used to determine the storage times of the flash memory device includes:
  • the number of times of storing the first logical address refers to the number of times data has been written in the first logical address
  • the processor 2001 is configured to determine whether to perform address conversion on the reserved storage unit in the flash memory device according to the comparison result includes:
  • the comparison result is that the storage times are not equal to the times threshold, it is determined to maintain the current mapping relationship of the reserved storage unit and store the data to the first storage mapped to the first logical address in the data storage request unit.
  • the first storage unit of the first logical address mapping used by the processor 2001 to store data in the data storage request includes:
  • the storage state indicates that the first storage unit is full of data, the first storage unit is erased and data is written.
  • the processor 2001 is configured to determine whether to perform address conversion on the reserved storage unit in the flash memory device according to the comparison result includes:
  • the processor 2001 is configured to perform address conversion on the reserved storage unit including:
  • the first logical address is mapped to the reserved storage unit and the reserved address is mapped to the first storage unit to complete address conversion.
  • the flash memory device includes a reserved storage unit mapped to a reserved address; if the reserved storage unit is adjacent to the first storage unit mapped to the first logical address in the data storage request, the processor 2001 is used to perform address conversion on the reserved storage unit including:
  • the reserved storage unit used by the processor 2001 to store data to the first logical address map includes:
  • the reserved storage unit is full of data, the reserved storage unit is erased and data is written.
  • the flash memory device includes a reserved storage unit mapped to a reserved address and a second storage unit mapped to a second logical address, the reserved storage unit is adjacent to the second storage unit and is The first storage unit is not adjacent, and the processor 2001 is used to perform address conversion on the reserved storage unit including:
  • the reserved address is mapped to the second storage unit and the second logical address is mapped to the reserved storage unit to complete address conversion.
  • the processor 2001 is further used to:
  • the state information is used to record the health state of each minimum storage unit; the state information includes at least a health state;
  • a step of determining whether to perform address conversion on the storage unit reserved in the flash memory device is performed according to the comparison result.
  • each of the minimum storage units includes a first storage unit. After the processor 2001 is used to obtain status information of each minimum storage unit in the flash memory device, it is also used to:
  • the processor 2001 for replacing the first storage unit includes:
  • a third storage unit adjacent to the first storage unit is used as the replaced first storage unit, and a mapping relationship between the first logical address and the replaced first storage unit is established.
  • the minimum storage units include reserved storage units. After the processor 2001 is used to obtain status information of the minimum storage units in the flash memory device, it is also used to:
  • the smallest storage unit closest to the reserved storage unit is used as the reserved storage unit after replacement, and the mapping relationship between the reserved address and the replaced reserved storage unit is established.
  • each of the minimum storage units includes a second storage unit adjacent to the reserved storage unit, and the processor 2001 is used to obtain status information of each minimum storage unit in the flash memory device and then use to:
  • the fourth storage unit adjacent to the second storage unit is used as the replaced second storage unit, and the second logical address and the replaced The mapping relationship of the second storage unit.
  • the other states include at least one of the following: read failure, write failure, and erase failure.
  • any storage unit in the flash memory device stores a mapping relationship between the first logical address and the first storage unit and a mapping relationship between the reserved address and the reserved storage unit.
  • the any storage unit is the last storage unit in the flash memory device.
  • An embodiment of the present invention also provides a movable platform, which may include the above-mentioned smart battery.
  • the mobile platform can be drones, smart phones, tablet computers, handheld camera equipment and other devices.
  • An embodiment of the present invention also provides a readable storage medium, which stores a number of computer instructions.
  • the steps of the data storage method shown in the foregoing embodiments are implemented. Specific content may be Reference is made to the embodiments of the data storage method, which will not be repeated here.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)
  • Read Only Memory (AREA)

Abstract

A data storage method, a flash device, an intelligent battery, and a movable platform. The data storage method comprises: if a data storage request is received, determining the number of times of storage of a flash device; comparing the number of times of storage with a threshold of the number of times to obtain a comparison result; and determining, according to the comparison result, whether to perform address conversion on a reserved storage unit in the flash device. According to the present embodiment, by configuring the threshold of the number of times, when the threshold is reached, the reserved storage unit in the flash device is subjected to address conversion, so that a case where data is written to the same minimum storage unit for multiple times is avoided, the probabilities of the minimum storage units in the flash device being erased tend to be consistent, an effect of making the number of times of erasing balanced is achieved, and the service life of the flash device is prolonged. Moreover, in the present embodiment, only data in some of the minimum storage units is processed, the requirements on a storage space and computing resources are low, and the embodiment is applicable to flash devices using a single chip microcomputer (MCU) as a processor.

Description

数据存储方法、闪存设备、智能电池、可移动平台Data storage method, flash memory device, smart battery, removable platform 技术领域Technical field
本发明实施例涉及存储技术领域,尤其涉及数据存储方法、闪存设备、智能电池、可移动平台。The embodiments of the present invention relate to the field of storage technologies, and in particular, to data storage methods, flash memory devices, smart batteries, and removable platforms.
背景技术Background technique
闪存Flash设备因具有可擦除、可编程、掉电数据不丢失以及支持快速的读取访问的特点,在嵌入式领域得到了广泛应用。实际使用中,闪存设备在写入数据时必须先进行擦除操作,而擦除操作是以最小擦除单元(sector)为单位。由于每个最小擦除单元的擦除次数有限,通常只有10万次,因此需要对各最小擦除单元的擦除次数进行管理,从而保证擦除次数均衡。The flash memory flash memory device has been widely used in the embedded field because it has the characteristics of erasable, programmable, no loss of power-off data and support for fast read access. In actual use, the flash memory device must first perform an erase operation when writing data, and the erase operation is based on the smallest erase unit (sector) as a unit. Since the number of erasures of each minimum erasing unit is limited, usually only 100,000 times, it is necessary to manage the erasure times of each minimum erasing unit, so as to ensure that the erasure times are balanced.
现有的闪存设备,如固定硬盘SSD、U盘等,通常会设置一个适用闪存设备的转换层(Flash Transform Layer,FTL)对每个最小擦除单元的擦除次数进行管理,避免出现部分最小擦除单元快达到擦除次数上限而部分最小擦除单元还没被擦除过的情况。Existing flash memory devices, such as fixed hard disk SSDs, U disks, etc., usually set a conversion layer (Flash, Transform, Layer, FTL) suitable for flash memory devices to manage the number of erasures for each minimum erasure unit to avoid some minimum The case where the erasing unit reaches the upper limit of the number of erasing and some minimum erasing units have not been erased.
然而,现在的Flash转换层需要对每个最小擦除单元的擦除次数进行跟踪和管理,需要较多的存储空间和计算资源。对于使用单片机MCU作为微处理器的电子设备而言,因存储空间和计算资源有限,因此Flash转换层实现比较困难。However, the current Flash conversion layer needs to track and manage the number of erasures for each minimum erase unit, and requires more storage space and computing resources. For electronic devices using a single-chip MCU as a microprocessor, it is more difficult to implement the Flash conversion layer due to limited storage space and computing resources.
发明内容Summary of the invention
本发明实施例提供一种数据存储方法、闪存设备、智能电池、可移动平台。The embodiments of the present invention provide a data storage method, a flash memory device, a smart battery, and a removable platform.
第一方面,本发明实施例提供一种数据存储方法,包括:In a first aspect, an embodiment of the present invention provides a data storage method, including:
若接收到数据存储请求,确定闪存设备的存储次数;If a data storage request is received, determine the storage times of the flash memory device;
对比所述存储次数与预先设置的次数阈值,得到对比结果;Compare the stored times with the preset times threshold to obtain a comparison result;
根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换。According to the comparison result, it is determined whether to perform address conversion on the reserved storage unit in the flash memory device.
第二方面,本发明实施例提供一种闪存装置,包括处理器、存储器和闪存设备,所述闪存设备上设置有多个最小存储单元,处理器在从存储器上读取可执行指令后实现:In a second aspect, an embodiment of the present invention provides a flash memory device, including a processor, a memory, and a flash memory device. The flash memory device is provided with a plurality of minimum storage units, and the processor implements after reading executable instructions from the memory:
若接收到数据存储请求,确定闪存设备的存储次数;If a data storage request is received, determine the storage times of the flash memory device;
对比所述存储次数与预先设置的次数阈值,得到对比结果;Compare the stored times with the preset times threshold to obtain a comparison result;
根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换。According to the comparison result, it is determined whether to perform address conversion on the reserved storage unit in the flash memory device.
第三方面,本发明实施例提供一种智能电池,包括处理器、存储器和闪存设备,所述闪存设备上设置有多个最小存储单元,处理器在从存储器上读取可执行指令后实现:In a third aspect, an embodiment of the present invention provides a smart battery, including a processor, a memory, and a flash memory device. The flash memory device is provided with a plurality of minimum storage units, and the processor implements after reading executable instructions from the memory:
若接收到数据存储请求,确定闪存设备的存储次数;If a data storage request is received, determine the storage times of the flash memory device;
对比所述存储次数与预先设置的次数阈值,得到对比结果;Compare the stored times with the preset times threshold to obtain a comparison result;
根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换。According to the comparison result, it is determined whether to perform address conversion on the reserved storage unit in the flash memory device.
第四方面,本发明实施例提供一种可移动平台,包括第三方面所述的智能电池。According to a fourth aspect, an embodiment of the present invention provides a movable platform, including the smart battery described in the third aspect.
第五方面,本发明实施例提供一种可读存储介质,所述可读存储介质上存储有若干计算机指令,所述计算机指令被执行时实现第一方面所述方法的步骤。According to a fifth aspect, an embodiment of the present invention provides a readable storage medium that stores a number of computer instructions, and when the computer instructions are executed, the steps of the method of the first aspect are implemented.
由上述的技术方案可见,本实施例中在接收到数据存储请求后,可以确定出闪存设备的存储次数。然后,对比存储次数和次数阈值是否相等,之后,根据对比结果确定是否对所述闪存设备中保留存储单元进行地址转换。可见,本实施例通过设置存储次数阈值,在达到次数阈值时对闪存设备中的保留存储单元进行地址转换,从而避免向同一最小存储单元中多次 写入数据,使闪存设备内各最小存储单元被擦除的概率趋于一致,从而达到均衡擦除次数的效果,有利于延长闪存设备的使用寿命。并且,本实施例中仅处理部分最小存储单元的数据,对存储空间和计算资源的要求比较低,适用使用单片机MCU作为处理器的闪存设备。It can be seen from the above technical solution that, in this embodiment, after receiving the data storage request, the storage times of the flash memory device can be determined. Then, it is compared whether the storage times and the times threshold are equal, and then, it is determined whether to perform address conversion on the reserved storage unit in the flash memory device according to the comparison result. It can be seen that in this embodiment, by setting the threshold of the number of times of storage, when the threshold of the number of times is reached, the address conversion is performed on the reserved storage unit in the flash memory device, thereby avoiding writing data to the same minimum storage unit multiple times, so that each minimum storage unit in the flash memory device The probability of being erased tends to be consistent, so as to achieve the effect of balancing the number of erases, which is beneficial to prolong the service life of flash memory devices. In addition, in this embodiment, only part of the data of the smallest storage unit is processed, and the requirements on storage space and computing resources are relatively low, which is suitable for a flash memory device using a single-chip MCU as a processor.
附图说明BRIEF DESCRIPTION
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly explain the technical solutions in the embodiments of the present invention, the drawings required in the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without paying any creative labor, other drawings can also be obtained based on these drawings.
图1是本发明实施例提供的一种数据存储方法的流程示意图;FIG. 1 is a schematic flowchart of a data storage method according to an embodiment of the present invention;
图2是本发明实施例提供的一种获取存储次数的流程示意图;2 is a schematic diagram of a process for obtaining storage times provided by an embodiment of the present invention;
图3是本发明实施例提供的另一种获取存储次数的流程示意图;FIG. 3 is another schematic flowchart of acquiring storage times provided by an embodiment of the present invention;
图4是本发明实施例提供的根据第一存储单元的存储状态写入数据的流程示意图;4 is a schematic flowchart of writing data according to a storage state of a first storage unit according to an embodiment of the present invention;
图5(a)~图5(b)是本发明实施例提供的第一存储单元未存满数据的情况下写入数据的结果示意图;FIG. 5(a) to FIG. 5(b) are schematic diagrams of the results of writing data when the first storage unit provided by the embodiment of the present invention is not full of data;
图6(a)~图6(c)是本发明实施例提供的第一存储单元已存满数据的情况下写入数据的过程示意图;6(a) to 6(c) are schematic diagrams of a process of writing data when the first storage unit provided by the embodiment of the present invention has filled with data;
图7是本发明实施例提供的先写入数据再地址转换的流程示意图;7 is a schematic diagram of a process of writing data before address conversion provided by an embodiment of the present invention;
图8(a)~图8(f)是本发明实施例提供的先写入数据再地址转换的过程示意图;8(a) to 8(f) are schematic diagrams of a process of writing data first and then address conversion provided by an embodiment of the present invention;
图9是本发明实施例提供的先地址转换再写入数据的流程示意图;9 is a schematic flowchart of address conversion before writing data according to an embodiment of the present invention;
图10(a)~图10(d)是本发明实施例提供的在第一存储单元已存满数据的情况下先地址转换再写入数据的过程示意图;10(a) to FIG. 10(d) are schematic diagrams of a process of address conversion before writing data when the first storage unit is full of data provided by an embodiment of the present invention;
图11(a)~图11(c)是本发明实施例提供的在第一存储单元未存满数据的情况下先地址转换再写入数据的过程示意图;11(a) to 11(c) are schematic diagrams of a process of address conversion before writing data when the first storage unit is not full of data according to an embodiment of the present invention;
图12是本发明实施例提供的一种地址转换的流程示意图;12 is a schematic flowchart of an address conversion provided by an embodiment of the present invention;
图13(a)~图13(d)是本发明实施例提供的在第一存储单元已存满数据的情况下同时进行地址转换和写入数据的过程示意图;13(a) to 13(d) are schematic diagrams of a process of simultaneously performing address conversion and writing data when the first storage unit is full of data according to an embodiment of the present invention;
图14是本发明实施例提供的一种数据存储方法的流程示意图;14 is a schematic flowchart of a data storage method according to an embodiment of the present invention;
图15(a)~图15(b)是本发明实施例提供的一种剔除坏块是第一存储单元的过程示意图;15(a) to 15(b) are schematic diagrams of a process for excluding bad blocks from being a first storage unit according to an embodiment of the present invention;
图16(a)~图16(b)是本发明实施例提供的一种剔除坏块是保留存储单元的过程示意图;16(a)-FIG. 16(b) are schematic diagrams of a process of removing bad blocks to reserve storage units provided by an embodiment of the present invention;
图17(a)~图17(b)是本发明实施例提供的一种剔除坏块是第二存储单元的过程示意图;17(a) to 17(b) are schematic diagrams of a process for excluding bad blocks from being a second storage unit according to an embodiment of the present invention;
图18(a)~图18(h)是本发明实施例提供的一种数据存储方法的过程示意图;18(a) to 18(h) are schematic process diagrams of a data storage method provided by an embodiment of the present invention;
图19是本发明实施例提供的一种闪存设备的框图;19 is a block diagram of a flash memory device provided by an embodiment of the present invention;
图20是本发明实施例提供的一种智能电池的框图。20 is a block diagram of a smart battery provided by an embodiment of the present invention.
具体实施方式detailed description
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。另外,在不冲突的情况下,下述的实施例及实施例中的特征可以相互组合。The technical solutions in the embodiments of the present invention will be described clearly and completely in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, but not all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by a person of ordinary skill in the art without making creative efforts fall within the protection scope of the present invention. In addition, in the case of no conflict, the following embodiments and the features in the embodiments can be combined with each other.
鉴于均衡现有闪存设备的各最小擦除单元的擦除次数方案,需要由转换层FTL对每个最小擦除单元的擦除次数进行管理,以避免出现部分最小擦除单元快达到擦除次数上限而部分最小擦除单元还没被擦除过或者很少被擦除过的情况。In view of balancing the erasure times of the minimum erasure units of existing flash memory devices, the conversion layer FTL needs to manage the erasure times of each minimum erasure unit to avoid some minimum erasure units reaching the erasure times soon The upper limit and part of the smallest erasing unit has not been erased or rarely erased.
然而,由于闪存设备中最小擦除单元的数量较多,在对每个最小擦除 单元的擦除次数进行跟踪和管理过程中,需要较多的存储空间和计算资源,这对于存储空间和计算资源均有限的单片机MCU而言,均衡擦除次数则比较困难。However, due to the large number of minimum erasing units in the flash memory device, in the process of tracking and managing the erasure times of each minimum erasing unit, more storage space and computing resources are required. For single-chip MCUs with limited resources, it is more difficult to balance the number of erasures.
为此,本发明实施例提供了一种数据存储方法,利用FTL软件可以对闪存设备中各最小擦除单元的擦除次数作均衡处理,其发明构思在于,设置一保留存储单元,然后在闪存设备的存储次数达到次数阈值时对保留存储单元进行地址转换,通过地址转换避免向同一最小存储单元多次写入数据,使数据存储各最小存储单元内的概率趋于一致,即使各最小存储单元的擦除次数趋于一致,达到均衡的效果。For this reason, the embodiments of the present invention provide a data storage method, which can use FTL software to perform equalization processing on the number of erasures of each minimum erasing unit in the flash memory device. The inventive concept is to set a reserved storage unit and then store it in the flash memory. When the storage frequency of the device reaches the threshold of the number of times, address conversion is performed on the reserved storage unit. The address conversion avoids writing data to the same minimum storage unit multiple times, so that the probability of data storage in each minimum storage unit tends to be consistent, even if each minimum storage unit The number of erasures tends to be consistent to achieve a balanced effect.
本实施例中,在闪存设备中可以预先存储逻辑地址(LA)和物理地址(PA)之间的映射关系。为方便描述方案,后续实施例中物理地址是指最小存储单元的首地址,逻辑地址是指与最小存储单元具有映射关系的逻辑块的首地址。In this embodiment, the mapping relationship between the logical address (LA) and the physical address (PA) may be stored in the flash memory device in advance. To facilitate the description of the solution, in subsequent embodiments, the physical address refers to the first address of the smallest storage unit, and the logical address refers to the first address of the logical block that has a mapping relationship with the smallest storage unit.
需要说明的是,上述包括逻辑地址与物理地址的映射关系可以存储在闪存设备中的任一个最小存储单元。在一些实施例中,映射关系存储在闪存设备的最后一个最小存储单元。当然,技术人员还可以将映射关系存储在外部储存器、云端等,在能够实现本实施例方案的情况下,相应方案落入本申请的保护范围。It should be noted that the above mapping relationship including the logical address and the physical address may be stored in any minimum storage unit in the flash memory device. In some embodiments, the mapping relationship is stored in the last smallest storage unit of the flash memory device. Of course, the technician can also store the mapping relationship in an external storage, cloud, etc., and in the case where the solution of this embodiment can be implemented, the corresponding solution falls within the protection scope of the present application.
本实施例中最小存储单元是指,每次擦除闪存设备时所能操作的最小物理区域(即最小擦除单元),例如4K比特。当然,技术人员还可以根据具体场景调整最小存储单元的大小,相应方案落入本申请的保护范围。In this embodiment, the minimum storage unit refers to the smallest physical area (ie, the minimum erase unit) that can be operated each time the flash memory device is erased, for example, 4K bits. Of course, the technician can also adjust the size of the minimum storage unit according to the specific scenario, and the corresponding solution falls within the protection scope of the present application.
图1是本发明实施例提供的一种数据存储方法的流程示意图,参见图1,一种数据存储方法,包括步骤101~步骤103,其中:FIG. 1 is a schematic flowchart of a data storage method according to an embodiment of the present invention. Referring to FIG. 1, a data storage method includes steps 101 to 103, where:
在步骤101中,若接收到数据存储请求,确定闪存设备的存储次数。In step 101, if a data storage request is received, the number of storage times of the flash memory device is determined.
本实施例中,闪存设备中FTL软件可以与应用软件进行交互。用户可以通过应用软件选择存储数据的位置,该位置可以包括一个逻辑地址或者多个逻辑地址。考虑到多个逻辑地址的场景下,各逻辑地址写入数据的过 程中仍然是从首个逻辑地址开始,和一个逻辑地址的写入方案相近,因此后续实施例选择一个逻辑地址的场景描述方案。In this embodiment, the FTL software in the flash memory device can interact with the application software. The user can select a location to store data through the application software, and the location may include one logical address or multiple logical addresses. Considering the scenario of multiple logical addresses, the process of writing data to each logical address still starts from the first logical address, which is similar to the writing scheme of one logical address, so the subsequent embodiment chooses a scenario description scheme of logical addresses .
本实施例中,在交互过程中,闪存设备可以接收到应用软件的数据存储请求。其中数据存储请求包括第一逻辑地址,该第一逻辑地址可以映射到一个物理地址,该物理地址表示一个最小存储单元的首地址,还可以表示多个最小存储单元的首地址。In this embodiment, during the interaction, the flash memory device may receive the data storage request of the application software. The data storage request includes a first logical address, and the first logical address may be mapped to a physical address, and the physical address represents a head address of a minimum storage unit, and may also indicate head addresses of a plurality of minimum storage units.
本实施例中,每次接收到数据存储请求,FTL软件会记录一下该数据存储请求或者修改一下闪存设备已经存入数据的存储次数,这样可以确定出闪存设备的存储次数。需要说明的是,在确定存储次数时,可以先获取记录,再结合本次数据存储请求可以确定出存储次数;还可以先记录本次数据存储请求,然后再确定出闪存设备的存储次数。技术人员可以根据具体场景进行设置,在此不作限定。In this embodiment, each time a data storage request is received, the FTL software records the data storage request or modifies the number of times the flash memory device has stored data, so that the number of times the flash memory device is stored can be determined. It should be noted that when determining the storage times, the records can be obtained first, and then the storage times can be determined in conjunction with the data storage request; the data storage requests can also be recorded first, and then the storage times of the flash memory device can be determined. Technicians can make settings according to specific scenarios, which are not limited here.
在一实施例中,存储次数可以包括:从存储设备的角度,向闪存设备已写入数据的次数。此场景下,参见图2,确定闪存设备的存储次数可以包括:In an embodiment, the storage times may include: the number of times data has been written to the flash memory device from the perspective of the storage device. In this scenario, referring to FIG. 2, determining the storage times of the flash memory device may include:
在接收到数据存储请求后,FTL软件调整已记录的存储次数(对应步骤201)。调整方式可以为记录一下该数据存储请求,然后统计已经记录的数据存储请求,从而得到存储次数;还可以为在前一存储次数的基础上增加1,将调整后的次数作为确定出存储次数。然后,读取已记录的存储次数,得到闪存设备的存储次数(对应步骤202)。After receiving the data storage request, the FTL software adjusts the recorded storage times (corresponding to step 201). The adjustment method can be to record the data storage request, and then count the data storage request that has been recorded, so as to obtain the storage times; or add 1 to the previous storage times, and use the adjusted times as the determined storage times. Then, the recorded storage times are read to obtain the storage times of the flash memory device (corresponding to step 202).
在另一实施例中,存储次数还可以包括:从最小存储单元的角度,向第一存储单元已写入数据的次数。此场景下,参见图3,确定闪存设备的存储次数可以包括:In another embodiment, the storage times may further include: from the perspective of the smallest storage unit, the number of times data has been written to the first storage unit. In this scenario, referring to FIG. 3, determining the storage times of the flash memory device may include:
在接收到数据存储请求后,获取数据存储请求中获取第一逻辑地址,该第一逻辑地址是指用户期望写入数据的逻辑地址。FTL软件调整数据存储请求中第一逻辑地址的存储次数,第一逻辑地址的存储次数是指向第一逻辑地址中已写入数据的次数(对应步骤301)。然后,FTL软件读取数 据存储请求中第一逻辑地址的存储次数,得到闪存设备的存储次数(对应步骤302)。After receiving the data storage request, the first logical address is obtained in the data storage request, and the first logical address refers to a logical address that the user desires to write data. The FTL software adjusts the storage times of the first logical address in the data storage request, and the storage times of the first logical address refers to the number of times the data has been written in the first logical address (corresponding to step 301). Then, the FTL software reads the storage times of the first logical address in the data storage request to obtain the storage times of the flash memory device (corresponding to step 302).
在步骤102中,对比所述存储次数与预先设置的次数阈值,得到对比结果。In step 102, the stored number of times is compared with a preset number of times threshold to obtain a comparison result.
本实施例中,可以预先设置次数阈值,该次数阈值可以根据具体进行调整,例如,根据经验值进行设置,又如,根据大数据方式进行统计,将闪存设备寿命最长或者各最小存储单元的擦除次数相同、相近或者相差最少对应的次数阈值作为本实施例的次数阈值。技术人员还可以根据其他方式设置次数阈值,在能够实现本申请方案的情况下,相应方案落入本申请的保护范围。In this embodiment, the threshold of times can be set in advance, and the threshold of times can be adjusted according to the specifics, for example, according to empirical values, for example, according to the statistics of big data, the longest life of the flash memory device or the minimum storage unit The threshold value of the number of times corresponding to the same erasure times, the similarity, or the smallest difference corresponds to the threshold number of times in this embodiment. The technician can also set the threshold of the number of times according to other methods. In the case where the scheme of the present application can be realized, the corresponding scheme falls within the protection scope of the present application.
其中,次数阈值可以存储在闪存设备中的任一个最小存储单元。在一些实施例中,次数阈值存储在闪存设备的最后一个最小存储单元。Among them, the threshold of the number of times may be stored in any minimum storage unit in the flash memory device. In some embodiments, the number of times threshold is stored in the last smallest storage unit of the flash memory device.
本实施例中,FTL软件可以对比存储次数和次数阈值,可以得到对比结果。其中对比结果可以包括存储次数和次数阈值相等,或者存储次数和次数阈值不等。In this embodiment, the FTL software can compare the storage times and the threshold of the times to obtain a comparison result. The comparison result may include that the storage times and the threshold are equal, or the storage times and the thresholds are not equal.
需要说明的是,在存储次数与次数阈值相等时,本实施例中FTL软件还对存储次数进行清零。其中清零的方式可以包括删除已经记录的存储数据存储请求、对已经记录的存储数据存储请求进行标记、存储次数变量归零。It should be noted that, when the number of storage times is equal to the threshold of the number of times, in this embodiment, the FTL software also clears the number of storage times. The method of clearing may include deleting the recorded storage data storage request, marking the recorded storage data storage request, and resetting the storage frequency variable to zero.
在步骤103中,根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换。In step 103, it is determined according to the comparison result whether to perform address conversion on the reserved storage unit in the flash memory device.
本实施例中,FTL软件可以根据对比结果确定是否对闪存设备中保留存储单元进行地址转换,可以包括:In this embodiment, the FTL software may determine whether to perform address conversion on the reserved storage unit in the flash memory device according to the comparison result, which may include:
对比结果1 Comparison result 1
若对比结果为存储次数与次数阈值不等,则确定保持保留存储单元当前的映射关系,并将数据存储到数据存储请求中的第一逻辑地址映射的第 一存储单元。If the comparison result is that the number of storage times is not equal to the number of times threshold, it is determined to maintain the current mapping relationship of the storage unit and store the data to the first storage unit mapped to the first logical address in the data storage request.
其中,保持保留存储单元当前的映射关系即不对保留地址和保留存储单元的映射关系作地址转换。Wherein, maintaining the current mapping relationship of the reserved storage unit means that no address conversion is performed on the mapping relationship between the reserved address and the reserved storage unit.
另外,FTL软件将数据存储到数据存储请求中的第一逻辑地址映射的第一存储单元,参见图4,可以包括:In addition, the FTL software stores the data to the first storage unit mapped to the first logical address in the data storage request, referring to FIG. 4, may include:
FTL软件可以确定第一存储单元的存储状态,其中存储状态可以包括表示所述第一存储单元未存满数据和表示所述第一存储单元已存满数据(对应步骤401)。The FTL software may determine the storage state of the first storage unit, where the storage state may include data indicating that the first storage unit is not full and data indicating that the first storage unit is full (corresponding to step 401).
然后,FTL软件判断存储状态是表示所述第一存储单元未存满数据,还是表示所述第一存储单元已存满数据(对应步骤402)。Then, the FTL software determines whether the storage status indicates that the first storage unit is not full of data or that the first storage unit is full of data (corresponding to step 402).
之后,若存储状态表示所述第一存储单元未存满数据,FTL软件将数据写入已存储数据的尾部(对应步骤403),即直接向第一存储单元写入数据,无需对第一存储单元进行擦除。参见图5(a)~图5(b),以第一逻辑地址为逻辑地址空间的第一个逻辑地址LA0为例,FTL软件确定第一存储单元PA1中已经存储的数据XX0,且数据XX0的大小小于第一存储单元PA1的大小,即第一存储单元PA1未存满数据,FTL软件从数据XX0的尾部开始写入数据,得到图5(b)所示结果。After that, if the storage status indicates that the first storage unit is not full of data, the FTL software writes the data to the tail of the stored data (corresponding to step 403), that is, directly writes data to the first storage unit, without the need for the first storage The cell is erased. 5(a) to 5(b), taking the first logical address as the first logical address LA0 in the logical address space as an example, the FTL software determines that the data XX0 already stored in the first storage unit PA1 and the data XX0 The size of is smaller than the size of the first storage unit PA1, that is, the first storage unit PA1 is not full of data, the FTL software writes data from the end of the data XX0, and obtains the result shown in FIG. 5(b).
若存储状态表示第一存储单元已经存满数据,则FTL软件擦除第一存储单元,之后再向第一存储单元写入数据(对应步骤404)。参见图6(a)~图6(c),继续以第一逻辑地址为逻辑地址空间的第一个逻辑地址LA0为例,FTL软件确定第一存储单元PA1中已经存储的数据XX1,且数据XX1的大小等于第一存储单元PA1的大小,即第一存储单元PA1已经存满数据,FTL软件擦除第一存储单元PA1中的数据XX1,采用FF表示未存储数据,结果如图6(b)所示。然后,FTL软件将数据写入第一存储单元PA1,结果如图6(c)所示。If the storage state indicates that the first storage unit is full of data, the FTL software erases the first storage unit, and then writes data to the first storage unit (corresponding to step 404). 6(a) to 6(c), continue to take the first logical address as the first logical address LA0 of the logical address space as an example, the FTL software determines the data XX1 already stored in the first storage unit PA1, and the data The size of XX1 is equal to the size of the first storage unit PA1, that is, the first storage unit PA1 has been filled with data, FTL software erases the data XX1 in the first storage unit PA1, using FF to indicate that no data is stored, the result is shown in Figure 6(b ) As shown. Then, the FTL software writes data to the first storage unit PA1, and the result is shown in FIG. 6(c).
需要说明的是,为方便阅读,图5(a)~图5(b)以及图6(a)~图6(c)中发生变化的地方以加组和下划线示出。It should be noted that, for ease of reading, the places where the changes occur in FIG. 5(a) to FIG. 5(b) and FIG. 6(a) to FIG. 6(c) are shown by adding groups and underlining.
对比结果2 Comparison result 2
场景一,若对比结果为存储次数与次数阈值相等,则确定对保留存储单元进行地址转换。地址转换可以包括以下方式:Scenario 1: If the result of the comparison is that the number of storage times is equal to the threshold of number of times, then it is determined to perform address conversion on the reserved storage unit. Address translation can include the following methods:
方式一method one
参见图7,首先,FTL软件将数据写入第一存储单元(对应步骤701),写入数据的场景可以考虑第一存储单元已存满数据或者未存满数据的,具体参见图5(a)~图5(b)以及图6(a)~图6(c)的内容,在此不再赘述。然后,FTL软件擦除保留存储单元,将第一存储单元中的数据复制到保留存储单元(对应步骤702)。之后,FTL软件将第一逻辑地址映射到保留存储单元以及将保留地址映射到第一存储单元,完成地址转换(对应步骤703)。Referring to FIG. 7, first, the FTL software writes data to the first storage unit (corresponding to step 701). The scenario of writing data may consider that the first storage unit has full data or not full data, see FIG. 5(a ) To FIG. 5(b) and FIG. 6(a) to FIG. 6(c), which will not be repeated here. Then, the FTL software erases the reserved storage unit and copies the data in the first storage unit to the reserved storage unit (corresponding to step 702). After that, the FTL software maps the first logical address to the reserved storage unit and the reserved address to the first storage unit to complete the address conversion (corresponding to step 703).
参见图8(a),以保留地址RS映射到保留存储单元PA0,以及第一逻辑地址LA0,且以第一存储单元PA1中存储数据XX1为例,FTL软件擦除第一存储单元PA1中的数据XX1变为数据FF,结果如图8(b)所示。然后,FTL软件向第一存储单元PA1中写入数据,结果如图8(c)所示。之后,FTL软件擦除保留存储单元PA0,保留存储单元PA0中数据由XX2变为FF,结果如图8(d)所示。再者,FTL软件将第一存储单元PA1中的数据复制到保留存储单元PA0中,保留存储单元PA0中数据由FF变为 数据,结果如图8(e)所示。最后,FTL软件将第一逻辑地址LA0映射到保留存储单元PA0以及将保留地址RS映射到第一存储单元PA1,完成地址转换,结果如图8(f)所示。 Referring to FIG. 8(a), with the reserved address RS mapped to the reserved memory cell PA0 and the first logical address LA0, and taking the data XX1 stored in the first memory cell PA1 as an example, FTL software erases the first memory cell PA1. Data XX1 becomes data FF, and the result is shown in Figure 8(b). Then, the FTL software writes data into the first storage unit PA1, and the result is shown in FIG. 8(c). After that, the FTL software erases the reserved memory cell PA0, and the data in the reserved memory cell PA0 changes from XX2 to FF. The result is shown in FIG. 8(d). Further, the FTL software to copy the data in the first storage unit PA1 PA0 to retain the storage unit, the reservation data storage unit PA0 from FF to the data, the results shown in FIG 8 (e) in FIG. Finally, the FTL software maps the first logical address LA0 to the reserved storage unit PA0 and the reserved address RS to the first storage unit PA1 to complete the address conversion. The result is shown in FIG. 8(f).
需要说明的是,为方便阅读,图8(a)~图8(f)中发生变化的地方以加组和下划线示出。It should be noted that, for ease of reading, the places where changes occur in FIG. 8(a) to FIG. 8(f) are shown by adding groups and underlining.
方式二Method two
参见图9,FTL软件将第一逻辑地址映射到保留存储单元以及将保留地址映射到第一存储单元,完成地址转换(对应步骤901)。然后,FTL 软件将数据存储到第一逻辑地址映射的保留存储单元(对应步骤902)。Referring to FIG. 9, the FTL software maps the first logical address to the reserved storage unit and the reserved address to the first storage unit to complete address conversion (corresponding to step 901). Then, the FTL software stores the data in the reserved storage unit mapped to the first logical address (corresponding to step 902).
在步骤902中,可以包括情况:情况一,若所述保留存储单元未存满数据,则从已存储数据的尾部写入数据。情况二,若所述保留存储单元已存满数据,则擦除所述保留存储单元后写入数据。In step 902, it may include a case: Case 1, if the reserved storage unit is not full of data, data is written from the end of the stored data. Case 2: If the reserved storage unit is full of data, the reserved storage unit is erased and data is written.
在保留存储单元存满数据的情况中,参见图10(a),继续以保留地址RS映射到保留存储单元PA0,以及第一逻辑地址LA0,且以第一存储单元PA1中存储数据XX1为例。FTL软件将第一逻辑地址LA0映射到保留存储单元PA0以及将保留地址RS映射到第一存储单元PA1,完成地址转换,结果如图10(b)所示。然后,FTL软件擦除保留存储单元PA0中的数据XX2变为数据FF,结果如图10(c)所示。最后,FTL软件向保留存储单元PA0中写入 数据,结果如图10(d)所示。 In the case where the reserved storage unit is full of data, refer to FIG. 10(a), continue to map the reserved address RS to the reserved storage unit PA0, and the first logical address LA0, and take the data XX1 stored in the first storage unit PA1 as an example . The FTL software maps the first logical address LA0 to the reserved storage unit PA0 and the reserved address RS to the first storage unit PA1 to complete the address conversion. The result is shown in FIG. 10(b). Then, the FTL software erases the data XX2 in the reserved memory cell PA0 into data FF, and the result is shown in FIG. 10(c). Finally, the FTL software to write data to the reserved memory unit PA0, the results shown in FIG 10 (d) shown in FIG.
在保留存储单元未存满数据的情况中,参见图11(a),继续以保留地址RS映射到保留存储单元PA0,以及第一逻辑地址LA0,且以第一存储单元PA1中存储数据XX1为例。FTL软件将第一逻辑地址LA0映射到保留存储单元PA0以及将保留地址RS映射到第一存储单元PA1,完成地址转换,结果如图11(b)所示。然后,FTL软件在保留存储单元PA0中数据XX2之后写入 数据,结果如图11(c)所示。 In the case where the reserved storage unit is not full of data, refer to FIG. 11(a), continue to map the reserved address RS to the reserved storage unit PA0, and the first logical address LA0, and use the stored data XX1 in the first storage unit PA1 as example. The FTL software maps the first logical address LA0 to the reserved storage unit PA0 and the reserved address RS to the first storage unit PA1 to complete the address conversion. The result is shown in FIG. 11(b). Then, FTL software writes data retained in the storage unit after the data PA0 XX2, the results shown in FIG 11 (c) shown in FIG.
需要说明的是,为方便阅读,图10(a)~图10(d)以及图11(a)~图11(c)中发生变化的地方以加组和下划线示出。It should be noted that, for ease of reading, the places where changes occur in FIG. 10(a) to FIG. 10(d) and FIG. 11(a) to FIG. 11(c) are shown by adding groups and underlining.
场景二,保留存储单元和第一存储单元不相邻,且保留存储单元和第二存储单元相邻。参见图12,地址转换可以包括:Scenario 2: The reserved storage unit and the first storage unit are not adjacent, and the reserved storage unit and the second storage unit are adjacent. Referring to FIG. 12, address translation may include:
FTL软件将数据写入第一存储单元(对应步骤1201)。向第一存储单元写入数据的方式可以参见图5(a)~图5(b)以及图6(a)~图6(c)的内容,在此不再赘述。The FTL software writes data to the first storage unit (corresponding to step 1201). For the manner of writing data to the first storage unit, reference may be made to the contents of FIG. 5(a) to FIG. 5(b) and FIG. 6(a) to FIG. 6(c), which will not be repeated here.
以及,FTL软件擦除保留存储单元擦除保留存储单元(对应步骤1202)。然后,FTL软件将第二存储单元中的数据复制到保留存储单元(对 应步骤1203)。最后,FTL软件将保留地址映射到第二存储单元且第二逻辑地址映射到保留存储单元,完成地址转换(对应步骤1204)。And, the FTL software erases the reserved memory cells to erase the reserved memory cells (corresponding to step 1202). Then, the FTL software copies the data in the second storage unit to the reserved storage unit (corresponding to step 1203). Finally, the FTL software maps the reserved address to the second storage unit and the second logical address to the reserved storage unit to complete the address conversion (corresponding to step 1204).
需要说明的是,步骤1201与步骤1202~步骤1204的顺序不作限定,步骤1201可以先于步骤1202~步骤1204,步骤1201可以后于步骤1202~步骤1204,步骤1201可以同时与步骤1202~步骤1204执行。图13(a)~图13(d)中以步骤1201同时与步骤1202~步骤1204执行为例进行说明。It should be noted that the order of step 1201 and step 1202 to step 1204 is not limited. Step 1201 can precede step 1202 to step 1204, step 1201 can follow step 1202 to step 1204, and step 1201 can be simultaneously with step 1202 to step 1204 carried out. In FIGS. 13(a) to 13(d), step 1201 is executed simultaneously with steps 1202 to 1204 as an example for description.
参见图13(a),以保留地址RS映射到保留存储单元PA0,以及第二逻辑地址LA0映射到第二存储单元PA1,第一逻辑地址LA5映射到第一存储单元PA5,且保留存储单元PA0存储数据XX2,第二存储单元PA1存储数据XX3,第一存储单元PA5存储数据XX1。然后,FTL软件擦除第一存储单元PA5中的数据XX1变为数据FF,以及擦除保留存储单元PA0中的数据XX2变为数据FF,结果如图13(b)所示。之后,FTL软件将数据写入第一存储单元PA5中,以及将第二存储单元PA1中的数据XX3复制到保留存储单元PA0中,即保留存储单元PA0中数据FF变为XX3,结果如图13(c)所示。最后,FTL软件保留地址RS映射到第二存储单元PA1以及将第二逻辑地址LA0映射到保留存储单元PA0,完成地址转换,结果如图13(d)所示。Referring to FIG. 13(a), the reserved address RS is mapped to the reserved memory unit PA0, and the second logical address LA0 is mapped to the second memory unit PA1, the first logical address LA5 is mapped to the first memory unit PA5, and the reserved memory unit PA0 The data XX2 is stored, the second storage unit PA1 stores data XX3, and the first storage unit PA5 stores data XX1. Then, the FTL software erases the data XX1 in the first memory cell PA5 into data FF, and erases the data XX2 in the reserved memory cell PA0 into data FF, and the result is shown in FIG. 13(b). After that, the FTL software writes the data in the first storage unit PA5, and copies the data XX3 in the second storage unit PA1 to the reserved storage unit PA0, that is, the data FF in the reserved storage unit PA0 becomes XX3, and the result is shown in FIG. 13 (c) shown. Finally, the FTL software reserved address RS is mapped to the second storage unit PA1 and the second logical address LA0 is mapped to the reserved storage unit PA0 to complete the address conversion. The result is shown in FIG. 13(d).
至此,本实施例中在接收到数据存储请求后,可以确定出闪存设备的存储次数。然后,对比存储次数和次数阈值是否相等,之后,根据对比结果确定是否对所述闪存设备中保留存储单元进行地址转换。可见,本实施例通过设置存储次数阈值,在达到次数阈值时对闪存设备中的保留存储单元进行地址转换,从而避免向同一最小存储单元中多次写入数据,使闪存设备内各最小存储单元被擦除的概率趋于一致,从而达到均衡擦除次数的效果,有利于延长闪存设备的使用寿命。并且,本实施例中仅处理部分最小存储单元的数据,对存储空间和计算资源的要求比较低,适用使用单片机MCU作为处理器的闪存设备。So far, in this embodiment, after receiving the data storage request, the storage times of the flash memory device can be determined. Then, it is compared whether the storage times and the times threshold are equal, and then, it is determined whether to perform address conversion on the reserved storage unit in the flash memory device according to the comparison result. It can be seen that in this embodiment, by setting the threshold of the number of times of storage, when the threshold of the number of times is reached, the address conversion is performed on the reserved storage unit in the flash memory device, thereby avoiding writing data to the same minimum storage unit multiple times, so that each minimum storage unit in the flash memory device The probability of being erased tends to be consistent, so as to achieve the effect of balancing the number of erases, which is beneficial to prolong the service life of flash memory devices. In addition, in this embodiment, only part of the data of the smallest storage unit is processed, and the requirements on storage space and computing resources are relatively low, which is suitable for a flash memory device using a single-chip MCU as a processor.
实际应用中,考虑到闪存设备中最小存储单元可能存储坏块的情况,本实施例中可以为各最小存储单元设置状态信息,该状态信息可以用于记录各最小存储单元的健康状态,状态信息至少包括健康状态和其他状态,其他状态包括以下至少一项:读失败、写失败和擦除失败。In practical applications, considering that the smallest storage unit in the flash memory device may store bad blocks, in this embodiment, state information may be set for each smallest storage unit, and the state information may be used to record the health status and status information of each smallest storage unit. At least include the health state and other states. Other states include at least one of the following: read failure, write failure, and erase failure.
为此,在对比结果为存储次数与次数阈值相等时,在图1所示数据存储方法的基础上,参见图14,一种数据存储方法还可以包括:For this reason, when the comparison result is that the number of storage times is equal to the number of times threshold, on the basis of the data storage method shown in FIG. 1, referring to FIG. 14, a data storage method may further include:
首先,FTL软件获取闪存设备各最小存储单元的状态信息(对应步骤1401)。本实施例中,FTL软件可以获取闪存设备中全部最小存储单元的状态信息,这样可以快速查询到其中任一个最小存储单元的状态信息。本实施例中,FTL软件还可以获取与本次数据存储以及地址转换相关的最小存储单元,这样获取的数据量较少,查询速度快。然后,FTL软件在确定出各最小存储单元的状态信息为健康状态时,则执行根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换的步骤(对应步骤1402),根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换的内容可以参见图1及相关内容,在此不再赘述。First, the FTL software obtains the status information of each minimum storage unit of the flash memory device (corresponding to step 1401). In this embodiment, the FTL software can obtain the status information of all the smallest storage units in the flash memory device, so that the status information of any one of the smallest storage units can be quickly queried. In this embodiment, the FTL software can also obtain the minimum storage unit related to the data storage and address conversion, so that the amount of data obtained is small and the query speed is fast. Then, when the FTL software determines that the status information of each minimum storage unit is healthy, it performs a step of determining whether to perform address conversion on the reserved storage unit in the flash memory device according to the comparison result (corresponding to step 1402). For the content of the comparison result to determine whether to perform address conversion on the reserved storage unit in the flash memory device, reference may be made to FIG. 1 and related content, which will not be repeated here.
在另一实施例中,FTL软件在确定出第一逻辑地址映射的第一存储单元的状态信息为除健康状态之外的其他状态时,则更换第一存储单元且执行根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换的步骤。其中,根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换的内容可以参见图1及相关内容,在此不再赘述。In another embodiment, when the FTL software determines that the state information of the first storage unit mapped by the first logical address is other than the healthy state, the first storage unit is replaced and the determination according to the comparison result is performed. The step of performing address conversion on the storage unit reserved in the flash memory device. For the content of determining whether to perform address conversion on the reserved storage unit in the flash memory device according to the comparison result, refer to FIG. 1 and related content, and details are not described herein again.
本实施例中,更换第一存储单元可以包括:参见图15(a),因第一存储单元PA1的状态信息为其他状态,FTL软件将与第一存储单元PA1相邻的第三存储单元PA2作为更换后的第一存储单元,然后建立第一逻辑地址LA0和更换后的第一存储单元(即第三存储单元PA2)的映射关系,结果图15(b)所示。其中图15(a)中第一存储单元PA为坏块,采用灰色背景示出,图15(b)中第三逻辑地址不存在映射关系,同样采用灰色背景示出。这样,本实施例中可以将坏块(即第一存储单元PA1)从映射 关系中剔除,达到对坏块进行管理的目的。同时,本实施例中将第三逻辑地址LA1从映射关系中剔除,从而保证映射关系中逻辑地址和各最小存储单元之间的关系。In this embodiment, replacing the first storage unit may include: referring to FIG. 15(a), because the status information of the first storage unit PA1 is other states, the FTL software will replace the third storage unit PA2 adjacent to the first storage unit PA1 As the first storage unit after replacement, a mapping relationship between the first logical address LA0 and the first storage unit after replacement (ie, the third storage unit PA2) is then established, and the result is shown in FIG. 15(b). The first storage unit PA in FIG. 15(a) is a bad block, which is shown on a gray background, and the third logical address in FIG. 15(b) does not have a mapping relationship, and is also shown on a gray background. In this way, in this embodiment, bad blocks (i.e., the first storage unit PA1) can be eliminated from the mapping relationship to achieve the purpose of managing the bad blocks. At the same time, in this embodiment, the third logical address LA1 is removed from the mapping relationship, so as to ensure the relationship between the logical address and each minimum storage unit in the mapping relationship.
在又一实施例中,FTL软件获取状态信息的最小存储单元中还包括保留存储单元。若保留存储单元的状态信息为其他状态,FTL软件则将与保留存储单元最近的一个最小存储单元作为更换后的保留存留单元,并建立保留地址和更换后的保留存储单元的映射关系。参见图16(a),当检测到保留存储单元PA0的状态信息为其他状态时,FTL软件检测到保留存储单元PA0最近的一个最小存储单元为第二存储单元PA1,因此FTL软件将第二存储单元PA1作为更换后的保留存储单元,并建立保留地址RS和第二存储单元PA1之间的映射关系,结果如图16(b)所示。In yet another embodiment, the minimum storage unit in which the FTL software obtains status information further includes a reserved storage unit. If the status information of the reserved storage unit is other states, the FTL software uses the smallest storage unit closest to the reserved storage unit as the reserved storage unit after replacement, and establishes the mapping relationship between the reserved address and the reserved storage unit after replacement. Referring to FIG. 16(a), when the state information of the reserved storage unit PA0 is detected to be other states, the FTL software detects that the nearest smallest storage unit of the reserved storage unit PA0 is the second storage unit PA1, so the FTL software stores the second storage unit The unit PA1 serves as a reserved storage unit after replacement and establishes a mapping relationship between the reserved address RS and the second storage unit PA1. The result is shown in FIG. 16(b).
需要说明的是,更换前的保留存储单元PA0为坏块,从映射关系中剔除;第二逻辑地址LA0没有最小存储单元与之映射被剔除,剔除内容采用灰色背景示出。It should be noted that the reserved storage unit PA0 before replacement is a bad block and is eliminated from the mapping relationship; the second logical address LA0 has no minimum storage unit mapped to it, and the deleted content is shown on a gray background.
在另一实施例中,FTL软件获取状态信息的最小存储单元中还包括第二存储单元。若第二存储单元的状态信息为其他状态,FTL软件则将与第二存储单元最近的一个最小存储单元作为更换后的保留存留单元,并建立保留地址和更换后的保留存储单元的映射关系。参见图17(a),当检测到第二存储单元PA1的状态信息为其他状态时,FTL软件检测到第二存储单元PA1最近的一个最小存储单元为第四存储单元PA2,因此FTL软件将第四存储单元PA2作为更换后的保留存储单元,并建立保留地址RS和第四存储单元PA2之间的映射关系,剔除灰度背景表示的第二存储单元PA1和第四逻辑地址LA1,结果如图17(b)所示。In another embodiment, the minimum storage unit for obtaining status information by the FTL software further includes a second storage unit. If the status information of the second storage unit is other states, the FTL software uses the smallest storage unit closest to the second storage unit as the reserved storage unit after replacement, and establishes the mapping relationship between the reserved address and the replaced storage unit after replacement. Referring to FIG. 17(a), when the state information of the second storage unit PA1 is detected as other states, the FTL software detects that the nearest smallest storage unit of the second storage unit PA1 is the fourth storage unit PA2, so the FTL software will The four storage units PA2 are used as reserved storage units after replacement, and the mapping relationship between the reserved address RS and the fourth storage unit PA2 is established, and the second storage unit PA1 and the fourth logical address LA1 indicated by the gray background are removed, and the result is as shown in the figure 17(b).
需要说明的是,更换后的保留存储单元RS的最近一个最小存储单元由第二存储单元PA1变为第四存储单元PA2。若保留存储单元RS需要地址转换,则按照图4或图7所示地址转换方式转换即可,在此不再赘述。It should be noted that the last smallest storage unit of the reserved storage unit RS after replacement is changed from the second storage unit PA1 to the fourth storage unit PA2. If the reserved storage unit RS needs address conversion, it can be converted according to the address conversion method shown in FIG. 4 or FIG. 7, which will not be repeated here.
下面结合实施例和附图描述本发明实施例提供的数据存储方法,其中 次数阈值为1,即用户每向闪存设备写入一次数据,保留地址RS作一次地址转换。实际应用中,FTL软件可以将逻辑地址展现给用户,由用户选择将数据存入的逻辑地址。为方便描述,本实施例中以用户依次选择逻辑地址的方式描述本实施例方案。The data storage method provided by the embodiments of the present invention will be described below with reference to the embodiments and the accompanying drawings. The threshold value of the number of times is 1, that is, each time the user writes data to the flash memory device, the address RS is reserved for address conversion. In practical applications, the FTL software can display the logical address to the user, and the user selects the logical address into which the data is stored. For convenience of description, in this embodiment, the solution of this embodiment is described in a manner that a user sequentially selects logical addresses.
参见图18(a),保留地址RS映射到保留存储单元PA0,逻辑地址LA 1~LA N-1依次映射到最小存储单元PA 1~PA N,其中最小存储单元SA中存储FTL软件所需要的状态数据、映射关系等数据,对应用软件或用户而言,最小存储单元SA不可见(斜线背景示出)。Referring to FIG. 18(a), the reserved address RS is mapped to the reserved memory unit PA0, and the logical addresses LA to N-1 are sequentially mapped to the smallest memory units PA to 1 to PA, in which the smallest memory unit SA stores all the information required by the FTL software. For the data such as state data and mapping relationship, for the application software or the user, the smallest storage unit SA is not visible (shown by a slanted background).
参见图18(b),第一次存储数据时,FTL软件检测到用户选择向第一逻辑地址LA0写入数据,此时第一逻辑地址映射到PA1。由于闪存设备的存储次数达到1次且各最小存储单元的状态信息为健康状态,FTL软件对保留存储单元进行地址转换,且写入数据XX0,结果如参见图18(c)所示,此时逻辑地址LA0映射到最小存储单元PA0,保存地址映射到最小存储单元PA1,即最小存储单元PA1成为保留存储单元。Referring to FIG. 18(b), when storing data for the first time, the FTL software detects that the user chooses to write data to the first logical address LA0, and at this time the first logical address is mapped to PA1. Since the storage number of the flash memory device reaches 1 and the status information of each minimum storage unit is healthy, the FTL software performs address conversion on the reserved storage unit and writes data XX0. The result is shown in FIG. 18(c). The logical address LA0 is mapped to the smallest storage unit PA0, and the save address is mapped to the smallest storage unit PA1, that is, the smallest storage unit PA1 becomes a reserved storage unit.
参见图18(d),第二次存储数据时,FTL软件检测到用户选择向第一逻辑地址LA1写入数据,此时第一逻辑地址映射到PA2。由于闪存设备的存储次数达到1次,FTL软件检测到第一存储单元PA2为坏块(状态信息为其他状态),如图18(d)所示。FTL软件先更换第一存储单元,由于最小存储单元PA2最近的一个存储单元为最小存储单元PA3,因此将最小存储单元PA3作为更换后的第一存储单元,结果如图18(e)所示。然后,FTL软件对保留存储单元PA1进行地址转换,且写入数据XX1,结果如参见图18(f)所示,此时逻辑地址LA1映射到最小存储单元PA1,保存地址RS映射到最小存储单元PA3,即最小存储单元PA3成为保留存储单元。Referring to FIG. 18(d), when storing data for the second time, the FTL software detects that the user selects to write data to the first logical address LA1, and at this time the first logical address is mapped to PA2. Since the storage number of the flash memory device reaches 1, the FTL software detects that the first storage unit PA2 is a bad block (the status information is other status), as shown in FIG. 18(d). The FTL software first replaces the first storage unit. Since the closest storage unit of the minimum storage unit PA2 is the minimum storage unit PA3, the minimum storage unit PA3 is used as the first storage unit after replacement. The result is shown in FIG. 18(e). Then, the FTL software performs address conversion on the reserved storage unit PA1 and writes data XX1. The result is shown in FIG. 18(f). At this time, the logical address LA1 is mapped to the smallest storage unit PA1, and the stored address RS is mapped to the smallest storage unit. PA3, the smallest storage unit PA3, becomes a reserved storage unit.
之后,继续检测用户的第3,4,……,N-3次数据,得到图18(g)所示的结果,此时保存地址RS映射到最小存储单元PA N-1。After that, continue to detect the user's 3rd, 4th, ..., N-3th data to obtain the result shown in Fig. 18(g). At this time, the storage address RS is mapped to the smallest storage unit PA-1.
当FTL软件检测到用户向最小存储单元LA0写入数据XX N-2时,经 过地址转换和数据写入得到图18(h)所示结果。When the FTL software detects that the user writes data XX N-2 to the minimum storage unit LA0, the result shown in Fig. 18(h) is obtained after address conversion and data writing.
这样,图18(a)~图18(h)示出了保留存储单元依次经过最小存储单元PA0、PA1、PA3、……、PA N-1,重新回到最小存储单元PA0的循环过程。In this way, FIGS. 18(a) to 18(h) show the cyclic process in which the reserved memory cells pass through the smallest memory cells PA0, PA1, PA3, ..., PA-1, and then return to the smallest memory cell PA0.
本实施例中,通过设置保留存储单元可以保证用户写入的数据存储到不同的最小存储单元,可以避免用户向同一逻辑地址写入多次数据时出现同一最小存储单元擦除次数增加过快的情况,达到均衡各存储单元的擦除次数的效果。并且,本实施例中,在数据写入且无需地址转换的场景中,FTL软件仅对第一逻辑地址映射的第一存储单元进行管理;在数据写入且需要地址转换的场景中,FTL软件仅对第一存储单元和保留存储单元(两者相邻)进行管理;在数据写入、需要地址转换且第一存储单元和保留存储单元不相邻的场景中,FTL软件仅对第一存储单元、保留存储单元和第二存储单元进行管理,即FTL软件每次管理的存储单元数量大大减少,对存储资源和计算资源的需求较低,适用于采用单片机作为处理器的场景。In this embodiment, by setting a reserved storage unit, the data written by the user can be guaranteed to be stored in different minimum storage units, which can prevent the user from writing the data to the same logical address multiple times, the same minimum storage unit erasure times increase too fast The situation achieves the effect of balancing the number of erasures of each memory cell. Moreover, in this embodiment, in the scenario where data is written without address conversion, the FTL software only manages the first storage unit mapped by the first logical address; in the scenario where data is written and address conversion is required, the FTL software Only the first storage unit and the reserved storage unit (the two are adjacent) are managed; in the scenario where data is written, address conversion is required, and the first storage unit and the reserved storage unit are not adjacent, the FTL software only stores the first storage unit Units, reserved storage units and second storage units are managed, that is, the number of storage units managed by the FTL software each time is greatly reduced, and the demand for storage resources and computing resources is low, which is suitable for the scenario where a single-chip microcomputer is used as a processor.
本发明实施例还提供一种闪存装置,图19是本发明实施例提供的一种闪存装置的框图。参见图19,一种闪存装置1900,包括处理器1901、存储器1902和闪存设备1904,所述闪存设备上设置有多个最小存储单元,各存储单元可以用于数据;处理器1901通过通信总线1903与存储器1902通信,处理器1901在从存储器1902上读取可执行指令后实现:An embodiment of the present invention also provides a flash memory device. FIG. 19 is a block diagram of a flash memory device according to an embodiment of the present invention. Referring to FIG. 19, a flash memory device 1900 includes a processor 1901, a memory 1902, and a flash memory device 1904. The flash memory device is provided with a plurality of minimum storage units, and each storage unit can be used for data. The processor 1901 passes a communication bus 1903. Communicating with the memory 1902, the processor 1901 realizes after reading the executable instructions from the memory 1902:
若接收到数据存储请求,确定闪存设备的存储次数;If a data storage request is received, determine the storage times of the flash memory device;
对比所述存储次数与预先设置的次数阈值,得到对比结果;Compare the stored times with the preset times threshold to obtain a comparison result;
根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换。According to the comparison result, it is determined whether to perform address conversion on the reserved storage unit in the flash memory device.
在一些实施例中,所述处理器1901用于确定闪存设备的存储次数包括:In some embodiments, the processor 1901 is configured to determine the storage times of the flash memory device includes:
调整已记录的存储次数,所述已记录的存储次数包括向所述闪存设备已写入数据的次数;Adjusting the number of recorded storage times, which includes the number of times data has been written to the flash memory device;
读取已记录的存储次数,得到所述闪存设备的存储次数。Reading the recorded storage times to obtain the storage times of the flash memory device.
在一些实施例中,所述处理器1901用于确定闪存设备的存储次数包括:In some embodiments, the processor 1901 is configured to determine the storage times of the flash memory device includes:
调整所述数据存储请求中第一逻辑地址的存储次数,所述第一逻辑地址的存储次数是指向所述第一逻辑地址中已写入数据的次数;Adjusting the number of times of storing the first logical address in the data storage request, the number of times of storing the first logical address refers to the number of times data has been written in the first logical address;
读取所述数据存储请求中第一逻辑地址的存储次数,得到所述闪存设备的存储次数。Reading the storage times of the first logical address in the data storage request to obtain the storage times of the flash memory device.
在一些实施例中,所述处理器1901用于根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换包括:In some embodiments, the processor 1901 is configured to determine whether to perform address translation on the reserved storage unit in the flash memory device according to the comparison result includes:
若对比结果为所述存储次数与所述次数阈值不等,则确定保持所述保留存储单元当前的映射关系,并将数据存储到所述数据存储请求中的第一逻辑地址映射的第一存储单元。If the comparison result is that the storage times are not equal to the times threshold, it is determined to maintain the current mapping relationship of the reserved storage unit and store the data to the first storage mapped to the first logical address in the data storage request unit.
在一些实施例中,所述处理器1901用于将数据存储到所述数据存储请求中的第一逻辑地址映射的第一存储单元包括:In some embodiments, the first storage unit of the first logical address mapping used by the processor 1901 to store data in the data storage request includes:
确定第一存储单元的存储状态;Determine the storage state of the first storage unit;
若所述存储状态表示所述第一存储单元未存满数据,则从已存储数据的尾部写入数据;If the storage state indicates that the first storage unit is not full of data, write data from the end of the stored data;
若所述存储状态表示所述第一存储单元已存满数据,则擦除所述第一存储单元后写入数据。If the storage state indicates that the first storage unit is full of data, the first storage unit is erased and data is written.
在一些实施例中,所述处理器1901用于根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换包括:In some embodiments, the processor 1901 is configured to determine whether to perform address translation on the reserved storage unit in the flash memory device according to the comparison result includes:
若对比结果为所述存储次数与所述次数阈值相等,则确定对所述保留存储单元进行地址转换。If the comparison result is that the storage times are equal to the times threshold, it is determined to perform address conversion on the reserved storage unit.
在一些实施例中,若所述保留存储单元与所述数据存储请求中第一逻辑地址映射的第一存储单元相邻,所述处理器1901用于对所述保留存储单元进行地址转换包括:In some embodiments, if the reserved storage unit is adjacent to the first storage unit mapped by the first logical address in the data storage request, the processor 1901 is configured to perform address conversion on the reserved storage unit including:
将数据写入所述第一存储单元;Write data to the first storage unit;
擦除所述保留存储单元,将所述第一存储单元中的数据复制到所述保留存储单元;Erasing the reserved storage unit, copying the data in the first storage unit to the reserved storage unit;
将所述第一逻辑地址映射到所述保留存储单元以及将所述保留地址映射到所述第一存储单元,完成地址转换。The first logical address is mapped to the reserved storage unit and the reserved address is mapped to the first storage unit to complete address conversion.
在一些实施例中,所述闪存设备包括与保留地址映射的保留存储单元;若所述保留存储单元与所述数据存储请求中第一逻辑地址映射的第一存储单元相邻,所述处理器1901用于对所述保留存储单元进行地址转换包括:In some embodiments, the flash memory device includes a reserved storage unit mapped to a reserved address; if the reserved storage unit is adjacent to the first storage unit mapped to the first logical address in the data storage request, the processor 1901 is used to perform address conversion on the reserved storage unit including:
将所述保留地址映射到所述第一存储单元且所述第一逻辑地址映射到所述保留存储单元,完成地址转换;Mapping the reserved address to the first storage unit and mapping the first logical address to the reserved storage unit to complete address conversion;
将数据存储到所述第一逻辑地址映射的保留存储单元。Storing data in the reserved storage unit mapped by the first logical address.
在一些实施例中,所述处理器1901用于将数据存储到所述第一逻辑地址映射的保留存储单元包括:In some embodiments, the reserved storage unit used by the processor 1901 to store data to the first logical address map includes:
若所述保留存储单元未存满数据,则从已存储数据的尾部写入数据;If the reserved storage unit is not full of data, write data from the end of the stored data;
若所述保留存储单元已存满数据,则擦除所述保留存储单元后写入数据。If the reserved storage unit is full of data, the reserved storage unit is erased and data is written.
在一些实施例中,所述闪存设备包括与保留地址映射的保留存储单元以及与第二逻辑地址映射的第二存储单元,所述保留存储单元与所述第二存储单元相邻且与所述第一存储单元不相邻,所述处理器1901用于对所述保留存储单元进行地址转换包括:In some embodiments, the flash memory device includes a reserved storage unit mapped to a reserved address and a second storage unit mapped to a second logical address, the reserved storage unit is adjacent to the second storage unit and is The first storage units are not adjacent, and the processor 1901 for performing address conversion on the reserved storage unit includes:
将数据写入所述第一存储单元;以及,Write data to the first storage unit; and,
擦除所述保留存储单元,将所述第二存储单元中的数据复制到所述保留存储单元;Erasing the reserved storage unit, copying the data in the second storage unit to the reserved storage unit;
将所述保留地址映射到所述第二存储单元且所述第二逻辑地址映射到所述保留存储单元,完成地址转换。The reserved address is mapped to the second storage unit and the second logical address is mapped to the reserved storage unit to complete address conversion.
在一些实施例中,若对比结果为所述存储次数与所述次数阈值相等,述处理器1901还用于:In some embodiments, if the comparison result is that the number of storage times is equal to the number of times threshold, the processor 1901 is further configured to:
获取所述闪存设备中各最小存储单元的状态信息;所述状态信息用于 记录各最小存储单元的健康状态;所述状态信息至少包括健康状态;Acquiring state information of each minimum storage unit in the flash memory device; the state information is used to record the health state of each minimum storage unit; the state information includes at least a health state;
若所述各最小存储单元的状态信息为健康状态,则执行根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换的步骤。If the state information of each minimum storage unit is a healthy state, a step of determining whether to perform address conversion on the storage unit reserved in the flash memory device is performed according to the comparison result.
在一些实施例中,所述各最小存储单元中包括第一存储单元,所述处理器1901用于获取所述闪存设备中各最小存储单元的状态信息之后,还用于:In some embodiments, each of the minimum storage units includes a first storage unit. After the processor 1901 is used to obtain status information of each minimum storage unit in the flash memory device, it is also used to:
若所述第一逻辑地址映射的第一存储单元的状态信息为除健康状态之外的其他状态,则更换第一存储单元且执行根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换的步骤。If the status information of the first storage unit mapped by the first logical address is in a state other than the healthy state, replace the first storage unit and perform whether to reserve the storage unit in the flash memory device according to the comparison result Steps for address conversion.
在一些实施例中,所述处理器1901用于更换第一存储单元包括:In some embodiments, the processor 1901 for replacing the first storage unit includes:
将与所述第一存储单元相邻的第三存储单元作为更换后的第一存储单元,并建立所述第一逻辑地址和所述更换后的第一存储单元的映射关系。A third storage unit adjacent to the first storage unit is used as the replaced first storage unit, and a mapping relationship between the first logical address and the replaced first storage unit is established.
在一些实施例中,所述各最小存储单元中包括保留存储单元,所述处理器1901用于获取所述闪存设备中各最小存储单元的状态信息之后,还用于:In some embodiments, each of the minimum storage units includes a reserved storage unit, and the processor 1901 is used to obtain status information of each minimum storage unit in the flash memory device, and is also used to:
若保留存储单元的状态信息为其他状态,将与所述保留存储单元最近的一个最小存储单元作为更换后的保留存储单元,并建立保留地址和所述更换后的保留存储单元的映射关系。If the status information of the reserved storage unit is other states, the smallest storage unit closest to the reserved storage unit is used as the reserved storage unit after replacement, and the mapping relationship between the reserved address and the replaced reserved storage unit is established.
在一些实施例中,所述各最小存储单元中包括与保留存储单元相邻的第二存储单元,所述处理器1901用于获取所述闪存设备中各最小存储单元的状态信息之后,还用于:In some embodiments, each of the minimum storage units includes a second storage unit adjacent to the reserved storage unit, and the processor 1901 is used to obtain status information of each minimum storage unit in the flash memory device and then use to:
若第二存储单元的状态信息为其他状态,将与所述第二存储单元相邻的第四存储单元作为更换后的第二存储单元,并建立所述第二逻辑地址与所述更换后的第二存储单元的映射关系。If the status information of the second storage unit is other states, the fourth storage unit adjacent to the second storage unit is used as the replaced second storage unit, and the second logical address and the replaced The mapping relationship of the second storage unit.
在一些实施例中,所述其他状态包括以下至少一项:读失败、写失败和擦除失败。In some embodiments, the other states include at least one of the following: read failure, write failure, and erase failure.
在一些实施例中,所述闪存设备中任一存储单元存储有第一逻辑地址 和第一存储单元的映射关系以及保留地址和保留存储单元的映射关系。In some embodiments, any storage unit in the flash memory device stores a mapping relationship between the first logical address and the first storage unit and a mapping relationship between the reserved address and the reserved storage unit.
在一些实施例中,所述任一存储单元为所述闪存设备中的最后一个存储单元。In some embodiments, the any storage unit is the last storage unit in the flash memory device.
本发明实施例还提供一种智能电池,图19是本发明实施例提供的一种智能电池的框图。参见图20,一种智能电池2000,其特征在于,包括处理器2001、存储器2002和闪存设备2004,所述闪存设备2004上设置有多个最小存储单元,处理器2001在从存储器2002上读取可执行指令后实现:An embodiment of the present invention also provides a smart battery. FIG. 19 is a block diagram of a smart battery according to an embodiment of the present invention. Referring to FIG. 20, a smart battery 2000 is characterized by including a processor 2001, a memory 2002, and a flash memory device 2004. The flash memory device 2004 is provided with a plurality of minimum storage units. The processor 2001 reads from the memory 2002 After the executable instruction is realized:
若接收到数据存储请求,确定闪存设备的存储次数;If a data storage request is received, determine the storage times of the flash memory device;
对比所述存储次数与预先设置的次数阈值,得到对比结果;Compare the stored times with the preset times threshold to obtain a comparison result;
根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换。According to the comparison result, it is determined whether to perform address conversion on the reserved storage unit in the flash memory device.
在一些实施例中,所述处理器2001用于确定闪存设备的存储次数包括:In some embodiments, the processor 2001 is used to determine the storage times of the flash memory device includes:
调整已记录的存储次数,所述已记录的存储次数包括向所述闪存设备已写入数据的次数;Adjusting the number of recorded storage times, which includes the number of times data has been written to the flash memory device;
读取已记录的存储次数,得到所述闪存设备的存储次数。Reading the recorded storage times to obtain the storage times of the flash memory device.
在一些实施例中,所述处理器2001用于确定闪存设备的存储次数包括:In some embodiments, the processor 2001 is used to determine the storage times of the flash memory device includes:
调整所述数据存储请求中第一逻辑地址的存储次数,所述第一逻辑地址的存储次数是指向所述第一逻辑地址中已写入数据的次数;Adjusting the number of times of storing the first logical address in the data storage request, the number of times of storing the first logical address refers to the number of times data has been written in the first logical address;
读取所述数据存储请求中第一逻辑地址的存储次数,得到所述闪存设备的存储次数。Reading the storage times of the first logical address in the data storage request to obtain the storage times of the flash memory device.
在一些实施例中,所述处理器2001用于根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换包括:In some embodiments, the processor 2001 is configured to determine whether to perform address conversion on the reserved storage unit in the flash memory device according to the comparison result includes:
若对比结果为所述存储次数与所述次数阈值不等,则确定保持所述保留存储单元当前的映射关系,并将数据存储到所述数据存储请求中的第一 逻辑地址映射的第一存储单元。If the comparison result is that the storage times are not equal to the times threshold, it is determined to maintain the current mapping relationship of the reserved storage unit and store the data to the first storage mapped to the first logical address in the data storage request unit.
在一些实施例中,所述处理器2001用于将数据存储到所述数据存储请求中的第一逻辑地址映射的第一存储单元包括:In some embodiments, the first storage unit of the first logical address mapping used by the processor 2001 to store data in the data storage request includes:
确定第一存储单元的存储状态;Determine the storage state of the first storage unit;
若所述存储状态表示所述第一存储单元未存满数据,则从已存储数据的尾部写入数据;If the storage state indicates that the first storage unit is not full of data, write data from the end of the stored data;
若所述存储状态表示所述第一存储单元已存满数据,则擦除所述第一存储单元后写入数据。If the storage state indicates that the first storage unit is full of data, the first storage unit is erased and data is written.
在一些实施例中,所述处理器2001用于根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换包括:In some embodiments, the processor 2001 is configured to determine whether to perform address conversion on the reserved storage unit in the flash memory device according to the comparison result includes:
若对比结果为所述存储次数与所述次数阈值相等,则确定对所述保留存储单元进行地址转换。If the comparison result is that the storage times are equal to the times threshold, it is determined to perform address conversion on the reserved storage unit.
在一些实施例中,若所述保留存储单元与所述数据存储请求中第一逻辑地址映射的第一存储单元相邻,所述处理器2001用于对所述保留存储单元进行地址转换包括:In some embodiments, if the reserved storage unit is adjacent to the first storage unit mapped by the first logical address in the data storage request, the processor 2001 is configured to perform address conversion on the reserved storage unit including:
将数据写入所述第一存储单元;Write data to the first storage unit;
擦除所述保留存储单元,将所述第一存储单元中的数据复制到所述保留存储单元;Erasing the reserved storage unit, copying the data in the first storage unit to the reserved storage unit;
将所述第一逻辑地址映射到所述保留存储单元以及将所述保留地址映射到所述第一存储单元,完成地址转换。The first logical address is mapped to the reserved storage unit and the reserved address is mapped to the first storage unit to complete address conversion.
在一些实施例中,所述闪存设备包括与保留地址映射的保留存储单元;若所述保留存储单元与所述数据存储请求中第一逻辑地址映射的第一存储单元相邻,所述处理器2001用于对所述保留存储单元进行地址转换包括:In some embodiments, the flash memory device includes a reserved storage unit mapped to a reserved address; if the reserved storage unit is adjacent to the first storage unit mapped to the first logical address in the data storage request, the processor 2001 is used to perform address conversion on the reserved storage unit including:
将所述保留地址映射到所述第一存储单元且所述第一逻辑地址映射到所述保留存储单元,完成地址转换;Mapping the reserved address to the first storage unit and mapping the first logical address to the reserved storage unit to complete address conversion;
将数据存储到所述第一逻辑地址映射的保留存储单元。Storing data in the reserved storage unit mapped by the first logical address.
在一些实施例中,所述处理器2001用于将数据存储到所述第一逻辑 地址映射的保留存储单元包括:In some embodiments, the reserved storage unit used by the processor 2001 to store data to the first logical address map includes:
若所述保留存储单元未存满数据,则从已存储数据的尾部写入数据;If the reserved storage unit is not full of data, write data from the end of the stored data;
若所述保留存储单元已存满数据,则擦除所述保留存储单元后写入数据。If the reserved storage unit is full of data, the reserved storage unit is erased and data is written.
在一些实施例中,所述闪存设备包括与保留地址映射的保留存储单元以及与第二逻辑地址映射的第二存储单元,所述保留存储单元与所述第二存储单元相邻且与所述第一存储单元不相邻,所述处理器2001用于对所述保留存储单元进行地址转换包括:In some embodiments, the flash memory device includes a reserved storage unit mapped to a reserved address and a second storage unit mapped to a second logical address, the reserved storage unit is adjacent to the second storage unit and is The first storage unit is not adjacent, and the processor 2001 is used to perform address conversion on the reserved storage unit including:
将数据写入所述第一存储单元;以及,Write data to the first storage unit; and,
擦除所述保留存储单元,将所述第二存储单元中的数据复制到所述保留存储单元;Erasing the reserved storage unit, copying the data in the second storage unit to the reserved storage unit;
将所述保留地址映射到所述第二存储单元且所述第二逻辑地址映射到所述保留存储单元,完成地址转换。The reserved address is mapped to the second storage unit and the second logical address is mapped to the reserved storage unit to complete address conversion.
在一些实施例中,若对比结果为所述存储次数与所述次数阈值相等,所述处理器2001还用于:In some embodiments, if the comparison result is that the number of storage times is equal to the number of times threshold, the processor 2001 is further used to:
获取所述闪存设备中各最小存储单元的状态信息;所述状态信息用于记录各最小存储单元的健康状态;所述状态信息至少包括健康状态;Obtain the state information of each minimum storage unit in the flash memory device; the state information is used to record the health state of each minimum storage unit; the state information includes at least a health state;
若所述各最小存储单元的状态信息为健康状态,则执行根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换的步骤。If the state information of each minimum storage unit is a healthy state, a step of determining whether to perform address conversion on the storage unit reserved in the flash memory device is performed according to the comparison result.
在一些实施例中,所述各最小存储单元中包括第一存储单元,所述处理器2001用于获取所述闪存设备中各最小存储单元的状态信息之后,还用于:In some embodiments, each of the minimum storage units includes a first storage unit. After the processor 2001 is used to obtain status information of each minimum storage unit in the flash memory device, it is also used to:
若所述第一逻辑地址映射的第一存储单元的状态信息为除健康状态之外的其他状态,则更换第一存储单元且执行根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换的步骤。If the status information of the first storage unit mapped by the first logical address is in a state other than the healthy state, replace the first storage unit and perform whether to reserve the storage unit in the flash memory device according to the comparison result Steps for address conversion.
在一些实施例中,所述处理器2001用于更换第一存储单元包括:In some embodiments, the processor 2001 for replacing the first storage unit includes:
将与所述第一存储单元相邻的第三存储单元作为更换后的第一存储单 元,并建立所述第一逻辑地址和所述更换后的第一存储单元的映射关系。A third storage unit adjacent to the first storage unit is used as the replaced first storage unit, and a mapping relationship between the first logical address and the replaced first storage unit is established.
在一些实施例中,所述各最小存储单元中包括保留存储单元,所述处理器2001用于获取所述闪存设备中各最小存储单元的状态信息之后,还用于:In some embodiments, the minimum storage units include reserved storage units. After the processor 2001 is used to obtain status information of the minimum storage units in the flash memory device, it is also used to:
若保留存储单元的状态信息为其他状态,将与所述保留存储单元最近的一个最小存储单元作为更换后的保留存储单元,并建立保留地址和所述更换后的保留存储单元的映射关系。If the status information of the reserved storage unit is other states, the smallest storage unit closest to the reserved storage unit is used as the reserved storage unit after replacement, and the mapping relationship between the reserved address and the replaced reserved storage unit is established.
在一些实施例中,所述各最小存储单元中包括与保留存储单元相邻的第二存储单元,所述处理器2001用于获取所述闪存设备中各最小存储单元的状态信息之后,还用于:In some embodiments, each of the minimum storage units includes a second storage unit adjacent to the reserved storage unit, and the processor 2001 is used to obtain status information of each minimum storage unit in the flash memory device and then use to:
若第二存储单元的状态信息为其他状态,将与所述第二存储单元相邻的第四存储单元作为更换后的第二存储单元,并建立所述第二逻辑地址与所述更换后的第二存储单元的映射关系。If the state information of the second storage unit is other states, the fourth storage unit adjacent to the second storage unit is used as the replaced second storage unit, and the second logical address and the replaced The mapping relationship of the second storage unit.
在一些实施例中,所述其他状态包括以下至少一项:读失败、写失败和擦除失败。In some embodiments, the other states include at least one of the following: read failure, write failure, and erase failure.
在一些实施例中,所述闪存设备中任一存储单元存储有第一逻辑地址和第一存储单元的映射关系以及保留地址和保留存储单元的映射关系。In some embodiments, any storage unit in the flash memory device stores a mapping relationship between the first logical address and the first storage unit and a mapping relationship between the reserved address and the reserved storage unit.
在一些实施例中,所述任一存储单元为所述闪存设备中的最后一个存储单元。In some embodiments, the any storage unit is the last storage unit in the flash memory device.
本发明实施例还提供了一种可移动平台,可以包括上述智能电池。其中,可移动平台可以为无人机、智能手机、平板电脑、手持拍照设备等设备。An embodiment of the present invention also provides a movable platform, which may include the above-mentioned smart battery. Among them, the mobile platform can be drones, smart phones, tablet computers, handheld camera equipment and other devices.
本发明实施例还提供了一种可读存储介质,所述可读存储介质上存储有若干计算机指令,所述计算机指令被执行时实现上述各实施例示出的数据存储方法的步骤,具体内容可以参考数据存储方法各实施例,在此不再赘述。An embodiment of the present invention also provides a readable storage medium, which stores a number of computer instructions. When the computer instructions are executed, the steps of the data storage method shown in the foregoing embodiments are implemented. Specific content may be Reference is made to the embodiments of the data storage method, which will not be repeated here.
需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用 来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that these entities or operations There is any such actual relationship or order. The terms "include", "include", or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device that includes a series of elements includes not only those elements, but also others that are not explicitly listed Elements, or also include elements inherent to such processes, methods, objects, or equipment. Without more restrictions, the element defined by the sentence "include one..." does not exclude that there are other identical elements in the process, method, article or equipment that includes the element.
以上对本发明实施例所提供的检测装置和方法进行了详细介绍,本发明中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想;对于本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本发明的限制。The detection devices and methods provided by the embodiments of the present invention are described in detail above. Specific examples are used in the present invention to explain the principles and implementations of the present invention. The descriptions of the above embodiments are only used to help understand the methods of the present invention. And its core idea; for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation and scope of application. In summary, the content of this specification should not be understood as a limitation of the present invention .

Claims (56)

  1. 一种数据存储方法,其特征在于,包括:A data storage method is characterized by including:
    若接收到数据存储请求,确定闪存设备的存储次数;If a data storage request is received, determine the storage times of the flash memory device;
    对比所述存储次数与预先设置的次数阈值,得到对比结果;Compare the stored times with the preset times threshold to obtain a comparison result;
    根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换。According to the comparison result, it is determined whether to perform address conversion on the reserved storage unit in the flash memory device.
  2. 根据权利要求1所述的数据存储方法,其特征在于,确定闪存设备的存储次数包括:The data storage method according to claim 1, wherein determining the number of storage times of the flash memory device comprises:
    调整已记录的存储次数,所述已记录的存储次数包括向所述闪存设备已写入数据的次数;Adjusting the number of recorded storage times, which includes the number of times data has been written to the flash memory device;
    读取已记录的存储次数,得到所述闪存设备的存储次数。Reading the recorded storage times to obtain the storage times of the flash memory device.
  3. 根据权利要求1所述的数据存储方法,其特征在于,确定闪存设备的存储次数包括:The data storage method according to claim 1, wherein determining the number of storage times of the flash memory device comprises:
    调整所述数据存储请求中第一逻辑地址的存储次数,所述第一逻辑地址的存储次数是指向所述第一逻辑地址中已写入数据的次数;Adjusting the number of times of storing the first logical address in the data storage request, the number of times of storing the first logical address refers to the number of times data has been written in the first logical address;
    读取所述数据存储请求中第一逻辑地址的存储次数,得到所述闪存设备的存储次数。Reading the storage times of the first logical address in the data storage request to obtain the storage times of the flash memory device.
  4. 根据权利要求1所述的数据存储方法,其特征在于,根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换包括:The data storage method according to claim 1, wherein determining whether to perform address conversion on the reserved storage unit in the flash memory device according to the comparison result includes:
    若对比结果为所述存储次数与所述次数阈值不等,则确定保持所述保留存储单元当前的映射关系,并将数据存储到所述数据存储请求中的第一逻辑地址映射的第一存储单元。If the comparison result is that the storage times are not equal to the times threshold, it is determined to maintain the current mapping relationship of the reserved storage unit and store the data to the first storage mapped to the first logical address in the data storage request unit.
  5. 根据权利要求4所述的数据存储方法,其特征在于,将数据存储到所述数据存储请求中的第一逻辑地址映射的第一存储单元包括:The data storage method according to claim 4, wherein the first storage unit mapped to the first logical address in the data storage request includes:
    确定第一存储单元的存储状态;Determine the storage state of the first storage unit;
    若所述存储状态表示所述第一存储单元未存满数据,则从已存储数据 的尾部写入数据;If the storage state indicates that the first storage unit is not full of data, write data from the end of the stored data;
    若所述存储状态表示所述第一存储单元已存满数据,则擦除所述第一存储单元后写入数据。If the storage state indicates that the first storage unit is full of data, the first storage unit is erased and data is written.
  6. 根据权利要求1所述的数据存储方法,其特征在于,根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换包括:The data storage method according to claim 1, wherein determining whether to perform address conversion on the reserved storage unit in the flash memory device according to the comparison result includes:
    若对比结果为所述存储次数与所述次数阈值相等,则确定对所述保留存储单元进行地址转换。If the comparison result is that the storage times are equal to the times threshold, it is determined to perform address conversion on the reserved storage unit.
  7. 根据权利要求6所述的数据存储方法,其特征在于,若所述保留存储单元与所述数据存储请求中第一逻辑地址映射的第一存储单元相邻,对所述保留存储单元进行地址转换包括:The data storage method according to claim 6, wherein if the reserved storage unit is adjacent to the first storage unit mapped by the first logical address in the data storage request, the reserved storage unit is subjected to address conversion include:
    将数据写入所述第一存储单元;Write data to the first storage unit;
    擦除所述保留存储单元,将所述第一存储单元中的数据复制到所述保留存储单元;Erasing the reserved storage unit, copying the data in the first storage unit to the reserved storage unit;
    将所述第一逻辑地址映射到所述保留存储单元以及将所述保留地址映射到所述第一存储单元,完成地址转换。The first logical address is mapped to the reserved storage unit and the reserved address is mapped to the first storage unit to complete address conversion.
  8. 根据权利要求6所述的数据存储方法,其特征在于,所述闪存设备包括与保留地址映射的保留存储单元;若所述保留存储单元与所述数据存储请求中第一逻辑地址映射的第一存储单元相邻,对所述保留存储单元进行地址转换包括:The data storage method according to claim 6, wherein the flash memory device includes a reserved storage unit mapped to a reserved address; if the reserved storage unit is mapped to the first logical address in the data storage request, the first The storage units are adjacent, and performing address conversion on the reserved storage unit includes:
    将所述保留地址映射到所述第一存储单元且所述第一逻辑地址映射到所述保留存储单元,完成地址转换;Mapping the reserved address to the first storage unit and mapping the first logical address to the reserved storage unit to complete address conversion;
    将数据存储到所述第一逻辑地址映射的保留存储单元。Storing data in the reserved storage unit mapped by the first logical address.
  9. 根据权利要求8所述的数据存储方法,其特征在于,将数据存储到所述第一逻辑地址映射的保留存储单元包括:The data storage method according to claim 8, wherein storing the data in the reserved storage unit of the first logical address mapping comprises:
    若所述保留存储单元未存满数据,则从已存储数据的尾部写入数据;If the reserved storage unit is not full of data, write data from the end of the stored data;
    若所述保留存储单元已存满数据,则擦除所述保留存储单元后写入数据。If the reserved storage unit is full of data, the reserved storage unit is erased and data is written.
  10. 根据权利要求6所述的数据存储方法,其特征在于,所述闪存设备包括与保留地址映射的保留存储单元以及与第二逻辑地址映射的第二存储单元,所述保留存储单元与所述第二存储单元相邻且与所述第一存储单元不相邻,对所述保留存储单元进行地址转换包括:The data storage method according to claim 6, wherein the flash memory device includes a reserved storage unit mapped to a reserved address and a second storage unit mapped to a second logical address, the reserved storage unit and the first Two storage units are adjacent and not adjacent to the first storage unit, and performing address conversion on the reserved storage unit includes:
    将数据写入所述第一存储单元;以及,Write data to the first storage unit; and,
    擦除所述保留存储单元,将所述第二存储单元中的数据复制到所述保留存储单元;Erasing the reserved storage unit, copying the data in the second storage unit to the reserved storage unit;
    将所述保留地址映射到所述第二存储单元且所述第二逻辑地址映射到所述保留存储单元,完成地址转换。The reserved address is mapped to the second storage unit and the second logical address is mapped to the reserved storage unit to complete address conversion.
  11. 根据权利要求6所述的数据存储方法,其特征在于,若对比结果为所述存储次数与所述次数阈值相等,所述方法还包括:The data storage method according to claim 6, wherein if the comparison result is that the number of times of storage is equal to the threshold of the number of times, the method further comprises:
    获取所述闪存设备中各最小存储单元的状态信息;所述状态信息用于记录各最小存储单元的健康状态;所述状态信息至少包括健康状态;Obtain the state information of each minimum storage unit in the flash memory device; the state information is used to record the health state of each minimum storage unit; the state information includes at least a health state;
    若所述各最小存储单元的状态信息为健康状态,则执行根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换的步骤。If the state information of each minimum storage unit is a healthy state, a step of determining whether to perform address conversion on the storage unit reserved in the flash memory device is performed according to the comparison result.
  12. 根据权利要求11所述的数据存储方法,其特征在于,所述各最小存储单元中包括第一存储单元,获取所述闪存设备中各最小存储单元的状态信息之后,所述方法还包括:The data storage method according to claim 11, wherein each of the minimum storage units includes a first storage unit, and after acquiring status information of each minimum storage unit in the flash memory device, the method further includes:
    若所述第一逻辑地址映射的第一存储单元的状态信息为除健康状态之外的其他状态,则更换第一存储单元且执行根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换的步骤。If the status information of the first storage unit mapped by the first logical address is in a state other than the healthy state, replace the first storage unit and perform whether to reserve the storage unit in the flash memory device according to the comparison result Steps for address conversion.
  13. 根据权利要求12所述的数据存储方法,其特征在于,更换第一存储单元包括:The data storage method according to claim 12, wherein replacing the first storage unit comprises:
    将与所述第一存储单元相邻的第三存储单元作为更换后的第一存储单元,并建立所述第一逻辑地址和所述更换后的第一存储单元的映射关系。A third storage unit adjacent to the first storage unit is used as the replaced first storage unit, and a mapping relationship between the first logical address and the replaced first storage unit is established.
  14. 根据权利要求12所述的数据存储方法,其特征在于,所述各最小存储单元中包括保留存储单元,获取所述闪存设备中各最小存储单元的 状态信息之后,所述方法还包括:The data storage method according to claim 12, wherein each of the minimum storage units includes a reserved storage unit, and after acquiring status information of each minimum storage unit in the flash memory device, the method further includes:
    若保留存储单元的状态信息为其他状态,将与所述保留存储单元最近的一个最小存储单元作为更换后的保留存储单元,并建立保留地址和所述更换后的保留存储单元的映射关系。If the status information of the reserved storage unit is other states, the smallest storage unit closest to the reserved storage unit is used as the reserved storage unit after replacement, and the mapping relationship between the reserved address and the replaced reserved storage unit is established.
  15. 根据权利要求12所述的数据存储方法,其特征在于,所述各最小存储单元中包括与保留存储单元相邻的第二存储单元,获取所述闪存设备中各最小存储单元的状态信息之后,所述方法还包括:The data storage method according to claim 12, wherein each of the minimum storage units includes a second storage unit adjacent to the reserved storage unit, and after acquiring status information of each minimum storage unit in the flash memory device, The method also includes:
    若第二存储单元的状态信息为其他状态,将与所述第二存储单元相邻的第四存储单元作为更换后的第二存储单元,并建立所述第二逻辑地址与所述更换后的第二存储单元的映射关系。If the state information of the second storage unit is other states, the fourth storage unit adjacent to the second storage unit is used as the replaced second storage unit, and the second logical address and the replaced The mapping relationship of the second storage unit.
  16. 根据权利要求12~15任一项所述的数据存储方法,其特征在于,所述其他状态包括以下至少一项:读失败、写失败和擦除失败。The data storage method according to any one of claims 12 to 15, wherein the other states include at least one of the following: read failure, write failure, and erase failure.
  17. 根据权利要求1所述的数据存储方法,其特征在于,所述闪存设备中任一存储单元存储有第一逻辑地址和第一存储单元的映射关系以及保留地址和保留存储单元的映射关系。The data storage method according to claim 1, wherein any storage unit in the flash memory device stores a mapping relationship between the first logical address and the first storage unit and a mapping relationship between the reserved address and the reserved storage unit.
  18. 根据权利要求17所述的数据存储方法,其特征在于,所述任一存储单元为所述闪存设备中的最后一个存储单元。The data storage method according to claim 17, wherein the any storage unit is the last storage unit in the flash memory device.
  19. 一种闪存装置,其特征在于,包括处理器、存储器和闪存设备,所述闪存设备上设置有多个最小存储单元,处理器在从存储器上读取可执行指令后实现:A flash memory device is characterized by including a processor, a memory, and a flash memory device. The flash memory device is provided with a plurality of minimum storage units, and the processor implements after reading executable instructions from the memory:
    若接收到数据存储请求,确定闪存设备的存储次数;If a data storage request is received, determine the storage times of the flash memory device;
    对比所述存储次数与预先设置的次数阈值,得到对比结果;Compare the stored times with the preset times threshold to obtain a comparison result;
    根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换。According to the comparison result, it is determined whether to perform address conversion on the reserved storage unit in the flash memory device.
  20. 根据权利要求19所述的闪存装置,其特征在于,所述处理器用于确定闪存设备的存储次数包括:The flash memory device according to claim 19, wherein the processor is used to determine the storage times of the flash memory device includes:
    调整已记录的存储次数,所述已记录的存储次数包括向所述闪存设备 已写入数据的次数;Adjusting the number of recorded storage times, which includes the number of times data has been written to the flash memory device;
    读取已记录的存储次数,得到所述闪存设备的存储次数。Reading the recorded storage times to obtain the storage times of the flash memory device.
  21. 根据权利要求19所述的闪存装置,其特征在于,所述处理器用于确定闪存设备的存储次数包括:The flash memory device according to claim 19, wherein the processor is used to determine the storage times of the flash memory device includes:
    调整所述数据存储请求中第一逻辑地址的存储次数,所述第一逻辑地址的存储次数是指向所述第一逻辑地址中已写入数据的次数;Adjusting the number of times of storing the first logical address in the data storage request, the number of times of storing the first logical address refers to the number of times data has been written in the first logical address;
    读取所述数据存储请求中第一逻辑地址的存储次数,得到所述闪存设备的存储次数。Reading the storage times of the first logical address in the data storage request to obtain the storage times of the flash memory device.
  22. 根据权利要求19所述的闪存装置,其特征在于,所述处理器用于根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换包括:The flash memory device according to claim 19, wherein the processor is configured to determine whether to perform address conversion on the reserved storage unit in the flash memory device according to the comparison result:
    若对比结果为所述存储次数与所述次数阈值不等,则确定保持所述保留存储单元当前的映射关系,并将数据存储到所述数据存储请求中的第一逻辑地址映射的第一存储单元。If the comparison result is that the storage times are not equal to the times threshold, it is determined to maintain the current mapping relationship of the reserved storage unit and store the data to the first storage mapped to the first logical address in the data storage request unit.
  23. 根据权利要求22所述的闪存装置,其特征在于,所述处理器用于将数据存储到所述数据存储请求中的第一逻辑地址映射的第一存储单元包括:The flash memory device according to claim 22, wherein the first storage unit of the first logical address mapping used by the processor to store data in the data storage request includes:
    确定第一存储单元的存储状态;Determine the storage state of the first storage unit;
    若所述存储状态表示所述第一存储单元未存满数据,则从已存储数据的尾部写入数据;If the storage state indicates that the first storage unit is not full of data, write data from the end of the stored data;
    若所述存储状态表示所述第一存储单元已存满数据,则擦除所述第一存储单元后写入数据。If the storage state indicates that the first storage unit is full of data, the first storage unit is erased and data is written.
  24. 根据权利要求19所述的闪存装置,其特征在于,所述处理器用于根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换包括:The flash memory device according to claim 19, wherein the processor is configured to determine whether to perform address conversion on the reserved storage unit in the flash memory device according to the comparison result:
    若对比结果为所述存储次数与所述次数阈值相等,则确定对所述保留存储单元进行地址转换。If the comparison result is that the storage times are equal to the times threshold, it is determined to perform address conversion on the reserved storage unit.
  25. 根据权利要求24所述的闪存装置,其特征在于,若所述保留存储单元与所述数据存储请求中第一逻辑地址映射的第一存储单元相邻,所述处理器用于对所述保留存储单元进行地址转换包括:The flash memory device of claim 24, wherein if the reserved storage unit is adjacent to the first storage unit mapped by the first logical address in the data storage request, the processor is used to store the reserved The unit's address translation includes:
    将数据写入所述第一存储单元;Write data to the first storage unit;
    擦除所述保留存储单元,将所述第一存储单元中的数据复制到所述保留存储单元;Erasing the reserved storage unit, copying the data in the first storage unit to the reserved storage unit;
    将所述第一逻辑地址映射到所述保留存储单元以及将所述保留地址映射到所述第一存储单元,完成地址转换。The first logical address is mapped to the reserved storage unit and the reserved address is mapped to the first storage unit to complete address conversion.
  26. 根据权利要求24所述的闪存装置,其特征在于,所述闪存设备包括与保留地址映射的保留存储单元;若所述保留存储单元与所述数据存储请求中第一逻辑地址映射的第一存储单元相邻,所述处理器用于对所述保留存储单元进行地址转换包括:The flash memory device of claim 24, wherein the flash memory device includes a reserved storage unit mapped to a reserved address; if the reserved storage unit is mapped to the first storage of the first logical address in the data storage request The units are adjacent, and the processor for performing address conversion on the reserved storage unit includes:
    将所述保留地址映射到所述第一存储单元且所述第一逻辑地址映射到所述保留存储单元,完成地址转换;Mapping the reserved address to the first storage unit and mapping the first logical address to the reserved storage unit to complete address conversion;
    将数据存储到所述第一逻辑地址映射的保留存储单元。Storing data in the reserved storage unit mapped by the first logical address.
  27. 根据权利要求26所述的闪存装置,其特征在于,所述处理器用于将数据存储到所述第一逻辑地址映射的保留存储单元包括:The flash memory device of claim 26, wherein the reserved storage unit used by the processor to store data to the first logical address map includes:
    若所述保留存储单元未存满数据,则从已存储数据的尾部写入数据;If the reserved storage unit is not full of data, write data from the end of the stored data;
    若所述保留存储单元已存满数据,则擦除所述保留存储单元后写入数据。If the reserved storage unit is full of data, the reserved storage unit is erased and data is written.
  28. 根据权利要求24所述的闪存装置,其特征在于,所述闪存设备包括与保留地址映射的保留存储单元以及与第二逻辑地址映射的第二存储单元,所述保留存储单元与所述第二存储单元相邻且与所述第一存储单元不相邻,所述处理器用于对所述保留存储单元进行地址转换包括:The flash memory device of claim 24, wherein the flash memory device includes a reserved storage unit mapped to a reserved address and a second storage unit mapped to a second logical address, the reserved storage unit and the second The storage unit is adjacent to and not adjacent to the first storage unit, and the processor for performing address conversion on the reserved storage unit includes:
    将数据写入所述第一存储单元;以及,Write data to the first storage unit; and,
    擦除所述保留存储单元,将所述第二存储单元中的数据复制到所述保留存储单元;Erasing the reserved storage unit, copying the data in the second storage unit to the reserved storage unit;
    将所述保留地址映射到所述第二存储单元且所述第二逻辑地址映射到所述保留存储单元,完成地址转换。The reserved address is mapped to the second storage unit and the second logical address is mapped to the reserved storage unit to complete address conversion.
  29. 根据权利要求24所述的闪存装置,其特征在于,若对比结果为所述存储次数与所述次数阈值相等,所述处理器还用于:The flash memory device according to claim 24, wherein if the comparison result is that the number of storage times is equal to the number of times threshold, the processor is further configured to:
    获取所述闪存设备中各最小存储单元的状态信息;所述状态信息用于记录各最小存储单元的健康状态;所述状态信息至少包括健康状态;Obtain the state information of each minimum storage unit in the flash memory device; the state information is used to record the health state of each minimum storage unit; the state information includes at least a health state;
    若所述各最小存储单元的状态信息为健康状态,则执行根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换的步骤。If the state information of each minimum storage unit is a healthy state, a step of determining whether to perform address conversion on the storage unit reserved in the flash memory device is performed according to the comparison result.
  30. 根据权利要求29所述的闪存装置,其特征在于,所述各最小存储单元中包括第一存储单元,所述处理器用于获取所述闪存设备中各最小存储单元的状态信息之后,还用于:The flash memory device according to claim 29, wherein each of the minimum storage units includes a first storage unit, and the processor is further used to obtain status information of each minimum storage unit in the flash memory device :
    若所述第一逻辑地址映射的第一存储单元的状态信息为除健康状态之外的其他状态,则更换第一存储单元且执行根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换的步骤。If the status information of the first storage unit mapped by the first logical address is in a state other than the healthy state, replace the first storage unit and perform whether to reserve the storage unit in the flash memory device according to the comparison result Steps for address conversion.
  31. 根据权利要求30所述的闪存装置,其特征在于,所述处理器用于更换第一存储单元包括:The flash memory device according to claim 30, wherein the processor for replacing the first storage unit includes:
    将与所述第一存储单元相邻的第三存储单元作为更换后的第一存储单元,并建立所述第一逻辑地址和所述更换后的第一存储单元的映射关系。A third storage unit adjacent to the first storage unit is used as the replaced first storage unit, and a mapping relationship between the first logical address and the replaced first storage unit is established.
  32. 根据权利要求30所述的闪存装置,其特征在于,所述各最小存储单元中包括保留存储单元,所述处理器用于获取所述闪存设备中各最小存储单元的状态信息之后,还用于:The flash memory device according to claim 30, wherein each of the minimum storage units includes a reserved storage unit, and after the processor is used to obtain status information of each minimum storage unit in the flash memory device, it is also used to:
    若保留存储单元的状态信息为其他状态,将与所述保留存储单元最近的一个最小存储单元作为更换后的保留存储单元,并建立保留地址和所述更换后的保留存储单元的映射关系。If the status information of the reserved storage unit is other states, the smallest storage unit closest to the reserved storage unit is used as the reserved storage unit after replacement, and the mapping relationship between the reserved address and the replaced reserved storage unit is established.
  33. 根据权利要求30所述的闪存装置,其特征在于,所述各最小存储单元中包括与保留存储单元相邻的第二存储单元,所述处理器用于获取所述闪存设备中各最小存储单元的状态信息之后,还用于:The flash memory device according to claim 30, wherein each of the minimum storage units includes a second storage unit adjacent to the reserved storage unit, and the processor is configured to obtain the minimum storage unit of the flash memory device. After the status information, it is also used to:
    若第二存储单元的状态信息为其他状态,将与所述第二存储单元相邻的第四存储单元作为更换后的第二存储单元,并建立所述第二逻辑地址与所述更换后的第二存储单元的映射关系。If the state information of the second storage unit is other states, the fourth storage unit adjacent to the second storage unit is used as the replaced second storage unit, and the second logical address and the replaced The mapping relationship of the second storage unit.
  34. 根据权利要求30~33任一项所述的闪存装置,其特征在于,所述其他状态包括以下至少一项:读失败、写失败和擦除失败。The flash memory device according to any one of claims 30 to 33, wherein the other states include at least one of the following: read failure, write failure, and erase failure.
  35. 根据权利要求19所述的闪存装置,其特征在于,所述闪存设备中任一存储单元存储有第一逻辑地址和第一存储单元的映射关系以及保留地址和保留存储单元的映射关系。The flash memory device of claim 19, wherein any storage unit in the flash memory device stores a mapping relationship between the first logical address and the first storage unit and a mapping relationship between the reserved address and the reserved storage unit.
  36. 根据权利要求35所述的闪存装置,其特征在于,所述任一存储单元为所述闪存设备中的最后一个存储单元。The flash memory device according to claim 35, wherein the any storage unit is the last storage unit in the flash memory device.
  37. 一种智能电池,其特征在于,包括处理器、存储器和闪存设备,所述闪存设备上设置有多个最小存储单元,处理器在从存储器上读取可执行指令后实现:A smart battery is characterized by comprising a processor, a memory and a flash memory device, the flash memory device is provided with a plurality of minimum storage units, and the processor realizes after reading executable instructions from the memory:
    若接收到数据存储请求,确定闪存设备的存储次数;If a data storage request is received, determine the storage times of the flash memory device;
    对比所述存储次数与预先设置的次数阈值,得到对比结果;Compare the stored times with the preset times threshold to obtain a comparison result;
    根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换。According to the comparison result, it is determined whether to perform address conversion on the reserved storage unit in the flash memory device.
  38. 根据权利要求37所述的智能电池,其特征在于,所述处理器用于确定闪存设备的存储次数包括:The smart battery according to claim 37, wherein the processor is used to determine the storage times of the flash memory device including:
    调整已记录的存储次数,所述已记录的存储次数包括向所述闪存设备已写入数据的次数;Adjusting the number of recorded storage times, which includes the number of times data has been written to the flash memory device;
    读取已记录的存储次数,得到所述闪存设备的存储次数。Reading the recorded storage times to obtain the storage times of the flash memory device.
  39. 根据权利要求37所述的智能电池,其特征在于,所述处理器用于确定闪存设备的存储次数包括:The smart battery according to claim 37, wherein the processor is used to determine the storage times of the flash memory device including:
    调整所述数据存储请求中第一逻辑地址的存储次数,所述第一逻辑地址的存储次数是指向所述第一逻辑地址中已写入数据的次数;Adjusting the number of times of storing the first logical address in the data storage request, the number of times of storing the first logical address refers to the number of times data has been written in the first logical address;
    读取所述数据存储请求中第一逻辑地址的存储次数,得到所述闪存设 备的存储次数。Reading the storage times of the first logical address in the data storage request to obtain the storage times of the flash memory device.
  40. 根据权利要求37所述的智能电池,其特征在于,所述处理器用于根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换包括:The smart battery according to claim 37, wherein the processor is configured to determine whether to perform address conversion on the reserved storage unit in the flash memory device according to the comparison result includes:
    若对比结果为所述存储次数与所述次数阈值不等,则确定保持所述保留存储单元当前的映射关系,并将数据存储到所述数据存储请求中的第一逻辑地址映射的第一存储单元。If the comparison result is that the storage times are not equal to the times threshold, it is determined to maintain the current mapping relationship of the reserved storage unit and store the data to the first storage mapped to the first logical address in the data storage request unit.
  41. 根据权利要求40所述的智能电池,其特征在于,所述处理器用于将数据存储到所述数据存储请求中的第一逻辑地址映射的第一存储单元包括:The smart battery according to claim 40, wherein the first storage unit of the first logical address mapping used by the processor to store data into the data storage request includes:
    确定第一存储单元的存储状态;Determine the storage state of the first storage unit;
    若所述存储状态表示所述第一存储单元未存满数据,则从已存储数据的尾部写入数据;If the storage state indicates that the first storage unit is not full of data, write data from the end of the stored data;
    若所述存储状态表示所述第一存储单元已存满数据,则擦除所述第一存储单元后写入数据。If the storage state indicates that the first storage unit is full of data, the first storage unit is erased and data is written.
  42. 根据权利要求37所述的智能电池,其特征在于,所述处理器用于根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换包括:The smart battery according to claim 37, wherein the processor is configured to determine whether to perform address conversion on the reserved storage unit in the flash memory device according to the comparison result includes:
    若对比结果为所述存储次数与所述次数阈值相等,则确定对所述保留存储单元进行地址转换。If the comparison result is that the storage times are equal to the times threshold, it is determined to perform address conversion on the reserved storage unit.
  43. 根据权利要求42所述的智能电池,其特征在于,若所述保留存储单元与所述数据存储请求中第一逻辑地址映射的第一存储单元相邻,所述处理器用于对所述保留存储单元进行地址转换包括:The smart battery according to claim 42, wherein if the reserved storage unit is adjacent to the first storage unit mapped by the first logical address in the data storage request, the processor is used to store the reserved The unit's address translation includes:
    将数据写入所述第一存储单元;Write data to the first storage unit;
    擦除所述保留存储单元,将所述第一存储单元中的数据复制到所述保留存储单元;Erasing the reserved storage unit, copying the data in the first storage unit to the reserved storage unit;
    将所述第一逻辑地址映射到所述保留存储单元以及将所述保留地址映 射到所述第一存储单元,完成地址转换。The first logical address is mapped to the reserved storage unit and the reserved address is mapped to the first storage unit to complete address conversion.
  44. 根据权利要求42所述的智能电池,其特征在于,所述闪存设备包括与保留地址映射的保留存储单元;若所述保留存储单元与所述数据存储请求中第一逻辑地址映射的第一存储单元相邻,所述处理器用于对所述保留存储单元进行地址转换包括:The smart battery according to claim 42, wherein the flash memory device includes a reserved storage unit mapped to a reserved address; if the reserved storage unit is mapped to the first storage of the first logical address in the data storage request The units are adjacent, and the processor for performing address conversion on the reserved storage unit includes:
    将所述保留地址映射到所述第一存储单元且所述第一逻辑地址映射到所述保留存储单元,完成地址转换;Mapping the reserved address to the first storage unit and mapping the first logical address to the reserved storage unit to complete address conversion;
    将数据存储到所述第一逻辑地址映射的保留存储单元。Storing data in the reserved storage unit mapped by the first logical address.
  45. 根据权利要求44所述的智能电池,其特征在于,所述处理器用于将数据存储到所述第一逻辑地址映射的保留存储单元包括:The smart battery according to claim 44, wherein the reserved storage unit used by the processor to store data to the first logical address map includes:
    若所述保留存储单元未存满数据,则从已存储数据的尾部写入数据;If the reserved storage unit is not full of data, write data from the end of the stored data;
    若所述保留存储单元已存满数据,则擦除所述保留存储单元后写入数据。If the reserved storage unit is full of data, the reserved storage unit is erased and data is written.
  46. 根据权利要求42所述的智能电池,其特征在于,所述闪存设备包括与保留地址映射的保留存储单元以及与第二逻辑地址映射的第二存储单元,所述保留存储单元与所述第二存储单元相邻且与所述第一存储单元不相邻,所述处理器用于对所述保留存储单元进行地址转换包括:The smart battery according to claim 42, wherein the flash memory device includes a reserved storage unit mapped to a reserved address and a second storage unit mapped to a second logical address, the reserved storage unit and the second The storage unit is adjacent to and not adjacent to the first storage unit, and the processor for performing address conversion on the reserved storage unit includes:
    将数据写入所述第一存储单元;以及,Write data to the first storage unit; and,
    擦除所述保留存储单元,将所述第二存储单元中的数据复制到所述保留存储单元;Erasing the reserved storage unit, copying the data in the second storage unit to the reserved storage unit;
    将所述保留地址映射到所述第二存储单元且所述第二逻辑地址映射到所述保留存储单元,完成地址转换。The reserved address is mapped to the second storage unit and the second logical address is mapped to the reserved storage unit to complete address conversion.
  47. 根据权利要求42所述的智能电池,其特征在于,若对比结果为所述存储次数与所述次数阈值相等,所述处理器还用于:The smart battery according to claim 42, wherein if the comparison result is that the storage times are equal to the times threshold, the processor is further configured to:
    获取所述闪存设备中各最小存储单元的状态信息;所述状态信息用于记录各最小存储单元的健康状态;所述状态信息至少包括健康状态;Obtain the state information of each minimum storage unit in the flash memory device; the state information is used to record the health state of each minimum storage unit; the state information includes at least a health state;
    若所述各最小存储单元的状态信息为健康状态,则执行根据所述对比 结果确定是否对所述闪存设备中保留存储单元进行地址转换的步骤。If the status information of each minimum storage unit is healthy, a step of determining whether to perform address conversion on the storage unit in the flash memory device is performed according to the comparison result.
  48. 根据权利要求47所述的智能电池,其特征在于,所述各最小存储单元中包括第一存储单元,所述处理器用于获取所述闪存设备中各最小存储单元的状态信息之后,还用于:The smart battery according to claim 47, wherein each of the minimum storage units includes a first storage unit, and the processor is used to obtain status information of each minimum storage unit in the flash memory device before :
    若所述第一逻辑地址映射的第一存储单元的状态信息为除健康状态之外的其他状态,则更换第一存储单元且执行根据所述对比结果确定是否对所述闪存设备中保留存储单元进行地址转换的步骤。If the status information of the first storage unit mapped by the first logical address is in a state other than the healthy state, replace the first storage unit and perform whether to reserve the storage unit in the flash memory device according to the comparison result Steps for address conversion.
  49. 根据权利要求48所述的智能电池,其特征在于,所述处理器用于更换第一存储单元包括:The smart battery according to claim 48, wherein the processor for replacing the first storage unit comprises:
    将与所述第一存储单元相邻的第三存储单元作为更换后的第一存储单元,并建立所述第一逻辑地址和所述更换后的第一存储单元的映射关系。A third storage unit adjacent to the first storage unit is used as the replaced first storage unit, and a mapping relationship between the first logical address and the replaced first storage unit is established.
  50. 根据权利要求48所述的智能电池,其特征在于,所述各最小存储单元中包括保留存储单元,所述处理器用于获取所述闪存设备中各最小存储单元的状态信息之后,还用于:The smart battery according to claim 48, wherein each of the minimum storage units includes a reserved storage unit, and after the processor is used to obtain status information of each minimum storage unit in the flash memory device, it is also used to:
    若保留存储单元的状态信息为其他状态,将与所述保留存储单元最近的一个最小存储单元作为更换后的保留存储单元,并建立保留地址和所述更换后的保留存储单元的映射关系。If the status information of the reserved storage unit is other states, the smallest storage unit closest to the reserved storage unit is used as the reserved storage unit after replacement, and the mapping relationship between the reserved address and the replaced reserved storage unit is established.
  51. 根据权利要求48所述的智能电池,其特征在于,所述各最小存储单元中包括与保留存储单元相邻的第二存储单元,所述处理器用于获取所述闪存设备中各最小存储单元的状态信息之后,还用于:The smart battery according to claim 48, wherein each of the minimum storage units includes a second storage unit adjacent to the reserved storage unit, and the processor is used to obtain the minimum storage unit of the flash memory device After the status information, it is also used to:
    若第二存储单元的状态信息为其他状态,将与所述第二存储单元相邻的第四存储单元作为更换后的第二存储单元,并建立所述第二逻辑地址与所述更换后的第二存储单元的映射关系。If the state information of the second storage unit is other states, the fourth storage unit adjacent to the second storage unit is used as the replaced second storage unit, and the second logical address and the replaced The mapping relationship of the second storage unit.
  52. 根据权利要求48~51任一项所述的智能电池,其特征在于,所述其他状态包括以下至少一项:读失败、写失败和擦除失败。The smart battery according to any one of claims 48 to 51, wherein the other states include at least one of the following: read failure, write failure, and erase failure.
  53. 根据权利要求37所述的智能电池,其特征在于,所述闪存设备中任一存储单元存储有第一逻辑地址和第一存储单元的映射关系以及保留 地址和保留存储单元的映射关系。The smart battery according to claim 37, wherein any storage unit in the flash memory device stores a mapping relationship between the first logical address and the first storage unit and a mapping relationship between the reserved address and the reserved storage unit.
  54. 根据权利要求553所述的智能电池,其特征在于,所述任一存储单元为所述闪存设备中的最后一个存储单元。The smart battery according to claim 553, wherein the any storage unit is the last storage unit in the flash memory device.
  55. 一种可移动平台,其特征在于,包括权利要求37~54任一项所述的智能电池。A movable platform, characterized by comprising the smart battery according to any one of claims 37 to 54.
  56. 一种可读存储介质,其特征在于,所述可读存储介质上存储有若干计算机指令,所述计算机指令被执行时实现权利要求1~18任一项所述方法的步骤。A readable storage medium, characterized in that a plurality of computer instructions are stored on the readable storage medium, and when the computer instructions are executed, the steps of the method according to any one of claims 1 to 18 are realized.
PCT/CN2018/119230 2018-12-04 2018-12-04 Data storage method, flash device, intelligent battery, and movable platform WO2020113440A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201880041365.5A CN110799935A (en) 2018-12-04 2018-12-04 Data storage method, flash memory device, intelligent battery and movable platform
PCT/CN2018/119230 WO2020113440A1 (en) 2018-12-04 2018-12-04 Data storage method, flash device, intelligent battery, and movable platform

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2018/119230 WO2020113440A1 (en) 2018-12-04 2018-12-04 Data storage method, flash device, intelligent battery, and movable platform

Publications (1)

Publication Number Publication Date
WO2020113440A1 true WO2020113440A1 (en) 2020-06-11

Family

ID=69438495

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/119230 WO2020113440A1 (en) 2018-12-04 2018-12-04 Data storage method, flash device, intelligent battery, and movable platform

Country Status (2)

Country Link
CN (1) CN110799935A (en)
WO (1) WO2020113440A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114063910B (en) * 2021-10-28 2024-04-02 武汉光迅科技股份有限公司 File processing method and device, file processing system and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102981970A (en) * 2012-11-23 2013-03-20 深圳市江波龙电子有限公司 Flash memory management method and system
CN106293530A (en) * 2016-08-09 2017-01-04 深圳市先天海量信息技术有限公司 A kind of method for writing data and device
CN106844227A (en) * 2017-01-14 2017-06-13 郑州云海信息技术有限公司 Solid state hard disc abrasion equilibrium method and device based on grouping mechanism

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100484147B1 (en) * 2002-07-26 2005-04-18 삼성전자주식회사 Flash memory management method
CN101740110B (en) * 2009-12-17 2013-06-12 中兴通讯股份有限公司 Method and device for erasure balance of Nand Flash
CN102135942B (en) * 2010-12-31 2013-04-24 北京握奇数据***有限公司 Method for realizing wear-leveling in storage equipment as well as the storage equipment
CN108319433B (en) * 2018-03-19 2021-02-02 艾体威尔电子技术(北京)有限公司 Storage management method for NOR Flash of small-memory single chip microcomputer

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102981970A (en) * 2012-11-23 2013-03-20 深圳市江波龙电子有限公司 Flash memory management method and system
CN106293530A (en) * 2016-08-09 2017-01-04 深圳市先天海量信息技术有限公司 A kind of method for writing data and device
CN106844227A (en) * 2017-01-14 2017-06-13 郑州云海信息技术有限公司 Solid state hard disc abrasion equilibrium method and device based on grouping mechanism

Also Published As

Publication number Publication date
CN110799935A (en) 2020-02-14

Similar Documents

Publication Publication Date Title
US8392690B2 (en) Management method for reducing utilization rate of random access memory (RAM) used in flash memory
KR101852668B1 (en) Address mapping
US20180276118A1 (en) Memory system and control method of nonvolatile memory
US20220197818A1 (en) Method and apparatus for performing operations to namespaces of a flash memory device
US9933975B1 (en) Data transmission method, memory storage device and memory control circuit unit
US10565103B2 (en) Method for creating multi-namespace and method for accessing data therein
CN107111452B (en) Data migration method and device applied to computer system and computer system
US20180366158A1 (en) Method for accessing shingled magnetic recording smr disk, and server
US9268688B2 (en) Data management method, memory controller and memory storage apparatus
CN111984188B (en) Management method and device of hybrid memory data and storage medium
CN109189772B (en) File management method and system for storage medium without file system
US8892812B2 (en) Flash memory device and data writing method for a flash memory
CN106922188A (en) Cancel map storage
CN105393228B (en) Read and write the method, apparatus and user equipment of data in flash memory
CN114415972B (en) Data processing method and device of SSD, storage medium and SSD device
US11269783B2 (en) Operating method for data storage device
TWI622890B (en) Method for creating multi-namespaces and method for accessing data stored therein
US20180276135A1 (en) Memory system and method of controlling nonvolatile memory
TW201826125A (en) Memory control scheme for flash memory device
WO2020103468A1 (en) Flash memory-based information garbage processing method, solid state disk, and storage device
WO2020113440A1 (en) Data storage method, flash device, intelligent battery, and movable platform
CN104408126B (en) A kind of persistence wiring method of database, device and system
CN115934002B (en) Solid state disk access method, solid state disk, storage system and cloud server
US9804968B2 (en) Storage system and data writing method
WO2021232427A1 (en) Flush method for mapping table of ssd

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18942578

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18942578

Country of ref document: EP

Kind code of ref document: A1