CN110333967B - Method, device and equipment for preventing USB flash disk data loss and system damage - Google Patents

Method, device and equipment for preventing USB flash disk data loss and system damage Download PDF

Info

Publication number
CN110333967B
CN110333967B CN201910384136.XA CN201910384136A CN110333967B CN 110333967 B CN110333967 B CN 110333967B CN 201910384136 A CN201910384136 A CN 201910384136A CN 110333967 B CN110333967 B CN 110333967B
Authority
CN
China
Prior art keywords
data
time programmable
management table
read
storage space
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910384136.XA
Other languages
Chinese (zh)
Other versions
CN110333967A (en
Inventor
李虎
梁永权
谭四方
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Demingli Electronics Co Ltd
Original Assignee
Shenzhen Demingli Electronics Co Ltd
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 Shenzhen Demingli Electronics Co Ltd filed Critical Shenzhen Demingli Electronics Co Ltd
Priority to CN201910384136.XA priority Critical patent/CN110333967B/en
Publication of CN110333967A publication Critical patent/CN110333967A/en
Application granted granted Critical
Publication of CN110333967B publication Critical patent/CN110333967B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • G06F11/1469Backup restoration techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/70Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer
    • G06F21/78Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure storage of data
    • G06F21/79Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure storage of data in semiconductor storage media, e.g. directly-addressable memories

Abstract

The invention discloses a method, a device and equipment for preventing data loss and system damage of a USB flash disk. Wherein the method comprises the following steps: adding a one-time programmable (OTP) storage space into a main control chip of the U disk, storing an operation code and original algorithm management table data into the OTP storage space, reading the stored operation code data from the OTP storage space when Boot Loader is guided to load the operation code normally or the algorithm management table data fails, recovering the operation code data according to the read operation code data, reading the stored original algorithm management table data from the OTP storage space, and recovering the original algorithm management table data according to the read original algorithm management table data. By the mode, the situation that the original data of the user is lost or the USB flash disk system is damaged and cannot run can be prevented.

Description

Method, device and equipment for preventing USB flash disk data loss and system damage
Technical Field
The present invention relates to the field of storage technologies, and in particular, to a method, an apparatus, and a device for preventing data loss and system damage of a usb disk.
Background
The USB Flash disk (USB Flash disk) is composed of a main control chip and an NF (NAND Flash ) memory. The main control chip loads the running code and the algorithm management table data stored in the NAND Flash Memory into a RAM (Random Access Memory) through Boot Loader codes solidified in a ROM (Read-Only Memory), and then the running code is executed in the RAM Random Access Memory.
Due to the storage characteristics of the NAND Flash memory, data errors can be caused due to the storage environment, the storage time is too long, abnormal power failure and the like, the Boot Loader Boot loading may cause the situations that running codes cannot be loaded or the data loading of the algorithm management table fails, and at the moment, the original data of a user is lost in the U disk, or the U disk system is damaged and cannot run, and the like.
Disclosure of Invention
In view of this, the present invention provides a method, an apparatus, and a device for preventing data loss and system damage of a usb disk, which can prevent the situation that the original data of a user is lost or the system of the usb disk is damaged and cannot be run.
According to an aspect of the present invention, there is provided a method for preventing data loss and system damage of a usb disk, comprising:
adding a one-time programmable storage space into a main control chip of the U disk;
storing run code and raw algorithm management table data in the one-time programmable memory space;
when the normal loading of the operation codes or the failure of the algorithm management table data is guided, reading the stored operation code data from the one-time programmable storage space, recovering the operation code data according to the read operation code data, reading the stored original algorithm management table data from the one-time programmable storage space, and recovering the original algorithm management table data according to the read original algorithm management table data.
Wherein, the reading out the stored running code data from the one-time programmable storage space and recovering the running code data according to the read out running code data comprises:
loading the stored running code data from the one-time programmable memory space;
reading a temporary mark from a first fixed offset address in said one-time programmable memory space;
judging whether the read temporary mark is the mark of a loading table in the one-time programmable storage space, and reading the initial address and the data length of the associated running code in the one-time programmable storage space from the address corresponding to the temporary mark when the read temporary mark is judged to be the mark of the loading table in the one-time programmable storage space;
reading out running code data related to the starting address and the data length from the one-time programmable storage space according to the read starting address and the read data length;
until all the run code data pointed by the fixed offset address in the one-time programmable storage space are read out, and the run code data are recovered according to the read run code data.
Wherein, the reading out the stored original algorithm management table data from the one-time programmable storage space, and recovering the original algorithm management table data according to the read-out original algorithm management table data comprises:
loading the stored raw algorithm management table data from the one-time programmable memory space;
reading a temporary mark from a first fixed offset address in said one-time programmable memory space;
judging whether the read temporary mark is the mark of the loading table in the one-time programmable storage space, and reading the initial address and the data length of the associated original algorithm management table data in the one-time programmable storage space from the address corresponding to the temporary mark when the read temporary mark is judged to be the mark of the loading table in the one-time programmable storage space;
reading original algorithm management table data related to the starting address and the data length from the one-time programmable storage space according to the read starting address and the read data length;
until all the original algorithm management table data pointed by the fixed offset addresses in the one-time programmable storage space are read out, and the original algorithm management table data are recovered according to the read-out original algorithm management table data.
Wherein, when the loading of the normal loading operation code or the algorithm management table data fails, the method further comprises the following steps of reading the stored operation code data from the one-time programmable storage space, recovering the operation code data according to the read operation code data, reading the stored original algorithm management table data from the one-time programmable storage space, recovering the original algorithm management table data according to the read original algorithm management table data, and recovering the original algorithm management table data, and the method further comprises the following steps:
and jumping the boot load to the restored running code data for execution, and enabling the USB flash disk to be successfully loaded.
According to another aspect of the present invention, there is provided an apparatus for preventing data loss and system damage of a usb disk, comprising:
a memory and a restorer;
the memory is used for storing the operation code and the original algorithm management table data in the one-time programmable storage space;
the restorer is used for reading the stored running code data from the one-time programmable storage space and restoring the running code data according to the read running code data when the normal loading of the running codes or the algorithm management table data is failed, reading the stored original algorithm management table data from the one-time programmable storage space and restoring the original algorithm management table data according to the read original algorithm management table data.
Wherein, the restorer is specifically configured to:
loading the stored running code data from the one-time programmable memory space;
reading a temporary mark from a first fixed offset address in said one-time programmable memory space;
judging whether the read temporary mark is the mark of a loading table in the one-time programmable storage space, and reading the initial address and the data length of the associated running code in the one-time programmable storage space from the address corresponding to the temporary mark when the read temporary mark is judged to be the mark of the loading table in the one-time programmable storage space;
reading out running code data related to the starting address and the data length from the one-time programmable storage space according to the read starting address and the read data length;
until all the run code data pointed by the fixed offset address in the one-time programmable storage space are read out, and the run code data are recovered according to the read run code data.
Wherein, the restorer is specifically configured to:
loading the stored raw algorithm management table data from the one-time programmable memory space;
reading a temporary mark from a first fixed offset address in said one-time programmable memory space;
judging whether the read temporary mark is the mark of the loading table in the one-time programmable storage space, and reading the initial address and the data length of the associated original algorithm management table data in the one-time programmable storage space from the address corresponding to the temporary mark when the read temporary mark is judged to be the mark of the loading table in the one-time programmable storage space;
reading original algorithm management table data related to the starting address and the data length from the one-time programmable storage space according to the read starting address and the read data length;
until all the original algorithm management table data pointed by the fixed offset addresses in the one-time programmable storage space are read out, and the original algorithm management table data are recovered according to the read-out original algorithm management table data.
The device for preventing the data loss and the system damage of the USB flash disk further comprises:
and the executor is used for jumping the boot load to the recovered running code data for execution so as to ensure that the USB flash disk is successfully loaded.
According to still another aspect of the present invention, there is provided an apparatus for preventing data loss and system damage of a usb disk, including:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform any of the above methods of preventing USB flash disk data loss and system corruption.
According to still another aspect of the present invention, there is provided a computer readable storage medium storing a computer program, which when executed by a processor implements the method for preventing data loss and system damage of a usb disk according to any of the above.
It can be found that, in the above scheme, the one-time programmable OTP memory space can be added in the main control chip of the usb disk, and run code and raw algorithm management table data may be stored in the OTP memory space, and when the Boot Loader fails to load the running code or the algorithm management table data normally, reading out the stored running code data from the one-time programmable OTP memory space, and according to the read operation code data recovering operation code data and reading out the stored original algorithm management table data from the one-time programmable OTP memory space, and according to the read original algorithm management table data, the original algorithm management table data is restored, and the situations that the original data of a user is lost or a U disk system is damaged and cannot run and the like of the U disk can be prevented.
Further, the above scheme may load the stored operation Code data from the OTP storage space, read a temporary flag TempFlag from the first fixed offset address in the OTP storage space, and determine whether the read temporary flag is equal to a flag tableflag of a loaded table in the OTP storage space, read a start address Code _ Add and a data length Code _ Len of the associated operation Code in the OTP storage space from an address corresponding to the temporary flag TempFlag when it is determined that the read temporary flag is equal to the flag tableflag of the loaded table in the OTP storage space, and read operation Code data associating the start address Code _ Add and the data length Code _ Len from the OTP storage space according to the read start address Code _ Add and data length Code _ Len, and until all the operation code data pointed by the fixed offset address in the one-time programmable storage space are read out, and the operation code data are recovered according to the read operation code data, so that the advantage of preventing the U disk from the situations of user original data loss or the U disk system damage and incapability of running and the like by a mode of recovering the operation code data is realized.
Further, the above scheme may load the stored original algorithm management table data from the OTP storage space, read a temporary flag TempFlag from the first fixed offset address in the OTP storage space, and determine whether the read temporary flag is equal to the flag tableflag of the loaded table in the OTP storage space, upon determining that the read temporary flag is equal to the flag tableflag of the loaded table in the OTP storage space, read the associated original algorithm management table data from the address corresponding to the temporary flag TempFlag at the start address TableData _ Add and the data length TableData _ Len in the OTP storage space, and read the original algorithm management table data associated with the start address TableData _ Add and the data length TableData _ Len from the OTP storage space according to the read start address TableData _ Add and the data length TableData _ Len, and until all original algorithm management table data pointed by the fixed offset addresses in the one-time programmable storage space are read out, and the original algorithm management table data are recovered according to the read original algorithm management table data, so that the advantage that the situations that the original data of a user are lost or a U disk system is damaged and cannot run and the like of the U disk are prevented by recovering the original algorithm management table data is realized.
Furthermore, the above scheme can make the Boot Loader jump to the recovered running code data for execution, and make the usb disk drive successfully, so that the advantage is that when the Boot Loader normally loads the running code or the algorithm management table data fails, the Boot Loader can jump to the recovered running code data for execution, and the usb disk drive succeeds, and can realize that the usb disk can recover to a normal use state, and ensure the service life of the usb disk.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flow chart illustrating an embodiment of a method for preventing USB flash disk data loss and system corruption according to the present invention;
FIG. 2 is a schematic diagram illustrating an example of a OTP memory space in an embodiment of the method for preventing data loss and system damage of a USB flash disk according to the present invention;
FIG. 3 is a diagram of another exemplary OTP memory space in an embodiment of the method for preventing data loss and system damage of a USB flash drive according to the invention;
FIG. 4 is a schematic diagram of an embodiment of a one-time programmable OTP memory according to the method for preventing data loss and system damage of a USB flash disk;
FIG. 5 is a flow chart illustrating another embodiment of the method for preventing USB flash disk data loss and system corruption according to the present invention;
FIG. 6 is a schematic structural diagram of an embodiment of an apparatus for preventing USB flash disk data loss and system damage according to the present invention;
FIG. 7 is a schematic structural diagram of another embodiment of the apparatus for preventing USB flash disk data loss and system damage according to the present invention;
fig. 8 is a schematic structural diagram of a system for controlling installation authority of an application program according to another embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be noted that the following examples are only illustrative of the present invention, and do not limit the scope of the present invention. Similarly, the following examples are only some but not all examples of the present invention, and all other examples obtained by those skilled in the art without any inventive work are within the scope of the present invention.
The invention provides a method for preventing data loss and system damage of a USB flash disk, which can prevent the situations that the original data of a user is lost or the USB flash disk system is damaged and cannot run and the like of the USB flash disk.
Referring to fig. 1, fig. 1 is a schematic flowchart illustrating an embodiment of a method for preventing data loss and system corruption of a usb disk according to the present invention. It should be noted that the method of the present invention is not limited to the flow sequence shown in fig. 1 if the results are substantially the same. As shown in fig. 1, the method comprises the steps of:
s101: an OTP (One Time Programmable) storage space is added into a main control chip of the U disk.
S102: run code and raw algorithm management table data are stored in the OTP memory space.
S103: when the Boot Loader is guided to normally load the running code or the algorithm management table data fails, reading the stored running code data from the one-time programmable OTP storage space, recovering the running code data according to the read running code data, reading the stored original algorithm management table data from the one-time programmable OTP storage space, and recovering the original algorithm management table data according to the read original algorithm management table data.
Wherein, the reading the stored running code data from the OTP memory space and recovering the running code data according to the read running code data may include:
loading the stored running code data from the one-time programmable OTP memory space;
reading out a temporary marker TempFlag from a first fixed offset address in the one-time programmable storage space;
judging whether the read temporary marker TempFlag is equal to a marker (tableFlag) of a loading table in the one-time programmable OTP storage space, and reading a start address (Code _ Add) and a data length (Code _ Len) of an associated running Code in the one-time programmable OTP storage space from an address corresponding to the temporary marker TempFlag when judging that the read temporary marker TempFlag is equal to the marker tableFlag of the loading table in the one-time programmable OTP storage space;
reading out running Code data related to the starting address Code _ Add and the data length Code _ Len from the one-time programmable OTP storage space according to the read starting address Code _ Add and the read data length Code _ Len;
the method has the advantages that the method can prevent the U disk from the situations that the original data of a user is lost or the U disk system is damaged and cannot run and the like by a mode of recovering the running code data.
The reading out the stored original algorithm management table data from the OTP memory space, and recovering the original algorithm management table data according to the read out original algorithm management table data may include:
loading the stored original algorithm management table data from the one-time programmable OTP memory space;
reading out a temporary marker TempFlag from a first fixed offset address in the one-time programmable storage space;
judging whether the read temporary marker TempFlag is equal to a marker TableFlag of a loading table in the one-time programmable OTP storage space, and reading a starting address (TableData _ Add) and a data length (TableData _ Len) of the associated original algorithm management table data in the one-time programmable OTP storage space from an address corresponding to the temporary marker TempFlag when judging that the read temporary marker TempFlag is equal to the marker TableFlag of the loading table in the one-time programmable OTP storage space;
reading original algorithm management table data related to the starting address TableData _ Add and the data length TableData _ Len from the one-time programmable OTP storage space according to the read starting address TableData _ Add and the read data length TableData _ Len;
until all the original algorithm management table data pointed by the fixed offset addresses in the one-time programmable storage space are read out, and the original algorithm management table data are restored according to the read original algorithm management table data, the advantage is that the situations that the original data of a user are lost or a U disk system is damaged and cannot run and the like can be prevented from occurring in the U disk in a mode of restoring the original algorithm management table data.
When the booting load Loader normally loads the running code or the algorithm management table data fails, reading the stored running code data from the OTP memory space, recovering the running code data according to the read running code data, reading the stored original algorithm management table data from the OTP memory space, managing the table data according to the read original algorithm, and recovering the original algorithm management table data, the method may further include:
the method has the advantages that the Boot Loader can be skipped to the recovered running code data to be executed when the Boot Loader normally loads the running codes or the algorithm management table data fails, the Boot Loader can be skipped to the recovered running code data to be executed, the USB flash disk can be successfully loaded, the USB flash disk can be recovered to a normal use state, and the service life of the USB flash disk is guaranteed.
In this embodiment, since the OTP added to the main control chip needs to consider the chip area, the OTP with 1bit data bus and 16KB total capacity can be preferably selected, and the invention is not limited with respect to the selection of the OTP type.
In the embodiment, since the 1-bit data bus is used, the reading speed is slow, and when the OTP data is loaded, the 16KB OTP data is not read out completely, but the corresponding data is loaded according to the range given by the OTP loading table.
In this embodiment, the OTP loading table format can be as follows:
Figure BDA0002054262420000081
Figure BDA0002054262420000091
note that TableFlg indicates a flag of the OTP load table. The OTP load table may be deposited at an address that is 1KB aligned with the OTP address. The Boot Loader code can judge whether a valid OTP loading table exists by reading the length of 4 bytes at all 1KB aligned addresses of the OTP, and if the correct tableFlg is read, the whole OTP loading table is continuously read.
It should be noted that, in the OTP load table, Code _ Add and Code _ Len respectively represent a start address and a data length of the running Code in the OTP. It should be noted that, in the OTP loading table, TableData _ Add and TableData _ Len respectively represent a start address and a data length of the original algorithm management table in the OTP.
In this embodiment, since each bit of the OTP can only be programmed once, and the backup data in the OTP, such as the running code and the original algorithm management table data, may be updated, in this embodiment, the running code in the backup data or the original algorithm management table data may be updated by updating the OTP loading table.
It should be noted that one piece of OTP backup data may be composed of three parts, namely, an OTP loading TABLE (OTP _ TABLE), a running Code (Code), and original algorithm management TABLE data (TableData).
In this embodiment, by using this OTP storage method, the run code and the original algorithm management table data can be updated many times in the OTP space of 16KB, and the run code and the original algorithm management table data can be updated many times in the OTP.
In this embodiment, the running code and the original algorithm management table data can be updated in the OTP space for multiple times in an OTP loading table manner, and multiple updates of the running code and the original algorithm management table data in the OTP can be realized.
It can be seen that, in this embodiment, a one-time programmable OTP memory space can be added to the main control chip of the usb disk, and run code and raw algorithm management table data may be stored in the OTP memory space, and when the Boot Loader fails to load the running code or the algorithm management table data normally, reading out the stored running code data from the one-time programmable OTP memory space, and according to the read operation code data recovering operation code data and reading out the stored original algorithm management table data from the one-time programmable OTP memory space, and according to the read original algorithm management table data, the original algorithm management table data is restored, and the situations that the original data of a user is lost or a U disk system is damaged and cannot run and the like of the U disk can be prevented.
Further, in this embodiment, the stored operation Code data may be loaded from the OTP storage space, a temporary flag TempFlag may be read from a first fixed offset address in the OTP storage space, and whether the read temporary flag is equal to a flag tableflag of a loaded table in the OTP storage space, a start address Code _ Add and a data length Code _ Len of the associated operation Code in the OTP storage space may be read from an address corresponding to the temporary flag TempFlag upon determining that the read temporary flag is equal to the flag tableflag of the loaded table in the OTP storage space, and operation Code data associated with the start address Code _ Add and the data length Code _ Len may be read from the OTP storage space according to the read start address Code _ Add and the data length Code _ Len, and until all the operation code data pointed by the fixed offset address in the one-time programmable storage space are read out, and the operation code data are recovered according to the read operation code data, so that the advantage of preventing the U disk from the situations of user original data loss or the U disk system damage and incapability of running and the like by a mode of recovering the operation code data is realized.
Further, in this embodiment, the stored original algorithm management table data may be loaded from the OTP storage space, the temporary flag is read from the first fixed offset address in the OTP storage space, and whether the read temporary flag is equal to the flag tableflag of the loaded table in the OTP storage space is judged, when the read temporary flag is judged to be equal to the flag tableflag of the loaded table in the OTP storage space, the associated original algorithm management table data is read from the address corresponding to the temporary flag TempFlag, the start address TableData _ Add and the data length TableData _ Len in the OTP storage space, and the original algorithm management table data associated with the start address TableData _ Add and the data length TableData _ Len is read from the OTP storage space according to the read start address TableData _ Add and the data length TableData _ Len According to the method, original algorithm management table data pointed by all fixed offset addresses in the one-time programmable storage space are read out, and the original algorithm management table data are restored according to the read original algorithm management table data, so that the advantage that the U disk can be prevented from the situations that original data of a user are lost or the U disk system is damaged and cannot run and the like in a mode of restoring the original algorithm management table data is achieved.
The present embodiment is illustrated below:
referring to fig. 2, fig. 2 is a schematic diagram illustrating an OTP memory space with one time programmable function according to an embodiment of the method for preventing data loss and system damage of the usb disk. As shown in fig. 2, OTP _ TABLE (1, 1) indicates that OTP _ TABLE points to Code (1) and TableData (1).
Referring to fig. 3, fig. 3 is another exemplary diagram of the OTP memory space in an embodiment of the method for preventing data loss and system damage of the usb disk according to the present invention. As shown in fig. 3, assuming that the currently running Code (1) needs to be updated to Code (2), a new OTP _ TABLE (2, 1) can be written in the OTP, where OTP _ TABLE (2, 1) can only be written at the 1KB aligned address in the OTP, here nKB address.
Referring to fig. 4, fig. 4 is a schematic diagram of another exemplary OTP memory space in an embodiment of the method for preventing data loss and system damage of the usb disk according to the present invention. As shown in fig. 4, assuming that the current original algorithm management TABLE data TableData (1) needs to be updated to TableData (2), a new OTP _ TABLE (1, 2) can be written in the OTP, wherein OTP _ TABLE (1, 2) can only be written at 1KB aligned address in the OTP, here nKB address.
Referring to fig. 5, fig. 5 is a flowchart illustrating another embodiment of the method for preventing data loss and system damage of the usb disk according to the present invention. In this embodiment, the method includes the steps of:
s501: and adding a one-time programmable OTP memory space in a main control chip of the USB flash disk.
S502: run code and raw algorithm management table data are stored in the OTP memory space.
S503: when the Boot Loader is guided to normally load the running code or the algorithm management table data fails, reading the stored running code data from the one-time programmable OTP storage space, recovering the running code data according to the read running code data, reading the stored original algorithm management table data from the one-time programmable OTP storage space, and recovering the original algorithm management table data according to the read original algorithm management table data.
As described above in S103, which is not described herein.
S504: and jumping the Boot Loader to the recovered running code data for execution, and successfully uploading the USB flash disk.
It can be found that, in this embodiment, the Boot Loader can be skipped to the recovered running code data for execution, and the usb disk can be loaded successfully, which has the advantages that when the Boot Loader normally loads the running code or the algorithm management table data fails, the Boot Loader can be skipped to the recovered running code data for execution, so that the usb disk can be loaded successfully, and the usb disk can be recovered to a normal use state, thereby ensuring the service life of the usb disk.
The invention also provides a device for preventing the data loss and the system damage of the USB flash disk, which can prevent the original data loss of a user or the damage of the USB flash disk system, the incapability of running and the like of the USB flash disk.
Referring to fig. 6, fig. 6 is a schematic structural diagram of an embodiment of an apparatus for preventing data loss and system damage of a usb disk according to the present invention. In this embodiment, the apparatus 60 for preventing data loss and system damage of the usb disk includes a memory 61 and a restorer 62.
The memory 61 is used for storing the operation code and the original algorithm management table data in the one-time programmable OTP memory space.
The recoverer 62 is configured to, when the Boot Loader is booted and loaded and normal loading of the running code or failure of the algorithm management table data occurs, read the stored running code data from the OTP memory space, recover the running code data according to the read running code data, read the stored original algorithm management table data from the OTP memory space, and recover the original algorithm management table data according to the read original algorithm management table data.
Optionally, the restorer 62 may be specifically configured to:
loading the stored running code data from the one-time programmable OTP memory space;
reading out a temporary marker TempFlag from a first fixed offset address in the one-time programmable storage space;
judging whether the read temporary marker TempFlag is equal to a marker TableFlag of a loading table in the one-time programmable OTP storage space or not, and reading a starting address Code _ Add and a data length Code _ Len of an associated running Code in the one-time programmable OTP storage space from an address corresponding to the temporary marker TempFlag when judging that the read temporary marker TempFlag is equal to the marker TableFlag of the loading table in the one-time programmable OTP storage space;
reading out running Code data related to the starting address Code _ Add and the data length Code _ Len from the one-time programmable OTP storage space according to the read starting address Code _ Add and the read data length Code _ Len;
until all the run code data pointed by the fixed offset address in the one-time programmable storage space are read out, and the run code data are recovered according to the read run code data.
Optionally, the restorer 62 may be specifically configured to:
loading the stored original algorithm management table data from the one-time programmable OTP memory space;
reading out a temporary marker TempFlag from a first fixed offset address in the one-time programmable storage space;
judging whether the read temporary marker TempFlag is equal to a marker TableFlag of a loading table in the one-time programmable OTP storage space, and reading a starting address TableData _ Add and a data length TableData _ Len of the associated original algorithm management table data in the one-time programmable OTP storage space from an address corresponding to the temporary marker TempFlag when judging that the read temporary marker TempFlag is equal to the marker TableFlag of the loading table in the one-time programmable OTP storage space;
reading original algorithm management table data related to the starting address TableData _ Add and the data length TableData _ Len from the one-time programmable OTP storage space according to the read starting address TableData _ Add and the read data length TableData _ Len;
until all the original algorithm management table data pointed by the fixed offset addresses in the one-time programmable storage space are read out, and the original algorithm management table data are recovered according to the read-out original algorithm management table data.
Referring to fig. 7, fig. 7 is a schematic structural diagram of another embodiment of the apparatus for preventing data loss and system damage of the usb disk according to the present invention. Unlike the previous embodiment, the apparatus 70 for preventing data loss and system damage of the usb disk according to this embodiment further includes: an actuator 71.
The executor 71 is configured to jump the Boot Loader to the recovered running code data for execution, so that the usb disk is successfully loaded.
The unit modules of the apparatus 60/70 for preventing data loss and system damage of a usb disk may respectively perform corresponding steps in the above method embodiments, and therefore, detailed descriptions of the unit modules are not repeated herein, for details, refer to the description of the corresponding steps above.
The present invention further provides an apparatus for preventing data loss and system damage of a usb disk, as shown in fig. 8, including: at least one processor 81; and a memory 82 communicatively coupled to the at least one processor 81; wherein the memory 82 stores instructions executable by the at least one processor 81, the instructions being executable by the at least one processor 81 to enable the at least one processor 81 to perform the above-described method for preventing data loss and system corruption of a usb disk.
Where the memory 82 and the processor 81 are coupled in a bus, the bus may comprise any number of interconnected buses and bridges that couple one or more of the various circuits of the processor 81 and the memory 82 together. The bus may also connect various other circuits such as peripherals, voltage regulators, power management circuits, and the like, which are well known in the art, and therefore, will not be described any further herein. A bus interface provides an interface between the bus and the transceiver. The transceiver may be one element or a plurality of elements, such as a plurality of receivers and transmitters, providing a means for communicating with various other apparatus over a transmission medium. The data processed by the processor 81 is transmitted over a wireless medium through an antenna, which further receives the data and passes the data to the processor 81.
The processor 81 is responsible for managing the bus and general processing and may also provide various functions including timing, peripheral interfaces, voltage regulation, power management, and other control functions. And memory 82 may be used to store data used by processor 81 in performing operations.
The present invention further provides a computer-readable storage medium storing a computer program. The computer program realizes the above-described method embodiments when executed by a processor.
It can be found that, in the above scheme, the one-time programmable OTP memory space can be added in the main control chip of the usb disk, and run code and raw algorithm management table data may be stored in the OTP memory space, and when the Boot Loader fails to load the running code or the algorithm management table data normally, reading out the stored running code data from the one-time programmable OTP memory space, and according to the read operation code data recovering operation code data and reading out the stored original algorithm management table data from the one-time programmable OTP memory space, and according to the read original algorithm management table data, the original algorithm management table data is restored, and the situations that the original data of a user is lost or a U disk system is damaged and cannot run and the like of the U disk can be prevented.
Further, the above scheme may load the stored operation Code data from the OTP storage space, read a temporary flag TempFlag from the first fixed offset address in the OTP storage space, and determine whether the read temporary flag is equal to a flag tableflag of a loaded table in the OTP storage space, read a start address Code _ Add and a data length Code _ Len of the associated operation Code in the OTP storage space from an address corresponding to the temporary flag TempFlag when it is determined that the read temporary flag is equal to the flag tableflag of the loaded table in the OTP storage space, and read operation Code data associating the start address Code _ Add and the data length Code _ Len from the OTP storage space according to the read start address Code _ Add and data length Code _ Len, and until all the operation code data pointed by the fixed offset address in the one-time programmable storage space are read out, and the operation code data are recovered according to the read operation code data, so that the advantage of preventing the U disk from the situations of user original data loss or the U disk system damage and incapability of running and the like by a mode of recovering the operation code data is realized.
Further, the above scheme may load the stored original algorithm management table data from the OTP storage space, read a temporary flag TempFlag from the first fixed offset address in the OTP storage space, and determine whether the read temporary flag is equal to the flag tableflag of the loaded table in the OTP storage space, upon determining that the read temporary flag is equal to the flag tableflag of the loaded table in the OTP storage space, read the associated original algorithm management table data from the address corresponding to the temporary flag TempFlag at the start address TableData _ Add and the data length TableData _ Len in the OTP storage space, and read the original algorithm management table data associated with the start address TableData _ Add and the data length TableData _ Len from the OTP storage space according to the read start address TableData _ Add and the data length TableData _ Len, and until all original algorithm management table data pointed by the fixed offset addresses in the one-time programmable storage space are read out, and the original algorithm management table data are recovered according to the read original algorithm management table data, so that the advantage that the situations that the original data of a user are lost or a U disk system is damaged and cannot run and the like of the U disk are prevented by recovering the original algorithm management table data is realized.
Furthermore, the above scheme can make the Boot Loader jump to the recovered running code data for execution, and make the usb disk drive successfully, so that the advantage is that when the Boot Loader normally loads the running code or the algorithm management table data fails, the Boot Loader can jump to the recovered running code data for execution, and the usb disk drive succeeds, and can realize that the usb disk can recover to a normal use state, and ensure the service life of the usb disk.
In the several embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a module or a unit is merely a logical division, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be substantially or partially implemented in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, a network device, or the like) or a processor (processor) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above description is only a part of the embodiments of the present invention, and not intended to limit the scope of the present invention, and all equivalent devices or equivalent processes performed by the present invention through the contents of the specification and the drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (8)

1. A method for preventing data loss and system damage of a USB flash disk is characterized by comprising the following steps:
adding a one-time programmable storage space into a main control chip of the U disk;
storing run code and raw algorithm management table data in the one-time programmable memory space;
when the loading of normal loading operation codes or the failure of algorithm management table data is guided, reading the stored operation code data from the one-time programmable storage space, recovering the operation code data according to the read operation code data, reading the stored original algorithm management table data from the one-time programmable storage space, and recovering the original algorithm management table data according to the read original algorithm management table data;
the reading out the stored running code data from the one-time programmable storage space and recovering the running code data according to the read out running code data includes:
loading the stored running code data from the one-time programmable memory space;
reading a temporary mark from a first fixed offset address in said one-time programmable memory space;
judging whether the read temporary mark is the mark of a loading table in the one-time programmable storage space, and reading the initial address and the data length of the associated running code in the one-time programmable storage space from the address corresponding to the temporary mark when the read temporary mark is judged to be the mark of the loading table in the one-time programmable storage space;
reading out running code data related to the starting address and the data length from the one-time programmable storage space according to the read starting address and the read data length;
until all the run code data pointed by the fixed offset address in the one-time programmable storage space are read out, and the run code data are recovered according to the read run code data.
2. The method for preventing data loss and system damage of a USB flash drive as claimed in claim 1, wherein said reading out the stored original algorithm management table data from the one-time programmable memory space and recovering the original algorithm management table data according to the read out original algorithm management table data comprises:
loading the stored raw algorithm management table data from the one-time programmable memory space;
reading a temporary mark from a first fixed offset address in said one-time programmable memory space;
judging whether the read temporary mark is the mark of the loading table in the one-time programmable storage space, and reading the initial address and the data length of the associated original algorithm management table data in the one-time programmable storage space from the address corresponding to the temporary mark when the read temporary mark is judged to be the mark of the loading table in the one-time programmable storage space;
reading original algorithm management table data related to the starting address and the data length from the one-time programmable storage space according to the read starting address and the read data length;
until all the original algorithm management table data pointed by the fixed offset addresses in the one-time programmable storage space are read out, and the original algorithm management table data are recovered according to the read-out original algorithm management table data.
3. The method for preventing data loss and system damage of a USB flash drive as claimed in claim 1, wherein after the step of reading out the stored operation code data from the one-time programmable memory space and recovering the operation code data according to the read out operation code data and the step of reading out the stored original algorithm management table data from the one-time programmable memory space and recovering the original algorithm management table data according to the read out original algorithm management table data when the step of loading normal operation code or algorithm management table data fails, the method further comprises:
and jumping the boot load to the restored running code data for execution, and enabling the USB flash disk to be successfully loaded.
4. An apparatus for preventing data loss and system damage of a USB flash disk, comprising:
a memory and a restorer;
the memory is used for storing the operation codes and the original algorithm management table data in the one-time programmable storage space;
the restorer is used for reading the stored running code data from the one-time programmable storage space and restoring the running code data according to the read running code data when the normal loading of the running codes or the algorithm management table data is guided to be loaded and failed, reading the stored original algorithm management table data from the one-time programmable storage space and restoring the original algorithm management table data according to the read original algorithm management table data;
the restorer is specifically configured to:
loading the stored running code data from the one-time programmable memory space;
reading a temporary mark from a first fixed offset address in said one-time programmable memory space;
judging whether the read temporary mark is the mark of a loading table in the one-time programmable storage space, and reading the initial address and the data length of the associated running code in the one-time programmable storage space from the address corresponding to the temporary mark when the read temporary mark is judged to be the mark of the loading table in the one-time programmable storage space;
reading out running code data related to the starting address and the data length from the one-time programmable storage space according to the read starting address and the read data length;
until all the run code data pointed by the fixed offset address in the one-time programmable storage space are read out, and the run code data are recovered according to the read run code data.
5. The apparatus for preventing data loss and system corruption of a usb disk according to claim 4, wherein said restorer is specifically configured to:
loading the stored raw algorithm management table data from the one-time programmable memory space;
reading a temporary mark from a first fixed offset address in said one-time programmable memory space;
judging whether the read temporary mark is the mark of the loading table in the one-time programmable storage space, and reading the initial address and the data length of the associated original algorithm management table data in the one-time programmable storage space from the address corresponding to the temporary mark when the read temporary mark is judged to be the mark of the loading table in the one-time programmable storage space;
reading original algorithm management table data related to the starting address and the data length from the one-time programmable storage space according to the read starting address and the read data length;
until all the original algorithm management table data pointed by the fixed offset addresses in the one-time programmable storage space are read out, and the original algorithm management table data are recovered according to the read-out original algorithm management table data.
6. The apparatus for preventing data loss and system damage of a USB flash disk according to claim 4, wherein said apparatus for preventing data loss and system damage of a USB flash disk further comprises:
and the executor is used for jumping the boot load to the recovered running code data for execution so as to ensure that the USB flash disk is successfully loaded.
7. An apparatus for preventing data loss and system damage to a USB flash disk, comprising:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of preventing USB flash disk data loss and system corruption of any one of claims 1 to 3.
8. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the method for preventing data loss and system damage of a usb disk according to any one of claims 1 to 3.
CN201910384136.XA 2019-05-09 2019-05-09 Method, device and equipment for preventing USB flash disk data loss and system damage Active CN110333967B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910384136.XA CN110333967B (en) 2019-05-09 2019-05-09 Method, device and equipment for preventing USB flash disk data loss and system damage

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910384136.XA CN110333967B (en) 2019-05-09 2019-05-09 Method, device and equipment for preventing USB flash disk data loss and system damage

Publications (2)

Publication Number Publication Date
CN110333967A CN110333967A (en) 2019-10-15
CN110333967B true CN110333967B (en) 2022-04-19

Family

ID=68139720

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910384136.XA Active CN110333967B (en) 2019-05-09 2019-05-09 Method, device and equipment for preventing USB flash disk data loss and system damage

Country Status (1)

Country Link
CN (1) CN110333967B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101751981A (en) * 2008-12-12 2010-06-23 苏州亮智科技有限公司 Method for protecting the safety of storing data in flash memory storing device
CN104424008A (en) * 2013-08-30 2015-03-18 飞思卡尔半导体公司 System and method for secure boot ROM patch

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120331303A1 (en) * 2011-06-23 2012-12-27 Andersson Jonathan E Method and system for preventing execution of malware

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101751981A (en) * 2008-12-12 2010-06-23 苏州亮智科技有限公司 Method for protecting the safety of storing data in flash memory storing device
CN104424008A (en) * 2013-08-30 2015-03-18 飞思卡尔半导体公司 System and method for secure boot ROM patch

Also Published As

Publication number Publication date
CN110333967A (en) 2019-10-15

Similar Documents

Publication Publication Date Title
US20070055969A1 (en) System and method for updating firmware
US9507604B2 (en) Boot method and boot system
EP2846261B1 (en) Method and apparatus for starting a boot program
CN109032632B (en) FOTA upgrading method, wireless communication terminal and storage medium
US8812910B2 (en) Pilot process method for system boot and associated apparatus
US20090094450A1 (en) Firmware image update and management
US20140365823A1 (en) Information processing device, information processing method, and computer program
US20180322013A1 (en) Method for recovering basic input/output system image file of a computer system and the computer system
CN102334100A (en) Program update device, program update method, and information processing device
CN103299276A (en) Software updating process for an embedded device
CN104915226A (en) Network device software starting method, device and network device
CN108958643B (en) Data storage device and operation method thereof
CN104077167A (en) Boot loading method and device based on NAND FLASH
CN110597533A (en) FPGA board card program updating system and method
CN107566169A (en) A kind of firmware upgrade method and router based on openwrt
CN104081376A (en) Maintaining system firmware images remotely using a distribute file system protocol
CN110333967B (en) Method, device and equipment for preventing USB flash disk data loss and system damage
CN112860291A (en) Firmware upgrading method and device
CN104765631A (en) Restoration method and device for application program of mobile terminal
CN108874318B (en) Data recovery method of solid state disk and solid state disk
CN107422987B (en) Method and device for storing data in nonvolatile memory
CN110908722A (en) Method and device applied to starting of operating system, electronic equipment and storage medium
CN106104474B (en) Method for updating firmware on low memory devices
WO2020223950A1 (en) Method, apparatus and device for preventing data loss and system damage of usb flash disk
CN112860595A (en) PCI (peripheral component interconnect express) equipment or PCIE (peripheral component interconnect express) equipment, data access method and related assembly

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 518000 Intelligence Valley Innovation Park 701, 707, No. 1010 Bulong Road, Xinniu Community, Minzhi Street, Longhua District, Shenzhen City, Guangdong Province

Applicant after: Shenzhen deminli Technology Co., Ltd

Address before: 518000 Intelligence Valley Innovation Park 701, 707, No. 1010 Bulong Road, Xinniu Community, Minzhi Street, Longhua District, Shenzhen City, Guangdong Province

Applicant before: SHENZHEN DEMINGLI ELECTRONICS Co.,Ltd.

CB02 Change of applicant information
CB02 Change of applicant information

Address after: 2501, 2401, block a, building 1, Shenzhen new generation industrial park, 136 Zhongkang Road, Meidu community, Meilin street, Futian District, Shenzhen, Guangdong 518000

Applicant after: Shenzhen deminli Technology Co.,Ltd.

Address before: 701, 707, wisdom Valley Innovation Park, 1010 Bulong Road, Xinniu community, Minzhi street, Longhua District, Shenzhen, Guangdong 518000

Applicant before: Shenzhen deminli Technology Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant