+

CN120687125A - Updating method, updating device, updating server, updating client and updating computer program product - Google Patents

Updating method, updating device, updating server, updating client and updating computer program product

Info

Publication number
CN120687125A
CN120687125A CN202510726626.9A CN202510726626A CN120687125A CN 120687125 A CN120687125 A CN 120687125A CN 202510726626 A CN202510726626 A CN 202510726626A CN 120687125 A CN120687125 A CN 120687125A
Authority
CN
China
Prior art keywords
block
firmware
blocks
differential
client
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202510726626.9A
Other languages
Chinese (zh)
Inventor
郭新新
许飞
徐记超
王斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Streamax Technology Co Ltd
Original Assignee
Streamax Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Streamax Technology Co Ltd filed Critical Streamax Technology Co Ltd
Priority to CN202510726626.9A priority Critical patent/CN120687125A/en
Publication of CN120687125A publication Critical patent/CN120687125A/en
Pending legal-status Critical Current

Links

Landscapes

  • Stored Programmes (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The application discloses an updating method, an updating device, a server, a client and a computer program product. The method for the server comprises the steps of partitioning mirror images of first firmware and latest second firmware which are installed at present on a client based on a preset first partition size to obtain a plurality of first blocks and second blocks, comparing the first blocks with the second blocks in sequence to determine first target blocks and corresponding second target blocks with differences, partitioning the first target blocks and corresponding second target blocks based on the preset second partition size to obtain a plurality of first sub-blocks and second sub-blocks, performing differential operation on the first sub-blocks and corresponding second sub-blocks in sequence to obtain differential results, packaging data based on all differential results which are not 0 to obtain differential packets, and transmitting the differential packets to the client to trigger the client to update based on the differential packets. The scheme of the application can reduce the flow consumption in the upgrading process on the premise of high efficiency.

Description

Updating method, updating device, updating server, updating client and updating computer program product
Technical Field
The present application relates to the field of electronic information technologies, and in particular, to an update method, an update apparatus, a server, a client, and a computer program product.
Background
Service providers typically need to maintain various software feature services that they provide, a common way of maintaining is to release new versions of firmware. One way of original update for a client is to download a new version of firmware from a server as a whole. This approach results in very much data to be transmitted and is prone to download errors. Based on this, a differential-based update method has been proposed currently, and the general implementation process is that after comparing the new version firmware and the old version firmware at byte level, a differential packet is generated, so that the client only needs to download the differential packet from the server to implement the update.
However, in a scenario where the firmware size is large or the number of updates is frequent, simple byte level comparison may be inefficient, and the size of the generated differential packet still has some space for optimization. That is, the current update method has problems such as low differential efficiency and high flow consumption.
Disclosure of Invention
The application provides an updating method, an updating device, a server, a client and a computer program product, which can reduce flow consumption in the upgrading process on the premise of ensuring efficiency.
In a first aspect, the present application provides an updating method, which is applied to a server, including:
Partitioning the mirror image of the first firmware and the mirror image of the second firmware based on a preset first partition size to obtain a plurality of first blocks included in the first firmware and a plurality of second blocks included in the second firmware, wherein the first firmware is currently installed firmware of the client, and the second firmware is the latest firmware;
sequentially comparing each first block with the corresponding second block to determine a first target block with a difference and a corresponding second target block;
partitioning each first target block and a corresponding second target block based on a preset second partitioning size to obtain a plurality of first sub-blocks included in each first target block and a plurality of second sub-blocks included in a corresponding second target block, wherein the first partitioning size is larger than the second partitioning size;
Performing differential operation on each first sub-block and the corresponding second sub-block in sequence to obtain a differential result;
data packaging is carried out on the basis of all target differential results to obtain differential packets, wherein the target differential results are differential results which are not 0;
the differential packets are transmitted to the client to trigger the client to update based on the differential packets.
Optionally, comparing each first block and the corresponding second block sequentially to determine a first target block and a corresponding second target block having a difference, including:
determining each first block and the corresponding second block as a first block to be compared and a second block to be compared in sequence based on a preset block index sequence;
respectively calculating hash values of the first block to be compared and the second block to be compared;
And determining the first block to be compared and the second block to be compared as a first target block and a second target block under the condition that the hash value of the first block to be compared is different from the hash value of the second block to be compared.
Optionally, performing data packaging based on all target differential results to obtain differential packets, including:
Calculating verification information according to each target difference result, the block index corresponding to each target difference result and the sub-block index corresponding to each target difference result;
and packaging each target differential result, the block index corresponding to each target differential result, the sub-block index corresponding to each target differential result and the verification information into differential packets.
In a second aspect, the present application provides an update method, which is applied to a client, including:
receiving a differential packet transmitted by a preset server;
Generating a candidate image of a second firmware based on the difference packet and the image of the first firmware, wherein the first firmware is the currently installed firmware of the client, and the second firmware is the latest firmware;
Checking the candidate mirror image;
writing the candidate mirror image into the standby partition under the condition that the candidate mirror image passes the verification;
updating is performed based on the candidate images.
In a third aspect, the present application provides an updating apparatus, which is applied to a server, including:
the first block partitioning module is used for partitioning the mirror image of the first firmware and the mirror image of the second firmware based on a preset first block size to obtain a plurality of first blocks included in the first firmware and a plurality of second blocks included in the second firmware, wherein the first firmware is currently installed firmware of the client, and the second firmware is the latest firmware;
The comparison module is used for sequentially comparing each first block with the corresponding second block so as to determine a first target block with a difference and a corresponding second target block;
The second block dividing module is used for dividing each first target block and the corresponding second target block based on a preset second block dividing size to obtain a plurality of first sub-blocks included in each first target block and a plurality of second sub-blocks included in the corresponding second target block, wherein the first block dividing size is larger than the second block dividing size;
the differential module is used for sequentially carrying out differential operation on each first sub-block and the corresponding second sub-block to obtain a differential result;
the packaging module is used for carrying out data packaging based on all the target differential results to obtain differential packets, wherein the target differential results are differential results which are not 0;
And the transmission module is used for transmitting the differential packets to the client so as to trigger the client to update based on the differential packets.
Optionally, updating based on the candidate image includes:
Loading the latest operation file into the memory standby area based on the candidate mirror image, wherein the operation file comprises a dynamic library file and/or an executable file;
establishing a new memory map based on the latest operation file;
and under the condition that the new memory mapping passes the verification, switching the memory references based on the new memory mapping so as to realize updating.
Optionally, establishing a new memory map based on the latest running file includes:
partitioning the latest operation file by adopting a preset partitioning strategy to obtain a plurality of latest operation file blocks;
Establishing a new memory map based on each latest operation file block;
accordingly, switching the memory references based on the new memory map includes:
determining whether the latest operation file block enters a safe update window for each latest operation file block;
and under the condition that the latest operation file block enters the safe updating window, performing atomic switching on the memory reference corresponding to the latest operation file block based on the new memory mapping.
Optionally, after performing atomic switching on the memory reference corresponding to the latest running file block, the updating method further includes:
determining whether a memory reference corresponding to the latest operation file block has a fault or not in a preset observation period;
And under the condition of faults, backing off the memory references corresponding to the latest operation file blocks.
In a fourth aspect, the present application provides an updating apparatus, which is applied to a client, including:
the receiving module is used for receiving the differential packet transmitted by the preset server;
The generating module is used for generating a candidate image of the second firmware based on the difference packet and the image of the first firmware, wherein the first firmware is the currently installed firmware of the client, and the second firmware is the latest firmware;
the verification module is used for verifying the candidate mirror images;
the writing module is used for writing the candidate mirror image into the standby partition under the condition that the candidate mirror image passes the verification;
and the updating module is used for updating based on the candidate mirror image.
In a fifth aspect, the present application provides a server comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the method as in the first aspect when the computer program is executed.
In a sixth aspect, the present application provides a client comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the method as in the second aspect when the computer program is executed.
In a seventh aspect, the present application provides a computer program product comprising a computer program which, when executed by one or more processors, implements the steps of the method of the first and/or second aspects described above.
Compared with the prior art, the method has the advantages that the server does not directly compare the new firmware with the old firmware in byte level, adopts a multi-level segmentation strategy, performs preliminary segmentation on the firmware, reduces the calculation complexity, rapidly locates the area where the difference position is located, performs further segmentation in the area, adopts finer granularity comparison, and thus obtains the difference packet which is finally transmitted to the client for updating. In this way, the differential efficiency can be improved and the differential packet size can be reduced. It will be appreciated that the advantages of the second to seventh aspects may be found in the relevant description of the first aspect, and are not described here again.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments or the description of the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings can be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of an implementation flow of an update method according to an embodiment of the present application;
FIG. 2 is a schematic diagram of an implementation flow of another update method according to an embodiment of the present application;
FIG. 3 is a block diagram of an update apparatus according to an embodiment of the present application;
FIG. 4 is a block diagram of another update apparatus according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of a server according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of a client according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth such as the particular system architecture, techniques, etc., in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
With the high-speed development of embedded systems and internet of things devices, continuous iterative upgrade of system software is more frequent. Currently, a common updating mode adopts a traditional whole package updating mode, namely, a client directly downloads a new version firmware from a server. Obviously, this upgrade mode results in a very large amount of data to be transferred between the server and the client, and is prone to download errors. Based on this, a differential-based upgrade mode has been proposed currently, which has a general procedure that a server compares the new version firmware with the old version firmware, generates a differential packet, and a client only needs to download the differential packet from the server to realize the update. However, in a scenario where the firmware scale is large or the number of updates is frequent, even if the upgrade mode based on the difference is adopted, the simple byte comparison may be less efficient, and the size of the generated difference packet still has a certain optimization space.
Based on the above consideration, the embodiment of the application provides an updating method, which adopts a multi-stage segmentation strategy, firstly performs preliminary segmentation on firmware, reduces the computational complexity, rapidly locates the area where the difference position is located, further segments the area, and adopts finer granularity comparison to obtain the difference packet, thereby not only improving the difference efficiency, but also reducing the size of the obtained difference packet. In order to illustrate the technical scheme provided by the embodiment of the application, the following description is made by specific embodiments.
An update method according to an embodiment of the present application is described below, and the update method is applied to a server. Referring to fig. 1, an update method provided by an embodiment of the present application includes:
And 101, partitioning the mirror image of the first firmware and the mirror image of the second firmware based on a preset first partition size to obtain a plurality of first blocks included in the first firmware and a plurality of second blocks included in the second firmware.
To ensure upgrade controllability and security, firmware images (rather than firmware itself) are commonly used in the art to make differential packets, and are not described in detail herein. For any software, the server should store all versions of the firmware image of the software to accommodate the various possible upgrade requirements of different clients. Based on this, after the developer obtains the latest firmware image of the software based on the development work, the operator can upload the latest firmware image of the software to the server. In addition, if any of the historical versions of the firmware image is not saved on the server, the operator also needs to upload the historical version of the firmware image to the server. Considering that there may be multiple versions of the firmware image stored by the server, for convenience of description, the embodiment of the present application refers to the currently installed firmware of the client having the update requirement as the first firmware, and refers to the latest firmware as the second firmware.
In some examples, the server may determine the image of the first firmware by receiving a firmware version number reported by the client, and performing a lookup based on the firmware version number to determine a firmware image corresponding to the firmware version number, that is, the image of the first firmware.
In order to minimize the size of the differential packet, in the embodiment of the present application, a multi-level slicing strategy is proposed. Based on this, after determining the image of the first firmware and the image of the second firmware, the server may block the first firmware and the second firmware based on the preset first block size. It will be appreciated that the first chunk size is a relatively large size, i.e., the primary chunk operation is performed this time. In general, the number of blocking results for the image of the first firmware and the image of the second firmware is the same, i.e. the number of resulting first blocks and the number of second blocks generally remain the same.
In some examples, the first block size may be a predetermined value, such as 4 kilobytes (kB) or 8kB, or the first block size may be determined according to the flash erase characteristics of the system or the common paging, which is not limited by the embodiments of the present application.
After the blocking operation of this step is completed, the server may obtain a blocking list for each firmware image. For example only, for the mirroring of the first firmware, the resulting blocklist may be denoted { B1, B2,..and Bn }, after blocking based on the preset first blocksize, and for the mirroring of the second firmware, the resulting blocklist may be denoted { B '1, B '2,..and B ' n }.
Step 102, comparing each first block and the corresponding second block in sequence to determine a first target block and a corresponding second target block with differences.
The server may sequentially compare each first block with the corresponding second block after obtaining the plurality of first blocks and the plurality of second blocks. As described above, the number of the first blocks and the number of the second blocks are generally consistent, so that the correspondence between the first blocks and the second blocks, that is, the first blocks and the second blocks corresponding to each other, may be determined based on the block indexes of the respective blocks. Therefore, the server can sequentially determine each first block and the corresponding second block as a first block to be compared and a second block to be compared based on a preset block index sequence.
For the first block to be compared and the second block to be compared, the server can calculate and obtain respective hash values of the first block to be compared and the second block to be compared by adopting a preset hash algorithm. By way of example only, the predetermined Hash algorithm may be a Rolling Hash (Rolling Hash) algorithm, a quick Hash algorithm, or the like, without limitation. It can be understood that if the first block to be compared and the second block to be compared are completely consistent, the hash values of the first block to be compared and the second block to be compared are necessarily consistent, otherwise, if the first block to be compared and the second block to be compared are different, the hash values of the first block to be compared and the second block to be compared have extremely high probability, and the hash values of the first block to be compared and the second block to be compared are also different. Based on the above, the server can determine the first block to be compared and the second block to be compared as the first target block and the second target block when the hash value of the first block to be compared and the hash value of the second block to be compared are different. After traversing all the first blocks and the corresponding second blocks, the server can screen out all the first target blocks and the second target blocks.
Of course, the server may also calculate hash values for each first chunk to obtain a first hash table, denoted { H1, H2..once, hn }, and similarly may calculate hash values for each second chunk to obtain a second hash table, denoted { H '1, H ' 2..once, H ' n }, and based on the chunk indices, the server may quickly complete a comparison of the first hash table and the second hash table to determine all chunk indices for which hash values differ, thereby screening out all first target chunks and corresponding second target chunks. The embodiment of the application does not limit the specific implementation manner of determining the first target block and the corresponding second target block.
And 103, partitioning each first target block and the corresponding second target block based on a preset second partition size to obtain a plurality of first sub-blocks included in each first target block and a plurality of second sub-blocks included in the corresponding second target block.
Based on the multi-level slicing strategy, after determining the first target block and the corresponding second target block, the server may further refine the target blocks based on the preset second slicing size. It will be appreciated that the second chunk size is a relatively small size that is smaller than the first chunk size set forth above, i.e., the smaller granularity of the chunk operation is performed this time. Generally, for each pair of a first target block and a second target block (i.e., a first target block and a corresponding second target block), the number of block splitting results is the same, i.e., the number of first sub-blocks obtained based on each first target block is generally consistent with the number of second sub-blocks obtained based on the corresponding second target block. Based on this, a sub-block index may be set, and the sub-block index may be combined with the block index set forth above, so as to determine a corresponding pair of the first sub-block and the second sub-block.
In some examples, the first block size may be a predetermined value, such as 512 bytes (B) or less, or the second block size may be determined based on the first block size, which is not limited by the embodiments of the present application.
And 104, sequentially carrying out differential operation on each first sub-block and the corresponding second sub-block to obtain a differential result.
It has been described above that by means of the block index and the sub-block index, a corresponding pair of first sub-block and second sub-block can be determined, i.e. the block index is the same for any first sub-block and its corresponding second sub-block, and the sub-block index is the same. Based on the above, the server may perform differential operation on each first sub-block and the corresponding second sub-block sequentially after obtaining the plurality of first sub-blocks and the plurality of second sub-blocks. Specifically, the server may sequentially determine each first sub-block and the corresponding second sub-block as a first sub-block to be differentiated and a second sub-block to be differentiated based on a preset block index order and a sub-block index order.
For the first sub-block to be differentiated and the second sub-block to be differentiated, the server can perform byte-level differential operation on the first sub-block to be differentiated and the second sub-block to be differentiated. It can be understood that if the first sub-block to be differential and the second sub-block to be differential are completely consistent, the differential result of the first sub-block to be differential and the second sub-block to be differential is 0, otherwise, if the first sub-block to be differential and the second sub-block to be differential have differences, the differential result of the first sub-block to be differential and the second sub-block to be differential is a non-0 value. After traversing all the first sub-blocks and the corresponding second sub-blocks, the server can obtain all the differential results.
And 105, packaging data based on all the target differential results to obtain differential packets.
In order to control the size of the differential packets and reduce the flow consumption in the data transmission process, the server will not package all the differential results but only the target differential results. Wherein the target differential result refers to a differential result other than 0.
On the basis, in order to avoid transmission errors and ensure updating accuracy and integrity, the server can calculate the verification information according to each target differential result, the block index corresponding to each target differential result and the sub-block index corresponding to each target differential result. Thus, the verification information corresponding to each target differential result can be obtained. In some examples, the verification information may be calculated by a hash algorithm or other verification algorithm, not limited herein. And then, the server can package each target differential result, the block index corresponding to each target differential result, the sub-block index corresponding to each target differential result and the verification information into differential packets. In some examples, the server may specifically use metadata of the obtained verification information, instead of the verification information itself, so as to have both advantages of interpretability and structural significance, and facilitate identification, verification, positioning, compatible expansion, and the like of the subsequent client in the update process.
And step 106, transmitting the differential packet to the client to trigger the client to update based on the differential packet.
After obtaining the differential packet, the server may transmit the differential packet to the client having the update requirement, so that the client updates based on the differential packet after receiving the differential packet.
In some embodiments, to prevent the differential packet from being tampered with during transmission or storage, the server may also encrypt the differential packet after it is obtained. The encryption mode may be symmetric encryption or asymmetric encryption, and is not limited herein. On this basis, the server may also sign the differential packet with a private key. Of course, the server may also sign each block or segment of the differential packet locally, respectively, to ensure that the differential packet is timely identified even if it is locally tampered with.
In some embodiments, to ensure security during transmission, the server may transmit the differential packets to the client over an encrypted channel. The encryption channel may be HTTPS/TLS, or the encryption channel may be a private VPN, which is not limited herein.
In some embodiments, to further reduce the amount of data during transmission, the server may further compress the differential packet after obtaining the differential packet by using a preset compression algorithm, where the compression algorithm may be zstd, LZ4 or Brotli, and the like, and is not limited herein. In this way, the original differential packets are not transmitted to the client in the following, but the compressed differential packets.
From the above, in the embodiment of the present application, the server does not directly perform byte level comparison on the new firmware and the old firmware, but adopts a multi-level segmentation strategy, performs preliminary segmentation on the firmware, reduces the computational complexity, rapidly locates the region where the difference position is located, performs further segmentation in the region, and adopts finer granularity comparison, thereby obtaining the difference packet to be finally transmitted to the client for updating. In this way, the differential efficiency can be improved and the differential packet size can be reduced.
Another update method proposed by the embodiment of the present application is described below, and the update method is applied to a client. Referring to fig. 2, a client method provided by an embodiment of the present application includes:
step 201, receiving a differential packet transmitted by a preset server.
The client may report its firmware version number to the server, enabling the server to learn which version of firmware the client currently installs. In some examples, the client may actively report its firmware version number to the server immediately after each firmware is installed, or may actively report its firmware version number to the server when there is an update demand (e.g., when the client has been updated for a preset period of time from last time), which is not limited by the reporting timer of the client in the embodiment of the present application.
In the case where the currently installed firmware of the client is not the latest version of firmware, the server may pertinently make a differential packet for the client using a multi-level splitting policy and transmit the differential packet to the client. Thus, the client can receive the differential packet transmitted by the server.
In some embodiments, the client may specifically receive the differential packet via an encrypted channel. The encryption channel may be HTTPS/TLS, or the encryption channel may be a private VPN, which is not limited herein.
In some embodiments, after receiving the differential packet, the client may further decrypt and/or verify the signature of the differential packet using a public key or a symmetric key stored locally through secure storage (including but not limited to trust zone and TPM, etc.), to ensure that the data of the differential packet has not been tampered with.
Step 202, generating a candidate image of the second firmware based on the differential packet and the image of the first firmware.
Similar to what has been described above, the first firmware is the firmware that the client has currently installed, and the second firmware is the latest firmware. In order to avoid that the updating process affects the normal operation of the client, the client may call the synthesis tool in a specified period of time, so that the synthesis tool may generate a candidate image of the second firmware based on the differential packet and the image of the first firmware. In some examples, the specified period may be a period preset by a user, or the specified period may be a period when the client detects that its running load is lower than a preset load threshold, which is not limited by the embodiment of the present application.
And 203, checking the candidate mirror image.
After synthesizing the candidate image, the server may calculate a hash value of the candidate image, thereby verifying the candidate image based on the hash value. In some examples, the hash value of the candidate image may be calculated by the following formula:
Wherein H () represents a hash function used by a single block, which may be SHA-256, etc., without limitation, Δi represents a difference result of an i-th block in the difference packet, F old,i represents data of a mirror image of the first firmware at the i-th block, F candidate represents a candidate mirror image of the second firmware; Representing the merging/updating operation of the corresponding bytes or bits, k being the total number of blocks that need to be updated.
The client may use the private key to sign the hash value after obtaining the hash value of the candidate image, or use the existing signature file to verify the hash value, and compare the hash value with the signature provided by the server, thereby ensuring the validity, reliability and integrity of the synthesized candidate image.
Step 204, in the case that the candidate image passes the verification, writing the candidate image into the spare partition.
Once the candidate image passes the verification, i.e., the verification result of the candidate image indicates that it is legitimate, the client may write the candidate image to the spare partition (i.e., partition B). In the embodiment of the application, the client can adopt a block-level writing + checking strategy, and the method is characterized in that the client immediately calculates the checking value of the written block after writing one block of the candidate mirror image to the standby partition, wherein the checking value can be a hash value or a cyclic redundancy check (Cyclic Redundancy Check, CRC) value, and the checking value is compared with the expected checking value of the block. If the comparison result is inconsistent, the client can continue writing the next block, otherwise, if the comparison result is inconsistent, the error occurs in the writing process, and operations such as re-writing are necessary for the block. After all the blocks are written, the client can perform signature verification on the whole of the blocks again, and details are omitted here.
In some embodiments, during the process of writing the candidate image into the spare partition, if the power-off or verification fails, the client may record the writing progress first and continue writing based on the writing progress after the next power-on, or may fall back to the firmware image still available in the system partition (i.e. partition a), which is not limited herein.
In step 205, an update is performed based on the candidate image.
The client may update based on the written candidate images. In some application scenarios, if the core content (including but not limited to the kernel, etc.) that needs to be updated must be validated at the next reset, the boot logic of the boot loader (Bootloader) may set to be started with the spare partition (i.e., partition B) preferentially, so that the client may wait for the next restart to update. In other application scenarios, if the content to be updated only includes user mode application and/or dynamic library, the embodiment of the application provides a memory mirror image real-time update mechanism for the content, and can complete memory switching on the premise of no shutdown of the system, thereby realizing update.
In order to facilitate understanding of the update method proposed by the embodiment of the present application, the following description is given by way of specific examples:
The client may be equipped with an ARM Cortex-A series processor, which may have a TrustZone built therein, a Flash memory may be configured to divide at least A, B two firmware partitions having the same size, it being understood that A is specifically a system partition and B is specifically a standby partition, and in addition, another additional space may be divided in the Flash memory for storing differential packets, temporary files, and the like. It can be understood that the client stores the key related to the update procedure through the trust zone, so as to construct a secure environment, and the signature verification and decryption operations can be completed in the secure environment, and of course, the processor can also store the key related to the update procedure through the secure MCU, which is not limited herein.
Based on the above hardware configuration, a specific flow of updating by the client is described below:
step 1, bootloader of the client runs first after the client is powered on, so that the image signature of the firmware partition A or B is read, and if the signature passes and the configuration specification, the Bootloader can jump to the kernel or the main program entry of the firmware partition to execute subsequent operations.
And 2, the server stores a plurality of firmware images F_old of old versions and a plurality of firmware images F_new of latest versions, so that the server can find out the corresponding firmware image F_old of the old version according to the firmware version number actively reported by the client or the firmware version number of the client inquired through the platform, and the server can manufacture a differential packet based on a multi-stage segmentation strategy together with the firmware image F_new of the latest version and use a private key signature, meanwhile, the server can also provide a differential metadata file, wherein the differential metadata file can comprise the old version number, the new version number, the blocking information, the verification mode and the like, and the differential metadata file can also use the private key signature, so that the differential metadata file is not limited.
And 3, downloading the differential packet and the differential metadata file through the secure channel by the client, and checking the signatures of the differential packet and the differential metadata file.
And 4, after the signatures of the two are verified, the client calls a synthesis tool, and synthesizes the difference packet and the local firmware image of the old version together to obtain a candidate image F_candidate. In the process, the hash or CRC32 is compared block by block, the global SHA-256 is calculated after the synthesis is confirmed to be correct, the public key is adopted to verify the signature of the server, and if the matching is successful, the validity of the candidate mirror image can be confirmed.
Step 5, the client writes the candidate image f_candidate to the spare partition B, a process involving block-level writing and image verification. The block-level writing means that the candidate image F_candidate is written into the standby partition B by the partition, the data errors caused by abrasion or electromagnetic interference are avoided when the blocks are written, the image checking means that after all the blocks of the candidate image F_candidate are written, the full image signature checking is executed on the standby partition B, and after the checking is passed, the status of 'new firmware available' is marked in the standby partition B. It should be noted that, in this writing process, the index information of the current writing block can be recorded all the time, if the power is cut off in the middle, the writing progress can be queried based on the index information and writing can be continued from the interruption position after the next power is applied, so as to reduce the repeated writing operation.
In some embodiments, the client may modify the Bootloader, specifically, configure the Bootloader to support dual partition/multi-partition startup and perform signature verification at startup, and if it is detected that the new image (i.e., candidate image) of the system partition (i.e., partition a) or the spare partition (i.e., partition B) has passed all security verification, mark the next startup loading partition as the partition where the new image is located, so that the startup is performed automatically from the partition at the next power-up. If the new image (i.e., the candidate image) fails to start or operates abnormally, the Bootloader may automatically select the old version partition (i.e., the partition where the image of the first firmware is located) when it is powered on next time, or may manually trigger rollback by the system administrator, which is not limited herein.
It can be understood that, based on the memory mirror image real-time update mechanism, the client can gradually replace the old version library or module with the new version under the condition that the device kernel or the user state process continuously runs, so as to realize the software upgrading without perception or with shortest perception by the user. Based on this, step 205 may comprise:
a1, loading the latest operation file into the memory standby area based on the candidate mirror image.
As described above, the memory mirror real-time update mechanism is only applicable to application scenarios where the content to be updated includes only user-mode applications and/or dynamic libraries, and thus the running files of interest herein are specifically referred to as dynamic library files and/or executable files.
After the candidate image has been written into the spare partition, the client may map the running file corresponding to the candidate image (i.e., the latest running file) to the memory spare area. It should be noted that this operation does not replace the old running file that is currently in use. After the latest running file is loaded in the memory standby area and the verification is completed, the client starts the subsequent updating flow.
A2, establishing a new memory map based on the latest operation file;
Under the memory mirror image real-time updating mechanism, the client side can perform version identification in advance through a memory mirror image version table. The memory mirror version table is used for recording the actual loading address and the corresponding version number of the running file in the memory, and the memory mirror version table can be maintained in a kernel layer or a management layer of the client side, which is not limited herein. Based on this, the client may establish a new memory map based on the latest running file after the latest running file has been loaded into the memory spare area, that is, update the memory mirror version table.
In some embodiments, the client may also chunk the run files (including old run files and new run files), and the employed chunking policy may remain consistent with the differentiated chunking policy described above. Thus, each run file block of a run file will have a unique version identification. The memory mirror version table can be optimized to record the actual loading address and corresponding version number of each running file block of the running file in the memory. The method can be optimized to block the latest operation file by adopting a preset block strategy to obtain a plurality of latest operation file blocks, and establish a new memory map based on each latest operation file block.
A3, under the condition that the new memory mapping passes the verification, switching the memory reference based on the new memory mapping so as to realize updating.
The client may check the integrity of the new memory map. In the case that the new memory map passes the verification, that is, the integrity of the new memory map is confirmed, the client may switch the memory references based on the new memory map, thereby implementing the hot update of the memory. Otherwise, if the new memory map fails to pass the verification, the client may discard the current hot update for the memory, or return to execute step A1 and the subsequent steps, which is not limited herein.
In some embodiments, in the case that the client performs a blocking operation on the running file, in order to ensure consistency, the client may add a synchronization point at a key function entry or a common interface, or introduce a mechanism such as a Read-write lock/Read-Copy-Update (RCU) or the like, so as to detect a security Update window of each latest running file block. Wherein, the safe update window refers to that all executing threads and/or processes leave the function area contained in the old running file block, and no new call is entered. For any latest running file block, the client can perform atomic switching on the memory reference corresponding to the latest running file block based on the new memory mapping only when the client enters the security update window, so that the memory reference pointing to the running file block of the old version is switched to the running file block of the new version, and the normal running of the client is not influenced by the switching operation. The atomic switch refers to an atomic level page table update and/or a segment table update, where the page table and the segment table refer to a memory management structure of an operating system or a processor of the client, and are not described herein.
In some examples, detection of a secure update window may be implemented at the application layer by, in particular, the client maintaining an active reference count (ACTIVE REFERENCE count) for each function or library module. When a thread calls the function or library module, the corresponding active reference count is +1, and after the call is finished, the corresponding active reference count is-1. When the memory mirror image real-time updating mechanism provided by the embodiment of the application is to be adopted to perform hot updating on the memory, aiming at the function or library module, the client can prohibit a new call request from entering, for example, a temporary lock is added to the function entry, or the call is directly forwarded to a new version, and the corresponding active reference count is waited to be reduced to 0. Once its corresponding active reference count is equal to 0, it indicates that all threads have completed execution of the old version function, confirming that the secure update window is currently entered.
In other examples, detection of the security update window may be implemented at the driver/kernel layer, in particular, by implementing detection of the security update window based on the RCU. When a certain code or data structure needs to be replaced, the client can firstly create a new copy, then make all processors enter a security point (quick state), and confirm that no thread is using the old copy, then confirm that the current process has entered a security update window.
In some embodiments, to further ensure the security and availability of the update, the client may also introduce a viewing period of a preset duration. Based on the observation period, after step A3, the client may further perform the following operations:
B1, determining whether the memory reference corresponding to the latest operation file block has faults or not in a preset observation period.
During the observation period, the client segment can execute test cases and/or collect operation indexes and the like, and monitor whether the memory references corresponding to the latest operation file block fail or not in the process, and during the period, the memory references of the old version are not released immediately but are temporarily reserved. The client may expand the memory mirror version table into a memory mirror dual version table, thereby recording both (i.e., the new version of the memory application and the old version of the memory reference).
And B2, under the condition of faults, backing off the memory references corresponding to the latest operation file blocks.
Once the client monitors that the new version of the memory reference has faults, the client can fall back to the old version of the memory reference. It should be noted that, when rollback is performed, atomic switching can be performed through the memory mirror version table, so as to avoid affecting the running service logic. The client may wait for the system administrator or subsequent schedule to confirm the cause of the failure before further processing, or the client may wait for the start of the automatic entry into the spare partition (i.e., partition B) after the restart, i.e., the start using updated software, without limiting the operations performed by the client after the backoff. On the basis, the client can automatically collect fault logs before and after rollback and upload the fault logs to the server, thereby assisting in analyzing the fault reasons.
In some embodiments, the client may also keep a Watchdog (Watchdog) or heartbeat mechanism running during the update process. In the process of hot updating the memory based on a memory mirror image real-time updating mechanism, the client can also set a specific upgrading monitoring process to carry out health detection on a newly loaded module, including but not limited to CPU utilization rate, error log and/or interface calling success rate, and the like, and if the health detection result indicates abnormality (for example, certain index values exceed a preset index threshold value), the rollback can be automatically executed.
In order to facilitate understanding of the memory mirror image real-time update mechanism in the update method provided by the embodiment of the present application, the following description is given by way of specific examples:
Assume that the application scenario is that a network protocol stack dynamic library libnet.so of the client needs to be updated from v1.0 to v2.1. The old version is libnet.so v1.0 and memory addresses 0x1000-0x2000, the new version is libnet.so v2.1, the spare partition B is written, and the spare partition B is preloaded to the memory spare area 0x3000-0x4000.
Step 1, in the initial state (i.e. before updating), the memory mirror version table may be as shown in table 1 below:
BlockID Memory address Version identification Status of Reference count
libnet.so-1 0x1000 v1.0-a1b2 Active activity 2
libnet.so-2 0x1800 v1.0-c3d4 Active activity 0
TABLE 1
Therein, libnet.so is divided into two blocks (Block 1 and Block 2), and Block1 (address 0x 1000) currently has 2 active threads executing.
Step 2, the pre-loading of the new version can be started, the libnet. So v2.1 can be mapped to the memory standby area, and the memory mirror version table can be updated correspondingly. The updated memory mirror version table may be as follows in table 2:
BlockID Memory address Version identification Status of Reference count
libnet.so-1 0x1000 v1.0-a1b2 Active activity 2
libnet.so-1 0x3000 v2.1-e5f6 Standby for use 0
libnet.so-2 0x1800 v1.0-c3d4 Active activity 0
libnet.so-2 0x3800 v2.1-g7h8 Standby for use 0
TABLE 2
The updated memory mirror version table can record the address and version identification of the new version block, thereby providing metadata for subsequent switching. Wherein the new version of the state is marked as "standby" indicating that it has not been activated.
Step 3, then, atomic switching can be performed on Block 1. This process requires waiting for the reference count to return to zero, specifically in the case where the reference count of old Block1 falls from 2 to 0 (i.e., all threads exit), then modifying the page table map to point the page table entry of virtual address 0x1000 to physical address 0x3000 (new Block). The updated memory mirror version table may be as shown in table 3 below:
BlockID Memory address Version identification Status of Reference count
libnet.so-1 0x1000 v2.1-e5f6 Active activity 0
libnet.so-1 0x3000 v2.1-e5f6 Standby for use 0
libnet.so-2 0x1800 v1.0-c3d4 Active activity 0
libnet.so-2 0x3800 v2.1-g7h8 Standby for use 0
TABLE 3 Table 3
The new block may then be marked as "active", the old block address 0x1000 still remains, but its version identification is updated to v2.1 (note that the actual physical content has been switched). All subsequent calls to libnet.so-1 are mapped to the new version through the page table.
And 4, carrying out abnormal rollback on the assumption that the new version Block1 crashes. For example, if the monitoring process finds that the CPU usage of libnet.so-1 exceeds the preset usage threshold, a rollback is triggered, where the rollback process is to first query the memory mirror version table, find the memory address 0x3000 of the original new version (i.e. the version that generated the exception) and the memory address 0x1000 of the last active version (i.e. the old version) (now v 2.1) according to BlockID =libnet.so-1, and if it is desired to rollback to the earlier version, retrieve the address of v1.0 from the history, where the address is stored persistently. Then, by atomic switching, rollback to the old version, specifically modifying the page table, remaps the page table entry for virtual address 0x1000 to physical address 0x7F8a0000 (physical address of v 1.0). The updated memory mirror version table may be as shown in table 4 below:
BlockID Memory address Version identification Status of Reference count
libnet.so-1 0x1000 v1.0-a1b2 Active activity 0
libnet.so-1 0x3000 v2.1-e5f6 Has been abandoned 0
TABLE 4 Table 4
Therefore, in the embodiment of the application, the differential packet downloaded by the client is obtained by the server based on the multi-stage splitting strategy, and the size of the differential packet is greatly reduced compared with the differential packet obtained by the conventional method, so that the flow consumption of the client in downloading the differential packet can be reduced. On the basis, when the client updates based on the differential packet, a memory mirror image real-time updating mechanism is also provided, and key codes or library files can be replaced while the client works normally, so that software upgrading without perception or with shortest perception is realized. In the updating process, the client also provides a fault detection and rollback mechanism based on the observation period, so that the normal function of the client can be recovered in time when the updating is abnormal.
Corresponding to the update method applied to the server provided above, the embodiment of the application also provides an update device applied to the server. As shown in fig. 3, the updating device 3 includes:
The first partitioning module 301 is configured to partition, based on a preset first partition size, a mirror image of a first firmware and a mirror image of a second firmware, to obtain a plurality of first blocks included in the first firmware and a plurality of second blocks included in the second firmware, where the first firmware is a firmware currently installed in the client, and the second firmware is an up-to-date firmware;
a comparison module 302, configured to sequentially compare each first block and a corresponding second block, so as to determine a first target block and a corresponding second target block that have a difference;
The second partitioning module 303 is configured to partition each first target block and a corresponding second target block based on a preset second partitioning size, so as to obtain a plurality of first sub-blocks included in each first target block and a plurality of second sub-blocks included in a corresponding second target block, where the first partitioning size is greater than the second partitioning size;
The difference module 304 is configured to perform a difference operation on each first sub-block and the corresponding second sub-block in sequence, so as to obtain a difference result;
The packaging module 305 is configured to perform data packaging based on all the target differential results to obtain a differential packet, where the target differential results are differential results that are not 0;
And the transmission module 306 is configured to transmit the differential packet to the client, so as to trigger the client to update based on the differential packet.
In some embodiments, the comparison module 302 includes:
The first determining unit is used for sequentially determining each first block and the corresponding second block as a first block to be compared and a second block to be compared based on a preset block index sequence;
the first calculating unit is used for calculating hash values of the first block to be compared and the second block to be compared respectively;
And the second determining unit is used for determining the first block to be compared and the second block to be compared as a first target block and a second target block under the condition that the hash value of the first block to be compared and the hash value of the second block to be compared are different.
In some embodiments, the encapsulation module 305 includes:
the second calculation unit is used for calculating verification information according to each target difference result, the block index corresponding to each target difference result and the sub-block index corresponding to each target difference result;
And the packaging unit is used for packaging each target differential result, the block index corresponding to each target differential result, the sub-block index corresponding to each target differential result and the verification information into differential packets.
From the above, in the embodiment of the present application, the server does not directly perform byte level comparison on the new firmware and the old firmware, but adopts a multi-level segmentation strategy, performs preliminary segmentation on the firmware, reduces the computational complexity, rapidly locates the region where the difference position is located, performs further segmentation in the region, and adopts finer granularity comparison, thereby obtaining the difference packet to be finally transmitted to the client for updating. In this way, the differential efficiency can be improved and the differential packet size can be reduced.
Corresponding to the updating method applied to the client provided above, the embodiment of the application also provides an updating device applied to the client. As shown in fig. 4, the updating device 4 includes:
A receiving module 401, configured to receive a differential packet transmitted by a preset server;
a generating module 402, configured to generate a candidate image of a second firmware based on the difference packet and an image of the first firmware, where the first firmware is a firmware currently installed on the client, and the second firmware is a latest firmware;
a verification module 403, configured to verify the candidate mirror image;
A writing module 404, configured to write the candidate image to the spare partition if the candidate image passes the verification;
an updating module 405, configured to update based on the candidate images.
In some embodiments, the update module 405 includes:
the loading unit is used for loading the latest operation file into the memory standby area based on the candidate mirror image, wherein the operation file comprises a dynamic library file and/or a movable file;
The building unit is used for building a new memory mapping based on the latest operation file;
And the switching unit is used for switching the memory reference based on the new memory mapping under the condition that the new memory mapping passes the verification so as to realize the updating.
In some embodiments, the establishing unit comprises:
the partitioning subunit is used for partitioning the latest operation file by adopting a preset partitioning strategy to obtain a plurality of latest operation file blocks;
The building subunit is used for building a new memory mapping based on each latest operation file block;
Accordingly, the switching unit includes:
a determining subunit, configured to determine, for each latest running file block, whether the latest running file block enters a security update window;
And the switching subunit is used for performing atomic switching on the memory reference corresponding to the latest operation file block based on the new memory mapping under the condition that the latest operation file block enters the safety updating window.
In some embodiments, the update module 405 further comprises:
the monitoring unit is used for determining whether the memory reference corresponding to the latest operation file block has a fault or not in a preset observation period;
And the rollback unit is used for rollback the memory references corresponding to the latest operation file block under the condition of faults.
Therefore, in the embodiment of the application, the differential packet downloaded by the client is obtained by the server based on the multi-stage splitting strategy, and the size of the differential packet is greatly reduced compared with the differential packet obtained by the conventional method, so that the flow consumption of the client in downloading the differential packet can be reduced. On the basis, when the client updates based on the differential packet, a memory mirror image real-time updating mechanism is also provided, and key codes or library files can be replaced while the client works normally, so that software upgrading without perception or with shortest perception is realized. In the updating process, the client also provides a fault detection and rollback mechanism based on the observation period, so that the normal function of the client can be recovered in time when the updating is abnormal.
Corresponding to the updating method applied to the server provided above, the embodiment of the application also provides a server. Referring to fig. 5, the server 5 in an embodiment of the present application includes a memory 501, one or more processors 502 (only one shown in fig. 5), and a computer program stored on the memory 501 and executable on the processors. The memory 501 is used for storing software programs and modules, and the processor 502 executes various functional applications and data processing by running the software programs and units stored in the memory 501 to obtain resources corresponding to the preset events. Specifically, the processor 502 implements each step of the update method applied to the server by running the above-mentioned computer program stored in the memory 501, which is not described herein.
It should be appreciated that in embodiments of the present application, the Processor 502 may be a central processing unit (Central Processing Unit, CPU), which may also be other general purpose processors, digital signal processors (DIGITAL SIGNAL processors, DSPs), application SPECIFIC INTEGRATED Circuits (ASICs), off-the-shelf Programmable gate arrays (Field-Programmable GATE ARRAY, FPGA) or other Programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Memory 501 may include read only memory and random access memory and provides instructions and data to processor 502. Some or all of memory 501 may also include non-volatile random access memory. For example, the memory 501 may also store information of a device type.
From the above, in the embodiment of the present application, the server does not directly perform byte level comparison on the new firmware and the old firmware, but adopts a multi-level segmentation strategy, performs preliminary segmentation on the firmware, reduces the computational complexity, rapidly locates the region where the difference position is located, performs further segmentation in the region, and adopts finer granularity comparison, thereby obtaining the difference packet to be finally transmitted to the client for updating. In this way, the differential efficiency can be improved and the differential packet size can be reduced.
Corresponding to the updating method applied to the client provided above, the embodiment of the application also provides the client. Referring to fig. 6, the client 6 in an embodiment of the present application includes a memory 601, one or more processors 602 (only one shown in fig. 6), and a computer program stored on the memory 601 and executable on the processors. The memory 601 is used for storing software programs and modules, and the processor 602 executes various functional applications and data processing by running the software programs and units stored in the memory 601 to obtain resources corresponding to the preset events. Specifically, the processor 602 implements each step of the update method applied to the client by running the above-mentioned computer program stored in the memory 601, which is not described herein.
It should be appreciated that in embodiments of the present application, the Processor 602 may be a central processing unit (Central Processing Unit, CPU), which may also be other general purpose processors, digital signal processors (DIGITAL SIGNAL processors, DSPs), application SPECIFIC INTEGRATED Circuits (ASICs), off-the-shelf Programmable gate arrays (Field-Programmable GATE ARRAY, FPGA) or other Programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Memory 601 may include read only memory and random access memory and provides instructions and data to processor 602. Some or all of the memory 601 may also include non-volatile random access memory. For example, the memory 601 may also store information of a device type.
Therefore, in the embodiment of the application, the differential packet downloaded by the client is obtained by the server based on the multi-stage splitting strategy, and the size of the differential packet is greatly reduced compared with the differential packet obtained by the conventional method, so that the flow consumption of the client in downloading the differential packet can be reduced. On the basis, when the client updates based on the differential packet, a memory mirror image real-time updating mechanism is also provided, and key codes or library files can be replaced while the client works normally, so that software upgrading without perception or with shortest perception is realized. In the updating process, the client also provides a fault detection and rollback mechanism based on the observation period, so that the normal function of the client can be recovered in time when the updating is abnormal.
The embodiments of the present application also provide a computer program product enabling a server to carry out the steps of the above-described respective embodiments of the update method applied to the server, when the computer program product is run on a server, and/or enabling a client to carry out the steps of the above-described respective embodiments of the update method applied to the client, when the computer program product is run on a client.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, the specific names of the functional units and modules are only for distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of external device software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the system embodiments described above are merely illustrative, e.g., the division of modules or units described above is merely a logical functional division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described above as separate components may or may not be physically separate, and components shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
The foregoing embodiments are merely for illustrating the technical solution of the present application, but not for limiting the same, and although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those skilled in the art that the technical solution described in the foregoing embodiments may be modified or substituted for some of the technical features thereof, and that these modifications or substitutions should not depart from the spirit and scope of the technical solution of the embodiments of the present application and should be included in the protection scope of the present application.

Claims (12)

1.一种更新方法,其特征在于,所述更新方法应用于服务器,所述更新方法包括:1. An update method, characterized in that the update method is applied to a server, and the update method comprises: 基于预设的第一分块尺寸对第一固件的镜像及第二固件的镜像进行分块,得到所述第一固件所包括的多个第一块以及所述第二固件所包括的多个第二块,其中,第一固件为客户端当前已安装的固件,所述第二固件为最新的固件;Dividing the image of the first firmware and the image of the second firmware into blocks based on a preset first block size to obtain a plurality of first blocks included in the first firmware and a plurality of second blocks included in the second firmware, wherein the first firmware is the firmware currently installed on the client and the second firmware is the latest firmware; 依序比对各个所述第一块及对应的所述第二块,以确定出存在差异的第一目标块及对应的第二目标块;Comparing each of the first blocks and the corresponding second blocks in sequence to determine a first target block and a corresponding second target block having a difference; 基于预设的第二分块尺寸对各个所述第一目标块及对应的所述第二目标块进行分块,得到各个所述第一目标块所包括的多个第一子块以及对应的所述第二目标块所包括的多个第二子块,其中,第一分块尺寸大于所述第二分块尺寸;Dividing each of the first target blocks and the corresponding second target blocks into blocks based on a preset second block size to obtain a plurality of first sub-blocks included in each of the first target blocks and a plurality of second sub-blocks included in the corresponding second target block, wherein the first block size is larger than the second block size; 依序对各个所述第一子块及对应的所述第二子块进行差分运算,得到差分结果;performing a differential operation on each of the first sub-blocks and the corresponding second sub-block in sequence to obtain a differential result; 基于所有目标差分结果进行数据打包得到差分包,其中,所述目标差分结果为:不为0的差分结果;Data is packaged based on all target differential results to obtain a differential package, wherein the target differential result is: a differential result that is not 0; 向所述客户端传输所述差分包,以触发所述客户端基于所述差分包进行更新。The differential package is transmitted to the client to trigger the client to perform an update based on the differential package. 2.如权利要求1所述的更新方法,其特征在于,所述依序比对各个所述第一块及对应的所述第二块,以确定出存在差异的第一目标块及对应的第二目标块,包括:2. The updating method according to claim 1 , wherein the sequentially comparing each of the first blocks and the corresponding second blocks to determine the first target blocks and the corresponding second target blocks having differences comprises: 基于预设的块索引顺序,依次将各个所述第一块及对应的所述第二块确定为确定待比对第一块及待比对第二块;Based on a preset block index order, sequentially determining each of the first blocks and the corresponding second blocks as a first block to be compared and a second block to be compared; 分别计算所述待比对第一块及所述待比对第二块的哈希值;Calculating hash values of the first block to be compared and the second block to be compared respectively; 在所述待比对第一块的哈希值与所述待比对第二块的哈希值不相同的情况下,将所述待比对第一块及所述待比对第二块确定为所述第一目标块及所述第二目标块。When the hash value of the first block to be compared is different from the hash value of the second block to be compared, the first block to be compared and the second block to be compared are determined as the first target block and the second target block. 3.如权利要求1所述的更新方法,其特征在于,所述基于所有目标差分结果进行数据打包得到差分包,包括:3. The updating method according to claim 1, wherein the step of packaging data based on all target differential results to obtain a differential package comprises: 根据各个所述目标差分结果、各个所述目标差分结果所对应的块索引及各个所述目标差分结果所对应的子块索引,计算校验信息;Calculating verification information according to each of the target differential results, a block index corresponding to each of the target differential results, and a sub-block index corresponding to each of the target differential results; 将各个所述目标差分结果、各个所述目标差分结果所对应的块索引、各个所述目标差分结果所对应的子块索引及所述校验信息打包为所述差分包。The target differential results, the block index corresponding to each target differential result, the sub-block index corresponding to each target differential result, and the verification information are packaged into the differential package. 4.一种更新方法,其特征在于,所述更新方法应用于客户端,所述更新方法包括:4. An update method, characterized in that the update method is applied to a client, and the update method comprises: 接收预设的服务器所传输的差分包;Receive differential packets transmitted by a preset server; 基于所述差分包及第一固件的镜像,生成第二固件的候选镜像,其中,第一固件为客户端当前已安装的固件,所述第二固件为最新的固件;Generate a candidate image of the second firmware based on the differential package and the image of the first firmware, wherein the first firmware is the firmware currently installed on the client and the second firmware is the latest firmware; 对所述候选镜像进行校验;Verifying the candidate image; 在所述候选镜像通过校验的情况下,将所述候选镜像写入备用分区;If the candidate image passes the verification, writing the candidate image into the standby partition; 基于所述候选镜像进行更新。Update based on the candidate image. 5.如权利要求4所述的更新方法,其特征在于,所述基于所述候选镜像进行更新,包括:5. The updating method according to claim 4, wherein the updating based on the candidate image comprises: 基于所述候选镜像,将最新的运行文件加载至内存备用区,其中,所述运行文件包括:动态库文件和/或可执行文件;Based on the candidate image, the latest running file is loaded into the memory spare area, wherein the running file includes: a dynamic library file and/or an executable file; 基于所述最新的运行文件,建立新的内存映射;Based on the latest running file, a new memory map is established; 在所述新的内存映射通过校验的情况下,基于所述新的内存映射对内存引用进行切换,以实现更新。In a case where the new memory mapping passes verification, the memory reference is switched based on the new memory mapping to achieve updating. 6.如权利要求5所述的更新方法,其特征在于,所述基于所述最新的运行文件,建立新的内存映射,包括:6. The updating method according to claim 5, wherein establishing a new memory mapping based on the latest running file comprises: 采用预设的分块策略对所述最新的运行文件进行分块,得到多个最新的运行文件块;Using a preset block strategy to block the latest running file to obtain multiple latest running file blocks; 基于各个所述最新的运行文件块,建立所述新的内存映射;Establishing the new memory mapping based on each of the latest running file blocks; 相应地,所述基于所述新的内存映射对内存引用进行切换,包括:Accordingly, switching the memory reference based on the new memory mapping includes: 针对每个所述最新的运行文件块,确定所述最新的运行文件块是否进入安全更新窗口;For each of the latest running file blocks, determining whether the latest running file block enters a security update window; 在所述最新的运行文件块进入安全更新窗口的情况下,基于所述新的内存映射,对所述最新的运行文件块所对应的内存引用进行原子切换。When the latest running file block enters the security update window, the memory reference corresponding to the latest running file block is atomically switched based on the new memory mapping. 7.如权利要求6所述的更新方法,其特征在于,在对所述最新的运行文件块所对应的内存引用进行原子切换之后,所述更新方法还包括:7. The updating method according to claim 6, wherein after performing an atomic switch on the memory reference corresponding to the latest running file block, the updating method further comprises: 在预设的观察期内,确定所述最新的运行文件块所对应的内存引用是否存在故障;During a preset observation period, determining whether a memory reference corresponding to the latest running file block has a fault; 在存在故障的情况下,对所述最新的运行文件块所对应的内存引用进行回退。In the event of a failure, the memory reference corresponding to the latest running file block is rolled back. 8.一种更新装置,其特征在于,所述更新装置应用于服务器,所述更新装置包括:8. An update device, characterized in that the update device is applied to a server, and the update device comprises: 第一分块模块,用于基于预设的第一分块尺寸对第一固件的镜像及第二固件的镜像进行分块,得到所述第一固件所包括的多个第一块以及所述第二固件所包括的多个第二块,其中,第一固件为客户端当前已安装的固件,所述第二固件为最新的固件;a first block segmentation module configured to segment the image of the first firmware and the image of the second firmware based on a preset first block size to obtain a plurality of first blocks included in the first firmware and a plurality of second blocks included in the second firmware, wherein the first firmware is the firmware currently installed on the client and the second firmware is the latest firmware; 比对模块,用于依序比对各个所述第一块及对应的所述第二块,以确定出存在差异的第一目标块及对应的第二目标块;a comparison module, configured to sequentially compare each of the first blocks with the corresponding second blocks to determine a first target block and a corresponding second target block having differences; 第二分块模块,用于基于预设的第二分块尺寸对各个所述第一目标块及对应的所述第二目标块进行分块,得到各个所述第一目标块所包括的多个第一子块以及对应的所述第二目标块所包括的多个第二子块,其中,第一分块尺寸大于所述第二分块尺寸;a second blocking module, configured to block each of the first target blocks and the corresponding second target blocks based on a preset second blocking size to obtain a plurality of first sub-blocks included in each of the first target blocks and a plurality of second sub-blocks included in the corresponding second target blocks, wherein the first blocking size is larger than the second blocking size; 差分模块,用于依序对各个所述第一子块及对应的所述第二子块进行差分运算,得到差分结果;a difference module, configured to perform a difference operation on each of the first sub-blocks and the corresponding second sub-block in sequence to obtain a difference result; 封装模块,用于基于所有目标差分结果进行数据打包得到差分包,其中,所述目标差分结果为:不为0的差分结果;A packaging module, configured to package data based on all target differential results to obtain differential packets, wherein the target differential results are differential results that are not 0; 传输模块,用于向所述客户端传输所述差分包,以触发所述客户端基于所述差分包进行更新。A transmission module is used to transmit the differential package to the client to trigger the client to update based on the differential package. 9.一种更新装置,其特征在于,所述更新装置应用于客户端,所述更新装置包括:9. An update device, characterized in that the update device is applied to a client, and the update device comprises: 接收模块,用于接收预设的服务器所传输的差分包;A receiving module, configured to receive differential packets transmitted by a preset server; 生成模块,用于基于所述差分包及第一固件的镜像,生成第二固件的候选镜像,其中,第一固件为客户端当前已安装的固件,所述第二固件为最新的固件;a generation module, configured to generate a candidate image of the second firmware based on the differential package and the image of the first firmware, wherein the first firmware is the firmware currently installed on the client and the second firmware is the latest firmware; 校验模块,用于对所述候选镜像进行校验;A verification module, configured to verify the candidate image; 写入模块,用于在所述候选镜像通过校验的情况下,将所述候选镜像写入备用分区;A writing module, configured to write the candidate image into a spare partition if the candidate image passes verification; 更新模块,用于基于所述候选镜像进行更新。An update module is used to perform an update based on the candidate image. 10.一种服务器,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现如权利要求1至3任一项所述的方法。10. A server comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 3 when executing the computer program. 11.一种客户端,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现如权利要求4至7任一项所述的方法。11. A client comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 4 to 7 when executing the computer program. 12.一种计算机程序产品,其特征在于,所述计算机程序产品包括计算机程序,所述计算机程序被一个或多个处理器执行时实现如权利要求1至7任一项所述的方法。12. A computer program product, characterized in that the computer program product comprises a computer program, and when the computer program is executed by one or more processors, it implements the method according to any one of claims 1 to 7.
CN202510726626.9A 2025-05-30 2025-05-30 Updating method, updating device, updating server, updating client and updating computer program product Pending CN120687125A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202510726626.9A CN120687125A (en) 2025-05-30 2025-05-30 Updating method, updating device, updating server, updating client and updating computer program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202510726626.9A CN120687125A (en) 2025-05-30 2025-05-30 Updating method, updating device, updating server, updating client and updating computer program product

Publications (1)

Publication Number Publication Date
CN120687125A true CN120687125A (en) 2025-09-23

Family

ID=97079942

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202510726626.9A Pending CN120687125A (en) 2025-05-30 2025-05-30 Updating method, updating device, updating server, updating client and updating computer program product

Country Status (1)

Country Link
CN (1) CN120687125A (en)

Similar Documents

Publication Publication Date Title
US20210124574A1 (en) Techniques for updating a file using a multi-version patch file
US9606875B2 (en) Migration of computer data
CN107111528B (en) System and method for storage error management
US9268648B1 (en) System and method for consistency verification of replicated data in a recovery system
TWI471726B (en) Managing cache data and metadata
JP6026538B2 (en) Non-volatile media journaling of validated datasets
US11163886B2 (en) Information handling system firmware bit error detection and correction
US20160150012A1 (en) Content-based replication of data between storage units
US20080270677A1 (en) Safe software revision for embedded systems
US11775283B2 (en) Resilient software updates in secure storage devices
CN1598777A (en) Method and system for updating software
US10884871B2 (en) Systems and methods for copying an operating source volume
EP2998903B1 (en) System and method for robust full-drive encryption
CN114398062A (en) Equipment software upgrading and confirming method based on encrypted upgrading packet
CN118567692B (en) Basic input and output system firmware upgrade method, product, device and medium
CN119917149A (en) A wireless embedded product online upgrade method
KR101019822B1 (en) Method and apparatus for updating sensor node software in wireless sensor network
CN120687125A (en) Updating method, updating device, updating server, updating client and updating computer program product
US11762756B2 (en) System and method for startup data verification
RU2580014C2 (en) System and method for changing mask of encrypted region during breakdown in computer system
US20230099455A1 (en) Dynamic boot configuration
US10719379B2 (en) Fault isolation in transaction logs
US11475170B2 (en) System and method for correction of memory errors
RU2580018C2 (en) Method of determining mask of encrypted region of disc
CN107656747B (en) A data upgrade method and mobile terminal

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载