CN117972712B - Firmware updating method, device, computer equipment and computer storage medium - Google Patents

Firmware updating method, device, computer equipment and computer storage medium Download PDF

Info

Publication number
CN117972712B
CN117972712B CN202311857018.9A CN202311857018A CN117972712B CN 117972712 B CN117972712 B CN 117972712B CN 202311857018 A CN202311857018 A CN 202311857018A CN 117972712 B CN117972712 B CN 117972712B
Authority
CN
China
Prior art keywords
firmware
new version
original
edition
new
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
CN202311857018.9A
Other languages
Chinese (zh)
Other versions
CN117972712A (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.)
Beijing Chenguang Rongxin Technology Co ltd
Original Assignee
Beijing Chenguang Rongxin Technology 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 Beijing Chenguang Rongxin Technology Co ltd filed Critical Beijing Chenguang Rongxin Technology Co ltd
Priority to CN202311857018.9A priority Critical patent/CN117972712B/en
Publication of CN117972712A publication Critical patent/CN117972712A/en
Application granted granted Critical
Publication of CN117972712B publication Critical patent/CN117972712B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Stored Programmes (AREA)

Abstract

The invention discloses a firmware updating method, a device, a computer device and a computer storage medium, wherein the method is applied to the computer device and comprises the following steps: receiving a new version of firmware data fragment; after receiving the new version firmware data fragments, verifying whether the received new version firmware data fragments are complete, if so, splicing the new version firmware data fragments to generate new version firmware, and storing the new version firmware in an operation directory, wherein the operation directory is stored in a first storage partition; the original edition firmware performs signature verification on the new edition firmware, and if the signature verification passes, the original edition firmware stops running, wherein the original edition firmware is stored in a second storage partition; under the condition that the original edition firmware stops running, the daemon carries out signature verification and decryption on the new edition firmware; starting the new version of firmware under the condition that the verification signature and decryption of the new version of firmware pass; in the event that the new version of firmware is able to be booted up successfully, the original version of firmware is replaced with the new version of firmware.

Description

Firmware updating method, device, computer equipment and computer storage medium
Technical Field
The present invention relates to the field of firmware technologies, and in particular, to a firmware update method, apparatus, computer device, and computer storage medium.
Background
The firmware is the software which plays the most basic and bottom layer of a system, in an electronic terminal (such as a printer, a scanner and the like), the firmware is the most important part of the electronic terminal, and as some electronic terminals have no other software components except the firmware, the firmware also determines the functions and the performances of the electronic terminal, so that the firmware needs to repair various known bugs, push new functions and optimize through continuous updating.
The prior art cannot ensure the security and reliability of firmware storage, and if the storage area is tampered, the tampered program will be started when the next time is started. The prior art cannot ensure the safety and reliability of the firmware source, cannot ensure the validity of the firmware program, cannot update the firmware again by using a normal software mode once the updated firmware cannot be started, and may need to refresh the memory chip again.
Disclosure of Invention
In view of this, embodiments of the present invention provide a firmware update method, apparatus, computer device, and computer storage medium.
The technical scheme of the invention is realized as follows:
Receiving a new version of firmware data fragment, wherein the new version of firmware data fragment comprises encrypted firmware update data and fragment information of the encrypted firmware update data;
After receiving the new version firmware data fragments, verifying whether the received new version firmware data fragments are complete, if so, splicing the new version firmware data fragments to generate new version firmware, and storing the new version firmware in an operation directory, wherein the operation directory is stored in a first storage partition;
the original edition firmware performs signature verification on the new edition firmware, and if the signature verification passes, the original edition firmware stops running, wherein the original edition firmware is stored in a second storage partition;
Under the condition that the original edition firmware stops running, the daemon carries out signature verification and decryption on the new edition firmware;
starting the new version firmware under the condition that the verification and decryption of the new version firmware pass;
And replacing the original edition firmware with the new edition firmware under the condition that the new edition firmware can be started successfully.
In the above scheme, the slicing information includes the number of the new version firmware data slices and the slicing identifier;
The verifying whether the received new version firmware data fragment is complete comprises the following steps:
and judging whether the received new version firmware data fragments are complete or not according to the number of the new version firmware data fragments and the fragment identification.
In the above scheme, the new version firmware is a compressed packet, and the new version firmware data slicing is data slicing obtained from the compressed packet according to a preset slicing rule;
The starting the new version of firmware comprises:
the daemon performs signature verification on the new version of firmware;
If the new version firmware passes the verification, the daemon decrypts the new version firmware;
If the decryption is passed, controlling the original edition firmware to stop running;
Decompressing the decrypted new version of firmware to an operation directory, wherein the operation directory is stored in the second storage partition;
and starting the new version firmware under the running directory.
In the above scheme, the original edition firmware performs signature verification on the new edition firmware, and generates a first identification file under the condition that the signature verification passes;
before the daemon performs signature verification and decryption on the new version firmware, the method further comprises:
The daemon checks whether the first identification file exists;
If yes, the daemon carries out signature verification and decryption on the new version of firmware;
if not, the firmware update is terminated and the original edition firmware rollback is performed.
In the above scheme, the access right of the second storage partition is read-write;
said replacing said original firmware with said new version of firmware comprising:
Storing the new version of firmware in the second storage partition;
starting the new version firmware to delete the original version firmware;
if the original edition firmware is successfully deleted, the firmware is successfully updated;
And if the original edition firmware deletion is unsuccessful, ending the firmware update, and carrying out original edition firmware rollback.
In the above scheme, the access right of the second storage partition is read-only;
Before the starting of the new version firmware, the method further comprises the following steps:
unloading the second storage partition, and re-mounting the access right of the second storage partition as a read-write right;
after replacing the original firmware with the new version of firmware, further comprising:
re-mounting the access right of the second storage partition as a read-only right;
Under the condition that the new version of firmware can be started successfully, the original version of firmware generates a second identification file;
said replacing said original firmware with said new version of firmware comprising:
The daemon checks whether the second identification file is present,
If so, the daemon deletes the original edition firmware;
if the original edition firmware is successfully deleted, the firmware is successfully updated;
And if the original edition firmware deletion is unsuccessful, ending the firmware update, and carrying out original edition firmware rollback.
A firmware update apparatus, the apparatus comprising:
the receiving module is used for receiving the new version firmware data fragments, wherein the new version firmware data fragments comprise encrypted firmware update data and fragment information of the encrypted firmware update data;
The complete verification module is used for verifying whether the received new version firmware data fragments are complete after the new version firmware data fragments are received, if the complete new version firmware data fragments are received, generating new version firmware according to the new version firmware data fragments, and storing the new version firmware in an operation catalog;
The signature verification module is used for carrying out signature verification processing on the new version of firmware by the firmware program, and under the condition that the signature verification passes, the original version of firmware stops running;
the signature verification decryption module is used for performing signature verification and decryption processing on the new version firmware by the daemon under the condition that the original version firmware stops running;
The starting verification module is used for starting the new version firmware under the condition that the verification and decryption processes of the new version firmware are passed; wherein the running directory and the upgrading directory belong to different storage partitions;
And the updating module is used for replacing the original edition firmware with the new edition firmware under the condition that the new edition firmware can be started successfully.
A computer device comprising a memory and a processor, the memory having stored therein computer readable instructions which, when executed by the processor, cause the processor to perform the steps of firmware update described above.
A storage medium storing computer readable instructions that, when executed by one or more processors, cause the one or more processors to perform the steps of firmware update described above.
To achieve the above object, an embodiment of the present invention further provides a computer storage medium storing one or more programs executable by one or more processors to cause the one or more processors to perform the steps of the firmware update method according to any one of the above aspects.
The embodiment of the invention provides a firmware updating method, a device, computer equipment and a computer storage medium, which are used for receiving a new version of firmware data fragment, wherein the new version of firmware data fragment comprises encrypted firmware updating data and fragment information of the encrypted firmware updating data; after receiving the new version firmware data fragments, verifying whether the received new version firmware data fragments are complete, if so, splicing the new version firmware data fragments to generate new version firmware, and storing the new version firmware in an operation directory, wherein the operation directory is stored in a first storage partition; then the original edition firmware carries out signature verification on the new edition firmware, and if the signature verification passes, the original edition firmware stops running, wherein the original edition firmware is stored in a second storage partition; under the condition that the original edition firmware stops running, the daemon carries out signature verification and decryption on the new edition firmware; starting the new version firmware under the condition that the verification and decryption of the new version firmware pass; and finally, under the condition that the new version of firmware can be started successfully, replacing the original version of firmware by the new version of firmware. Thus, the new version of firmware data is digitally signed and encrypted, and the process of verifying the signature and decrypting is performed when the firmware file is received and the firmware program is started when the firmware is updated. The private key of the digital signature and encryption algorithm is stored by the firmware issuing unit and is not disclosed, so that the reliability and the safety of the source of the firmware file are ensured. The validity of the firmware program is verified in the firmware updating process, so that the validity of the firmware program is ensured.
Drawings
FIG. 1 is a technical framework diagram of a firmware update product provided by some embodiments of the present invention;
FIG. 2 is a flowchart illustrating a firmware update method according to some embodiments of the present invention;
FIG. 3 is a flowchart illustrating a firmware update method according to another embodiment of the invention;
FIG. 4 is a flowchart illustrating a firmware update method according to still other embodiments of the present invention;
FIG. 5 is a schematic diagram illustrating a firmware update apparatus according to some embodiments of the present invention;
fig. 6 is a schematic diagram of a hardware structure of a computer device according to an embodiment of the present invention.
Detailed Description
In the case of printing, for example, the electronic terminal is used as an example, the printer needs to use a computer installed with a corresponding printer driver or an intelligent device connected with the bluetooth of the printer to send a printing instruction, and after receiving the printing instruction, the printer processes the received printing instruction through its own processing chip and initiates a printing task corresponding to the printing instruction. The driver in the processing chip of the printer is printer firmware, and along with continuous updating and optimization of the printer program, the processing program of the printer needs to update the driver of the processing chip of the printer in order to process the received command signals normally or more quickly and efficiently, which is called printer firmware update. Generally, the firmware upgrade process includes: firstly, acquiring a new version of firmware and an upgrade tool; then placing the new version of firmware under a fixed directory of the printer to be upgraded; at this time, selecting a corresponding new version of firmware to execute a corresponding upgrade command; after the upgrade is completed, whether the firmware version is correct is detected. The prior art cannot ensure the safe transmission in the transmission process of the new version firmware, cannot ensure the new version firmware not to be tampered in the updating and upgrading process of the firmware, and cannot ensure the starting of the firmware after updating.
Based on the above, the embodiment of the invention provides a set of firmware updating product, when the printer electronic terminal is updated, a temporary storage space can be created in advance in the printer electronic terminal, so that the original edition firmware can be safely detected by utilizing the temporary storage space, and the damage of malicious firmware (namely unsafe firmware) to the printer electronic terminal can be prevented; secondly, the new version firmware released by authorities often has a new version firmware digital signature, so whether the original version firmware is tampered or not can be detected by utilizing whether the new version firmware digital signature is effective, thereby the information security of the firmware can be effectively improved, and finally, signature verification and decryption operations are required before each start of the updated firmware, thereby avoiding the situation that the firmware is tampered and the damage to the printer electronic terminal caused by the start of malicious firmware.
Technical term interpretation:
Firmware data refers to the whole data content of the firmware of the device, and physical storage can be fixed address segment storage or file form.
The new version of firmware data refers to the data which is transmitted to the device outside the device and used for updating the firmware by the device.
Firmware file refers to firmware data stored in the form of device file according to the invention.
The temporary file is transmitted, which means that part or all of firmware data received in the updating process of the file form storage of the device is stored in a file different from the file name of the formal firmware. The use of transfer temporary files is to reduce the complexity of the process that is increased by processing data files that may remain due to anomalies in the update process.
Firmware program refers to executable content in the firmware of the device of the present invention, and generally refers to a main program in the executable program.
Daemon refers to a process for monitoring the running condition of a firmware program in the device firmware, and when the daemon monitors that the firmware program is not in a running state, the daemon is responsible for starting the firmware program; when the firmware program is detected to be in the updating process, the firmware program is responsible for updating or rolling back the firmware data according to the updating process; when illegal firmware data is detected, it is responsible for suspending the firmware program operation or attempting to recover the original firmware program, etc.
Firmware partitioning, wherein in the process of updating and starting the device, the firmware adopts partition management during management.
The running catalog refers to a starting catalog of the device firmware in the invention when the firmware program runs, and the running catalog is specified in the program partition in the scheme of the invention.
The upgrade catalog refers to a storage catalog for storing received firmware data in the firmware upgrade process of the device, and the upgrade catalog is appointed in the data partition in the scheme of the invention.
The device of the invention operates based on a multi-process system, and the communication among the processes can be carried out through file interaction. In the invention, the identification file is used for exchanging the flow information between the daemon process and the firmware program.
Fig. 1 is a technical framework diagram of a firmware update product, and as shown in fig. 1, a printer electronic terminal has two working modes, a factory mode and a working mode, wherein the factory mode realizes functions of firmware upgrade, mainboard setting, mainboard debugging and the like. The working mode is a normal use mode of a user, and all normal operation working modes of the equipment can be completed to be a default mode used by the equipment and also to be a main mode. The embodiment of the invention aims at researching the technology of automatically downloading a firmware update package, automatically executing an update instruction and detecting an update result.
Fig. 2 is a flowchart of a firmware update method in an embodiment of the present invention, please refer to fig. 2, and an embodiment of the present invention provides a firmware update method, which is applied to a computer device, and includes:
Step 201: receiving a new version of firmware data fragment, wherein the new version of firmware data fragment comprises encrypted firmware update data and fragment information of the encrypted firmware update data;
the new version firmware data fragments are new version firmware data fragments, and the complete new version firmware can be generated only if the electronic terminal receives all the new version firmware data fragments. By way of example, a developer may develop and generate a new version of firmware on a host device, which is any computing device that provides firmware update data to an electronic terminal that is to upgrade the firmware. For example, the upper computer device may be a cloud server, or a local server, or a device of a Bluetooth Low Energy (BLE) network. It should be understood that the upper computer device may be located at the cloud or locally. The upper computer device and the electronic terminal of the firmware to be updated can communicate in Wi-Fi, bluetooth, zigBee, ethernet and other modes, and the specific implementation method is compatible with various communication modes and is not limited herein.
Of course, the upper computer device can also receive the new version firmware sent by other devices, because the volume of the new version firmware is generally larger, in order to ensure the stability of the transmission process, to avoid the situation that the whole new version firmware needs to be retransmitted due to interruption in the transmission process, the upper computer device can divide the new version firmware into a plurality of firmware new version firmware data fragments with preset file sizes and sequentially send the firmware new version firmware data fragments to the electronic terminal, and when a situation that the sending of a certain firmware new version firmware data fragment fails, only the firmware new version firmware data fragment needs to be retransmitted instead of retransmitting the whole new version firmware. The electronic terminal can confirm that the complete and correct new version of firmware is received. For example, when updating the firmware, in the process of transmitting the firmware file, the temporary file name is first transmitted and stored, and after the data is completely received, the temporary file name is updated to be the formal firmware file name. The original edition firmware (firmware program) checks whether the new edition firmware data slicing transmission process is abnormal, abnormal execution firmware update termination is caused (namely, the firmware program exits from the firmware update flow), and the transmission temporary file is cleaned. The firmware program checks that no abnormality has occurred in the transmission process, and the original firmware (original firmware program) of the electronic terminal controls the reception of the new version of firmware data. In order to prevent the increase of fault tolerance judgment on the residual new version of firmware data after the abnormal suspension of the firmware updating process and to improve the flow complexity, the new version of firmware data is stored in a transmission temporary file with different names from the formal new version of firmware file in a slicing way, the original edition of firmware program checks whether the reception is finished, and if so, the firmware program names the transmission temporary file as the formal firmware file name and stores the transmission temporary file under the upgrading directory.
Step 202: after receiving the new version firmware data fragments, verifying whether the received new version firmware data fragments are complete, if so, splicing the new version firmware data fragments to generate new version firmware, and storing the new version firmware in an operation directory, wherein the operation directory is stored in a first storage partition;
It may be understood that the first storage partition may be a data partition, that is, the new version of firmware is first stored under the running directory, and the first storage partition is a storage partition with a readable and writable right. The new version firmware can compress the file, cut the compressed file into a plurality of data fragments according to a preset cutting rule, and splice the plurality of new version firmware data fragments into the new version firmware on one side of the electronic equipment after all the data fragments are transmitted to the electronic equipment. If the new version firmware data is not segmented completely or has errors, the new version firmware cannot be spliced.
In some embodiments, the sharding information includes a number of shards of the new version of firmware data and a shard identification; the step 202 may include:
Step 2021: and judging whether the received new version firmware data fragments are complete or not according to the number of the new version firmware data fragments and the fragment identification.
The method includes that when the upper computer equipment divides the new version firmware file into a plurality of new version firmware data fragments and transmits the compressed differential upgrade package to the electronic terminal, the plurality of new version firmware data fragments are sequentially transmitted, and the limitation of the size of single transmission data is avoided. The compressed differential upgrade package is divided into 50 new version firmware data fragments, the upper computer device issues the 50 new version firmware data fragments to the terminal, and if the terminal receives 50 new version firmware data fragments with different IDs and the IDs also correspond to the sequence type of the transmission of the new version firmware data fragments, the received new version firmware data fragments are determined to be complete, for example, a flag bit representing the transmission sequence of the fragments is arranged in the IDs, and the flag bit represents the transmission sequence of the fragments. Optionally, when the upper computer device issues the new version firmware data fragments, a redundant set of new version firmware data fragments are issued by using a redundancy algorithm, so that the integrity of the received data of the terminal is improved.
Preferably, in some embodiments, if the received new version firmware data fragment is incomplete, the missing new version firmware data fragment is re-acquired until the received new version firmware data fragment is complete, or until the number of times of re-acquiring the new version firmware data fragment reaches a preset number of times threshold; if the new version of the firmware data fragments finally received are incomplete, deleting the new version of the firmware data fragments, terminating the firmware update, and performing original edition firmware rollback (namely continuing to use the original edition firmware).
Step 203: and the original edition firmware performs signature verification on the new edition firmware, and if the signature verification passes, the original edition firmware stops running, wherein the original edition firmware is stored in a second storage partition.
Wherein, the firmware digital signature refers to: only the sender of the information can generate a digital string which cannot be forged by others, and the digital string is also a valid proof for the authenticity of the information sent by the sender of the information.
The tamper-resistant logic of the new version of firmware digital signature is: the sender generates a message digest from a message text by using a Hash function, encrypts the digest by using a private key of the sender, the encrypted digest is sent to the receiver together with the message as a new version of the firmware digital signature of the message, the receiver calculates the message digest (i.e., the Hash digest) from the received original message by using the same Hash function as the sender, then decrypts the new version of the firmware digital signature attached to the message by using the public key, and if the two digests are identical, the receiver can confirm that the message is the sender.
And if the original edition firmware passes the verification of the new edition firmware, updating the original edition firmware, and rolling back the original edition firmware.
In some embodiments, the step 203 may include:
Step 2031: a signature verification request is sent to a new version firmware sender, and a new version firmware digital signature fed back by the new version firmware sender, an asymmetric key algorithm and a public key corresponding to the asymmetric key algorithm are received; namely, an asymmetric key algorithm is obtained, and a public key corresponding to the asymmetric key algorithm is obtained;
Step 2032: decrypting the digital signature of the new version of firmware according to the asymmetric key algorithm and the public key to obtain first abstract information corresponding to the new version of firmware; it should be noted that, when the decryption processing of the digital signature corresponding to the new version firmware fails, it may be determined that the obtained new version firmware is illegal, and at this time, the operation of the new version firmware needs to be stopped, so as to ensure the security of the firmware update process;
Step 2033: performing abstract calculation processing on the received new version firmware according to a secure hash algorithm to obtain second abstract information corresponding to the received new version firmware data fragments;
step 2034: judging whether the first abstract information and the second abstract information are the same or not;
step 2035: if the verification result is the same, the verification of the new version firmware is passed.
Step 204: under the condition that the original edition firmware stops running, the daemon carries out signature verification and decryption on the new edition firmware;
in the firmware updating process, the firmware program and the daemon process respectively check the new version of firmware, so that the validity of the firmware program is verified, and the validity of the firmware program is ensured.
The new version firmware is checked by adopting the daemon, the check process is the same as that of the original version firmware, and the step of decrypting the new version firmware by adopting the daemon is added.
It will be appreciated that if the daemon does not verify and/or decrypt the new version of firmware, then the firmware update is terminated and the original version of firmware is rolled back.
In some embodiments, the original firmware performs signature verification on the new version firmware, and in the case that the signature verification passes, the original firmware generates a first identification file;
prior to step 204, it may further include:
step 02041: the daemon checks whether the first identification file exists;
Step 02042: if yes, the daemon carries out signature verification and decryption on the new version of firmware;
Step 02043: if not, the firmware update is terminated and the original edition firmware rollback is performed.
The firmware and the daemon process carry out flow information interaction through the identification file. If the complete new version firmware data fragment is received, generating a first identification file by the firmware program; before the daemon carries out signature verification and decryption processing on the new version firmware, determining whether the first identification file exists, and if so, carrying out signature verification and decryption processing on the new version firmware by the daemon; if not, terminating the firmware update. For example, before the daemon performs verification signing and decryption processing on the firmware file under the upgrade directory, the daemon checks whether the identification file checkupgrade exists, if so, performs verification signing and decryption, and if not, terminates firmware update, and performs the original firmware rollback procedure.
Step 205: and starting the new version firmware under the condition that the verification and decryption of the new version firmware pass.
Wherein, the start-up of the new version firmware is to try to start up the new version firmware, and if the new version firmware can be started up successfully, the original version firmware can be updated to the new version firmware.
In some embodiments, the new version of firmware is a compressed packet, and the new version of firmware data slicing is data slicing obtained from the compressed packet according to a preset slicing rule;
the step 205 may include:
Step 2051: the daemon performs signature verification on the new version of firmware;
step 2052: if the new version firmware passes the verification, the daemon decrypts the new version firmware;
step 2053: if the decryption is passed, controlling the original edition firmware to stop running;
Step 2054: decompressing the decrypted new version of firmware to an operation directory, wherein the operation directory is stored in the second storage partition;
step 2055: and starting the new version firmware under the running directory.
When the firmware is started, the firmware of the program partition is written into an operation catalog, the new version of firmware is compressed data, the decrypted new version of firmware is decompressed, and the decompressed new version of firmware is written into the operation catalog, so that the starting of the firmware is completed. And after the firmware is updated, the original firmware is replaced by the new version of firmware when the first start of the firmware program is successful, otherwise, rollback is carried out, the new version of firmware is deleted, and the original firmware is reserved so as to ensure the validity of the firmware program.
It will be appreciated that when the firmware is started, the signature verification decryption process prevents the firmware program from being replaced by an unknown source program, and if signature verification decryption cannot pass, the original edition firmware is used for replacing the current illegal version. In this embodiment, when the firmware is started, the signature verification decryption process is used to prevent the firmware program from being replaced by an unknown source program, and if the signature verification decryption cannot pass, the original edition firmware is used to replace the current illegal edition.
Step 206: and replacing the original edition firmware with the new edition firmware under the condition that the new edition firmware can be started successfully.
In some embodiments, the access rights of the storage partition of the upgrade directory are read-only;
before writing the new version firmware into the operation catalog corresponding to the new version firmware, the method further comprises the following steps:
Unloading the storage partition where the upgrading directory is located, and re-mounting the access right of the storage partition where the upgrading directory is located as the read-write right;
Storing the new version firmware in a storage partition where the upgrading directory is located;
after writing the new version firmware into the running catalog corresponding to the new version firmware, the method further comprises the following steps:
and re-mounting the access right of the storage partition of the upgrading directory as read-only right.
If the daemon re-installs the partition as the read-write permission, the firmware program generates an identification file checkwritable. Before the daemon moves the firmware file under the upgrade directory to replace the firmware file under the program partition, the daemon checks whether the identification file checkwritable exists, if so, the daemon moves the firmware file under the upgrade directory to replace the firmware file under the program partition; if not, the firmware update procedure is ended.
For example, as shown in fig. 3, the firmware update flow without the storage read-write permission change may include:
Step 301: after the electronic terminal starts to receive the new version firmware data fragments, the firmware program checks whether the transmission process is abnormal or not, and the step 306 is executed when the transmission process is abnormal;
Step 302: the new version firmware data are stored in a transmission temporary file with different names from the formal firmware file in a slicing way; therefore, the method can prevent the residual updated firmware data from increasing fault tolerance judgment after the firmware updating process is aborted, and improves the complexity of the process.
Step 303: the firmware program checks whether the receiving of the new version of firmware data fragments is finished, if yes, the next step is executed, otherwise, the step 301 is returned;
Step 304: the firmware program will transmit the temporary file to be named as the new version firmware file name and store it under the upgrade catalog;
Step 305: the firmware program verifies and signs the new version of firmware under the upgrading catalog, the signature verification is carried out by executing step 307, otherwise, step 306 is carried out;
Step 306: the firmware program exits the firmware updating process and cleans up the transmission temporary file;
step 307: the firmware program generates an identification file checkupgrade indicating that the complete new version of firmware has been received;
step 308: actively exiting the firmware program, namely stopping the original edition firmware;
step 309: the daemon checks if the original firmware is aborted, if yes, then go to the next step, otherwise go to step 309;
step 3010: the daemon checks whether the identification file checkupgrade exists, and the next step is executed, otherwise step 3014 is executed;
Step 3011: the daemon deletes the identification file checkupgrade;
Step 3012: the daemon performs verification signing and decryption processing on the new version of firmware under the upgrading catalog, and performs the next step, otherwise, performs step 309;
step 3013: the daemon decompresses the new version firmware under the upgrade catalog to the running catalog, executing step 3017;
step 3014: the daemon deletes the new version firmware under the upgrade directory;
step 3015: the daemon processes the verification signature and decryption processing to the original edition firmware under the program partition, and the next step is executed, otherwise, the step 309 is executed;
Step 3016: the daemon decompresses the original edition firmware under the program partition to the running catalog, executing step 3017;
step 3017: the daemon starts a new version of firmware under the running directory;
step 3018: executing step 309 if the new version of firmware fails to boot, otherwise executing the next step;
Step 3019: the firmware program checks whether the new version of firmware exists under the upgrading catalog, the next step is executed, otherwise step 3021 is executed;
Step 3020: the firmware program moves the new version firmware under the upgrade catalog to replace the original edition firmware under the program partition;
step 3021: the firmware program runs normally;
Step 3022: the firmware program checks whether to exit running the current firmware program, and if so, step 309 is executed, otherwise step 3021 is executed.
For example, as shown in fig. 4, the firmware update flow with the storage read-write permission change may include:
step 401: after the electronic terminal starts to receive the new version firmware data fragments, the firmware program checks whether the transmission process is abnormal or not, and the step 406 is executed when the transmission process is abnormal;
Step 402: the new version firmware data are stored in a transmission temporary file with different names from the formal firmware file in a slicing way; therefore, the method can prevent the residual updated firmware data from increasing fault tolerance judgment after the firmware updating process is aborted, and improves the complexity of the process.
Step 403: the firmware program checks whether the receiving of the new version of firmware data fragments is finished, if yes, the next step is executed, otherwise, the step 401 is returned;
Step 404: the firmware program will transmit the temporary file to be named as the new version firmware file name and store it under the upgrade catalog;
Step 405: the firmware program verifies and signs the new version of firmware under the upgrading catalog, the verification signature is carried out by executing the step 407, otherwise, the step 406 is carried out;
step 406: the firmware program exits the firmware updating process and cleans up the transmission temporary file;
Step 407: the firmware program generates an identification file checkupgrade indicating that the complete new version of firmware has been received;
step 408: actively exiting the firmware program, namely stopping the original edition firmware;
Step 409: the daemon checks if the original firmware is aborted, if yes, then go to the next step, otherwise go to step 409;
step 4010: the daemon re-mounts the program partition as the read-write permission;
Step 4011: the daemon checks whether the identification file checkwritable exists, and if not, the execution proceeds to step 4014;
step 4012: the daemon deletes the identification file checkwritable;
Step 4013: the daemon moves the new version firmware under the upgrade directory to replace the original edition firmware under the program partition;
step 4014: the daemon checks whether the identification file checkupgrade exists, and if not, the execution proceeds to step 4014;
Step 4015: the daemon deletes the identification file checkupgrade;
step 4016: the daemon processes the verification signature and decryption processing to the new version firmware file under the upgrade catalog, and executes the next step, otherwise, executes the step 409;
step 4017: the daemon decompresses the new version firmware under the upgrade catalog to the running catalog, executing step 4022;
Step 4018: the daemon deletes the new version firmware under the upgrade directory;
step 4019: the daemon processes the verification signature and decryption processing to the new version firmware under the program partition, and executes the next step, otherwise, executes the step 409;
step 4020: the daemon decompresses the firmware files under the program partition to the running directory, executing step 22.
Step 4022: the daemon re-mounts the program partition as read-only rights;
Step 4022: the daemon starts a new version of firmware under the running directory;
step 4023: executing step 409 if the firmware program fails to start, otherwise executing the next step;
step 4024: the firmware program checks whether the new version firmware of the upgrading catalog exists or not, and the next step is executed, otherwise, the step 4027 is executed;
Step 4025: the firmware program generates an identification file checkwritable to indicate that the updated firmware can be started normally and can be updated actually;
Step 4026: the firmware program actively exits operation, and step 4028 is executed;
Step 4027: the firmware program runs normally;
Step 4028: the firmware program checks whether to exit running the current firmware program, and if so, step 409 is executed, otherwise step 4028 is executed.
It should be noted that, each of the above functional modules is a virtual division of a processing module in a computer device for implementing a certain function in the computer device, and it can be understood that computer instructions implemented by different functional modules implement the function, thereby cooperatively implementing the above data classification method.
To achieve the above object, an embodiment of the present invention further provides a firmware updating apparatus, referring to fig. 5, including:
A receiving module 51, configured to receive a new version of firmware data fragment, where the new version of firmware data fragment includes encrypted firmware update data and fragment information of the encrypted firmware update data;
The verification integrity module 52 is configured to verify whether the received new version firmware data fragment is complete after receiving the new version firmware data fragment is over, and if so, splice the new version firmware data fragment to generate a new version firmware, and store the new version firmware in an operation directory, where the operation directory is stored in a first storage partition;
The signature verification module 53 is configured to verify the new version of firmware by using original version firmware, and if the verification passes, the original version of firmware stops running, where the original version of firmware is stored in the second storage partition;
a signature verification decryption module 54, configured to, in a case where the original firmware ceases to operate, perform signature verification and decryption on the new firmware by using a daemon process;
The starting module 55 is configured to start the new firmware if the verification and decryption of the new firmware pass;
an updating module 56, configured to replace the original firmware with the new firmware if the new firmware can be started successfully.
It should be noted here that: the description of the firmware updating apparatus item is similar to the description of the firmware updating method item, and the description of the beneficial effects of the same method is omitted. For technical details not disclosed in the embodiment of the firmware update apparatus of the present invention, please refer to the description of the embodiment of the firmware update method of the present invention.
To achieve the above object, an embodiment of the present invention further provides a computer device, as shown in fig. 6, including a processor 601, and a memory 603 connected to the processor 601 through a communication bus 602; wherein the memory 603 is used for a data classification program; the processor 601 is configured to execute the data classification program to implement the method steps of data classification according to any of the above aspects: receiving a new version of firmware data fragment, wherein the new version of firmware data fragment comprises encrypted firmware update data and fragment information of the encrypted firmware update data; after receiving the new version firmware data fragments, verifying whether the received new version firmware data fragments are complete, if so, splicing the new version firmware data fragments to generate new version firmware, and storing the new version firmware in an operation directory, wherein the operation directory is stored in a first storage partition; the original edition firmware performs signature verification on the new edition firmware, and if the signature verification passes, the original edition firmware stops running, wherein the original edition firmware is stored in a second storage partition; under the condition that the original edition firmware stops running, the daemon carries out signature verification and decryption on the new edition firmware; starting the new version firmware under the condition that the verification and decryption of the new version firmware pass; and replacing the original edition firmware with the new edition firmware under the condition that the new edition firmware can be started successfully.
Alternatively, the processor 601 may be a general purpose processor, a digital signal processor (DigitalSignalProcesso, DSP), an application specific integrated circuit (ApplicationSpecificIntegratedCircuit, ASIC), a field programmable gate array (FieldProgrammableGateArray, FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component. Here, the program executed by the processor 601 may be stored in the memory 603 connected to the processor 601 through the communication bus 602, and the memory 603 may be a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memories. Wherein, the nonvolatile memory can be read-only memory (ROM, readOnlyMemory), programmable read-only memory (PROM, programmableRead-only memory), erasable programmable read-only memory (EPROM, erasableProgrammableRead-only memory), electrically erasable programmable read-only memory (EEPROM, electricallyErasableProgrammableRead-only memory), and memory cell, magnetic random access memory (FRAM, ferromagneticrandomaccessmemory), flash memory (flash memory), magnetic surface memory, optical disk, or compact disk-only (CD-ROM, compactDiscRead-only memory); The magnetic surface memory may be a disk memory or a tape memory. The volatile memory may be a random access memory (RAM, randomAccessMemory) that acts as an external cache. by way of example, and not limitation, many forms of RAM are available, such as static random access memory (SRAM, staticRandomAccessMemory), synchronous static random access memory (SSRAM, synchronousStaticRandomAccessMemory), dynamic random access memory (DRAM, dynamicRandomAccessMemory), synchronous dynamic random access memory (SDRAM, synchronousDynamicRandomAccessMemory), Double data rate synchronous dynamic random access memory (DDRSDRAM, doubleDataRateSynchronousDynamicRandomAccessMemory), enhanced synchronous dynamic random access memory (ESDRAM, enhancedSynchronousDynamicRandomAccessMemory), synchronous dynamic random access memory (SLDRAM, syncLinkDynamicRandomAccessMemory), Direct memory bus random access memory (DRRAM, directRambusRandomAccessMemory). The memory 603 described in the embodiments of the present invention is intended to comprise, without being limited to, these and any other suitable types of memory 603. The memory 603 in an embodiment of the present invention is used to store various types of data to support the operation of the processor 601. Examples of such data include: any computer programs for operation by the processor 601, such as an operating system and application programs; contact data; telephone book data; a message; a picture; video, etc. The operating system includes various system programs, such as a framework layer, a core library layer, a driver layer, and the like, for implementing various basic services and processing hardware-based tasks.
In some embodiments, the memory 603 in embodiments of the present invention may be volatile memory or nonvolatile memory, or may include both volatile and nonvolatile memory. The nonvolatile memory may be a Read-only memory (ROM), a programmable Read-only memory (ProgrammableROM, PROM), an erasable programmable Read-only memory (ErasablePROM, EPROM), an electrically erasable programmable Read-only memory (ElectricallyEPROM, EEPROM), or a flash memory, among others. The volatile memory may be a random access memory (RandomAccessMemory, RAM) that acts as an external cache. By way of example, and not limitation, many forms of RAM are available, such as static random access memory (STATICRAM, SRAM), dynamic random access memory (DYNAMICRAM, DRAM), synchronous dynamic random access memory (SynchronousDRAM, SDRAM), double data rate synchronous dynamic random access memory (DoubleDataRateSDRAM, DDRSDRAM), enhanced synchronous dynamic random access memory (ENHANCEDSDRAM, ESDRAM), synchronous link dynamic random access memory (SYNCHLINKDRAM, SLDRAM), and direct memory bus random access memory (DirectRambusRAM, DRRAM). The memory 603 of the systems and methods described herein is intended to comprise, without being limited to, these and any other suitable types of memory.
And processor 601 may be an integrated circuit chip with signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in the processor 601 or instructions in the form of software. The processor 601 may be a general purpose processor, a digital signal processor (DigitalSignalProcessor, DSP), an application specific integrated circuit (ApplicationSpecificIntegratedCircuit, ASIC), an off-the-shelf programmable gate array (FieldProgrammableGateArray, FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component. The disclosed methods, steps, and logic blocks in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present invention may be embodied directly in the execution of a hardware decoding processor, or in the execution of a combination of hardware and software modules in a decoding processor. The software modules may be located in a random access memory, flash memory, read only memory, programmable read only memory, or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in the memory 603 and the processor 601 reads the information in the memory 603 and in combination with its hardware performs the steps of the method described above.
In some embodiments, the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For a hardware implementation, the processing units may be implemented within one or more application specific integrated circuits (ApplicationSpecificIntegratedCircuits, ASIC), digital signal processors (DigitalSignalProcessing, DSP), digital signal processing devices (DSPDEVICE, DSPD), programmable logic devices (ProgrammableLogicDevice, PLD), field programmable gate arrays (Field-ProgrammableGateArray, FPGA), general purpose processors, controllers, microcontrollers, microprocessors, other electronic units configured to perform the functions described herein, or a combination thereof.
For a software implementation, the techniques described herein may be implemented with modules (e.g., procedures, functions, and so on) that perform the functions described herein. The software codes may be stored in a memory and executed by a processor. The memory may be implemented within the processor or external to the processor.
Yet another embodiment of the present invention provides a computer storage medium storing an executable program that, when executed by the processor 601, implements steps of a data scanning method applied to the endpoint device. Such as one or more of the methods shown in fig. 2 or 3.
In some embodiments, the computer storage medium may include: a usb disk, a removable hard disk, a read-only memory (ROM, readOnlyMemory), a random access memory (RAM, randomAccessMemory), a magnetic disk, an optical disk, or other various media capable of storing program codes.
It should be noted that: the technical schemes described in the embodiments of the present invention may be arbitrarily combined without any collision.
The foregoing description is only of the preferred embodiments of the present invention, and is not intended to limit the scope of the present invention.

Claims (10)

1. A method of firmware update, the method comprising:
Receiving a new version of firmware data fragment, wherein the new version of firmware data fragment comprises encrypted firmware update data and fragment information of the encrypted firmware update data;
After receiving the new version firmware data fragments, verifying whether the received new version firmware data fragments are complete, if so, splicing the new version firmware data fragments to generate new version firmware, and storing the new version firmware in an operation directory, wherein the operation directory is stored in a first storage partition;
the original edition firmware performs signature verification on the new edition firmware, and if the signature verification passes, the original edition firmware stops running, wherein the original edition firmware is stored in a second storage partition;
Under the condition that the original edition firmware stops running, the daemon carries out signature verification and decryption on the new edition firmware;
starting the new version firmware under the condition that the verification and decryption of the new version firmware pass;
And replacing the original edition firmware with the new edition firmware under the condition that the new edition firmware can be started successfully.
2. The method of claim 1, wherein the shard information includes a number of shards and a shard identification of the new version of firmware data shards;
The verifying whether the received new version firmware data fragment is complete comprises the following steps:
and judging whether the received new version firmware data fragments are complete or not according to the number of the new version firmware data fragments and the fragment identification.
3. The method of claim 1, wherein the new version of firmware is a compressed packet, and the new version of firmware data fragmentation is a data fragmentation obtained for the compressed packet according to a preset fragmentation rule;
The starting the new version of firmware comprises:
the daemon performs signature verification on the new version of firmware;
If the new version firmware passes the verification, the daemon decrypts the new version firmware;
If the decryption is passed, controlling the original edition firmware to stop running;
Decompressing the decrypted new version of firmware to an operation directory, wherein the operation directory is stored in the second storage partition;
and starting the new version firmware under the running directory.
4. The method of claim 1, wherein the original firmware performs a signature verification on the new version of firmware, and in the event that the signature verification passes, the original firmware generates a first identification file;
before the daemon performs signature verification and decryption on the new version firmware, the method further comprises:
The daemon checks whether the first identification file exists;
If yes, the daemon carries out signature verification and decryption on the new version of firmware;
if not, the firmware update is terminated and the original edition firmware rollback is performed.
5. The method of claim 1, wherein the access rights of the second storage partition are read and write;
said replacing said original firmware with said new version of firmware comprising:
Storing the new version of firmware in the second storage partition;
starting the new version firmware to delete the original version firmware;
if the original edition firmware is successfully deleted, the firmware is successfully updated;
And if the original edition firmware deletion is unsuccessful, ending the firmware update, and carrying out original edition firmware rollback.
6. The method of claim 1, wherein the access rights of the second memory partition are read-only;
Before the starting of the new version firmware, the method further comprises the following steps:
unloading the second storage partition, and re-mounting the access right of the second storage partition as a read-write right;
after replacing the original firmware with the new version of firmware, further comprising:
and re-mounting the access right of the second storage partition as read-only right.
7. The method of claim 6, wherein the original firmware generates a second identification file if the new version of firmware can be booted up successfully;
said replacing said original firmware with said new version of firmware comprising:
The daemon checks whether the second identification file is present,
If so, the daemon deletes the original edition firmware;
if the original edition firmware is successfully deleted, the firmware is successfully updated;
And if the original edition firmware deletion is unsuccessful, ending the firmware update, and carrying out original edition firmware rollback.
8. A firmware update apparatus, the apparatus comprising:
the receiving module is used for receiving the new version firmware data fragments, wherein the new version firmware data fragments comprise encrypted firmware update data and fragment information of the encrypted firmware update data;
The verification complete module is used for verifying whether the received new version firmware data fragments are complete after the received new version firmware data fragments are finished, if so, splicing the new version firmware data fragments to generate new version firmware, and storing the new version firmware in an operation catalog, wherein the operation catalog is stored in a first storage partition;
The signature verification module is used for verifying the new edition of firmware by the original edition of firmware, and if the verification passes, the original edition of firmware stops running, wherein the original edition of firmware is stored in the second storage partition;
The signature verification decryption module is used for verifying and decrypting the new version of firmware by the daemon under the condition that the original version of firmware stops running;
The starting module is used for starting the new version firmware under the condition that the verification and decryption of the new version firmware pass;
And the updating module is used for replacing the original edition firmware with the new edition firmware under the condition that the new edition firmware can be started successfully.
9. A computer device, comprising:
A processor;
A memory for storing processor-executable instructions;
wherein the processor is configured to perform the firmware update method of any one of claims 1 to 7.
10. A computer storage medium storing one or more programs executable by one or more processors to cause the one or more processors to perform the firmware update method of any one of claims 1 to 7.
CN202311857018.9A 2023-12-29 2023-12-29 Firmware updating method, device, computer equipment and computer storage medium Active CN117972712B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311857018.9A CN117972712B (en) 2023-12-29 2023-12-29 Firmware updating method, device, computer equipment and computer storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311857018.9A CN117972712B (en) 2023-12-29 2023-12-29 Firmware updating method, device, computer equipment and computer storage medium

Publications (2)

Publication Number Publication Date
CN117972712A CN117972712A (en) 2024-05-03
CN117972712B true CN117972712B (en) 2024-07-02

Family

ID=90855485

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311857018.9A Active CN117972712B (en) 2023-12-29 2023-12-29 Firmware updating method, device, computer equipment and computer storage medium

Country Status (1)

Country Link
CN (1) CN117972712B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103595730A (en) * 2013-11-28 2014-02-19 中国科学院信息工程研究所 Ciphertext cloud storage method and system
CN107786504A (en) * 2016-08-26 2018-03-09 腾讯科技(深圳)有限公司 ELF file publishing methods, ELF file verifications method, server and terminal

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10956346B1 (en) * 2017-01-13 2021-03-23 Lightbits Labs Ltd. Storage system having an in-line hardware accelerator
US20210111876A1 (en) * 2019-10-11 2021-04-15 Atakama LLC Secure session for decryption
CN113805908A (en) * 2020-06-17 2021-12-17 瑞昱半导体股份有限公司 Firmware update system and method
CN112214780B (en) * 2020-08-26 2021-06-25 腾讯科技(深圳)有限公司 Data processing method and device, intelligent equipment and storage medium
CN114281379A (en) * 2021-12-21 2022-04-05 上海银基信息安全技术股份有限公司 Software updating method and device based on OTA, equipment terminal, server terminal and storage medium
CN114338651B (en) * 2021-12-27 2024-06-18 中电金信软件有限公司 File transmission method, device, electronic equipment and readable storage medium
CN117014196A (en) * 2023-07-21 2023-11-07 北京易华录信息技术股份有限公司 File encryption storage method, system and computer readable storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103595730A (en) * 2013-11-28 2014-02-19 中国科学院信息工程研究所 Ciphertext cloud storage method and system
CN107786504A (en) * 2016-08-26 2018-03-09 腾讯科技(深圳)有限公司 ELF file publishing methods, ELF file verifications method, server and terminal

Also Published As

Publication number Publication date
CN117972712A (en) 2024-05-03

Similar Documents

Publication Publication Date Title
US11803366B2 (en) Firmware updating system and method
US20190057214A1 (en) Update control device, terminal, and method of controlling
US9720782B2 (en) Authenticating a backup image with bifurcated storage
US8239674B2 (en) System and method of protecting files from unauthorized modification or deletion
US20020157010A1 (en) Secure system and method for updating a protected partition of a hard drive
US20160234396A1 (en) Image forming apparatus having firmware update function, method of controlling the same, program for executing the method, and storage medium
EP2605175A2 (en) Method and apparatus for checking field replaceable unit, and communication device
CN112783537B (en) Embedded linux operating system upgrading method and system based on MTD storage device
CN101236502A (en) Method of booting electronic device and method of authenticating boot of electronic device
US20200143057A1 (en) Staging memory for accessory firmware update
CN109445705B (en) Firmware authentication method and solid state disk
CN111786820B (en) Firmware updating method and device and network equipment
US20210176065A1 (en) Storage system and data protection method for storage system
CN112148314B (en) Mirror image verification method, device and equipment of embedded system and storage medium
CN114116305A (en) BIOS firmware recovery method, system, terminal and storage medium based on PFR
JP2004139371A (en) Storage device and its structure setting method
CN112131041A (en) Method, apparatus and computer program product for managing data placement
CN117972712B (en) Firmware updating method, device, computer equipment and computer storage medium
CN113360914A (en) BIOS updating method, system, equipment and medium
CN115242413A (en) Internet of things equipment firmware safety upgrading method and device, electronic equipment and medium
CN113721952A (en) Embedded software upgrading method applied to acquisition terminal
CN112882743A (en) Software upgrading method
CN112866195A (en) Agile data transmission method and device, computer equipment and storage medium
WO2021184712A1 (en) Software upgrading method and device
CN114281379A (en) Software updating method and device based on OTA, equipment terminal, server terminal and storage medium

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
GR01 Patent grant