Differential packet generation method, differential upgrade method, server and embedded terminal

By introducing differential direction and position offset into the embedded upgrade system, generating and adjusting differential packets, the problem of high resource consumption in embedded terminal upgrade is solved and the optimization of differential data packets is achieved.

CN114895951BActive Publication Date: 2025-09-09HANGZHOU TUYA INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210446420.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-26
Publication Date
2025-09-09
Estimated Expiration
2042-04-26

AI Technical Summary

Technical Problem

The existing full differential upgrade method consumes a lot of resources during the embedded terminal upgrade process, especially because the overall differential position offset caused by the addition and subtraction of new and old version firmware blocks leads to excessively large differential data packets.

Method used

By introducing differential direction and differential position offset in the embedded upgrade system, an initial differential packet is generated. When its length exceeds the storage requirement, the offset is iteratively adjusted to generate a target differential packet so that its length meets the storage requirement and resource consumption is reduced.

Benefits of technology

This effectively solves the overall differential position offset problem caused by the addition or removal of firmware blocks, and reduces the resource consumption of embedded terminal upgrades.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114895951B_ABST
    Figure CN114895951B_ABST
Patent Text Reader

Abstract

The present application relates to a differential packet generation method, a differential upgrade method, a server, and an embedded terminal, wherein the differential packet generation method comprises: when the length of a new version of firmware exceeds the length of an old version of firmware, performing firmware differential on the new version of firmware according to a preset differential direction and an initial differential position offset to obtain an initial differential packet; when the sum of the length of the initial differential packet and the length of the new version of firmware exceeds a preset storage requirement, determining whether the new version of firmware meets a minimum differential packet generation condition; when the new version of firmware meets the minimum differential packet generation condition, iteratively generating a target differential packet according to a preset offset value. By introducing a differential direction and a differential position offset in the differential packet generation process, the present application solves the problem of an excessively large differential data packet caused by an overall differential position offset caused by the addition or subtraction of firmware blocks in the new and old versions of firmware, thereby reducing the consumption of embedded terminal upgrade resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of embedded terminal upgrade, and in particular to a differential packet generation method, a differential upgrade method, a server and an embedded terminal. Background Art

[0002] In embedded terminal applications, product function updates, performance optimizations, and software problem repairs all require remote upgrades of the product software of the embedded terminal devices.

[0003] The current full differential upgrade method generates a differential file for the upgrade by performing a full differential between the old and new versions of the firmware. This method minimizes the differential file size, thus saving storage space, download bandwidth, and download time compared to other upgrade methods. However, this method requires the embedded terminal to use at least the size of the new firmware in its RAM to temporarily store the new firmware during the restore process, resulting in a high resource consumption on the embedded terminal.

[0004] With regard to the problem in related technologies that the upgrading method consumes a lot of resources when upgrading embedded terminals, no effective solution has been proposed yet. Summary of the Invention

[0005] In this embodiment, a differential packet generation method, a differential upgrade method, a server, and an embedded terminal are provided to solve the problem in the related art that the upgrade method consumes a lot of resources when upgrading the embedded terminal.

[0006] In a first aspect, a differential packet generation method is provided in this embodiment for use in a server of an embedded upgrade system. The method includes:

[0007] Performing firmware differentiation on the new version firmware of the embedded terminal of the embedded upgrade system according to a preset differentiation direction and an initial differentiation position offset to obtain an initial differentiation packet;

[0008] If the sum of the length of the initial differential packet and the length of the new version of the firmware exceeds a preset storage requirement, determining whether the new version of the firmware meets a minimum differential packet generation condition;

[0009] When the new version firmware meets the minimum differential package generation condition, a target differential package is iteratively generated according to a preset offset value, and the sum of the length of the target differential package and the length of the new version firmware meets the preset storage requirement.

[0010] In some embodiments, performing firmware differentiation on the new version firmware of the embedded terminal of the embedded upgrade system according to a preset differential direction and an initial differential position offset to obtain an initial differential packet includes:

[0011] Determining the firmware block size according to the hardware resource parameters of the embedded terminal;

[0012] Splitting the new version firmware based on the firmware block size to obtain at least two new version firmware blocks;

[0013] Each new version firmware block is differentiated from the old version firmware one by one according to the preset differential direction and the initial differential position offset to obtain the initial differential packet.

[0014] In some embodiments, determining whether the new version of the firmware meets the minimum differential packet generation condition includes:

[0015] Performing full differential analysis on the new version firmware and the old version firmware to obtain a full differential generation package;

[0016] It is determined whether the sum of the length of the full differential generation package and the length of the new version firmware meets the preset storage requirement. If so, it is determined that the new version firmware meets the minimum differential package generation condition.

[0017] In some embodiments, when the new version of the firmware meets the minimum differential packet generation condition, iteratively generating a target differential packet according to a preset offset value, where the sum of the length of the target differential packet and the length of the new version of the firmware meets the preset storage requirement, includes:

[0018] If the new version of the firmware meets the minimum differential package generation condition, updating the differential position offset according to a preset offset value, and performing firmware differencing on the new version of the firmware according to a preset differential direction and the updated differential position offset to obtain a differential package to be determined;

[0019] In the event that the sum of the length of the differential packet to be determined and the length of the new version of the firmware exceeds the preset storage requirement, the differential position offset is updated according to the preset offset value, and firmware differencing is performed on the new version of the firmware according to the preset differential direction and the updated differential position offset. Updating the differential position offset is stopped until the sum of the length of the differential packet to be determined and the length of the new version of the firmware meets the preset storage requirement, and the final differential packet to be determined is determined as the target differential packet.

[0020] In some embodiments, after updating the differential position offset according to the preset offset value, the method further includes:

[0021] It is determined whether the updated differential position offset exceeds a preset offset threshold. If so, the generation of the differential package for the new version of the firmware is terminated, and a differential failure prompt message is generated.

[0022] In some embodiments, performing firmware differential on the new version firmware of the embedded terminal of the embedded upgrade system according to a preset differential direction and an initial differential position offset to obtain an initial differential packet further includes:

[0023] When the length of the new version of the firmware exceeds the length of the old version of the firmware, performing firmware differentiation on the new version of the firmware according to the first differential direction and the initial differential position offset to obtain an initial differential packet;

[0024] When the length of the new version of the firmware does not exceed the length of the old version of the firmware, firmware differentiation is performed on the new version of the firmware according to a second differential direction and an initial differential position offset to obtain the initial differential packet; wherein the second differential direction is opposite to the first differential direction.

[0025] In some embodiments, when the sum of the length of the initial differential packet and the length of the new version of the firmware exceeds a preset storage requirement, and the new version of the firmware does not meet the minimum differential packet generation condition, the method further includes:

[0026] The generation of the differential package for the new version of the firmware is completed, and a differential failure prompt message is generated.

[0027] In a second aspect, a differential upgrade method is provided in this embodiment for an embedded terminal of an embedded upgrade system, the method comprising:

[0028] Obtaining a target differential packet generated by the server of the embedded upgrade system based on the differential packet generation method described in the first aspect;

[0029] According to the differential direction and differential position offset of the target differential packet, the old version of the firmware is upgraded using the target differential packet to obtain a new version of the firmware.

[0030] In some embodiments, the embedded terminal includes a first upgrade process information management area and a second upgrade process information management area, and upgrading the old version of firmware using the target differential package according to the differential direction and differential position offset of the target differential package to obtain the new version of firmware includes:

[0031] In the process of upgrading the old version firmware using the target differential package according to the differential direction and differential position offset of the target differential package, the upgrade process information generated by the upgrade process is alternately stored in the first upgrade process information management area and the second upgrade process information management area.

[0032] In a third aspect, a server is provided in this embodiment for an embedded upgrade system, comprising: an initialization module, a judgment module, and a difference generation module; wherein:

[0033] The initial module is configured to perform firmware differential on the new version firmware of the embedded terminal of the embedded upgrade system according to a preset differential direction and an initial differential position offset to obtain an initial differential packet;

[0034] The judgment module is configured to judge whether the new version of the firmware meets the minimum differential packet generation condition when the sum of the length of the initial differential packet and the length of the new version of the firmware exceeds the preset storage requirement;

[0035] The differential generation module is used to iteratively generate a target differential package according to a preset offset value when the new version of the firmware meets the minimum differential package generation condition, and the sum of the length of the target differential package and the length of the new version of the firmware meets the preset storage requirement.

[0036] In a fourth aspect, an embedded terminal is provided in this embodiment for use in an embedded upgrade system, comprising: an acquisition module and an upgrade module; wherein:

[0037] The acquisition module is configured to acquire a target differential packet generated by the server of the embedded upgrade system based on the differential packet generation method described in the first aspect;

[0038] The upgrade module is configured to upgrade the old version of the firmware using the target differential packet according to the differential direction and differential position offset of the target differential packet to obtain the new version of the firmware.

[0039] In a fifth aspect, an embedded upgrade system is provided in this embodiment, comprising: a server and an embedded terminal; wherein the server is communicatively connected to the embedded terminal;

[0040] The server is used to execute the differential packet generation method described in the first aspect;

[0041] The embedded terminal is used to execute the differential upgrade method described in the second aspect.

[0042] In the sixth aspect, an electronic device is provided in this embodiment, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the differential packet generation method described in the first aspect above when executing the computer program.

[0043] In a seventh aspect, a storage medium is provided in this embodiment, on which a computer program is stored. When the program is executed by a processor, the differential packet generation method described in the first aspect is implemented.

[0044] Compared with related technologies, the differential packet generation method, differential upgrade method, server, and embedded terminal provided in this embodiment perform firmware differential on the new version of the firmware according to a preset differential direction and initial differential position offset when the length of the new version of the embedded terminal in the embedded upgrade system exceeds the length of the old version of the firmware, thereby obtaining an initial differential packet; when the sum of the length of the initial differential packet and the length of the new version of the firmware exceeds the preset storage requirement, it is determined whether the new version of the firmware meets the minimum differential packet generation condition; when the new version of the firmware meets the minimum differential packet generation condition, it iteratively generates a target differential packet according to a preset offset value, and the sum of the length of the target differential packet and the length of the new version of the firmware meets the preset storage requirement. By introducing the differential direction and differential position offset in the differential packet generation process, the method solves the problem of excessively large differential data packets caused by the overall differential position offset caused by the addition or subtraction of firmware blocks between the new and old versions of the firmware, thereby reducing the consumption of embedded terminal upgrade resources.

[0045] The details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0047] Figure 1 This is a hardware structure diagram of a terminal of a differential packet generation method in related art;

[0048] Figure 2 is a flow chart of the differential packet generation method of this embodiment;

[0049] Figure 3 This is a schematic diagram of the firmware split into blocks in this embodiment;

[0050] Figure 4 Schematic diagram of the differential packet generation process of this embodiment;

[0051] Figure 5 is a flow chart of the differential packet generation method of this preferred embodiment;

[0052] Figure 6 is a flow chart of a differential upgrade method of this embodiment;

[0053] Figure 7 This is a schematic diagram of the differential storage area of ​​an embedded terminal according to this embodiment;

[0054] Figure 8 This is a structural block diagram of a server in this embodiment;

[0055] Figure 9 This is a structural block diagram of an embedded terminal according to the present embodiment;

[0056] Figure 10 This is a structural block diagram of an embedded upgrade system of this embodiment. DETAILED DESCRIPTION

[0057] In order to more clearly understand the purpose, technical solutions and advantages of the present application, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments.

[0058] Unless otherwise defined, the technical terms or scientific terms involved in this application should have the general meaning understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "an", "a", "the", "these" and the like in this application do not indicate quantitative restrictions, and they can be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "plurality" involved in this application refers to two or more. "And / or" describes the relationship between related objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A exists alone, A and B exist simultaneously, and B exists alone. Generally, the character " / " indicates that the related objects are in an "or" relationship. The terms "first," "second," "third," etc. used in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.

[0059] The method embodiment provided in this embodiment can be executed in a terminal, a computer or a similar computing device. For example, running on a terminal, Figure 1 FIG. 1 is a hardware structure diagram of a terminal of the differential packet generation method of this embodiment. Figure 1 As shown, the terminal may include one or more ( Figure 1Only one is shown) a processor 102 and a memory 104 for storing data, wherein the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA. The above terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It will be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above terminal. Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown.

[0060] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the differential packet generation method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implementing the above-mentioned method. The memory 104 may include a high-speed random access memory and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely located relative to the processor 102, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0061] The transmission device 106 is used to receive or send data via a network. The network may include a wireless network provided by the terminal's telecommunications provider. In one embodiment, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0062] In this embodiment, a differential packet generation method is provided. Figure 2 is a flow chart of the differential packet generation method of this embodiment, such as Figure 2 As shown, the process includes the following steps:

[0063] Step S210 , performing firmware differentiation on the new version firmware of the embedded terminal of the embedded upgrade system according to a preset differentiation direction and an initial differentiation position offset to obtain an initial differentiation packet.

[0064] Specifically, the preset differential direction can be a differential direction from back to front, or a differential direction from front to back. Among them, the firmware difference of the new version firmware is performed in the differential direction from back to front, and specifically, the new version firmware and the old version firmware are evenly divided into firmware blocks of preset sizes, respectively, to obtain a number of new version firmware blocks and old version firmware blocks. According to the arrangement order of the new version firmware blocks, each new version firmware block is differentiated from the old version firmware block in sequence from back to front, so as to obtain a differential packet. Similarly, it can be seen that the firmware difference of the new version firmware is performed in the differential direction from front to back, and each new version firmware block can be differentiated from the old version firmware block in the order from front to back to obtain a differential packet. The differential direction can be set according to the actual application scenario. Exemplarily, when the length of the new version of the firmware exceeds that of the old version of the firmware, in order to avoid the problem of the generated differential package being too large due to the new version of the firmware block being offset as a whole due to the new version of the firmware block being in a different position, and the corresponding code segment not being matched in the old version of the firmware block, the new version of the firmware can be firmware differentiated in a first differential direction from back to front. In addition, when the length of the new version of the firmware does not exceed the length of the old version of the firmware, the firmware can be differentiated in a second differential direction from front to back. The length of the new version of the firmware can specifically be the length of the bytes contained in the new version of the firmware, and the length of the old version of the firmware can specifically be the length of the bytes contained in the old version of the firmware. In addition, the differential position offset is the number of bytes that the differential block obtained by differentiating the new version of the firmware block obtained by splitting the new version of the firmware is offset backward in the firmware area compared to the old version of the firmware block. Exemplarily, the initial differential position offset can specifically be 0.

[0065] By introducing the settings of the differential direction and differential position offset during the differential process, the problem of overall firmware block differential position offset caused by the addition or removal of firmware blocks in the front part during the differential process between the new version of firmware and the old version can be solved. In addition, the size of the firmware blocks can also be dynamically divided according to the hardware storage resources of the embedded terminal. Larger blocks can shorten the calculation time, while smaller blocks can reduce resource consumption. Therefore, the block size can be reasonably set based on the hardware storage resources of the embedded terminal in the actual application scenario, and no specific restrictions are given here.

[0066] Step S220 : When the sum of the length of the initial differential packet and the length of the new version firmware exceeds the preset storage requirement, it is determined whether the new version firmware meets the minimum differential packet generation condition.

[0067] The preset storage requirement can be specifically set based on the actual application scenario. For example, in this embodiment, the storage requirement can be the maximum storage space allowed by the embedded terminal. If the sum of the length of the initial differential packet and the length of the new version of the firmware exceeds the preset storage requirement, the embedded terminal cannot perform a firmware upgrade based on the initial differential packet. Therefore, it is necessary to further determine whether the new version of the firmware meets the minimum differential packet generation condition. If so, it is possible to consider adjusting the differential position offset so that the sum of the length of the newly generated differential packet and the length of the new version of the firmware meets the storage requirement. Furthermore, the minimum differential packet generation condition can specifically be whether the sum of the length of the differential packet obtained by the current method for generating the minimum differential packet and the length of the new version of the firmware meets the preset storage requirement. For example, if a full differential packet is generated based on the full differential method, if the sum of the length of the full differential packet and the length of the new version of the firmware meets the preset storage requirement, it can be determined that the new version of the firmware meets the minimum differential packet generation condition.

[0068] Step S230, when the new version firmware meets the minimum differential packet generation condition, iteratively generate the target differential packet according to the preset offset value, and the sum of the length of the target differential packet and the length of the new version firmware meets the preset storage requirement.

[0069] When the new version of the firmware meets the minimum differential packet generation conditions, it indicates that the storage resources of the embedded terminal meet the conditions for upgrading the new version of the firmware. Therefore, the new version of the firmware block can be matched and differentiated with the old version of the firmware block by adjusting the differential position offset, thereby reducing the overall firmware block differential offset caused by the increase or decrease of the firmware block, thereby reducing the data packet size of the differential packet. The differential position offset can be updated based on a preset offset value, thereby achieving iterative generation of the differential packet. Exemplarily, the offset value can be the byte size of a sector of the embedded terminal. For example, if the bytes of the sector are 4096 bytes, then the offset value is 4096. Specifically, based on the original differential position offset, the offset value can be added to the differential position offset during the iterative process to obtain an updated differential position offset, and the new version of the firmware is re-differentiated according to the preset differential direction and the updated differential position offset to obtain a newly generated differential packet to be determined. It should be noted that the updated differential position offset cannot exceed the preset offset threshold. In addition, if the length of the differential package to be determined and the length of the new version of the firmware meet the preset storage requirements, the current differential package to be determined will be used as the target differential package; otherwise, the differential position offset will continue to be updated based on the preset offset value, and the new version of the firmware will be differentiated according to the preset differential direction and the updated differential position offset to obtain the differential package to be determined again. The iteration will be stopped until the length of the differential package to be determined and the length of the new version of the firmware meet the preset storage requirements, and the target differential package will be obtained.

[0070] Alternatively, if the new version of the firmware does not meet the minimum differential packet generation conditions, it indicates that the embedded terminal does not support differential upgrades for the new version of the firmware. Therefore, the differential generation process can be terminated directly and a prompt message generated. If, after updating the differential position offset based on a preset offset value, the updated differential position offset exceeds a preset offset threshold, the differential generation process can also be terminated directly and a prompt message indicating differential failure is generated, thereby preventing the differential calculation from exceeding the storage capacity of the embedded terminal's hardware chip. It is understood that the preset offset threshold can also be determined based on the storage capacity of the embedded terminal.

[0071] For example, Figure 3 This is a schematic diagram of the firmware of this embodiment being split into blocks, as shown in FIG. Figure 3 As shown in FIG, after determining the estimated block size, the new version firmware and the old version firmware are evenly divided into several firmware blocks according to the block size. Among them, the new version firmware deletes the firmware block CODE1 and inserts the firmware blocks CODE6 and CODE7 compared to the old version firmware. Figure 3 The length of the new version of the firmware is greater than that of the old version of the firmware, so the differential direction can be set to be from back to front in advance. Among them, first, the new version of the firmware is differentiated according to the differential direction from back to front and the differential position offset is 0 to obtain the initial differential package. Because the firmware block CODE4, firmware block CODE3, and firmware block CODE2 cannot find the corresponding code segments in the old version of the firmware under this differential method, the generated initial differential package is too large. Assuming that the length of the initial differential package and the length of the new version of the firmware package do not meet the preset storage requirements, the differential position offset needs to be updated. If during the update process, the differential position offset is obtained as 1 sector, that is, 4096 bytes are added, the differential package length obtained by firmware differential and the length of the new version of the firmware meet the preset storage requirements, then the differential package obtained by differential at this time can be used as the target differential package of the new version of the firmware. Among them, Figure 4 FIG. 1 is a schematic diagram of the differential packet generation process of this embodiment. Figure 4 As shown, it can be seen that after determining that the differential direction is from back to front and the differential position offset is 1 sector, the differential packet generation process includes the following steps:

[0072] Differencing the last firmware block CODE5 in the new version of the firmware with the old version of the firmware to obtain the differential package patch1, and placing the firmware block CODE5 in the new version of the firmware at a position offset by one sector from the end of the old version of the firmware;

[0073] Differentiate the firmware block CODE7 in the new version of the firmware from the old version of the firmware to obtain the differential package patch2, and place the firmware block CODE7 in the new version of the firmware before the firmware block CODE5 in the old version of the firmware;

[0074] Differentiate the firmware block CODE6 in the new version of the firmware from the old version of the firmware to obtain the differential package patch3, and place the firmware block CODE6 in the new version of the firmware before the firmware block CODE7 in the old version of the firmware;

[0075] According to the above process of generating differential package patch1, differential package patch2, and differential package patch3, differential package patch4, differential package patch5, differential package patch6, and differential package patch7 can be obtained respectively;

[0076] The differential packages patch 1 to 7 are combined to obtain the differential package patches of the old version firmware and the new version firmware. The differential package patches are then compressed and pre-determined upgrade header information is added to obtain the required differential package.

[0077] In the above steps S210 to S230, when the length of the new version firmware of the embedded terminal of the embedded upgrade system exceeds the length of the old version firmware, the new version firmware is subjected to firmware differentiation according to a preset differential direction and an initial differential position offset to obtain an initial differential packet; when the sum of the length of the initial differential packet and the length of the new version firmware exceeds the preset storage requirement, it is determined whether the new version firmware meets the minimum differential packet generation condition; when the new version firmware meets the minimum differential packet generation condition, a target differential packet is iteratively generated according to a preset offset value, and the sum of the length of the target differential packet and the length of the new version firmware meets the preset storage requirement. By introducing the differential direction and differential position offset in the differential packet generation process, the problem of the differential data packet being too large due to the overall differential position offset caused by the increase or decrease of firmware blocks in the new and old versions of the firmware is solved, thereby reducing the consumption of embedded terminal upgrade resources.

[0078] In one embodiment, based on the above step S210, firmware differentiation is performed on the new version of the firmware according to a preset differentiation direction and an initial differentiation position offset to obtain an initial differentiation packet, which specifically includes the following steps:

[0079] Step S211: Determine the size of the firmware blocks according to the hardware resource parameters of the embedded terminal.

[0080] Specifically, the hardware resource parameter can be storage space, download bandwidth, or other resource parameters. The firmware block size is set based on the hardware resource parameters of the embedded terminal, thereby minimizing the differential operation time as much as possible, provided that the hardware resource conditions support it. This allows for differential upgrades that balance hardware resource consumption and operation time, and improves the adaptability of different embedded terminal hardware resources to the differences between new and old firmware versions.

[0081] Step S212: split the new version firmware based on the firmware block size to obtain at least two new version firmware blocks.

[0082] Specifically, based on the firmware block size determined in step S211 , the new version firmware is evenly divided to obtain a number of new version firmware blocks having the same size as the firmware block size.

[0083] Step S213 : Differentiate each new version firmware block from the old version firmware one by one according to the preset differential direction and initial differential position offset to obtain an initial differential packet.

[0084] Based on the arrangement order of the new version firmware blocks, if the preset difference direction is from back to front, then each new version firmware block is differentiated from the old version firmware in the direction from the firmware block with the later arrangement to the firmware block with the earlier arrangement, so as to obtain the corresponding difference block, and integrate all the differences to obtain the initial difference package.

[0085] In addition, in one embodiment, based on the above step S220, determining whether the new version of the firmware meets the minimum difference package generation condition specifically includes the following steps:

[0086] Step S221 : perform full differential on the new version firmware and the old version firmware to obtain a full differential generation package.

[0087] Step S222: determine whether the sum of the length of the full differential package and the length of the new version of the firmware meets the preset storage requirement. If so, determine that the new version of the firmware meets the minimum differential package generation condition.

[0088] When the sum of the length of the initial differential packet and the length of the new version of the firmware exceeds the preset storage requirements, it is necessary to first determine whether the sum of the length of the minimum differential packet generated by the new version of the firmware and the length of the new version of the firmware meets the storage requirements. When the length of the minimum differential packet and the length of the new version of the firmware meet the storage requirements, continue to adjust the differential position offset of the differential packet of the new version of the firmware so that the differential packet obtained by firmware differentiation based on the differential direction and the adjusted differential position offset meets the storage requirements of the embedded terminal.

[0089] Additionally, in one embodiment, based on the above step S230, when the new version of the firmware meets the minimum differential packet generation condition, a target differential packet is iteratively generated according to a preset offset value, and the sum of the length of the target differential packet and the length of the new version of the firmware meets the preset storage requirement, specifically including the following steps:

[0090] Step S231: When the new version firmware meets the minimum differential package generation condition, the differential position offset is updated according to the preset offset value, and the new version firmware is firmware differentiated according to the preset differential direction and the updated differential position offset to obtain the differential package to be determined.

[0091] Step S232: When the sum of the length of the differential packet to be determined and the length of the new version of the firmware exceeds the preset storage requirement, the differential position offset is updated according to the preset offset value, and the new version of the firmware is subjected to firmware differentiation according to the preset differential direction and the updated differential position offset. When the sum of the length of the differential packet to be determined and the length of the new version of the firmware meets the preset storage requirement, the updating of the differential position offset is stopped, and the final differential packet to be determined is determined as the target differential packet.

[0092] By adjusting the differential position offset and performing firmware differentiation according to the preset differential direction and the updated differential position offset, corresponding matching differentiation of the new version firmware block and the old version firmware block can be achieved, thereby reducing the data volume of the generated differential packet.

[0093] Furthermore, in one embodiment, based on the above step S232, after updating the differential position offset according to the preset offset value, the above method also includes: determining whether the updated differential position offset exceeds the preset offset threshold; if so, ending the generation of the differential package for the new version of the firmware and generating a differential failure prompt message.

[0094] Specifically, an offset threshold can be pre-set based on the storage capacity of the embedded terminal. When the updated differential position offset exceeds the threshold, the differential packet generation process is directly terminated, thereby preventing the resources consumed by the differential upgrade operation from exceeding the storage capacity of the embedded terminal. Furthermore, the differential packet with a larger differential position offset will consume more memory resources and storage resources of the embedded terminal during the restoration process. Therefore, the offset threshold can be determined based on the minimum remaining memory and the minimum value of the remaining flash memory space of the embedded terminal. For example, the minimum value of the remaining minimum memory and the remaining flash memory space of the embedded terminal can be obtained, and the offset threshold can be obtained by rounding the two to the byte size of a sector.

[0095] Additionally, in one embodiment, based on the above step S210, performing firmware differentiation on the new version of the firmware according to a preset differential direction and an initial differential position offset to obtain an initial differential packet may further include the following steps:

[0096] Step S214: When the length of the new version of the firmware exceeds the length of the old version of the firmware, perform firmware differentiation on the new version of the firmware according to the first differential direction and the initial differential position offset to obtain an initial differential packet;

[0097] Step S215 , when the length of the new version firmware does not exceed the length of the old version firmware, perform firmware differentiation on the new version firmware according to the second differential direction and the initial differential position offset to obtain an initial differential packet; wherein the second differential direction is opposite to the first differential direction.

[0098] Additionally, in one embodiment, when the sum of the length of the initial differential packet and the length of the new version of the firmware exceeds the preset storage requirement, and the new version of the firmware does not meet the minimum differential packet generation condition, the above method may further include the following steps:

[0099] Step S250: End the generation of the differential package for the new version of the firmware and generate a differential failure prompt message.

[0100] The present embodiment is described and illustrated below through preferred embodiments.

[0101] Figure 5 This is a flow chart of the differential packet generation method of this preferred embodiment, as shown in FIG. Figure 5 As shown, the differential packet generation method includes the following steps:

[0102] Step S501, determining whether the length newlen of the new version of the firmware is greater than the length oldlen of the old version of the firmware, if so, executing step S502; otherwise, executing step S503;

[0103] Step S502: Set the differential direction mode to 1 and the differential position offset step to 0, and perform firmware differential on the new version of the firmware according to the mode and step parameters to obtain an initial differential packet; when mode = 1, the differential direction is from back to front;

[0104] Step S503: Set mode=0 and differential position offset step=0, and perform firmware differential on the new version of the firmware according to the mode parameter and the step parameter to obtain an initial differential packet; wherein, when mode=0, the differential direction is from front to back;

[0105] Step S504: determine whether the sum of newlen and the length of the initial differential packet plen1 is greater than the maximum value flen of the terminal storage space limit. If so, execute step S505; otherwise, execute step S511;

[0106] Step S505: Perform full differential analysis on the new version firmware and the old version firmware to obtain a full differential package.

[0107] Step S506: Determine whether the sum of the length of the full differential packet generated by plen2 and newlen is greater than flen. If so, execute step S507; otherwise, execute step S508;

[0108] Step S507: prompt that the difference generation fails and end the difference generation process;

[0109] Step S508: Set the step to add a sector of bytes, for example, 4096 bytes, and re-generate a differential package by firmware differential;

[0110] Step S509: If the updated step is greater than the preset offset threshold max_step, execute step S507; otherwise, execute step 510;

[0111] Step S510, determine whether the sum of newlen and the length of the regenerated differential packet plen3 is greater than flen, if so, return to step S508, otherwise execute step S511;

[0112] Step S511: prompt that the difference generation is successful, and end the difference generation process.

[0113] In this embodiment, a differential upgrade method is provided. Figure 6 This is a flow chart of a differential upgrade method of this embodiment, such as Figure 6 As shown, the process includes the following steps:

[0114] Step S610: obtaining a target differential packet generated by a server of the embedded upgrade system based on the differential packet generation method of any of the above embodiments;

[0115] Step S620 : According to the differential direction and differential position offset of the target differential packet, the target differential packet is used to upgrade the old version of the firmware to obtain a new version of the firmware.

[0116] Specifically, the embedded terminal can obtain the firmware blocks of the new version firmware in sequence based on the old version firmware and the target differential package, according to the differential direction and differential position offset of the target differential package, in the reverse order of the generation order of the differential blocks in the target differential package, and then combine them to obtain the complete new version firmware.

[0117] In the above steps S610 to S620, a target differential packet generated by the differential packet generation method based on any of the above embodiments is obtained, and based on the differential direction and differential position offset of the target differential packet, the target differential packet is used to upgrade the old version of the firmware, thereby reducing the consumption of embedded terminal upgrade resources due to excessive differential packet data.

[0118] Furthermore, in one embodiment, based on the above step S620, the embedded terminal includes a first upgrade process information management area and a second upgrade process information management area, and upgrades the old version of the firmware using the target differential packet according to the differential direction and differential position offset of the target differential packet to obtain the new version of the firmware, specifically including the following steps:

[0119] Step S621 , when upgrading the old version firmware using the target differential package according to the differential direction and differential position offset of the target differential package, the upgrade process information generated during the upgrade process is alternately stored in the first upgrade process information management area and the second upgrade process information management area.

[0120] For example, Figure 7 This is a schematic diagram of the differential storage area of ​​an embedded terminal provided in this embodiment. Figure 7 As shown, the differential storage area of ​​the embedded terminal can specifically include a boot area, a firmware area, a backup area, a differential package storage area, a first upgrade process information management area, a second upgrade process information management area, and a user area. The boot area is used for booting and upgrading the firmware area. The firmware area is used to store and execute application programs. The backup area is used as a firmware backup during the upgrade phase. The newly restored new version firmware blocks are stored in the backup area and copied to the firmware area after the restoration is complete. The differential package storage area is used to store differential package data downloaded from the cloud.

[0121] Furthermore, the first and second upgrade process information management areas are used to record all upgrade process information, including the real-time location of the new firmware restore, the number of the new firmware block, the restore progress of each new firmware block, and the file write location. By providing two alternate upgrade process information management areas for the embedded terminal, the upgrade process can be continued after an interruption, thus resolving upgrade failures caused by abnormal power outages during the upgrade process.

[0122] In this embodiment, a server 80 is also provided. Figure 8 is a structural block diagram of the server 80, such as Figure 8 As shown, the server 80 includes: an initial module 82, a judgment module 84, and a difference generation module 86; wherein:

[0123] The initial module 82 is used to perform firmware differential on the new version firmware of the embedded terminal of the embedded system according to a preset differential direction and an initial differential position offset to obtain an initial differential packet;

[0124] The judging module 84 is configured to judge whether the new version of the firmware meets the minimum differential packet generation condition when the sum of the length of the initial differential packet and the length of the new version of the firmware exceeds the preset storage requirement;

[0125] The differential generation module 86 is used to iteratively generate a target differential packet according to a preset offset value when the new version firmware meets the minimum differential packet generation condition, and the sum of the length of the target differential packet and the length of the new version firmware meets the preset storage requirement.

[0126] In this embodiment, an embedded terminal 90 is also provided. Figure 9 is a structural block diagram of the embedded terminal 90, such as Figure 9 As shown, the embedded terminal 90 includes: an acquisition module 92 and an upgrade module 94; wherein:

[0127] An acquisition module 92 is configured to acquire a target differential packet generated by a server of the embedded upgrade system based on the differential packet generation method of any of the above embodiments;

[0128] The upgrading module 94 is configured to upgrade the old version of the firmware using the target differential packet according to the differential direction and differential position offset of the target differential packet to obtain the new version of the firmware.

[0129] It should be noted that the above modules can be functional modules or program modules, and can be implemented through software or hardware. For modules implemented through hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.

[0130] In this embodiment, an embedded upgrade system 100 is also provided. Figure 10 is a structural block diagram of the embedded upgrade system 100, such as Figure 10 As shown, the embedded upgrade system 100 includes: a server 112 and an embedded terminal 114; wherein the server 112 is in communication connection with the embedded terminal 114;

[0131] The server 112 is configured to execute the differential packet generation method of any of the above embodiments;

[0132] The embedded terminal 114 is configured to execute the differential upgrade method of any of the above embodiments.

[0133] The above-mentioned embedded upgrade system 100 solves the problem of excessively large differential data packets caused by the overall differential position offset caused by the addition or removal of large firmware blocks in the new and old versions of firmware by introducing differential direction and differential position offset in the differential packet generation process, thereby reducing the consumption of embedded terminal upgrade resources.

[0134] This embodiment further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0135] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0136] Optionally, in this embodiment, the processor may be configured to execute the following steps through a computer program:

[0137] Performing firmware differentiation on the new version firmware of the embedded terminal of the embedded upgrade system according to a preset differential direction and an initial differential position offset to obtain an initial differential packet;

[0138] If the sum of the length of the initial differential packet and the length of the new version of the firmware exceeds the preset storage requirement, determining whether the new version of the firmware meets the minimum differential packet generation condition;

[0139] When the new version of the firmware meets the minimum differential packet generation condition, the target differential packet is iteratively generated according to the preset offset value, and the sum of the length of the target differential packet and the length of the new version of the firmware meets the preset storage requirement.

[0140] It should be noted that, for specific examples in this embodiment, reference may be made to the examples described in the above embodiments and optional implementation modes, and will not be repeated in this embodiment.

[0141] In addition, in conjunction with the differential packet generation method provided in the above embodiments, a storage medium may also be provided in this embodiment to implement the differential packet generation method. The storage medium stores a computer program; when the computer program is executed by a processor, any of the differential packet generation methods in the above embodiments is implemented.

[0142] It should be understood that the specific embodiments described herein are only used to explain this application and are not used to limit it. Based on the embodiments provided in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0143] Obviously, the accompanying drawings are merely examples or embodiments of the present application. A person skilled in the art can also apply the present application to other similar situations based on these drawings without inventive effort. Furthermore, it is understandable that, although the work involved in this development process may be complex and lengthy, certain design, manufacturing, or production changes based on the technical content disclosed in this application are merely routine technical means for a person skilled in the art and should not be considered to constitute a deficiency in the disclosure of the present application.

[0144] The term "embodiment" as used in this application refers to specific features, structures, or characteristics described in conjunction with the embodiment that can be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily mean that the embodiment is the same, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. It is understood, either explicitly or implicitly, by those skilled in the art that the embodiments described in this application can be combined with other embodiments when there is no conflict.

[0145] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of patent protection. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.

Claims

1. A differential packet generation method for a server of an embedded upgrade system, characterized in that: include: Performing firmware differentiation on the new version firmware of the embedded terminal of the embedded upgrade system according to a preset differentiation direction and an initial differentiation position offset to obtain an initial differentiation packet; If the sum of the length of the initial differential packet and the length of the new version of the firmware exceeds a preset storage requirement, determining whether the new version of the firmware meets a minimum differential packet generation condition; If the new version of the firmware meets the minimum differential packet generation condition, iteratively generating a target differential packet according to a preset offset value, where the sum of the length of the target differential packet and the length of the new version of the firmware meets the preset storage requirement, includes: If the new version of the firmware meets the minimum differential package generation condition, updating the differential position offset according to a preset offset value, and performing firmware differencing on the new version of the firmware according to the preset differential direction and the updated differential position offset to obtain a differential package to be determined; In the event that the sum of the length of the differential packet to be determined and the length of the new version of the firmware exceeds the preset storage requirement, the differential position offset is updated according to the preset offset value, and firmware differencing is performed on the new version of the firmware according to the preset differential direction and the updated differential position offset. Updating the differential position offset is stopped until the sum of the length of the differential packet to be determined and the length of the new version of the firmware meets the preset storage requirement, and the final differential packet to be determined is determined as the target differential packet.

2. The differential packet generation method according to claim 1, characterized in that: The firmware difference of the new version firmware of the embedded terminal of the embedded upgrade system is performed according to a preset difference direction and an initial difference position offset to obtain an initial difference packet, including: Determining the size of firmware blocks according to hardware resource parameters of the embedded terminal; Splitting the new version firmware based on the firmware block size to obtain at least two new version firmware blocks; Each new version firmware block is differentiated from the old version firmware one by one according to the preset differential direction and the initial differential position offset to obtain the initial differential packet.

3. The differential packet generation method according to claim 1, wherein: The determining whether the new version of the firmware meets the minimum difference packet generation condition includes: Performing full differential analysis on the new version firmware and the old version firmware to obtain a full differential generation package; It is determined whether the sum of the length of the full differential generation package and the length of the new version firmware meets the preset storage requirement. If so, it is determined that the new version firmware meets the minimum differential package generation condition.

4. The differential packet generation method according to claim 1, wherein: After updating the differential position offset according to the preset offset value, the method further includes: It is determined whether the updated differential position offset exceeds a preset offset threshold. If so, the generation of the differential package for the new version of the firmware is terminated, and a differential failure prompt message is generated.

5. The differential packet generation method according to claim 1, wherein: The method further includes performing firmware differentiation on the new version firmware of the embedded terminal of the embedded upgrade system according to a preset differential direction and an initial differential position offset to obtain an initial differential packet, and further includes: When the length of the new version of the firmware exceeds the length of the old version of the firmware, performing firmware differentiation on the new version of the firmware according to the first differential direction and the initial differential position offset to obtain an initial differential packet; When the length of the new version of the firmware does not exceed the length of the old version of the firmware, firmware differentiation is performed on the new version of the firmware according to a second differential direction and an initial differential position offset to obtain the initial differential packet; wherein the second differential direction is opposite to the first differential direction.

6. The differential packet generation method according to any one of claims 1 to 5, characterized in that: In the case where the sum of the length of the initial differential packet and the length of the new version firmware exceeds a preset storage requirement, and the new version firmware does not meet the minimum differential packet generation condition, the method further includes: The generation of the differential package for the new version of the firmware is completed, and a differential failure prompt message is generated.

7. A differential upgrade method for an embedded terminal of an embedded upgrade system, characterized in that: The method comprises: Acquire a target differential package generated by the server of the embedded upgrade system based on the differential package generation method according to any one of claims 1 to 6; According to the differential direction and differential position offset of the target differential packet, the old version of the firmware is upgraded using the target differential packet to obtain a new version of the firmware.

8. The differential upgrade method according to claim 7, characterized in that: The embedded terminal includes a first upgrade process information management area and a second upgrade process information management area. The target differential package is used to upgrade the old version of the firmware to obtain the new version of the firmware according to the differential direction and differential position offset of the target differential package, including: In the process of upgrading the old version firmware using the target differential package according to the differential direction and differential position offset of the target differential package, the upgrade process information generated during the upgrade process is alternately stored in the first upgrade process information management area and the second upgrade process information management area.

9. A server for an embedded upgrade system, characterized in that: include: Initial module, judgment module, and difference generation module; wherein: The initial module is configured to perform firmware differential on the new version firmware of the embedded terminal of the embedded upgrade system according to a preset differential direction and an initial differential position offset to obtain an initial differential packet; The judgment module is configured to judge whether the new version of the firmware meets the minimum differential packet generation condition when the sum of the length of the initial differential packet and the length of the new version of the firmware exceeds the preset storage requirement; The differential generation module is configured to iteratively generate a target differential packet according to a preset offset value when the new version of the firmware meets the minimum differential packet generation condition, wherein the sum of the length of the target differential packet and the length of the new version of the firmware meets the preset storage requirement, including: If the new version of the firmware meets the minimum differential package generation condition, updating the differential position offset according to a preset offset value, and performing firmware differencing on the new version of the firmware according to the preset differential direction and the updated differential position offset to obtain a differential package to be determined; In the event that the sum of the length of the differential packet to be determined and the length of the new version of the firmware exceeds the preset storage requirement, the differential position offset is updated according to the preset offset value, and firmware differencing is performed on the new version of the firmware according to the preset differential direction and the updated differential position offset. Updating the differential position offset is stopped until the sum of the length of the differential packet to be determined and the length of the new version of the firmware meets the preset storage requirement, and the final differential packet to be determined is determined as the target differential packet.

10. An embedded terminal for an embedded upgrade system, characterized in that: include: Obtain modules and upgrade modules; among them: The acquisition module is configured to acquire a target differential package generated by the server of the embedded upgrade system based on the differential package generation method according to any one of claims 1 to 6; The upgrade module is configured to upgrade the old version of the firmware using the target differential packet according to the differential direction and differential position offset of the target differential packet to obtain the new version of the firmware.

11. An embedded upgrade system, characterized in that: include: A server and an embedded terminal; wherein the server is in communication connection with the embedded terminal; The server is used to execute the differential packet generation method according to any one of claims 1 to 6; The embedded terminal is used to execute the differential upgrade method according to any one of claims 7 to 8.

12. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the differential packet generation method according to any one of claims 1 to 6.

13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the differential packet generation method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Differential file generation and firmware online upgrading method and device

    CN111930412A

  • Differential packet generation method, differential packet generation equipment and upgrading method

    CN113721967A