Method for preventing overwriting of storage device, storage device and electronic equipment

By using a mapping table in the storage device to record the mapping relationship and writing time between the logical address and the physical address, and determining whether writing is allowed based on the preset time period, the problem that the storage device cannot prevent data overwriting and writing in special circumstances is solved, and the durable reliability and adaptability of the data are achieved.

CN120179583APending Publication Date: 2025-06-20SHENZHEN XINGHUO SEMICON TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510667353.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-22
Publication Date
2025-06-20

AI Technical Summary

Technical Problem

In special circumstances, existing storage devices cannot effectively prevent data overwriting and writing, resulting in the overwriting and loss of important video data in car accidents. The existing methods are complex, costly, and are not suitable for all host systems.

Method used

By implementing a method of preventing overwriting in the storage device, the mapping relationship and writing time of the logical address and physical address are recorded using the mapping table, and whether writing is allowed is determined based on the preset time period to prevent overwriting of data.

Benefits of technology

Effectively protect data from being overwritten for a certain period of time, improve data durability, avoid the risk of data loss, and do not require additional host operations, good adaptability and low cost.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120179583A_ABST
    Figure CN120179583A_ABST
Patent Text Reader

Abstract

The invention provides a method for preventing overwriting of a storage device, the storage device and electronic equipment. The method comprises the following steps: for data received after an anti-coverage write trigger signal is received, judging whether a logic address to be written is written with data or not; if the data is written into the logic address to be written, judging whether the difference value between the current writing time and the last writing time exceeds the preset duration or not; if the difference value between the current writing time and the last writing time does not exceed the preset duration, writing of the current data is forbidden, and the mapping table is not updated. According to the method, the data persistence reliability is improved, and the risk that the data is covered at any time under special conditions is avoided. Moreover, the method is good in adaptability, does not need to additionally add chips, and is low in cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of storage technology, and in particular to a method for preventing a storage device from overwriting, a storage device and an electronic device. Background Art

[0002] NAND Flash related storage products (SD card, TF card), due to its small size, fast data transmission speed, hot-swappable and other excellent characteristics, are widely used in various portable electronic devices such as driving recorders or photographic equipment. The file system of general driving recorders or photographic equipment will divide the memory card into two logical areas: metadata (meta data) and data data (user data); the data area is the area for host system user file access, generally video data, and the metadata is the file system used to manage the relevant structural data information of the data area. General driving recorders or photographic equipment use the memory to format and directly write data into it. When the data is full, it will directly overwrite the original data and repeat it in this cycle.

[0003] For products such as dashcams, if a car accident occurs, the device may still be working. If the recording is not stopped in time, the dashcam will continue recording, which may overwrite the video data at the time, thereby losing the video data at the scene of the car accident. If the written video data is write-protected, the host side needs to manage when to clear the write protection and when to enable the write protection. It will be much more complicated to use and not easy to manage. In addition, some host systems do not support sending commands to set and release write protection. This method cannot be adapted to all host systems. If an external chip is used to control the time when data cannot be written, this will increase the cost and require host system management, which makes the structure complicated. If the host system requires that the written data cannot be changed externally within a certain period of time, the general memory will not record the data write time, and the original data may be overwritten, increasing the risk of data loss. Summary of the invention

[0004] In order to solve the above technical problem, the present invention provides a method for preventing a storage device from being overwritten, a storage device and an electronic device.

[0005] To this end, a first aspect of the present invention provides a method for preventing a storage device from being overwritten, comprising: In a specific embodiment, the, comprising: For the data received after receiving the anti-overwrite trigger signal, determining whether the logical address to be written has been written with data; If the logical address to be written has been written with data, determine whether the difference between the current writing time and the last writing time exceeds a preset time length; If the difference between the current write time and the previous write time does not exceed a preset duration, the writing of the current data is prohibited and the mapping table is not updated, where the unupdated mapping table includes the mapping relationship between the logical address to be written and the corresponding original physical address and the previous write time.

[0006] In a specific embodiment, the method further includes: If the logical address to be written has not been written with data, the writing of the current data is allowed and the mapping table is updated, where the updated mapping table includes the mapping relationship between the written logical address and the corresponding new physical address and the current write time.

[0007] In a specific embodiment, the method further includes: If the difference between the current write time and the previous write time exceeds the preset duration, the writing of the current data is allowed and the mapping table is updated, where the updated mapping table includes the mapping relationship between the written logical address and the corresponding new physical address and the current write time.

[0008] In a specific embodiment, the method further includes: After prohibiting the writing of the current data, determine whether to leave the write process; If it is determined that the write process has not been left, continue to wait for receiving new data.

[0009] In a specific embodiment, the method further includes: After the current data is written, determine whether to leave the write process; If it is determined that the write process has not been left, continue to wait for receiving new data.

[0010] In a specific embodiment, the method further includes: In response to the power-on of the host, the host synchronizes time information with the storage device, where the timer in the storage device updates the write time of the current data in real time.

[0011] In a specific embodiment, the determination of whether the logical address to be written has been written with data includes: Load the mapping table; Check whether there is an entry for the logical address in the mapping table; If there is an entry for the logical address, determine that the logical address to be written has been written with data, otherwise determine that the logical address to be written has not been written with data.

[0012] In a specific embodiment, the method further includes: When the current data is written, record the logical address and time information of the current written data in a blank block.

[0013] The second aspect of the present invention provides a storage device, including a controller and a flash memory module. The flash memory module includes a program, and when the program is executed by the controller, the method described in the first aspect of the present invention is implemented.

[0014] The third aspect of the present invention provides an electronic device, including a host and the storage device described in the second aspect of the present invention.

[0015] The fourth aspect of the present invention provides a device for preventing overwriting of a storage device, including: A first judgment module, configured to judge whether data has been written to the logical address to be written for the data received after receiving the anti-overwriting trigger signal; A second judgment module, configured to judge whether the difference between the current writing time and the previous writing time exceeds a preset duration if data has been written to the logical address to be written; An execution module, configured to prohibit the writing of the current data and not update the mapping table if the difference between the current writing time and the previous writing time does not exceed the preset duration.

[0016] Compared with the prior art, the beneficial effects of the present invention are as follows: The present invention provides a method for protecting data in a storage device from being overwritten within a certain period of time, improving the durability and reliability of the data, and avoiding the risk of data being overwritten at any time in special cases. Moreover, it does not require the host to perform additional write protection operations, and the method has good adaptability; on the other hand, it only needs to be implemented by software programs and does not require additional chips, resulting in low costs. Description of the Drawings

[0017] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for the description of the specific embodiments or the prior art.

[0018] Figure 1 It is a schematic diagram of a storage device according to an embodiment of the present invention; Figure 2 It is a flowchart of a method for preventing overwriting of a storage device according to an embodiment of the present invention; Figure 3 It is a schematic diagram of the mapping table format according to an embodiment of the present invention. Detailed Embodiments

[0019] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the drawings in the embodiments of the present invention.

[0020] Figure 1Schematic diagram of a storage device 12 according to an embodiment of the present invention. The storage device 12 includes a flash memory module 125 and a flash memory controller 120, and the flash memory controller 120 is used to access the flash memory module 125. According to this embodiment, the flash memory controller 120 includes a processor, control logic, buffer storage, and interface logic. The processor is used to execute program code to control the access to the flash memory module. Typically, the flash memory module includes a plurality of flash memory chips, and each flash memory chip includes a plurality of blocks. The flash memory controller erases data from the flash memory module in units of blocks. In addition, a block can record a specific number of data pages, and the flash memory controller writes data to the flash memory module in units of data pages. In one example, the flash memory module is a 3D NAND-type flash module.

[0021] The flash memory controller that executes program code through the processor can perform many control operations using its own internal components. For example, it uses control logic to control the access operations of the flash memory module (especially the access operations to at least one block or at least one data page), uses buffer storage for required buffering processing, and uses interface logic to communicate with the host device 10. The buffer storage is implemented using random access memory (RAM). For example, the buffer storage can be static random access memory (SRAM), but the present invention is not limited to this.

[0022] In one embodiment, the storage device 12 can be a solid-state drive or an embedded storage device that complies with the Universal Flash Storage (UFS) or Embedded Multi Media Card (EMMC) specifications, and is set in an electronic device, such as the dash cam described in the background art. At this time, the host 10 can be a processor of the electronic device. Of course, those skilled in the art can understand that such an electronic device is not limited to a dash cam. For example, it can be set in a mobile phone, a laptop computer, or a desktop computer, as long as there is a need to prevent overwrite writing according to the present invention in a certain application scenario.

[0023] Therefore, in another embodiment, the storage device 12 can also be a portable memory device (for example, a memory card that complies with the SD / MMC, CF, MS, XD standards), and the host 10 is an electronic device that can be connected to the storage device, such as a mobile phone, a laptop computer, a desktop computer, and so on.

[0024] To this end, a first aspect of the present invention provides a method for preventing overwriting of a storage device, as Figure 2 shown, including: S100. Detect whether an anti-overwriting trigger signal is received.

[0025] Taking a dash cam as an example. When a vehicle accident occurs, the vehicle sends an accident indication signal to the dash cam, and then the host (i.e., the processor of the dash cam) sends an anti-overwriting trigger signal to the controller of the storage device.

[0026] In one example, when an accident occurs, the driver can judge that an accident has occurred and activate this function. In other examples, such as in the scenario of intelligent driving or when the driver loses the ability to start due to an accident, the vehicle can detect the accident through devices such as an acceleration sensor, a safety airbag sensor, a collision sensor, a body control module, a camera, a radar, a vehicle-mounted communication system, and a seat belt pretensioner. Once an accident is detected, the vehicle main control immediately sends an accident indication signal to the dash cam, and then the host sends an anti-overwriting trigger signal to the controller of the storage device, thereby starting the anti-overwriting method of the present application.

[0027] S101. Monitor the data write command of the host.

[0028] As Figure 1 shown, the flash memory controller 120 of the storage device receives a write command request from the host 10.

[0029] S102. Wait to receive data.

[0030] S103. For the data received after the anti-overwriting trigger signal is received, judge whether the logical address to be written has been written with data.

[0031] In a specific example, judging whether the logical address to be written has been written with data includes: loading a mapping table; checking whether there is an entry for the logical address in the mapping table; if there is an entry for the logical address, it is judged that the logical address to be written has been written with data, otherwise it is judged that the logical address to be written has not been written with data.

[0032] If the logical address to be written has not been written with data (N in the figure), then step S104 is executed: Allow the current data to be written and update the mapping table, where the updated mapping table includes the mapping relationship between the written logical address and the corresponding new physical address and the current writing time.

[0033] The mapping table of the present invention is different from the mapping table of the prior art. In the prior art, the mapping table only includes the mapping relationship between the logical address of the host and the physical address of the memory, while the mapping table of the present invention is as Figure 3As shown, in addition to including the mapping relationship between the logical address and the physical address, it also includes the write time. The former records the mapping (L2P) information from the logical address to the physical address, and the latter is used to record the time (Recorded-Time) information, which is managed together with the mapping relationship. Since the mapping granularities of the two are different, the sizes of the two may not be equal. When writing the mapping relationship to the flash memory module, the time information also needs to be written to the flash memory module at the same time. Among them, the L2P table has a fixed size, and the Recorded-Time table has a dynamic size, depending on the data granularity of the recorded time.

[0034] In another example, the mapping relationship and the recorded time information are written on the mapping table and the recorded time information table respectively, and the two are independent of each other. When writing the mapping table to the flash memory module, the table of the recorded time information also needs to be written to the flash memory module at the same time. The recorded time information table is managed together with the mapping relationship table. This implementation manner also belongs to the equivalent implementation manner of the above-mentioned example of being represented as one table of the present invention, and all are within the protection scope of the present invention.

[0035] After step S104, the method further includes the steps: S107. Determine whether to leave the write process; If it is determined that the write process has not been left (N in the figure), then execute the steps and return to step S108.

[0036] If it is determined that the write process has been left (Y in the figure), then end the anti-overwrite write method of the present invention.

[0037] On the other hand, if the logical address to be written has already been written with data (Y in the figure), then execute step S105: Judge whether the difference between the current write time and the previous write time exceeds a preset duration.

[0038] Continuing with the example of the driving recorder, the preset duration can be preset according to the average duration for processing car accident alarms obtained from big data statistics, for example, 1 hour.

[0039] Furthermore, if the difference between the current write time and the previous write time does not exceed the preset duration (N in the figure), then execute step S106: prohibit the writing of the current data and do not update the mapping table, where the unupdated mapping table includes the mapping relationship between the logical address to be written and the corresponding original physical address and the previous write time.

[0040] Specifically, in the present invention, each data entry records a time information, and the size of the entry depends on the setting of the host. When writing data, it is judged whether the time from the last write time of the data written corresponding to the same logical address to the current write time has exceeded the set duration for prohibiting overwriting. If not, neither the mapping table corresponding to this logical address nor the write time of this data entry is updated, that is, the previous mapping relationship on this logical address and the write time of the previously written data are still maintained. When reading the data of this logical address subsequently, it is still the previously written data.

[0041] After step S106, the process also proceeds to step S107, that is, it is judged whether to leave the write process.

[0042] On the other hand, if the difference between the current write time and the last write time exceeds the preset duration (Y in the figure), step S104 is executed.

[0043] In this case, both the mapping table corresponding to this logical address and the write time of this data entry are updated, that is, the new mapping relationship of this logical address and the write time of the currently written data. When reading the data of this logical address subsequently, it is the currently written data.

[0044] To ensure the accuracy of time, in one embodiment, the method further includes an initialization process after the host is powered on. Specifically, it includes: In response to the power-on of the host, the host synchronizes the time information with the storage device.

[0045] In one example, the write time of the current data is updated in real time through a timer in the storage device to ensure time synchronization. For example, the internal time format is UNIX timestamp.

[0046] In addition, the method further includes: When the current data is written, the logical address and time information of the currently written data are recorded in the blank block.

[0047] When the data is written to the flash memory module, the logical address and time information of the currently written data are recorded in the blank area of the flash memory module to prevent the loss of data information and time information caused by abnormal power-off.

[0048] The present invention provides a method for protecting data in a storage device from being overwritten within a certain time, which improves the persistent reliability of the data and avoids the risk of data being overwritten at any time in special cases. Moreover, it does not require the host to perform additional write protection operations, and the method has good adaptability; on the other hand, it only needs to be implemented by software programs and does not require additional chips, so the cost is low.

[0049] The second aspect of the present invention provides a storage device, such as Figure 1As shown, it includes a controller and a flash memory module. The flash memory module includes a program, and when the program is executed by the controller, the method described in the first aspect of the present invention is implemented.

[0050] The third aspect of the present invention provides an electronic device, such as Figure 1 As shown, it includes a host and the storage device described in the second aspect of the present invention.

[0051] The fourth aspect of the present invention provides a device for preventing overwriting of a storage device, including: A first judgment module, configured to judge whether data has been written to the logical address to be written for the data received after receiving an anti-overwriting trigger signal; A second judgment module, configured to judge whether the difference between the current writing time and the previous writing time exceeds a preset duration if data has been written to the logical address to be written; An execution module, configured to prohibit the writing of the current data and not update the mapping table if the difference between the current writing time and the previous writing time does not exceed the preset duration.

[0052] It should be noted that although the above embodiments describe the various steps in a specific order, those skilled in the art can understand that in order to achieve the effects of the present application, it is not necessary for different steps to be executed in such an order. They can be executed simultaneously (in parallel) or in other orders. These adjusted solutions are equivalent technical solutions to the technical solutions described in the present application, and thus will also fall within the protection scope of the present application.

[0053] The above embodiments are only specific implementation manners of the present invention, used to illustrate the technical solutions of the present invention, rather than to limit it. The protection scope of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: any person skilled in the art within the technical scope disclosed by the present invention can still modify or improve the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims

1. A method for preventing overwriting in a storage device, characterized in that, Including: For the data received after receiving the anti-overwrite trigger signal, determine whether the logical address to be written has already been written with data; If the logical address to be written has already been written with data, determine whether the difference between the current write time and the previous write time exceeds a preset duration; If the difference between the current write time and the previous write time does not exceed the preset duration, prohibit the writing of the current data and do not update the mapping table.

2. The method according to claim 1, characterized in that, The method further includes: If the logical address to be written has not been written with data, allow the writing of the current data and update the mapping table.

3. The method according to claim 1, characterized in that, The method further includes: If the difference between the current write time and the previous write time exceeds the preset duration, allow the writing of the current data and update the mapping table.

4. The method according to claim 1, characterized in that, The method further includes: After prohibiting the writing of the current data, determine whether to leave the write process; If it is determined that the write process has not been left, continue to wait for new data to be received.

5. The method according to claim 2 or 3, characterized in that, The method further includes: After the current data has been written, determine whether to leave the write process; If it is determined that the write process has not been left, continue to wait for new data to be received.

6. The method according to claim 1, characterized in that, The method further includes: In response to the power-on of the host, the host synchronizes time information with the storage device, wherein the timer in the storage device updates the write time of the current data in real time.

7. The method according to claim 1, characterized in that, The determination of whether the logical address to be written has already been written with data includes: Load the mapping table; Check whether there is an entry for the logical address in the mapping table; If there is an entry for the logical address, determine that the logical address to be written has already been written with data, otherwise determine that the logical address to be written has not been written with data.

8. An apparatus for preventing overwriting in a storage device, characterized in that, Including: A first judgment module for, for the data received after receiving the anti-overwrite trigger signal, determining whether the logical address to be written has already been written with data; A second judgment module for, if the logical address to be written has already been written with data, determining whether the difference between the current write time and the previous write time exceeds a preset duration; An execution module for, if the difference between the current write time and the previous write time does not exceed the preset duration, prohibiting the writing of the current data and not updating the mapping table.

9. A storage device, comprising a controller and a flash memory module, characterized in that, The flash memory module includes a program that, when executed by the controller, implements the method according to any one of claims 1-7.

10. An electronic device, characterized in that, Including a host and the storage device according to claim 9.

Citation Information

Patent Citations

  • Data storage method with Flash storage blocks evenly assigned

    CN102981966A

  • Vehicle travelling video storage method and device based on automobile data recorder

    CN105631968A

  • Video storage method, system, chip, storage device and driving recorder

    CN107302676A