Data storage method, module, unmanned aerial vehicle control device, and readable storage medium
By setting up buffered power and logical-physical storage block mapping in the drone data storage module, the problem of data loss when the drone suddenly loses power is solved, and stable data storage and rapid recovery are achieved.
Patent Information
- Application Number
- CN202310180117.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-17
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2043-02-17
AI Technical Summary
When a drone experiences a sudden power outage, the data being stored or about to be stored may be lost, and the reliability of data storage cannot be guaranteed.
A buffer power supply is set in the data storage module. When an external power failure occurs, the buffer power supply provides short-term power to the controller, enabling the controller to store the data to be stored in the temporary material storage block. Through the mapping relationship between the logical storage block and the physical storage block, the data is quickly stored in the temporary physical storage block.
It prevents data loss during sudden power outages, ensures the stability and reliability of data storage, and guarantees that data can be recovered after a power outage.
Smart Images

Figure CN116225326B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data storage, in particular to a data storage method, module, unmanned aerial vehicle control device and readable storage medium. BACKGROUND
[0002] In the use process of the unmanned aerial vehicle, the operator often wants to store various data in the use process for subsequent inspection, especially after an abnormal situation occurs, the operator wants to obtain and trace the process record data, so as to analyze and investigate the event occurrence process and reason; the data that need to be recorded and stored generally include sensor data, navigation positioning data, control instruction data, telemetry data, flight control data and the like. At the same time, it is required to conveniently export these data records, such as designing an independent external interface, connecting a cable with an external device, and then reading out the stored data for subsequent processing and analysis.
[0003] However, at present, when the unmanned aerial vehicle suddenly loses power, the data being stored or about to be stored will be lost, which cannot guarantee the reliability of data storage. SUMMARY
[0004] In view of the deficiencies in the prior art, the data storage method, module, unmanned aerial vehicle control device and readable storage medium provided by the present application solve the problem of data loss in the prior art when suddenly losing power.
[0005] In a first aspect, the present application provides a data storage method applied to a data storage module, the data storage module comprising a memory, a controller and a buffer power supply, the memory comprising a plurality of physical storage blocks, each physical storage block comprising a plurality of pages, each page comprising a data storage area for storing data and a page spare area for managing data, the spare area comprising a good and bad block identification bit, a block number identification bit, a temporary physical block number identification bit, a temporary block address identification bit and a temporary data length identification bit, the method comprising: the controller establishing a physical-logical mapping table, an idle physical storage block table and a physical-temporary mapping table according to the block number identification bit of the first page spare area of each normal physical storage block; the controller acquiring a target physical storage block number and a block address corresponding to a data storage operation according to a logical starting address, a to-be-stored data length and the physical-logical mapping table in a data storage instruction; when a power failure event occurs, the buffer power supply provides power for the controller, and the controller acquires a temporary physical storage block number according to a preset temporary block number and the physical-temporary mapping table; and the controller writes the target physical storage block number, the block address, the to-be-stored data length and the to-be-stored data into the temporary physical block number identification bit, the temporary block address identification bit, the temporary data length identification bit and the data storage area of the temporary physical storage block, respectively.
[0006] Optionally, the controller writes the target physical storage block number, the block-in address, the to-be-stored data length and the to-be-stored data into the temporary storage physical block number identification bit, the temporary block-in address identification bit, the temporary data length identification bit and the data storage area of the temporary storage physical block respectively, and the method further comprises: establishing a temporary record linked list according to the temporary storage physical block number identification bit, the temporary block-in address identification bit and the data length identification bit; and storing the temporarily stored data in the temporary storage physical block into the target data storage area in the target physical storage block according to the temporary record linked list after a power failure event occurs.
[0007] Optionally, the controller obtains the target physical storage block number and the block-in address corresponding to the data storage operation according to the logical start address, the to-be-stored data length and the physical-logical mapping table in the data storage instruction, which comprises: obtaining the target logical storage block number and the block-in address corresponding to the data storage operation according to the logical start address and the to-be-stored data length in the data storage instruction; obtaining the target physical storage block number corresponding to the data storage operation according to the target logical storage block number and the physical-logical mapping table; and obtaining the target data storage area in the target physical storage block according to the target physical storage block number, the block-in address and the to-be-stored data length.
[0008] Optionally, when no power failure event occurs and the target data storage area has no stored data, the to-be-stored data in the data storage instruction is written into the target data storage area.
[0009] Optionally, when no power failure event occurs and the target data storage area has stored data, the method further comprises: reading the stored data of the target data storage area; merging and updating the stored data of the target data storage area with the to-be-stored data to obtain merged stored data; selecting an idle physical storage block from the idle physical storage block table; and writing the merged stored data into the idle physical storage block.
[0010] Optionally, after the merged stored data is written into the idle physical storage block, the method further comprises: writing the target logical storage block number into the block number identification bit of the first page spare area of the idle physical storage block; updating the physical-logical mapping table according to the idle physical storage block number; and erasing the data of the target physical storage block and marking it into the idle physical storage block table.
[0011] Optionally, before the controller establishes the physical-logical mapping table, the free physical storage block table and the physical-temporary mapping table according to the block number identification bit of the first page spare area of each normal physical storage block, the method further comprises: obtaining all current normal physical storage blocks according to the good / bad block identification bit of the first page spare area and the good / bad block identification bit of the second page spare area in each physical storage block; and writing each logical block number into the block number identification bit of the first page spare area of the corresponding normal physical storage block in sequence according to the preset logical storage block.
[0012] In a second aspect, the present application provides a data storage module, which comprises a memory, a controller, a power failure detection circuit, a buffer power supply and a USB interface; wherein the memory comprises a plurality of physical storage blocks, each of which comprises a plurality of pages, each of which comprises a data storage area for storing data and a page spare area for managing data, the spare area comprising a good / bad block identification bit, a block number identification bit, a temporary physical block number identification bit, a temporary block address identification bit and a temporary data length identification bit; the controller is connected with the buffer power supply, the memory, the power failure detection circuit and the USB interface respectively; the power failure detection circuit is connected with an external power supply and the buffer power supply respectively, and is used for detecting whether the external power supply has a power failure, and further used for outputting a power failure signal to the buffer power supply and the controller when detecting that the external power supply has a power failure, so that the buffer power supply provides power for the controller according to the power failure signal, and the controller stores the data to be stored in a temporary physical storage block according to the power failure signal.
[0013] In a third aspect, the present application provides a UAV control device, which integrates the data storage module.
[0014] In a fourth aspect, the present application provides a readable storage medium, which stores a computer program, and the computer program is executed by a processor to realize the following steps: the controller establishes a physical-logical mapping table, a free physical storage block table and a physical-temporary mapping table according to the block number identification bit of the first page spare area of each normal physical storage block; the controller obtains a target physical storage block number and a block address corresponding to a data storage operation according to a logical starting address, a data length to be stored and the physical-logical mapping table in a data storage instruction; when a power failure event occurs, the buffer power supply provides power for the controller, and the controller obtains a temporary physical storage block number according to a preset temporary block number and the physical-temporary mapping table; and the controller writes the target physical storage block number, the block address, the data length to be stored and the data to be stored into the temporary physical block number identification bit, the temporary block address identification bit, the temporary data length identification bit and the data storage area of the temporary physical storage block, respectively.
[0015] Compared with the prior art, the present application has the following advantages:
[0016] 1. The application sets a buffer power supply in the data storage module, which can provide temporary power for the controller through the buffer power supply when the external power supply has a power failure event, so that the controller can store the data to be stored in the temporary material storage block, preventing data loss when the power suddenly fails.
[0017] 2. The application maps the logical storage block and the temporary block with the physical storage block respectively, calculates the target physical storage block number that needs to be stored through the logical starting address and the length of the data to be stored in the data storage instruction; when a power failure event occurs, the controller stores the data to be stored in the temporary physical storage block according to the mapping relationship between the temporary block and the physical storage block, which can further prevent the problem of data loss when the power suddenly fails, and ensure the stability of data storage. BRIEF DESCRIPTION OF DRAWINGS
[0018] Figure 1 Fig. 1 shows a structural schematic diagram of a data storage module provided by an embodiment of the application;
[0019] Figure 2 Fig. 2 shows a program level relationship diagram provided by an embodiment of the application;
[0020] Figure 3 Fig. 3 shows a structural schematic diagram of a memory provided by an embodiment of the application;
[0021] Figure 4 Fig. 4 shows a flowchart of a data storage method provided by an embodiment of the application;
[0022] Figure 5 Fig. 5 shows a power failure event processing flowchart provided by an embodiment of the application;
[0023] Figure 6 Fig. 6 shows a block replacement event processing flowchart provided by an embodiment of the application. DETAILED DESCRIPTION
[0024] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme of the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0025] In a first aspect, the application provides a data storage module, which specifically includes the following embodiments:
[0026] As Figure 1As shown, the data storage module includes a memory, a controller, a power failure detection circuit, a buffer power supply and a USB interface, the memory includes a plurality of physical storage blocks, each physical storage block includes a plurality of pages, each page includes a data storage area for storing data and a page spare area for managing data, the spare area includes good and bad block identification bits, block number identification bits, temporary physical block number identification bits, temporary block address identification bits and temporary data length identification bits;
[0027] The controller is connected with the buffer power supply, the memory, the power failure detection circuit and the USB interface respectively; the power failure detection circuit is connected with an external power supply, a buffer power supply and the controller respectively, for detecting whether the external power supply has a power failure, and also for outputting a power failure signal to the buffer power supply and the controller when detecting that the external power supply has a power failure, so that the buffer power supply provides power for the controller according to the power failure signal, and also so that the controller stores the data to be stored in a temporary material storage block according to the power failure signal.
[0028] It should be noted that the controller is connected with the memory through a parallel port to realize access and operation of the memory, such as writing, reading, erasing, parameter configuration and the like; as Figure 2 As shown, in order to realize access and operation of the memory, a plurality of programs run in the controller, mainly including a storage medium drive program, a power failure event interrupt processing program, a medium operation log program, a medium operation recovery program, a file system program, a storage application program, a USB drive program, an SPI drive program and a clock program. The file system is realized on the basis of the API provided by the medium drive program, the storage module uses a general file system to organize data, file storage, and provides an API calling interface to an upper layer.
[0029] The storage application program calls the file system API to realize file management, data storage and reading out. Through the SPI driver, external communication is realized to obtain storage data and feedback storage system state. When the power failure event occurs, the storage application program immediately enters the process of closing the storage task and closing the open file, and realizes complete storage of information before the buffer power is exhausted. The USB driver calls the API provided by the medium driver to access the storage medium, and combines the independently designed USB interface, so that the general computer can conveniently access and read the stored data. In addition, the data is organized in the form of a general file system in the storage medium, so that the general computer can access the storage module like a U disk through the USB interface. The clock program realizes the timing function on the basis of the RTC of the MCU, and is used by the upper application. The clock program can obtain the external time through the SPI communication interface to perform coarse time synchronization. The controller internally has a USB peripheral controller, the communication pins of which are connected to the USB interface device through the printed board circuit, and are used for external device access. The controller is connected with the flight control processing platform through the SPI to realize the reception of the storage data and the reception and response of the external command. The power failure detection circuit detects that the external power voltage drops to a certain threshold, and notifies the controller of the occurrence of the power failure event through the GPIO pin connected to the controller. The buffer power can continuously supply power for a period of time in the order of ms after the power supply power fails.
[0030] As Figure 3 indicated, the memory is generally composed of a plurality of physical storage blocks, one physical storage block is composed of a plurality of pages, each page is composed of a data storage area and a standby area, each area is composed of a certain number of byte storage spaces. Data can be randomly addressed and written, but erasing needs to be performed in units of physical storage blocks.
[0031] In a second aspect, the present application provides a data storage method, which specifically includes the following embodiments:
[0032] Figure 4 Fig. 1 shows a flowchart of a data storage method provided by an embodiment of the present application; as Figure 4 indicated, the data storage method specifically includes the following steps:
[0033] In step S101, the controller establishes a physical-logical mapping table, an idle physical storage block table and a physical-temporary mapping table according to the block number identification bit of the first page standby area of each normal physical storage block.
[0034] In the embodiment, before the controller establishes the physical-logical mapping table, the idle physical storage block table and the physical-temporary mapping table according to the block number identification bit of the first page spare area of each normal physical storage block, the method further comprises: obtaining all current normal physical storage blocks according to the good / bad block identification bit of the first page spare area and the good / bad block identification bit of the second page spare area in each physical storage block; and writing each logical block number into the block number identification bit of the corresponding normal physical storage block in sequence according to the preset logical storage block.
[0035] It should be noted that the good / bad block identification bit is used to identify whether the current physical storage block is normal. When formatting the storage, all storage areas and all identification bits of all good physical storage blocks are reset to 0xFF data. If there is an exception in a good physical storage block, the good / bad block identification bit of the good physical storage block is identified as non-0xFF data when the exception is found. Therefore, whether each physical storage block is a normal physical storage block is determined by the values of the good / bad block identification bit of the first page spare area and the good / bad block identification bit of the second page spare area in each physical storage block.
[0036] Further, the physical storage block in the embodiment refers to the actual storage space in the storage, and the logical storage block refers to the virtual storage space divided in the program. One logical storage block can correspond to one or any number of physical storage blocks, which is set according to the control program running in the controller. In the embodiment, one logical storage block corresponds to one physical storage block, the preset logical storage block is sequentially defined with logical block numbers, and each logical block number is written into the block number identification bit of the corresponding normal physical storage block in sequence to realize the binding of the logical storage block and the physical storage block. Similarly, a temporary storage block for temporary storage is also defined in the embodiment, and each temporary storage block number is written into the block number identification bit of the corresponding normal physical storage block in sequence to realize the binding of the temporary storage block and the physical storage block. Further, the material storage block that has not been bound is used as an idle physical storage block, so that the physical-logical mapping table, the idle physical storage block table and the physical-temporary mapping table are established according to the block number identification bit of each normal physical storage block.
[0037] In step S102, the controller obtains the target physical storage block number and the block address corresponding to the data storage operation according to the logical starting address, the length of the data to be stored and the physical-logical mapping table in the data storage instruction.
[0038] In the embodiment, the controller obtains the target physical storage block number and the in-block address corresponding to the data storage operation according to the logical start address in the data storage instruction, the length of the data to be stored, and the physical-logical mapping table, including: obtaining the target logical storage block number and the in-block address corresponding to the data storage operation according to the logical start address in the data storage instruction and the length of the data to be stored; obtaining the target physical storage block number corresponding to the data storage operation according to the target logical storage block number and the physical-logical mapping table; and obtaining the target data storage area in the target physical storage block according to the target physical storage block number, the in-block address, and the length of the data to be stored.
[0039] It should be noted that the data storage instruction can be an instruction sent by a flight control running platform to the controller, and the data storage instruction includes the data to be stored, a logical start address for storing the data to be stored, and the length of the data to be stored; wherein the storage addresses of the logical storage blocks in the embodiment are continuous, for example, each logical storage block includes 256 bytes, the in-block address of the first logical storage block is from 0-255, and the in-block address of the second logical storage block is from 256-512; therefore, according to the logical start address in the data storage instruction and the length of the data to be stored, the corresponding target logical storage block number and the in-block address can be calculated, then the physical-logical mapping table is queried to find the target physical storage block number corresponding to the write operation, and the target data storage area is queried according to the target physical storage block number, the in-block address, and the length of the data to be stored.
[0040] In step S103, when the power-off event occurs, the buffer power supply provides power for the controller, and the controller obtains the temporary storage physical storage block number according to the preset temporary storage block number and the physical-temporary mapping table.
[0041] It should be noted that when the power-off detection circuit detects that the external power supply is powered off, a power-off signal is output to the buffer power supply and the controller, so that the buffer power supply provides temporary power for the controller according to the power-off signal, and the temporary power enables the controller to store the data to be stored into the temporary storage block.
[0042] In the embodiment, when the controller receives the power-off signal output by the power-off detection circuit, the corresponding temporary storage physical storage block number is found from the physical-temporary mapping table according to the preset temporary storage block number.
[0043] In step S104, the controller writes the target physical storage block number, the in-block address, the length of the data to be stored, and the data to be stored into the temporary storage physical block number identification bit, the temporary in-block address identification bit, the temporary data length identification bit, and the data storage area of the temporary storage physical storage block, respectively.
[0044] It should be noted that the controller directly writes the data to be stored into the data storage area of the temporary physical storage block, and writes the target physical storage block number, the block address, and the length of the data to be stored into the temporary physical block number identification bit, the temporary block address identification bit, and the temporary data length identification bit of the temporary physical storage block, respectively, for subsequent convenient query and data recovery.
[0045] In the embodiment, after the controller writes the target physical storage block number, the block address, the length of the data to be stored, and the data to be stored into the temporary physical block number identification bit, the temporary block address identification bit, the temporary data length identification bit, and the data storage area of the temporary physical storage block, respectively, the method further comprises: establishing a temporary record linked list according to the temporary physical block number identification bit, the temporary block address identification bit, and the data length identification bit; and when a power-off event occurs, storing the temporarily stored data in the temporary physical storage block into the target data storage area in the target physical storage block according to the temporary record linked list when next power-on.
[0046] It should be noted that the power-off event interrupt handling program is triggered when the power-off event occurs, as shown in Figure 5 The program selects a physical block from the idle physical storage block table as a temporary block, and removes the mark of the used physical block in the idle physical storage block table. The order number of the temporary block number is filled in the first page standby area of this block, which is the starting number at this time. Then, the mapping relationship record is written into the physical block number and temporary block number mapping table. The temporary write position is initialized as the temporary block order number and the first page number in the block.
[0047] The media operation log program is triggered when the power-off event occurs, and intervenes in the block replacement write operation of the memory driver program. The block replacement operation will not be performed, but the write data will be temporarily stored in the temporary block, so as to reduce the operation time. As shown in Figure 6The physical block number corresponding to the temporary block number is determined by querying the physical-temporary mapping table according to the temporary block number in the temporary write position mark. Then, the physical write address (physical block number, block address) of the write data and the data length are written into the page spare area pointed by the temporary write position, the fifth and sixth bytes of the spare area are written into the physical block number where the data should be originally written, the seventh to tenth bytes of the spare area are written into the physical block address where the data should be originally written, and the eleventh to fourteenth bytes of the spare area are written into the data length. Subsequently, the data to be written is sequentially written from the start position of the temporary space pointed by the temporary write position. If the temporary space is used up, a physical block is selected from the idle physical block number table as a temporary block to continue storing data, and the mark of the used physical block in the idle physical block number table is removed; the first page spare area of the block is filled with the newly allocated temporary block number, and the mapping relationship is recorded in the physical block number and temporary block number mapping table. When the data storage is completed, a record is added in the temporary record chain table, recording the physical block number, block address, data length, temporary block number pointed by the temporary write position, and page number pointed by the temporary write position. Finally, the temporary block number of the remaining unused temporary space and the start position (page number) of the remaining temporary space in the block pointed by the temporary write position are updated for the next temporary operation.
[0048] After the power failure event occurs, the read operation of the memory driver needs to determine whether the address range of the read data falls in the temporary area by querying the temporary record chain table. If yes, the data in the temporary area needs to be read when reading the data to ensure data consistency.
[0049] When the power is turned on and the memory is scanned, if the physical block number and temporary block number mapping table is not empty, the medium operation recovery program is triggered. The program first scans the temporary area from the start position of the temporary area according to the physical block number and temporary block number mapping table, and the complete temporary record chain table can be constructed by reading the information written in the start page spare area during each temporary operation. Subsequently, the medium operation recovery program reads the data in the temporary area according to the entry information recorded in the temporary record chain table, and performs complete block replacement operation to restore the data consistency of the data storage area. Finally, the physical-temporary mapping table and the temporary record chain table are emptied.
[0050] Compared with the prior art, the present application has the following advantages:
[0051] 1. The buffer power supply is arranged in the data storage module, so that the controller can store the data to be stored in the temporary material storage block when the external power supply fails, thereby preventing data loss caused by sudden power failure.
[0052] 2、The application can calculate the target physical storage block number by the logical starting address and the length of the data to be stored in the data storage instruction, and can store the data to be stored in the temporary physical storage block quickly according to the mapping relationship between the temporary block and the physical storage block when the power-off event occurs, so that the problem of data loss caused by sudden power-off can be further prevented, and the stability of data storage is ensured.
[0053] In another embodiment of the application, when the power-off event does not occur and the target data storage area does not store data, the data to be stored in the data storage instruction is written into the target data storage area.
[0054] In another embodiment of the application, when the power-off event does not occur and the target data storage area has stored data, the method further comprises: reading the stored data of the target data storage area; merging and updating the stored data of the target data storage area and the data to be stored to obtain merged stored data; selecting an idle physical storage block from the idle physical storage block table, and writing the merged stored data into the idle physical storage block.
[0055] It should be noted that when the target data storage area has stored data, the stored data of the target data storage area needs to be read into the cache of the controller, and the data to be processed and the stored data of the target data storage area are merged and updated and then stored in an idle physical storage block, that is, the block switching operation of data storage. Since the block switching operation of data storage needs to read the stored data into the cache, then merge and update the data to be stored, then select an idle physical storage block, and finally write the merged stored data into the idle physical storage block, the operation process of these operations takes a long time. When the power-off event does not occur, data storage according to this operation process is not a problem, and the accuracy and stability of data storage can be ensured. However, when the power-off event occurs, the long-time block switching operation is not suitable, and it is necessary to switch to the above embodiment of storing the data to be stored in the temporary physical storage block quickly, so that the operation time can be reduced, the problem of data loss caused by sudden power-off can be prevented, and the stability of data storage is ensured.
[0056] In this embodiment, after the merged stored data is written into the idle physical storage block, the method further comprises: writing the target logical storage block number into the block number identification bit of the first page spare area of the idle physical storage block; updating the physical-logical mapping table according to the idle physical storage block number; and erasing the data of the target physical storage block number and marking it into the idle physical storage block table.
[0057] In a third aspect, the present application provides a UAV control device, which has integrated a navigation positioning platform, a flight control program running platform, a data processing platform and the data storage module described in the above embodiments, and is designed in an integrated control device through hardware high integration, thereby reducing the overall device weight, improving the UAV payload, and ensuring the reliability of the module functions. The data storage module manages data files through the use of a general file system, and combines an independently designed USB interface, so that a general computer can conveniently access and read the stored data. Through the software and hardware integrated design, the storage medium and its characteristics are fully utilized, and the data files written in the storage module still exist after a sudden power failure, so that the sudden power failure situation can be reliably coped with.
[0058] In a fourth aspect, the present application provides a readable storage medium, which has stored a computer program thereon, and the computer program is executed by a processor to realize the following steps: the controller establishes a physical-logical mapping table, an idle physical storage block table and a physical-temporary mapping table according to the block number identification bit of the first spare area of each normal physical storage block; the controller acquires the target physical storage block number and the block address corresponding to the data storage operation according to the logical starting address, the to-be-stored data length and the physical-logical mapping table in the data storage instruction; when a power failure event occurs, the buffer power supply provides power for the controller, and the controller acquires the temporary physical storage block number according to the preset temporary block number and the physical-temporary mapping table; and the controller writes the target physical storage block number, the block address, the to-be-stored data length and the to-be-stored data into the temporary physical block number identification bit, the temporary block address identification bit, the temporary data length identification bit and the data storage area of the temporary physical storage block, respectively.
[0059] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing relevant hardware through a computer program. The program can be stored in a non-volatile computer readable storage medium, and when the program is executed, the processes of the above-mentioned embodiments of the methods can be included. Any reference to memory, storage, databases, or other media in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in many forms such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0060] It should be noted that, in this document, the terms "first" and "second" and the like are used merely to distinguish one entity or action from another, without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without more limitations, an element defined by the statement "comprising a" does not exclude the existence of additional identical elements in the process, method, article, or apparatus including the element.
Claims
1. A data storage method, characterized in that, The method is applied to a data storage module, which includes a memory, a controller, and a buffer power supply. The memory includes multiple physical storage blocks, each physical storage block includes multiple pages, and each page includes a data storage area for storing data and a page spare area for managing data. The spare area includes a good / bad block identifier, a block number identifier, a temporary physical block number identifier, a temporary block address identifier, and a temporary data length identifier. The method includes: The controller establishes a physical-logical mapping table, a free physical storage block table, and a physical-temporary storage mapping table based on the block number identifier bit of the home page spare area of each normal physical storage block; The controller obtains the target physical storage block number and the address within the block corresponding to the data storage operation based on the logical start address, the length of the data to be stored, and the physical-logical mapping table in the data storage instruction. When a power failure occurs, the buffer power supply provides power to the controller, and the controller obtains the temporary physical storage block number according to the preset temporary block number and the physical-temporary mapping table; The controller writes the target physical storage block number, the address within the block, the length of the data to be stored, and the data to be stored into the temporary physical storage block's temporary physical block number identifier, temporary block address identifier, temporary data length identifier, and data storage area, respectively.
2. The data storage method as described in claim 1, characterized in that, After the controller writes the target physical storage block number, the block address, the length of the data to be stored, and the data to be stored into the temporary physical storage block's ... A temporary storage record linked list is established based on the temporary storage physical block number identifier, the temporary storage block address identifier, and the data length identifier. When a power failure occurs, the temporary storage data in the temporary physical storage block is stored in the target data storage area in the target physical storage block according to the temporary record linked list.
3. The data storage method as described in claim 1, characterized in that, The controller obtains the target physical storage block number and intra-block address corresponding to the data storage operation based on the logical start address, the length of the data to be stored, and the physical-logical mapping table in the data storage instruction, including: Based on the logical start address and the length of the data to be stored in the data storage instruction, obtain the target logical storage block number and the address within the block corresponding to the data storage operation; Based on the target logical storage block number and the physical-logical mapping table, obtain the target physical storage block number corresponding to the data storage operation; Based on the target physical storage block number, the address within the block, and the length of the data to be stored, the target data storage area within the target physical storage block number is obtained.
4. The data storage method as described in claim 3, characterized in that, When no power failure event occurs and the target data storage area does not store data, the data to be stored in the data storage instruction is written into the target data storage area.
5. The data storage method as described in claim 3, characterized in that, When no power failure event occurs and the target data storage area already contains stored data, the method further includes: Read the stored data in the target data storage area; The stored data in the target data storage area is merged and updated with the data to be stored to obtain merged stored data; Select a free physical storage block from the free physical storage block table and write the merged storage data into the free physical storage block.
6. The data storage method as described in claim 5, characterized in that, After writing the merged storage data into the free physical storage block, the method further includes: Write the target logical storage block number into the block number identifier bit of the first page spare area of the free physical storage block; Update the physical-logical mapping table according to the free physical storage block number; After erasing the data of the target physical storage block number, it is marked in the free physical storage block table.
7. The data storage method as described in claim 1, characterized in that, Before the controller establishes a physical-logical mapping table, a free physical storage block table, and a physical-temporary storage mapping based on the block number identifier bit of the homepage spare area of each normal physical storage block, the method further includes: Based on the good / bad block identifier bits of the first page spare area and the second page spare area in each physical storage block, obtain all currently normal physical storage blocks; Based on the preset logical storage blocks, each logical block number is sequentially written into the block number identifier bit of the home page spare area of the corresponding normal physical storage block.
8. A data storage module based on the data storage method of claim 1, characterized in that, The module includes: The system includes a memory, a controller, a power failure detection circuit, a buffer power supply, and a USB interface. The memory comprises multiple physical storage blocks, each physical storage block comprises multiple pages, and each page comprises a data storage area for storing data and a page spare area for managing data. The spare area includes a good / bad block identifier, a block number identifier, a temporary physical block number identifier, a temporary block address identifier, and a temporary data length identifier. The controller is connected to the buffer power supply, the memory, the power failure detection circuit, and the USB interface, respectively. The power failure detection circuit is connected to an external power supply and a buffer power supply respectively. It is used to detect whether the external power supply has lost power. When the power failure of the external power supply is detected, it is also used to output a power failure signal to the buffer power supply and the controller, so that the buffer power supply provides power to the controller according to the power failure signal, and the controller stores the data to be stored in the temporary material storage block according to the power failure signal.
9. A drone control device, characterized in that, The control device integrates the data storage module described in claim 8.
10. A readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of any one of claims 1 to 7.
Citation Information
Patent Citations
Caching data block processing method and hard disk
CN101458668A
Control method, unmanned aerial vehicle and computer readable storage medium
CN110832737A