Firmware upgrading method, electronic equipment and storage medium
By dividing the firmware upgrade file package into multiple file stream data blocks and storing it in multiple independent storage units, the problem of data loss caused by a single point of failure during the firmware upgrade process is solved, and decentralized storage is realized, ensuring the correctness and security of firmware upgrades.
Patent Information
- Application Number
- CN202311575168.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-22
- Publication Date
- 2025-05-23
AI Technical Summary
The existing firmware incremental upgrade solution is a single point of failure that may cause data loss of the entire upgrade file package due to centralized storage of the entire upgrade file package.
Split the upgrade file package into multiple file stream data blocks and store these data blocks in multiple independent storage units to avoid single point of failure. The terminal device performs firmware upgrades based on the received multiple file stream data blocks.
Through decentralized storage, data loss problems caused by single point of failure are avoided, and the correctness and security of the firmware upgrade process are ensured.
Smart Images

Figure CN120029652A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of firmware upgrade, and specifically relates to a firmware upgrade method, electronic device and storage medium. Background Art
[0002] With the development of the Internet of Things, more and more devices rely on firmware to work. In order to improve the efficiency and security of firmware upgrades, incremental upgrade technology is widely used. Incremental upgrade technology can only transmit the parts of the firmware that need to be updated, reducing the amount of data transmitted and the upgrade time. At the same time, by comparing the differences between the firmware versions before and after the upgrade, the correctness and security of the upgrade process can be ensured.
[0003] However, the current firmware incremental upgrade solution usually uses centralized storage for the entire upgrade file package, that is, the entire upgrade file package is stored in a storage device or storage node. When the storage device or storage node fails, the single point failure will cause the loss of the entire upgrade file package data. Summary of the invention
[0004] The embodiments of the present application provide a firmware upgrade method, an electronic device, and a storage medium, which can solve the problem of data loss of the entire upgrade file package due to a single point failure during a firmware upgrade process.
[0005] In a first aspect, an embodiment of the present application provides a firmware upgrade method, which is applied to a server, and the method includes: dividing an upgrade file package into multiple file stream data blocks; storing the multiple file stream data blocks in multiple first storage units; and sending the multiple file stream data blocks stored in the multiple first storage units to a terminal device, so that the terminal device performs a firmware upgrade according to the multiple file stream data blocks.
[0006] In the second aspect, an embodiment of the present application provides a firmware upgrade method, applied to a terminal device, the method comprising: receiving multiple file stream data blocks sent by a server, the multiple file stream data blocks are obtained by the server splitting an upgrade file package, and in the server, the multiple file stream modules are stored in multiple first storage units; performing firmware upgrade according to the multiple file stream data blocks.
[0007] In the third aspect, an embodiment of the present application provides a firmware upgrade device, which is applied to a server, and the device includes: a segmentation module, which is used to segment the upgrade file package into multiple file stream data blocks; a storage module, which is used to store the multiple file stream data blocks in multiple first storage units; and an execution module, which is used to send the multiple file stream data blocks stored in the multiple first storage units to a terminal device, so that the terminal device performs a firmware upgrade according to the multiple file stream data blocks.
[0008] In a fourth aspect, an embodiment of the present application provides a firmware upgrade device, which is applied to a terminal device, and the device includes: a receiving module, which is used to receive multiple file stream data blocks sent by a server, and the multiple file stream data blocks are obtained by the server splitting the upgrade file package. In the server, the multiple file stream modules are stored in multiple first storage units; an upgrade module, which is used to perform firmware upgrade according to the multiple file stream data blocks.
[0009] In a fifth aspect, an embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method described in the first aspect.
[0010] In a sixth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0011] In an embodiment of the present application, by dividing the upgrade file package into multiple file stream data blocks, storing the multiple file stream data blocks in multiple first storage units, and sending the multiple file stream data blocks stored in the multiple first storage units to the terminal device, so that the terminal device performs firmware upgrade according to the multiple file stream data blocks, it is avoided that the entire upgrade file package is stored in one storage device or storage node during the firmware upgrade, and the problem of loss of the entire upgrade file package data due to a single point failure is avoided, decentralized storage is realized, and the correctness and security of the firmware upgrade process are ensured. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Figure 1 It is a flowchart of a firmware upgrade method provided in an embodiment of the present application;
[0013] Figure 2 This is a schematic diagram of a firmware upgrade management system provided by an embodiment of the present application;
[0014] Figure 3 This is a schematic diagram of a Merkle tree calculation process provided by an embodiment of the present application;
[0015] Figure 4 It is a flowchart of another firmware upgrade method provided in an embodiment of the present application;
[0016] Figure 5 It is a flowchart of another firmware upgrade method provided in an embodiment of the present application;
[0017] Figure 6 It is a structural schematic diagram of a firmware upgrade device provided in an embodiment of the present application;
[0018] Figure 7 It is a structural schematic diagram of another firmware upgrade device provided in an embodiment of the present application;
[0019] Figure 8 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0020] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0021] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0022] The firmware upgrade method, electronic device and storage medium provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.
[0023] Figure 1 A firmware upgrade method provided by an embodiment of the present application is shown, and the method can be executed by a server. In other words, the method can be executed by software or hardware installed on the server, and the method includes the following steps:
[0024] Step 102: Divide the upgrade file package into multiple file stream data blocks.
[0025] In an embodiment of the present application, a firmware upgrade management system is provided, which may include a file management unit and a storage unit. The storage unit is responsible for the storage and management of the upgrade file, which generally includes file allocation and storage space management, and may cut the upgrade file into a plurality of file stream data blocks, and store these file stream data blocks in different storage nodes or storage units. By managing the storage space, the storage unit may effectively utilize the disk space and ensure the security and reliability of the upgrade file.
[0026] The file management unit is responsible for managing the metadata information of the upgrade file, such as the name, path, modification time, size, etc. of the upgrade file. The file management unit can also provide functions such as file search, sorting, deletion, and export. At the same time, it can also perform authorization management on users to ensure that only authorized users can access and modify the upgrade file. Figure 2 In the firmware upgrade management system shown in the figure, when a user uploads a file, the file management unit will record the metadata information of the file (such as file path, size, upload time, etc.), divide the file into blocks and store these blocks in the storage unit. The file management unit can perform authorization management for the user's terminal device. When the user's terminal device needs to access the file, the file management unit can find the corresponding file blocks and assemble them into a complete file according to the user's permissions and query conditions.
[0027] In the embodiment of the present application, the firmware upgrade management system is a system that integrates a storage unit and a file management unit, and can provide effective file management and storage services. It is an important infrastructure that plays a vital role in improving user work efficiency, reducing storage costs, and protecting file security.
[0028] In an embodiment of the present application, the upgrade file package to be transmitted to the terminal device may first be divided into a plurality of file stream data blocks.
[0029] Step 104: Store the plurality of file stream data blocks into a plurality of first storage units.
[0030] In an embodiment of the present application, different storage units can be planned according to demand and resource conditions. For example, suitable storage devices or storage nodes can be selected as storage units based on factors such as storage capacity, performance requirements, and data protection requirements. These storage units can be independent physical storage devices or multiple nodes in a distributed storage system. After the upgrade file package is divided into multiple file stream data blocks, multiple first storage units are selected from the storage units according to the file stream data blocks and storage unit planning, and the file stream data blocks are distributed to the multiple first storage units. Each file stream data block can be stored in an independent first storage unit to achieve load balancing and data redundancy.
[0031] After storing the plurality of file stream data blocks in the plurality of first storage units, the file stream data blocks stored in different first storage units can be indexed and managed, and a data management system can be maintained to record metadata information of each file stream data block, such as data block number, storage location, etc. Through the data management system, the file stream data blocks can be effectively found and managed to accelerate the execution of the upgrade operation.
[0032] Step 106: Send the plurality of file stream data blocks stored in the plurality of first storage units to a terminal device, so that the terminal device performs a firmware upgrade according to the plurality of file stream data blocks.
[0033] Specifically, the server may send the multiple file stream data blocks stored in the multiple first storage units to the terminal device, so that the terminal device may perform firmware upgrade according to the received multiple file stream data blocks.
[0034] The firmware upgrade method provided in the embodiment of the present application divides the upgrade file package into multiple file stream data blocks, stores the multiple file stream data blocks in multiple first storage units, and sends the multiple file stream data blocks stored in the multiple first storage units to the terminal device, so that the terminal device performs firmware upgrade according to the multiple file stream data blocks, thereby avoiding storing the entire upgrade file package in one storage device or storage node during the firmware upgrade, avoiding the problem of loss of the entire upgrade file package data due to a single point failure, realizing decentralized storage, and ensuring the correctness and security of the firmware upgrade process.
[0035] In one implementation, after storing the plurality of file stream data blocks in the plurality of first storage units, the method further includes:
[0036] Calculate the hash value of each file stream data block, and construct a first Merkle tree according to the hash value of each file stream data block. Send the first Merkle tree to the terminal device, so that the terminal device performs integrity check on the received multiple file stream data blocks by comparing the first Merkle tree with a second Merkle tree, wherein the second Merkle tree is constructed by the terminal device according to the hash values of the received multiple file stream data blocks.
[0037] In an embodiment of the present application, it is necessary to calculate the hash value of the segmented file stream data blocks and construct a first Merkle tree. The Merkle tree is a binary tree structure, and its leaf nodes store the hash values of the data blocks rather than the file stream data blocks themselves. When the terminal device receives multiple file stream data blocks sent by the server, it is necessary to construct a second Merkle tree based on the hash values of the received multiple file stream data blocks. The server sends the first Merkle tree to the terminal device, so that the terminal device can perform integrity verification on the received multiple file stream data blocks by comparing the first Merkle tree and the second Merkle tree.
[0038] In one implementation, constructing a first Merkle tree according to the hash value of each of the file stream data blocks includes:
[0039] The hash values of the plurality of file stream data blocks are respectively used as leaf nodes in all nodes of the first Merkle tree. Starting from the leaf nodes, a parent node is generated by calculating every two adjacent nodes until a root node is obtained, thereby obtaining the first Merkle tree.
[0040] Specifically, the first Merkle tree is constructed by taking the hash values of multiple file stream data blocks as leaf nodes of all nodes in the first Merkle tree. Starting from the leaf nodes, each pair of adjacent nodes calculates and generates a parent node, which stores the combined hash value of the hash values of the two nodes before merging. The nodes are merged all the way to the root node, and finally there is only one hash value, which is called the root node hash value of the Merkle tree. Taking the example of hexadecimal representation, assuming that there are four file stream data blocks A, B, C and D, the steps for calculating the Merkle tree are as follows: Calculate the hash value for each file stream data block to obtain hash values HA, HB, HC and HD. Combine two adjacent hash values into a new hash value, that is, HAB = hash (HA||HB), HCD = hash (HC||HD). Repeat step 2 until only one hash value is left, that is, HABCD = hash (HAB||HCD). HABCD is the root node hash value of the first Merkle tree. In practical applications, in order to improve efficiency, hash chains are usually used instead of traditional Merkle trees. Hash chain refers to performing hash calculations on data blocks in sequence to obtain a series of hash values, and then using the last hash value as the root node hash value. This can avoid repeated calculations and improve calculation efficiency.
[0041] As another example, Figure 3 The calculation process of the Merkle tree in the embodiment of the present application is shown as follows: Figure 3 As shown, L1 to L4 represent 4 file stream data blocks, Hash0-0 = hash(L1), Hash0-1 = hash(L2), Hash1-0 = hash(L3), Hash1-1 = hash(L4), Hash0 = hash(Hash0-0 + Hash0-1), Hash1 = hash(Hash1-0 + Hash1-1), Top Hash = hash(Hash0 + Hash1), after the calculation is completed, the information of the entire Merkle tree is stored in a trusted data source. The value of Top Hash is the root of the Merkle tree.
[0042] In one implementation, after the upgrade file package is divided into a plurality of file stream data blocks, the method further includes:
[0043] Backing up the plurality of file stream data blocks to obtain a plurality of backup data blocks, and storing the plurality of backup data blocks in a plurality of second storage units.
[0044] Specifically, after the upgrade file package is divided into multiple file stream data blocks, the multiple file stream data blocks can be backed up to obtain multiple backup data blocks, and then the multiple backup data blocks can be stored in multiple second storage units respectively. At the same time, the information of the backup data blocks can be registered to the file management center, such as the second storage unit location corresponding to the backup data blocks, etc. In this way, the reliability and availability of the data can be improved.
[0045] In one implementation, after sending the first Merkle tree to the terminal device, the method further includes:
[0046] In the case of receiving a retransmission request sent by the terminal device, a target backup data block is determined from the multiple backup data blocks according to the information of the erroneous data block carried in the retransmission request. The target backup data block is sent to the terminal device so that the terminal device updates the erroneous data block to the target backup data block. The retransmission request is sent by the terminal device when the integrity check of multiple file stream data blocks fails and the erroneous data block is determined from the multiple file stream data blocks. The erroneous data block is determined from the multiple file stream data blocks by the terminal device by comparing the node hash values of the first Merkle tree and the second Merkle tree layer by layer, and the comparison results show that the node is different.
[0047] The terminal device can perform integrity check on the received multiple file stream data blocks according to the first Merkle tree and the second Merkle tree. Specifically, the terminal device can compare the root node hash values of the first Merkle tree and the second Merkle tree. If the root node hash values of the first Merkle tree and the second Merkle tree are different, the integrity check of the multiple file stream data blocks fails, indicating that the received upgrade file package is missing or wrong. At this time, the terminal device can compare the node hash values of the first Merkle tree and the second Merkle tree layer by layer, and determine the erroneous data block from the multiple file stream data blocks according to the nodes that are different in the comparison results.
[0048] by Figure 3 The Merkle tree shown is used as an example. The terminal device compares the first Merkle tree with the second Merkle tree. If the root node hash values of the first Merkle tree and the second Merkle tree are inconsistent, the comparison continues to the next layer, comparing the roots of the left subtree and the right subtree respectively:
[0049] (1) If the root hash0 of the left subtree is different, then there is a problem with the file stream data block of the left subtree. That is, it can be determined that the file stream data blocks L1 to L2 have a problem, and the problem is continued to the next layer of the Merkle tree.
[0050] (2) If the root hash1 of the right subtree is different, then there is a problem with the file stream data block of the right subtree. That is, it can be determined that the file stream data blocks L3 to L4 have a problem, and the problem is continued to the next layer of the Merkle tree.
[0051] (3) If the root hash0 and hash1 of the left and right subtrees are different, there is a problem with the file stream data blocks of the left and right subtrees, and the problem is solved by going to the next level of the Merkle tree.
[0052] The purpose of constructing the entire Merkle tree is to speed up the location of the erroneous data block and shorten the time complexity of the entire location process to log n , n represents the number of file stream data blocks. If this Merkle tree is not constructed, the time complexity of locating the error block is n.
[0053] After the terminal device determines that the data block is an error, the terminal device will initiate a retransmission request for the error data block to the server. When the server receives the retransmission request sent by the terminal device, it can determine the target backup data block corresponding to the error data block from multiple backup data blocks based on the information of the error data block carried in the retransmission request, such as the hash value of the error data block. The server sends the target backup data block to the terminal device so that the terminal device updates the error data block to the target backup data block and can then perform a firmware upgrade. In this way, the error data block in the transmission process is determined by Merkle tree comparison, and only the target backup data block of the error data block is retransmitted, which improves the retransmission efficiency and reduces bandwidth occupancy.
[0054] In one implementation, when the root node hash value of the second Merkle tree is the same as the root node hash value of the first Merkle tree, the integrity check of the plurality of file stream data blocks passes.
[0055] Specifically, the terminal device can perform integrity check on the received multiple file stream data blocks based on the first Merkle tree and the second Merkle tree. If the root node hash value of the second Merkle tree is the same as the root node hash value of the first Merkle tree, it can be determined that the integrity check of the multiple file stream data blocks has passed.
[0056] In one implementation, before determining the target backup data block corresponding to the information of the error data block from the multiple backup data blocks, it also includes: marking the error data block stored in the first storage unit, wherein the mark is used to indicate that the error data block in the first storage unit is damaged, and subsequent firmware upgrades prohibit obtaining the error data block from the first storage unit.
[0057] Specifically, after the server receives a retransmission request regarding the erroneous data block sent by the terminal device, the service can find the erroneous data block from the first storage unit based on the information of the erroneous data block carried in the retransmission request, and mark the erroneous data block. The mark is used to indicate that the erroneous data block in the first storage unit is damaged, and subsequent firmware upgrades are prohibited from obtaining the erroneous data block from the first storage unit, thereby ensuring the correctness of the data and the correctness of the firmware upgrade.
[0058] Figure 4 A firmware upgrade method provided by an embodiment of the present application is shown, and the method can be executed by a terminal device. In other words, the method can be executed by software or hardware installed in the terminal device, and the method includes the following steps:
[0059] Step 402: Receive multiple file stream data blocks sent by the server.
[0060] Specifically, multiple file stream data blocks are obtained by the server segmenting the upgrade file package. In the server, multiple file stream modules are stored in multiple first storage units. In the server, the entire upgrade file package used for firmware upgrade is first segmented, and the upgrade file package is segmented into multiple file stream data blocks, each file stream data block contains a certain number of bytes. The upgrade file package can be segmented according to size, such as each block is segmented into 128K in size, or it can be segmented according to data blocks, such as the entire upgrade file package is evenly segmented into file stream data blocks of the same size or randomly segmented into different file stream data blocks. The way to segment the upgrade file package can be set according to actual needs, and no specific limitation is made here. The upgrade file package is divided into multiple file stream data blocks for better management and storage.
[0061] Step 404: Perform firmware upgrade according to the plurality of file stream data blocks.
[0062] Specifically, the terminal device may perform a firmware upgrade based on the received multiple file stream data blocks.
[0063] In an embodiment of the present application, multiple file stream data blocks received by the terminal device are distributed and stored in multiple first storage units of the server, avoiding the storage of the entire upgrade file package in one storage device or storage node during the firmware upgrade, avoiding the problem of loss of the entire upgrade file package data due to a single point failure, realizing decentralized storage, and ensuring the correctness and security of the firmware upgrade process.
[0064] In one implementation, after receiving the multiple file stream data blocks sent by the server, the method further includes:
[0065] Receive a first Merkle tree sent by the server, where the first Merkle tree is determined by the server according to the hash values of the plurality of file stream data blocks. Calculate the hash value of each received file stream data block. Construct a second Merkle tree according to the hash value of each file stream data block. Perform integrity check on the plurality of received file stream data blocks by comparing the first Merkle tree with the second Merkle tree.
[0066] Specifically, the terminal device can receive a first Merkle tree sent by the server, which is constructed by the server according to the hash values of multiple file stream data blocks. The terminal device can calculate the hash value of each received file stream data block, and construct a second Merkle tree according to the hash value of each file stream data block. Then, the integrity of the received multiple file stream data blocks is checked by comparing the first Merkle tree with the second Merkle tree.
[0067] In one implementation, performing integrity check on the received plurality of file stream data blocks by comparing the first Merkle tree with the second Merkle tree includes:
[0068] When the root node hash value of the second Merkle tree is different from the root node hash value of the first Merkle tree, the integrity check of the plurality of file stream data blocks fails.
[0069] Specifically, the terminal device can perform integrity check on the received multiple file stream data blocks based on the first Merkle tree and the second Merkle tree. If the root node hash value of the second Merkle tree is the same as the root node hash value of the first Merkle tree, it can be determined that the integrity check of the multiple file stream data blocks has passed.
[0070] In one implementation, performing integrity check on the received plurality of file stream data blocks by comparing the first Merkle tree with the second Merkle tree includes:
[0071] When the root node hash value of the second Merkle tree is the same as the root node hash value of the first Merkle tree, the integrity check of the plurality of file stream data blocks passes.
[0072] Specifically, the terminal device can perform integrity check on the received multiple file stream data blocks based on the first Merkle tree and the second Merkle tree. If the root node hash value of the second Merkle tree is different from the root node hash value of the first Merkle tree, it can be determined that the integrity check of the multiple file stream data blocks has failed.
[0073] In one implementation, constructing a second Merkle tree according to the hash value of each of the file stream data blocks includes:
[0074] The hash values of the plurality of file stream data blocks are respectively used as leaf nodes in all nodes of the second Merkle tree. Starting from the leaf nodes, a parent node is generated by calculating every two adjacent nodes until a root node is obtained, thereby obtaining the second Merkle tree.
[0075] Specifically, the second Merkle tree is constructed in such a way that the terminal device uses the hash values of the received multiple file stream data blocks as leaf nodes in all nodes of the second Merkle tree, and starts from the leaf nodes, and each pair of adjacent nodes calculates and generates a parent node, which stores the combined hash value of the hash values of the two nodes before merging. The nodes are merged all the way to the root node, and finally there is only one hash value, which is called the root node hash value of the Merkle tree. That is, the construction method of the first Merkle tree and the construction method of the second Merkle tree are the same, and the construction of the second Merkle tree will not be repeated here.
[0076] In one implementation, after performing integrity check on the received plurality of file stream data blocks by comparing the first Merkle tree with the second Merkle tree, the method further includes:
[0077] In the case where the integrity check of the plurality of file stream data blocks fails, the node hash values of the first Merkle tree and the second Merkle tree are compared layer by layer. According to the nodes whose comparison results are different in the first Merkle tree and the second Merkle tree, an erroneous data block is determined from the plurality of file stream data blocks. A retransmission request is sent to the server, and the retransmission request includes information of the erroneous data block.
[0078] The terminal device can perform integrity check on the received multiple file stream data blocks according to the first Merkle tree and the second Merkle tree. Specifically, the terminal device can compare the root node hash values of the first Merkle tree and the second Merkle tree. If the root node hash values of the first Merkle tree and the second Merkle tree are different, the integrity check of the multiple file stream data blocks fails, indicating that the received upgrade file package is missing or wrong. At this time, the terminal device can compare the node hash values of the first Merkle tree and the second Merkle tree layer by layer, and determine the erroneous data block from the multiple file stream data blocks according to the nodes that are different in the comparison results.
[0079] by Figure 3 The Merkle tree shown is used as an example. The terminal device compares the first Merkle tree with the second Merkle tree. If the root node hash values of the first Merkle tree and the second Merkle tree are inconsistent, the comparison continues to the next layer, comparing the roots of the left subtree and the right subtree respectively:
[0080] (1) If the root hash0 of the left subtree is different, then there is a problem with the file stream data block of the left subtree. That is, it can be determined that the file stream data blocks L1 to L2 have a problem, and the problem is continued to the next layer of the Merkle tree.
[0081] (2) If the root hash1 of the right subtree is different, then there is a problem with the file stream data block of the right subtree. That is, it can be determined that the file stream data blocks L3 to L4 have a problem, and the problem is continued to the next layer of the Merkle tree.
[0082] (3) If the root hash0 and hash1 of the left and right subtrees are different, there is a problem with the file stream data blocks of the left and right subtrees, and the problem is solved by going to the next level of the Merkle tree.
[0083] The purpose of constructing the entire Merkle tree is to speed up the location of the erroneous data block and shorten the time complexity of the entire location process to log n , n represents the number of file stream data blocks. If this Merkle tree is not constructed, the time complexity of locating the error block is n.
[0084] After the terminal device determines that it is an erroneous data block, the terminal device will initiate a retransmission request for the erroneous data block to the server, and the retransmission request includes information about the erroneous data block, such as the hash value of the erroneous data block. The terminal device can confirm the integrity of the upgrade file and ensure the correctness and effectiveness of the upgrade process by performing integrity verification on the received file stream data blocks. Since the second Merkle tree is calculated from multiple received file stream data blocks, rather than the traditional calculation of the entire file upgrade package, the calculation efficiency is greatly improved.
[0085] In one implementation, after sending the retransmission request to the server, the method further includes:
[0086] Receive a target backup data block sent by the server, the target backup data block is determined by the server from the multiple backup data blocks according to the information of the error data block, the multiple backup data blocks are obtained by the server backing up the multiple file stream data blocks, and the multiple backup data blocks are stored in multiple second storage units. Update the error data block to the target backup data block.
[0087] Specifically, when the server receives a retransmission request sent by a terminal device, it can determine the target backup data block corresponding to the erroneous data block from multiple backup data blocks based on the information of the erroneous data block carried in the retransmission request, such as the hash value of the erroneous data block. The multiple backup data blocks are obtained by the server backing up multiple file stream data blocks, and the multiple backup data blocks are stored in multiple second storage units. The terminal device can receive the target backup data block sent by the server, and update the erroneous data block to the target backup data block, and then perform a firmware upgrade. In this way, the erroneous data block in the transmission process is determined by using Merkle tree comparison, and only the target backup data block of the erroneous data block is retransmitted, which improves the retransmission efficiency and reduces bandwidth occupancy.
[0088] In one implementation, the step of performing firmware upgrade according to the plurality of file stream data blocks includes:
[0089] When the integrity check of the plurality of file stream data blocks passes, the firmware is upgraded according to the plurality of file stream data blocks.
[0090] Specifically, in the terminal device, the integrity check can be repeatedly performed on the received file stream data blocks. When the integrity check passes, the terminal device can end the transmission process of the file stream data blocks and perform firmware upgrade according to the received multiple file stream data blocks.
[0091] In order to explain the estimation upgrade method provided in the embodiment of the present application in detail, the firmware upgrade method provided in the embodiment of the present application is explained in detail below through a specific example. Figure 5 As shown, the firmware upgrade method includes the following steps:
[0092] Step 501: Divide the upgrade file package into a plurality of file stream data blocks, and store them in a plurality of first storage units.
[0093] First, the upgrade file package to be transmitted to the terminal device can be divided into a plurality of file stream data blocks, and the file stream data blocks are distributed to a plurality of first storage units for storage.
[0094] Step 502: configure the index, storage location and other information of the file stream data blocks stored in each first storage unit to the file management unit.
[0095] Specifically, the index, storage location and other information of the file stream data blocks stored in each first storage unit can be configured in the file management unit, so that the file stream data blocks can be effectively searched and managed to accelerate the execution of the upgrade operation.
[0096] Step 503: The server sends the first Merkle tree to the terminal device.
[0097] The server can construct a first Merkle tree according to the hash value of each file stream data block, and the construction process of the first Merkle tree is not described in detail here. The server can send the first Merkle tree to the terminal device.
[0098] Step 504: The server sends multiple file stream data blocks to the terminal device.
[0099] Specifically, the server may send a plurality of file stream data blocks stored in a plurality of first storage units to the terminal device.
[0100] Step 505: The terminal device receives a plurality of file stream data blocks, and calculates a second Merkle tree according to the plurality of file stream data blocks.
[0101] Specifically, after receiving multiple file stream data blocks, the terminal device can construct a second Merkle tree according to the hash values of the multiple file stream data. The construction method of the second Merkle tree is the same as the construction method of the first Merkle tree, which will not be repeated here.
[0102] Step 506: Check whether the integrity of the multiple file stream data blocks passes.
[0103] Specifically, the terminal device can perform integrity check on the received multiple file stream data blocks according to the first Merkle tree and the second Merkle tree. Specifically, the terminal device can compare the root node hash values of the first Merkle tree and the second Merkle tree. If the root node hash values of the first Merkle tree and the second Merkle tree are different, the integrity check of the multiple file stream data blocks fails. If the root node hash values of the first Merkle tree and the second Merkle tree are the same, the integrity check of the multiple file stream data blocks passes. If the integrity check of the file stream data block passes, execute step 507. If the integrity check of the file stream data block fails, execute step 508.
[0104] Step 507: End the transmission of the file stream data block and perform firmware upgrade.
[0105] Step 508: Determine the erroneous data block based on the compared Merkle tree.
[0106] The terminal device can compare the node hash values of the first Merkle tree and the second Merkle tree layer by layer, and determine the erroneous data block from the multiple file stream data blocks based on the nodes that are different in the comparison results.
[0107] by Figure 3 The Merkle tree shown is used as an example. The terminal device compares the first Merkle tree with the second Merkle tree. If the root node hash values of the first Merkle tree and the second Merkle tree are inconsistent, the comparison continues to the next layer, comparing the roots of the left subtree and the right subtree respectively:
[0108] (1) If the root hash0 of the left subtree is different, then there is a problem with the file stream data block of the left subtree. That is, it can be determined that the file stream data blocks L1 to L2 have a problem, and the problem is continued to the next layer of the Merkle tree.
[0109] (2) If the root hash1 of the right subtree is different, then there is a problem with the file stream data block of the right subtree. That is, it can be determined that the file stream data blocks L3 to L4 have a problem, and the problem is continued to the next layer of the Merkle tree.
[0110] (3) If the root hash0 and hash1 of the left and right subtrees are different, there is a problem with the file stream data blocks of the left and right subtrees, and the problem is solved by going to the next level of the Merkle tree.
[0111] The purpose of constructing the entire Merkle tree is to speed up the location of the erroneous data block and shorten the time complexity of the entire location process to log n , n represents the number of file stream data blocks. If this Merkle tree is not constructed, the time complexity of locating the error block is n.
[0112] Step 509: Retransmit the erroneous data block.
[0113] Specifically, after the terminal device determines that the data block is an error, the terminal device will initiate a retransmission request for the error data block to the server. When the server receives the retransmission request sent by the terminal device, it can determine the target backup data block corresponding to the error data block from multiple backup data blocks based on the information of the error data block carried in the retransmission request, such as the hash value of the error data block. The server sends the target backup data block to the terminal device so that the terminal device updates the error data block to the target backup data block and can then perform a firmware upgrade. In this way, the error data block in the transmission process is determined by using Merkle tree comparison, and only the target backup data block of the error data block is retransmitted, which improves the retransmission efficiency and reduces bandwidth occupancy.
[0114] It should be noted that the firmware upgrade method provided in the embodiment of the present application can be executed by a firmware upgrade device or a control module in the firmware upgrade device for executing the firmware upgrade method. In the embodiment of the present application, the firmware upgrade device provided in the embodiment of the present application is described by taking the firmware upgrade method executed by the firmware upgrade device as an example.
[0115] Figure 6 1 is a schematic diagram of a firmware upgrade device provided according to an embodiment of the present application, and the firmware upgrade device is applied to a server. Figure 6 As shown, the firmware upgrade device 600 includes: a segmentation module 610 , a storage module 620 , and an execution module 630 .
[0116] The segmentation module 610 is used to segment the upgrade file package into multiple file stream data blocks. The storage module 620 is used to store the multiple file stream data blocks in multiple first storage units. The execution module 630 is used to send the multiple file stream data blocks stored in the multiple first storage units to the terminal device, so that the terminal device performs a firmware upgrade according to the multiple file stream data blocks.
[0117] In one implementation, the execution module 630 is also used to calculate the hash value of each of the file stream data blocks, construct a first Merkle tree based on the hash value of each of the file stream data blocks, and send the first Merkle tree to the terminal device so that the terminal device performs integrity verification on the multiple received file stream data blocks by comparing the first Merkle tree and the second Merkle tree, and the second Merkle tree is constructed by the terminal device based on the hash values of the multiple received file stream data blocks.
[0118] In one implementation, the storage module 620 is further configured to back up the plurality of file stream data blocks to obtain a plurality of backup data blocks, and store the plurality of backup data blocks in a plurality of second storage units.
[0119] In one implementation, the execution module 630 is used to, upon receiving a retransmission request sent by the terminal device, determine a target backup data block from the multiple backup data blocks based on information about the erroneous data block carried in the retransmission request, and send the target backup data block to the terminal device so that the terminal device updates the erroneous data block to the target backup data block. The retransmission request is sent by the terminal device when the integrity check of multiple file stream data blocks fails and the erroneous data block is determined from the multiple file stream data blocks. The erroneous data block is determined from the multiple file stream data blocks by the terminal device based on nodes that are different according to the comparison results after comparing the node hash values of the first Merkel tree and the second Merkel tree layer by layer.
[0120] In one implementation, when the root node hash value of the second Merkle tree is the same as the root node hash value of the first Merkle tree, the integrity check of the plurality of file stream data blocks passes.
[0121] In one implementation, the storage module 620 is also used to mark the erroneous data block stored in the first storage unit, and the mark is used to indicate that the erroneous data block in the first storage unit is damaged, and subsequent firmware upgrades are prohibited from obtaining the erroneous data block from the first storage unit.
[0122] In one implementation, the execution module 630 is used to use the hash values of the multiple file stream data blocks as leaf nodes in all nodes of the first Merkle tree, starting from the leaf nodes, calculating and generating a parent node for every two adjacent nodes until the root node is obtained, thereby obtaining the first Merkle tree.
[0123] The firmware upgrade device in the embodiment of the present application can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and the non-mobile electronic device can be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0124] The firmware upgrade device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0125] The firmware upgrade device provided in the embodiment of the present application can achieve Figure 1 To avoid repetition, the various processes implemented by the method embodiment are not described here.
[0126] Figure 7 1 is a schematic diagram of the structure of another firmware upgrade device provided according to an embodiment of the present application, and the firmware upgrade device is applied to a server. Figure 7 As shown, the firmware upgrade device 700 includes: a receiving module 710 and an upgrade module 720.
[0127] The receiving module 710 is used to receive a plurality of file stream data blocks sent by the server, wherein the plurality of file stream data blocks are obtained by the server by segmenting the upgrade file package, and in the server, the plurality of file stream modules are stored in a plurality of first storage units. The upgrading module 720 is used to perform firmware upgrade according to the plurality of file stream data blocks.
[0128] In one implementation, the receiving module 710 is also used to receive a first Merkle tree sent by the server, where the first Merkle tree is determined by the server based on hash values of multiple file stream data blocks, calculate the hash value of each received file stream data block, and construct a second Merkle tree based on the hash value of each file stream data block, and perform integrity verification on the multiple received file stream data blocks by comparing the first Merkle tree with the second Merkle tree.
[0129] In one implementation, the receiving module 710 is configured to, when the root node hash value of the second Merkle tree is different from the root node hash value of the first Merkle tree, indicate that the integrity check of the plurality of file stream data blocks has failed.
[0130] In one implementation, the receiving module 710 is used to verify that the integrity of the plurality of file stream data blocks passes when the root node hash value of the second Merkle tree is the same as the root node hash value of the first Merkle tree.
[0131] In one implementation, the receiving module 710 is used to compare the node hash values of the first Merkel tree and the second Merkel tree layer by layer when the integrity check of multiple file stream data blocks fails, determine the erroneous data block from the multiple file stream data blocks based on the nodes whose comparison results are different in the first Merkel tree and the second Merkel tree, and send a retransmission request to the server, wherein the retransmission request includes information of the erroneous data block.
[0132] In one implementation, the receiving module 710 is used to receive a target backup data block sent by the server, where the target backup data block is determined by the server from the multiple backup data blocks based on information about the error data block, and the multiple backup data blocks are obtained by the server backing up multiple file stream data blocks. The multiple backup data blocks are stored in multiple second storage units, and the error data block is updated to the target backup data block.
[0133] In one implementation, the receiving module 710 is used to use the hash values of the multiple file stream data blocks as leaf nodes in all nodes of the second Merkle tree, starting from the leaf nodes, calculating and generating a parent node for every two adjacent nodes until the root node is obtained, thereby obtaining the second Merkle tree.
[0134] In one implementation, the upgrade module 720 is used to perform firmware upgrade according to the multiple file stream data blocks when the integrity check of the multiple file stream data blocks passes.
[0135] The firmware upgrade device in the embodiment of the present application can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and the non-mobile electronic device can be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0136] The firmware upgrade device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0137] The firmware upgrade device provided in the embodiment of the present application can achieve Figure 4 To avoid repetition, the various processes implemented by the method embodiment are not described here.
[0138] Alternatively, if Figure 8 As shown, an embodiment of the present application further provides an electronic device 800, including a processor 801 and a memory 802, wherein the memory 802 stores a program or instruction that can be run on the processor 801, and when the program or instruction is executed by the processor 801, the following is achieved: dividing the upgrade file package into multiple file stream data blocks. The multiple file stream data blocks are stored in multiple first storage units. The multiple file stream data blocks stored in the multiple first storage units are sent to a terminal device, so that the terminal device performs a firmware upgrade according to the multiple file stream data blocks.
[0139] In one implementation, after storing the plurality of file stream data blocks in the plurality of first storage units, a hash value of each of the file stream data blocks is calculated. A first Merkle tree is constructed according to the hash value of each of the file stream data blocks. The first Merkle tree is sent to the terminal device so that the terminal device performs integrity check on the plurality of received file stream data blocks by comparing the first Merkle tree with a second Merkle tree, wherein the second Merkle tree is constructed by the terminal device according to the hash values of the plurality of received file stream data blocks.
[0140] In one implementation, after the upgrade file package is divided into a plurality of file stream data blocks, the plurality of file stream data blocks are backed up to obtain a plurality of backup data blocks, and the plurality of backup data blocks are stored in a plurality of second storage units.
[0141] In one implementation, after sending the first Merkle tree to the terminal device, upon receiving a retransmission request sent by the terminal device, a target backup data block is determined from the multiple backup data blocks based on the information of the erroneous data block carried in the retransmission request. The target backup data block is sent to the terminal device so that the terminal device updates the erroneous data block to the target backup data block. The retransmission request is sent by the terminal device when the integrity check of multiple file stream data blocks fails and the erroneous data block is determined from the multiple file stream data blocks. The erroneous data block is determined from the multiple file stream data blocks by the terminal device comparing the node hash values of the first Merkle tree and the second Merkle tree layer by layer, and based on the nodes that are different as a result of the comparison.
[0142] In one implementation, when the root node hash value of the second Merkle tree is the same as the root node hash value of the first Merkle tree, the integrity check of the plurality of file stream data blocks passes.
[0143] In one implementation, before determining a target backup data block corresponding to the information of the error data block from a plurality of the backup data blocks, the error data block stored in the first storage unit is marked, and the mark is used to indicate that the error data block in the first storage unit is damaged, and subsequent firmware upgrades prohibit obtaining the error data block from the first storage unit.
[0144] In one implementation, the hash values of the plurality of file stream data blocks are respectively used as leaf nodes in all nodes of the first Merkle tree. Starting from the leaf nodes, a parent node is generated by calculating every two adjacent nodes until a root node is obtained, thereby obtaining the first Merkle tree.
[0145] Alternatively, when the program or instruction is executed by the processor 801, it is implemented as follows: receiving multiple file stream data blocks sent by the server, the multiple file stream data blocks are obtained by the server dividing the upgrade file package, and in the server, the multiple file stream modules are stored in multiple first storage units. Firmware upgrade is performed according to the multiple file stream data blocks.
[0146] In one implementation, after receiving the plurality of file stream data blocks sent by the server, a first Merkle tree sent by the server is received, wherein the first Merkle tree is determined by the server according to the hash values of the plurality of file stream data blocks. The hash value of each received file stream data block is calculated. According to the hash value of each file stream data block, a second Merkle tree is constructed. The integrity of the plurality of received file stream data blocks is checked by comparing the first Merkle tree with the second Merkle tree.
[0147] In one implementation, when the root node hash value of the second Merkle tree is different from the root node hash value of the first Merkle tree, the integrity check of the plurality of file stream data blocks fails.
[0148] In one implementation, when the root node hash value of the second Merkle tree is the same as the root node hash value of the first Merkle tree, the integrity check of the plurality of file stream data blocks passes.
[0149] In one implementation, after integrity checking is performed on the received plurality of file stream data blocks by comparing the first Merkle tree and the second Merkle tree, if the integrity check of the plurality of file stream data blocks fails, the node hash values of the first Merkle tree and the second Merkle tree are compared layer by layer. According to nodes whose comparison results in the first Merkle tree and the second Merkle tree are different, an erroneous data block is determined from the plurality of file stream data blocks. A retransmission request is sent to the server, and the retransmission request includes information of the erroneous data block.
[0150] In one implementation, after sending the retransmission request to the server, a target backup data block sent by the server is received, the target backup data block is determined by the server from the multiple backup data blocks according to the information of the error data block, the multiple backup data blocks are obtained by the server by backing up the multiple file stream data blocks, and the multiple backup data blocks are stored in multiple second storage units. The error data block is updated to the target backup data block.
[0151] In one implementation, the hash values of the plurality of file stream data blocks are respectively used as leaf nodes in all nodes of the second Merkle tree. Starting from the leaf nodes, a parent node is generated by calculating every two adjacent nodes until a root node is obtained, thereby obtaining the second Merkle tree.
[0152] In one implementation, when the integrity check of the plurality of file stream data blocks passes, the firmware is upgraded according to the plurality of file stream data blocks.
[0153] The specific execution steps can refer to the various steps of the above-mentioned firmware upgrade method embodiment, and can achieve the same technical effect. To avoid repetition, they will not be repeated here.
[0154] It should be noted that the electronic devices in the embodiments of the present application include: servers, terminals, or other devices except terminals.
[0155] The above electronic device structure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. For example, the input unit may include a graphics processing unit (GPU) and a microphone, and the display unit may be configured with a display panel in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit includes a touch panel and at least one of other input devices. The touch panel is also called a touch screen. Other input devices may include, but are not limited to, a physical keyboard, function keys (such as volume control buttons, switch buttons, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
[0156] The memory can be used to store software programs and various data. The memory may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory may include a volatile memory or a non-volatile memory, or the memory may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. Volatile memory can be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct memory bus random access memory (DRRAM).
[0157] The processor may include one or more processing units; optionally, the processor integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to the operating system, user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor.
[0158] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned firmware upgrade method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0159] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as ROM, RAM, magnetic disk or optical disk.
[0160] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0161] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0162] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A firmware upgrade method, It is characterized in that Applicable to servers, including: Split the upgrade file package into multiple file stream data blocks; Storing a plurality of the file stream data blocks into a plurality of first storage units; The plurality of file stream data blocks stored in the plurality of first storage units are sent to a terminal device, so that the terminal device performs a firmware upgrade according to the plurality of file stream data blocks.
2. The method according to claim 1, It is characterized in that After storing the plurality of file stream data blocks in the plurality of first storage units, the method further comprises: Calculating a hash value of each file stream data block; Constructing a first Merkle tree according to the hash value of each of the file stream data blocks; The first Merkle tree is sent to the terminal device so that the terminal device performs integrity verification on the multiple received file stream data blocks by comparing the first Merkle tree with the second Merkle tree, and the second Merkle tree is constructed by the terminal device according to the hash values of the multiple received file stream data blocks.
3. The method according to claim 2, It is characterized in that After the upgrade file package is divided into multiple file stream data blocks, it also includes: Backing up the plurality of file stream data blocks to obtain a plurality of backup data blocks; The plurality of backup data blocks are stored in a plurality of second storage units.
4. The method according to claim 3, It is characterized in that After sending the first Merkle tree to the terminal device, the method further includes: In case of receiving a retransmission request sent by the terminal device, determining a target backup data block from the plurality of backup data blocks according to information of the erroneous data block carried in the retransmission request; Sending the target backup data block to the terminal device so that the terminal device updates the erroneous data block to the target backup data block; The retransmission request is sent by the terminal device when the integrity check of the plurality of the file stream data blocks fails and the erroneous data block is determined from the plurality of the file stream data blocks; The error data block is determined from the plurality of file stream data blocks by the terminal device comparing the node hash values of the first Merkle tree and the second Merkle tree layer by layer and determining nodes that are different according to the comparison results.
5. The method according to claim 2, It is characterized in that When the root node hash value of the second Merkle tree is the same as the root node hash value of the first Merkle tree, the integrity check of the plurality of file stream data blocks passes.
6. The method according to claim 4, It is characterized in that Before determining the target backup data block corresponding to the information of the error data block from the plurality of backup data blocks, the method further includes: The error data block stored in the first storage unit is marked, and the mark is used to indicate that the error data block in the first storage unit is damaged, and subsequent firmware upgrades are prohibited from obtaining the error data block from the first storage unit.
7. The method according to claim 2, It is characterized in that According to the hash value of each of the file stream data blocks, a first Merkle tree is constructed, including: Using hash values of the plurality of file stream data blocks as leaf nodes in all nodes of the first Merkle tree respectively; Starting from the leaf node, every two adjacent nodes are calculated to generate a parent node until the root node is obtained, thereby obtaining the first Merkle tree.
8. A firmware upgrade method, It is characterized in that Applied to terminal equipment, including: Receiving a plurality of file stream data blocks sent by a server, wherein the plurality of file stream data blocks are obtained by the server segmenting an upgrade file package, and in the server, the plurality of file stream modules are stored in a plurality of first storage units; Firmware upgrade is performed according to the plurality of file stream data blocks.
9. The method according to claim 8, It is characterized in that After receiving the plurality of file stream data blocks sent by the server, the method further comprises: receiving a first Merkle tree sent by the server, where the first Merkle tree is determined by the server according to hash values of a plurality of the file stream data blocks; Calculating a hash value of each received file stream data block; Constructing a second Merkle tree according to the hash value of each of the file stream data blocks; An integrity check is performed on the received plurality of file stream data blocks by comparing the first Merkle tree with the second Merkle tree.
10. The method according to claim 9, It is characterized in that The step of performing integrity checking on the received plurality of file stream data blocks by comparing the first Merkle tree with the second Merkle tree includes: When the root node hash value of the second Merkle tree is different from the root node hash value of the first Merkle tree, the integrity check of the plurality of file stream data blocks fails.
11. The method according to claim 9, It is characterized in that The step of performing integrity checking on the received plurality of file stream data blocks by comparing the first Merkle tree with the second Merkle tree includes: When the root node hash value of the second Merkle tree is the same as the root node hash value of the first Merkle tree, the integrity check of the plurality of file stream data blocks passes.
12. The method according to claim 9, It is characterized in that After performing integrity check on the received plurality of file stream data blocks by comparing the first Merkle tree with the second Merkle tree, the method further includes: When the integrity check of the plurality of file stream data blocks fails, comparing the node hash values of the first Merkle tree and the second Merkle tree layer by layer; According to nodes whose comparison results are different in the first Merkle tree and the second Merkle tree, an erroneous data block is determined from the plurality of file stream data blocks; A retransmission request is sent to the server, where the retransmission request includes information about the erroneous data block.
13. The method according to claim 12, It is characterized in that After sending the retransmission request to the server, the method further includes: receiving a target backup data block sent by the server, wherein the target backup data block is determined by the server from the multiple backup data blocks according to information of the error data block, the multiple backup data blocks are obtained by the server by backing up the multiple file stream data blocks, and the multiple backup data blocks are stored in multiple second storage units; The error data block is updated to the target backup data block.
14. The method according to claim 9, It is characterized in that The step of constructing a second Merkle tree according to the hash value of each of the file stream data blocks comprises: Using hash values of the plurality of file stream data blocks as leaf nodes in all nodes of the second Merkle tree respectively; Starting from the leaf node, a parent node is generated by calculating every two adjacent nodes until the root node is obtained, thereby obtaining the second Merkle tree.
15. The method according to claim 9, It is characterized in that The firmware upgrade is performed according to the plurality of file stream data blocks, comprising: When the integrity check of the plurality of file stream data blocks passes, the firmware is upgraded according to the plurality of file stream data blocks.
16. An electronic device, It is characterized in that It includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein when the program or instruction is executed by the processor, the steps of the firmware upgrade method according to any one of claims 1 to 6 are implemented or the steps of the firmware upgrade method according to any one of claims 7 to 15 are implemented.
17. A readable storage medium, It is characterized in that The readable storage medium stores a program or instruction, and when the program or instruction is executed by the processor, the steps of the firmware upgrade method according to any one of claims 1 to 6 or the steps of the firmware upgrade method according to any one of claims 7 to 15 are implemented.
Citation Information
Cited By
Differential upgrading method for integrated electronic communication module
CN121614169A