CN113721968A - Firmware upgrading method and device - Google Patents

Firmware upgrading method and device Download PDF

Info

Publication number
CN113721968A
CN113721968A CN202111016767.XA CN202111016767A CN113721968A CN 113721968 A CN113721968 A CN 113721968A CN 202111016767 A CN202111016767 A CN 202111016767A CN 113721968 A CN113721968 A CN 113721968A
Authority
CN
China
Prior art keywords
file
target
firmware
description
upgrading
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.)
Granted
Application number
CN202111016767.XA
Other languages
Chinese (zh)
Other versions
CN113721968B (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.)
Hangzhou Hikvision Digital Technology Co Ltd
Original Assignee
Hangzhou Hikvision Digital 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 Hangzhou Hikvision Digital Technology Co Ltd filed Critical Hangzhou Hikvision Digital Technology Co Ltd
Priority to CN202111016767.XA priority Critical patent/CN113721968B/en
Publication of CN113721968A publication Critical patent/CN113721968A/en
Application granted granted Critical
Publication of CN113721968B publication Critical patent/CN113721968B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/658Incremental updates; Differential updates

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention provides a firmware upgrading method and a firmware upgrading device, which are applied to electronic equipment, wherein original firmware to be upgraded is arranged in the electronic equipment, and the method comprises the following steps: acquiring a description file of an original firmware as a first description file; the description file is a preset file for recording the content attribute of each file in the firmware to which the description file belongs; acquiring difference information determined by using the first description file and the second description file; wherein the second description file is: the original firmware is to be upgraded into a description file of the target firmware, and the difference information is used for indicating: target file identification and target upgrading operation of files with different contents between original firmware and target firmware; and executing target upgrading operation by using the file indicated by the target file identification so as to upgrade the original firmware. By the scheme, the efficiency of firmware upgrading can be improved.

Description

Firmware upgrading method and device
Technical Field
The invention relates to the technical field of data updating, in particular to a firmware upgrading method and device.
Background
Firmware is a general term for software, basic components and pre-installed applications in electronic equipment, which are required to maintain the normal operation of the electronic equipment, and one firmware includes at least one file. In order to improve the operation performance of the electronic device, when a device manufacturer issues new firmware, the firmware operating in the electronic device needs to be upgraded to the new firmware.
The existing firmware upgrade generally adopts a differential upgrade mode, that is, an equipment manufacturer issues new firmware in an upgrade package in advance, and the upgrade package issued by the equipment manufacturer contains all files of the new firmware. When the electronic equipment needs to upgrade the firmware, the upgrade server needs to perform binary difference on each file of the original firmware in the electronic equipment to determine the file needing to be changed, then generates a differential upgrade package based on the file needing to be changed, and sends the differential upgrade package to the electronic equipment, and the electronic equipment uses the received differential upgrade package to upgrade.
In the above process, binary differentiation is required for each file in the firmware, so that the efficiency is low.
Disclosure of Invention
The embodiment of the invention aims to provide a firmware upgrading method and device so as to improve firmware upgrading efficiency. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides a firmware upgrading method, which is applied to an electronic device, where an original firmware to be upgraded is set in the electronic device; the method comprises the following steps:
acquiring a description file of the original firmware as a first description file; the description file is a preset file for recording the content attribute of each file in the firmware to which the description file belongs;
acquiring difference information determined by using the first description file and the second description file; wherein the second description file is: the original firmware is to be upgraded into a description file of a target firmware, and the difference information is used for indicating: target file identification and target upgrading operation of the file with content difference between the original firmware and the target firmware;
and executing the target upgrading operation by using the file indicated by the target file identification so as to upgrade the original firmware.
In a second aspect, an embodiment of the present invention provides a firmware upgrading apparatus, which is applied to an electronic device, where original firmware to be upgraded is set in the electronic device, and the apparatus includes:
the first file acquisition module is used for acquiring the description file of the original firmware as a first description file; the description file is a preset file for recording the content attribute of each file in the firmware to which the description file belongs;
the information acquisition module is used for acquiring the difference information determined by the first description file and the second description file; wherein the second description file is: the original firmware is to be upgraded into a description file of a target firmware, and the difference information is used for indicating: target file identification and target upgrading operation of the file with content difference between the original firmware and the target firmware;
and the operation execution module is used for executing the target upgrading operation by using the file indicated by the target file identification so as to upgrade the original firmware.
The embodiment of the invention has the following beneficial effects:
in the firmware upgrading method provided in the embodiment of the present invention, the description file of the original firmware may be acquired as the first description file, and the difference information determined by using the first description file and the second description file of the target firmware may be acquired, where the difference information indicates: and the target file identifier and the target upgrading operation of the file with the content difference between the original firmware and the target firmware are performed, and then the target upgrading operation is performed by using the file indicated by the target file identifier so as to upgrade the original firmware. Because the description file is a preset file for recording the content attribute of each file in the firmware to which the description file belongs, when the firmware needs to be upgraded, the difference information between the original firmware and the target firmware can be determined by using the first description file of the original firmware and the second description file of the target firmware, and binary difference does not need to be carried out on the files in the firmware, so that the firmware upgrading efficiency is improved.
Of course, not all of the advantages described above need to be achieved at the same time in the practice of any one product or method of the invention.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other embodiments can be obtained by using the drawings without creative efforts.
Fig. 1 is a flowchart of a firmware upgrading method according to an embodiment of the present invention;
FIG. 2 is another flowchart of a firmware upgrade method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an upgrade package provided by an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a firmware upgrading apparatus according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the 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.
In order to improve the efficiency of firmware upgrade, embodiments of the present invention provide a firmware upgrade method and apparatus.
First, a firmware upgrading method provided by an embodiment of the present invention is described below.
The firmware in the embodiment of the invention is a general name of software required for maintaining normal operation of the electronic equipment, basic components in the electronic equipment and pre-installed application programs. It should be noted that the software required for maintaining the normal operation of the electronic device is also often referred to as firmware by those skilled in the art, and for simplicity of description, the firmware, the basic components and the pre-installed applications referred to by those skilled in the art are collectively referred to as firmware in the embodiment of the present invention. Wherein, the basic component can be a component of basic function. For example, for a video camera, the base component may include a preview component within the camera. The pre-installed application program may be an app (application) program obtained by performing secondary development on the basic component to provide more intelligent services.
As known to those skilled in the art, according to the upgrade mode division, the firmware upgrade of the electronic device can be divided into an offline mode and an online mode. In order to clearly illustrate the technical solutions provided by the embodiments of the present invention, the offline mode and the online mode are briefly described.
The offline mode refers to a mode of firmware upgrade through a local area network. In the offline mode, the upgrade package of the target firmware provided by the device vendor needs to be downloaded and saved locally. For a general embedded device (such as a switch), since the memory space of the device is limited, the device cannot completely store the upgrade package of the target firmware, and therefore, the upgrade package is generally placed in the upgrade client in advance. And upgrading the firmware of the electronic equipment through the upgrading client.
Online mode refers to the way firmware is done over the internet. In the online mode, the electronic device needs to be connected with an upgrade server through the internet in advance, and sends a firmware upgrade request to the internet to upgrade the firmware.
For the embodiment of the invention, whether in an offline mode or an online mode, the firmware released by the equipment manufacturer exists in an upgraded package mode. For the upgrade package in the offline mode, the complete data file can be used, that is, each file in the upgrade package is a complete file. For the upgrade package in online mode, the upgrade includes an address connection where each file can be the file, which can relieve the storage pressure of the upgrade server.
The embodiment of the invention can be applied to various electronic devices, such as embedded devices such as switches, intelligent terminals, servers and other devices with data processing capability. Moreover, the firmware upgrading method provided by the embodiment of the invention can be realized in a software, hardware or combination of software and hardware.
In order to improve the efficiency of firmware upgrade, an embodiment of the present invention provides a firmware upgrade method, including:
acquiring a description file of an original firmware as a first description file; the description file is a preset file for recording the content attribute of each file in the firmware to which the description file belongs;
acquiring difference information determined by using the first description file and the second description file; wherein the second description file is: the original firmware is to be upgraded into a description file of the target firmware, and the difference information is used for indicating: target file identification and target upgrading operation of files with different contents between original firmware and target firmware;
and executing target upgrading operation by using the file indicated by the target file identification so as to upgrade the original firmware.
The above technical solution provided in the embodiment of the present invention may acquire the description file of the original firmware as the first description file, and acquire the difference information determined by using the first description file and the second description file of the target firmware, where the difference information indicates: and the target file identifier and the target upgrading operation of the file with the content difference between the original firmware and the target firmware are performed, and then the target upgrading operation is performed by using the file indicated by the target file identifier so as to upgrade the original firmware. Because the description file is a preset file for recording the content attribute of each file in the firmware to which the description file belongs, when the firmware needs to be upgraded, the difference information between the original firmware and the target firmware can be determined by using the first description file of the original firmware and the second description file of the target firmware, and binary difference does not need to be carried out on the files in the firmware, so that the firmware upgrading efficiency is improved.
The following describes a firmware upgrading method provided in an embodiment of the present invention with reference to the accompanying drawings.
As shown in fig. 1, a firmware upgrading method provided in an embodiment of the present invention is applied to an electronic device, where an original firmware to be upgraded is set in the electronic device, and the method may include the following steps:
s101, acquiring a description file of an original firmware as a first description file; the description file is a preset file for recording the content attribute of each file in the firmware to which the description file belongs;
the description file may be a JSON (JavaScript Object Notation) format file. The JSON file is a lightweight data exchange format file.
The content attribute may be a file identifier, location information, version information, hash value, file size, file type, etc. The file identifier may be a name of a file, etc. The location information may be an offset location of the file in the upgrade package, or an address link of the file. The version information may be a release version number of the file firmware. The hash value is obtained by performing hash value calculation on the file. The file size is the data size of the file. The file type is a type to which the file belongs, wherein the file type can be divided into a directory type and a non-directory type, which needs to be explained. The directory of the firmware is also used as a file in the upgrade package, and the non-directory type file is the actual content file of the firmware.
For example, in a description file of a specification, the following content attributes may be recorded: at least one of schema version, Component (file name), fileType, version, digest, offset, size, url, or signature.
Wherein the schema version is used for describing the specification version of the file. Layers are the content Layers of the files, including the specific content properties of the files. Component is the name of the file. Version is the Version of the file. The fileType is a file type and is divided into directory files and non-directory files (normal files), wherein the directory files may not have attributes such as file size, offset position, hash value, and the like. Digest is a file hash value, and can be obtained by calculating a file by using sha 256. Offset is the Offset of the file in the upgrade package. Size is the file Size of the file. Signature is Signature information of the file and is used for proving the legality of the file.
When the firmware needs to be upgraded, the electronic device can directly read the description file of the original estimation currently running by the electronic device from a cache or other memories.
S102, acquiring difference information determined by using the first description file and the second description file; wherein the second description file is: the original firmware is to be upgraded into a description file of the target firmware, and the difference information is used for indicating: target file identification and target upgrading operation of files with different contents between original firmware and target firmware;
in other words, the electronic device obtains the difference information in different manners in different scenes. For the offline mode, the electronic device itself may execute the difference information determined by using the first description file and the second description file, and the electronic device may acquire the difference information. And for the online mode, the upgrade server may execute the difference information determined by using the first description file and the second description file, and at this time, the electronic device may obtain the difference information from the upgrade server. A specific implementation manner of the difference information determined by using the first description file and the second description file will be described in embodiments required later, and is not described herein again.
For a file in the original firmware and a file in the target firmware, the file existence form may include four types: the first method comprises the following steps: the original firmware and the target firmware exist and are the same; and the second method comprises the following steps: the original firmware and the target firmware are different in content; and the third is that: present in the original firmware, but not in the target firmware; and fourthly: not in the original firmware but in the target firmware.
For the first form of presence, the file does not require any action to be taken, as it is present in both the original firmware and the target firmware. For the other three existing forms, the file is not completely consistent in the original firmware and the target firmware, that is, the file is a file with a difference in content between the original firmware and the target firmware, so that the file identifier of the file is a target file identifier, and the upgrade operation for the file is a target upgrade operation. The target upgrading operation is modification operation for the second existing form file, deletion operation for the third existing form file, and addition operation for the fourth existing form file.
And S103, executing target upgrading operation by using the file indicated by the target file identification so as to upgrade the original firmware.
As can be seen from the foregoing description, the target upgrade operation is: add operations, delete operations, or modify operations. If the target upgrading operation is an adding operation, acquiring a file with a target file identifier in the target firmware, and adding the acquired file into the original firmware; if the target upgrading operation is a deleting operation, deleting the file with the target file identification from the original firmware; and if the target upgrading operation is a modification operation, updating the file with the target file identification in the original firmware based on the file with the target file identification in the target firmware.
According to the technical scheme provided by the embodiment of the invention, because the description file is a preset file for recording the content attribute of each file in the firmware to which the description file belongs, when the firmware needs to be upgraded, the difference information between the original firmware and the target firmware can be determined by using the first description file of the original firmware and the second description file of the target firmware, and binary difference does not need to be carried out on the files in the firmware, so that the firmware upgrading efficiency is improved.
Optionally, in an embodiment, on the basis of the embodiment shown in fig. 1, as shown in fig. 2, an embodiment of the present invention further provides another firmware upgrading method, which includes, in addition to the steps shown in fig. 1:
s201: comparing the content attributes of the first description file and the second description file;
wherein, the content attribute of each file may include the version information and hash value to which the file belongs, and the content attribute comparison of the first description file and the second description file may include;
and comparing the version information of the file with the hash value of the first description file and the second description file.
The judging mode of whether any two content attributes are the same includes: if the contained version information and the hash value are the same, the two arbitrary content attributes are the same, otherwise, the two arbitrary content attributes are different.
S202: if the first content attribute only appearing in the first description file exists, determining the file identifier of the first file to which the first content attribute belongs as a target file identifier and the target upgrading operation as a deleting operation;
for example, the first description file includes content attribute 1, content attribute 2, and content attribute 3, and the second description file includes content attribute 2 and content attribute 3, so that content attribute 1 only appears in the first description file, and thus the file identifier of the first file to which content attribute 1 belongs is determined as the target file identifier and the target upgrade operation is the delete operation.
S203: if the second content attribute only appearing in the second description file exists, determining the file identifier of the second file to which the second content attribute belongs as a target file identifier and performing target upgrading operation as increasing operation;
for example, the first description file includes content attribute 1, content attribute 2, and content attribute 3, and the second description file includes content attribute 1, content attribute 2, content attribute 3, and content attribute 4, then content attribute 4 appears in the second description file only initially, so the file identifier of the second file to which content attribute 4 belongs is determined as the target file identifier and the target upgrade operation is the add operation.
S204: if the second description file has a fourth content attribute corresponding to the third content attribute, determining the file identifier of the third file to which the third content attribute belongs as a target file identifier and the target upgrading operation as a modifying operation; the third content attribute is a content attribute in the first description file, and the fourth content attribute is different from the third content attribute and belongs to the same file.
For example, if the first description file includes a content attribute 5, and the file identifier of the content attribute 5 is an identifier a, and the second description file includes a content attribute 6, and the file identifier of the content attribute 6 is also an identifier a, the content attribute 6 is a third content attribute, and the content attribute 5 is a fourth content attribute, the identifier a to which the content attribute 6 belongs is determined as a target file identifier, and the target upgrade operation is a modify operation.
In the above description, the electronic device is only used to execute the above steps as an example. When the electronic device is in an online scene, the execution main body of the steps can be an upgrade server, the electronic device only needs to send the first description file and version information pointing to the target firmware to be upgraded to the upgrade server, and the upgrade server obtains the second description file according to the version image so as to point to the content attribute comparison process. Since the comparison process is completely consistent with the steps shown in FIG. 2, the description is omitted.
According to the technical scheme provided by the embodiment of the invention, because the description file is a preset file for recording the content attribute of each file in the firmware to which the description file belongs, when the firmware needs to be upgraded, the difference information between the original firmware and the target firmware can be determined by using the first description file of the original firmware and the second description file of the target firmware, and binary difference does not need to be carried out on the files in the firmware, so that the firmware upgrading efficiency is improved.
In an embodiment, when the upgrade mode is an offline upgrade mode, the electronic device needs to first obtain a second description file of the target upgrade package, and at this time, before performing content attribute comparison between the first description file and the second description file, the method further includes:
acquiring header information of an upgrade package where target firmware is located; wherein the header information indicates location information of a second description file in the upgrade package; and acquiring a second description file from the upgrade package based on the position information.
The header information may be common fixed header information, so as to facilitate identification of the location and size of the description file during network transmission. The electronic device receives the header information of the upgrade package first, and then can know the position information of the second description file in the upgrade package based on the header information, for example, the header information is the offset and the size of the second description file in the upgrade package, and then can know the data interval occupied by the second description file in the upgrade package based on the offset and the size. And further sending a request containing offset and size to the upgrading client to request the upgrading client to send the description file.
According to the technical scheme provided by the embodiment of the invention, because the description file is a preset file for recording the content attribute of each file in the firmware to which the description file belongs, when the firmware needs to be upgraded, the difference information between the original firmware and the target firmware can be determined by using the first description file of the original firmware and the second description file of the target firmware, and binary difference does not need to be carried out on the files in the firmware, so that the firmware upgrading efficiency is improved.
Optionally, in an embodiment, the electronic device may be connected to the upgrade client through a local area network, and in this case, in an implementation manner, if the target upgrade operation is an add operation, a file with a target file identifier in the target firmware is obtained from the upgrade client, and the obtained file is added to the original firmware. In another implementation manner, if the target upgrade operation is a modification operation, a file with a target file identifier in the target firmware is acquired from the upgrade client, and the acquired file is used to replace the file with the target file identifier in the original firmware.
Optionally, in another embodiment, the electronic device is connected to an upgrade server through the internet, and in this case, in an implementation manner, if the target upgrade operation is an add operation, a file with a target file identifier in the target firmware is obtained from the upgrade server, and the obtained file is added to the original firmware; in another implementation mode, if the target upgrading operation is a modification operation, a target update file is obtained from an upgrading server, and the file with the target file identification in the original firmware is updated by using the target update file; and the target update file is obtained based on a file with a target file identification in the target firmware.
Optionally, in an embodiment, the target update file is: the step of updating the file with the target file identifier in the original firmware by using the target update file may include:
and replacing the file with the target file identification in the original firmware by using the file with the target file identification in the target firmware.
The target update file is a differential file obtained by binary differential of a file with a target file identifier in the original firmware and the file with the target file identifier in the target firmware by the upgrade server; in this case, the step of updating the file with the target file identifier in the original firmware by using the target update file may include: and adding the differential file into a file with the target file identification in the original firmware.
The binary difference is to compare the new file with the original file in binary, extract the difference part, and only update the difference part when upgrading the device, so as to save the flow and the upgrading time.
According to the technical scheme provided by the embodiment of the invention, because the description file is a preset file for recording the content attribute of each file in the firmware to which the description file belongs, when the firmware needs to be upgraded, the difference information between the original firmware and the target firmware can be determined by using the first description file of the original firmware and the second description file of the target firmware, and binary difference does not need to be carried out on the files in the firmware, so that the firmware upgrading efficiency is improved.
Optionally, in an embodiment, the difference information may be obtained from the upgrade server, and the difference information is further used to indicate: when the target upgrading operation is an increasing operation, a first download address of a file to be increased, or when the target upgrading operation is a modifying operation, a second download address of a target updating file; the file to be added is a file with a target file identifier;
at this time, the file with the target file identifier in the target firmware may be obtained from the upgrade server according to the first download address, and the target update file may be obtained from the upgrade server according to the second download address.
According to the technical scheme provided by the embodiment of the invention, because the description file is a preset file for recording the content attribute of each file in the firmware to which the description file belongs, when the firmware needs to be upgraded, the difference information between the original firmware and the target firmware can be determined by using the first description file of the original firmware and the second description file of the target firmware, and binary difference does not need to be carried out on the files in the firmware, so that the firmware upgrading efficiency is improved.
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the embodiments of the present invention are described below from an offline mode and an online mode, respectively.
As shown in fig. 3, which is a schematic structural diagram of an upgrade package in an offline mode, each firmware in the upgrade package is derived from a specified version of firmware stored in a warehouse and already in an internal release state, each firmware may be composed of one file or a plurality of files and directories (the directories are represented as files in the upgrade package), and the upgrade package is encrypted in units of files, so that malicious tampering of content can be prevented.
Furthermore, the upgrading process includes the steps of sorting the files and the directory names from small to large according to the character sequence of the files, and then forming a new binary file by connecting the encrypted binary data of the files according to the sorting sequence. Meanwhile, a description file, i.e., a file describing information of each upgrade file in fig. 3, is added to the header, and an encrypted header (referred to as header information in the foregoing) is added to the front of the description file.
When the electronic equipment is connected with the upgrading client through the local area network, the electronic equipment firstly receives the head information of the off-line upgrading packet, so that the offset and the size of the description file in the binary upgrading packet are known, and the offset and the size of the description file are fed back to the upgrading client. After the description file is obtained, the description file is analyzed, and version information and hash values of all files in the target firmware recorded in the description file are extracted.
If the directory does not exist in the electronic equipment, the directory needs to be created according to the information of the recorded target file in the description file, and for the ordinary file of the non-directory file, the version, the information and the hash value need to be compared with the corresponding file in the original firmware in the electronic equipment, so as to extract the file identifier, the offset and the size of the file with different version information and hash value, and feed back the file identifier, the offset and the size to the upgrade client, so that the upgrade client reads the data in the binary upgrade package according to the fed file identifier, the offset and the size and sends the data to the electronic equipment.
For the online mode, when the electronic device needs to upgrade the firmware, the electronic device first initiates a differential upgrade request to the upgrade server, and informs the upgrade server of the version of the original firmware running in the electronic device and the version of the target firmware that is expected to be upgraded. After receiving the request of differential upgrading, the upgrading server firstly obtains a first description file of the original firmware and a second description file of the target firmware, and then downloads files to which content attributes in the first description file and the second description file belong respectively.
Traversing the content attribute of each file in the first description file and the second description file, and if the file is a directory file, directly recording the content attribute into a new difference description file; if the new upgrade package exists and the old upgrade package does not exist, recording the difference description file and marking the difference description file as a new file; if the old upgrade package exists and the new upgrade package does not exist, recording the difference description file and marking the difference description file as a deleted file; if the new and old upgrade packages exist, comparing version information and hash values of the files, carrying out binary differential calculation under the condition that the version information or the hash values are different to obtain binary files of different parts, recording information of the produced differential files, including names, download addresses and the like, into a differential description file, and marking the differential description file as modified;
optionally, in an implementation manner, the differentiated content digest of each file is signed by a private key in the upgrade server, and the signature information is stored in the content digest of each file. After the electronic device obtains the difference description file, the electronic device verifies the signature information by using the corresponding public key, so that the source of the file is judged to be reliable and the file is not tampered.
And the upgrading server returns the difference description file to the electronic equipment. And the electronic equipment performs corresponding processing according to the difference description file returned by the upgrading server. If the directory file is yes, judging whether the directory file exists or not, and if not, creating a directory; otherwise, judging whether the file attribute is newly added, normally creating and writing the file if the file attribute is newly added, deleting the attribute, releasing the storage space of the original file of the equipment, modifying the attribute, and executing the patch to update the old file.
According to the technical scheme provided by the embodiment of the invention, because the description file is a preset file for recording the content attribute of each file in the firmware to which the description file belongs, when the firmware needs to be upgraded, the difference information between the original firmware and the target firmware can be determined by using the first description file of the original firmware and the second description file of the target firmware, and binary difference does not need to be carried out on the files in the firmware, so that the firmware upgrading efficiency is improved.
Corresponding to the method provided by the foregoing embodiment, as shown in fig. 4, an embodiment of the present invention further provides a firmware upgrading apparatus, which is applied to an electronic device, where original firmware to be upgraded is set in the electronic device, and the apparatus includes:
a first file obtaining module 401, configured to obtain a description file of an original firmware as a first description file; the description file is a preset file for recording the content attribute of each file in the firmware to which the description file belongs;
an information obtaining module 402, configured to obtain difference information determined by using the first description file and the second description file; wherein the second description file is: the original firmware is to be upgraded into a description file of the target firmware, and the difference information is used for indicating: target file identification and target upgrading operation of files with different contents between original firmware and target firmware;
and an operation executing module 403, configured to execute a target upgrade operation to upgrade the original firmware by using the file indicated by the target file identifier.
Optionally, in an embodiment, the apparatus further includes:
the difference information determining module is used for comparing the content attributes of the first description file and the second description file; if the first content attribute only appearing in the first description file exists, determining the file identifier of the first file to which the first content attribute belongs as a target file identifier and the target upgrading operation as a deleting operation; if the second content attribute only appearing in the second description file exists, determining the file identifier of the second file to which the second content attribute belongs as a target file identifier and performing target upgrading operation as increasing operation; if the second description file has a fourth content attribute corresponding to the third content attribute, determining the file identifier of the third file to which the third content attribute belongs as a target file identifier and the target upgrading operation as a modifying operation; the third content attribute is a content attribute in the first description file, and the fourth content attribute is different from the third content attribute and belongs to the same file.
Optionally, in an embodiment, the apparatus further includes:
the second file acquisition module is used for acquiring the header information of the upgrading packet of the target firmware before the difference information determination module compares the content attributes of the first description file and the second description file; wherein the header information indicates location information of a second description file in the upgrade package; and acquiring a second description file from the upgrade package based on the position information.
Optionally, in an embodiment, the content attribute of each file includes version information and a hash value to which the file belongs;
and the difference information determining module is specifically used for comparing the version information and the hash value of the file of the first description file and the second description file.
Optionally, in an embodiment, the target upgrade operation is: add, delete, or modify operations;
the operation execution module is specifically used for acquiring a file with a target file identifier in the target firmware and adding the acquired file into the original firmware if the target upgrading operation is an increasing operation; if the target upgrading operation is a deleting operation, deleting the file with the target file identification from the original firmware; and if the target upgrading operation is a modification operation, updating the file with the target file identification in the original firmware based on the file with the target file identification in the target firmware.
Optionally, in an embodiment, the electronic device is connected to the upgrade client through a local area network;
the operation execution module is specifically used for acquiring a file with a target file identifier in the target firmware from the upgrading client if the target upgrading operation is an adding operation, and adding the acquired file into the original firmware; if the target upgrading operation is a modification operation, acquiring a file with a target file identifier in the target firmware from the upgrading client, and replacing the file with the target file identifier in the original firmware by using the acquired file.
Optionally, in an embodiment, the electronic device is connected to the upgrade server through the internet;
the operation execution module is specifically used for acquiring a file with a target file identifier in the target firmware from the upgrade server and adding the acquired file into the original firmware if the target upgrade operation is an increase operation; if the target upgrading operation is a modification operation, acquiring a target updating file from an upgrading server, and updating a file with a target file identifier in the original firmware by using the target updating file; and the target update file is obtained based on a file with a target file identification in the target firmware.
Optionally, in an embodiment, the target update file is: a file in the target firmware having a target file identifier;
and the operation execution module is specifically used for replacing the file with the target file identifier in the original firmware by using the file with the target file identifier in the target firmware.
Optionally, in an embodiment, the target update file is: the upgrade server performs binary differential on a file with a target file identifier in the original firmware and a file with the target file identifier in the target firmware to obtain a differential file;
and the operation execution module is specifically used for adding the differential file into a file with a target file identifier in the original firmware.
Optionally, in an embodiment, the difference information is obtained from the upgrade server, and the difference information is further used to indicate: when the target upgrading operation is an adding operation, a first download address of a file to be added is obtained, or when the target upgrading operation is a modifying operation, a second download address of a target updating file is obtained, wherein the file to be added is a file with a target file identifier;
the operation execution module is specifically used for acquiring a file with a target file identifier in the target firmware from the upgrade server according to the first download address; and acquiring the target update file from the upgrade server according to the second download address.
According to the technical scheme provided by the embodiment of the invention, because the description file is a preset file for recording the content attribute of each file in the firmware to which the description file belongs, when the firmware needs to be upgraded, the difference information between the original firmware and the target firmware can be determined by using the first description file of the original firmware and the second description file of the target firmware, and binary difference does not need to be carried out on the files in the firmware, so that the firmware upgrading efficiency is improved.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the apparatus, device, and system embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference may be made to some descriptions of the method embodiments for relevant points.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (10)

1. A firmware upgrading method is characterized in that the method is applied to electronic equipment, and original firmware to be upgraded is arranged in the electronic equipment; the method comprises the following steps:
acquiring a description file of the original firmware as a first description file; the description file is a preset file for recording the content attribute of each file in the firmware to which the description file belongs;
acquiring difference information determined by using the first description file and the second description file; wherein the second description file is: the original firmware is to be upgraded into a description file of a target firmware, and the difference information is used for indicating: target file identification and target upgrading operation of the file with content difference between the original firmware and the target firmware;
and executing the target upgrading operation by using the file indicated by the target file identification so as to upgrade the original firmware.
2. The method of claim 1, wherein determining the difference information using the first description file and the second description file comprises:
comparing the content attributes of the first description file and the second description file;
if the first content attribute only appearing in the first description file exists, determining the file identifier of the first file to which the first content attribute belongs as a target file identifier and the target upgrading operation as a deleting operation;
if the second content attribute only appearing in the second description file exists, determining the file identifier of the second file to which the second content attribute belongs as a target file identifier and performing target upgrading operation as adding operation;
if a fourth content attribute corresponding to the third content attribute exists in the second description file, determining a file identifier of a third file to which the third content attribute belongs as a target file identifier and performing target upgrading operation as modification operation; the third content attribute is a content attribute in the first description file, and the fourth content attribute is different from the third content attribute and belongs to the same file.
3. The method according to claim 2, further comprising, before the comparing the content attributes of the first description file and the second description file:
acquiring the header information of an upgrade package where the target firmware is located; wherein the header information indicates location information of the second description file in the upgrade package;
and acquiring the second description file from the upgrade package based on the position information.
4. The method according to claim 2 or 3, wherein the content attribute of each file comprises version information and a hash value to which the file belongs;
the comparing the content attributes of the first description file and the second description file includes:
and comparing the version information and the hash value of the file of the first description file with the version information and the hash value of the second description file.
5. The method of any of claims 1 to 3, wherein the target upgrade operation is to: add, delete, or modify operations;
the executing the target upgrade operation by using the file indicated by the target file identifier to upgrade the original firmware includes:
if the target upgrading operation is an adding operation, acquiring a file with the target file identifier in the target firmware, and adding the acquired file into the original firmware;
if the target upgrading operation is a deleting operation, deleting the file with the target file identification from the original firmware;
and if the target upgrading operation is a modification operation, updating the file with the target file identification in the original firmware based on the file with the target file identification in the target firmware.
6. The method of claim 5, wherein the electronic device is connected to an upgrade client via a local area network;
if the target upgrading operation is an adding operation, acquiring a file with the target file identifier in the target firmware, and adding the acquired file into the original firmware, including:
if the target upgrading operation is an adding operation, acquiring a file with the target file identifier in the target firmware from the upgrading client, and adding the acquired file into the original firmware;
if the target upgrading operation is a modification operation, updating the file with the target file identifier in the original firmware based on the file with the target file identifier in the target firmware, including:
if the target upgrading operation is a modification operation, acquiring a file with the target file identification in the target firmware from the upgrading client, and replacing the file with the target file identification in the original firmware by using the acquired file.
7. The method of claim 5, wherein the electronic device is connected to an upgrade server via the internet;
if the target upgrading operation is an adding operation, acquiring a file with the target file identifier in the target firmware, and adding the acquired file into the original firmware, including:
if the target upgrading operation is an adding operation, acquiring a file with the target file identifier in the target firmware from the upgrading server, and adding the acquired file into the original firmware;
if the target upgrading operation is a modification operation, updating the file with the target file identifier in the original firmware based on the file with the target file identifier in the target firmware, including:
if the target upgrading operation is a modification operation, acquiring a target updating file from the upgrading server, and updating the file with the target file identification in the original firmware by using the target updating file; and the target update file is obtained based on a file with the target file identification in the target firmware.
8. The method of claim 7,
the target update file is: a file in the target firmware having the target file identification;
the updating the file with the target file identification in the original firmware by using the target update file comprises:
and replacing the file with the target file identification in the original firmware by using the file with the target file identification in the target firmware.
9. The method of claim 7,
the target update file is: the upgrade server performs binary difference on the file with the target file identifier in the original firmware and the file with the target file identifier in the target firmware to obtain a differential file;
the updating the file with the target file identification in the original firmware by using the target update file comprises:
and adding the differential file into a file with the target file identification in the original firmware.
10. A firmware upgrading device applied to an electronic device, wherein original firmware to be upgraded is set in the electronic device, the device comprising:
the first file acquisition module is used for acquiring the description file of the original firmware as a first description file; the description file is a preset file for recording the content attribute of each file in the firmware to which the description file belongs;
the information acquisition module is used for acquiring the difference information determined by the first description file and the second description file; wherein the second description file is: the original firmware is to be upgraded into a description file of a target firmware, and the difference information is used for indicating: target file identification and target upgrading operation of the file with content difference between the original firmware and the target firmware;
and the operation execution module is used for executing the target upgrading operation by using the file indicated by the target file identification so as to upgrade the original firmware.
CN202111016767.XA 2021-08-31 2021-08-31 Firmware upgrading method and device Active CN113721968B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111016767.XA CN113721968B (en) 2021-08-31 2021-08-31 Firmware upgrading method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111016767.XA CN113721968B (en) 2021-08-31 2021-08-31 Firmware upgrading method and device

Publications (2)

Publication Number Publication Date
CN113721968A true CN113721968A (en) 2021-11-30
CN113721968B CN113721968B (en) 2024-04-02

Family

ID=78680143

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111016767.XA Active CN113721968B (en) 2021-08-31 2021-08-31 Firmware upgrading method and device

Country Status (1)

Country Link
CN (1) CN113721968B (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20080083512A (en) * 2007-03-12 2008-09-18 (주)프레스토블루 Firmware over the air system
CN102387165A (en) * 2010-08-27 2012-03-21 腾讯科技(深圳)有限公司 System and method for upgrading software
US20120290596A1 (en) * 2011-05-12 2012-11-15 Samsung Electronics Co. Ltd. Stabilized binary differencing
CN103136013A (en) * 2011-12-01 2013-06-05 腾讯科技(深圳)有限公司 Method and system of software upgrade
US20160291967A1 (en) * 2015-03-30 2016-10-06 Konica Minolta Laboratory U.S.A., Inc. Method and system for updating firmware
CN107066303A (en) * 2017-05-04 2017-08-18 深圳市欧瑞博电子有限公司 Firmware comparison method and device
CN109189460A (en) * 2018-11-20 2019-01-11 北京千丁互联科技有限公司 offline firmware upgrade system and method
CN110377308A (en) * 2019-07-18 2019-10-25 上海擎感智能科技有限公司 Data updating method, system
CN112000355A (en) * 2020-08-21 2020-11-27 青岛海尔科技有限公司 Method and device for firmware upgrading and household appliance

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20080083512A (en) * 2007-03-12 2008-09-18 (주)프레스토블루 Firmware over the air system
CN102387165A (en) * 2010-08-27 2012-03-21 腾讯科技(深圳)有限公司 System and method for upgrading software
US20120290596A1 (en) * 2011-05-12 2012-11-15 Samsung Electronics Co. Ltd. Stabilized binary differencing
CN103136013A (en) * 2011-12-01 2013-06-05 腾讯科技(深圳)有限公司 Method and system of software upgrade
US20160291967A1 (en) * 2015-03-30 2016-10-06 Konica Minolta Laboratory U.S.A., Inc. Method and system for updating firmware
CN107066303A (en) * 2017-05-04 2017-08-18 深圳市欧瑞博电子有限公司 Firmware comparison method and device
CN109189460A (en) * 2018-11-20 2019-01-11 北京千丁互联科技有限公司 offline firmware upgrade system and method
CN110377308A (en) * 2019-07-18 2019-10-25 上海擎感智能科技有限公司 Data updating method, system
CN112000355A (en) * 2020-08-21 2020-11-27 青岛海尔科技有限公司 Method and device for firmware upgrading and household appliance

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
王高洲;: "基于网络监听的嵌入式系统固件获取方法", 信息系统工程, no. 07 *

Also Published As

Publication number Publication date
CN113721968B (en) 2024-04-02

Similar Documents

Publication Publication Date Title
US11500897B2 (en) Allocation and reassignment of unique identifiers for synchronization of content items
US8073926B2 (en) Virtual machine image server
US7849462B2 (en) Image server
CN109995866B (en) Distributed file verification method and device, computer device and storage medium
CN107786638B (en) Data processing method, device and system
CN108491715B (en) Terminal fingerprint database generation method and device and server
KR20130012929A (en) Method and system for efficient download of data package
CN107704465B (en) Static resource updating method and static resource management system
CN112839076B (en) Data storage method, data reading method, gateway, electronic equipment and storage medium
CN111881150A (en) Web application program offline data processing method and device
CN104699511A (en) Plug-in upgrading method and plug-in upgrading device
CN113395340A (en) Information updating method, device, equipment, system and readable storage medium
JP2012531644A (en) System, method and computer program for marking required content items on a network media device
CN113596087A (en) Application upgrading method and device and computer readable storage medium
CN113721968B (en) Firmware upgrading method and device
CN115686665A (en) Plug-in quick access method, device and storage medium
CN112433741B (en) Page processing method, device and system, electronic equipment and storage medium
CN110083509B (en) Method and device for arranging log data
CN114491653A (en) Data content tamper-proof system, method and device
CN109857719B (en) Distributed file processing method, device, computer equipment and storage medium
CN114077587A (en) Rule engine based business processing method, rule engine, medium and device
CN105812894A (en) Video file processing method and device based on intelligent terminal
CN111586170A (en) Resource downloading method, device, equipment and computer readable storage medium
US20220405244A1 (en) Batch deletion method and apparatus for cache contents, device and readable storage medium
CN111147888B (en) Streaming media video data processing method and device, computer equipment 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
GR01 Patent grant