Detailed Description
The following description and the drawings sufficiently illustrate specific embodiments of the invention to enable those skilled in the art to practice them.
It should be understood that the described embodiments are only some embodiments of the invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the invention, as detailed in the appended claims.
In the description of the present invention, it is to be understood that the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. The specific meanings of the above terms in the present invention can be understood in specific cases to those skilled in the art. In addition, in the description of the present invention, "a plurality" means two or more unless otherwise specified. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
So far, the ECU has no memory backup, when the upper computer or the brushing tool carries out data brushing on the ECU, when the data brushing is unsuccessful, the ECU is brushed, and the probability of data loss is increased. Therefore, the present application provides a memory backup method, device, storage medium and electronic device for preventing an ECU from being swiped up, so as to solve the problems existing in the related art. In the technical scheme provided by the application, as the partition with the same size is added in advance to the lower limit variable storage area which is frequently subjected to data flashing for carrying out data backup on the lower limit variable storage area, under the condition of unsuccessful flashing, the data in the backup area can be copied into the lower limit variable storage area based on the calculated checksum.
The memory backup method for preventing the ECU from being swiped up according to the embodiment of the present application will be described in detail below with reference to fig. 1 to 4.
Referring to fig. 1, a schematic flow chart of a memory backup method for preventing an ECU from being swiped up is provided in an embodiment of the present application. As shown in fig. 1, the method of the embodiment of the present application may include the steps of:
s101, acquiring a preset first checksum;
and the checksum is obtained by calculating the data of the storage area according to a checksum algorithm. The data of the storage area is data stored in, for example, EOL (offline variable storage area) and the data stored in the area needs to be changed frequently. The EOL is a data storage area in an EMS (Engine Management System), the EMS is an application program area of an ECU (electronic control Unit), and represents a program required by the ECU to control the normal operation of an engine, and an internal area of the ECU is divided into two large areas, namely a Bootloader and an EMS area, wherein the Bootloader is a bootstrap loader for updating the EMS area by a user.
Generally, before calculating a checksum, data backup is performed on partitions with the same size added to an EOL area (a lower limit variable storage area), the added backup partitions are referred to as backup partitions, then an algorithm for calculating a checksum is set, the checksum algorithm can be set by itself, and is not limited herein.
In the embodiment of the application, a user uses an upper computer (INCA or a flash tool) to change data in an EOL area and then generate changed data, the upper computer needs to recalculate a checksum on the changed data according to a preset checksum algorithm, after the checksum calculation is completed, the upper computer finally writes the changed data and a new checksum into the EOL area for storage, and at this time, the new checksum is regarded as a first checksum. After the upper computer is refreshed, the ECU is electrified again to enter the Bootloader, and the ECU firstly obtains a first check sum.
S102, acquiring a second checksum corresponding to a preset backup area;
and the second checksum is a checksum corresponding to the backup data in the backup area.
In the embodiment of the present application, after the user uses the upper computer to modify the data of the EOL area, it needs to determine whether the checksum of the EOL area is correct, and in the determination process, the ECU first obtains the first checksum, that is, the checksum corresponding to the modified data stored in the EOL area, based on step S101. And then, a checksum corresponding to the backup data stored in the backup area is obtained.
S103, when the first checksum and the second checksum are inconsistent, judging whether the first checksum is correct or not to obtain a judgment result;
in a feasible implementation manner, the ECU firstly obtains the first checksum and the second checksum based on steps S101 and S102, and then compares the first checksum and the second checksum according to a value corresponding to the first checksum and a value corresponding to the second checksum, at this time, since the user uses the upper computer to change the EOL area data, a value of the first checksum stored in the EOL area and a value of the second checksum are definitely not equal, at this time, it is necessary to determine whether the first checksum stored in the EOL area is correct, and the ECU determines the first checksum according to a set determination program and generates a determination result.
And S104, finishing memory data backup based on the judgment result.
In a possible implementation manner, the result of the determination obtained based on step S103 may be that the first checksum is correct, and the first checksum error may also occur.
Optionally, when the first checksum determined by the ECU is correct, the ECU copies the data content after the EOL area change to the backup area, and the data is successfully written.
Optionally, when the first checksum determined by the ECU is incorrect, the ECU copies the data content in the backup area to the EOL area, and the data flush fails, which may effectively protect the data stored in the EOL area from being maliciously tampered.
In another possible implementation manner, when the user does not perform the flash change on the data of the EOL area, the data of the EOL area and the data of the backup area at this time are consistent, in this case, the ECU also needs to calculate a checksum on the data of the EOL area to determine whether the checksum is correct, and when the checksum is correct, it indicates that the data of the EOL area and the data of the backup area are consistent, and no operation is needed. When the judgment result is incorrect, the data is maliciously tampered, but the modifier does not know the checksum algorithm at this time, so that the checksum is not modified, and therefore whether the data is modified or not can be judged according to the checksum, and the data in the backup area needs to be copied to the EOL area at this time, so that the data maliciously tampered is effectively prevented.
And after the backup area is added, the ECU copies the data content of the backup area to the EOL area according to the judgment result of the checksum, so that the ECU can normally operate.
For example, as shown in fig. 2, when a user uses an upper computer to perform a flash change on data in an EOL area, a change instruction is generated and sent to the ECU, and after receiving the change instruction, the ECU first determines whether the checksum stored in the EOL area and the backup area are consistent.
And when the checksums are consistent, the ECU judges whether the checksum of the EOL area is correct or not, if the checksum is correct, the operation is not needed, if the checksum is wrong, the EOL area data is changed, and if the checksum is not changed, the content of the backup area needs to be copied to the EOL area.
And when the checksums are not consistent, the ECU judges whether the EOL area checksums are correct or not, if so, the EOL area data and the checksums are changed, and the EOL area data and the checksums are correct, the content of the EOL area needs to be copied to a backup area, and the flash is successful. If the judgment is wrong, the EOL area data and the checksum are changed, but the checksum is not correct, and the content of the backup area needs to be copied to the EOL area.
In the embodiment of the application, the vehicle computer firstly obtains a preset first checksum, then obtains a second checksum corresponding to the preset backup area, then judges whether the first checksum is correct or not when the first checksum is inconsistent with the second checksum to obtain a judgment result, and finally completes memory data backup based on the judgment result. According to the scheme, the partitions with the same size are added in advance to perform data backup on the lower limit variable storage area which is frequently subjected to data flashing, and under the condition that the flashing is unsuccessful, the data in the backup area can be copied into the lower limit variable storage area based on the calculated checksum.
Fig. 3 is a schematic flow chart of a memory backup method for preventing an ECU from being swiped up according to an embodiment of the present application. The present embodiment is exemplified by applying the image processing method to an electronic device. The memory backup method for preventing the ECU from being swiped up can comprise the following steps:
s201, when a data change instruction for the offline variable storage area is received, changing the data to generate changed data;
in a possible implementation manner, when a user uses an upper computer to perform data flashing, firstly, a command of the flashing is sent to the ECU, and when the ECU receives the data of the EOL area to be flashed, the data in the EOL area is modified according to the command of the flashing to generate modified data.
S202, calculating the modified data based on a preset checksum algorithm to generate a checksum corresponding to the modified data, and taking the checksum corresponding to the modified data as a first checksum;
in a possible implementation manner, based on the modified data obtained in step S201, when the data is modified, the ECU obtains a checksum calculation rule preset by the user, for example, adding an offset to a multiplication factor of data (four bytes) in a range except for the checksum in the EOL area and the backup area, and then accumulating, where the final sum is the checksum, or using a general CRC algorithm, and the like. The specific checksum algorithm may be determined according to actual situations, and is not limited herein. And after the modified data is calculated according to the checksum algorithm, generating a checksum corresponding to the modified data, wherein the modified data sum can be regarded as a first checksum.
S203, the changed data and the check sum are written into the offline variable storage area in a flashing mode to generate data and a first check sum in the offline variable storage area.
In the embodiment of the present application, based on the step S202, the checksum corresponding to the modified data may be obtained, and when the checksum corresponding to the modified data is obtained, the ECU saves the modified data and the checksum in the EOL area in a flash manner.
S204, acquiring a preset first checksum;
specifically, refer to step S101, which is not described herein again.
S205, acquiring a second checksum corresponding to the preset backup area;
specifically, refer to step S102, which is not described herein again.
S206, when the first checksum and the second checksum are not consistent, judging whether the first checksum is correct or not to obtain a judgment result;
specifically, refer to step S103, which is not described herein again.
And S207, when the first checksum is correct, copying the data in the offline variable storage area to the preset backup area.
Specifically, refer to step S104, which is not described herein again.
In the embodiment of the application, the vehicle computer firstly obtains a preset first checksum, then obtains a second checksum corresponding to the preset backup area, then judges whether the first checksum is correct or not when the first checksum is inconsistent with the second checksum to obtain a judgment result, and finally completes memory data backup based on the judgment result. According to the scheme, the partitions with the same size are added in advance to perform data backup on the lower limit variable storage area which is frequently subjected to data flashing, and under the condition that the flashing is unsuccessful, the data in the backup area can be copied into the lower limit variable storage area based on the calculated checksum.
Fig. 4 is a schematic flow chart of a memory backup method for preventing an ECU from being swiped up according to an embodiment of the present application. The present embodiment is exemplified by applying the image processing method to an electronic device. The memory backup method for preventing the ECU from being swiped up can comprise the following steps:
s301, when a data change instruction for the offline variable storage area is received, changing the data to generate changed data;
specifically, refer to step S201, which is not described herein again.
S302, calculating the modified data based on a preset checksum algorithm to generate a checksum corresponding to the modified data, and taking the checksum corresponding to the modified data as a first checksum;
specifically, refer to step S202, which is not described herein again.
And S303, flashing the changed data and the check sum to the offline variable storage area to generate the data and the first check sum in the offline variable storage area.
Specifically, refer to step S203, which is not described herein again.
S304, acquiring a preset first checksum;
specifically, refer to step S101, which is not described herein again.
S305, acquiring a second checksum corresponding to the preset backup area;
specifically, refer to step S102, which is not described herein again.
S306, when the first checksum and the second checksum are not consistent, judging whether the first checksum is correct or not to obtain a judgment result;
specifically, refer to step S103, which is not described herein again.
S307, when the first checksum is incorrect, copying the backup data of the preset backup area to the offline variable storage area.
Specifically, refer to step S104, which is not described herein again.
In the embodiment of the application, the vehicle computer firstly obtains a preset first checksum, then obtains a second checksum corresponding to the preset backup area, then judges whether the first checksum is correct or not when the first checksum is inconsistent with the second checksum to obtain a judgment result, and finally completes memory data backup based on the judgment result. According to the scheme, the partitions with the same size are added in advance to perform data backup on the lower limit variable storage area which is frequently subjected to data flashing, and under the condition that the flashing is unsuccessful, the data in the backup area can be copied into the lower limit variable storage area based on the calculated checksum.
The following are embodiments of the apparatus of the present invention that may be used to perform embodiments of the method of the present invention. For details which are not disclosed in the embodiments of the apparatus of the present invention, reference is made to the embodiments of the method of the present invention.
Referring to fig. 5, a schematic structural diagram of a memory backup device for preventing an ECU from being swiped up according to an exemplary embodiment of the present invention is shown. The memory backup device for preventing the ECU from being swiped can be realized by software, hardware or a combination of the software and the hardware to be all or part of equipment. The device 1 comprises a first checksum obtaining module 10, a second checksum obtaining module 20, a result obtaining module 30 and a backup completing module 40.
A first checksum obtaining module 10, configured to obtain a preset first checksum;
the second checksum obtaining module 20 is configured to obtain a second checksum corresponding to the preset backup area;
a result obtaining module 30, configured to, when the first checksum is inconsistent with the second checksum, determine whether the first checksum is correct, and obtain a determination result;
and a backup completion module 40, configured to complete memory data backup based on the determination result.
Optionally, as shown in fig. 6, the memory backup device 1 for preventing the ECU from being swiped up further includes:
the data modification module 50 is configured to modify the data to generate modified data when a data modification instruction for the offline variable storage area is received;
a checksum generating module 60, configured to calculate the modified data based on a preset checksum algorithm to generate a checksum corresponding to the modified data, and use the checksum corresponding to the modified data as a first checksum;
a data saving module 70, configured to flush the modified data and the checksum to the offline variable storage area.
It should be noted that, when the memory backup method for preventing the ECU from being swiped up is used for the memory backup device for preventing the ECU from being swiped up, the division of the functional modules is merely used for illustration, and in practical applications, the function distribution may be completed by different functional modules according to needs, that is, the internal structure of the device may be divided into different functional modules to complete all or part of the functions described above. In addition, the memory backup device for preventing the ECU from being swiped up and the memory backup method embodiment for preventing the ECU from being swiped up provided by the above embodiments belong to the same concept, and the detailed implementation process is shown in the method embodiment and will not be described herein again.
The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments.
In the embodiment of the application, the vehicle computer firstly obtains a preset first checksum, then obtains a second checksum corresponding to the preset backup area, then judges whether the first checksum is correct or not when the first checksum is inconsistent with the second checksum to obtain a judgment result, and finally completes memory data backup based on the judgment result. According to the scheme, the partitions with the same size are added in advance to perform data backup on the lower limit variable storage area which is frequently subjected to data flashing, and under the condition that the flashing is unsuccessful, the data in the backup area can be copied into the lower limit variable storage area based on the calculated checksum.
The present invention also provides a computer readable medium, on which program instructions are stored, which when executed by a processor implement the memory backup method for preventing ECU from being swiped up, provided by the above-mentioned method embodiments.
The present invention also provides a computer program product containing instructions, which when run on a computer, causes the computer to execute the memory backup method for preventing ECU from being swiped.
Fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure. As shown in fig. 7, the electronic device 1000 may include: at least one processor 1001, at least one network interface 1004, a user interface 1003, memory 1005, at least one communication bus 1002.
Wherein a communication bus 1002 is used to enable connective communication between these components.
The user interface 1003 may include a Display screen (Display) and a Camera (Camera), and the optional user interface 1003 may also include a standard wired interface and a wireless interface.
The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface), among others.
Processor 1001 may include one or more processing cores, among other things. The processor 1001 interfaces various components throughout the electronic device 1000 using various interfaces and lines to perform various functions of the electronic device 1000 and to process data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory 1005 and invoking data stored in the memory 1005. Alternatively, the processor 1001 may be implemented in at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). The processor 1001 may integrate one or more of a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), a modem, and the like. Wherein, the CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for rendering and drawing the content required to be displayed by the display screen; the modem is used to handle wireless communications. It is understood that the modem may not be integrated into the processor 1001, but may be implemented by a single chip.
The Memory 1005 may include a Random Access Memory (RAM) or a Read-Only Memory (Read-Only Memory). Optionally, the memory 1005 includes a non-transitory computer-readable medium. The memory 1005 may be used to store an instruction, a program, code, a set of codes, or a set of instructions. The memory 1005 may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the various method embodiments described above, and the like; the storage data area may store data and the like referred to in the above respective method embodiments. The memory 1005 may optionally be at least one memory device located remotely from the processor 1001. As shown in fig. 7, a memory 1005, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a memory backup application program for preventing an ECU from being swiped.
In the electronic device 1000 shown in fig. 7, the user interface 1003 is mainly used as an interface for providing input for a user, and acquiring data input by the user; and the processor 1001 may be configured to invoke a memory backup application stored in the memory 1005 that prevents ECU flashing, and specifically perform the following operations:
acquiring a preset first check sum;
acquiring a second checksum corresponding to the preset backup area;
when the first checksum and the second checksum are inconsistent, judging whether the first checksum is correct or not to obtain a judgment result;
and finishing memory data backup based on the judgment result.
In one embodiment, the processor 1001, before performing the obtaining of the preset first checksum, further performs the following operations:
when a data change instruction for an offline variable storage area is received, changing the data to generate changed data;
calculating the modified data based on a preset checksum algorithm to generate a checksum corresponding to the modified data, and taking the checksum corresponding to the modified data as a first checksum;
and flashing the changed data and the checksum to the offline variable storage area to generate data and a first checksum in the offline variable storage area.
In an embodiment, when the processor 1001 executes the memory data backup based on the determination result, the following operations are specifically executed:
and when the first checksum is correct, copying the data in the offline variable storage area to the preset backup area.
In an embodiment, when the processor 1001 executes the memory data backup based on the determination result, the following operations are specifically executed:
and when the first checksum is incorrect, copying the backup data of the preset backup area to the offline variable storage area.
In the embodiment of the application, the vehicle computer firstly obtains a preset first checksum, then obtains a second checksum corresponding to the preset backup area, then judges whether the first checksum is correct or not when the first checksum is inconsistent with the second checksum to obtain a judgment result, and finally completes memory data backup based on the judgment result. According to the scheme, the partitions with the same size are added in advance to perform data backup on the lower limit variable storage area which is frequently subjected to data flashing, and under the condition that the flashing is unsuccessful, the data in the backup area can be copied into the lower limit variable storage area based on the calculated checksum.
Those of skill in the art would appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention. It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments disclosed herein, it should be understood that the disclosed methods, articles of manufacture (including but not limited to devices, apparatuses, etc.) may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, 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. The 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 solution 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.
It should be understood that the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions. The present invention is not limited to the procedures and structures that have been described above and shown in the drawings, and various modifications and changes may be made without departing from the scope thereof. The scope of the invention is limited only by the appended claims.