In-situ upgrade methods, devices, network equipment, and storage media

By generating differential files and directly writing parsed data to the terminal, the problem of insufficient storage space in embedded device FOTA upgrades is solved, achieving FOTA upgrades with low resource consumption.

CN116932022BActive Publication Date: 2026-11-17CHINA MOBILE M2M +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210370003.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-08
Publication Date
2026-11-17
Estimated Expiration
2042-04-08

AI Technical Summary

Technical Problem

Existing FOTA upgrade algorithms require additional storage space in embedded devices to store the parsed upgrade files, resulting in significant resource consumption, which is particularly problematic in devices with limited storage space.

Method used

By generating a differential file containing multiple differential packets and the parsing sequence number of each differential packet, the parsed data is directly written to the corresponding location in the terminal's memory, avoiding the occupation of additional storage space. The differential file is generated using the association information between the upgraded firmware and the firmware to be upgraded, and the upgrade is performed on the terminal in place.

Benefits of technology

It enables FOTA upgrades to be completed with low resource consumption, avoiding the need for additional storage space and improving storage space utilization efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116932022B_ABST
    Figure CN116932022B_ABST
Patent Text Reader

Abstract

This application provides an in-situ upgrade method, apparatus, network device, and storage medium. The method includes: obtaining a differential file based on the association information between the upgraded firmware and the firmware to be upgraded; the differential file contains at least a plurality of differential packets and a parsing sequence number corresponding to each differential packet; the association information indicates the location information of the same code in the upgraded firmware and the firmware to be upgraded; the data length of the differential packet is the same as the data length of the data block; and sending the differential file to the terminal.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of Firmware Over the Air (FOTA) technology, and in particular to an in-situ upgrade method, apparatus, network device, and storage medium. Background Technology

[0002] FOTA refers to the technology of updating the firmware of terminal devices via over-the-air download. Through FOTA upgrades, device manufacturers can send upgrade packages to users' terminal devices over the network, avoiding device recalls, reducing operating costs, and providing convenience for users.

[0003] Many embedded devices have very strict storage requirements, with some having only a few hundred kilobytes of storage space, or even less. However, in current technologies, firmware upgrades, whether using a full upgrade algorithm or an incremental upgrade algorithm, require additional storage space to store the parsed upgrade file, consuming significant storage resources. Summary of the Invention

[0004] To address the aforementioned technical problems, embodiments of this application provide an in-situ upgrade method, apparatus, network device, and computer-readable storage medium. The terminal can directly modify the firmware to be upgraded based on the received differential file without needing to apply for new storage space to store the parsed upgraded firmware, thus achieving low-resource-consumption FOTA upgrades.

[0005] This application provides an in-situ upgrade method applied to a server, including:

[0006] Based on the association information between the upgraded firmware and the firmware to be upgraded, a differential file is obtained. The differential file contains at least multiple differential packets and a parsing sequence number corresponding to each differential packet. The association information indicates the location information of the same code in the upgraded firmware and the firmware to be upgraded. The data length of the differential packet is the same as the data length of the data block.

[0007] Send the differential file to the terminal.

[0008] This application also provides an in-situ upgrade method, applied to a terminal, including:

[0009] The server receives a differential file, which contains at least a plurality of differential packets and a parsing sequence number corresponding to each differential packet.

[0010] Decompress the differential file to obtain multiple differential packets and the parsing sequence number corresponding to each differential packet;

[0011] The corresponding differential packet is parsed based on the parsing sequence number of each differential packet, and the parsed data is written to the corresponding block location in the memory.

[0012] This application embodiment also provides an in-situ upgrade device applied to a server, the device comprising:

[0013] The differential file acquisition unit is used to obtain a differential file based on the association information between the upgraded firmware and the firmware to be upgraded. The differential file contains at least multiple differential packets and a parsing sequence number corresponding to each differential packet. The association information indicates the location information of the same code in the upgraded firmware and the firmware to be upgraded. The data length of the differential packet is the same as the data length of the data block.

[0014] The sending unit is used to send differential files to the terminal.

[0015] This application embodiment also provides an in-situ upgrade device, applied to a terminal, the device comprising:

[0016] The receiving unit is used to receive a differential file sent by the server, wherein the differential file contains at least a plurality of differential packets and a parsing sequence number corresponding to each differential packet;

[0017] The decompression unit is used to decompress the differential file to obtain multiple differential packets and the parsing sequence number corresponding to each differential packet;

[0018] The parsing and writing unit is used to parse the corresponding differential packet based on the parsing sequence number of each differential packet, and write the parsed data to the corresponding block location in the memory.

[0019] This application also provides a network device, including a processor and a memory, the memory for storing computer programs, and the processor for calling and running the computer programs stored in the memory to execute the in-situ upgrade method described in this application.

[0020] This application also provides a computer-readable storage medium storing executable instructions, which, when executed by a processor, implement the in-situ upgrade method described in this application.

[0021] This application provides an in-situ upgrade method, apparatus, network device, and computer-readable storage medium. The in-situ upgrade method includes: a server obtaining a differential file based on the association information between the upgraded firmware and the firmware to be upgraded, and sending the differential file to a terminal; the terminal receiving and decompressing the differential file sent by the server, parsing the corresponding differential packet based on the parsing sequence number of each differential packet, and writing the parsed data to the corresponding block location in the memory. In the solution provided by this application, the server can generate a differential file composed of multiple differential packets based on the association between the upgraded file and the file to be upgraded; after the terminal parses the differential packet according to the parsing sequence number, it can directly modify the file to be upgraded without needing to apply for new storage space to store the parsed upgraded firmware, thus achieving low-resource-consumption FOTA upgrades. Attached Figure Description

[0022] Figure 1 A flowchart illustrating an in-situ upgrade method provided in an embodiment of this application;

[0023] Figure 2 A flowchart illustrating the second in-situ upgrade method provided in this application embodiment;

[0024] Figure 3 A flowchart illustrating the in-situ upgrade method provided for an application embodiment of this application;

[0025] Figure 4 A schematic diagram illustrating the process of constructing a second coverage line group for a server provided in the application embodiments of this application;

[0026] Figure 5 A schematic diagram of the structure of the second coverage line group provided in the application embodiment of this application;

[0027] Figure 6 A schematic diagram of the structure of the first coverage line group provided in the application embodiment of this application;

[0028] Figure 7 A schematic diagram of block information of the firmware to be upgraded provided in an application embodiment of this application;

[0029] Figure 8 A schematic diagram illustrating the process of generating the parsing sequence number corresponding to each differential packet for the server provided in the application embodiment of this application;

[0030] Figure 9 A schematic diagram illustrating the erasable state of a block in the firmware to be upgraded, provided for an application embodiment of this application;

[0031] Figure 10 A schematic diagram illustrating the generation of differential packets by the server in an application embodiment of this application;

[0032] Figure 11This is a schematic diagram of the structure of an in-situ upgrade device provided in an embodiment of this application;

[0033] Figure 12 This is a schematic diagram of the structure of the second in-situ upgrade device provided in the embodiments of this application;

[0034] Figure 13 This is a schematic diagram of the network device provided in an embodiment of this application. Detailed Implementation

[0035] The technical solutions of the embodiments of this application will now be described with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.

[0036] It should be noted that, in the embodiments of this application, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, in the embodiments of this application, the character " / " generally indicates that the preceding and following related objects have an "or" relationship.

[0037] In the description of the embodiments of this application, the term "correspondence" may indicate that there is a direct or indirect correspondence between two things, or that there is an association between two things, or that there is a relationship of instruction and being instructed, configuration and being configured, etc.

[0038] To facilitate understanding of the technical solutions of the embodiments of this application, the relevant technologies of the embodiments of this application are described below. The following relevant technologies are optional solutions and can be combined with the technical solutions of the embodiments of this application in any way, and they all fall within the protection scope of the embodiments of this application.

[0039] FOTA refers to the technology of updating the firmware of terminal devices via over-the-air download. Through FOTA upgrades, device manufacturers can send upgrade packages to users' terminal devices over the network, thereby upgrading the firmware and software of the terminal devices. This avoids the inconvenience caused by device recall upgrades, reduces operating costs, and also makes things more convenient for users.

[0040] Many embedded devices have strict storage requirements, some with only a few hundred kilobytes of storage space, or even less. In existing technologies, FOTA (Firmware Over-The-Air) upgrade algorithms are mainly divided into two types: full upgrade algorithms and differential upgrade algorithms. Compared to full upgrade algorithms, differential upgrade algorithms focus on higher compression ratios, producing smaller differential files and having wider applicability in low-storage-space environments; examples include the Bsdiff and Hdiffpatch algorithms. However, in practical applications, terminal devices also require additional FLASH space to store the new firmware version generated after parsing the differential file, consuming significant amounts of Random Access Memory (RAM) and Read-Only Memory (ROM) storage resources.

[0041] The existing technology is further described below with specific solutions:

[0042] The existing solution proposes a small-space-based FOTA upgrade method. First, each function of the smart terminal is distinguished by a flag and divided into different differential packets, which are then compressed and packaged sequentially into a first differential packet. A second differential packet is created by partitioning the data. Finally, the entire packet is used as a third differential packet and uploaded to the OTA server. Then, instructions are issued and the smart terminal's feedback is monitored. If the Over-the-Air (OTA) server detects that the smart terminal's space is limited, multiple compressed packets from the first differential packet are downloaded sequentially to the corresponding spaces on the smart terminal and upgraded individually. Once the current compressed packet in the first differential packet is successfully upgraded, it is automatically deleted, and a flag is sent to the OTA server to download the next compressed packet. This process continues until the last compressed packet in the first differential packet is successfully upgraded, at which point the upgrade package is automatically deleted.

[0043] The above solution has the following drawbacks:

[0044] First, users need to differentiate the functional flags of the terminal to create differential packets. As the differences between terminal types increase, the creation of differential packets will consume a lot of manpower.

[0045] Secondly, when creating differential packets using partition or terminal function flags, the differential packets cannot be compressed with maximum efficiency. Instead, a large amount of differential packet control description data may be introduced. The number of differential packet downloads will also increase the calls to the terminal's network communication interface, increasing power consumption.

[0046] In addition, parsing the differential packets still requires additional storage space to store the data after differential reconstruction.

[0047] In conclusion, simply dividing large differential packets into multiple smaller differential packets for batch upgrades cannot completely solve the problem of terminal resource consumption.

[0048] To address at least some of the aforementioned deficiencies, the following technical solutions based on embodiments of this application are proposed.

[0049] To provide a more detailed understanding of the features and technical content of this application, the implementation of this application will be described in detail below with reference to the accompanying drawings. The accompanying drawings are for reference and illustration only and are not intended to limit this application. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0050] This application provides an in-situ upgrade method applied to a server. For example... Figure 1 As shown, Figure 1 This is a flowchart illustrating an in-situ upgrade method provided in an embodiment of this application. The in-situ upgrade method includes:

[0051] Step 101: Based on the association information between the upgraded firmware and the firmware to be upgraded, a differential file is obtained. The differential file contains at least multiple differential packets and a parsing sequence number corresponding to each differential packet. The association information indicates the location information of the same code in the upgraded firmware and the firmware to be upgraded. The data length of the differential packet is the same as the data length of the block.

[0052] Step 102: Send the differential file to the terminal.

[0053] Among existing differential upgrade algorithms, taking the Bsdiff algorithm as an example, the implementation of the Bsdiff algorithm includes the following three steps:

[0054] Step A: Form a dictionary from all the strings in the firmware to be upgraded using the FasterSuffix Sorting algorithm based on the binary search idea;

[0055] Step B: Compare the upgraded firmware and the firmware to be upgraded to generate diff string and extra string;

[0056] Step C: Compress the diff string, extra string, and corresponding control words into a patch package using a compression algorithm (zip).

[0057] From the implementation steps of the Bsdiff algorithm described above, we can see that the patch package before compression with zip does not save any characters, but the diff string can be compressed efficiently. Therefore, the Bsdiff algorithm can compress differential files with a high compression ratio.

[0058] During FOTA upgrades, the main reason for resource consumption is the need for additional storage space to store the data parsed from the differential file. Therefore, this embodiment employs an in-situ upgrade method, directly writing the data parsed from the differential packets contained in the differential file into the corresponding location in the terminal's memory, achieving a low-resource-consumption FOTA upgrade. In this embodiment, the corresponding location in the terminal's memory refers to the storage location allocated by the terminal for the firmware. This storage location is measured in blocks and contains multiple blocks. Both the firmware to be upgraded and the upgraded firmware parsed from the differential file are stored in this storage location, and the system calls to implement the firmware configuration function. To facilitate firmware upgrades for the terminal device, the number of blocks contained in the storage location is usually sufficient during initial allocation.

[0059] However, in practical applications, differential files are generated based on the data association and differences between the upgraded firmware and the firmware to be upgraded. When the terminal parses the differential file, in order to extract the upgraded firmware from it, it also needs to rely on the data of the firmware to be upgraded stored in the terminal's memory. Therefore, when upgrading in place, it is necessary to overcome the problem of the data of the dependent firmware to be upgraded being overwritten.

[0060] Based on this, the embodiments of this application generate multiple differential packets based on the association information between the upgraded firmware and the firmware to be upgraded, with the data length of the block as the unit. At the same time, the parsing sequence number of each differential packet is identified, ensuring that the data of the file to be upgraded stored at the location where the parsing data is written in the terminal is in an erasable state, preventing the data of the file to be upgraded that is relied upon during in-place upgrade from being overwritten, so as to ensure that all differential packets can be correctly parsed, accurately restore the upgraded file, and realize FOTA upgrade with low resource consumption.

[0061] In this embodiment of the application, the "block" refers to the smallest unit of data reading / writing in the memory.

[0062] Furthermore, due to server storage limitations, upgraded firmware and firmware to be upgraded are typically stored in a database. When performing an FOTA upgrade on a terminal, in order to obtain the association information between the upgraded firmware and firmware to be upgraded, it is necessary to first retrieve the corresponding firmware to be upgraded and upgraded firmware from the database based on the version number of the firmware to be upgraded.

[0063] Based on this, in one embodiment, the method further includes:

[0064] Based on the first information, the firmware to be upgraded and the upgraded firmware are obtained from the database, where the first information indicates the version number of the firmware to be upgraded.

[0065] The first information indicating the version number of the firmware to be upgraded can be pre-stored in the server or sent by the terminal based on the server's instructions. In this embodiment, in order to save server storage space, the first information is sent by the terminal based on the server's instructions.

[0066] Based on this, in one embodiment, the method further includes:

[0067] Send a first instruction to the terminal and receive the first information returned by the terminal. The first instruction is used to request the version number of the firmware to be upgraded.

[0068] Furthermore, upgraded firmware is usually obtained by rewriting the firmware to be upgraded to a certain extent. For example, code to implement new functions is added to the firmware to be upgraded to form upgraded firmware. Therefore, upgraded firmware and firmware to be upgraded generally contain some identical code. The core idea of ​​differential upgrade algorithm is to utilize this identical code as much as possible and add as little new data as possible to construct differential file to obtain a higher compression ratio. Based on this, in order to obtain differential file, it is also necessary to obtain the association information between upgraded firmware and firmware to be upgraded. The association information indicates the location information of the identical code in upgraded firmware and firmware to be upgraded.

[0069] Based on this, in one embodiment, before obtaining the differential file based on the association information between the upgraded firmware and the firmware to be upgraded, the method further includes:

[0070] Based on the upgraded firmware and the firmware to be upgraded, the association information between the upgraded firmware and the firmware to be upgraded is obtained.

[0071] Based on the core idea of ​​the differential upgrade algorithm, the key to obtaining the correlation information between the upgraded firmware and the firmware to be upgraded lies in obtaining the location information of the same code in both firmware. In this embodiment, a continuous region in the upgraded firmware where the percentage of the same code as the firmware to be upgraded is not less than a set threshold is identified as the location of the same code in both firmware.

[0072] Based on this, in one embodiment, obtaining the association information between the upgraded firmware and the firmware to be upgraded based on the upgraded firmware and the firmware to be upgraded includes:

[0073] Based on the upgraded firmware and the firmware to be upgraded, the upgraded firmware is divided into a matching region and a new region. The matching region refers to a continuous region in the upgraded firmware where the percentage of the same code as the firmware to be upgraded is not less than a set threshold. The new region refers to a continuous region in the upgraded firmware where the percentage of the same code as the firmware to be upgraded is less than a set threshold.

[0074] Based on the matching region and the newly added region, the association information between the upgraded firmware and the firmware to be upgraded is obtained.

[0075] In practical applications, the method for finding identical code in upgraded firmware and firmware to be upgraded usually adopts a binary search algorithm.

[0076] Based on this, in one embodiment, dividing the upgraded firmware into a matching region and a new region based on the upgraded firmware and the firmware to be upgraded includes:

[0077] Based on the firmware to be upgraded, sort all the suffixes in the firmware by dictionary order to obtain the suffix sorted array of the firmware to be upgraded.

[0078] Based on the suffix sorted array of the firmware to be upgraded, the upgraded firmware is traversed using a binary search algorithm, and the upgraded firmware is divided into matching regions and new regions.

[0079] Since the differential file contains at least multiple differential packets and a parsing sequence number corresponding to each differential packet, and the data length of the differential packet is the same as the data length of the block, in this embodiment, the association information between the upgraded firmware and the firmware to be upgraded is constructed using the data length of the block as the unit. For ease of description, the concept of a coverage line is introduced. The coverage line refers to the data band covered by the newly added region and / or matching region in the upgraded firmware.

[0080] Based on this, in one embodiment, obtaining the association information between the upgraded firmware and the firmware to be upgraded based on the matching region and the newly added region includes:

[0081] Based on the matching area and the newly added area, a first coverage line group is constructed through coverage line planning rules. The first coverage line group indicates the association information between the upgraded firmware and the firmware to be upgraded.

[0082] The coverage line planning rules include:

[0083] The structure of the first coverage line consists of newly added areas and matching areas connected one after the other, or newly added areas and matching areas;

[0084] Except for the position corresponding to the last block, the sum of the data lengths covered by all the first overlay lines in each block that constitutes the upgraded firmware is equal to the data length of the block, and the sum of the data lengths covered by all the first overlay lines in the last block is less than or equal to the data length of the block;

[0085] The set of first coverage lines constitutes the first coverage line group;

[0086] Traverse all first coverage lines in the first coverage line group. If a matching region exists in the data covered by the current first coverage line, then in the firmware to be upgraded, all blocks containing this matching region are associated with the current first coverage line.

[0087] Furthermore, to facilitate the construction of the first coverage line group, the construction of the first coverage line group based on the matching area and the newly added area, through coverage line planning rules, includes:

[0088] Based on the matched region and the newly added region, a second set of coverage lines is constructed using coverage line construction rules, which include:

[0089] The structure of the second coverage line is a newly added area and a matching area connected one after the other, or a newly added area. The collection of the second coverage lines constitutes the second coverage line group.

[0090] Based on the second coverage line group, the first coverage line group is constructed using coverage line planning rules.

[0091] In this embodiment of the application, since the data length covered by the second coverage line is not limited relative to the first coverage line, in practical applications, the second coverage line group can be constructed first through the coverage line construction rules; then the first coverage line group can be constructed based on the data length of the block.

[0092] The first overlay line group indicates the association information between the upgraded firmware and the firmware to be upgraded. Based on the first overlay line group, the location of the same code as the firmware to be upgraded in each block of the upgraded firmware can be determined, and multiple differential packets can be constructed accordingly.

[0093] Furthermore, in this embodiment of the application, in order to achieve in-situ upgrade and avoid additional space resource occupation, it is necessary to directly write the data after differential packet parsing into the corresponding location in the terminal's memory.

[0094] As mentioned earlier, to facilitate firmware upgrades, the number of blocks contained in the storage location is sufficient; that is, the number of blocks in the firmware to be upgraded is less than the number of blocks in the storage location. Therefore, in the un-upgraded state, no data is written to the blocks at the end of the storage location sequence. Since the number of blocks in the differential packet is the same as the number of blocks in the upgraded firmware, if the number of blocks in the upgraded firmware is greater than the number of blocks in the firmware to be upgraded, the data parsed from the differential packet at the end of the differential packet sequence can be directly written to the corresponding location in the terminal's memory.

[0095] However, if the block at the beginning of the storage location sequence already contains data for the firmware to be upgraded, the data from the parsed differential packets will overwrite the stored firmware data. In this case, if any unparsed differential packets depend on the overwritten firmware data, the unparsed packets will be unable to be parsed because the corresponding firmware data has been overwritten.

[0096] To address the aforementioned issues, in one embodiment, obtaining the differential file based on the association information between the upgraded firmware and the firmware to be upgraded includes:

[0097] Based on the upgraded firmware and the firmware to be upgraded, the number of blocks contained in the upgraded firmware and the firmware to be upgraded is obtained;

[0098] Traverse each block in the upgraded firmware in reverse order and determine whether the number of untraversed blocks in the upgraded firmware is greater than the number of blocks contained in the firmware to be upgraded.

[0099] If so, based on the traversal order, record the block number corresponding to the traversed block in the upgraded firmware, and continue traversing the next block in the upgraded firmware until the number of untraversed blocks in the upgraded firmware is equal to the number of blocks contained in the firmware to be upgraded.

[0100] If the number of untraversed blocks in the upgraded firmware is equal to the number of blocks in the firmware to be upgraded, then based on the association information between the upgraded firmware and the firmware to be upgraded, determine the erasable status of the block in the firmware to be upgraded that has the same block number as the currently traversed block.

[0101] If the block to be upgraded in the firmware is in an erasable state, record the block number corresponding to the currently traversed block based on the traversal order;

[0102] If the block to be upgraded in the firmware is in an indelible state, the block number corresponding to the currently traversed block is put into the stack, and the next block is traversed, until all blocks in the upgraded firmware have been traversed.

[0103] Record the block number in the stack according to the order of insertion, and treat the data contained in the block of the upgraded firmware corresponding to the first overlay line of the firmware to be upgraded as the new area, and redivide the matching area and the new area of ​​the upgraded firmware.

[0104] Based on the redefined matching region and the newly added region, multiple differential packets and the parsing sequence number of each differential packet are obtained. The parsing sequence number refers to the record number of the block sequence number corresponding to each differential packet, and the block sequence number corresponding to each differential packet refers to the block sequence number of the upgraded file corresponding to each differential packet.

[0105] In the above scheme, if the block of the firmware to be upgraded is in an indelible state, that is, the differential packets that have not yet been parsed need to rely on the data in the block of the firmware to be upgraded, in order to achieve in-situ upgrade, it is only necessary to treat the data contained in the block of the upgraded firmware corresponding to the first overlay line associated with the block of the firmware to be upgraded as a new area. At this time, the differential packets that have not yet been parsed do not need to rely on the data in the block of the firmware to be upgraded.

[0106] Therefore, based on the redefined matching region and the newly added region, multiple differential packets and their parsing sequence numbers are obtained. The corresponding differential packets are then parsed according to their parsing sequence numbers, and the parsed data can be directly written to the corresponding location in the terminal's memory. During this process, there is no issue where unparsed differential packets need to rely on data from the overwritten firmware to be upgraded.

[0107] Furthermore, in the above process, in order to determine the erasable status of the block of the firmware to be upgraded, in one embodiment, the step of determining the erasable status of the block of the firmware to be upgraded that has the same block number as the currently traversed block, based on the association information between the upgraded firmware and the firmware to be upgraded, includes:

[0108] Based on the association information between the upgraded firmware and the firmware to be upgraded, the first coverage line associated with the block of the firmware to be upgraded is obtained. The block of the firmware to be upgraded refers to the block of the firmware to be upgraded with the same block number as the block corresponding to the currently traversed block.

[0109] If the block number of the block of the upgraded firmware corresponding to the first overlay line associated with the block of the firmware to be upgraded has been recorded, then the block of the firmware to be upgraded is in an erasable state.

[0110] If the block number of the upgraded firmware block corresponding to the first overlay line associated with the block of the firmware to be upgraded is not recorded, then the block of the firmware to be upgraded is in an indelible state.

[0111] If the block number of the upgraded firmware block corresponding to the first overlay line associated with the block of the firmware to be upgraded has been recorded, it means that the differential packet of the corresponding block number has been recorded. That is, the data in the block of the firmware to be upgraded corresponding to the block number is not dependent. Therefore, the block of the firmware to be upgraded is in an erasable state.

[0112] If the block number of the upgraded firmware block corresponding to the first overlay line associated with the block of the firmware to be upgraded is not recorded, it means that the differential packet of the corresponding block number is not recorded. That is, the data in the block of the firmware to be upgraded corresponding to the block number is dependent on the differential packet that has not yet been parsed. Therefore, the block of the firmware to be upgraded is in an indelible state.

[0113] Furthermore, based on the re-divided matching region and the newly added region, multiple differential packets and the parsing sequence number of each differential packet are obtained, including:

[0114] Based on the redefined matching region and the newly added region, the difference data between the upgraded firmware and the firmware to be upgraded is compressed into multiple differential packets according to the data length of the block.

[0115] Based on the record number of the block sequence number corresponding to each differential packet, the parsing sequence number corresponding to each differential packet is obtained.

[0116] In the above scheme, based on the redefined matching region and the newly added region, since the matching region in the upgraded firmware and the data in the firmware to be upgraded are highly similar, the data after the subtraction operation between the upgraded firmware and the firmware to be upgraded has high compression.

[0117] Based on this, in one embodiment, the step of compressing the difference data between the upgraded firmware and the firmware to be upgraded into multiple differential packets according to the block data length, based on the re-divided matching region and the newly added region, includes:

[0118] Based on the redefined matching area and the newly added area, the first coverage line group is reconstructed using coverage line planning rules;

[0119] Based on the reconstructed first coverage line group, the difference data corresponding to each reconstructed first coverage line is compressed using the RLE algorithm to obtain the first compressed data of the difference data corresponding to each reconstructed first coverage line. The difference data refers to the difference data after the upgraded firmware and the firmware to be upgraded are subtracted.

[0120] Based on the first compressed data corresponding to the difference data of each reconstructed first coverage line, the first compressed data belonging to the same block is compressed using the LZMA algorithm in units of blocks to obtain multiple differential packets.

[0121] In the above scheme, the basic idea of ​​the RLE algorithm is to divide the data into two cases according to a linear sequence: one is continuous repeating data blocks, and the other is continuous non-repeating data blocks. The principle of the RLE algorithm is to use an attribute representing the number of blocks plus a data block to represent several consecutive data blocks, thereby achieving the goal of saving storage space. Since the difference data corresponding to the first coverage line of the reconstruction is obtained by subtracting the upgraded firmware and the firmware to be upgraded, the difference data corresponding to the first coverage line of the reconstruction contains a large amount of continuous repeating data, which can be effectively compressed using the RLE algorithm.

[0122] Furthermore, to ensure the correctness of the data parsed by the terminal, it is also necessary to detect or verify whether errors occur after the differential packets are transmitted from the server to the terminal. In this embodiment, Cyclic Redundancy Check (CRC) technology is used to detect or verify whether errors occur after the differential packets are transmitted from the server to the terminal.

[0123] Based on this, in one embodiment, the differential file further includes a CRC value corresponding to each differential packet; the method for obtaining the CRC value corresponding to each differential packet is as follows:

[0124] Based on the block sequence number corresponding to each differential packet, the CRC value corresponding to each differential packet is obtained; in this embodiment of the application, the CRC value corresponding to each differential packet refers to the CRC value of the block of the upgraded firmware corresponding to the block sequence number of each differential packet.

[0125] This application also provides an in-situ upgrade method, applied to a terminal; such as... Figure 2 As shown, Figure 2 This is a flowchart illustrating a second in-situ upgrade method provided in an embodiment of this application. The in-situ upgrade method includes:

[0126] Step 201: Receive the differential file sent by the server, wherein the differential file contains at least multiple differential packets and the parsing sequence number corresponding to each differential packet;

[0127] Step 202: Decompress the differential file to obtain multiple differential packets and the parsing sequence number corresponding to each differential packet;

[0128] Step 203: Parse the corresponding differential packet based on the parsing sequence number of each differential packet, and write the parsed data into the corresponding block location in the memory.

[0129] In the above scheme, the terminal parses the corresponding differential packet based on the parsing sequence number of each differential packet and writes the parsed data into the corresponding block position in the memory. There is no need to apply for new storage space to store the parsed upgraded firmware, thus realizing FOTA upgrade with low resource consumption.

[0130] In order to ensure the correctness of the data parsed by the terminal, it is also necessary to detect or verify whether errors occur after the differential packet is transmitted from the server to the terminal. In this embodiment, CRC technology is used to detect or verify whether errors occur after the differential packet is transmitted from the server to the terminal.

[0131] Accordingly, in one embodiment, the differential file further includes a CRC value corresponding to each differential packet.

[0132] Accordingly, the decompression of the differential file yields multiple differential packets and a parsing sequence number for each differential packet, including:

[0133] Decompress the differential file to obtain multiple differential packets and the corresponding parsing sequence number and CRC value for each differential packet.

[0134] Furthermore, the step of parsing the corresponding differential packet based on the parsing sequence number of each differential packet and writing the parsed data into the corresponding block location in the memory includes:

[0135] Based on the parsing sequence number corresponding to each differential packet, parse the corresponding differential packet and calculate the CRC value of the data after parsing each differential packet;

[0136] The CRC value of the parsed data of each differential packet is compared with its corresponding CRC value. If they are the same, the parsed data is written to the corresponding block location in the memory; if they are different, an instruction to retrieve the current differential packet is sent to the server.

[0137] Furthermore, based on the principle of the differential upgrade method, in one embodiment, the step of parsing the corresponding differential packet based on the parsing sequence number of each differential packet includes:

[0138] Based on the parsing sequence number corresponding to the differential packet, decompress the corresponding differential packet in sequence to obtain the difference data in the current differential packet;

[0139] Based on the parsing sequence number corresponding to the current differential packet, obtain the block sequence number of the firmware to be upgraded associated with the current differential packet;

[0140] Based on the block number of the firmware to be upgraded associated with the current differential packet, retrieve the firmware data to be upgraded associated with the current differential packet from the corresponding block location in the memory;

[0141] Based on the decompressed data of the current differential packet and the firmware data to be upgraded associated with the current differential packet, the parsed data of the current differential packet is obtained. The parsed data refers to the upgraded firmware data corresponding to the current differential packet.

[0142] When the device manufacturer develops an upgraded firmware, the terminal still needs to be upgraded via a server. In this case, the terminal needs to send the version number of the firmware to be upgraded to the server so that the server can find the corresponding upgraded file and the file to be upgraded in the database.

[0143] Based on this, in one embodiment, before receiving the differential file sent by the receiving server, the method further includes:

[0144] The system receives a first instruction from the server and sends a first message to the server. The first instruction is used to request the version number of the firmware to be upgraded, and the first message indicates the version number of the firmware to be upgraded.

[0145] This application provides an in-situ upgrade method, in which the server obtains a differential file based on the association information between the upgraded firmware and the firmware to be upgraded, and sends the differential file to the terminal; the terminal receives and decompresses the differential file sent by the server, and parses the corresponding differential packet based on the parsing sequence number of each differential packet, writing the parsed data into the corresponding block location in the memory. In the solution provided by this application, the server can generate a differential file composed of multiple differential packets based on the association between the upgraded file and the file to be upgraded; after the terminal parses the differential packet according to the parsing sequence number, it can directly modify the file to be upgraded without needing to apply for new storage space to store the parsed upgraded firmware, thus achieving a low-resource-consumption FOTA upgrade.

[0146] The present application will be further described below with reference to application embodiments:

[0147] Figure 3 This is a flowchart illustrating the in-situ upgrade method provided in an application embodiment of this application. For example... Figure 3 As shown, the in-situ upgrade method provided in the application embodiments of this application includes:

[0148] Step 301: The server sends a first instruction to the terminal, and the terminal returns first information to the server. The first instruction is used to request the version number of the firmware to be upgraded, and the first information indicates the version number of the firmware to be upgraded.

[0149] Step 302: Based on the first information, the server retrieves the upgraded firmware and the firmware to be upgraded from the database;

[0150] Step 303: Based on the association information between the upgraded firmware and the firmware to be upgraded, the server constructs a second coverage line group; such as... Figure 4 As shown, Figure 4A schematic diagram of the process for constructing a second coverage line group by a server according to an application embodiment of this application, wherein the server constructs the second coverage line group, including:

[0151] Step 401: Based on the firmware to be upgraded, the server sorts all the suffixes in the firmware to be upgraded into a lexicographical array to obtain the suffix sorted array of the firmware to be upgraded.

[0152] Step 402: Based on the suffix sorted array of the firmware to be upgraded, the server uses a binary search algorithm to traverse the upgraded firmware and divide the upgraded firmware into matching regions and new regions.

[0153] Step 403: Based on the matching region and newly added region in the upgraded firmware, the server constructs a second coverage line group according to the coverage line construction rules, which include:

[0154] The structure of the second coverage line consists of newly added areas and matching areas connected one after the other, or newly added areas; the collection of second coverage lines constitutes a second coverage line group; such as Figure 5 As shown, Figure 5 A schematic diagram of the structure of the second coverage line group provided in the application embodiment of this application; wherein, Figure 5 In this context, m1 and m2 refer to the second coverage line 1 and the second coverage line 2, respectively.

[0155] Step 304: Based on the second coverage line group, the server constructs the first coverage line group according to the coverage line planning rules; the first coverage line group indicates the association information between the upgraded firmware and the firmware to be upgraded;

[0156] The coverage line planning rules include:

[0157] The structure of the first coverage line consists of newly added areas and matching areas connected one after the other, or newly added areas and matching areas;

[0158] Except for the position corresponding to the last block, the sum of the data lengths covered by all the first overlay lines in each block that constitutes the upgraded firmware is equal to the data length of the block, and the sum of the data lengths covered by all the first overlay lines in the last block is less than or equal to the data length of the block;

[0159] The set of first coverage lines constitutes the first coverage line group; such as Figure 6 As shown, Figure 6 A schematic diagram of the structure of the first coverage line group provided in the application embodiment of this application; wherein, Figure 6 In this context, m1 and m2 refer to the second coverage line 1 and the second coverage line 2, respectively. Figure 6 In this context, n1, n2, n3, n4, and n5 refer to the first covering line 1, the first covering line 2, the first covering line 3, the first covering line 4, and the first covering line 5, respectively; Figure 6 It can be seen that the second coverage line group consists only of the second coverage line 1 and the second coverage line 2. After the server divides the coverage line according to the coverage line planning rules, the first coverage line group includes the first coverage line 1, the first coverage line 2, the first coverage line 3, the first coverage line 4, and the first coverage line 5.

[0160] Traverse all first coverage lines in the first coverage line group. If there is a matching area in the data covered by the current first coverage line, then in the firmware to be upgraded, all blocks containing this matching area are associated with the current first coverage line.

[0161] Step 305: Based on the first coverage line group, the server constructs the block information of the upgraded firmware, wherein the block information of the upgraded firmware includes the number of blocks contained in the upgraded firmware and the first coverage line information contained in each block.

[0162] like Figure 6 As shown, the structure of the first overlay line 1 in the upgraded firmware block1 is a newly added area; the structure of the first overlay line 2 in the upgraded firmware block2 is a newly added area; the structure of the upgraded firmware block3 includes the first overlay line 3 and the first overlay line 4, the structure of the first overlay line 3 is a newly added area and a matching area connected front and back, the structure of the first overlay line 4 is a newly added area; and the structure of the first overlay line 5 in the upgraded firmware block4 is a newly added area.

[0163] Step 306: Based on the first overlay line group, the server constructs the block information of the firmware to be upgraded, wherein the block information of the firmware to be upgraded includes the number of blocks contained in the firmware to be upgraded and the first overlay line associated with each block.

[0164] like Figure 7 As shown, Figure 7 A schematic diagram of block information of the firmware to be upgraded provided in an application embodiment of this application; Figure 7 In the process, the upgraded firmware contains four blocks, and the firmware to be upgraded contains two blocks. The first overlay line 2 and the first overlay line 3 are associated with block 1 of the firmware to be upgraded, and the first overlay line 3 and the first overlay line 4 are associated with block 2 of the firmware to be upgraded.

[0165] Step 307: Based on the block information of the upgraded firmware and the block information of the firmware to be upgraded, the server generates a parsing sequence number corresponding to each differential packet; specifically, such as... Figure 8 As shown, Figure 8 The flowchart illustrating the process of generating the parsing sequence number corresponding to each differential packet for the server provided in the application embodiment of this application includes the following steps:

[0166] Step 801: Traverse each block in the upgraded firmware in reverse order and determine whether the number of untraversed blocks in the upgraded firmware is greater than the number of blocks contained in the firmware to be upgraded; if yes, proceed to step 802; if no, proceed to step 803.

[0167] Step 802: Based on the traversal order, record the block number corresponding to the traversed block in the upgraded firmware, and continue to traverse the next block in the upgraded firmware until the number of untraversed blocks in the upgraded firmware is equal to the number of blocks contained in the firmware to be upgraded.

[0168] Step 803: If the number of untraversed blocks in the upgraded firmware is equal to the number of blocks in the firmware to be upgraded, then based on the association information between the upgraded firmware and the firmware to be upgraded, determine the erasable status of the block in the firmware to be upgraded that has the same block number as the currently traversed block.

[0169] If the block of the firmware to be upgraded is in an erasable state, proceed to step 804;

[0170] If the block of the firmware to be upgraded is in an indelible state, proceed to step 805;

[0171] Step 804: Based on the traversal order, record the block number corresponding to the currently traversed block;

[0172] Step 805: Push the block number corresponding to the currently traversed block onto the stack, and continue traversing the next block;

[0173] Step 806: Continue traversing all blocks in the upgraded firmware;

[0174] Step 807: Record the block number placed in the stack according to the order of placement, and treat the data contained in the block of the upgraded firmware corresponding to the first overlay line of the firmware to be upgraded as the new area, and re-divide the matching area and the new area of ​​the upgraded firmware.

[0175] Specifically, such as Figure 9 As shown, Figure 9 This is a schematic diagram illustrating the erasable state of the block of the firmware to be upgraded, provided in an application embodiment of this application. Figure 9In the left part, when the terminal parses the differential packet corresponding to block number 4, it needs to rely on the data corresponding to block number B in the firmware to be upgraded. When the terminal parses the differential packet corresponding to block number 2, it needs to rely on the data corresponding to block number D in the firmware to be upgraded. Therefore, block number D in the terminal's memory is in an indelible state. To achieve in-situ upgrades, in the application embodiments of this application, as follows... Figure 9 As shown on the right, the data of the upgraded firmware corresponding to block number 2 is treated as a new area. That is, when the terminal parses the differential packet corresponding to block number 2, it does not need to rely on the data stored in block number D in the terminal's memory. Therefore, the in-situ upgrade method described in the application embodiment of this application can be realized.

[0176] Step 808: The server generates a parsing sequence number corresponding to each differential packet. The parsing sequence number refers to the record sequence number of the block sequence number corresponding to each differential packet. The block sequence number corresponding to each differential packet refers to the block sequence number of the upgraded file corresponding to each differential packet.

[0177] Step 308: Based on the redefined matching region, the new region, and the parsing sequence number corresponding to each differential packet, the server reconstructs the first coverage line group based on the redefined matching region and the new region, using the coverage line planning rules.

[0178] Step 309: Based on the reconstructed first coverage line group, the server uses the RLE algorithm to compress the difference data corresponding to each reconstructed first coverage line to obtain the first compressed data of the difference data corresponding to each reconstructed first coverage line. The difference data refers to the difference data after the upgraded firmware and the firmware to be upgraded are subtracted.

[0179] Step 3010: Based on the first compressed data of the difference data corresponding to each reconstructed first coverage line, compress the first compressed data belonging to the same block, parse the sequence number and CRC value in units of block, and obtain multiple differential packets;

[0180] Specifically, such as Figure 10 As shown, Figure 10This is a schematic diagram illustrating the generation of differential packets by a server in an application embodiment of this application. Assume the upgraded firmware consists of a single block, and each block contains only one overlay line. The data sequence of the firmware to be upgraded is "a,b,c,d,e,f,g,h,i,j,k,l,m,n", and the data sequence of the upgraded firmware is "o,p,q,r,s,t,a,b,c,e,d,e,f,g,h,i,j,m,l,m,n". Then, in the upgraded firmware, the newly added region contains the data sequence "o,p,q,r,s,t", and the matching region contains the data sequence "a,b,c,e, The sequence d,e,f,g,h,i,j,m,l,m,n is used to subtract the firmware from the upgraded firmware. The resulting differential data sequence is "0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,2,0,0,0". Here, "0,0,2,0,0,0,0,0,0,0,2,0,0,0" represents the differential data corresponding to the matching region, exhibiting high compressibility. Therefore, the RLE algorithm is first used to compress the differential data, and then the LZMA algorithm is used to compress and parse the sequence number and CRC value to obtain the differential packet.

[0181] Step 3011: The server packages multiple differential packets into a differential file and sends the differential file to the terminal;

[0182] Step 3012: The terminal receives the differential file sent by the server, parses the data of the corresponding differential packet according to the parsing sequence number of each differential packet, and writes the parsed data directly into the corresponding block location in the memory.

[0183] The in-situ upgrade method provided in this application embodiment allows the server to generate differential packets in units of block data length. The terminal parses the corresponding differential packet according to its parsing sequence number and directly writes the parsed data to the corresponding location in the terminal's memory, thus achieving an in-situ upgrade. In this process, the terminal does not require additional storage space to store the parsed data; instead, it directly modifies the firmware to be upgraded, effectively saving a significant amount of storage space, reducing the occupancy rate of the terminal's storage, and achieving low-resource-consumption FOTA upgrades.

[0184] To implement the in-situ upgrade method for servers provided in the embodiments of this application, the embodiments of this application also provide an in-situ upgrade apparatus for servers. For example... Figure 11 As shown, Figure 11 This is a schematic diagram of an in-situ upgrade device provided in an embodiment of this application. The in-situ upgrade device 1100 includes:

[0185] The differential file acquisition unit 1101 is used to obtain a differential file based on the association information between the upgraded firmware and the firmware to be upgraded. The differential file contains at least a plurality of differential packets and a parsing sequence number corresponding to each differential packet. The association information indicates the location information of the same code in the upgraded firmware and the firmware to be upgraded. The data length of the differential packet is the same as the data length of the data block.

[0186] The sending unit 1102 is used to send differential files to the terminal.

[0187] To implement the in-situ upgrade method for terminals provided in the embodiments of this application, the embodiments of this application also provide an in-situ upgrade device for terminals. For example... Figure 12 As shown, Figure 12 This is a schematic diagram of the structure of a second in-situ upgrade device provided in an embodiment of this application. The in-situ upgrade device 1200 includes:

[0188] The receiving unit 1201 is used to receive a differential file sent by the server, wherein the differential file contains at least a plurality of differential packets and a parsing sequence number corresponding to each differential packet;

[0189] The decompression unit 1202 is used to decompress the differential file to obtain multiple differential packets and the parsing sequence number corresponding to each differential packet;

[0190] The parsing and writing unit 1203 is used to parse the corresponding differential packet based on the parsing sequence number of each differential packet, and write the parsed data into the corresponding block location in the memory.

[0191] Those skilled in the art should understand that Figure 11 The aforementioned in-situ upgrade device 1100 and Figure 12 The functions of each unit in the second type of in-situ upgrade device 1200 shown can be understood by referring to the relevant description of the aforementioned in-situ upgrade method. Figure 11 The aforementioned in-situ upgrade device 1100 and Figure 12 The functions of each unit in the second type of in-situ upgrade device 1200 shown can be implemented by a program running on a processor or by specific logic circuits.

[0192] It should be noted that the in-situ upgrade device 1100 and the second in-situ upgrade device 1200 provided in the above embodiments are only illustrated by the division of the above-described program units. In practical applications, the above processing can be assigned to different program units as needed, that is, the internal structure of the system can be divided into different program units to complete all or part of the processing described above. In addition, the in-situ upgrade device 1100 and the second in-situ upgrade device 1200 provided in the above embodiments belong to the same concept as the in-situ upgrade method embodiments, and their specific implementation process is detailed in the method embodiments, which will not be repeated here.

[0193] Based on the hardware implementation of the above program units, and in order to implement the in-situ upgrade method provided in the embodiments of this application, the embodiments of this application also provide a network device, such as... Figure 13 As shown, Figure 13 This is a schematic diagram of the network device provided in an embodiment of this application; the network device 1300 includes:

[0194] A processor 1301 and a memory 1302 are provided. The memory 1302 stores computer programs, and the processor 1301 is used to call and run the computer programs stored in the memory 1302 to execute the in-situ upgrade method provided in this application embodiment. In practical applications, such as... Figure 13 As shown, the various components in the network device 1300 are coupled together via a bus module 1303. It is understood that the bus module 1303 is used to implement communication between these components. In addition to a data bus, the bus module 1303 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 13 The general labels all buses as bus module 1303.

[0195] This application also provides a computer-readable storage medium storing executable instructions, which, when executed by a processor, implement the in-situ upgrade method provided in this application.

[0196] In some embodiments, the storage medium may be a magnetic random access memory (FRAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM), etc.; or it may be a device that includes one or any combination of the above-mentioned memories.

[0197] In some embodiments, executable instructions may take the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a standalone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.

[0198] As an example, executable instructions may, but do not necessarily, correspond to files in the file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple collaborative files (e.g., files that store one or more modules, subroutines, or code sections).

[0199] As an example, executable instructions can be deployed to execute on a single computing device, or on multiple computing devices located in one location, or on multiple computing devices distributed across multiple locations and interconnected via a communication network.

[0200] It should be noted that terms such as "first" and "second" are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0201] The technical solutions described in the embodiments of this application can be combined arbitrarily without conflict.

[0202] In the several embodiments provided in this application, it should be understood that the disclosed methods and electronic devices can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components may be combined, or integrated into another system, or some features may be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed may be through some interfaces, and the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0203] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.

[0204] In addition, each functional unit in the various embodiments of this application can be integrated into a second processing unit, or each unit can be a separate unit, or two or more units can be integrated into a unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.

[0205] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.

Claims

1. An in-situ upgrade method, applied to a server, characterized in that, include: The upgraded firmware is divided into a matching region and a new region. The matching region refers to a continuous region in the upgraded firmware where the percentage of the same code as the firmware to be upgraded is not less than a set threshold. The new region refers to a continuous region in the upgraded firmware where the percentage of the same code as the firmware to be upgraded is less than a set threshold. Based on matching regions and newly added regions, a first coverage line group is constructed using coverage line planning rules. This first coverage line group indicates the association information between the upgraded firmware and the firmware to be upgraded. The association information indicates the location information of the same code in both firmware. A coverage line refers to the data band covered by the newly added region and / or matching region in the upgraded firmware. The coverage line planning rules include: the structure of the first coverage line is a series of consecutive newly added regions and matching regions, or one newly added region and another matching region; except for the position corresponding to the last block, the sum of the data lengths covered by all the first coverage lines in each block of the upgraded firmware is equal to the data length of the block, and the sum of the data lengths covered by all the first coverage lines in the last block is less than or equal to the data length of the block; the set of first coverage lines constitutes the first coverage line group; traversing all the first coverage lines in the first coverage line group, if a matching region exists in the data covered by the current first coverage line, then all blocks in the firmware to be upgraded that contain this matching region are associated with the current first coverage line; Based on the upgraded firmware and the firmware to be upgraded, the number of blocks contained in the upgraded firmware and the firmware to be upgraded is obtained; Traverse each block in the upgraded firmware in reverse order; If the number of untraversed blocks in the upgraded firmware is greater than the number of blocks in the firmware to be upgraded, then based on the traversal order, the block number corresponding to the traversed block in the upgraded firmware is recorded, and the next block in the upgraded firmware is traversed again until the number of untraversed blocks in the upgraded firmware is equal to the number of blocks in the firmware to be upgraded. If the number of untraversed blocks in the upgraded firmware is equal to the number of blocks in the firmware to be upgraded, then based on the association information between the upgraded firmware and the firmware to be upgraded, a first overlay line associated with a block in the firmware to be upgraded is obtained. The block in the firmware to be upgraded refers to the block in the firmware to be upgraded with the same block number as the currently traversed block. If the block number of the upgraded firmware block corresponding to the first overlay line associated with the block in the firmware to be upgraded has been recorded, then the block in the firmware to be upgraded is in an erasable state. If the block number of the upgraded firmware block corresponding to the first overlay line associated with the block in the firmware to be upgraded has not been recorded, then the block in the firmware to be upgraded is in an inerasable state. If the block to be upgraded in the firmware is in an erasable state, record the block number corresponding to the currently traversed block based on the traversal order; If the block to be upgraded in the firmware is in an indelible state, the block number corresponding to the currently traversed block is put into the stack, and the next block is traversed, until all blocks in the upgraded firmware have been traversed. Record the block number placed in the stack according to the order of placement, and treat the data contained in the block of the upgraded firmware corresponding to the first overlay line associated with the block of the firmware to be upgraded as a new area, and redivide the matching area and the new area of ​​the upgraded firmware. Based on the redefined matching region and the newly added region, multiple differential packets and a parsing sequence number for each differential packet are obtained. The parsing sequence number refers to the record sequence number of the block sequence number corresponding to each differential packet. The block sequence number corresponding to each differential packet refers to the block sequence number of the upgraded firmware corresponding to each differential packet. The differential file contains at least multiple differential packets and a parsing sequence number corresponding to each differential packet. The data length of the differential packet is the same as the data length of the data block. The differential file is sent to the terminal.

2. The method according to claim 1, characterized in that, Also includes: Based on the first information, the firmware to be upgraded and the upgraded firmware are obtained from the database, where the first information indicates the version number of the firmware to be upgraded.

3. The method according to claim 2, characterized in that, The method further includes: Send a first instruction to the terminal and receive the first information returned by the terminal. The first instruction is used to request the version number of the firmware to be upgraded.

4. The method according to claim 1, characterized in that, The process of dividing the upgraded firmware into a matching region and a new region includes: Based on the firmware to be upgraded, sort all the suffixes in the firmware by dictionary order to obtain the suffix sorted array of the firmware to be upgraded. Based on the suffix sorted array of the firmware to be upgraded, the upgraded firmware is traversed using a binary search algorithm, and the upgraded firmware is divided into matching regions and new regions.

5. The method according to claim 1, characterized in that, The construction of the first coverage line group based on the matching region and the newly added region, through coverage line planning rules, includes: Based on the matched region and the newly added region, a second set of coverage lines is constructed using coverage line construction rules, which include: The structure of the second coverage line is a newly added area and a matching area connected one after the other, or a newly added area. The collection of the second coverage lines constitutes the second coverage line group. Based on the second coverage line group, the first coverage line group is constructed using coverage line planning rules.

6. The method according to claim 1, characterized in that, Based on the re-divided matching region and the newly added region, multiple differential packets and the parsing sequence number of each differential packet are obtained, including: Based on the redefined matching region and the newly added region, the difference data between the upgraded firmware and the firmware to be upgraded is compressed into multiple differential packets according to the data length of the block; Based on the record number of the block sequence number corresponding to each differential packet, the parsing sequence number corresponding to each differential packet is obtained.

7. The method according to claim 6, characterized in that, Based on the redefined matching region and the newly added region, and according to the block data length, the difference data between the upgraded firmware and the firmware to be upgraded is compressed into the multiple differential packets according to the block data length, including: Based on the redefined matching region and the newly added region, the first coverage line group is reconstructed using the coverage line planning rules; Based on the reconstructed first coverage line group, the difference data corresponding to each reconstructed first coverage line is compressed using the RLE algorithm to obtain the first compressed data of the difference data corresponding to each reconstructed first coverage line. The difference data refers to the difference data after subtracting the upgraded firmware and the firmware to be upgraded. Based on the first compressed data corresponding to the difference data of each reconstructed first coverage line, the first compressed data belonging to the same block is compressed using the LZMA algorithm in units of blocks to obtain the multiple differential packets.

8. The method according to claim 6, characterized in that, The differential file also includes a cyclic redundancy check (CRC) value corresponding to each differential packet; the method for obtaining the CRC value corresponding to each differential packet is as follows: Based on the block number corresponding to each differential packet, obtain the CRC value corresponding to each differential packet.

9. An in-situ upgrade method, applied to a terminal, characterized in that, include: The server receives a differential file, which contains at least a plurality of differential packets and a parsing sequence number corresponding to each differential packet. The data length of the differential packet is the same as the data length of the data block. Decompress the differential file to obtain multiple differential packets and the parsing sequence number corresponding to each differential packet; The corresponding differential packet is parsed based on the parsing sequence number of each differential packet, and the parsed data is written into the corresponding block location in the memory; The differential file is obtained based on the association information between the upgraded firmware and the firmware to be upgraded. The association information indicates the location information of the same code in both the upgraded firmware and the firmware to be upgraded. The association information is indicated by a first coverage line group, which is constructed based on matching regions and newly added regions using coverage line planning rules. The matching region refers to a continuous region in the upgraded firmware where the percentage of the same code as the firmware to be upgraded is not less than a set threshold. The newly added region refers to a continuous region in the upgraded firmware where the percentage of the same code as the firmware to be upgraded is less than a set threshold. The coverage line refers to the newly added region or... / and the data band covered by the matching area; the coverage line planning rules include: the structure of the first coverage line is a newly added area and a matching area connected one after the other, or a newly added area, or a matching area; except for the position corresponding to the last block, the sum of the data lengths covered by all the first coverage lines in each block constituting the upgraded firmware is equal to the data length of the block, and the sum of the data lengths covered by all the first coverage lines in the last block is less than or equal to the data length of the block; the set of the first coverage lines constitutes the first coverage line group; traversing all the first coverage lines in the first coverage line group, if there is a matching area in the data covered by the current first coverage line, then In the firmware to be upgraded, all blocks containing this matching region are associated with the current first coverage line; the parsing sequence number is obtained based on the following method: based on the upgraded firmware and the firmware to be upgraded, the number of blocks contained in the upgraded firmware and the firmware to be upgraded is obtained; each block in the upgraded firmware is traversed in reverse order, and if the number of untraversed blocks in the upgraded firmware is greater than the number of blocks contained in the firmware to be upgraded, then based on the traversal order, the block number corresponding to the traversed block in the upgraded firmware is recorded, and the next block in the upgraded firmware is traversed again, until the untraversed blocks in the upgraded firmware are traversed. The number of traversed blocks is equal to the number of blocks contained in the firmware to be upgraded; if the number of untraversed blocks in the upgraded firmware is equal to the number of blocks contained in the firmware to be upgraded, then based on the association information between the upgraded firmware and the firmware to be upgraded, a first overlay line associated with the block of the firmware to be upgraded is obtained, wherein the block of the firmware to be upgraded refers to the block of the firmware to be upgraded with the same block number as the currently traversed block; if the block number of the block of the upgraded firmware corresponding to the first overlay line associated with the block of the firmware to be upgraded has been recorded, then the block of the firmware to be upgraded is in an erasable state.If the block number of the block in the upgraded firmware corresponding to the first overlay line associated with the block in the firmware to be upgraded is not recorded, then the block in the firmware to be upgraded is in an indelible state. If the block in the firmware to be upgraded is in an erasable state, the block number corresponding to the currently traversed block is recorded based on the traversal order. If the block in the firmware to be upgraded is in an indelible state, the block number corresponding to the currently traversed block is placed on the stack, and the traversal of the next block continues until all blocks in the upgraded firmware have been traversed. The block numbers placed on the stack are recorded in the order of placement, and the data contained in the block in the upgraded firmware corresponding to the first overlay line associated with the block in the firmware to be upgraded is treated as a new region. The matching region and the new region of the upgraded firmware are re-divided. Based on the re-divided matching region and the new region, multiple differential packets and the parsing sequence number of each differential packet are obtained. The parsing sequence number refers to the recording sequence number of the block number corresponding to each differential packet, and the block number corresponding to each differential packet refers to the block number of the upgraded firmware corresponding to each differential packet.

10. The method according to claim 9, characterized in that, The differential file also contains the CRC value corresponding to each differential packet.

11. The method according to claim 10, characterized in that, The decompression of the differential file yields multiple differential packets and a parsing sequence number for each differential packet, including: Decompress the differential file to obtain multiple differential packets and the corresponding parsing sequence number and CRC value for each differential packet.

12. The method according to claim 11, characterized in that, The step of parsing the corresponding differential packet based on the parsing sequence number of each differential packet and writing the parsed data into the corresponding block location in the memory includes: Based on the parsing sequence number corresponding to each differential packet, parse the corresponding differential packet and calculate the CRC value of the data after parsing each differential packet; The CRC value of the parsed data of each differential packet is compared with its corresponding CRC value. If they are the same, the parsed data is written to the corresponding block location in the memory; if they are different, an instruction to retrieve the current differential packet is sent to the server.

13. The method according to claim 12, characterized in that, The process of parsing the corresponding differential packet based on the parsing sequence number of each differential packet includes: Based on the parsing sequence number corresponding to the differential packet, decompress the corresponding differential packet in sequence to obtain the difference data in the current differential packet; Based on the parsing sequence number corresponding to the current differential packet, obtain the block sequence number of the firmware to be upgraded associated with the current differential packet; Based on the block number of the firmware to be upgraded associated with the current differential packet, retrieve the firmware data to be upgraded associated with the current differential packet from the corresponding block location in the memory; Based on the decompressed data of the current differential packet and the firmware data to be upgraded associated with the current differential packet, the parsed data of the current differential packet is obtained. The parsed data refers to the upgraded firmware data corresponding to the current differential packet.

14. The method according to any one of claims 9-13, characterized in that, Before receiving the differential file sent by the receiving server, the system also includes: The system receives a first instruction from the server and sends a first message to the server. The first instruction is used to request the version number of the firmware to be upgraded, and the first message indicates the version number of the firmware to be upgraded.

15. An in-situ upgrade device, characterized in that, Applied to a server, the device includes: The differential file acquisition unit is used to obtain the number of blocks contained in the upgraded firmware and the firmware to be upgraded based on the upgraded firmware and the firmware to be upgraded; traverse each block in the upgraded firmware in reverse order; if the number of untraversed blocks in the upgraded firmware is greater than the number of blocks contained in the firmware to be upgraded, then based on the traversal order, record the block number corresponding to the traversed block in the upgraded firmware, and continue traversing the next block in the upgraded firmware until the number of untraversed blocks in the upgraded firmware is equal to the number of blocks contained in the firmware to be upgraded; if the number of untraversed blocks in the upgraded firmware is equal to the number of blocks contained in the firmware to be upgraded, then based on the association information of the upgraded firmware and the firmware to be upgraded, obtain the first overlay line associated with the block of the firmware to be upgraded, where the block of the firmware to be upgraded refers to the block of the firmware to be upgraded with the same block number as the currently traversed block; if the block number of the upgraded firmware block corresponding to the first overlay line associated with the block of the firmware to be upgraded has been recorded, then the block of the firmware to be upgraded is in an erasable state; if the first overlay line associated with the block of the firmware to be upgraded has been recorded, then the block of the firmware to be upgraded is in an erasable state; If the block number of the upgraded firmware block corresponding to a coverage line is not recorded, then the block of the firmware to be upgraded is in an indelible state. If the block of the firmware to be upgraded is in an erasable state, the block number corresponding to the currently traversed block is recorded based on the traversal order. If the block of the firmware to be upgraded is in an indelible state, the block number corresponding to the currently traversed block is placed on the stack, and the traversal of the next block continues until all blocks in the upgraded firmware have been traversed. The block numbers placed on the stack are recorded in the order they were placed, and the corresponding block numbers of the firmware to be upgraded are recorded. The data contained in the block of the upgraded firmware corresponding to the first coverage line associated with k is treated as a new region, and the matching region and the new region of the upgraded firmware are re-divided; based on the re-divided matching region and the new region, multiple differential packets and the parsing sequence number of each differential packet are obtained. The parsing sequence number refers to the record sequence number of the block sequence number corresponding to each differential packet. The block sequence number corresponding to each differential packet refers to the block sequence number of the upgraded firmware corresponding to each differential packet. The differential file contains at least multiple differential packets and the parsing sequence number corresponding to each differential packet. The data length of the differential packet is the same as the data length of the data block. The sending unit is used to send the differential file to the terminal; The device is further configured to divide the upgraded firmware into a matching region and a new region, wherein the matching region refers to a continuous region in the upgraded firmware where the percentage of identical code in the firmware to be upgraded is not less than a set threshold, and the new region refers to a continuous region in the upgraded firmware where the percentage of identical code in the firmware to be upgraded is less than a set threshold; based on the matching region and the new region, a first coverage line group is constructed through coverage line planning rules, wherein the first coverage line group indicates the association information between the upgraded firmware and the firmware to be upgraded, wherein the association information indicates the location information of identical code in the upgraded firmware and the firmware to be upgraded, and the coverage line refers to the data band covered by the new region and / or the matching region in the upgraded firmware, and the coverage line planning rules... The rules for defining the first coverage line include: the structure of the first coverage line consists of consecutive newly added regions and matching regions, or newly added regions, or matching regions; except for the position corresponding to the last block, the sum of the data lengths covered by all the first coverage lines in each block constituting the upgraded firmware is equal to the data length of the block, and the sum of the data lengths covered by all the first coverage lines in the last block is less than or equal to the data length of the block; the set of the first coverage lines constitutes the first coverage line group; traversing all the first coverage lines in the first coverage line group, if there is a matching region in the data covered by the current first coverage line, then in the firmware to be upgraded, all blocks containing this matching region are associated with the current first coverage line.

16. An in-situ upgrade device, characterized in that, Applied to a terminal, the device includes: The receiving unit is used to receive a differential file sent by the server. The differential file contains at least a plurality of differential packets and a parsing sequence number corresponding to each differential packet. The data length of the differential packet is the same as the data length of the data block. The decompression unit is used to decompress the differential file to obtain multiple differential packets and the parsing sequence number corresponding to each differential packet; The parsing and writing unit is used to parse the corresponding differential packet based on the parsing sequence number of each differential packet, and write the parsed data into the corresponding block location in the memory; The differential file is obtained based on the association information between the upgraded firmware and the firmware to be upgraded. The association information indicates the location information of the same code in both firmware. This association information is indicated by a first coverage line group, which is constructed based on matching regions and newly added regions using coverage line planning rules. The matching region refers to a continuous region in the upgraded firmware where the percentage of the same code as the firmware to be upgraded is not less than a set threshold. The newly added region refers to a continuous region in the upgraded firmware where the percentage of the same code as the firmware to be upgraded is less than a set threshold. The coverage line refers to the region in the upgraded firmware covered by the newly added region and / or the matching region. The data band covered; the coverage line planning rules include: the structure of the first coverage line is a newly added area and a matching area connected one after the other, or a newly added area, or a matching area; except for the position corresponding to the last block, the sum of the data lengths covered by all the first coverage lines in each block constituting the upgraded firmware is equal to the data length of the block, and the sum of the data lengths covered by all the first coverage lines in the last block is less than or equal to the data length of the block; the set of the first coverage lines constitutes the first coverage line group; traversing all the first coverage lines in the first coverage line group, if there is a matching area in the data covered by the current first coverage line, then in the firmware to be upgraded... All blocks containing this matching region are associated with the current first coverage line; the parsing sequence number is obtained based on the following method: based on the upgraded firmware and the firmware to be upgraded, the number of blocks contained in the upgraded firmware and the firmware to be upgraded is obtained; each block in the upgraded firmware is traversed in reverse order; if the number of untraversed blocks in the upgraded firmware is greater than the number of blocks contained in the firmware to be upgraded, then based on the traversal order, the block sequence number corresponding to the traversed block in the upgraded firmware is recorded, and the next block in the upgraded firmware is traversed again until the untraversed block in the upgraded firmware is reached. The number k is equal to the number of blocks contained in the firmware to be upgraded; if the number of untraversed blocks in the upgraded firmware is equal to the number of blocks contained in the firmware to be upgraded, then based on the association information between the upgraded firmware and the firmware to be upgraded, a first overlay line associated with the block of the firmware to be upgraded is obtained, wherein the block of the firmware to be upgraded refers to the block of the firmware to be upgraded with the same block number as the currently traversed block; if the block number of the block of the upgraded firmware corresponding to the first overlay line associated with the block of the firmware to be upgraded has been recorded, then the block of the firmware to be upgraded is in an erasable state.If the block number of the block of the upgraded firmware corresponding to the first overlay line associated with the block of the firmware to be upgraded is not recorded, then the block of the firmware to be upgraded is in an indelible state. If the block of the firmware to be upgraded is in an erasable state, the block number corresponding to the currently traversed block is recorded based on the traversal order. If the block of the firmware to be upgraded is in an indelible state, the block number corresponding to the currently traversed block is placed on the stack, and the traversal of the next block continues until all blocks in the upgraded firmware have been traversed. The block numbers placed on the stack are recorded in the order of placement, and the data contained in the block of the upgraded firmware corresponding to the first overlay line associated with the block of the firmware to be upgraded is treated as a new region. The matching region and the new region of the upgraded firmware are re-divided. Based on the re-divided matching region and the new region, multiple differential packets and the parsing sequence number of each differential packet are obtained. The parsing sequence number refers to the recording sequence number of the block number corresponding to each differential packet, and the block number corresponding to each differential packet refers to the block number of the upgraded firmware corresponding to each differential packet.

17. A network device, characterized in that, It includes a processor and a memory for storing computer programs, the processor for calling and running the computer programs stored in the memory to perform the method as described in any one of claims 1-8, or the method as described in any one of claims 9-14.

18. A computer-readable storage medium, characterized in that, The system stores executable instructions that, when executed by a processor, implement the method as described in any one of claims 1-8, or the method as described in any one of claims 9-14.

Citation Information

Patent Citations

  • File upgrading method and device, equipment and medium

    CN112559020A

  • Memory-controllable NB-IOT module differential upgrading method and system

    CN113590161A

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

    CN113721967A