Firmware upgrading method and device, electronic equipment and storage medium
Through the combination of differential upgrade package and target differential algorithm, the problem of low efficiency of traditional firmware upgrade is solved, a faster firmware upgrade process is achieved, and the upgrade efficiency is improved.
Patent Information
- Application Number
- CN202411133068.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2025-01-07
AI Technical Summary
Traditional firmware upgrade methods require downloading and installing complete firmware files, resulting in low upgrade efficiency and long time.
Differential upgrade packages are used to perform differential operations on the firmware upgrade packages of different versions through the target differential algorithm, and only differential upgrade packages are sent. Electronic devices restore operations based on the differential upgrade package and existing firmware upgrade packages to obtain the target firmware upgrade package and realize firmware upgrade. .
It reduces the amount of data sent by the cloud, shortens the data transmission time, improves firmware upgrade efficiency, and reduces the transmission time of upgrade packets.
Smart Images

Figure CN119271253A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of electronic information technology, and more specifically, to a firmware upgrade method, device, electronic device, and computer-readable storage medium. Background Art
[0002] With the rapid development of Internet of Things technology, electronic devices such as smartphones, tablets, smart home devices, and in-vehicle terminals need to update their firmware regularly to maintain the optimal performance of electronic devices, fix potential security vulnerabilities in electronic devices, or add new functions to electronic devices.
[0003] However, the traditional firmware upgrade method requires downloading and installing the complete firmware file, which is time-consuming and leads to low firmware upgrade efficiency. Therefore, a method is urgently needed to improve the firmware upgrade efficiency. Summary of the invention
[0004] The present application proposes a firmware upgrade method, device, electronic device and computer-readable storage medium to improve the efficiency of firmware upgrade.
[0005] In a first aspect, an embodiment of the present application provides a firmware upgrade method, the method comprising:
[0006] Receive a differential upgrade package sent from the cloud; the differential upgrade package is obtained by performing differential operations on a first firmware upgrade package and a second firmware upgrade package of different versions through a target differential algorithm; the target differential algorithm is determined based on at least one of the computing resources of the electronic device, the size of the first firmware upgrade package, the size of the second firmware upgrade package, the size of the upgrade package difference data, and the target data type; the first firmware upgrade package is a firmware upgrade package corresponding to the firmware installed on the electronic device; the upgrade package difference data refers to the difference data between the first firmware upgrade package and the second firmware upgrade package; the target data type is the data type to which the data in the first firmware upgrade package and / or the second firmware upgrade package belongs;
[0007] A target restoration algorithm corresponding to the target difference algorithm performs restoration operation based on the difference upgrade package and the existing firmware upgrade package to obtain a target firmware upgrade package; the existing firmware upgrade package is obtained after the electronic device stores the first firmware upgrade package;
[0008] Perform firmware upgrade via the target firmware upgrade package.
[0009] In a second aspect, an embodiment of the present application further provides a firmware upgrade device, the device comprising:
[0010] A receiving module, used for receiving a differential upgrade package sent from the cloud; the differential upgrade package is obtained by performing differential operations on a first firmware upgrade package and a second firmware upgrade package of different versions through a target differential algorithm; the target differential algorithm is determined based on at least one of the computing resources of the electronic device, the size of the first firmware upgrade package, the size of the second firmware upgrade package, the size of the upgrade package difference data, and a target data type; the first firmware upgrade package is a firmware upgrade package corresponding to the firmware installed on the electronic device; the upgrade package difference data refers to the difference data between the first firmware upgrade package and the second firmware upgrade package; the target data type is the data type to which the data in the first firmware upgrade package and / or the second firmware upgrade package belongs;
[0011] A determination module, configured to perform a restoration operation based on the differential upgrade package and the existing firmware upgrade package using a target restoration algorithm corresponding to the target differential algorithm, to obtain a target firmware upgrade package; the existing firmware upgrade package is obtained after the electronic device stores the first firmware upgrade package;
[0012] The upgrade module is used to upgrade the firmware through the target firmware upgrade package.
[0013] In a third aspect, an embodiment of the present application further provides an electronic device, characterized in that the electronic device comprises: one or more processors; a memory; one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the above method.
[0014] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores a program code executable by a processor, and when the program code is executed by the processor, the processor executes the above method.
[0015] The present application provides a firmware upgrade method, device, electronic device and computer-readable storage medium. In the present application, the electronic device receives a differential upgrade package sent from the cloud, and the differential upgrade package is obtained by performing a differential operation on a first firmware upgrade package and a second firmware upgrade package of different versions through a target differential algorithm; then, a target restoration algorithm corresponding to the target differential algorithm is used to perform a restoration operation based on the differential upgrade package and an existing firmware upgrade package obtained after storing the first firmware upgrade package to obtain a target firmware upgrade package; and then, the firmware is upgraded through the target firmware upgrade package. The cloud only needs to send the differential upgrade package, and the electronic device can obtain a target firmware upgrade package consistent with the second firmware upgrade package based on the differential upgrade package and the existing firmware upgrade package, and the cloud does not need to send the complete second firmware upgrade package, which reduces the amount of data sent by the cloud, thereby greatly reducing the data transmission time between the cloud and the electronic device, thereby reducing the transmission time of the upgrade package and improving the firmware upgrade efficiency.
[0016] Other features and advantages of the embodiments of the present application will be described in the subsequent description, and partly become apparent from the description, or can be understood by practicing the embodiments of the present application. The purposes and other advantages of the embodiments of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0018] Figure 1 A flowchart of a firmware upgrade method proposed in one embodiment of the present application is shown.
[0019] Figure 2 A flowchart of generating a differential upgrade package and a configuration file in the cloud in an embodiment of the present application is shown.
[0020] Figure 3 A flowchart of firmware upgrade of an electronic device in an embodiment of the present application is shown.
[0021] Figure 4 A structural block diagram of a firmware upgrade device proposed in an embodiment of the present application is shown.
[0022] Figure 5 A structural block diagram of an electronic device provided according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0023] In order to make those skilled in the art better understand the present application scheme, the technical scheme in the present application embodiment will be clearly and completely described below in conjunction with the drawings in the present application embodiment. Obviously, the described embodiment is only a part of the present application embodiment, rather than all the embodiments. The components of the present application embodiment usually described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the present application for protection, but merely represents the selected embodiment of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0024] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0025] See also Figure 1 , Figure 1 A flowchart of a firmware upgrade method proposed in one embodiment of the present application is shown, which is used for an electronic device. The method includes:
[0026] S110. Receive the differential upgrade package sent by the cloud.
[0027] The differential upgrade package is obtained by performing differential calculation on the first firmware upgrade package and the second firmware upgrade package of different versions through a target differential algorithm; the target differential algorithm is determined based on at least one of the computing resources of the electronic device, the size of the first firmware upgrade package, the size of the second firmware upgrade package, the size of the upgrade package difference data, and the target data type; the first firmware upgrade package is the firmware upgrade package corresponding to the firmware installed on the electronic device; the upgrade package difference data refers to the difference data between the first firmware upgrade package and the second firmware upgrade package; the target data type is the data type to which the data in the first firmware upgrade package and / or the second firmware upgrade package belongs. The data type may include multimedia data or text data, etc.
[0028] The electronic device in this embodiment can be a smart phone, a tablet computer, a laptop computer, a desktop computer, an intelligent voice interaction device, a smart home appliance, a vehicle terminal, an aircraft, etc., but is not limited thereto.
[0029] The cloud can be a server that is connected to electronic devices and provides firmware upgrade packages for electronic devices. The server can be an independent physical server or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (CDN), as well as big data and artificial intelligence platforms.
[0030] A firmware upgrade package is a software package used to update or upgrade the firmware of an electronic device. It contains new firmware programs, drivers, and other necessary files to update the software version of the electronic device from the old version to the new version. This process usually requires following specific steps and instructions to ensure that the device is not damaged during the upgrade process. The purpose of the firmware upgrade package is to improve the performance and functionality of the device, fix possible vulnerabilities and problems, and enhance the security of the device.
[0031] The firmware upgrade package in the present application may be a firmware upgrade package for some modules in the electronic device (for example, a graphics processor, an audio processor, etc. in the electronic device), or may be a firmware upgrade package for the entire electronic device.
[0032] The first firmware upgrade package is an upgrade package corresponding to the firmware installed in the electronic device, that is, the firmware currently used by the electronic device is obtained by installing the first firmware upgrade package. The first firmware upgrade package and the second firmware upgrade package have different versions. Generally speaking, the version of the second firmware upgrade package is higher than the version of the first firmware upgrade package, that is, the first firmware upgrade package is an old version of the firmware upgrade package, and the second firmware upgrade package is a new version of the firmware upgrade package. In other embodiments, the first firmware upgrade package may also be a new version of the firmware upgrade package, and the second firmware upgrade package may be an old version of the firmware upgrade package, thereby realizing firmware restoration.
[0033] The cloud can send a first firmware upgrade package to an electronic device, and the electronic device installs the first firmware upgrade package to implement a firmware upgrade of the electronic device through the first firmware upgrade package. At the same time, the cloud can record the version of the first firmware upgrade package. After obtaining a firmware upgrade package with a different version from the first firmware upgrade package, the firmware upgrade package with a different version from the first firmware upgrade package can be used as a second firmware upgrade package, and then the first firmware upgrade package and the second firmware upgrade package with different versions are differentially calculated through a target differential algorithm to obtain a differential upgrade package, and the differential upgrade package is sent to the electronic device.
[0034] It is worth mentioning that when the cloud obtains a second firmware upgrade package with a higher version than the first firmware upgrade package, it can obtain upgrade prompt information and send the upgrade prompt information to the electronic device. When the electronic device returns an upgrade instruction based on the upgrade prompt information, the cloud performs a differential operation on the first firmware upgrade package and the second firmware upgrade package with different versions through a target differential algorithm to obtain a differential upgrade package. Among them, the electronic device can display the upgrade prompt information, and then the electronic device can return the upgrade instruction in response to the confirmation operation of the upgrade prompt information. Among them, the confirmation operation of the upgrade prompt information can be clicking on the upgrade prompt information, long pressing the upgrade prompt information, etc., which is not limited in this application.
[0035] In another embodiment, the cloud can receive the recovery request from the server and obtain the second firmware upgrade package corresponding to the reply request. At this time, the version of the second firmware upgrade package may be no higher than the version of the first firmware upgrade package. After that, the cloud performs a differential operation on the first firmware upgrade package and the second firmware upgrade package of different versions through a target differential algorithm to obtain a differential upgrade package. The reply request may include version indication information, and the cloud obtains the second firmware upgrade package according to the version indication information, wherein the version indication information may be a version number, a version name, etc.
[0036] In the present application, upgrade package difference data between the first firmware upgrade package and the second firmware upgrade package may be determined by a target difference algorithm as a differential upgrade package.
[0037] The corresponding target differential algorithm can be determined based on at least one of the computing resources of the electronic device, the size of the first firmware upgrade package, the size of the second firmware upgrade package, the size of the upgrade package difference data, and the target data type, wherein the computing resources of the electronic device include at least one of the central processing unit resources, the memory resources, and the hard disk resources. The differential algorithms involved in this application may include the BSDi ff algorithm, the XDelta3 algorithm, the HDi ffPatch algorithm, etc.
[0038] The computing resources of the electronic device are different, and the selected target differential algorithm is different. For example, when the computing resources of the electronic device are large, the HDi ffPatch algorithm can be determined as the target differential algorithm. When the computing resources of the electronic device are small, the BSDi ff algorithm or the XDe l ta3 algorithm can be determined as the target differential algorithm.
[0039] When the size of the upgrade package difference data is different, the determined target difference algorithm is different. For example, when the upgrade package difference data is small, the HDi ffPatch algorithm can be determined as the target difference algorithm. When the upgrade package difference data is large, the BSDi ff algorithm or XDe l ta3 algorithm can be determined as the target difference algorithm.
[0040] When the size of the firmware upgrade package is different, the determined target differential algorithm is also different. For example, when the firmware upgrade package (the first firmware upgrade package, the second firmware upgrade package, or the merged upgrade package of the two) is small, the HDiffPatch algorithm can be determined as the target differential algorithm. When the firmware upgrade package (the first firmware upgrade package, the second firmware upgrade package, or the merged upgrade package of the two) is large, the BSDi ff algorithm or the XDe l ta3 algorithm can be determined as the target differential algorithm.
[0041] When the target data type is different, the selected target differential algorithm may also be different. Exemplarily, when the target data type is a multimedia data type (such as pictures, audio or video, etc.), it means that the data redundancy in the first firmware upgrade package and the second firmware upgrade package is very high, and the target differential algorithm may include a data compression algorithm and a combination of the aforementioned three differential algorithms, that is, firstly perform data compression through a data compression algorithm, and then perform differential operations through the aforementioned differential algorithms to implement differential operations of the target differential algorithm and obtain a differential upgrade package; wherein the compression algorithm may include a png data compression algorithm and an inter-frame prediction algorithm, etc.
[0042] For example, the target differential algorithm is a combination of the png data compression algorithm and the XDe l ta3 algorithm, that is, the first firmware upgrade package and the second firmware upgrade package are compressed by the png data compression algorithm, and then the compressed first firmware upgrade package and the compressed second firmware upgrade package are differentially operated by the XDe l ta3 algorithm to obtain a differential upgrade package.
[0043] Exemplarily, when the target data type is a character data type, it indicates that the data redundancy in the first firmware upgrade package and the second firmware upgrade package is not high, and data compression does not need to be performed through a data compression algorithm. One of the BSDiff algorithm, XDe l ta3 algorithm, and HDi ffPatch algorithm can be directly selected as the target differential algorithm, that is, the differential operation is directly performed through the aforementioned differential algorithm to implement the differential operation of the target differential algorithm and obtain a differential upgrade package.
[0044] Of course, the target differential algorithm may also be determined by combining the computing resources of the electronic device, the size of the first firmware upgrade package, the size of the second firmware upgrade package, the size of the upgrade package difference data, and multiple items of the target data type.
[0045] For example, since the BSDi ff algorithm has stable performance, simple implementation, and low resource consumption, when the upgrade package difference data is small and the computing resources of the electronic device are small, the BSDi ff algorithm is determined as the target difference algorithm.
[0046] For example, the XDe l ta3 algorithm has complex parameters and a high compression rate, but it also has high requirements for memory and hard disk. Therefore, when the first firmware upgrade package is large, the second firmware upgrade package is large, and the computing resources of the electronic device are large, the XDe l ta3 algorithm is determined as the target differential algorithm.
[0047] For example, the HDi ffPatch algorithm has a better differential effect when the data volume is large, the CPU requirements are relatively high, and the difference between the new and old versions is relatively large; then when the upgrade package difference data is large, the first firmware upgrade package is large, the second firmware upgrade package is large, and the computing resources of the electronic device are large, the HDi ffPatch algorithm is determined as the target differential algorithm.
[0048] S120 , performing a restoration operation based on the differential upgrade package and the existing firmware upgrade package using a target restoration algorithm corresponding to the target differential algorithm to obtain a target firmware upgrade package.
[0049] The existing firmware upgrade package is obtained after the electronic device stores the first firmware upgrade package.
[0050] After the electronic device obtains the first firmware upgrade package, the firmware of the electronic device can be upgraded through the first firmware upgrade package, and then the first firmware upgrade package is directly stored locally to obtain an existing firmware upgrade package. At this time, the data in the existing firmware upgrade package is exactly the same as that in the first firmware upgrade package.
[0051] In some embodiments, after the electronic device performs a firmware upgrade on the electronic device through the first firmware upgrade package, the first firmware upgrade package can also be stored in the format of a drive letter device, and the stored data is an existing firmware upgrade package. At this time, the data in the existing firmware upgrade package is not exactly the same as the data in the first firmware upgrade package.
[0052] The electronic device can obtain a target restoration algorithm corresponding to the target differential algorithm from the cloud, and then perform a restoration operation based on the differential upgrade package and the existing firmware upgrade package through the target restoration algorithm to restore a target firmware upgrade package that is consistent with the second firmware upgrade package.
[0053] It is worth mentioning that if the existing firmware upgrade package is obtained by directly storing the first firmware upgrade package, the target restoration algorithm is used to directly perform a restoration operation based on the differential upgrade package and the existing firmware upgrade package to restore the target firmware upgrade package that is consistent with the second firmware upgrade package; if the existing firmware upgrade package is obtained by storing the first firmware upgrade package in the format of a drive letter device, it is necessary to take out the existing firmware upgrade package, and then convert the format of the existing firmware upgrade package to obtain a preprocessed firmware upgrade package that is consistent with the data format of the first firmware upgrade package, and then the target restoration algorithm is used to perform a restoration operation based on the differential upgrade package and the preprocessed firmware upgrade package to restore the target firmware upgrade package that is consistent with the second firmware upgrade package.
[0054] In some embodiments, before S120, the method further includes: receiving a configuration file sent from the cloud; the configuration file includes a target algorithm identifier corresponding to the target differential algorithm; and obtaining a target restoration algorithm corresponding to the target differential algorithm from a locally stored algorithm set according to the target algorithm identifier.
[0055] The cloud may send the configuration file and the differential upgrade package to the electronic device at the same time, or the cloud may send the configuration file and the differential upgrade package to the electronic device at different sending times, which is not limited here.
[0056] The target algorithm identifier is used to indicate the target differential algorithm, and different differential algorithms are indicated by different algorithm identifiers. The algorithm identifier can be the name, category or label of the differential algorithm, etc., which is not limited in this application. For example, when the target differential algorithm is the HDiffPatch algorithm, the target algorithm identifier is "HDiffPatch algorithm". For example, when the target differential algorithm is a combination of the png data compression algorithm and the HDiffPatch algorithm, the target algorithm identifier is "png data compression algorithm + HDiffPatch algorithm".
[0057] One differential algorithm corresponds to one restoration algorithm, and the differential algorithm and restoration algorithm with corresponding relationship are used to perform differential operation and restoration operation respectively: the differential algorithm is used to perform differential operation on data, and the restoration algorithm corresponding to the differential algorithm is used to perform restoration operation on the data after the differential operation of the differential algorithm, so as to restore the data.
[0058] For example, the restoration algorithm corresponding to the differential algorithm BSDi ff algorithm is the BSPatch algorithm, that is, the BSDi ff algorithm is used to perform differential operations on data, and the BSPatch algorithm is used to perform restoration operations on the data after the differential operation of the BSDi ff algorithm, so as to restore the data.
[0059] The algorithm set may store restoration algorithms corresponding to different algorithm identifiers, wherein the restoration algorithm corresponding to an algorithm identifier is the restoration algorithm corresponding to the differential algorithm indicated by the algorithm identifier, and the restoration algorithm corresponding to the target algorithm identifier of the target differential algorithm is used as the target restoration algorithm. For example, when the target differential algorithm is the BSDi ff algorithm, the restoration algorithm corresponding to the algorithm identifier of the BSDi ff algorithm is the BSPatch algorithm, and the BSPatch algorithm is the target restoration algorithm.
[0060] That is to say, the electronic device stores the target restoration algorithm locally, so there is no need to send the target restoration algorithm to the cloud. Only the target algorithm identifier of the target differential algorithm needs to be sent. The amount of data of the target algorithm identifier is much smaller than the amount of data of the target restoration algorithm, thereby reducing the data sent from the cloud to the electronic device, improving data transmission efficiency, and reducing network transmission pressure.
[0061] S130: Perform firmware upgrade via the target firmware upgrade package.
[0062] After obtaining the target firmware upgrade package, the firmware upgrade can be performed through the target firmware upgrade package to upgrade the firmware of the electronic device.
[0063] Generally speaking, when the version of the second firmware upgrade package is higher than the version of the first firmware upgrade package, firmware upgrade through the target firmware upgrade package refers to upgrading the firmware of the electronic device. When the version of the second firmware upgrade package is not higher than the version of the first firmware upgrade package, firmware upgrade through the target firmware upgrade package actually refers to restoring the firmware of the electronic device.
[0064] It is worth mentioning that the first firmware upgrade package obtained by the electronic device can also be obtained through S110-S120, that is, before the electronic device installs the first firmware upgrade package, after the electronic device installs the third firmware upgrade package, the third firmware upgrade package is stored to obtain a historical upgrade package, and the electronic device can use a historical restoration algorithm to perform a restoration operation based on the historical upgrade package and the historical differential upgrade package to obtain the first firmware upgrade package, wherein the historical differential upgrade package is obtained by performing a differential operation on the first firmware upgrade package and the third firmware upgrade package through the corresponding historical differential algorithm, the historical restoration algorithm is a restoration algorithm corresponding to the historical differential algorithm, and the determination process of the historical differential algorithm and the determination process of the historical restoration algorithm are as described above and will not be repeated.
[0065] In this embodiment, the electronic device receives a differential upgrade package sent from the cloud, and the differential upgrade package is obtained by performing a differential operation on a first firmware upgrade package and a second firmware upgrade package of different versions through a target differential algorithm; then a target restoration algorithm corresponding to the target differential algorithm is used to perform a restoration operation based on the differential upgrade package and an existing firmware upgrade package obtained after storing the first firmware upgrade package to obtain a target firmware upgrade package; and then the firmware is upgraded through the target firmware upgrade package. The cloud only needs to send the differential upgrade package, and the electronic device can obtain a target firmware upgrade package consistent with the second firmware upgrade package based on the differential upgrade package and the existing firmware upgrade package. The cloud does not need to send a complete second firmware upgrade package, which reduces the amount of data sent by the cloud, thereby greatly reducing the data transmission time between the cloud and the electronic device, thereby reducing the transmission time of the upgrade package and improving the firmware upgrade efficiency.
[0066] In one embodiment, the configuration file sent by the cloud also includes a first hash, which is obtained by performing a hash operation on the first firmware upgrade package; accordingly, step S120 includes: performing a hash operation on the existing firmware upgrade package to obtain a second hash; if the first hash is consistent with the second hash, a restoration operation is performed based on the differential upgrade package and the existing firmware upgrade package through a target restoration algorithm to determine the target firmware upgrade package.
[0067] In the present application, the hash algorithm used by the cloud to perform hash operation on the first firmware upgrade package can be MD5, SHA-1, SHA-256, SHA-3, CRC32, BLAKE2 and Si pHash, etc. The hash algorithm used to perform hash operation on the existing firmware upgrade package is consistent with the hash algorithm used by the cloud to perform hash operation on the first firmware upgrade package.
[0068] In this embodiment, the configuration file may also include a first algorithm identifier corresponding to the first hash, which is used to indicate the hash algorithm used by the cloud to perform hash operations on the first firmware upgrade package, so that the electronic device obtains the corresponding hash algorithm based on the first algorithm identifier and performs hash operations on the existing firmware upgrade package according to the obtained hash algorithm.
[0069] It is worth mentioning that if the existing firmware upgrade package is obtained by directly storing the first firmware upgrade package, the existing firmware upgrade package is directly hashed to obtain the second hash; if the existing firmware upgrade package is obtained by storing the first firmware upgrade package in the format of a drive letter device, it is necessary to take out the existing firmware upgrade package, and then convert the format of the existing firmware upgrade package to obtain a preprocessed firmware upgrade package with the same data format as the first firmware upgrade package, and then perform a hash operation on the preprocessed firmware upgrade package to obtain the second hash.
[0070] After obtaining the second hash, compare the first hash in the configuration file with the second hash to see if they are consistent. If the first hash is consistent with the second hash, it means that the existing firmware upgrade package data is complete and has not been tampered with. The target firmware upgrade package that is consistent with the second firmware upgrade package can be restored through the existing firmware upgrade package and the differential upgrade package. At this time, the step of determining the target firmware upgrade package by performing a restoration operation based on the differential upgrade package and the existing firmware upgrade package through a target restoration algorithm is executed.
[0071] If the first hash is inconsistent with the second hash, it means that the existing firmware upgrade package data is incomplete or has not been tampered with, and the target firmware upgrade package consistent with the second firmware upgrade package cannot be restored through the existing firmware upgrade package and the differential upgrade package. At this time, the existing firmware upgrade package can be deleted. At the same time, the first prompt information indicating that the existing firmware upgrade package data is incomplete or the data has been tampered with can also be output.
[0072] In this embodiment, the existing firmware upgrade package is verified, and when the verification passes (that is, the first hash and the second hash are consistent), a target restoration algorithm is used to perform a restoration operation based on the differential upgrade package and the existing firmware upgrade package to determine the target firmware upgrade package, which effectively ensures the success rate of restoring the target firmware upgrade package and avoids the situation where, when the existing firmware upgrade package fails the verification, the target restoration algorithm is still used to perform a restoration operation based on the differential upgrade package and the existing firmware upgrade package to determine the target firmware upgrade package, resulting in a restoration failure.
[0073] In one embodiment, the configuration file also includes a third hash, which is obtained by performing a hash operation on the differential upgrade package; accordingly, S120 includes: performing a hash operation on the received differential upgrade package to obtain a fourth hash; if the third hash is consistent with the fourth hash, performing a restoration operation based on the differential upgrade package and the existing firmware upgrade package through a target restoration algorithm to determine the target firmware upgrade package.
[0074] In the present application, the hash algorithm used by the cloud to perform hash operations on the differential upgrade package can be MD5, SHA-1, SHA-256, SHA-3, CRC32, BLAKE2, and Si pHash, etc. The hash algorithm used by the electronic device to perform hash operations on the received differential upgrade package is consistent with the hash algorithm used by the cloud to perform hash operations on the differential upgrade package.
[0075] In this embodiment, the configuration file may also include a second algorithm identifier corresponding to the third hash, which is used to indicate the hash algorithm used by the cloud to perform hash operations on the differential upgrade package, so that the electronic device obtains the corresponding hash algorithm based on the second algorithm identifier and performs hash operations on the received differential upgrade package according to the obtained hash algorithm.
[0076] After obtaining the fourth hash, compare the third hash in the configuration file with the fourth hash to see if they are consistent. If the third hash is consistent with the fourth hash, it means that the differential upgrade package data received by the electronic device is complete and has not been tampered with. The target firmware upgrade package that is consistent with the second firmware upgrade package can be restored through the existing firmware upgrade package and the received differential upgrade package. At this time, the step of determining the target firmware upgrade package by performing a restoration operation based on the differential upgrade package and the existing firmware upgrade package through a target restoration algorithm is executed.
[0077] If the third hash is inconsistent with the fourth hash, it means that the differential upgrade package received by the electronic device is incomplete or has not been tampered with (which may be caused by malicious deletion or tampering of data during data transmission), and the target firmware upgrade package consistent with the second firmware upgrade package cannot be restored by the existing firmware upgrade package and the received differential upgrade package. At this time, the differential upgrade package can be deleted. At the same time, a second prompt message can be output to indicate that the differential upgrade package data is incomplete or the data has been tampered with.
[0078] In this embodiment, the differential upgrade package is verified, and when the verification passes (that is, the third hash and the fourth hash are consistent), a target restoration algorithm is used to perform a restoration operation based on the differential upgrade package and the existing firmware upgrade package to determine the target firmware upgrade package, which effectively ensures the success rate of restoring the target firmware upgrade package and avoids the situation where, when the differential upgrade package verification fails, the target restoration algorithm is still used to perform a restoration operation based on the differential upgrade package and the existing firmware upgrade package to determine the target firmware upgrade package, resulting in a restoration failure.
[0079] In one embodiment, the configuration file may also include a fifth hash, which is obtained by performing a hash operation on the second firmware upgrade package; accordingly, S130 includes: performing a hash operation on the target firmware upgrade package to obtain a sixth hash; if the fifth hash is consistent with the sixth hash, the firmware upgrade is performed through the target firmware upgrade package.
[0080] In the present application, the hash algorithm used by the cloud to perform hash operation on the second firmware upgrade package can be MD5, SHA-1, SHA-256, SHA-3, CRC32, BLAKE2 and Si pHash, etc. The hash algorithm used by the electronic device to perform hash operation on the target firmware upgrade package is consistent with the hash algorithm used by the cloud to perform hash operation on the second firmware upgrade package.
[0081] In this embodiment, the configuration file may also include a third algorithm identifier corresponding to the fifth hash, which is used to indicate the hash algorithm used by the cloud to perform hash operation on the second firmware upgrade package, so that the electronic device obtains the corresponding hash algorithm based on the third algorithm identifier and performs hash operation on the target firmware upgrade package according to the obtained hash algorithm.
[0082] After obtaining the sixth hash, compare the fifth hash in the configuration file with the sixth hash to see if they are consistent. If the fifth hash is consistent with the sixth hash, it means that the target firmware upgrade package generated by the electronic device is consistent with the second firmware upgrade package, and the electronic device accurately restores the second firmware upgrade package. At this time, the firmware upgrade can be directly performed through the target firmware upgrade package to achieve the firmware upgrade of the electronic device.
[0083] If the fifth hash is inconsistent with the sixth hash, it means that the target firmware upgrade package generated by the electronic device is inconsistent with the second firmware upgrade package, and the electronic device has failed to accurately restore the second firmware upgrade package. At this time, the firmware upgrade cannot be performed through the target firmware upgrade package, and the target firmware upgrade package can be deleted. At the same time, a third prompt message indicating that the restoration of the target firmware upgrade package has failed can also be output.
[0084] In this embodiment, the target firmware upgrade package is verified, and when the verification passes (that is, the fifth hash and the sixth hash are consistent), the step of performing the firmware upgrade through the target firmware upgrade package is performed, which effectively ensures the success rate of the firmware upgrade and avoids the situation where the firmware upgrade step through the target firmware upgrade package is still executed when the target firmware upgrade package fails to be restored, resulting in an upgrade failure.
[0085] In one embodiment, before S130, the method further includes: backing up the image data of the firmware installed in the electronic device to obtain the backup image data; correspondingly, after S130, the method further includes: if the firmware upgrade through the target firmware upgrade package fails, performing image restoration processing through the backup image data.
[0086] That is to say, before performing a firmware upgrade through the target firmware upgrade package, the image data of the installed firmware is first backed up, and the backup result is used as the backup image data. In the event of a firmware upgrade failure, image restoration is performed through the backup image data to restore the firmware of the electronic device to the state before the upgrade, thereby effectively avoiding the situation where a firmware error in the electronic device and the electronic device cannot be used due to a firmware upgrade failure, and effectively ensuring that the electronic device can still be used normally when a firmware upgrade fails.
[0087] In one embodiment, the firmware upgrade process is as follows: Figure 2-Figure 3 As shown, in Figure 2 In the process, the cloud obtains a first firmware upgrade package corresponding to version v1 and a second firmware upgrade package corresponding to version v2 (wherein the first firmware upgrade package is an upgrade package corresponding to the firmware installed on the electronic device), and then performs a differential operation on the first firmware upgrade package and the second firmware upgrade package through a determined target differential algorithm to obtain a differential upgrade package; in addition, the cloud can also perform a hash operation on the first firmware upgrade package to obtain a first hash, perform a hash operation on the differential upgrade package to obtain a third hash, perform a hash operation on the second firmware upgrade package to obtain a fifth hash, and store the first hash, the third hash and the fifth hash in a configuration file. After that, the cloud can send the differential upgrade package and the configuration file to the electronic device.
[0088] like Figure 3As shown, after the electronic device receives the differential upgrade package and the configuration file, it can first calculate the third hash to determine whether the first hash is consistent with the second hash. If the first hash is inconsistent with the second hash, a first prompt message is output. If the first hash is consistent with the second hash, a fourth hash is calculated and it is determined whether the third hash is consistent with the fourth hash. If the third hash is inconsistent with the fourth hash, a second prompt message is output. If the third hash is consistent with the fourth hash, the target firmware upgrade file is restored based on the differential upgrade package, and a sixth hash is calculated. Then, it is determined whether the fifth hash is consistent with the sixth hash. If the fifth hash is inconsistent with the sixth hash, a third prompt message is output. If the fifth hash is consistent with the sixth hash, the image data of the installed firmware is backed up to obtain the backup image data.
[0089] Then, upgrade the firmware using the target firmware upgrade package.
[0090] If the firmware upgrade fails, the backup image data is used to perform image restoration processing to restore the firmware of the electronic device to the state before the upgrade. Of course, after the upgrade fails and the backup image data is used to perform image restoration processing, a fourth prompt message can also be output to prompt that the firmware upgrade has failed and the firmware has been successfully restored.
[0091] See attached Figure 4 , Figure 4 The structure block diagram of a firmware upgrade device proposed in one embodiment of the present application is shown. For electronic equipment, the device 800 includes:
[0092] The receiving module 810 is used to receive a differential upgrade package sent from the cloud; the differential upgrade package is obtained by performing differential operations on a first firmware upgrade package and a second firmware upgrade package of different versions through a target differential algorithm; the target differential algorithm is determined based on at least one of the computing resources of the electronic device, the size of the first firmware upgrade package, the size of the second firmware upgrade package, the size of the upgrade package difference data, and the target data type; the first firmware upgrade package is a firmware upgrade package corresponding to the firmware installed on the electronic device; the upgrade package difference data refers to the difference data between the first firmware upgrade package and the second firmware upgrade package; the target data type is the data type to which the data in the first firmware upgrade package and / or the second firmware upgrade package belongs;
[0093] The determination module 820 is used to perform a restoration operation based on the differential upgrade package and the existing firmware upgrade package by using a target restoration algorithm corresponding to the target differential algorithm to obtain a target firmware upgrade package; the existing firmware upgrade package is obtained after the electronic device stores the first firmware upgrade package;
[0094] The upgrade module 830 is used to perform firmware upgrade via a target firmware upgrade package.
[0095] Optionally, the receiving module 810 is also used to receive a configuration file sent from the cloud; the configuration file includes a target algorithm identifier corresponding to the target differential algorithm; and obtain a target restoration algorithm corresponding to the target differential algorithm from a locally stored algorithm set according to the target algorithm identifier.
[0096] Optionally, the configuration file also includes a first hash, which is obtained by performing a hash operation on the first firmware upgrade package; the determination module 820 is also used to perform a hash operation on the existing firmware upgrade package to obtain a second hash; if the first hash is consistent with the second hash, a restoration operation is performed based on the differential upgrade package and the existing firmware upgrade package through a target restoration algorithm to determine the target firmware upgrade package.
[0097] Optionally, the configuration file also includes a third hash, which is obtained by performing a hash operation on the differential upgrade package; the determination module 820 is also used to perform a hash operation on the received differential upgrade package to obtain a fourth hash; if the third hash is consistent with the fourth hash, a restoration operation is performed based on the differential upgrade package and the existing firmware upgrade package through a target restoration algorithm to determine the target firmware upgrade package.
[0098] Optionally, the configuration file also includes a fifth hash, which is obtained by performing a hash operation on the second firmware upgrade package; the upgrade module 830 is also used to perform a hash operation on the target firmware upgrade package to obtain a sixth hash; if the fifth hash is consistent with the sixth hash, the firmware upgrade is performed through the target firmware upgrade package.
[0099] Optionally, the device also includes a backup module for backing up the image data of the firmware installed in the electronic device to obtain the backup image data; if the firmware upgrade fails through the target firmware upgrade package, the image restoration process is performed through the backup image data.
[0100] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.
[0101] In addition, each function in each embodiment of the present application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated module can be implemented in the form of hardware or in the form of software function module.
[0102] In addition, each function in each embodiment of the present application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated module can be implemented in the form of hardware or in the form of software function module.
[0103] Please refer to Figure 5 , which shows a structural block diagram of an electronic device provided according to an embodiment of the present application. The electronic device 500 can be an electronic device capable of running applications, such as a smart phone, a tablet computer, an e-book, and a vehicle. The electronic device 500 in the present application may include one or more of the following components: a processor 510, a memory 520, and one or more applications. One or more applications may be stored in the memory 520 and configured to be executed by one or more processors 510, and one or more programs are configured to execute the method described in the aforementioned method embodiment.
[0104] The processor 510 may include one or more processing cores. The processor 510 uses various interfaces and lines to connect various parts of the entire electronic device 500, and executes various functions and processes data of the electronic device 500 by running or executing instructions, programs, code sets or instruction sets stored in the memory 520, and calling data stored in the memory 520. Optionally, the processor 510 can be implemented in at least one hardware form of digital signal processing (DSP), field programmable gate array (FPGA), and programmable logic array (PLA). The processor 510 can integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 510, but may be implemented separately through a communication chip.
[0105] The memory 520 may include a random access memory (RAM) or a read-only memory (ROM). The memory 520 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 520 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as a phone book, audio and video data, chat record data) created by the electronic device 500 during use.
[0106] In addition, each function in each embodiment of the present application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated module can be implemented in the form of hardware or in the form of software function module.
[0107] On the other hand, the present application also provides a computer-readable storage medium, in which program code is stored. The program code can be called by a processor to execute the method described in the above method embodiment.
[0108] The computer readable storage medium can be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a cluster of ROMs. Optionally, the computer readable storage medium includes a non-transitory computer-readable storage medium. The computer readable storage medium has storage space for program codes that execute any of the method steps in the above method. These program codes can be read from or written into one or more computer program products. The program code can be compressed, for example, in an appropriate form.
[0109] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A firmware upgrade method, characterized in that: For an electronic device, the method comprises: Receive a differential upgrade package sent from the cloud; the differential upgrade package is obtained by performing a differential operation on a first firmware upgrade package and a second firmware upgrade package of different versions through a target differential algorithm; the target differential algorithm is determined based on at least one of the computing resources of the electronic device, the size of the first firmware upgrade package, the size of the second firmware upgrade package, the size of the upgrade package difference data, and a target data type; the first firmware upgrade package is a firmware upgrade package corresponding to the firmware installed on the electronic device; the upgrade package difference data refers to the difference data between the first firmware upgrade package and the second firmware upgrade package; the target data type is the data type to which the data in the first firmware upgrade package and / or the second firmware upgrade package belongs; A target firmware upgrade package is obtained by performing a restoration operation based on the differential upgrade package and the existing firmware upgrade package using a target restoration algorithm corresponding to the target differential algorithm; the existing firmware upgrade package is obtained after the electronic device stores the first firmware upgrade package; The firmware is upgraded through the target firmware upgrade package.
2. The method according to claim 1, characterized in that Before obtaining the target firmware upgrade package by performing a restoration operation based on the differential upgrade package and the existing firmware upgrade package using the target restoration algorithm corresponding to the target differential algorithm, the method further includes: Receiving a configuration file sent by the cloud; the configuration file includes a target algorithm identifier corresponding to the target difference algorithm; According to the target algorithm identifier, a target restoration algorithm corresponding to the target differential algorithm is obtained from a locally stored algorithm set.
3. The method according to claim 2, characterized in that The configuration file further includes a first hash, where the first hash is obtained by performing a hash operation on the first firmware upgrade package; The target restoration algorithm corresponding to the target differential algorithm performs restoration operation based on the differential upgrade package and the existing firmware upgrade package to obtain a target firmware upgrade package, including: Performing a hash operation on the existing firmware upgrade package to obtain a second hash; If the first hash is consistent with the second hash, a restoration operation is performed based on the differential upgrade package and the existing firmware upgrade package using the target restoration algorithm to determine a target firmware upgrade package.
4. The method according to claim 2, characterized in that: The configuration file further includes a third hash, where the third hash is obtained by performing a hash operation on the differential upgrade package; The target restoration algorithm corresponding to the target differential algorithm performs restoration operation based on the differential upgrade package and the existing firmware upgrade package to obtain a target firmware upgrade package, including: Performing a hash operation on the received differential upgrade package to obtain a fourth hash; If the third hash is consistent with the fourth hash, a restoration operation is performed based on the differential upgrade package and the existing firmware upgrade package using the target restoration algorithm to determine a target firmware upgrade package.
5. The method according to claim 2, characterized in that: The configuration file further includes a fifth Hash, where the fifth Hash is obtained by performing a Hash operation on the second firmware upgrade package; The firmware upgrade is performed by using the target firmware upgrade package, including: Performing a hash operation on the target firmware upgrade package to obtain a sixth hash; If the fifth hash is consistent with the sixth hash, the firmware upgrade is performed through the target firmware upgrade package.
6. The method according to claim 1, characterized in that Before performing the firmware upgrade through the target firmware upgrade package, the method further includes: Backing up the image data of the firmware installed in the electronic device to obtain backup image data; After the firmware upgrade is performed using the target firmware upgrade package, the method further includes: If the firmware upgrade fails through the target firmware upgrade package, image restoration is performed through the backup image data.
7. The method according to claim 1, characterized in that The computing resources include at least one of a central processing unit resource, a memory resource, and a hard disk resource.
8. A firmware upgrade device, characterized in that: The device comprises: A receiving module, used for receiving a differential upgrade package sent from the cloud; the differential upgrade package is obtained by performing a differential operation on a first firmware upgrade package and a second firmware upgrade package of different versions through a target differential algorithm; the target differential algorithm is determined based on at least one of the computing resources of the electronic device, the size of the first firmware upgrade package, the size of the second firmware upgrade package, the size of the upgrade package difference data, and a target data type; the first firmware upgrade package is a firmware upgrade package corresponding to the firmware installed on the electronic device; the upgrade package difference data refers to the difference data between the first firmware upgrade package and the second firmware upgrade package; the target data type is the data type to which the data in the first firmware upgrade package and / or the second firmware upgrade package belongs; a determination module, configured to perform a restoration operation based on the differential upgrade package and an existing firmware upgrade package using a target restoration algorithm corresponding to the target differential algorithm, to obtain a target firmware upgrade package; the existing firmware upgrade package is obtained after the electronic device stores the first firmware upgrade package; An upgrade module is used to perform firmware upgrade via the target firmware upgrade package.
9. An electronic device, characterized in that: include: one or more processors; Memory; One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more applications are configured to execute the method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program code executable by a processor, and when the program code is executed by the processor, the processor executes the method according to any one of claims 1 to 7.
Citation Information
Cited By
Differential upgrading method for integrated electronic communication module
CN121614169A
A differential upgrade method for integrated electronic communication modules
CN121614169B