An Online Differential Upgrade Implementation Method
By segmenting and processing differential information in IoT devices, establishing a directed graph of dependency relationships and performing topological sorting, in-place upgrades under limited memory space are achieved, solving the storage space requirements of the differential upgrade method and ensuring that no additional storage space is required during the upgrade process.
Patent Information
- Application Number
- CN202211632533.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-19
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2042-12-19
AI Technical Summary
The existing differential upgrade method cannot meet the upgrade requirements in IoT devices with small Flash memory space, and requires additional storage space for open-loop processing.
By extracting the full difference information between the firmware to be upgraded and the target upgrade firmware, dividing it into multiple sub-blocks, establishing a directed graph of dependency relationships, performing open-loop processing and topological sorting, and executing diff and extra commands for in-place coverage upgrades.
Complete in-place restoration and coverage of source firmware on the device side, and upgrade with minimal extra space, solving the problem of memory space limitations.
Smart Images

Figure CN116069371B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information technology, and specifically to an online differential upgrade implementation method. Background Art
[0002] With the rapid development of the Internet of Things, the diversity and large-scale operation of Internet of Things devices have brought pressure, driving Internet of Things devices to have the firmware upgrade ability to meet different operating scenarios.
[0003] Currently, there are dedicated firmware upgrade service companies in the market that provide such services to solution providers or device manufacturers. By establishing a firmware upgrade server platform to serve other enterprises, one of the main methods of current firmware upgrade is the differential upgrade method. In the differential upgrade method, an upgrade patch is first made in the host computer or platform. The device side downloads the upgrade patch file from the host computer or platform side. After the download is completed, the target firmware is restored based on the upgrade patch file and the original file. When using this upgrade patch file, if the established dependency relationship is an acyclic graph, no additional flash storage space is required. If the dependency relationship is a cyclic graph, the target firmware restoration process must require open-loop processing, and additional space is also required to save a block number data during the open-loop process.
[0004] Therefore, the above solution does not solve the requirement for flash memory space, and in Internet of Things devices with a small flash memory space, the application scenario of the differential upgrade method still cannot be satisfied. Summary of the Invention
[0005] This application provides an online differential upgrade implementation method. During the upgrade process on the device side, in-place restoration and overwrite of the source firmware are completed, and the required additional space is minimized. The technical solution is as follows.
[0006] On the one hand, an online differential upgrade implementation method is provided, and the method includes:
[0007] Extract the full-difference information between the source firmware and the target upgrade firmware of the firmware to be upgraded;
[0008] According to the target block size, divide the target upgrade firmware into multiple target upgrade firmware sub-blocks, and divide the source firmware into multiple source firmware sub-blocks; each target upgrade firmware sub-block and each source firmware sub-block include corresponding identifiers;
[0009] Decompose the full differential information according to the identifier corresponding to each target upgraded firmware sub-block, the identifier corresponding to each source firmware sub-block, the target block size, and the target operation step length, so as to create a command list for the target upgraded firmware; the command list includes a diff command and an extra command corresponding to each target upgraded firmware sub-block; the diff command represents the operation information within the source firmware sub-block on which each target upgraded firmware sub-block depends; the extra command represents the unique operation information within each target upgraded firmware sub-block;
[0010] According to the command list, establish a directed graph of the dependency relationship between the target upgraded firmware sub-block and the source firmware sub-block;
[0011] Perform an open-loop process on the directed graph of the dependency relationship to obtain the restored topological sorting of each sub-block in the directed graph of the dependency relationship;
[0012] According to the restored topological sorting result, sequentially execute the diff command and the extra command to perform an in-place overwrite upgrade on the source firmware.
[0013] In another aspect, an online differential upgrade implementation device is provided, and the device includes:
[0014] A full differential information acquisition module, configured to extract the full differential information between the source firmware and the target upgraded firmware of the firmware to be upgraded;
[0015] A firmware segmentation module, configured to segment the target upgraded firmware into multiple target upgraded firmware sub-blocks according to the target block size, and segment the source firmware into multiple source firmware sub-blocks; each target upgraded firmware sub-block and each source firmware sub-block includes a corresponding identifier;
[0016] A command list creation module, configured to decompose the full differential information according to the identifier corresponding to each target upgraded firmware sub-block, the identifier corresponding to each source firmware sub-block, the target block size, and the target operation step length, so as to create a command list for the target upgraded firmware; the command list includes a diff command and an extra command corresponding to each target upgraded firmware sub-block; the diff command represents the operation information within the source firmware sub-block on which each target upgraded firmware sub-block depends; the extra command represents the unique operation information within each target upgraded firmware sub-block;
[0017] A dependency relationship directed graph acquisition module, configured to establish a directed graph of the dependency relationship between the target upgraded firmware sub-block and the source firmware sub-block according to the command list;
[0018] A reduction topological sorting acquisition module, configured to perform an open-loop process on the directed graph of dependencies to obtain the reduction topological sorting of each sub-block in the directed graph of dependencies;
[0019] A source firmware upgrade module, configured to sequentially execute the diff command and the extra command according to the reduction topological sorting result to perform an in-place overwrite upgrade on the source firmware.
[0020] In a possible implementation manner, the apparatus is further configured to:
[0021] Obtain the memory size of a target processor on the device side and the minimum erasure unit of a target flash memory on the device side;
[0022] Determine the target block size according to the memory size of the target processor and the minimum erasure unit of the target flash memory.
[0023] In a possible implementation manner, the full differential information includes control information, differential information, and unique information of the target upgrade firmware.
[0024] In a possible implementation manner, the apparatus is further configured to:
[0025] Obtain a plurality of control triple commands in the control information, each control triple command including first control information and second control information, where the first control information represents the sum of information of a first target byte amount read from within the differential information and within the source firmware respectively; the second control information represents unique information of a second target byte amount read from the unique information of the target upgrade firmware.
[0026] In a possible implementation manner, the command list creation module includes:
[0027] A diff command linked list acquisition unit, configured to decompose each first control information according to the identifier corresponding to each target upgrade firmware sub-block, the identifier corresponding to each source firmware sub-block, the target block size, and a first target operation step length to obtain the diff command corresponding to each target upgrade firmware sub-block, so as to form a diff command linked list;
[0028] An extra command linked list acquisition unit, configured to decompose each second control information according to the identifier corresponding to each target upgrade firmware sub-block, the target block size, and a second target operation step length to obtain the extra command corresponding to each target upgrade firmware sub-block, so as to form an extra command linked list.
[0029] In a possible implementation manner, the diff command linked list obtaining unit is further configured to:
[0030] Determine a current first decomposition step corresponding to the first control information according to the current operable byte count of the first control information, the remaining bytes in the current source firmware sub-block being operated on, and the remaining bytes in the current target upgrade firmware sub-block being operated on;
[0031] Decompose the first control information according to the current first decomposition step corresponding to the first control information to obtain a first decomposition result, and record the identifier of the source firmware sub-block corresponding to each decomposition operation in the decomposition process of the first control information, the identifier of the corresponding target upgrade firmware sub-block, the current first position offset pointer in the source firmware, the current second position offset pointer in the target upgrade firmware, and the current third position offset pointer in the differential information of the full differential information;
[0032] Determine the diff command corresponding to each target upgrade firmware sub-block according to the first decomposition result, the first position offset pointer, the identifier of the corresponding source firmware sub-block, the identifier of the corresponding target upgrade firmware sub-block, the first position offset pointer, the second position offset pointer, and the third position offset pointer.
[0033] In a possible implementation manner, the extra command linked list obtaining unit is further configured to:
[0034] Determine a current second decomposition step corresponding to the second control information according to the current operable byte count of the second control information and the remaining bytes in the current target upgrade firmware sub-block being operated on;
[0035] Decompose the second control information according to the current second decomposition step corresponding to the second control information to obtain a second decomposition result, and record the identifier of the target upgrade firmware sub-block corresponding to each decomposition operation in the decomposition process of the second control information, the current fourth position offset pointer in the target upgrade firmware, and the current fifth position offset pointer in the unique information of the full differential information;
[0036] Determine the extra command corresponding to each target upgrade firmware sub-block according to the second decomposition result, the fourth position offset pointer, the fifth position offset pointer, and the identifier of the target upgrade firmware sub-block.
[0037] In a possible implementation manner, the dependency directed graph obtaining module further includes:
[0038] The traversing diff command unit is used to traverse the diff commands in the command list to obtain the identifiers of the source firmware sub-blocks upon which each target upgraded firmware sub-block depends;
[0039] The dependency obtaining unit is used to obtain the dependency relationships between each target upgraded firmware sub-block and each source firmware sub-block according to the identifiers of the source firmware sub-blocks upon which each target upgraded firmware sub-block depends;
[0040] The dependency directed graph obtaining unit is used to establish a dependency directed graph between the target upgraded firmware sub-blocks and the source firmware sub-blocks according to the dependency relationships.
[0041] In a possible implementation manner, the dependency directed graph obtaining unit is further used to:
[0042] Add the dependency relationships to a variable with a graph data structure to form a dependency directed graph between the target upgraded firmware sub-blocks and the source firmware sub-blocks.
[0043] In a possible implementation manner, the reduced topological sorting obtaining module is further used to:
[0044] Determine the sub-block with the least in-degree in the dependency directed graph as the first sub-block of the reduced topological sorting, so as to perform priority reduction processing and erasure processing on the first sub-block;
[0045] Perform an open-loop process on other sub-blocks in the dependency directed graph except the first sub-block, and determine the target sub-blocks that are still depended on by other sub-blocks after the reduction is completed; the target sub-blocks need to be saved in an additional space during the reduction process;
[0046] Obtain the reduced topological sorting of each sub-block in the dependency directed graph according to the first sub-block, the target sub-blocks, and the open-loop process result.
[0047] On the other hand, a computer device is provided. The computer device includes a processor and a memory. At least one instruction is stored in the memory, and the at least one instruction is loaded and executed by the processor to implement an online differential upgrade implementation method as described above.
[0048] On another hand, a computer-readable storage medium is provided. At least one instruction is stored in the storage medium, and the at least one instruction is loaded and executed by a processor to implement any one of the online differential upgrade implementation methods as described above.
[0049] The technical solution provided by this application may include the following beneficial effects:
[0050] First, extract the full-difference information between the source firmware of the firmware to be upgraded and the target upgrade firmware, and according to the target block size, split the target upgrade firmware into multiple target upgrade firmware sub-blocks, and split the source firmware into multiple source firmware sub-blocks; then, according to the identifier corresponding to each target upgrade firmware sub-block, the identifier corresponding to each source firmware sub-block, the target block size, and the target operation step, decompose the full-difference information to create a command list for the target upgrade firmware; then, according to the command list, establish a directed graph of the dependency relationship between the target upgrade firmware sub-blocks and the source firmware sub-blocks, and perform an open-loop process on the directed graph of the dependency relationship to obtain the restored topological sorting of each sub-block in the directed graph of the dependency relationship; finally, according to the restored topological sorting result, execute the diff command and the extra command in sequence to perform an in-place overwrite upgrade on the source firmware. During the upgrade process on the device side of the above solution, the in-place restoration and overwrite of the source firmware can be completed according to the restored order after the restored topological sorting, ensuring that the upgrade is performed with the least amount of extra space. Brief Description of the Drawings
[0051] In order to more clearly illustrate the specific implementation manners of the present application or the technical solutions in the prior art, the following will briefly introduce the drawings required for the description of the specific implementation manners or the prior art. Obviously, the following drawings are some implementation manners of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0052] Figure 1 is a flowchart of a method for realizing online differential upgrade according to an exemplary embodiment.
[0053] Figure 2 is a schematic structural diagram of a command list of a created target upgrade firmware according to an exemplary embodiment.
[0054] Figure 3 is a flowchart of a method for realizing online differential upgrade according to an exemplary embodiment.
[0055] Figure 4 is a schematic structural diagram of the remaining bytes in the source firmware sub-block of the current operation according to an exemplary embodiment.
[0056] Figure 5 is a schematic structural diagram of the remaining bytes in the target upgrade firmware sub-block of the current operation according to an exemplary embodiment.
[0057] Figure 6 is a directed graph of the dependency relationship according to an exemplary embodiment.
[0058] Figure 7 It is a structural block diagram of an online differential upgrade implementation device shown according to an exemplary embodiment.
[0059] Figure 8 It shows a structural block diagram of a computer device shown according to an exemplary embodiment of the present application. Detailed implementation manners
[0060] Next, the technical solutions of the present application will be clearly and completely described in conjunction with the accompanying drawings. Obviously, the described embodiments are some embodiments of the present application, rather than all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0061] It should be understood that in the description of the embodiments of the present application, the term "corresponding" may indicate a direct or indirect corresponding relationship between two parties, may also indicate an association relationship between two parties, or may be an indication and being indicated, configuration and being configured, etc. relationships.
[0062] Figure 1 It is a method flow chart of an online differential upgrade implementation method shown according to an exemplary embodiment. This method can be applied to a host computer or a differential upgrade platform system, and all historical firmware data and upgradable firmware data on the side of the device to be upgraded are integrated on the host computer or the differential upgrade platform system; as Figure 1 shown, this method may include the following steps:
[0063] S101. Extract the full - volume differential information between the source firmware and the target upgrade firmware of the firmware to be upgraded.
[0064] In a possible implementation manner, the firmware may be code stored in the memory operable by a single - chip microcomputer or an MCU, which is a compiled binary file and can operate on the hardware, and is usually called: Firmware. The source firmware may be the firmware before the upgrade, also called the old firmware; the target upgrade firmware may be the firmware after the upgrade, also called the new firmware.
[0065] In a possible implementation manner, the full - volume differential information may be a difference file between the target upgrade firmware and the source firmware made through a differential algorithm, called a patch file (Patch), which is completed by the host computer or the platform system. The differential algorithm may be a method or step for extracting the difference information between the source firmware and the target upgrade firmware. Commonly used differential algorithms are bsdiff and vcdiff. After completing the matching search, both algorithms can perform secondary compression, and for the characteristics of the firmware binary file, efficient matching can be completed.
[0066] S102. Divide the target upgrade firmware into multiple target upgrade firmware sub - blocks and divide the source firmware into multiple source firmware sub - blocks according to the target block size; each target upgrade firmware sub - block and each source firmware sub - block includes a corresponding identifier.
[0067] In a possible implementation manner, the setting of the target block size affects the final patch size. The larger the block, the smaller the patch file, but the higher the requirement for the memory size on the device side. The content on the device side refers to the memory that is lost when the power is off, which can be understood as the memory on a computer device.
[0068] In a possible implementation manner, the target block size can be any size. The embodiments of the present application do not limit the specific content of the target block size, as long as it can achieve the block division of the source firmware and the target upgrade firmware, which can be determined by those skilled in the art according to needs. In the embodiments of the present application, the source firmware and the target upgrade firmware can be divided according to the target block size. For example, when the target block size is 512 bytes, the size of the source firmware is 4672 bytes, and the size of the target upgrade firmware is 5580 bytes, then the source firmware and the upgrade firmware are divided into blocks of 512 bytes, and the identifier corresponding to each source firmware sub - block and the identifier corresponding to each target upgrade firmware sub - block are recorded; exemplarily, the identifier can be the block number corresponding to each source firmware sub - block and each target upgrade firmware sub - block respectively.
[0069] S103. Decompose the full - volume differential information according to the identifier corresponding to each target upgrade firmware sub - block, the identifier corresponding to each source firmware sub - block, the target block size, and the target operation step - length to create a command list for the target upgrade firmware; the command list includes the diff command and the extra command corresponding to each target upgrade firmware sub - block; the diff command represents the operation information within the source firmware sub - block on which each target upgrade firmware sub - block depends; the extra command represents the unique operation information within each target upgrade firmware sub - block.
[0070] Exemplarily, in the embodiments of the present application, the full - volume differential information includes control information, which is composed of a series of commands. Each command consists of a command triple in the fixed format of CMD(X, Y, Z). The operation object for decomposing the full - volume differential information is the command triple included in the control information, and at this time, it has nothing to do with the old firmware and the new firmware files themselves.
[0071] Exemplarily, when decomposing the command triple, the target operation step size may be the number of operation bytes corresponding to each operation step. In the embodiments of the present application, for example, if X in the command triple is decomposed into reduction commands corresponding to each target upgrade firmware sub-block, assuming that the operation bytes of X in the first command triple are 1,671 bytes and the size of each block is 512, so X will span 3 sub-blocks during execution and involve 4 sub-block spaces. Therefore, when decomposing X, it should be decomposed into operation instructions corresponding to each sub-block in the four block spaces.
[0072] Similarly, in the embodiments of the present application, if Y in the command triple is decomposed into reduction commands corresponding to each target upgrade firmware sub-block; assuming that the operation bytes of Y in the first command triple are 1,671 bytes and the size of each block is 512, so Y will span 3 sub-blocks during execution and involve 4 sub-block spaces. Therefore, when decomposing Y, it should be decomposed into operation instructions corresponding to each sub-block in the four block spaces.
[0073] Further, the command list of the created target upgrade firmware is as Figure 2 shown. The command list includes the identifier of each target upgrade firmware sub-block (i.e., Figure 2 the new firmware block number in ), as well as the diff command and extra command corresponding to each target upgrade firmware sub-block; the diff command represents the operation information in the source firmware sub-block on which each target upgrade firmware sub-block depends, and is a reduction command obtained by decomposing X in the command triple; the extra command represents the unique operation information in each target upgrade firmware sub-block, and is a reduction command obtained by decomposing Y in the command triple.
[0074] S104. According to the command list, establish a directed graph of the dependency relationship between the target upgrade firmware sub-block and the source firmware sub-block.
[0075] In a possible implementation manner, the dependency relationship between each target upgrade firmware sub-block and each source firmware sub-block can be obtained from the diff command in the command linked list, and this dependency relationship is added to a variable with a graph data structure to obtain a directed graph of the dependency relationship between each target upgrade firmware sub-block and each source firmware sub-block. The directed graph of the dependency relationship more intuitively shows the dependency relationship between each sub-block to assist subsequent topological sorting.
[0076] S105. Perform an open-loop process on the directed graph of the dependency relationship to obtain the reduction topological sorting of each sub-block in the directed graph of the dependency relationship.
[0077] In a possible implementation, for the case where there are both cycles and acyclic parts in the dependency directed graph, the acyclic interval blocks are processed first. Finally, when only the cyclic part remains, the cycle is broken. When breaking the cycle, since the number of other sub-blocks affected by the sub-block with the least in-degree is equal to the number of sub-blocks to be cached, the principle is to process the sub-block with the least in-degree first and restore it preferentially. For the case where the in-degrees are the same, the block with the most out-degree is processed first. Among them, in the original topological sorting, the sub-blocks that are still dependent on other sub-blocks after restoration are the sub-blocks to be cached, and caching is performed during restoration to facilitate the restoration of other subsequent sub-blocks.
[0078] S106. According to the restored topological sorting result, sequentially execute the diff command and the extra command to perform in-place overwrite upgrade on the source firmware.
[0079] In a possible implementation, after the cycle-breaking process, the firmware restoration order has been converted to perform topological sorting on this graph. For the acyclic graph after the cycle-breaking process, after topological sorting, a dependency sequence is formed. This sequence can ensure that when executed in order, there will no longer be restored dependencies. There may be multiple result sequences for topological sorting, and any one of the result sequences can be used as the firmware restoration order. This solves the problem of the new firmware restoration order and also solves the problem of in-place overwrite on the source firmware without using additional space, thus eliminating the need for additional space.
[0080] In summary, first extract the full-difference information between the source firmware of the firmware to be upgraded and the target upgrade firmware, and according to the target block size, divide the target upgrade firmware into multiple target upgrade firmware sub-blocks and divide the source firmware into multiple source firmware sub-blocks; then decompose the full-difference information according to the identifier corresponding to each target upgrade firmware sub-block, the identifier corresponding to each source firmware sub-block, the target block size, and the target operation step length to create a command list for the target upgrade firmware; then establish a dependency directed graph between the target upgrade firmware sub-blocks and the source firmware sub-blocks according to the command list, and perform cycle-breaking processing on the dependency directed graph to obtain the restored topological sorting of each sub-block in the dependency directed graph; finally, according to the restored topological sorting result, sequentially execute the diff command and the extra command to perform in-place overwrite upgrade on the source firmware. During the upgrade process of the device side of the above solution, the in-place restoration and overwrite of the source firmware can be completed according to the restored order after topological sorting, ensuring that the upgrade is performed with the least amount of additional space.
[0081] Figure 3 is a flowchart of an online differential upgrade implementation method shown according to an exemplary embodiment. This method can be implemented by a host computer or a platform. AsFigure 3 As shown, the method may include the following steps:
[0082] S301. Extract the full-difference information between the source firmware of the firmware to be upgraded and the target upgrade firmware.
[0083] In a possible implementation, the full-difference information includes control information, difference information, and unique information of the target upgrade firmware.
[0084] Furthermore, in the embodiments of the present application, the bsdiff difference algorithm may be used to complete the extraction of the full-difference information. After the source firmware and the target upgrade firmware pass through the bsdiff algorithm, a patch file (full-difference information) is generated. The role of the patch file is that when the patch file is transmitted to the device to be upgraded, the device can restore the target upgrade firmware according to this patch file and the source firmware. The patch file consists of three parts of information: control information, difference information, and unique information of the new firmware. Among them, the control information consists of a series of commands, and each command consists of a command triple in the fixed format of CMD(X, Y, Z). The composition of the patch file is shown in Table 1 below.
[0085] Table 1
[0086]
[0087]
[0088] S302. According to the target block size, divide the target upgrade firmware into multiple target upgrade firmware sub-blocks, and divide the source firmware into multiple source firmware sub-blocks; each target upgrade firmware sub-block and each source firmware sub-block include corresponding identifiers.
[0089] In a possible implementation, obtain the memory size of the target processor on the device side and the minimum erasure unit of the target flash memory on the device side;
[0090] Determine the target block size according to the memory size of the target processor and the minimum erasure unit of the target flash memory.
[0091] Further, the block size setting must meet the following principles: meet the memory requirements on the device side and use the flash erasure unit on the device side as the minimum unit. Therefore, to achieve the best differential effect, assuming that the memory of the MCU on the device side is size_mem and the erasure unit of the memory on the device side is size_flash_erasor, the present application provides a calculation formula for setting the block size (block_size): block_size = M * size_flash_erasor, (where M is a positive integer); M = (size_mem / 4 + size_flash_erasor - 1) / size_flash_erasor; for example, for a resource-constrained MCU, size_mem = 8192B, size_flash_erasor = 512B, after calculation, M = 4, block_size = 2048B.
[0092] S303. Decompose the full differential information according to the identifier corresponding to each target upgraded firmware sub-block, the identifier corresponding to each source firmware sub-block, the target block size, and the target operation step length to create a command list for the target upgraded firmware; the command list includes a diff command and an extra command corresponding to each target upgraded firmware sub-block; the diff command represents the operation information in the source firmware sub-block on which each target upgraded firmware sub-block depends; the extra command represents the unique operation information in each target upgraded firmware sub-block.
[0093] In a possible implementation manner, obtain a plurality of control triple commands in the control information, each control triple command including first control information and second control information, where the first control information represents the sum of the information of the first target byte amounts read from the differential information and the source firmware respectively; the second control information represents the unique information of the second target byte amount read from the unique information of the target upgraded firmware.
[0094] Further, in the embodiments of the present application, the first control information may be X in the above command triple (X, Y, Z). The meaning of X is that X bytes (i.e., the above first target byte amount) are read from the differential information (D1D2D3…) and added to X bytes of the old firmware to obtain the content of the new firmware. The second control information may be Y in the command triple (X, Y, Z). The meaning of Y is that Y bytes (i.e., the above second target byte amount) of data are copied from the unique information (E1E2E3…) and added to the current position as the content of the new firmware.
[0095] In a possible implementation manner, according to the identifier corresponding to each target upgraded firmware sub-block, the identifier corresponding to each source firmware sub-block, the target block size, and the first target operation step size, decompose each piece of first control information to obtain the diff command corresponding to each target upgraded firmware sub-block, so as to form a diff command linked list;
[0096] According to the identifier corresponding to each target upgraded firmware sub-block, the target block size, and the second target operation step size, decompose each piece of second control information to obtain the extra command corresponding to each target upgraded firmware sub-block, so as to form an extra command linked list.
[0097] In a possible implementation manner, according to the current operable byte count of the first control information, the remaining bytes in the currently operated source firmware sub-block, and the remaining bytes in the currently operated target upgraded firmware sub-block, determine the current first decomposition step size corresponding to the first control information;
[0098] According to the current first decomposition step size corresponding to the first control information, decompose the first control information to obtain a first decomposition result, and record the identifier of the source firmware sub-block corresponding to each decomposition operation in the decomposition process of the first control information, the identifier of the target upgraded firmware sub-block corresponding thereto, the current first position offset pointer in the source firmware, the current second position offset pointer in the target upgraded firmware, and the current third position offset pointer in the differential information of the full differential information;
[0099] Determine the diff command corresponding to each target upgraded firmware sub-block according to the first decomposition result, the first position offset pointer, the identifier of the corresponding source firmware sub-block, the identifier of the corresponding target upgraded firmware sub-block, the first position offset pointer, the second position offset pointer, and the third position offset pointer.
[0100] Furthermore, the current operable byte count of the first control information may be the remaining operable bytes of the first control information; the remaining bytes in the currently operated source firmware sub-block may be the remaining length from the current operation position (old_from) in the source firmware sub-block to the lower boundary (old_blk_upper_bound) of the sub-block, specifically as Figure 4 shown; the remaining bytes in the currently operated target upgraded firmware sub-block may be the remaining length from the current operation position (new_from) in the target upgraded firmware sub-block to the lower boundary (new_blk_upper_bound) of the sub-block, specifically as Figure 5As shown. The selection principle of the current first decomposition step size can be to select the minimum value among the three variables: the current operable byte count of the first control information, the remaining bytes in the source firmware sub-block of the current operation, and the remaining bytes in the target upgrade firmware sub-block of the current operation as the current first decomposition step size.
[0101] Furthermore, when decomposing the first control information, the current operation length of the first control information can be subtracted by the current first decomposition step size, and the decomposition step size of each step can be recorded until the current operation length of the first control information is 0, then the decomposition of the first control information is completed. If the first control information is not completely decomposed, but the remaining bytes of the target upgrade firmware sub-block and / or the source firmware sub-block of the current operation are 0, then it is necessary to shift to the next sub-block for decomposition operation. During the decomposition process, it is also necessary to record the identifier (new_blk_idx) of the target upgrade firmware sub-block, the identifier (old_blk_idx) of the source firmware sub-block, the offset position old_from (the first position offset pointer) in the source firmware, the offset position new_from (the second position offset pointer) in the target upgrade firmware, and the offset position diff_from (the third position offset pointer) in the patch file (full differential information) involved in each decomposition operation.
[0102] Furthermore, in the embodiments of the present application, when determining the diff command, it involves the process of command reconstruction. When the type of the control command included in the control information corresponding to the first decomposition result is used for command reconstruction; the actions with the command type of DIFF generated by decomposing X (the first control information) are subdivided into two command types: copy and diff. The subdivision principle is: if the data involved in the differential information corresponding to the first decomposition result (with a length of step and an offset address of the offset of the differential block in the "command details") is all 0, that is, the differential information with a length of step in this paragraph is all 0, which is equivalent to not requiring differential and only depending on the old firmware. At this time, this command is defined as a copy command; if the data involved in the differential information is not all 0, that is, the decomposed control information is related to both the differential information and the source firmware, this command is defined as a diff command. Define a = 0 as the copy command, a = 1 as the 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, to obtain (a, b, c) corresponding to the diff command. When a = 0, the meaning of (a, b, c) is to locate to the c position of the source firmware and copy b bytes from the source firmware; when a = 1, the meaning of (a, b, c) is to locate to the c position of the source firmware and add the b bytes copied from the source firmware to the b bytes in the differential information.
[0103] In a possible implementation manner, according to the current operable number of bytes of the second control information and the remaining number of bytes in the target upgrade firmware sub-block of the current operation, determine the current second decomposition step length corresponding to the second control information;
[0104] Decompose the second control information according to the current second decomposition step length corresponding to the second control information to obtain a second decomposition result, and record the identifier of the target upgrade firmware sub-block corresponding to each decomposition operation in the decomposition process of the second control information, the current fourth position offset pointer in the target upgrade firmware, and the current fifth position offset pointer in the unique information of the full-difference information;
[0105] Determine the extra command corresponding to each target upgrade firmware sub-block according to the second decomposition result, the fourth position offset pointer, the fifth position offset pointer, and the identifier of the target upgrade firmware sub-block.
[0106] Furthermore, in the embodiment of the present application, the meaning of Y (the second control information) is to read Y bytes of data from the unique information and add it to the current operation position as the content of the target upgrade firmware. Therefore, the decomposition of the second control information does not involve the source firmware. Therefore, only the current operable number of bytes of the second control information and the remaining number of bytes in the target upgrade firmware sub-block of the current operation are required to determine the current second decomposition step length. The selection principle of the current second decomposition step length corresponding to the second control information is: use the smaller value of the current operable number of bytes of the second control information and the remaining number of bytes in the target upgrade firmware sub-block of the current operation as the current second decomposition step length corresponding to the second control information.
[0107] Furthermore, decompose the second control information according to the current second decomposition step length corresponding to the second control information, and record the position offset new_from (the fourth position offset pointer) processed in the target upgrade firmware and the position offset extra_from (the fifth position offset pointer) of the exclusive sub-block for each decomposition operation. After processing one step length each time, record the identifier of the corresponding target upgrade firmware sub-block.
[0108] Furthermore, in the embodiment of the present application, the operation type of the control command corresponding to the second decomposition result can be defined as an EXTRA action, define a = 2 as the extra command, and use b to identify the operation step length step of the control information corresponding to the second decomposition result, to obtain (a, b, c) corresponding to the extra command, where c = 0 because the extra command has nothing to do with the old firmware. When a = 2, the meaning of (a, b, c) is to copy b bytes from the corresponding unique information.
[0109] S304. Traverse the diff commands in the command list to obtain the identifiers of the source firmware sub-blocks on which each target upgraded firmware sub-block depends.
[0110] Further, assume that the number of source firmware sub-blocks is M, and the number of target upgraded firmware sub-blocks is N. To establish the dependency relationship between the old and new block numbers, define a linked list array to save the dependency relationship, that is, define the linked list array of the old block numbers as: list_old_blk[M], with a total of M elements. Traverse the diff commands corresponding to the target upgraded firmware sub-blocks, extract the identifiers of the source firmware sub-blocks used in the diff commands, and add this block number to the array of list_old_blk[M]. Exemplarily, if the diff command uses the identifiers of the two sub-blocks p and q, add p to the linked list of list_old_blk[p] and add q to the linked list of list_old_blk[q]. After all the diff commands are traversed, in this way, a list of the identifiers of the target upgraded firmware sub-blocks that depend on this old block number is established with the identifier of the source firmware sub-block as the index.
[0111] S305. According to the identifiers of the source firmware sub-blocks on which each target upgraded firmware sub-block depends, obtain the dependency relationship between each target upgraded firmware sub-block and each source firmware sub-block.
[0112] Exemplarily, assume that when restoring the target upgraded firmware sub-blocks 10, 7, and 6, they all need to obtain corresponding information from the source firmware sub-block 0. Then the target upgraded firmware sub-blocks 10, 7, and 6 correspond to the source firmware sub-block 0 and generate a dependency relationship.
[0113] Perform a topological sort on the identifiers of the target upgraded firmware sub-blocks and the identifiers of the source firmware sub-blocks according to the correspondence relationship between the identifiers of the target upgraded firmware sub-blocks and the identifiers of the source firmware sub-blocks. Exemplarily, for example, when the correspondence relationship between the identifiers of the target upgraded firmware sub-blocks and the identifiers of the source firmware sub-blocks includes:
[0114] old blk idx (identifier of the target firmware sub-block): 0 corresponds to new blk idx (identifier of the target firmware sub-block): 10, new blk idx: 7, and new blk idx: 6;
[0115] old blk idx: 2 corresponds to new blk idx: 11 and new blk idx: 10;
[0116] old blk idx: 2 corresponds to new blk idx: 11 and new blk idx: 10;
[0117] The old block index: 3 corresponds to the new block index: 10;
[0118] The old block index: 4 corresponds to the new block indices: 10, 8, and 5;
[0119] The old block index: 5 corresponds to the new block index: 10;
[0120] The old block index: 6 corresponds to the new block indices: 10, 9, and 8;
[0121] The old block index: 7 corresponds to the new block indices: 11, 10, 9, 8, 6, and 3.
[0122] S306. According to this dependency relationship, establish a directed graph of the dependency relationship between the target upgraded firmware sub-block and the source firmware sub-block.
[0123] In a possible implementation manner, add this dependency relationship to a variable with a graph data structure to form a directed graph of the dependency relationship between the target upgraded firmware sub-block and the source firmware sub-block.
[0124] Please refer to Figure 6 the directed graph of the dependency relationship between the target upgraded firmware sub-block and the source firmware sub-block shown. The vertices represent the identifiers of the new firmware sub-blocks and the source firmware sub-blocks, and the edge set represents the corresponding relationship between the new firmware and the source firmware. The tail of the edge is the identifier of the new firmware sub-block, and the head is the identifier of the source firmware sub-block, which is used to identify the corresponding relationship between the new firmware sub-block and the source firmware sub-block. The restoration order of the target upgraded firmware sub-block can be converted into a topological sorting of this graph. There may be multiple result sequences for the topological sorting, and any one of the result sequences can be used as the firmware restoration order. In this way, the problem of the new firmware restoration order is solved, and the problem of in-place overwriting on the source firmware without using additional space is also solved.
[0125] According to the topological sorting result, determine the upgrade order of each target upgraded firmware sub-block. Exemplarily, in the embodiments of this application, for the situation where there are both cycles and acyclic intervals, the acyclic interval blocks are processed preferentially, and finally only the case with cycles remains. According to the Figure 6 directed graph of the dependency relationship shown, it can be seen that the sub-block No. 1 in the graph is not dependent on any other sub-blocks, but the sub-blocks No. 2, 3, and 4 form a cycle.
[0126] The restoration order can be carried out in the following way:
[0127] Sub-block 1 is not dependent on other sub-blocks. After restoring sub-block 1 on the flash memory, the content of sub-block 1 can be directly erased.
[0128] For sub-block 2: There are three ways to perform open-loop processing:
[0129] If open-loop method A: Open the edge between 2 and 4, the processing is as follows:
[0130] Sub-block 2 itself depends on sub-block 3, so the content of sub-block 3 can be used to restore sub-block 2. However, sub-block 2 itself is also dependent on sub-block 4, that is, when restoring sub-block 4, the content of sub-block 2 is still needed. If sub-block 2 is directly erased after restoration, it will cause sub-block 4 to not be restored properly, and this method cannot complete the upgrade of the entire firmware; if the content of sub-block 2 is saved in additional space before erasing it after restoration, then when restoring sub-block 4, the content of sub-block 4 can be restored normally. The final processing order is: 1--2--3--4, and the content of sub-block 2 needs to be saved additionally.
[0131] If open-loop method B: Open the edge between 2 and 3, the processing is as follows:
[0132] After opening the loop, the content of sub-block 3 is no longer dependent. Sub-block 3 can be restored and erased depending on the content of sub-block 4. Then sub-block 4 is not dependent on other blocks, and it can be restored and erased after depending on sub-block 2; after sub-block 4 is processed, for sub-block 2, it only depends on sub-block 3, so only when restoring sub-block 3, save sub-block 3 to additional space, and the content of sub-block 2 can be restored normally. The final processing order is: 1-3-4-2, and sub-block 3 needs to be saved additionally.
[0133] If open-loop method C: Open the edge between 3 and 4, the processing logic principle is the same as above. The final restoration order is: 1-4-2-3, and the content of sub-block 4 needs to be saved additionally.
[0134] Therefore, for the open-loop processing of a single loop with a dependency relationship of Figure 6 There are three ways, and the results all require additional space to save one sub-block.
[0135] In this embodiment, the core algorithm of the open-loop processing is described as follows:
[0136] Assume that the update interval is divided into N sub-blocks. In the case of extreme caching, there are input-output dependencies between the sub-blocks of all intervals, forming a large loop, and all sub-blocks are on the loop. There are a total of N*(N - 1) / 2 connections between them, and on average each sub-block has (N - 1) / 2 connections. When untying this loop, the principle adopted is to preferentially process the sub-block with the least in-degree, and the number of sub-blocks it affects is equal to the number of sub-blocks that need to be cached (as Figure 6 shown, the sub-block with the least in-degree is sub-block 1, which only affects the restoration of sub-block 2. Therefore, Figure 6 all three ways of opening the loop need to additionally save the content of 1 sub-block). For the case where the in-degrees are the same, preferentially process the block with the most out-degree. In the extreme case, the average in-degree of each sub-block is (N - 1) / 2 connections, and the limit number of blocks that need to be cached is (N - 1) / 2. For a system with M loops, in the extreme case, each loop has sub-blocks of N / M intervals, and the limit number of sub-blocks that need to be cached is (N - 1) / 2 / M.
[0137] S307. Perform open-loop processing on the dependency graph to obtain the restoration topological sorting of each sub-block in the dependency graph.
[0138] In a possible implementation manner, determine the sub-block with the least in-degree in the dependency graph as the first sub-block in the restoration topological sorting, so as to preferentially perform restoration processing and erasure processing on this first sub-block;
[0139] Perform open-loop processing on the other sub-blocks in the dependency graph except this first sub-block, and determine the target sub-block that is still depended on by other sub-blocks after restoration; this target sub-block needs to be saved to an additional space during restoration processing;
[0140] Obtain the restoration topological sorting of each sub-block in the dependency graph according to this first sub-block, this target sub-block, and the open-loop processing result.
[0141] Further, in the embodiments of the present application, when subsequently restoring the target upgrade firmware through the differential information corresponding to each target upgrade firmware sub-block (the differential information can be determined based on the diff command and the extra command), it can be overwritten on the source firmware, effectively reducing the requirement for Flash memory space during the firmware upgrade process. However, when executing the corresponding control information to restore the target upgrade firmware, it is necessary to rely on the information in the source firmware. Therefore, it is necessary to determine the restoration order of each target upgrade firmware sub-block in order to perform the overwrite on the source firmware and achieve the restoration operation of the target upgrade firmware. The diff command contains the operation commands for restoring each target upgrade firmware sub-block. The information of the source firmware on which each target upgrade firmware sub-block depends can be determined according to the diff command, and then the source firmware sub-blocks on which each target upgrade firmware sub-block depends can be determined; according to the source firmware sub-blocks on which each target upgrade firmware sub-block depends, the restoration order of each target upgrade firmware sub-block is determined. The restoration order can be determined manually or by some preset sorting algorithms.
[0142] As Figure 6 shown, the dependency directed graph is composed of edges and vertices. Among them,
[0143] The data structure of the graph is defined as follows:
[0144]
[0145]
[0146]
[0147] S308. According to the restoration topological sorting result, sequentially execute the diff command and the extra command to perform an in-place overwrite upgrade on the source firmware.
[0148] In a possible implementation manner, the firmware restoration order has been converted to a topological sorting of the dependency directed graph. After topological sorting, the dependency directed graph is converted into a dependency sequence, and this sequence can ensure that there will be no restored dependencies when executed in order. There may be multiple result sequences for topological sorting (such as Figure 6 the three open-loop results), and any one of the result sequences can be used as the firmware restoration order. In this way, the problem of the new firmware restoration order is solved, and the problem of in-place overwrite on the source firmware without using additional space is also solved, so that no additional space is required.
[0149] In summary, first extract the full-difference information between the source firmware of the firmware to be upgraded and the target upgrade firmware, and according to the target block size, divide the target upgrade firmware into multiple target upgrade firmware sub-blocks, and divide the source firmware into multiple source firmware sub-blocks; then according to the identifier corresponding to each target upgrade firmware sub-block, the identifier corresponding to each source firmware sub-block, the target block size, and the target operation step, decompose the full-difference information to create a command list for the target upgrade firmware; then according to the command list, establish a directed graph of the dependency relationship between the target upgrade firmware sub-blocks and the source firmware sub-blocks, and perform an open-loop process on the directed graph of the dependency relationship to obtain the restored topological sorting of each sub-block in the directed graph of the dependency relationship; finally, according to the restored topological sorting result, execute the diff command and the extra command in sequence to perform an in-place overwrite upgrade on the source firmware. During the upgrade process on the device side of the above solution, the in-place restoration and overwrite of the source firmware can be completed according to the restored order after the restored topological sorting, ensuring that the upgrade is performed with the least amount of additional space.
[0150] Figure 7 It is a structural block diagram of an online differential upgrade implementation device shown according to an exemplary embodiment. The device includes:
[0151] A full-difference information acquisition module 701, configured to extract the full-difference information between the source firmware of the firmware to be upgraded and the target upgrade firmware;
[0152] A firmware segmentation module 702, configured to divide the target upgrade firmware into multiple target upgrade firmware sub-blocks according to the target block size, and divide the source firmware into multiple source firmware sub-blocks; each target upgrade firmware sub-block and each source firmware sub-block includes a corresponding identifier;
[0153] A command list creation module 703, configured to decompose the full-difference information according to the identifier corresponding to each target upgrade firmware sub-block, the identifier corresponding to each source firmware sub-block, the target block size, and the target operation step to create a command list for the target upgrade firmware; the command list includes the diff command and the extra command corresponding to each target upgrade firmware sub-block; the diff command represents the operation information in the source firmware sub-block on which each target upgrade firmware sub-block depends; the extra command represents the unique operation information in each target upgrade firmware sub-block;
[0154] A directed graph of dependency relationship acquisition module 704, configured to establish a directed graph of the dependency relationship between the target upgrade firmware sub-blocks and the source firmware sub-blocks according to the command list;
[0155] The reduction topological sorting acquisition module 705 is configured to perform an open-loop process on the directed graph of dependencies to obtain the reduction topological sorting of each sub-block in the directed graph of dependencies;
[0156] The source firmware upgrade module 706 is configured to sequentially execute the diff command and the extra command according to the reduction topological sorting result to perform an in-place overwrite upgrade on the source firmware.
[0157] In a possible implementation manner, the device is further configured to:
[0158] Obtain the memory size of the target processor on the device side and the minimum erasure unit of the target flash memory on the device side;
[0159] Determine the target block size according to the memory size of the target processor and the minimum erasure unit of the target flash memory.
[0160] In a possible implementation manner, the full differential information includes control information, differential information, and unique information of the target upgrade firmware.
[0161] In a possible implementation manner, the device is further configured to:
[0162] Obtain a plurality of control triple commands in the control information, each control triple command including first control information and second control information, where the first control information represents the sum of the information of the first target byte amounts read from within the differential information and within the source firmware respectively; the second control information represents the unique information of the second target byte amount read from the unique information of the target upgrade firmware.
[0163] In a possible implementation manner, the command list creation module 703 includes:
[0164] The diff command linked list acquisition unit is configured to decompose each piece of first control information according to the identifier corresponding to each target upgrade firmware sub-block, the identifier corresponding to each source firmware sub-block, the target block size, and the first target operation step length to obtain the diff command corresponding to each target upgrade firmware sub-block, so as to form a diff command linked list;
[0165] The extra command linked list acquisition unit is configured to decompose each piece of second control information according to the identifier corresponding to each target upgrade firmware sub-block, the target block size, and the second target operation step length to obtain the extra command corresponding to each target upgrade firmware sub-block, so as to form an extra command linked list.
[0166] In a possible implementation, the diff command linked list obtaining unit is further configured to:
[0167] Determine a current first decomposition step corresponding to the first control information according to the current number of operable bytes of the first control information, the remaining bytes in the source firmware sub-block of the current operation, and the remaining bytes in the target upgrade firmware sub-block of the current operation;
[0168] Decompose the first control information according to the current first decomposition step corresponding to the first control information to obtain a first decomposition result, and record the identifier of the source firmware sub-block corresponding to each decomposition operation, the identifier of the corresponding target upgrade firmware sub-block, the current first position offset pointer in the source firmware, the current second position offset pointer in the target upgrade firmware, and the current third position offset pointer in the differential information of the full differential information during the decomposition process of the first control information;
[0169] Determine the diff command corresponding to each target upgrade firmware sub-block according to the first decomposition result, the first position offset pointer, the identifier of the corresponding source firmware sub-block, the identifier of the corresponding target upgrade firmware sub-block, the first position offset pointer, the second position offset pointer, and the third position offset pointer.
[0170] In a possible implementation, the extra command linked list obtaining unit is further configured to:
[0171] Determine a current second decomposition step corresponding to the second control information according to the current number of operable bytes of the second control information and the remaining bytes in the target upgrade firmware sub-block of the current operation;
[0172] Decompose the second control information according to the current second decomposition step corresponding to the second control information to obtain a second decomposition result, and record the identifier of the target upgrade firmware sub-block corresponding to each decomposition operation, the current fourth position offset pointer in the target upgrade firmware, and the current fifth position offset pointer in the unique information of the full differential information during the decomposition process of the second control information;
[0173] Determine the extra command corresponding to each target upgrade firmware sub-block according to the second decomposition result, the fourth position offset pointer, the fifth position offset pointer, and the identifier of the target upgrade firmware sub-block.
[0174] In a possible implementation, the dependency directed graph obtaining module 704 further includes:
[0175] The traversing diff command unit is used to traverse the diff commands in the command list to obtain the identifiers of the source firmware sub-blocks on which each target upgraded firmware sub-block depends;
[0176] The dependency relationship obtaining unit is used to obtain the dependency relationships between each target upgraded firmware sub-block and each source firmware sub-block according to the identifiers of the source firmware sub-blocks on which each target upgraded firmware sub-block depends;
[0177] The dependency relationship directed graph obtaining unit is used to establish a dependency relationship directed graph between the target upgraded firmware sub-blocks and the source firmware sub-blocks according to the dependency relationships.
[0178] In a possible implementation manner, the dependency relationship directed graph obtaining unit is further used for:
[0179] Adding the dependency relationships to a variable with a graph data structure to form a dependency relationship directed graph between the target upgraded firmware sub-blocks and the source firmware sub-blocks.
[0180] In a possible implementation manner, the restore topological sorting obtaining module 705 is further used for:
[0181] Determining the sub-block with the least in-degree in the dependency relationship directed graph as the first sub-block of the restore topological sorting, so as to perform priority restoration processing and erasure processing on the first sub-block;
[0182] Performing an open-loop process on other sub-blocks in the dependency relationship directed graph except the first sub-block, and determining target sub-blocks that are still depended on by other sub-blocks after the restoration is completed; the target sub-blocks need to be saved in an additional space during the restoration process;
[0183] Obtaining the restore topological sorting of each sub-block in the dependency relationship directed graph according to the first sub-block, the target sub-blocks, and the open-loop process result.
[0184] In summary, first extract the full-difference information between the source firmware of the firmware to be upgraded and the target upgraded firmware, and according to the target block size, split the target upgraded firmware into multiple target upgraded firmware sub-blocks, and split the source firmware into multiple source firmware sub-blocks; then decompose the full-difference information according to the identifier corresponding to each target upgraded firmware sub-block, the identifier corresponding to each source firmware sub-block, the target block size, and the target operation step size to create a command list for the target upgraded firmware; then, according to the command list, establish a directed graph of the dependency relationship between the target upgraded firmware sub-blocks and the source firmware sub-blocks, and perform an open-loop process on the directed graph of the dependency relationship to obtain the restored topological sorting of each sub-block in the directed graph of the dependency relationship; finally, according to the restored topological sorting result, sequentially execute the diff command and the extra command to perform an in-place overwrite upgrade on the source firmware. During the upgrade process on the device side of the above solution, the in-place restoration and overwrite of the source firmware can be completed according to the restored order after the restored topological sorting, ensuring that the upgrade is performed with the least amount of additional space.
[0185] Please refer to Figure 8 , which is a structural block diagram of a computer device provided according to an exemplary embodiment of the present application. The computer device includes a memory and a processor. The memory is used to store a computer program. When the computer program is executed by the processor, the above-described method for realizing online differential upgrade is implemented.
[0186] Among them, the processor may be a central processing unit (CPU). The processor 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, etc. chips, or combinations of the above types of chips.
[0187] As a non-transitory computer-readable storage medium, the memory can be used to store non-transitory software programs, non-transitory computer-executable programs, and modules, such as program instructions / modules corresponding to the methods in the embodiments of the present application. By running the non-transitory software programs, instructions, and modules stored in the memory, the processor can execute various functional applications and data processing of the processor, that is, implement the methods in the above method embodiments.
[0188] The memory may include a program storage area and a data storage area. The program storage area may store an operating system and application programs required for at least one function. The data storage area may store data created by the processor and the like. In addition, the memory may include a high-speed random access memory and may also include a non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state storage devices. In some embodiments, the memory may optionally include a memory remotely located relative to the processor, and these remote memories may be connected to the processor through a network. Examples of the above network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0189] In an exemplary embodiment, there is also provided a computer-readable storage medium for storing at least one computer program, and the at least one computer program is loaded and executed by a processor to implement all or part of the steps in the above method. For example, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, a floppy disk, and an optical data storage device, etc.
[0190] Those skilled in the art will readily conceive of other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any variations, uses, or adaptations of the present application, which follow the general principles of the present application and include known common knowledge or conventional technical means in the technical field not disclosed in the present application. The specification and embodiments are only regarded as exemplary, and the true scope and spirit of the present application are pointed out by the following claims.
[0191] It should be understood that the present application is not limited to the exact structures already described and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present application is only limited by the appended claims.
Claims
1. An online differential upgrade implementation method, characterized in that, The method includes: Extracting the full - volume differential information between the source firmware of the firmware to be upgraded and the target upgrade firmware; According to the target block size, splitting the target upgrade firmware into multiple target upgrade firmware sub - blocks, and splitting the source firmware into multiple source firmware sub - blocks; each target upgrade firmware sub - block and each source firmware sub - block includes a corresponding identifier; According to the identifier corresponding to each target upgrade firmware sub - block, the identifier corresponding to each source firmware sub - block, the target block size, and the target operation step, decomposing the full - volume differential information to create a command list for the target upgrade firmware; the command list includes the diff command and the extra command corresponding to each target upgrade firmware sub - block; the diff command represents the operation information within the source firmware sub - block on which each target upgrade firmware sub - block depends; the extra command represents the unique operation information within each target upgrade firmware sub - block; According to the command list, establishing a directed graph of the dependency relationship between the target upgrade firmware sub - blocks and the source firmware sub - blocks; Performing an open - loop process on the directed graph of the dependency relationship to obtain the restored topological sorting of each sub - block in the directed graph of the dependency relationship; According to the result of the restored topological sorting, sequentially executing the diff command and the extra command to perform an in - place overwrite upgrade on the source firmware.
2. The method according to claim 1, wherein Before splitting the target upgrade firmware into multiple target upgrade firmware sub - blocks and splitting the source firmware into multiple source firmware sub - blocks according to the target block size, the method further includes: Obtaining the memory size of the target processor on the device side and the minimum erasure unit of the target flash memory on the device side; Determining the target block size according to the memory size of the target processor and the minimum erasure unit of the target flash memory.
3. The method according to claim 1, characterized in that, The full - volume differential information includes control information, differential information, and unique information of the target upgrade firmware.
4. The method according to claim 3, wherein Before decomposing the full - volume differential information according to the identifier corresponding to each target upgrade firmware sub - block, the identifier corresponding to each source firmware sub - block, the target block size, and the target operation step to create a command list for the target upgrade firmware, the method further includes: Obtaining multiple control triple commands in the control information, each control triple command including first control information and second control information, where the first control information represents the sum of the information of the first target byte amount read from within the differential information and from within the source firmware respectively; the second control information represents the unique information of the second target byte amount read from the unique information of the target upgrade firmware.
5. The method according to claim 4, wherein Decomposing the full - volume differential information according to the identifier corresponding to each target upgrade firmware sub - block, the identifier corresponding to each source firmware sub - block, the target block size, and the target operation step to create a command list for the target upgrade firmware, includes: Decompose each first control information according to the identifier corresponding to each target upgrade firmware sub-block, the identifier corresponding to each source firmware sub-block, the target block size, and the first target operation step length, and obtain the diff command corresponding to each target upgrade firmware sub-block to form a diff command linked list; Decompose each second control information according to the identifier corresponding to each target upgrade firmware sub-block, the target block size, and the second target operation step length, and obtain the extra command corresponding to each target upgrade firmware sub-block to form an extra command linked list.
6. The method according to claim 5, wherein The step of decomposing each first control information according to the identifier corresponding to each target upgrade firmware sub-block, the identifier corresponding to each source firmware sub-block, the target block size, and the first target operation step length, and obtaining the diff command corresponding to each target upgrade firmware sub-block to form a diff command linked list includes: Determine the current first decomposition step length corresponding to the first control information according to the current operable byte count of the first control information, the remaining bytes in the currently operated source firmware sub-block, and the remaining bytes in the currently operated target upgrade firmware sub-block; Decompose the first control information according to the current first decomposition step length corresponding to the first control information to obtain a first decomposition result, and record the identifier of the source firmware sub-block corresponding to each decomposition operation in the decomposition process of the first control information, the identifier of the target upgrade firmware sub-block corresponding thereto, the current first position offset pointer in the source firmware, the current second position offset pointer in the target upgrade firmware, and the current third position offset pointer in the differential information of the full differential information; Determine the diff command corresponding to each target upgrade firmware sub-block according to the first decomposition result, the identifier of the corresponding source firmware sub-block, the identifier of the corresponding target upgrade firmware sub-block, the first position offset pointer, the second position offset pointer, and the third position offset pointer.
7. The method according to claim 5, wherein The step of decomposing each second control information according to the identifier corresponding to each target upgrade firmware sub-block, the target block size, and the second target operation step length, and obtaining the extra command corresponding to each target upgrade firmware sub-block to form an extra command linked list includes: Determine the current second decomposition step length corresponding to the second control information according to the current operable byte count of the second control information and the remaining bytes in the currently operated target upgrade firmware sub-block; Decompose the second control information according to the current second decomposition step length corresponding to the second control information to obtain a second decomposition result, and record the identifier of the target upgrade firmware sub-block corresponding to each decomposition operation in the decomposition process of the second control information, the current fourth position offset pointer in the target upgrade firmware, and the current fifth position offset pointer in the unique information of the full differential information; Determine the extra command corresponding to each target upgrade firmware sub-block according to the second decomposition result, the fourth position offset pointer, the fifth position offset pointer, and the identifier of the target upgrade firmware sub-block.
8. The method according to any one of claims 1 to 7, characterized in that Establishing a directed graph of dependencies between the target upgrade firmware sub-blocks and the source firmware sub-blocks according to the command list includes: Traverse the diff commands in the command list to obtain the identifiers of the source firmware sub-blocks on which each target upgrade firmware sub-block depends; According to the identifiers of the source firmware sub-blocks on which each target upgrade firmware sub-block depends, obtain the dependency relationships between each target upgrade firmware sub-block and each source firmware sub-block; Establish a directed graph of dependencies between the target upgrade firmware sub-blocks and the source firmware sub-blocks according to the dependency relationships.
9. The method according to claim 8, wherein Establishing a directed graph of dependencies between the target upgrade firmware sub-blocks and the source firmware sub-blocks according to the dependency relationships includes: Add the dependency relationships to a variable with a graph data structure to form a directed graph of dependencies between the target upgrade firmware sub-blocks and the source firmware sub-blocks.
10. The method according to claim 1, characterized in that Performing an open-loop process on the directed graph of dependencies to obtain the restored topological sorting of each sub-block in the directed graph of dependencies, including: Determine the sub-block with the least in-degree in the directed graph of dependencies as the first sub-block in the restored topological sorting, and perform priority restoration processing and erasure processing on the first sub-block; Perform an open-loop process on the other sub-blocks in the directed graph of dependencies except the first sub-block, and determine the target sub-blocks that are still depended on by other sub-blocks after restoration; the target sub-blocks need to be saved in an extra space during the restoration process; Obtain the restored topological sorting of each sub-block in the directed graph of dependencies according to the first sub-block, the target sub-blocks, and the open-loop process results.
Citation Information
Patent Citations
Differential upgrade package generation method, device and equipment
CN111258620A
Differential packet generation method, differential packet generation equipment and upgrading method
CN113721967A