Software upgrading method, device, electronic device and computer readable storage medium

By analyzing differential packets and restoring data blocks in segments, optimizing storage with duplicate data and translation control information, the problem of insufficient storage space in terminal devices is solved, and the upgrade success rate and performance are improved.

CN113986309BActive Publication Date: 2025-08-15BEIJING ESWIN COMPUTING TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111499057.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-09
Publication Date
2025-08-15
Estimated Expiration
2041-12-09

AI Technical Summary

Technical Problem

The terminal device cannot generate the target firmware at one time when the storage space is limited, resulting in unexpected situations such as power outages during the differential upgrade process, resulting in the failure of the upgrade.

Method used

By analyzing the differential packet, new data, differential data, restore instructions and translation control information are obtained, data blocks are restored in segments, and duplicate data is retained in the storage space. The translation control information is used to optimize the storage location and reduce flash operations.

Benefits of technology

Improves storage space utilization, reduces flash memory mobile operations, and improves the overall performance and upgrade success rate of terminal devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113986309B_ABST
    Figure CN113986309B_ABST
Patent Text Reader

Abstract

The present application provides a software upgrade method, apparatus, electronic device, and computer-readable storage medium. The method includes: parsing a differential packet to obtain newly added data, differential data, restoration indication information, and translation control information; performing the following operations for each restoration indication information: determining the data required to restore a data block, and restoring the corresponding data block based on the determined data; determining whether the restoration indication information indicates the same third data as the remaining restoration indication information; if so, retaining the third data after restoring the data block; and storing the restored data block in a first storage space in a first space based on the translation control information. The present application reduces the content movement operations on the terminal device's flash memory during the terminal device upgrade process, thereby improving overall performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer and mobile communication technology, and in particular to a software upgrading method, device, electronic device and computer-readable storage medium. Background Art

[0002] In the mobile communications sector, device manufacturers and operators are launching new features and services at increasingly shorter intervals. At the same time, software versions are becoming increasingly numerous and complex, leading to numerous unknown issues that arise during user experience. To address these issues and provide a better user experience, manufacturers and operators typically collaborate to place differential packages corresponding to the device's system software on a server for the device to download. This differential package allows the device to upgrade the entire software version.

[0003] In the existing technology, the terminal device stores the differential package downloaded from the server in local storage space, parses the differential package to generate the entire target firmware, and then stores the target firmware in the storage space of the original firmware. However, due to memory limitations of the terminal device, the terminal device cannot generate the entire target firmware based on the differential package in one go and complete the upgrade from the original firmware to the target firmware. Summary of the Invention

[0004] The purpose of the embodiments of the present application is to provide a software upgrade method, device, electronic device and computer-readable storage medium.

[0005] In a first aspect, an embodiment of the present application provides a software upgrade method, the method comprising:

[0006] Parsing the differential packet to obtain newly added data, each differential data, each restoration instruction information, and each translation control information, wherein each differential data is differential data between the second data in the second firmware and the corresponding first data in the first firmware;

[0007] For each restore instruction, do the following in order:

[0008] Determine the data required to restore the data block, and restore the corresponding data block according to the determined data;

[0009] determining whether the restoration instruction information and the remaining restoration instruction information indicate the same third data, wherein the third data is data belonging to the first data;

[0010] If the restoration instruction information and the remaining restoration instruction information indicate the same third data, retaining the third data after restoring the data block;

[0011] According to the translation control information, the restored data block is stored in a first storage space in a first space, where the first space is a space in the terminal device for storing the first firmware.

[0012] In a second aspect, an embodiment of the present application provides another software upgrade method, the method comprising:

[0013] In response to a software upgrade request for target software from a terminal device, determining newly added data in the second firmware, each second data having similar data in the first firmware, and differential data between each second data and the first data in the first firmware;

[0014] The second firmware is divided into multiple data blocks, and the following operations are performed on each data block in sequence according to the order of the data blocks in the second firmware:

[0015] If fourth data is stored in the second storage space in the first firmware corresponding to the data block, the fourth data is moved to an idle area of the second space, where the fourth data is a repeated portion of the first data corresponding to at least two second data, and the second space is a space in the server for storing the first firmware;

[0016] generating, according to the movement of the fourth data, translation control information of each fourth data whose storage position has been moved in the first data and restoration indication information corresponding to each data block;

[0017] A differential packet is generated according to the newly added data, each differential data, the restoration instruction information corresponding to each data block, and each translation control information.

[0018] In a third aspect, an embodiment of the present application provides a software upgrade device, the device comprising:

[0019] a parsing module, configured to parse the differential packet to obtain newly added data, differential data, restoration instruction information, and translation control information, wherein each differential data is differential data between the second data in the second firmware and the corresponding first data in the first firmware;

[0020] The restoration control module is used to perform the following operations in sequence for each restoration instruction:

[0021] Determine the data required to restore the data block, and restore the corresponding data block according to the determined data;

[0022] determining whether the restoration instruction information and the remaining restoration instruction information indicate the same third data, wherein the third data is data belonging to the first data;

[0023] If the restoration instruction information and the remaining restoration instruction information indicate the same third data, retaining the third data after restoring the data block;

[0024] The storage module is used to store the restored data block in a first storage space in the first space according to the translation control information, where the first space is a space in the terminal device for storing the first firmware.

[0025] In a fourth aspect, an embodiment of the present application provides another software upgrade device, the device comprising:

[0026] a data determination module, configured to determine, in response to a software upgrade request for target software from a terminal device, newly added data in the second firmware, respective second data having similar data in the first firmware, and differential data between respective second data and the first data in the first firmware;

[0027] The translation control module is used to divide the second firmware into multiple data blocks and perform the following operations on each data block in sequence according to the order of the data blocks in the second firmware:

[0028] If fourth data is stored in the second storage space in the first firmware corresponding to the data block, the fourth data is moved to an idle area of the second space, where the fourth data is a repeated portion of the first data corresponding to at least two second data, and the second space is a space in the server for storing the first firmware;

[0029] an information generating module, configured to generate, according to the movement of the fourth data, translation control information of each fourth data whose storage position has been moved in the first data and restoration indication information corresponding to each data block;

[0030] The differential packet generation module is used to generate a differential packet according to the newly added data, each differential data, the restoration instruction information corresponding to each data block and each translation control information.

[0031] In a fifth aspect, an embodiment of the present application further provides an electronic device, the electronic device comprising: a processor and a memory;

[0032] The memory is used to store operation instructions;

[0033] The processor is used to execute the software upgrade method described in the first aspect or the second aspect by calling the operation instruction.

[0034] In a sixth aspect, an embodiment of the present application further provides a computer-readable storage medium, which is used to store a computer program. When the computer program is run by a processor, the processor executes the software upgrade method described in the first or second aspect above.

[0035] The beneficial effects of the technical solution provided by the embodiments of the present application are:

[0036] The solution provided in the embodiment of the present application parses the differential packet to obtain newly added data, each differential data, each restoration indication information and each translation control information; for each restoration indication information, the following operations are performed in sequence: determine the data required to restore the data block, and restore the corresponding data block based on the determined data; determine whether the restoration indication information indicates the same third data as the remaining restoration indication information, and if so, retain the third data after restoring the data block; store the restored data block in the first storage space in the first space according to the translation control information, that is, the embodiment of the present application can fully utilize the storage space of the first firmware in the terminal device by segmentedly restoring the second firmware according to the first firmware and the restoration indication information corresponding to the data block, thereby improving space utilization, and when there is repeated similar data, by forming a corresponding relationship between the repeated data and multiple data blocks, it is realized that multiple data blocks can be restored using one third data, and when the terminal device restores the data block, the movement operation on the terminal device's flash memory (Flash) is reduced, thereby improving overall performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for describing the embodiments of the present application.

[0038] Figure 1 A flowchart of a software upgrade method provided in an embodiment of the present application;

[0039] Figure 2 A flowchart of another software upgrade method provided in an embodiment of the present application;

[0040] Figures 3a to 3d An example diagram of a software upgrade method provided in an embodiment of the present application;

[0041] Figure 4 A schematic diagram of the structure of a software upgrade device provided in an embodiment of the present application;

[0042] Figure 5 A schematic diagram of the structure of another software upgrade device provided in an embodiment of the present application;

[0043] Figure 6 A schematic structural diagram of a software-upgraded electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0044] The following describes in detail embodiments of the present application, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and are not to be construed as limiting the present invention.

[0045] It will be understood by those skilled in the art that, unless expressly stated otherwise, the singular forms "a", "an", "said" and "the" used herein may also include the plural forms. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be intermediate elements. In addition, "connected" or "coupled" as used herein may include wireless connections or wireless couplings. The term "and / or" used herein includes all or any units and all combinations of one or more associated listed items.

[0046] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.

[0047] In the prior art, for example, when operating in a network environment with an embedded device, remote upgrades, such as OTA (over the air) upgrades, are needed for reasons such as program bug fixes and performance improvements. These upgrades are typically performed online via Wi-Fi networks, providing users with a more user-friendly service version.

[0048] The general implementation process of the differential upgrade solution is as follows: the target version of the firmware (second firmware) to be upgraded is compared with the current version of the firmware (first firmware), and the maximum length of similar data in the second firmware is determined. The data in the second firmware corresponding to the similar data is then determined as the second data. The second data can be subtracted from the corresponding similar data in the first firmware to obtain the smaller differential data. The data in the second firmware other than the second data can be determined as the newly added data. The server can generate a differential packet with the differential data and the newly added data and send it to the terminal device. During the differential upgrade process based on the differential packet, the terminal device first parses the differential packet to obtain the differential data and the newly added data. Based on the similar data in the first firmware, the entire second firmware is generated in an area outside the terminal device's storage space for the first firmware. The second firmware is stored in the terminal device's storage space for the first firmware, thereby implementing the software upgrade. In the prior art, during the differential upgrade process, the second firmware may not be generated in its entirety at once due to insufficient storage space in the terminal device. Moreover, during the upgrade process of overwriting the first firmware with the entire second firmware, unexpected events such as power outages may occur, resulting in data loss and upgrade failure.

[0049] To address the above-mentioned problems in the prior art, the embodiments of the present application propose an improved differential algorithm that can upgrade the first firmware in segments with a set data length, ultimately completing the upgrade from the first firmware to the second firmware. This allows the terminal device to utilize the storage resources storing the first firmware to complete the differential upgrade under the condition of limited storage resources. The present application scheme is applicable to any scenario where the current version of software needs to be upgraded to the target version of software, and the present application scheme is applicable to any differential upgrade method.

[0050] The solutions provided in the embodiments of the present application can be executed by any electronic device, which can be a user terminal (hereinafter referred to as a terminal device) or a server. The server can be an independent physical server, a server cluster composed of multiple physical servers, or a distributed system. The user terminal can include at least one of the following: a smartphone, a tablet computer, a laptop computer, a desktop computer, a smart TV, or a smart car device.

[0051] An embodiment of the present application provides a software upgrade method for upgrading a current version of software to a target version of software. For the current version of software, the storage space of a user terminal on which the software is installed includes a first storage area and a second storage area, wherein the first storage area is used to store a differential package used to upgrade the current version of software to the target version of software, and the second storage area is used to store firmware corresponding to the current version of software.

[0052] The following combination Figure 1 A software upgrade method is shown to illustrate the present application solution. Figure 1 FIG1 shows a flow chart of a software upgrade method provided by an embodiment of the present application, which can be executed by a terminal device. Figure 1 As shown in , the method may include the following steps:

[0053] Step S101 , parsing the differential packet to obtain newly added data, each differential data, each restoration instruction information and each translation control information, wherein each differential data is differential data between the second data in the second firmware and the corresponding first data in the first firmware.

[0054] The differential data is the difference between the second data in the target version of the second firmware and the corresponding first data in the current version of the first firmware. In other words, the first data in the first firmware is similar to the second data in the second firmware. The newly added data is the data newly added by the target version of the second firmware relative to the current version of the first firmware, that is, the data of the second firmware that does not exist in the first firmware. The method by which the server determines the differential data and newly added data based on the first and second firmware is not limited in this embodiment of the application.

[0055] The restoration indication information of each data block is used to determine the data required to restore the data block, and the translation control information is used to indicate the storage space before and after the movement corresponding to the data to be moved in the first data of the first firmware.

[0056] The terminal device can receive a differential packet from the server in response to a software upgrade instruction. The software upgrade instruction includes identification information of the target software of the terminal device. After determining the identification information of the target software, the terminal device determines which software needs to be upgraded based on the identification information and determines the storage location of the first firmware of the current version of the target software. The space in which the terminal device stores the first firmware can be referred to as the first space.

[0057] The terminal device can determine the target version of the target software through the software upgrade instruction. The target version is the version to which the current version is to be upgraded. For example, if the current version is version 2.0 and the target version is version 3.0, it means that based on the software upgrade instruction, the target software will be upgraded from version 2.0 to version 3.0.

[0058] The identification information of the target software is used to identify the software. For example, the identification information may include the version identifier of the target software's firmware. Based on this version identifier, the terminal device can determine the current version of the installed target software. The identification information can be represented by at least one of text, characters, and numbers. The specific form of the identification information is not limited in this application.

[0059] After receiving the differential packet, the terminal device first parses the differential packet to obtain the newly added data, each differential data, the restoration instruction information corresponding to each data block, and each translation control information, and stores the parsed data in a first storage area in the memory. Optionally, when the differential packet is a compressed packet, the differential packet is first decompressed and then parsed.

[0060] The newly added data, each differential data, the restoration instruction information corresponding to each data block, and each translation control information obtained by parsing have a certain storage rule, and the corresponding data or information can be determined based on the storage rule. For example, the restoration instruction information, each translation control information, each differential data, and the newly added data can be stored in the order of each restoration instruction information, each translation control information, each differential data, and each new data.

[0061] Optionally, the restoration instruction information and translation control information corresponding to each data block may include a tag indicating the order in which they are processed. For example, the restoration instruction information and translation control information corresponding to each data block may be arranged in the order in which they were generated, and a tag corresponding to that order may be generated. Optionally, the restoration instruction information and translation control information corresponding to each data block may be arranged in any order and processed in the order indicated by the tags they contain. Optionally, the newly added data may be arranged in the order in which they were in the second firmware, and the differential data may be arranged in the order in which the corresponding second data were in the second firmware.

[0062] Step S102 : performing the following operations in sequence for each restoration instruction information: determining data required to restore a data block, and restoring the corresponding data block according to the determined data.

[0063] In the order indicated by the restoration instructions, for each restoration instruction, the data required to restore the data block corresponding to the restoration instruction is determined, and the corresponding data block is restored according to a certain restoration rule based on the determined data. The restoration rule is not limited here.

[0064] Step S103 : determining whether the restoration indication information and the remaining restoration indication information indicate the same third data, wherein the third data is data belonging to the first data.

[0065] After determining the data required to restore the data block based on the restoration instruction information in step S102, the terminal device may, for example, traverse each restoration instruction information to determine whether the restoration instruction information indicates the same third data as the remaining restoration instruction information, where the third data is data in the first data, i.e., the third data is partially similar data in the first firmware. Determining whether the restoration instruction information indicates the same third data as the remaining restoration instruction information means determining whether the first data corresponding to the data block is duplicated with the first data corresponding to other data blocks.

[0066] Step S104: if the restoration instruction information and the remaining restoration instruction information indicate the same third data, retain the third data after restoring the data block.

[0067] If the restoration instruction information and the remaining restoration instruction information indicate the same third data, i.e., two data blocks need to be restored based on the same third data, then after restoring the data block based on the third data, the third data is retained for use in the subsequent restoration of the other data block. Retaining the third data means that the storage space containing the third data is not processed and the third data is stored in its storage space as is.

[0068] If the restoration instruction information and the remaining restoration instruction information both indicate different third data, that is, the restoration instruction does not indicate the same third data as any of the remaining restoration instruction information, then after restoring the data block based on the third data, the storage space where the third data is located is determined to be a free area. The free area refers to the space in the first firmware other than the space for storing the first data, that is, the free area refers to the space in the first firmware used to store data not used by the first firmware upgrade. During the firmware upgrade process, the terminal device can move other data in the first firmware to the free area.

[0069] Step S105 : storing the restored data block in a first storage space in the first space according to the translation control information. The first space is a space in the terminal device for storing the first firmware.

[0070] After restoring the data block, the terminal device needs to determine the storage space in which to store the data block. In an embodiment of the present application, the terminal device can store the restored data block in the first space where the first firmware is stored, thereby reducing the storage resources used during the upgrade process. Therefore, the terminal device can determine the corresponding first storage space in the first space for the data block based on the restoration instruction information. For example, when the data blocks are generated sequentially, the corresponding first storage space in the first space can be determined based on the order and size of the data blocks.

[0071] Before storing the data block in the first storage space, the terminal device may move the data in the first storage space according to the shift control information. The terminal device determines whether there is data to be moved in the first storage space based on the pre-movement storage space indicated by the shift control information, and then moves the data based on the post-movement storage space indicated by the shift control information. The specific process is described below.

[0072] The solution provided in the embodiment of the present application parses the differential packet to obtain newly added data, each differential data, each restoration indication information and each translation control information; for each restoration indication information, the following operations are performed in sequence: determine the data required to restore the data block, and restore the corresponding data block based on the determined data; determine whether the restoration indication information indicates the same third data as the remaining restoration indication information, and if so, retain the third data after restoring the data block; store the restored data block in the first storage space in the first space according to the translation control information, that is, the embodiment of the present application can fully utilize the storage space of the first firmware in the terminal device by segmentedly restoring the second firmware according to the first firmware and the restoration indication information corresponding to the data block, thereby improving space utilization, and when there is repeated similar data, by forming a corresponding relationship between the repeated data and multiple data blocks, it is realized that multiple data blocks can be restored using one third data, and when the terminal device restores the data block, the movement operation on the terminal device's flash memory (Flash) is reduced, thereby improving overall performance.

[0073] Optionally, for each restoration indication information, the restoration indication information includes first indication information and / or second indication information.

[0074] The first indication information is used to determine the storage space of the third data corresponding to the data block in the first space, and the second indication information is used to determine the newly added sub-data corresponding to the data block from the newly added data.

[0075] According to an embodiment of the present application, the data block in the second firmware may include at least one of the second data and the newly added data. Therefore, the instruction information for restoring the data block may indicate at least one of the first data and the newly added data. The restoration instruction information may include first instruction information for determining the storage space of the third data corresponding to the data block in the first space, and / or second instruction information for determining the newly added sub-data corresponding to the data block from the newly added data.

[0076] Optionally, determining whether the restoration indication information and the remaining restoration indication information indicate the same third data includes: determining whether the restoration indication information and the remaining restoration indication information include the same first indication information.

[0077] Optionally, if the restoration instruction information and the remaining restoration instruction information indicate the same third data, retaining the third data after restoring the data block includes:

[0078] The restoration indication information and the remaining restoration indication information include the same first indication information, a storage space for the third data is determined according to the same first indication information, and the third data is retained after the data block is restored.

[0079] Optionally, if the restoration indication information does not indicate the same third data as the remaining restoration indication information, determining the storage space where the third data is located as a free area after restoring the data block includes:

[0080] The restoration indication information does not include the same first indication information as the remaining restoration indication information, the storage space of the third data is determined according to the first indication information included in the restoration indication information, and the storage space of the third data is determined as a free area after the data block is restored.

[0081] If the restoration indication information M includes the first indication information A and the second indication information B, and there is a restoration indication information N among the other restoration indication information that includes the first indication information A and the second indication information C, it can be determined that the restoration indication information M and the remaining restoration indication information include the same first indication information, namely, the first indication information A.

[0082] As described above, the first indication information is used to determine the storage space of the third data corresponding to the data block in the first space. Therefore, the storage space of the third data corresponding to the data block in the first space can be determined based on the first indication information A. After determining the storage space of the third data, the data block can be restored based on the third data. Furthermore, after restoring the data block, the third data can be retained for use in the subsequent restoration process of the data block corresponding to the restoration indication information N.

[0083] If the restoration instruction information does not include the same first instruction information as the remaining restoration instruction information, after the data block is restored according to the first instruction information in the restoration instruction information, the storage space where the third data is located is determined as a free area.

[0084] Optionally, for each restoration instruction information, determining data required to restore the data block, and restoring the corresponding data block according to the determined data includes:

[0085] If the restoration indication information corresponding to the data block is the first indication information, determining a storage space for the third data corresponding to the data block according to the first indication information, and restoring the data of the data block according to the third data in the storage space and the differential data corresponding to the third data;

[0086] If the restoration instruction information corresponding to the data block is the second instruction information, determining the newly added sub-data corresponding to the data block from the newly added data according to the second instruction information, and determining the newly added sub-data as the data of the data block;

[0087] If the restoration indication information corresponding to the data block includes first indication information and second indication information, the storage space of the third data corresponding to the data block is determined according to the first indication information, and the target sub-data is restored according to the third data in the storage space and the differential data corresponding to the third data, the newly added sub-data is obtained according to the second indication information, and the data of the corresponding data block is obtained according to the target sub-data and the newly added sub-data.

[0088] Optionally, the storage space for the third data can be determined based on the first indication information, and the data block can be restored based on the third data in the storage space and the corresponding differential data. Optionally, the differential data corresponding to the data block can be determined, for example, based on the order of the current data blocks. For example, if the data blocks are restored sequentially, since the generated differential data are arranged sequentially, the differential data corresponding to the data block can be determined from all differential data based on the order of the data blocks.

[0089] Optionally, the newly added sub-data corresponding to the data block can be determined from the newly added data according to the second indication information. For example, the position of the newly added sub-data in the newly added data can be determined according to the order of the current data block. After the newly added sub-data is determined, the newly added sub-data can be determined as the data of the data block.

[0090] Optionally, the second indication information indicates the size of the newly added sub-data, which is represented by z. Since the newly added data are arranged in sequence, the newly added sub-data can be determined by the size of each newly added sub-data.

[0091] If the restoration indication information corresponding to the data block is the first indication information, the data of the data block can be restored according to the third data.

[0092] If the restoration instruction corresponding to the data block is the second instruction information, the data of the data block can be obtained by determining the newly added sub-data.

[0093] If the data block includes the first indication information and the second indication information, the target sub-data of the data block can be restored based on the third data, and the newly added sub-data can be determined. Then, the data of the data block can be obtained based on the correspondence between the first indication information and the second indication information. For example, the order of the target sub-data and the newly added sub-data can be determined based on the order of the first indication information and the second indication information, thereby obtaining the data of the data block.

[0094] Optionally, the first indication information includes a storage address offset of the third data and a size of the third data.

[0095] Determining, according to the first indication information, a storage space for third data corresponding to the data block includes:

[0096] Determining a first starting storage address of the first space;

[0097] Determine, according to the first starting storage address and the storage address offset, a starting storage address of the third data corresponding to the data block in the first space;

[0098] The storage space of the third data is determined according to the starting storage address of the third data in the first space and the size of the third data.

[0099] For example, for a data block, the first indication information of the third data corresponding to the data block can be expressed as (x, y), where x represents the storage address offset and y represents the size of the third data. Since the first indication information is generated by the server, x represents the offset from the second starting storage address of the second space where the server stores the first firmware.

[0100] After the terminal device determines the first indication information, it can determine the storage space of the third data in the first space based on the first indication information. For example, after determining the first indication information, the terminal device first determines the first starting storage address of the first space storing the first firmware. For ease of description, the following example uses the first starting storage address of the first space as 0. The starting storage address of the third data corresponding to the data block in the first space is x. Based on the starting storage address x and the size y of the third data, the storage space (x, y) of the third data can be determined.

[0101] Optionally, storing the restored data block in the first storage space in the first space according to the translation control information includes:

[0102] Determine each first subspace before the movement and each second subspace after the movement corresponding to each translation control information in the first space;

[0103] Determining whether a first storage space corresponding to the data block in the first space includes a first subspace;

[0104] If the first storage space does not include the first subspace, storing the data block in the first storage space;

[0105] If the first storage space includes a first subspace, the data in the first subspace is moved to the second subspace corresponding to the first subspace according to the translation control information corresponding to the first subspace, and the data block is stored in the first storage space after removing the first subspace.

[0106] Optionally, the translation control information is used to indicate each storage space before the movement and each storage space after the movement corresponding to the data to be moved in the first data.

[0107] After restoring the data of the data block, the terminal device can determine the storage space before movement and the storage space after movement indicated by each translation control information, and determine the corresponding first subspaces before movement and second subspaces after movement in the first space based on the storage space before movement and the storage space after movement.

[0108] After restoring the data of the data block, the terminal device determines the first storage space corresponding to the data block in the first space. For example, the terminal device may determine the first storage space of the data block in the first space according to the order of the data blocks.

[0109] After determining the first storage space for the data block, whether the first subspace is included in the first storage space can be determined by determining whether there is overlap between the first storage space and any first subspace based on the shift control information. If there is overlap between the first storage space and any first subspace or if any first subspace is within the range of the second storage space, then it can be determined that the first subspace is included in the first storage space.

[0110] If the first storage space does not include the first subspace, the data of the data block is stored in the first storage space.

[0111] If the first storage space includes at least one first subspace, data in the at least one first subspace is moved to each second subspace corresponding to the at least one first subspace according to the translation control information corresponding to the at least one first subspace. Finally, the data of the data block is stored in the first storage space after the first subspace is removed.

[0112] Optionally, for each piece of translation control information, the translation control information includes a storage address offset before the move, a storage address offset after the move, and a data size of the moved data.

[0113] The determining of each first subspace before the movement and each second subspace after the movement corresponding to each translation control information in the first space includes:

[0114] Determining a first starting storage address of the first space;

[0115] Determine, according to the first starting storage address, the storage address offset before the move, and the data size of the moved data, the corresponding first subspaces before the move in the first space;

[0116] The corresponding second subspaces after the move in the first space are determined according to the first starting storage address, the storage address offset after the move, and the data size of the moved data.

[0117] According to an embodiment of the present application, for each translation control information, the translation control information can be expressed as (x, y, z), where x represents the storage address offset before the move, y represents the storage address offset after the move, and z represents the data size of the moved data. Since the translation control information is generated by the server, the storage address offset refers to the offset relative to the second starting storage address of the second space of the server.

[0118] After determining the translation control information, the terminal device may first determine the first starting storage address of the first space. For ease of description, the following description is made by taking the first starting storage address of the first space as 0 as an example.

[0119] Based on the second starting storage address 0, the storage address offset before the move is x, and the data size z of the moved data, at least one first subspace (x, z) before the move corresponding to the second space is determined. Based on the second starting storage address 0, the storage address offset after the move is y, and the data size z of the moved data, a storage space (y, z) after the move corresponding to the second space is determined.

[0120] The terminal device can determine the first subspaces of each data item to be moved before the move and the corresponding second subspaces after the move by using the various address information included in the translation control information and the storage address of the first space storing the first firmware. The terminal device can move the first data in the first firmware based on both the restoration control information and the translation control information, restore the data block, and store the data block.

[0121] The solution provided in the embodiment of the present application parses the differential packet to obtain newly added data, each differential data, each restoration indication information and each translation control information; for each restoration indication information, the following operations are performed in sequence: determine the data required to restore the data block, and restore the corresponding data block based on the determined data; determine whether the restoration indication information indicates the same third data as the remaining restoration indication information, and if so, retain the third data after restoring the data block; store the restored data block in the first storage space in the first space according to the translation control information, that is, the embodiment of the present application can fully utilize the storage space of the first firmware in the terminal device by segmentedly restoring the second firmware according to the first firmware and the restoration indication information corresponding to the data block, thereby improving space utilization, and when there is repeated similar data, by forming a corresponding relationship between the repeated data and multiple data blocks, it is realized that multiple data blocks can be restored using one third data, and when the terminal device restores the data block, the movement operation on the terminal device's flash memory (Flash) is reduced, thereby improving overall performance.

[0122] Based on the same principle as the above software upgrade method, an embodiment of the present application provides another software upgrade method, which can be executed by a server and includes the following steps:

[0123] S201, in response to a software upgrade request for target software from a terminal device, determining newly added data in a second firmware, respective second data having similar data in a first firmware, and differential data between respective second data and first data in the first firmware;

[0124] S202: Divide the second firmware into multiple data blocks, and perform the following operations on each data block in sequence according to the order of the data blocks in the second firmware:

[0125] If fourth data is stored in the second storage space in the first firmware corresponding to the data block, the fourth data is moved to an idle area of the second space, where the fourth data is a repeated portion of the first data corresponding to at least two second data, and the second space is a space in the server for storing the first firmware;

[0126] S203, generating, based on the movement of the fourth data, translation control information of each fourth data whose storage position has been moved in the first data and restoration instruction information corresponding to each data block;

[0127] S204 : Generate a differential packet according to the newly added data, each differential data, restoration instruction information corresponding to each data block, and each translation control information.

[0128] The server may receive a software upgrade request from a terminal device, the software upgrade request including identification information of the target software of the terminal device. After the server determines the current version of firmware (first firmware) and the target version of firmware (second firmware) corresponding to the target software based on the identification information of the target software, the server may determine the first firmware and the second firmware from multiple firmware files stored on the server, or may obtain the first firmware from the terminal device and store it in its storage space. The space where the server stores the first firmware may be referred to as the second space.

[0129] The server can determine the storage space of the first firmware and the second firmware corresponding to the target software on the server, and can traverse and compare the first firmware and the second firmware starting from the starting byte of the second firmware to determine the maximum length of similar data in the first firmware and the second firmware. The method for determining the maximum length of similar data in the first firmware and the second firmware is not limited in the embodiment of the present application. For example, it can be determined by an existing differential algorithm. By traversing and comparing, the data newly added to the second firmware relative to the first firmware (hereinafter referred to as newly added data) and the second data stored in the similar data in the first firmware can be determined.

[0130] Among them, through the above comparison, the first correspondence between the second data in the second firmware and the corresponding similar data (i.e., the first data) in the first firmware can be determined. The first correspondence includes the storage space of the similar data corresponding to the second data in the first firmware, and the storage space may include a storage address and a data size. Among them, the storage address of the similar data in the first firmware can be the address offset of the similar data relative to the starting storage address of the first firmware on the server. For example, for any second data, its corresponding similar data can be expressed as (x, y), wherein x represents the offset of the similar data corresponding to the second data relative to the starting storage address of the first firmware on the server, and y represents the size of the similar data corresponding to the second data. Among them, the size of the data can also be called the length of the data, which can be expressed in kilobytes KB (Kilobyte).

[0131] After determining each second data in the second firmware and the corresponding first data in the first firmware, the server can divide the data in the second firmware into multiple data blocks. The embodiment of the present application does not limit the manner in which the second firmware is divided. Optionally, the server can divide the data obtained in the second firmware into multiple data blocks of the same size according to a set size. The set size can be set by the user or a default value. Optionally, the server can also divide the second firmware according to a data size with a certain regularity. Optionally, the server can also determine the manner in which the second firmware is divided based on the storage space size of the terminal device obtained.

[0132] Optionally, when dividing the data in the second firmware into a plurality of data blocks, the server may correspondingly divide the data in the first firmware into a corresponding plurality of data blocks, and determine a second corresponding relationship between the data blocks in the first firmware and the second firmware.

[0133] For each data block in the second firmware, the space of the data block size corresponding to the storage location of the data block in the second space can be called the second storage space. For any data block, if the second storage space corresponding to the data block stores fifth data, the fifth data in the second storage space is moved to the free area of the second space, wherein the fifth data belongs to the data other than the similar data corresponding to the data block in each first data, that is, if the second storage space corresponding to the data block stores other similar data other than the similar data corresponding to the data block, the other similar data in the second storage space is moved to the free area of the second space, wherein the free area refers to the other space in the first firmware except the space for storing the first data, that is, the free area refers to the space in the first firmware used to store data not used by the first firmware upgrade.

[0134] The fifth data may include fourth data, which is a repeated portion of the first data corresponding to at least two second data. If the fourth data is stored in the second storage space in the first firmware corresponding to the data block, the fourth data is moved to an idle area of the second space.

[0135] After completing the above operations on each data block, restoration indication information corresponding to each data block is generated. The restoration indication information of a data block is used to determine data required to restore the data block.

[0136] After completing the movement of the fifth data in the corresponding storage space for each data block, corresponding translation control information can be generated for each portion of the first data whose storage location has been moved. The translation control information corresponding to each fifth data portion is used to indicate the storage space before and after the movement corresponding to the fifth data portion. If the fifth data portion is a duplicate portion of the first data corresponding to two second data portions, i.e., the fourth data portion, restoration indication information for the two second data portions is determined based on the movement of the fourth data portion.

[0137] The server generates a differential packet from the generated newly added data, differential data, restoration instructions corresponding to each data block, and translation control information corresponding to each fifth data. Optionally, the differential packet can be compressed and sent to the terminal device, so that the terminal device upgrades to the second firmware based on the differential packet and the first firmware stored therein.

[0138] Alternatively, in actual applications, the server can perform a differential package generation process for any two versions of firmware, store the generated differential package on the server, and directly send the stored differential package to another terminal device when it requests the differential package. Alternatively, the server can pre-generate a differential package between two corresponding versions based on the multiple versions of the stored firmware, and send it to the terminal device when the terminal device requests the corresponding differential package.

[0139] The server generates a differential package according to the above rules and sends it to the terminal device, so that the terminal device obtains the second firmware according to the differential package and the first firmware upgrade.

[0140] Optionally, after dividing the second firmware into multiple data blocks, the software upgrade method of the embodiment of the present application further includes:

[0141] Based on the division results, the target sub-data and / or newly added sub-data included in each data block are determined, and the fifth data and differential data corresponding to each target sub-data are determined, wherein the target sub-data is the data belonging to the second data in the second firmware, and the newly added sub-data is the data belonging to the newly added data in the second firmware.

[0142] By dividing the data in the second firmware into multiple data blocks, according to the first correspondence relationship and the second correspondence relationship between the first firmware and the second firmware, the second data and the newly added data in the second firmware can be divided into target sub-data and newly added sub-data included in each data block, wherein the target sub-data can be data belonging to the second data located in a data block, and the newly added sub-data can be data belonging to the newly added data located in a data block.

[0143] After determining the target sub-data included in the data block, for each target sub-data, corresponding similar data in the first firmware can be determined based on the first correspondence between the first data and the second data, and corresponding differential data can be determined based on the target sub-data and the corresponding similar data. The method for determining differential data is not limited in this embodiment of the application; for example, an existing differential algorithm can be used to generate differential data.

[0144] When the similar data corresponding to the target sub-data in the first firmware is determined according to the first corresponding relationship between the first data and the second data, the two target sub-data may correspond to the same similar data.

[0145] Optionally, after determining the target sub-data and / or newly added sub-data included in each data block, generating the restoration indication information corresponding to each data block includes: determining the restoration indication information corresponding to the data block according to the target sub-data and / or newly added sub-data included in each data block.

[0146] For each data block, the data block may include target sub-data and / or newly added sub-data. The following will specifically describe the restoration instruction information corresponding to different situations of the data block.

[0147] Optionally, determining restoration instruction information corresponding to each data block according to each target sub-data and / or newly added sub-data included in the data block includes:

[0148] For each data block, if the data block is the target sub-data, the restoration indication information corresponding to the data block is the first indication information;

[0149] If the data block is newly added sub-data, the restoration indication information corresponding to the data block is the second indication information;

[0150] If the data block includes the target sub-data and the newly added sub-data, the restoration instruction information corresponding to the data block includes the first instruction information and the second instruction information.

[0151] The first indication information is used to determine the storage space of similar data corresponding to the target sub-data, and the second indication information is used to determine the newly added sub-data corresponding to the data block from the newly added data.

[0152] In the embodiments of the present application, the restoration instruction information corresponding to a data block may be different depending on the data included in the data block. If the data block is the target sub-data, that is, the data block only includes the target sub-data, then the restoration instruction information corresponding to the data block is the first instruction information; if the data block is the newly added sub-data, that is, the data block only includes the newly added sub-data, then the restoration instruction information corresponding to the data block is the second instruction information; if the data block includes at least one target sub-data and at least one newly added sub-data, then the restoration instruction information corresponding to the data block includes the first instruction information and the second instruction information.

[0153] If two newly added sub-data correspond to the same similar data, then the two newly added sub-data correspond to the same first indication information, and the data block including the two newly added sub-data includes the same first indication information.

[0154] After determining the restoration instruction information, the data required to restore the data block can be determined based on the restoration instruction information, and the corresponding data block can be restored. The embodiment of the present application can fully utilize the storage space of the first firmware in the terminal device by restoring the second firmware in segments based on the first firmware and the restoration instruction information corresponding to the data block, thereby improving space utilization. In addition, when there is repeated similar data, by forming a corresponding relationship between the repeated data and multiple data blocks, it is possible to restore multiple data blocks using a fourth data, thereby reducing the movement operation on the terminal device's flash memory when the terminal device restores the data block, thereby improving overall performance.

[0155] In order to more clearly illustrate the principle of the software upgrade method of the present application, the software upgrade process is described in detail below with specific examples. Figures 3a to 3d This is an example diagram of a software upgrade method provided in an embodiment of the present application. Optionally, the software upgrade method in an embodiment of the present application can be executed by a server.

[0156] Optionally, after determining the current version of firmware (hereinafter referred to as the first firmware) and the target version of firmware (hereinafter referred to as the second firmware) corresponding to the target software, the server can determine the correspondence between the data in the second firmware and the first firmware according to an existing differential algorithm.

[0157] Figure 3a A schematic diagram showing the correspondence between data in the second firmware and the first firmware.

[0158] According to an embodiment of the present application, by determining the above-described correspondence, the server can determine the newly added data in the second firmware, each second data that has similar data in the first firmware, and the first data in the first firmware that is similar to each second data. Optionally, the server can determine data in the first firmware other than the first data, hereinafter referred to as non-similar data, and the storage space for such data can be referred to as a free area.

[0159] Among them, new data refers to the data added to the second firmware relative to the first firmware, represented by D1, D2, D3, and D4; second data refers to data with similar data in the first firmware, represented by T1, T2, T3, T3', and T4; first data refers to the similar data corresponding to the second data in the second firmware in the first firmware, represented by S1, S2, S3, and S4; non-similar data refers to the data in the first firmware that is not used after upgrading to the second firmware, represented by K1, K2, K3, K4, and K5.

[0160] When determining the correspondence between the data in the first firmware and the second firmware, the server can determine the repeated portion of similar data corresponding to the second data. For example, Figure 3a The portion from the start of S3 to the vertical line E is similar data corresponding to T3, and the portion from the vertical line S to the end of S3 is similar data corresponding to T3'. The portion between the vertical lines S and E is repeated data. Therefore, a correspondence can be established between T3 and T3' and the corresponding portion of S3.

[0161] Figure 3b The first division process is shown. According to the division result, the target sub-data T11 contained in the second firmware can be determined, and according to the corresponding relationship determined above, the similar data corresponding to the target sub-data T11, that is, the corresponding part in S1, can be determined, and the differential data can be determined based on the corresponding parts in T11 and S1.

[0162] Since the second storage space corresponding to the first divided data block stores third data, namely, a portion of S3, denoted as S5, S5 in the second storage space needs to be moved to a free area of the second space, that is, S5 is moved to K2. For the third data S5 whose storage location has been moved, translation control information (x5, y5, z5) corresponding to the third data S5 is generated. This translation control information is used to indicate the storage space before and after the move corresponding to the third data S5.

[0163] After the translation operation is completed on the data block, restoration indication information corresponding to the data block is generated. Since the data block only includes the target sub-data T11, the restoration indication information is the first indication information (x1, y1).

[0164] Figure 3c The second division process is shown. According to the division result, the target sub-data T12 contained in the second firmware can be determined, and according to the corresponding relationship determined above, the similar data corresponding to the target sub-data T12 can be determined, that is, the corresponding part in S1, and the differential data can be determined based on the corresponding parts in T12 and S1.

[0165] Since the second storage space corresponding to the second divided data block stores third data, that is, a part of S3, where this part of data includes a part of the similar data and duplicate data corresponding to T3, these two parts can be respectively recorded as S6 and S6', and S6 and S6' in the second storage space need to be moved to the free area of the second space. At this time, T3 will be fragmented according to the movement of S6 and S6' data, and form a corresponding relationship between T6 and S6, and a corresponding relationship between T6' and S6'; T3' will be fragmented according to the movement of S6' data, and form a corresponding relationship between T6' and S6'. For the third data S6 and S6' whose storage location has moved, two translation control information (x6, y6, z6) and (x6', y6', z6') can be generated to indicate the storage space before the movement and the storage space after the movement corresponding to S6 and S6'.

[0166] After the translation operation is completed on the data block, restoration indication information corresponding to the data block is generated. Since the data block only includes the target sub-data T12, the restoration indication information is the first indication information (x2, y2).

[0167] Figure 3d The third division process is shown. According to the division result, the target sub-data T13 contained in the second firmware can be determined, and according to the corresponding relationship determined above, the similar data corresponding to the target sub-data T13 can be determined, that is, the corresponding part in S1, and the differential data can be determined based on the corresponding parts in T13 and S1.

[0168] Since the third data is stored in the second storage space corresponding to the data block divided for the third time, that is, the data includes a part of the repeated data and similar data corresponding to T3', the two parts can be respectively recorded as S7' and S7, and S7' and S7 in the second storage space need to be moved to the free area of the second space. At this time, T3 will be fragmented according to the movement of S7' data, and a corresponding relationship between T7' and S7' will be formed; T3' will be fragmented according to the movement of S7' and S7 data, and a corresponding relationship between T7' and S7' and a corresponding relationship between T7 and S7 will be formed. For the third data S7' and S7 whose storage positions have been moved, two translation control information (x7, y7, z7) and (x7', y7', z7') can be generated to indicate the storage space before the movement and the storage space after the movement corresponding to S7 and S7'.

[0169] After completing the translation operation on the data block, the restoration indication information corresponding to the data block is generated. Since the data block includes the target sub-data T13 and part of the data in the newly added data D1, the restoration indication information includes the first indication information (x3, y3) and the second indication information (z1), where the second indication information (z1) is used to indicate that the newly added sub-data of size z1 is obtained from the newly added data.

[0170] According to the above description, each target sub-data in the second firmware may form a corresponding relationship with each similar data in the first firmware, and at least two target sub-data may correspond to the same similar data.

[0171] According to an embodiment of the present application, when generating a differential packet, the server can directly move duplicate similar data and re-form a mapping relationship based on the moved duplicate similar data, without having to copy the duplicate similar data and move the two copied data parts separately, which greatly reduces the flash movement operation and improves the overall performance.

[0172] Based on the same principle as the above software upgrade, the embodiment of the present application provides a software upgrade device. Figure 4 As shown, the software upgrade device 400 includes: a parsing module 401 , a restoration control module 402 and a storage module 403 .

[0173] Parsing module 401, configured to parse the differential packet to obtain newly added data, differential data, restoration instruction information, and translation control information, wherein each differential data is differential data between the second data in the second firmware and the corresponding first data in the first firmware;

[0174] The restoration control module 402 is configured to sequentially perform the following operations for each restoration instruction information: determining data required to restore the data block, and restoring the corresponding data block according to the determined data;

[0175] determining whether the restoration instruction information and the remaining restoration instruction information indicate the same third data, wherein the third data is data belonging to the first data;

[0176] If the restoration instruction information and the remaining restoration instruction information indicate the same third data, retaining the third data after restoring the data block;

[0177] The storage module 403 is configured to store the restored data block in a first storage space in the first space according to the translation control information. The first space is a space in the terminal device for storing the first firmware.

[0178] Optionally, for each restoration indication information, the restoration indication information includes first indication information and / or second indication information.

[0179] Optionally, the first indication information is used to determine the storage space of the third data corresponding to the data block in the first space, and the second indication information is used to determine the newly added sub-data corresponding to the data block from the newly added data.

[0180] Optionally, the restoration control module 402 is further configured to determine whether the restoration instruction information and the remaining restoration instruction information include the same first instruction information;

[0181] If the restoration instruction information and the remaining restoration instruction information include the same first instruction information, the restoration control module 402 determines the storage space for the third data according to the same first instruction information, and retains the third data after restoring the data block;

[0182] If the restoration instruction information does not include the same first instruction information as the remaining restoration instruction information, the restoration control module 402 determines the storage space of the third data according to the first instruction information included in the restoration instruction information, and determines the storage space of the third data as a free area after restoring the data block.

[0183] Optionally, if the restoration indication information corresponding to the data block is the first indication information, the restoration control module 402 determines the storage space of the third data corresponding to the data block according to the first indication information, and restores the data of the data block according to the third data in the storage space and the differential data corresponding to the third data.

[0184] Optionally, if the restoration indication information corresponding to the data block is the second indication information, the restoration control module 402 determines the newly added sub-data corresponding to the data block from the newly added data according to the second indication information, and determines the newly added sub-data as the data of the data block.

[0185] Optionally, if the restoration indication information corresponding to the data block includes first indication information and second indication information, the restoration control module 402 determines the storage space of the third data corresponding to the data block based on the first indication information, and restores the target sub-data based on the third data in the storage space and the differential data corresponding to the third data, obtains the newly added sub-data based on the second indication information, and obtains the data of the corresponding data block based on the target sub-data and the newly added sub-data.

[0186] Optionally, the first indication information includes a storage address offset of the third data and a size of the third data.

[0187] Optionally, the restoration control module 402 is further configured to: determine a first starting storage address of the first space;

[0188] Determine, according to the first starting storage address and the storage address offset, a starting storage address of the third data corresponding to the data block in the first space;

[0189] The storage space of the third data is determined according to the starting storage address of the third data in the first space and the size of the third data.

[0190] Optionally, the restoration control module 402 is further configured to: determine each first subspace before the movement and each second subspace after the movement corresponding to each translation control information in the first space;

[0191] Determining whether a first storage space corresponding to the data block in the first space includes a first subspace;

[0192] If the first storage space does not include the first subspace, storing the data block in the first storage space;

[0193] If the first storage space includes a first subspace, the data in the first subspace is moved to the second subspace corresponding to the first subspace according to the translation control information corresponding to the first subspace, and the data block is stored in the first storage space after removing the first subspace.

[0194] Optionally, for each piece of translation control information, the translation control information includes a storage address offset before the move, a storage address offset after the move, and a data size of the moved data.

[0195] Optionally, the restoration control module 402 is further configured to: determine a first starting storage address of the first space;

[0196] Determine, according to the first starting storage address, the storage address offset before the move, and the data size of the moved data, the corresponding first subspaces before the move in the first space;

[0197] The corresponding second subspaces after the move in the first space are determined according to the first starting storage address, the storage address offset after the move, and the data size of the moved data.

[0198] The solution provided in the embodiment of the present application parses the differential packet to obtain newly added data, each differential data, each restoration indication information and each translation control information; for each restoration indication information, the following operations are performed in sequence: determine the data required to restore the data block, and restore the corresponding data block based on the determined data; determine whether the restoration indication information indicates the same third data as the remaining restoration indication information, and if so, retain the third data after restoring the data block; store the restored data block in the first storage space in the first space according to the translation control information, that is, the embodiment of the present application can restore the second firmware in segments according to the first firmware and the restoration indication information corresponding to the data block, thereby fully utilizing the storage space of the first firmware in the terminal device and improving space utilization. In addition, when there is repeated similar data, by forming a corresponding relationship between the repeated data and multiple data blocks, the restoration of multiple data blocks using one third data is achieved, reducing the movement operation on the terminal device's flash memory when the terminal device restores the data block, thereby improving overall performance.

[0199] Based on the same principle as the above software upgrade, the embodiment of the present application provides another software upgrade device, which can be a server for generating differential packets. Figure 5 As shown, the software upgrade device 500 includes: a data determination module 501, a translation control module 502, an information generation module 503 and a differential packet generation module 504.

[0200] a data determination module, configured to determine, in response to a software upgrade request for target software from a terminal device, newly added data in the second firmware, respective second data having similar data in the first firmware, and differential data between respective second data and the first data in the first firmware;

[0201] The translation control module is used to divide the second firmware into multiple data blocks and perform the following operations on each data block in sequence according to the order of the data blocks in the second firmware:

[0202] If fourth data is stored in the second storage space in the first firmware corresponding to the data block, the fourth data is moved to an idle area of the second space, where the fourth data is a repeated portion of the first data corresponding to at least two second data, and the second space is a space in the server for storing the first firmware;

[0203] an information generating module, configured to generate, according to the movement of the fourth data, translation control information of each fourth data whose storage position has been moved in the first data and restoration indication information corresponding to each data block;

[0204] The differential packet generation module is used to generate a differential packet according to the newly added data, each differential data, the restoration instruction information corresponding to each data block and each translation control information.

[0205] The embodiment of the present application can restore the second firmware in segments according to the first firmware and the restoration indication information corresponding to the data block, thereby fully utilizing the storage space of the first firmware in the terminal device and improving space utilization. In addition, when there is repeated similar data, by forming a corresponding relationship between the repeated data and multiple data blocks, it is possible to restore multiple data blocks using one third data, thereby reducing the movement operation of the terminal device's flash memory when the terminal device restores the data block, and improving the overall performance.

[0206] The present application embodiment provides an electronic device, such as Figure 6 As shown, Figure 6 The electronic device 6000 shown includes a processor 6001 and a memory 6003. The processor 6001 and the memory 6003 are connected, for example, via a bus 6002. Optionally, the electronic device 6000 may further include a transceiver 6004. It should be noted that in actual applications, the number of transceivers 6004 is not limited to one, and the structure of the electronic device 6000 does not constitute a limitation on the embodiments of the present application.

[0207] The processor 6001 is used in the embodiment of the present application to implement Figure 4 The functions of the parsing module 401, the restoration control module 402 and the storage module 403 are shown, and Figure 5 The functions of the data determination module 501, the translation control module 502, the information generation module 503 and the differential packet generation module 504 are shown. The transceiver 6004 includes a receiver and a transmitter, and the transceiver 6004 is applied in the embodiment of the present application.

[0208] Processor 6001 may be a CPU, a general-purpose processor, a DSP, an ASIC, an FPGA, or other programmable logic device, a transistor logic device, a hardware component, or any combination thereof. It may implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 6001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.

[0209] The bus 6002 may include a path for transmitting information between the above components. The bus 6002 may be a PCI bus or an EISA bus, etc. The bus 6002 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one thick line is used in the diagram, but this does not mean that there is only one bus or one type of bus.

[0210] The memory 6003 may be a ROM or other type of static storage device that can store static information and instructions, a RAM or other type of dynamic storage device that can store information and instructions, or an EEPROM, a CD-ROM or other optical disk storage, an optical disc storage (including a compact disc, a laser disc, an optical disc, a digital versatile disc, an additional data optical disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to these.

[0211] The memory 6003 is used to store the application code for executing the solution of the present application, and the execution is controlled by the processor 6001. The processor 6001 is used to execute the application code stored in the memory 6003 to implement Figure 4 The software upgrade device 400 provided in the embodiment shown and Figure 5 The illustrated embodiment provides actions of the software upgrade device 500.

[0212] The present invention provides a computer-readable storage medium having a computer program stored thereon. When executed by a processor, the computer-readable storage medium can implement the software upgrade method described above. The computer-readable storage medium provided in the present invention is applicable to any of the above-described methods. Details thereof will not be given here.

[0213] It should be understood that although the steps in the flowcharts of the accompanying drawings are shown in sequence as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the flowcharts of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0214] The above descriptions are only partial embodiments of the present invention. It should be pointed out that ordinary technicians in this technical field can make several improvements and modifications without departing from the principles of the present invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.

Claims

1. A software upgrade method, characterized in that: include: Parsing the differential packet to obtain newly added data, differential data, restoration instruction information, and translation control information, wherein each differential data is differential data between second data in the second firmware and corresponding first data in the first firmware, the first firmware being the firmware of the current version of the target software to be upgraded, and the second firmware being the firmware of the target version to which the target software is to be upgraded; the second data being data in the second firmware that has similar data in the first firmware; and the first data being data in the first firmware that is similar to the second data; For each restore instruction, do the following in order: Determine the data required to restore the data block, and restore the corresponding data block according to the determined data; determining whether the restoration instruction information and the remaining restoration instruction information indicate the same third data, wherein the third data is data belonging to the first data; If the restoration instruction information and the remaining restoration instruction information indicate the same third data, retaining the third data after restoring the data block; Determine a first storage space of the restored data block in the first space, and store the restored data block in the first storage space in the first space according to the translation control information, where the first space is a space in the terminal device for storing the first firmware.

2. The method according to claim 1, characterized in that For each restoration instruction information, the restoration instruction information includes first instruction information and / or second instruction information. The first indication information is used to determine the storage space of the third data corresponding to the data block in the first space, and the second indication information is used to determine the newly added sub-data corresponding to the data block from the newly added data.

3. The method according to claim 2, characterized in that The determining whether the restoration instruction information and the remaining restoration instruction information indicate the same third data includes: determining whether the restoration instruction information and the remaining restoration instruction information include the same first instruction information; If the restoration instruction information and the remaining restoration instruction information indicate the same third data, retaining the third data after restoring the data block includes: The restoration indication information and the remaining restoration indication information include the same first indication information, a storage space for the third data is determined according to the same first indication information, and the third data is retained after the data block is restored.

4. The method according to claim 2 or 3, characterized in that For each restoration instruction information, determining data required to restore the data block, and restoring the corresponding data block according to the determined data, including: If the restoration indication information corresponding to the data block is the first indication information, determining a storage space for the third data corresponding to the data block according to the first indication information, and restoring the data of the data block according to the third data in the storage space and the differential data corresponding to the third data; If the restoration instruction information corresponding to the data block is the second instruction information, determining the newly added sub-data corresponding to the data block from the newly added data according to the second instruction information, and determining the newly added sub-data as the data of the data block; If the restoration indication information corresponding to the data block includes first indication information and second indication information, the storage space of the third data corresponding to the data block is determined according to the first indication information, and the target sub-data is restored according to the third data in the storage space and the differential data corresponding to the third data, the newly added sub-data is obtained according to the second indication information, and the data of the corresponding data block is obtained according to the target sub-data and the newly added sub-data.

5. The method according to claim 4, characterized in that The first indication information includes a storage address offset of the third data and a size of the third data; The determining, according to the first indication information, a storage space for the third data corresponding to the data block includes: Determining a first starting storage address of the first space; Determine, according to the first starting storage address and the storage address offset, a starting storage address of the third data corresponding to the data block in the first space; The storage space of the third data is determined according to the starting storage address of the third data in the first space and the size of the third data.

6. The method according to claim 1, characterized in that The step of storing the restored data block in the first storage space in the first space according to the translation control information includes: Determine each first subspace before the movement and each second subspace after the movement corresponding to each translation control information in the first space; Determining whether a first storage space corresponding to the data block in the first space includes a first subspace; If the first storage space does not include the first subspace, storing the data block in the first storage space; If the first storage space includes a first subspace, the data in the first subspace is moved to the second subspace corresponding to the first subspace according to the translation control information corresponding to the first subspace, and the data block is stored in the first storage space after removing the first subspace.

7. The method according to claim 6, characterized in that For each translation control information, the translation control information includes a storage address offset before the move, a storage address offset after the move, and a data size of the moved data; The determining of each first subspace before the movement and each second subspace after the movement corresponding to each translation control information in the first space includes: Determining a first starting storage address of the first space; Determine, according to the first starting storage address, the storage address offset before the move, and the data size of the moved data, the corresponding first subspaces before the move in the first space; The corresponding second subspaces after the move in the first space are determined according to the first starting storage address, the storage address offset after the move, and the data size of the moved data.

8. A software upgrade method, characterized in that: include: In response to a software upgrade request for target software from a terminal device, determining newly added data in the second firmware, each second data having similar data in the first firmware, and differential data between each second data and the first data in the first firmware, wherein the first firmware is firmware of a current version of the target software to be upgraded, and the second firmware is firmware of a target version to which the target software is to be upgraded; The second data is data in the second firmware that is similar to data in the first firmware; The first data is similar data to the second data in the first firmware; Divide the second firmware into multiple data blocks, and perform the following operations on each data block in sequence according to the order of the data blocks in the second firmware: If fourth data is stored in the second storage space in the first firmware corresponding to the data block, the fourth data is moved to a free area of the second space, the fourth data being a repeated portion of the first data corresponding to at least two second data, the second space being a space in the server for storing the first firmware, and the second storage space being a space of the size of the data block corresponding to the storage position of the data block in the second firmware; generating, according to the movement of the fourth data, translation control information of each fourth data whose storage position has been moved in the first data and restoration indication information corresponding to each data block; A differential packet is generated according to the newly added data, each differential data, the restoration instruction information corresponding to each data block, and each translation control information.

9. A software upgrade device, characterized in that: include: a parsing module, configured to parse the differential packet to obtain newly added data, each differential data, each restoration instruction information, and each translation control information, wherein each differential data is differential data between second data in the second firmware and corresponding first data in the first firmware, the first firmware being the firmware of the current version of the target software to be upgraded, and the second firmware being the firmware of the target version to which the target software is to be upgraded; the second data being data in the second firmware to which similar data exists in the first firmware; and the first data being data in the first firmware that is similar to the second data; The restoration control module is used to perform the following operations in sequence for each restoration instruction: Determine the data required to restore the data block, and restore the corresponding data block according to the determined data; determining whether the restoration instruction information and the remaining restoration instruction information indicate the same third data, wherein the third data is data belonging to the first data; If the restoration instruction information and the remaining restoration instruction information indicate the same third data, retaining the third data after restoring the data block; A storage module is used to determine the first storage space of the restored data block in the first space, and store the restored data block in the first storage space in the first space according to the translation control information. The first space is the space in the terminal device for storing the first firmware.

10. A software upgrading device, characterized in that: include: a data determination module, configured to determine, in response to a software upgrade request for target software from a terminal device, newly added data in a second firmware, respective second data having similar data in a first firmware, and differential data between respective second data and the first data in the first firmware, wherein the first firmware is firmware of a current version of the target software to be upgraded, and the second firmware is firmware of a target version to which the target software is to be upgraded; The second data is data in the second firmware that is similar to data in the first firmware; The first data is similar data to the second data in the first firmware; The translation control module is used to divide the second firmware into multiple data blocks and perform the following operations on each data block in sequence according to the order of the data blocks in the second firmware: If fourth data is stored in the second storage space in the first firmware corresponding to the data block, the fourth data is moved to a free area of the second space, where the fourth data is a repeated portion of the first data corresponding to at least two second data, the second space is a space in the server for storing the first firmware, and the second storage space is a space in the first firmware that is the same as the storage position of the data block in the second firmware and has the same size as the data block; an information generating module, configured to generate, according to the movement of the fourth data, translation control information of each fourth data whose storage position has been moved in the first data and restoration indication information corresponding to each data block; The differential packet generation module is used to generate a differential packet according to the newly added data, each differential data, the restoration instruction information corresponding to each data block and each translation control information.

11. An electronic device, characterized in that: include: processor and memory; The memory is used to store operation instructions; The processor is configured to execute the software upgrade method according to any one of claims 1 to 8 by calling the operation instruction.

12. A computer-readable storage medium, characterized in that The computer-readable storage medium is used to store a computer program. When the computer program is executed by a processor, the processor executes the software upgrading method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Differential upgrading method and device, storage medium and computer equipment

    CN111796856A

  • Method and equipment for formatting user space storage area in firmware upgrading process

    CN112230969A