CN115718614A - Block differential upgrade package generation and block differential upgrade method and device - Google Patents

Block differential upgrade package generation and block differential upgrade method and device Download PDF

Info

Publication number
CN115718614A
CN115718614A CN202211497718.7A CN202211497718A CN115718614A CN 115718614 A CN115718614 A CN 115718614A CN 202211497718 A CN202211497718 A CN 202211497718A CN 115718614 A CN115718614 A CN 115718614A
Authority
CN
China
Prior art keywords
firmware
target
block
control information
upgrade
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
CN202211497718.7A
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.)
Beijing Yahua Iot Technology Development Co ltd
Original Assignee
Beijing Yahua Iot Technology Development Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Yahua Iot Technology Development Co ltd filed Critical Beijing Yahua Iot Technology Development Co ltd
Priority to CN202211497718.7A priority Critical patent/CN115718614A/en
Publication of CN115718614A publication Critical patent/CN115718614A/en
Pending legal-status Critical Current

Links

Images

Abstract

The invention discloses a method and a device for generating a block differential upgrade packet and a block differential upgrade, wherein the method for generating the block differential upgrade packet is used for decomposing control information in a full differential packet of firmware to be upgraded of a source firmware and a target, determining third control information and fourth control information corresponding to each block of the target upgrade firmware during upgrading, generating a differential upgrade packet corresponding to each block of the target upgrade firmware according to the third control information and the fourth control information, determining an upgrade sequence corresponding to each block of the target upgrade firmware according to the third control information, packaging the differential upgrade packet corresponding to each block of the target upgrade firmware and the upgrade sequence to obtain the differential upgrade packet corresponding to the target upgrade firmware, and subsequently covering on the basis of the source firmware when the source firmware is upgraded according to the differential upgrade packet corresponding to the target upgrade firmware, wherein all required memories only depend on the size of the block.

Description

Block differential upgrade package generation and block differential upgrade method and device
Technical Field
The invention relates to the technical field of firmware upgrading, in particular to a method and a device for generating a block differential upgrading packet and upgrading the block differential upgrading.
Background
Currently, there are two main types of firmware upgrade methods, namely type a and type B. Wherein: the A-type upgrading method is that target upgrading firmware is downloaded from an upper computer or a platform to an equipment side, and the equipment side directly starts the target upgrading firmware to run, namely copy upgrading; the B-class upgrading method is that an upgrading patch is firstly manufactured on a platform or an upper computer, the upgrading patch is downloaded from the upper computer or the platform side by the equipment side, and after the downloading is finished, a target upgrading firmware is restored according to the upgrading patch and an original file, and the method is called differential upgrading.
The disadvantages of the class a upgrade method include: the downloading process is long in time, the target file needs to be completely downloaded, the network coverage is poor or the bandwidth is limited, the downloading time is long, and the stability of the complete downloading in a single time is poor; the upgrading process has large requirements on hardware resources, and the flash space of the equipment side is required to be at least 2 times of the firmware storage space. The scheme disclosed by the B-type upgrading method can partially overcome the defect of long downloading process time in the A-type method, but does not solve the defect of large demand on hardware resources, and can reduce the dependence on the ram space size through a special compression method, but does not solve the problem of high demand on the flash space.
Disclosure of Invention
Therefore, the technical problem to be solved by the present invention is to overcome the defect of large requirement for hardware storage resources in the existing differential upgrade method, thereby providing a method and a device for generating a block differential upgrade packet and updating block differential.
According to a first aspect, an embodiment of the present invention discloses a method for generating a block differential upgrade package, including: acquiring a source firmware and a target upgrade firmware of a firmware to be upgraded; calculating a full differential packet of the source firmware and the target upgrade firmware, wherein the full differential packet comprises control information, differential information and unique information; the method comprises the steps that block processing is conducted on source firmware data and target upgrading firmware data according to the size of target blocks to obtain block data of a plurality of source firmware blocks and block data of a plurality of target upgrading firmware blocks, wherein the block data of each source firmware block comprises a corresponding block identifier, and the block data of each target upgrading firmware block comprises a corresponding block identifier; acquiring a plurality of control triple commands in the control information, wherein each control triple command comprises first control information and second control information, the first control information represents the same information and difference information of the source firmware and the target upgrade firmware, and the second control information represents the unique information of the target upgrade firmware; decomposing each piece of first control information according to the identification corresponding to each target upgrading firmware block, the identification corresponding to each source firmware block, the target block size and the operation step length to obtain third control information corresponding to each target upgrading firmware block, wherein the third control information represents the same information and difference information in each target upgrading firmware block and the corresponding source firmware block; decomposing each piece of second control information according to the block identification corresponding to the block data of each piece of target upgrading firmware, the size of each target block and the operation step length to obtain fourth control information corresponding to the block of each piece of target upgrading firmware, wherein the fourth control information is used for representing the same information and difference information in the block of each piece of target upgrading firmware and the corresponding source firmware block; determining differential information and unique information corresponding to each target upgrade firmware block according to the third control information, the fourth control information, the differential information and the unique information; generating a differential upgrade package corresponding to the blocks of each target upgrade firmware according to the third control information, the fourth control information and the differential information and the unique information corresponding to the blocks of each target upgrade firmware; determining the upgrading sequence of each target upgrading firmware block according to the third control information; and packaging the differential upgrade package corresponding to the blocks of each target upgrade firmware and the upgrade sequence to obtain the differential upgrade package corresponding to the target upgrade firmware.
Optionally, before the blocking processing is performed on the source firmware data and the target upgrade firmware data according to the size of the target block to obtain block data of a plurality of source firmware blocks and block data of a plurality of target upgrade firmware blocks, the method further includes: acquiring the memory size of a target processor at the equipment side and the minimum erasing unit of a target flash memory at the equipment side; and determining the size of the target block according to the memory size of the target processor and the minimum erasing unit of the target flash memory.
Optionally, decomposing each first control information according to the identifier corresponding to each target upgrade firmware partition, the identifier corresponding to each source firmware partition, the target partition size, and the operation step size to obtain third control information corresponding to each target upgrade firmware partition, including: determining a current decomposition step length corresponding to the first control information according to the current operable byte number of the first control information, the residual byte number in the currently operated source firmware sub-block and the residual byte number in the currently operated target upgrade firmware sub-block; decomposing the first control information according to the current decomposition step length corresponding to the first control information to obtain a first decomposition result, and recording a block identifier corresponding to a source firmware, a block identifier corresponding to a target upgrading firmware, a current first position offset pointer in the source firmware, a current second position offset pointer in the target upgrading firmware and a current third position offset pointer in differential information in the full differential packet in each decomposition operation in the decomposition process of the first control information; determining the third control information according to a first decomposition result, the first position offset pointer, the block identifier corresponding to the source firmware, the block identifier corresponding to the target upgrade firmware, the first position offset pointer, the second position offset pointer and the third position offset pointer;
decomposing each piece of second control information according to the block identifier corresponding to the block data of each piece of target upgrade firmware, the target block size and the operation step length to obtain fourth control information corresponding to the block of each piece of target upgrade firmware, including: determining a current decomposition step length corresponding to the second control information according to the current operable byte number of the second control information and the residual byte number in the currently operated target upgrading solid block; decomposing the second control information according to the current decomposition step length corresponding to the second control information to obtain a second decomposition result, and recording a block identifier of target upgrade firmware corresponding to each decomposition operation in the decomposition process of the second control information, a current fourth position offset pointer in the target upgrade firmware and a current fifth position offset pointer in unique information in the full differential packet; and determining the fourth control information according to a second decomposition result, the fourth position offset pointer, a fifth position offset pointer and a block identifier of the target upgrading firmware.
Optionally, the determining an upgrade order of each target upgrade firmware partition according to the third control information includes: determining a block identifier of the target upgrade firmware and a block identifier of the source firmware corresponding to the third control information; determining a corresponding relation between the block identifier of each target upgrading firmware and the block identifier of the source firmware according to the block identifier of the target upgrading firmware and the block identifier of the source firmware corresponding to the third control information; carrying out topological sorting on the block identifier of the target upgrading firmware and the block identifier of the source firmware according to the corresponding relation between the block identifier of the target upgrading firmware and the block identifier of the source firmware; and determining the upgrading sequence of each target upgrading firmware block according to the topological sorting result.
Optionally, the method further comprises: and carrying out upgrading simulation operation on the source firmware by using a preset simulation program to carry out upgrading simulation operation on the differential upgrading packet corresponding to the target upgrading firmware.
According to a second aspect, an embodiment of the present invention further discloses a block differential upgrade method, including: obtaining a target differential upgrade package, where the target differential upgrade package is obtained by the block differential upgrade package generation method according to the first aspect or any optional embodiment of the first aspect; reading upgrading sequence information of each target upgrading firmware block in the target differential upgrading packet; and according to the upgrading sequence information of each target upgrading firmware block, executing an upgrading command corresponding to each target upgrading firmware block in the firmware to be upgraded, and upgrading the firmware to be upgraded.
According to a third aspect, an embodiment of the present invention further discloses a block differential upgrade package generation apparatus, including: the first acquisition module is used for acquiring a source firmware and a target upgrade firmware of the firmware to be upgraded; a calculation module, configured to calculate a full differential packet of the source firmware and the target upgrade firmware, where the full differential packet includes control information, differential information, and unique information; the block processing module is used for carrying out block processing on the source firmware data and the target upgrading firmware data according to the size of the target block to obtain block data of a plurality of source firmware blocks and block data of a plurality of target upgrading firmware blocks, wherein the block data of each source firmware block comprises a corresponding block identifier, and the block data of each target upgrading firmware block comprises a corresponding block identifier; a second obtaining module, configured to obtain multiple control triple commands in the control information, where each control triple command includes first control information and second control information, where the first control information represents identical information and differential information of the source firmware and the target upgrade firmware, and the second control information represents unique information of the target upgrade firmware; the first decomposition module is used for decomposing each piece of first control information according to the identifier corresponding to each target upgrading firmware block, the identifier corresponding to each source firmware block, the target block size and the operation step length to obtain third control information corresponding to each target upgrading firmware block, wherein the third control information represents the same information and difference information in each target upgrading firmware block and the corresponding source firmware block; the second decomposition module is used for decomposing each piece of second control information according to the block identifier corresponding to the block data of each target upgrading firmware, the size of each target block and the operation step length to obtain fourth control information corresponding to the block of each target upgrading firmware, wherein the fourth control information is used for representing the same information and difference information in the block of each target upgrading firmware and the corresponding source firmware block; a first determining module, configured to determine, according to the third control information, the fourth control information, the difference information, and the unique information, difference information and unique information corresponding to each target upgrade firmware block; the generating module is used for generating a differential upgrade package corresponding to the blocks of each target upgrade firmware according to the third control information, the fourth control information and the differential information and the unique information corresponding to the blocks of each target upgrade firmware; the second determining module is used for determining the upgrading sequence of each target upgrading firmware block according to the third control information; and the packaging module is used for packaging the differential upgrade package corresponding to the blocks of each target upgrade firmware and the upgrade sequence to obtain the differential upgrade package corresponding to the target upgrade firmware.
According to a fourth aspect, an embodiment of the present invention further discloses a block differential upgrade apparatus, including: a third obtaining module, configured to obtain a target differential upgrade package, where the target differential upgrade package is obtained by using the block differential upgrade package generation method according to the first aspect or any optional embodiment of the first aspect; the reading module is used for reading the upgrading sequence information of each target upgrading firmware block in the target differential upgrading packet; and the upgrading module is used for executing the upgrading command corresponding to each target upgrading firmware block in the firmware to be upgraded according to the upgrading sequence information of each target upgrading firmware block, and upgrading the firmware to be upgraded.
According to a fifth aspect, an embodiment of the present invention further discloses an electronic device, including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executable by the at least one processor to cause the at least one processor to perform the steps of the method for generating a blocked differential upgrade package according to the first aspect or any one of the alternative embodiments of the first aspect, or to perform the steps of the method for generating a blocked differential upgrade according to the second aspect.
According to a sixth aspect, the present invention further discloses a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps of the method for generating a blocked differential upgrade package according to the first aspect or any one of the optional embodiments of the first aspect, or implements the steps of the method for generating a blocked differential upgrade according to the second aspect.
The technical scheme of the invention has the following advantages:
the method and the device for generating the block differential upgrade package solve the problem that the existing upgrade hardware only needs to be subjected to the additional upgrade of the target firmware, and do not depend on the size of the existing upgrade hardware, and solve the problem that the existing upgrade hardware only needs to be subjected to the additional upgrade of the target firmware, wherein the method and the device provided by the invention are used for solving the defect that the existing upgrade hardware only needs to be subjected to the additional upgrade of the target firmware, and have the advantages that the size of the existing upgrade hardware is not large.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of a specific example of a method for generating a blocked differential upgrade package according to an embodiment of the present invention;
fig. 2A is a schematic diagram of a specific example of a block differential upgrade package generation method in the embodiment of the present invention;
fig. 2B is a schematic diagram of a specific example of a method for generating a blocked differential upgrade package according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a specific example of a method for generating a blocked differential upgrade package according to an embodiment of the present invention;
fig. 4 is a flowchart of a specific example of a block differential upgrade method in the embodiment of the present invention;
fig. 5 is a schematic block diagram of a specific example of a block differential upgrade package generation apparatus in the embodiment of the present invention;
FIG. 6 is a schematic block diagram of a specific example of a block differential upgrade apparatus in an embodiment of the present invention;
fig. 7 is a diagram of a specific example of an electronic device in an embodiment of the present invention.
Detailed Description
The technical solutions of the present invention will be described clearly and completely with reference to the accompanying drawings, and it should be understood that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, and are only for convenience of description and simplicity of description, but do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus, should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
In the description of the present invention, it should be noted that, unless otherwise explicitly specified or limited, the terms "mounted," "connected," and "connected" are to be construed broadly, e.g., as meaning either a fixed connection, a removable connection, or an integral connection; can be mechanically or electrically connected; the two elements may be directly connected or indirectly connected through an intermediate medium, or may be communicated with each other inside the two elements, or may be wirelessly connected or wired connected. The specific meanings of the above terms in the present invention can be understood in a specific case to those of ordinary skill in the art.
In addition, the technical features involved in the different embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
The embodiment of the invention discloses a method for generating a block differential upgrade package, which can be applied to an upper computer or a differential upgrade platform system, wherein all historical firmware data and upgradable firmware data of a device side to be upgraded are integrated on the upper computer or the differential upgrade platform system; as shown in fig. 1, the method comprises the steps of:
step 101, obtaining a source firmware and a target upgrade firmware of a firmware to be upgraded.
The Firmware may be code stored in a memory operable by the single chip or the MCU, and may be a compiled binary file, which may operate on hardware, and is generally referred to as Firmware. The source firmware may be firmware prior to upgrade, which may also be referred to as old firmware; the target upgraded firmware may be firmware after upgrading, which may also be referred to as new firmware.
102, calculating a total differential packet of the source firmware and the target upgrading firmware, wherein the total differential packet comprises control information, differential information and unique information.
Illustratively, the full differential package may be a difference file, called a Patch file (Patch), between the target upgrade firmware and the source firmware, which is made by a difference algorithm, and is completed by the upper computer or the platform system. The difference algorithm can be a method or a step for extracting difference information between source firmware and target upgrading firmware, the commonly used difference algorithm has two modes of bsdiff and vcdiff, the two algorithms can be compressed for the second time after matching search is completed, and efficient matching can be completed aiming at the characteristics of the binary file of the firmware. In the embodiment of the present application, a bsdiff differential algorithm may be adopted to complete extraction of the total differential information, and a patch file (total differential information) is generated after the source firmware and the target upgrade firmware pass through the bsdiff algorithm, and the patch file has the following functions: and after the patch file is transmitted to the equipment to be upgraded, the equipment can restore the target upgrading firmware according to the patch file and the source firmware. The patch file consists of three parts of information: control information, differential information, and new firmware unique information, wherein: the control information consists of a series of commands, each consisting of a triplet of CMD (X, Y, Z) fixed format, and the patch files are constructed as shown in table 1 below.
TABLE 1
Figure BDA0003964600950000081
Figure BDA0003964600950000091
And 103, partitioning the source firmware data and the target upgrading firmware data according to the size of the target partition to obtain multiple source firmware partition data and multiple target upgrading firmware partition data, wherein each source firmware partition data comprises a corresponding partition identifier, and each target upgrading firmware partition data comprises a corresponding partition identifier.
For example, the size of the target block may be any size, and the specific content of the size of the target block is not limited in this embodiment of the application, as long as the blocking of the source firmware and the target upgrade firmware can be implemented, and a person skilled in the art can determine the size as needed. In this embodiment of the present application, the source firmware and the target upgrade firmware may be partitioned according to the size of the target partition, for example, when the size of the target partition is 512 bytes, the size of the source firmware is 4672 bytes, and the size of the target upgrade firmware is 5580 bytes, the source firmware and the upgrade firmware are partitioned according to 512 bytes, and a partition identifier corresponding to each source firmware partition and a partition identifier corresponding to each target upgrade firmware partition are recorded; the block identifier corresponding to each source firmware block may be a corresponding block number, and the block identifier corresponding to each target upgrade firmware block may be a corresponding block number.
And step 104, acquiring a plurality of control triple commands in the control information, wherein each control triple command comprises first control information and second control information, the first control information represents the same information and difference information of the source firmware and the target upgrade firmware, and the second control information represents the unique information of the target upgrade firmware.
For example, in this embodiment of the application, the first control information may be X in the control triplet (X, Y, Z), where the meaning of X is to read X bytes from the differential information (D1D 2D3 …) and add the X bytes of the old firmware to obtain the content of the new firmware. The second control information may be Y in the control triplet (X, Y, Z), meaning that copying Y bytes of data from the unique information (E1E 2E3 …) adds the current location as the content of the new firmware.
And 105, decomposing each piece of first control information according to the identifier corresponding to each target upgrading firmware block, the identifier corresponding to each source firmware block, the target block size and the operation step length to obtain third control information corresponding to each target upgrading firmware block, wherein the third control information represents the same information and difference information in each target upgrading firmware block and the corresponding source firmware block.
For example, the operation step size may be an operation byte number corresponding to each step of operation when the first control information is decomposed, in this embodiment of the application, the first control information is decomposed into a corresponding restore command in each target upgrade firmware partition, for example, the operation byte number of X of the first control triplet is 1671 bytes, and the size of each block is 512, so that X may span 3 partitions when executed, and 4 partition spaces are involved, so when X is decomposed, it is decomposed into an operation instruction corresponding to each partition in four partition spaces.
And 106, decomposing each piece of second control information according to the block identifier corresponding to the block data of each target upgrading firmware, the target block size and the operation step length to obtain fourth control information corresponding to the block of each target upgrading firmware, wherein the fourth control information is used for representing the same information and difference information in the block of each target upgrading firmware and the corresponding source firmware block.
For example, the operation step size may be an operation byte number corresponding to each step of operation when the second control information is decomposed, in this embodiment of the application, the second control information is decomposed into a corresponding restore command in each target upgrade firmware partition, for example, the operation byte number of Y of the first control triplet is 1671 bytes, and the size of each block is 512, so Y spans 3 partitions when executed, and involves 4 partition spaces, so when Y is decomposed, it is decomposed into operation instructions corresponding to each partition in four partition spaces.
And 107, determining the difference information and the unique information corresponding to the blocks of each target upgrade firmware according to the third control information, the fourth control information, the difference information and the unique information.
Illustratively, the third control information is a control instruction corresponding to each target upgrade firmware block generated according to the same information and the difference information between the target upgrade firmware and the source firmware, and then each target upgrade firmware block difference information can be determined according to the third control information and the difference information in the full difference packet; the fourth control information is a control instruction corresponding to each target upgrade firmware block generated according to the unique information of the target upgrade firmware, and the unique information of each target upgrade firmware block can be determined according to the fourth control information and the unique information in the full-amount difference packet.
And 108, generating a differential upgrade package corresponding to the partition of each target upgrade firmware according to the third control information, the fourth control information, and the differential information and the unique information corresponding to the partition of each target upgrade firmware. Illustratively, the third control information and the fourth control information corresponding to the blocks may be executed subsequently according to the differential upgrade package corresponding to the blocks of each target upgrade firmware, so as to implement data restoration of the blocks of each target upgrade firmware.
And step 109, determining the upgrading sequence of each target upgrading firmware block according to the third control information.
Exemplarily, in the embodiment of the present application, when the target upgrade firmware is subsequently restored through the differential upgrade package corresponding to the partition of each target upgrade firmware, the coverage may be performed on the source firmware, so as to effectively reduce the requirement of the Flash memory space of the firmware in the upgrade process, but when the corresponding control information is executed to restore the target upgrade firmware, the coverage may be performed on the source firmware only by determining the upgrade order of each target upgrade firmware partition, so as to implement the restoration operation of the target upgrade firmware. The third control information contains an operation command for restoring each target upgrade firmware block, and the information of the source firmware, which is depended on when each target upgrade firmware block is restored, can be determined according to the third control command, so that the source firmware block, which is depended on by each target upgrade firmware block, can be determined; and determining the upgrading sequence of each target upgrading firmware block according to the source firmware block depended by each target upgrading firmware, wherein the upgrading sequence can be determined manually or by some preset sequencing algorithms.
And 110, packaging the differential upgrade package corresponding to the blocks of each target upgrade firmware and the upgrade sequence to obtain the differential upgrade package corresponding to the target upgrade firmware.
Illustratively, the upper computer or the platform system obtains a differential upgrade package corresponding to the target upgrade firmware, and then the differential upgrade package can be sent to the device to be upgraded, so that the device to be upgraded can conveniently execute the upgrade operation of the corresponding source firmware according to the received differential upgrade package.
In the embodiment of the application, the obtained differential upgrade package corresponding to the target upgrade firmware can be applied to the internet of things equipment with a small Flash space during subsequent firmware upgrade, so that the firmware upgrade (Flash is less than 32K, and the memory is less than 1K) under the condition of extremely small resources on the equipment side is solved. If the size of the source firmware is S1, the size of the target upgrade firmware is S2, and the size of the patch file is S3, in the upgrade process of the differential upgrade patch obtained in this embodiment, the space requirement of the device side on the flash is S2+ S3, and the space requirement of the device side on the flash in the currently disclosed scheme is (S1 + S2+ S3). And (3) configuring hardware of a common MCU: s1=122k, S2=120k, and S3=15k are calculated as examples, the size of the flash space required by the differential upgrade package obtained in this embodiment in the subsequent upgrade is: s2+ S3=135K; the size of the flash space required by other existing schemes is S1+ S2+ S3=257K.
The invention provides a method for generating a block differential upgrade package, which comprises the steps of decomposing control information in a full-amount differential package of a source firmware to be upgraded and a target firmware to be upgraded, determining third control information and fourth control information corresponding to each block of the target upgrade firmware when the blocks of the target upgrade firmware are upgraded, generating a differential upgrade package corresponding to each block of the target upgrade firmware according to the third control information and the fourth control information, determining an upgrade sequence corresponding to each block of the target upgrade firmware according to the third control information, packaging the differential upgrade package and the upgrade sequence corresponding to each block of the target upgrade firmware to obtain the differential upgrade package corresponding to the target upgrade firmware, wherein the differential upgrade package corresponding to the target upgrade firmware is a minimum differential package, the size of the differential upgrade package can be smaller than 10% of the source firmware or the target firmware, when the source firmware is upgraded according to the differential upgrade package corresponding to the target upgrade, the upgrade sequence corresponding to each block of the target upgrade firmware can be read, the control information corresponding to the blocks of the target upgrade firmware can be sequentially restored, the target firmware can be sequentially restored, the size of each block of the target upgrade firmware does not need to be additionally stored in the existing upgrade hardware, and the existing upgrade method can be used in the existing hardware, and the existing upgrade method can be used for solving the problem that the existing target upgrade of the existing hardware.
As an alternative embodiment of the present invention, before step 103, the method further comprises: acquiring the memory size of a target processor at the equipment side and the minimum erasing unit of a target flash memory at the equipment side; and determining the size of the target block according to the memory size of the target processor and the minimum erasing unit of the target flash memory.
For example, in this embodiment of the present application, the setting of the size of the target partition may affect the size of the final differential upgrade packet, and the larger the partition is, the smaller the differential upgrade packet is, but the requirement on the size of the memory on the device side is also large, and the setting of the size of the partition must satisfy the following principle: the memory requirement of the equipment side is met, and the flash erasing unit of the equipment side is taken as the minimum unit. Therefore, in order to achieve the best difference effect, assuming that the memory of the device-side MCU is size _ mem and the erasing unit of the device-side memory is size _ flash _ erase, the present application provides a calculation formula for setting the block size (block _ size): block _ size = M × size _ flash _ erase, (where M is a positive integer); m = (size _ mem/4+ size_flash _ erase-1)/size _ flash _ erase; for example, for a resource-constrained MCU, size _ mem =8192b, size _flash _resolver =512b, calculated M =4, block _size =2048b.
As an alternative embodiment of the present invention, step 105 includes:
and determining a current decomposition step corresponding to the first control information according to the current operable byte number of the first control information, the residual byte number in the currently operated source firmware sub-block and the residual byte number in the currently operated target upgrade firmware sub-block.
Illustratively, the currently operable byte number of the first control information may be a currently remaining operable byte number of the first control information; the remaining number of bytes in the currently operated source firmware partition may be a remaining length from the current operation position (old _ from) in the source firmware partition to the lower boundary (old _ blk _ upper _ bound) of the partition, which may be specifically shown in fig. 2A; the remaining number of bytes in the target upgrade firmware partition currently operated may be a remaining length from the current operation location (new _ from) in the target upgrade firmware partition to the lower boundary (new _ blk _ upper _ bound) of the partition, which may be specifically shown in fig. 2B. The selection principle of the current operation step size may be to select a minimum value from three variables, namely, the currently operable byte number of the first control information, the remaining byte number in the currently operated source firmware partition and the remaining byte number in the currently operated target upgrade firmware partition, as the current decomposition step size.
And decomposing the first control information according to the current decomposition step length corresponding to the first control information to obtain a first decomposition result, and recording a block identifier corresponding to the source firmware, a block identifier corresponding to the target upgrade firmware, a current first position offset pointer in the source firmware, a current second position offset pointer in the target upgrade firmware and a current third position offset pointer in the differential information in the full differential packet in each decomposition operation in the decomposition process of the first control information.
For example, when the first control information is decomposed, the current operation length of the first control information may be subtracted by the current decomposition step size, and the decomposition step size of each step is recorded until the current operation length of the first control information is 0, and the decomposition of the first control information is completed. If the first control information is not decomposed completely, but the number of remaining bytes of the target upgrade firmware block and/or the source firmware block of the current operation is 0, shifting to the next block for decomposition operation. In the decomposition process, the new _ blk _ idx corresponding to the target upgrade firmware involved in each decomposition operation, the block id (old _ blk _ idx) of the source firmware, the offset position old _ from (first position offset pointer) in the source firmware, the offset position new _ from (second position offset pointer) in the target upgrade firmware, and the offset position diff _ from (third position offset pointer) in the patch file (full differential information) are also recorded.
And determining the third control information according to the first decomposition result, the first position offset pointer, the block identifier corresponding to the source firmware, the block identifier corresponding to the target upgrade firmware, the first position offset pointer, the second position offset pointer and the third position offset pointer.
Exemplarily, in the embodiment of the present application, when determining the third control information, a command rebuilding process is involved, and when a type of a control command included in the control information corresponding to the first decomposition result is rebuilt; the action of decomposing X (first control information) to generate a command type DIFF is subdivided into two command types: copy and diff. The subdivision principle is as follows: if the differential information corresponding to the first decomposition result relates to data (the length is step, the offset address is the offset of the differential block in the command detail) is all 0, namely the differential information with the length being step is all 0, which means that the differential information does not need to be differentiated and only depends on the old firmware, and at this time, the command is defined as a copy command; if the data included in the differential information is not all 0, the control information after the decomposition is related to both the differential information and the source firmware, and the command is defined as a diff command. Defining a =0 as a copy command, a =1 as a diff command, the operation step size step of the control information corresponding to the first decomposition result is identified by b, and the offset of the control information corresponding to the first decomposition result in the source firmware is identified by c, so as to obtain third control information (a, b, c). When a =0, (a, b, c) means that b bytes are copied from the source firmware, located at the c position of the source firmware; when a =1, (a, b, c) means that b bytes are copied from the source firmware and added to b bytes in the differential information, locating the c position of the source firmware.
Step 106, comprising:
and determining the current decomposition step length corresponding to the second control information according to the current operable byte number of the second control information and the residual byte number in the currently operated target upgrading solid block.
In the embodiment of the present application, Y (second control information) means that data of Y bytes is read from the unique information and added to the current operation position as the content of the target upgrade firmware, and therefore, the decomposition of the second control information does not involve the source firmware, and therefore, the current decomposition step size can be determined only according to the currently operable number of bytes of the second control information and the remaining number of bytes in the currently operated target upgrade firmware partition. The selection principle of the current decomposition step corresponding to the second control information is as follows: and taking the smaller value of the current operable byte number of the second control information and the residual byte number in the current operated target upgrading fixed part as the current decomposition step length corresponding to the second control information.
And decomposing the second control information according to the current decomposition step length corresponding to the second control information to obtain a second decomposition result, and recording a block identifier of target upgrade firmware corresponding to each decomposition operation in the decomposition process of the second control information, a current fourth position offset pointer in the target upgrade firmware and a current fifth position offset pointer in unique information in the full differential packet.
Exemplarily, the second control information is decomposed according to a current decomposition step corresponding to the second control information, and a processed position offset new _ from (fourth position offset pointer) and a dedicated fast position offset extra _ from (fifth position offset pointer) of each decomposition operation in the target upgrade firmware are recorded, and after one step is processed each time, a partition identification corresponding to the target upgrade firmware is recorded.
And determining the fourth control information according to a second decomposition result, the fourth position offset pointer, the fifth position offset pointer and the block identifier of the target upgrade firmware.
For example, in this embodiment of the application, the operation type of the control command corresponding to the second decomposition result may be defined as an EXTRA action, a =2 is defined as an EXTRA command, and the operation step size step of the control information corresponding to the second decomposition result is identified by b, so as to obtain the third control information (a, b, c), where c =0, because the third control information is not related to the old firmware. When a =2, (a, b, c) means that b bytes are copied from the corresponding unique information.
As an alternative embodiment of the present invention, step 109 includes: and determining the block identifier of the target upgrading firmware and the block identifier of the source firmware corresponding to the third control information. Illustratively, the content of the third control information includes operations on the target upgrade firmware partition and the source firmware partition, and the partition identifier of the target upgrade firmware and the partition identifier of the source firmware corresponding to the third control command may be determined.
And determining the corresponding relation between the block identifier of each target upgrading firmware and the block identifier of the source firmware according to the block identifier of the target upgrading firmware and the block identifier of the source firmware corresponding to the third control information. Exemplarily, when the third control information is executed to restore the corresponding target upgrade firmware partition, the corresponding information may be read from the corresponding source firmware, so that the correspondence between the partition identifier of each target upgrade firmware and the partition identifier of the source firmware may be determined according to the partition identifier of the target upgrade firmware and the partition identifier of the source firmware corresponding to the third control information. For example, if the target upgrade firmware partitions 10, 7, and 6 all need to obtain corresponding information from the source firmware partition 0 during the restoration, the target upgrade firmware partitions 10, 7, and 6 correspond to the source firmware partition 0.
And carrying out topological sequencing on the block identifier of the target upgrading firmware and the block identifier of the source firmware according to the corresponding relation between the block identifier of the target upgrading firmware and the block identifier of the source firmware. Illustratively, for example, when the correspondence between the block identifier of the target upgrade firmware and the block identifier of the source firmware includes:
old blk idx (target firmware block ID): 0 corresponds to new blk idx (target firmware block ID): 10, new blk idx:7, and new blk idx: 6;
old blk idx:2 corresponds to new blk idx:11 and new blk idx: 10;
old blk idx:2 corresponds to new blk idx:11 and new blk idx: 10;
old blk idx:3 corresponds to new blk idx: 10;
old blk idx:4 corresponds to new blk idx:10, new blk idx:8, and new blk idx: 5;
old blk idx:5 corresponds to new blk idx: 10;
old blk idx:6 corresponds to new blk idx:10, new blk idx:9, and new blk idx: 8;
old blk idx:7 corresponds to new blk idx:11, new blk idx:10, new blk idx:9, new blk idx:8, new blk idx:6, and new blk idx: 3.
And performing topological sorting on the block identifier of the target upgrade firmware and the block identifier of the source firmware according to the correspondence, as shown in fig. 3, the graph is a directed graph, a vertex represents the new firmware block identifier and the source firmware block identifier, an edge set represents the correspondence between the new firmware and the source firmware, a tail of the edge is the new firmware block identifier, and a head of the edge is the source firmware block identifier, and is used for identifying the correspondence between the new firmware block and the source firmware block. The target upgrading firmware block reduction sequence can be converted into topology sequencing on the graph, the topology sequencing can have a plurality of result sequences, and any one result sequence can be used as the sequence of firmware reduction, so that the problem of the new firmware reduction sequence is solved, and the problem of on-site coverage on the original firmware without using extra space is also solved.
And determining the upgrading sequence of each target upgrading firmware block according to the topological sorting result. Exemplarily, in the embodiment of the present application, one of sequences obtained by performing topological sorting according to the graph shown in fig. 3 is: 11- - >10- - >2- - >3- - >5- - >9- - >8- - >4- - >6- - >7- - >0- - >1, and the sequence can be used as a restoring sequence corresponding to the target upgrading firmware sub-block.
As an optional embodiment of the present invention, the method further comprises: and carrying out upgrading simulation operation on the source firmware by using a preset simulation program to carry out upgrading simulation operation on the differential upgrading packet corresponding to the target upgrading firmware.
Illustratively, the preset simulation program may implement simulation upgrade according to a differential upgrade package corresponding to the target upgrade firmware. And simulating the control information flow in the differential upgrade package through a preset simulation program, simulating the restoration action of the equipment side, ensuring that the contents of the simulated new firmware and the real new firmware are completely the same, and if any abnormity occurs, the generated firmware cannot be used for upgrading.
In the embodiment of the application, the differential upgrade package corresponding to the target upgrade firmware needs to be encrypted by a secret SM4 algorithm and added with a message verification code (MAC code), so that confidentiality and integrity of the firmware are guaranteed. The differential upgrade package corresponding to the target upgrade firmware also needs to add CRC of the original firmware, so as to ensure that the source firmware on the device side is the same as the source firmware corresponding to the differential upgrade package.
The embodiment of the invention also discloses a block differential upgrading method, which is applied to the equipment of the Internet of things, and as shown in figure 4, the method comprises the following steps:
step 201, obtaining a target differential upgrade package, where the target differential upgrade package is obtained by the block differential upgrade package generation method described in the above embodiment. Illustratively, the target differential upgrade package may be any pair of patch files that can implement differential upgrade on the source firmware in the internet of things device. In the embodiment of the application, the target differential upgrade package is transmitted to the equipment end through a wireless or wired channel, the equipment end initiates the handshake of the first package in the transmission process, and the equipment end has the request package serial number, so that the downloading is finished in the shortest time, and the capability of breakpoint (or power-off) continuous transmission is realized. After the equipment side receives the complete encrypted differential upgrade package, the safety decryption service of the SM4 secret is called, the differential upgrade package of the plaintext can be obtained, the MAC _1 (message verification code) of the differential upgrade package is obtained, the safety MAC service of the SM4 secret is called by the equipment side, the MAC _2 of the differential upgrade package of the plaintext is recalculated, and if the MAC _1 and the MAC _2 are the same, the differential file is not tampered, and the differential file is proved to be usable. And after a plaintext target upgrade firmware differential upgrade package is obtained, obtaining a source firmware CRC _1 in the differential upgrade package, calculating the CRC of the current firmware (source firmware) in real time to obtain a CRC _2, and if the CRC _1 is the same as the CRC _2, successfully matching the version of the differential upgrade package and being used for upgrading a new version firmware.
Step 202, reading the upgrading sequence information of each target upgrading firmware block in the target differential upgrading packet.
Step 203, according to the upgrading sequence information of each target upgrading firmware block, executing an upgrading command corresponding to each target upgrading firmware block in the firmware to be upgraded, and upgrading the firmware to be upgraded.
According to the block differential upgrading method provided by the invention, the target differential upgrading packet is obtained, the upgrading command in the corresponding block is executed according to the upgrading sequence information of one target upgrading firmware block contained in the target differential upgrading packet, the upgrading operation of the firmware to be upgraded is realized, the upgrading operation can be carried out on the basis of the source firmware in the upgrading process, all required memories only depend on the size of the block, do not depend on the sizes of the source firmware and the target firmware, and do not need to use extra space, so that the defect that the differential upgrading method in the prior art has large requirements on hardware storage resources is overcome.
The embodiment of the present invention further discloses a device for generating a block differential upgrade package, as shown in fig. 5, the device includes: a first obtaining module 301, configured to obtain a source firmware and a target upgrade firmware of a firmware to be upgraded; a calculating module 302, configured to calculate a full amount of differential packets of the source firmware and the target upgrade firmware, where the full amount of differential packets includes control information, differential information, and unique information; a block processing module 303, configured to perform block processing on the source firmware data and the target upgrade firmware data according to a target block size to obtain block data of a plurality of source firmware blocks and block data of a plurality of target upgrade firmware blocks, where the block data of each source firmware block includes a corresponding block identifier, and the block data of each target upgrade firmware block includes a corresponding block identifier; a second obtaining module 304, configured to obtain a plurality of control triple commands in the control information, where each control triple command includes first control information and second control information, where the first control information represents identical information and differential information of the source firmware and the target upgrade firmware, and the second control information represents unique information of the target upgrade firmware; a first decomposition module 305, configured to decompose each piece of first control information according to an identifier corresponding to each target upgrade firmware partition, an identifier corresponding to each source firmware partition, a size of the target partition, and an operation step length, to obtain third control information corresponding to each target upgrade firmware partition, where the third control information represents the same information and difference information in each target upgrade firmware partition and a corresponding source firmware partition; a second decomposition module 306, configured to decompose each piece of second control information according to the block identifier, the target block size, and the operation step length corresponding to the block data of each target upgrade firmware, to obtain fourth control information corresponding to the block of each target upgrade firmware, where the fourth control information is used to represent the same information and difference information in the block of each target upgrade firmware and the corresponding source firmware block; a first determining module 307, configured to determine, according to the third control information, the fourth control information, the difference information, and the unique information, difference information and unique information corresponding to each block of the target upgrade firmware; a generating module 308, configured to generate a differential upgrade package corresponding to the partition of each target upgrade firmware according to the third control information, the fourth control information, and the differential information and the unique information corresponding to the partition of each target upgrade firmware; a second determining module 309, configured to determine an upgrading order of each target upgrading firmware partition according to the third control information; and a packing module 310, configured to pack the differential upgrade package corresponding to the partition of each target upgrade firmware and the upgrade sequence to obtain the differential upgrade package corresponding to the target upgrade firmware.
The invention provides a block differential upgrade package generation device, which decomposes control information in a full differential package of firmware to be upgraded between a source firmware and a target firmware, determines third control information and fourth control information corresponding to each target upgrade firmware when upgrading the blocks, generates a differential upgrade package corresponding to each target upgrade firmware according to the third control information and the fourth control information, determines an upgrade sequence corresponding to each target upgrade firmware block according to the third control information, packages the differential upgrade package and the upgrade sequence corresponding to each target upgrade firmware block to obtain a differential upgrade package corresponding to the target upgrade firmware, wherein the differential upgrade package corresponding to the target upgrade firmware is a minimum differential package, the size of the differential upgrade package can be smaller than 10% of the source firmware or the target firmware, and can read the upgrade sequence corresponding to each target upgrade firmware block in the differential upgrade package when upgrading the source firmware according to the differential upgrade package corresponding to the target upgrade sequence, and sequentially restore each target firmware block according to the control information corresponding to the upgrade package, so that the size of the target firmware block differential upgrade is not required by the existing hardware upgrade technology, and the size of the target upgrade hardware does not need to be used in the existing upgrade process.
As an optional embodiment of the present invention, the apparatus further comprises: the fourth acquisition module is used for acquiring the size of a memory of a target processor at the equipment side and the minimum erasing unit of a target flash memory at the equipment side; and the third determining module is used for determining the size of the target block according to the memory size of the target processor and the minimum erasing unit of the target flash memory.
As an optional embodiment of the present invention, the first decomposition module includes: a first determining submodule, configured to determine a current decomposition step corresponding to the first control information according to a current operable byte number of the first control information, a remaining byte number in a currently operated source firmware partition, and a remaining byte number in a currently operated target upgrade firmware partition; a first decomposition submodule, configured to decompose the first control information according to a current decomposition step corresponding to the first control information to obtain a first decomposition result, and record a block identifier corresponding to source firmware, a block identifier corresponding to target upgrade firmware, a current first position offset pointer in the source firmware, a current second position offset pointer in the target upgrade firmware, and a current third position offset pointer in differential information in the full-component differential packet in a decomposition process of the first control information, where each step of decomposition operation corresponds to the source firmware; a second determining submodule, configured to determine the third control information according to a first decomposition result, the first location offset pointer, the block identifier of the corresponding source firmware, the block identifier of the corresponding target upgrade firmware, the first location offset pointer, the second location offset pointer, and the third location offset pointer;
a second decomposition module comprising: a third determining submodule, configured to determine a current decomposition step corresponding to the second control information according to a current operable byte number of the second control information and a remaining byte number in a currently operated target upgrade firmware partition; the second decomposition submodule is used for decomposing the second control information according to the current decomposition step length corresponding to the second control information to obtain a second decomposition result, and recording a block identifier of target upgrading firmware, a current fourth position offset pointer in the target upgrading firmware and a current fifth position offset pointer in unique information in the full differential packet, which correspond to each decomposition operation in the decomposition process of the second control information; and the fourth determining submodule is used for determining the fourth control information according to a second decomposition result, the fourth position offset pointer, the fifth position offset pointer and the block identifier of the target upgrading firmware.
As an optional embodiment of the present invention, the second determining module includes: the fifth determining submodule is used for determining the block identifier of the target upgrading firmware and the block identifier of the source firmware corresponding to the third control information; a sixth determining submodule, configured to determine, according to the block identifier of the target upgrade firmware and the block identifier of the source firmware corresponding to the third control information, a correspondence between the block identifier of each target upgrade firmware and the block identifier of the source firmware; the sequencing submodule is used for carrying out topological sequencing on the block identifier of the target upgrading firmware and the block identifier of the source firmware according to the corresponding relation between the block identifier of the target upgrading firmware and the block identifier of the source firmware; and the seventh determining submodule is used for determining the upgrading sequence of each target upgrading firmware block according to the topological sorting result.
As an optional embodiment of the present invention, the apparatus further comprises: and the upgrading simulation operation module is used for carrying out upgrading simulation operation on the source firmware by utilizing a preset simulation program to carry out upgrading simulation operation on the differential upgrading packet corresponding to the target upgrading firmware.
The embodiment of the present invention further discloses a device for generating a block differential upgrade package, as shown in fig. 6, the device includes: a third obtaining module 501, configured to obtain a target differential upgrade package, where the target differential upgrade package is obtained by using the block differential upgrade package generation method according to the embodiment; a reading module 502, configured to read upgrade sequence information of each target upgrade firmware partition in the target differential upgrade package; the upgrading module 503 is configured to execute an upgrading command corresponding to each target upgrade firmware partition in the firmware to be upgraded according to the upgrading sequence information of each target upgrade firmware partition, and upgrade the firmware to be upgraded.
According to the block differential upgrading device provided by the invention, the upgrading command in the corresponding block is executed according to the upgrading sequence information of one target upgrading firmware block contained in the target differential upgrading packet by acquiring the target differential upgrading packet, so that the upgrading operation of the firmware to be upgraded is realized, the upgrading operation can be carried out on the basis of the source firmware in the upgrading process, all required memories only depend on the size of the block, do not depend on the sizes of the source firmware and the target firmware, and do not need to use extra space, and the defect that the requirement of a differential upgrading method in the prior art on hardware storage resources is large is overcome.
An embodiment of the present invention further provides an electronic device, as shown in fig. 7, the electronic device may include a processor 401 and a memory 402, where the processor 401 and the memory 402 may be connected by a bus or in another manner, and fig. 7 takes the connection by the bus as an example.
Processor 401 may be a Central Processing Unit (CPU). The Processor 401 may also be other general purpose processors, digital Signal Processors (DSPs), application Specific Integrated Circuits (ASICs), field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, or combinations thereof.
The memory 402, which is a non-transitory computer readable storage medium, may be used to store non-transitory software programs, non-transitory computer executable programs, and modules, such as program instructions/modules corresponding to the block differential upgrade package generation method or the block differential upgrade method in the embodiments of the present invention. The processor 401 executes various functional applications and data processing of the processor by running the non-transitory software programs, instructions and modules stored in the memory 402, that is, implements the block differential upgrade package generation method or the block differential upgrade method in the above method embodiments.
The memory 402 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created by the processor 401, and the like. Further, the memory 402 may include high speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, memory 402 may optionally include memory located remotely from processor 401, which may be connected to processor 401 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The one or more modules are stored in the memory 402, and when executed by the processor 401, perform a block differential upgrade packet generation method as in the embodiment shown in fig. 1 or a block differential upgrade method as in the embodiment shown in fig. 4.
The details of the electronic device may be understood by referring to the corresponding descriptions and effects in the embodiments shown in fig. 1 and fig. 4, and are not described herein again.
Those skilled in the art will appreciate that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium and can include the processes of the embodiments of the methods described above when executed. The storage medium may be a magnetic Disk, an optical Disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a Flash Memory (Flash Memory), a Hard Disk (Hard Disk Drive, abbreviated as HDD), a Solid State Drive (SSD), or the like; the storage medium may also comprise a combination of memories of the kind described above.
Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope defined by the appended claims.

Claims (10)

1. A method for generating a block differential upgrade package is characterized by comprising the following steps:
acquiring a source firmware and a target upgrade firmware of a firmware to be upgraded;
calculating a total differential packet of the source firmware and the target upgrade firmware, wherein the total differential packet comprises control information, differential information and unique information;
the method comprises the steps that block processing is conducted on source firmware data and target upgrading firmware data according to the size of target blocks to obtain block data of a plurality of source firmware blocks and block data of a plurality of target upgrading firmware blocks, wherein the block data of each source firmware block comprises a corresponding block identifier, and the block data of each target upgrading firmware block comprises a corresponding block identifier;
acquiring a plurality of control triple commands in the control information, wherein each control triple command comprises first control information and second control information, the first control information represents the same information and difference information of the source firmware and the target upgrade firmware, and the second control information represents the unique information of the target upgrade firmware;
decomposing each piece of first control information according to the identifier corresponding to each piece of target upgrade firmware, the identifier corresponding to each piece of source firmware, the size of each piece of target firmware and the operation step length to obtain third control information corresponding to each piece of target upgrade firmware, wherein the third control information represents the same information and difference information in each piece of target upgrade firmware and the corresponding piece of source firmware;
decomposing each piece of second control information according to the block identification corresponding to the block data of each piece of target upgrading firmware, the size of each target block and the operation step length to obtain fourth control information corresponding to the block of each piece of target upgrading firmware, wherein the fourth control information is used for representing the same information and difference information in the block of each piece of target upgrading firmware and the corresponding source firmware block;
determining differential information and unique information corresponding to the blocks of each target upgrade firmware according to the third control information, the fourth control information, the differential information and the unique information;
generating a differential upgrade package corresponding to the blocks of each target upgrade firmware according to the third control information, the fourth control information and the differential information and the unique information corresponding to the blocks of each target upgrade firmware;
determining the upgrading sequence of each target upgrading firmware block according to the third control information;
and packaging the differential upgrade package corresponding to the blocks of each target upgrade firmware and the upgrade sequence to obtain the differential upgrade package corresponding to the target upgrade firmware.
2. The method of claim 1, wherein before the blocking the source firmware data and the target upgrade firmware data according to the target block size to obtain the block data of the plurality of source firmware blocks and the block data of the plurality of target upgrade firmware blocks, the method further comprises:
acquiring the memory size of a target processor at the equipment side and the minimum erasing unit of a target flash memory at the equipment side;
and determining the size of the target block according to the size of the memory of the target processor and the minimum erasing unit of the target flash memory.
3. The method of claim 1, wherein decomposing each first control information according to the identifier corresponding to each target upgrade firmware partition, the identifier corresponding to each source firmware partition, the target partition size, and the operation step size to obtain third control information corresponding to each target upgrade firmware partition comprises:
determining a current decomposition step corresponding to the first control information according to the current operable byte number of the first control information, the residual byte number in the currently operated source firmware sub-block and the residual byte number in the currently operated target upgrade firmware sub-block;
decomposing the first control information according to the current decomposition step length corresponding to the first control information to obtain a first decomposition result, and recording a block identifier corresponding to a source firmware, a block identifier corresponding to a target upgrading firmware, a current first position offset pointer in the source firmware, a current second position offset pointer in the target upgrading firmware and a current third position offset pointer in differential information in the full differential packet in each decomposition operation in the decomposition process of the first control information;
determining the third control information according to a first decomposition result, the first position offset pointer, the block identifier corresponding to the source firmware, the block identifier corresponding to the target upgrade firmware, the first position offset pointer, the second position offset pointer, and the third position offset pointer;
decomposing each piece of second control information according to the block identifier corresponding to the block data of each piece of target upgrade firmware, the target block size and the operation step length to obtain fourth control information corresponding to the block of each piece of target upgrade firmware, including:
determining a current decomposition step length corresponding to the second control information according to the current operable byte number of the second control information and the residual byte number in the currently operated target upgrading solid block;
decomposing the second control information according to the current decomposition step length corresponding to the second control information to obtain a second decomposition result, and recording a block identifier of target upgrade firmware corresponding to each decomposition operation in the decomposition process of the second control information, a current fourth position offset pointer in the target upgrade firmware and a current fifth position offset pointer in unique information in the full differential packet;
and determining the fourth control information according to a second decomposition result, the fourth position offset pointer, a fifth position offset pointer and a block identifier of the target upgrading firmware.
4. The method of claim 3, wherein determining an upgrade order for each target upgrade firmware partition based on the third control information comprises:
determining a block identifier of the target upgrading firmware and a block identifier of the source firmware corresponding to the third control information;
determining the corresponding relation between the block identifier of each target upgrading firmware and the block identifier of the source firmware according to the block identifier of the target upgrading firmware and the block identifier of the source firmware corresponding to the third control information;
carrying out topological sorting on the block identifier of the target upgrading firmware and the block identifier of the source firmware according to the corresponding relation between the block identifier of the target upgrading firmware and the block identifier of the source firmware;
and determining the upgrading sequence of each target upgrading firmware block according to the topological sorting result.
5. The method of claim 1, further comprising:
and carrying out upgrading simulation operation on the source firmware by using a preset simulation program to carry out upgrading simulation operation on the differential upgrading packet corresponding to the target upgrading firmware.
6. A method for upgrading block difference is characterized by comprising the following steps:
acquiring a target differential upgrade package, wherein the target differential upgrade package is obtained by the method for generating the blocked differential upgrade package according to any one of claims 1 to 5;
reading upgrading sequence information of each target upgrading firmware block in the target differential upgrading packet;
and according to the upgrading sequence information of each target upgrading firmware block, executing an upgrading command corresponding to each target upgrading firmware block in the firmware to be upgraded, and upgrading the firmware to be upgraded.
7. A block differential upgrade package generation apparatus, comprising:
the first acquisition module is used for acquiring a source firmware and a target upgrade firmware of the firmware to be upgraded;
a calculation module, configured to calculate a full differential packet of the source firmware and the target upgrade firmware, where the full differential packet includes control information, differential information, and unique information;
the block processing module is used for carrying out block processing on the source firmware data and the target upgrading firmware data according to the size of the target block to obtain block data of a plurality of source firmware blocks and block data of a plurality of target upgrading firmware blocks, wherein the block data of each source firmware block comprises a corresponding block identifier, and the block data of each target upgrading firmware block comprises a corresponding block identifier;
a second obtaining module, configured to obtain multiple control triple commands in the control information, where each control triple command includes first control information and second control information, where the first control information represents identical information and differential information of the source firmware and the target upgrade firmware, and the second control information represents unique information of the target upgrade firmware;
the first decomposition module is used for decomposing each piece of first control information according to the identifier corresponding to each target upgrading firmware block, the identifier corresponding to each source firmware block, the target block size and the operation step length to obtain third control information corresponding to each target upgrading firmware block, wherein the third control information represents the same information and difference information in each target upgrading firmware block and the corresponding source firmware block;
the second decomposition module is used for decomposing each piece of second control information according to the block identifier corresponding to the block data of each target upgrading firmware, the size of each target block and the operation step length to obtain fourth control information corresponding to the block of each target upgrading firmware, wherein the fourth control information is used for representing the same information and difference information in the block of each target upgrading firmware and the corresponding source firmware block;
a first determining module, configured to determine, according to the third control information, the fourth control information, the difference information, and the unique information, difference information and unique information that correspond to each block of the target upgrade firmware;
the generating module is used for generating a differential upgrade package corresponding to the blocks of each target upgrade firmware according to the third control information, the fourth control information and the differential information and the unique information corresponding to the blocks of each target upgrade firmware;
the second determining module is used for determining the upgrading sequence of each target upgrading firmware block according to the third control information;
and the packaging module is used for packaging the differential upgrade package corresponding to the blocks of each target upgrade firmware and the upgrade sequence to obtain the differential upgrade package corresponding to the target upgrade firmware.
8. A block differential upgrade apparatus, comprising:
a third obtaining module, configured to obtain a target differential upgrade package, where the target differential upgrade package is obtained by the block differential upgrade package generation method according to any one of claims 1 to 5;
the reading module is used for reading the upgrading sequence information of each target upgrading firmware block in the target differential upgrading packet;
and the upgrading module is used for executing the upgrading command corresponding to each target upgrading firmware block in the firmware to be upgraded according to the upgrading sequence information of each target upgrading firmware block, and upgrading the firmware to be upgraded.
9. An electronic device, comprising: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to cause the at least one processor to perform the steps of the block differential upgrade package generation method of any one of claims 1-5 or to perform the steps of the block differential upgrade method of claim 6.
10. A computer-readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, carries out the steps of the method for generating a blocked differential upgrade package according to any one of claims 1 to 5, or carries out the steps of the method for generating a blocked differential upgrade according to claim 6.
CN202211497718.7A 2022-11-25 2022-11-25 Block differential upgrade package generation and block differential upgrade method and device Pending CN115718614A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211497718.7A CN115718614A (en) 2022-11-25 2022-11-25 Block differential upgrade package generation and block differential upgrade method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211497718.7A CN115718614A (en) 2022-11-25 2022-11-25 Block differential upgrade package generation and block differential upgrade method and device

Publications (1)

Publication Number Publication Date
CN115718614A true CN115718614A (en) 2023-02-28

Family

ID=85256670

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211497718.7A Pending CN115718614A (en) 2022-11-25 2022-11-25 Block differential upgrade package generation and block differential upgrade method and device

Country Status (1)

Country Link
CN (1) CN115718614A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116302030A (en) * 2023-03-09 2023-06-23 上海对外经贸大学 Safe embedded system firmware block differential upgrading method and system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116302030A (en) * 2023-03-09 2023-06-23 上海对外经贸大学 Safe embedded system firmware block differential upgrading method and system

Similar Documents

Publication Publication Date Title
US9778926B2 (en) Minimizing image copying during partition updates
JP2008522254A (en) Static file system difference detection and update
CN111831297B (en) Zero-difference upgrading method and device
CN110471692B (en) Over-the-air upgrading method, device, equipment and storage medium of terminal program
CN106155734B (en) Method and device for downloading software version
CN106161336A (en) A kind of information updating method, Apparatus and system
US11977637B2 (en) Technique for authentication and prerequisite checks for software updates
CN111240722B (en) Method for upgrading firmware over the air, and terminal, server and system applied by same
CN115718614A (en) Block differential upgrade package generation and block differential upgrade method and device
CN103970566A (en) Router firmware updating method and device
CN104866293A (en) Method and device for extending Android application program function
CN104427119A (en) Communication terminal and nonvolatile data processing method of communication terminal
CN107239309A (en) Patch generation method and device, update method, electronic equipment, storage medium
CN113961226B (en) Software development kit repairing method, terminal, server and equipment
CN112286565B (en) Embedded system differential upgrading method based on storage container
CN113986313A (en) Software upgrading method and device, electronic equipment and storage medium
CN104427120A (en) Communication terminal and nonvolatile data processing method of communication terminal
CN113849859A (en) Linux kernel modification method, terminal device and storage medium
JP2005100007A (en) Data file saving system and allocation method
CN113794591A (en) Configuration method and device of acquisition protocol and electronic equipment
CN115454627A (en) Calculation method of neural network model, computer equipment and storage medium
CN113918423A (en) Cloud platform monitoring method and device and application thereof
CN112988176A (en) Channel package generation method and device, storage medium and electronic equipment
CN112835572A (en) Method and equipment for customizing reference flow depending on project management tool
CN110769030A (en) Method, terminal, server and storage medium for downloading file

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination