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

By determining the storage space relationship between differential data and similar data during the software upgrade process, the problem of insufficient recycling and utilization of storage resources in terminal devices is solved, and efficient recycling and utilization of storage space is achieved.

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

Patent Information

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

AI Technical Summary

Technical Problem

In the prior art, terminal equipment fails to effectively utilize storage space during software upgrade, resulting in insufficient recycling and utilization of storage resources.

Method used

By obtaining the upgrade control information in the differential package, the storage space relationship between the differential data and similar data in the terminal device is determined, and the corresponding relationship between the differential data and similar data is realized, thereby freeing up the storage space during the upgrade process.

Benefits of technology

It realizes efficient recycling and utilization of storage space during software upgrade process, and improves the efficiency of storage resources utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113986314B_ABST
    Figure CN113986314B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide a software upgrade method, device, electronic device and computer-readable storage medium, which relate to the field of computer technology. The method includes: in response to an upgrade request, obtaining a corresponding differential packet, the differential packet including upgrade control information and differential data corresponding to each of the multiple target sub-data, the upgrade control information including position indication information, the position indication information being used to determine the storage space of the similar data corresponding to each differential data and each first data in the terminal device, and for each differential data obtained by parsing the differential packet, the upgrade of the second firmware can be completed based on the multiple differential data and the upgrade control information. Through the solution of the present application, since there is a one-to-one correspondence between each differential data and the corresponding similar data in the storage space of the terminal device, after the upgrade is performed based on the differential data, the similar data corresponding to the differential data can be deleted, which is conducive to the recycling of storage resources.
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. Specifically, the present application relates 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 prior art, a terminal device has storage space for storing differential packets. Usually, data in the current version of the software firmware needs to be deleted when the target version of the firmware is upgraded, which is not conducive to the recycling of storage resources in the storage space. 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 one aspect, an embodiment of the present application provides a software upgrade method, the method comprising:

[0006] In response to an upgrade request for target software, obtaining a differential package corresponding to the target software, the differential package including upgrade control information and differential data corresponding to each of a plurality of target sub-data, the target sub-data being sub-data included in the second firmware for which similar data exists in the first firmware;

[0007] The upgrade control information includes location indication information, which is used to determine the storage space of similar data corresponding to each differential data and each first data in the terminal device, where the first data is the same data in the similar data corresponding to the two target sub-data;

[0008] Parse the differential packet to obtain multiple differential data and upgrade control information;

[0009] The upgrade of the second firmware is completed based on the plurality of differential data and the upgrade control information.

[0010] On the other hand, an embodiment of the present application provides a software upgrade device, which includes:

[0011] a differential package acquisition module, configured to, in response to an upgrade request for target software, acquire a differential package corresponding to the target software, wherein the differential package includes upgrade control information and differential data corresponding to each of a plurality of target sub-data, wherein the target sub-data refers to sub-data included in the second firmware that has similar data in the first firmware;

[0012] The upgrade control information includes location indication information, which is used to determine the storage space of the similar data corresponding to each differential data and each first data in the terminal device, where the first data is the same data in the similar data corresponding to the two target sub-data;

[0013] The differential packet parsing module is used to parse the differential packet to obtain multiple differential data and upgrade control information;

[0014] The upgrading module is used to complete the upgrading of the second firmware based on the plurality of differential data and the upgrading control information.

[0015] Optionally, when completing the upgrade of the second firmware based on the plurality of differential data and the upgrade control information, the upgrade module is specifically configured to: determine, according to the upgrade control information, a first storage space in the terminal device for similar data corresponding to each differential data, and a second storage space in the terminal device for each first data; and for each differential data, if the first storage space corresponding to the differential data includes the second storage space, perform the following operations:

[0016] If the first data exists in the second storage space, the first data is stored in a designated storage space, target data corresponding to the differential data is obtained based on similar data in the first storage space corresponding to the differential data and the differential data, and the similar data in the first storage space is deleted;

[0017] If the first data does not exist in the second storage space, the first data corresponding to the differential data is obtained from the designated storage space, and based on the differential data, the data in the first storage space corresponding to the differential data, and the first data, the target data corresponding to the differential data is obtained, and similar data in the first storage space is deleted.

[0018] Optionally, the location indication information includes a first starting storage address of the first firmware in the server, first indication information of each first data, and a first correspondence between each differential data and its corresponding similar data; the first indication information of a first data is the first storage location information of the first data in the server relative to the first starting storage address; the second indication information is the second storage location information of the similar data corresponding to each differential data in the server relative to the first starting storage address;

[0019] When the above-mentioned upgrade module determines the first storage space in the terminal device of the similar data corresponding to each differential data and the second storage space in the terminal device of each first data according to the upgrade control information, it is specifically used to: determine the second indication information of the similar data corresponding to each differential data based on the first correspondence, and obtain the second starting storage address of the first firmware in the terminal device; for each differential data, determine the first storage space in the terminal device of the similar data corresponding to the differential data based on the second storage position information and the second starting storage address corresponding to the differential data; for each first data, determine the second storage space in the terminal device of the first data based on the first storage position information and the second starting storage address of the first data.

[0020] Optionally, for each first data, the first storage location information includes a first address offset of the first data relative to the first starting storage address, and a first data length of the first data; when the upgrade module determines, for each first data, the second storage space of the first data in the terminal device based on the first storage location information and the second starting storage address of the first data, the upgrade module is specifically configured to: for each first data, determine, based on the first address offset and the second starting storage address of the first data, a third starting storage address corresponding to the first data in the terminal device, and determine, based on the third starting storage address and the first data length, the second storage space of the first data in the terminal device;

[0021] For each differential data, the above-mentioned second storage location information includes the second address offset of the similar data corresponding to the differential data relative to the first starting storage address, and the second data length of the similar data corresponding to the differential data; when the above-mentioned upgrade module determines the first storage space of the similar data corresponding to the differential data in the terminal device based on the second storage location information and the second starting storage address corresponding to the differential data for each differential data, it is specifically used to: for each differential data, based on the second address offset and the second starting storage address corresponding to the differential data, determine the fourth starting storage address corresponding to the similar data corresponding to the differential data in the terminal device; based on the fourth starting storage address and the second data length, determine the first storage space of the similar data corresponding to the differential data in the terminal device.

[0022] Optionally, the upgrade request includes identification information of the target software, including the software identification and the version identification of the current version. The differential package is generated by the server in the following manner:

[0023] Based on the above identification information, the first firmware and the second firmware of the target software are determined, and the data in the second firmware is divided into multiple sub-data; based on the first firmware and the second firmware, the target sub-data in the multiple sub-data and the similar data corresponding to each target sub-data are determined; for each target sub-data, if the similar data corresponding to at least two target sub-data contain the same data, the same data is used as the first data corresponding to the at least two target sub-data, and the first indication information corresponding to the first data is generated; the differential data between each target sub-data and the corresponding similar data is determined, the second indication information of each similar data is generated, and a first corresponding relationship between each differential data and the second indication information of the corresponding similar data is established; the first starting storage address of the first firmware in the server is obtained, and based on the first corresponding relationship, each first indication information and the first starting storage address, the upgrade control information is generated; based on the upgrade control information and the differential data, a differential package is generated.

[0024] Optionally, the server further performs the following operations:

[0025] Based on the first firmware and the second firmware, determining a third storage space in the server for second data in the first firmware, where the second data refers to data that is not included in the second firmware and is not required for the upgrade; for each piece of first data, determining a target storage space for the first data in the third storage space based on the storage space required for the first data, generating third indication information corresponding to the first data based on the target storage space, and establishing a second correspondence between the first indication information and the third indication information corresponding to each piece of first data; wherein the upgrade control information also includes the second correspondence;

[0026] When the above-mentioned upgrade module saves the first data to the designated storage space, it is specifically used to: determine the third indication information corresponding to the first indication information corresponding to the data based on the above-mentioned second correspondence relationship; based on the third indication information and the second starting storage address, determine the second data corresponding to the third indication information in the fourth storage space of the terminal device, and use the fourth storage space as the designated storage space corresponding to the first data; delete the data in the fourth storage space, and copy the first data to the fourth storage space.

[0027] Optionally, for each differential data, if the first storage space corresponding to the differential data does not include the second storage space, the above-mentioned upgrade module is also used to: obtain the target data corresponding to the differential data based on the similar data in the first storage space corresponding to the differential data and the differential data, and delete the similar data in the first storage space.

[0028] Optionally, if the third storage space includes multiple discontinuous fifth storage spaces; for each first data, when the above-mentioned server determines the target storage space of the first data in the third storage space based on the storage space size required for the first data, it is specifically used to: determine the space size of each fifth storage space; based on the storage space size required for the first data, determine the target storage space corresponding to the first data in each fifth storage space, the above-mentioned target storage space includes at least one fifth storage space whose target space size is not less than and is closest to the required storage space size, and the target space size is the space size corresponding to at least one fifth storage space.

[0029] On the other hand, an embodiment of the present application further provides an electronic device, which includes a memory and a processor, wherein a computer program is stored in the memory, and the processor executes the software upgrade method provided in any optional embodiment of the present application when running the computer program.

[0030] On the other hand, an embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the processor executes the software upgrade method provided in any optional embodiment of the present application.

[0031] In another aspect, embodiments of the present application further provide a computer program product or computer program that, when executed on a computer device, causes the computer device to perform any of the optional implementation methods provided herein. The computer program product or computer program includes computer instructions stored in a computer-readable storage medium. A processor of the computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the software upgrade method provided in any of the optional implementation methods of the present application.

[0032] The beneficial effects brought about by the technical solution provided by the present application are: the solution provided by the embodiment of the present application obtains the corresponding differential package when the target software needs to be upgraded, that is, in response to the upgrade request. In the process of upgrading based on each differential data in the differential package, for each differential data obtained by parsing, the storage space of the similar data of each differential data in the terminal device can be determined based on the upgrade control information, so that there is a one-to-one correspondence between each differential data and the storage space of the corresponding similar data in the terminal device. Then, for each differential data, when upgrading based on the differential data and the similar data corresponding to the differential data, the target data of the differential data can be upgraded while deleting the data in the storage space where the similar data is located to release the storage space, so that the storage space can be recycled.

[0033] Additional aspects and advantages of the present application will be given in part in the following description, which will become apparent from the following description, or will be learned through practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] 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.

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

[0036] Figure 2 A schematic diagram of the same data provided in an embodiment of the present application;

[0037] Figure 3 A schematic diagram of another embodiment of the present application providing the same data;

[0038] Figure 4 A schematic diagram of two adjacent first storage spaces including a second storage space provided in an embodiment of the present application;

[0039] Figure 5 A schematic diagram of a target storage space provided in an embodiment of the present application;

[0040] Figure 6 A schematic diagram of the structure of a software upgrade system provided in an embodiment of the present application;

[0041] Figure 7 A schematic diagram of a difference table TB1 and a free list TB2 provided in an embodiment of the present application;

[0042] Figure 8 A schematic diagram of another difference table TB1 and free list TB2 provided in an embodiment of the present application;

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

[0044] Figure 10 This is a structural diagram of an electronic device 4000 provided in an embodiment of the present application. DETAILED DESCRIPTION

[0045] The following describes in detail embodiments of the present application. Examples of the embodiments 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.

[0046] 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.

[0047] In the prior art, taking the network environment of embedded devices as an example, due to reasons such as program fault repair and performance improvement, the device needs to be remotely upgraded, such as OTA (over the air) upgrade. Generally, the online firmware update of the embedded device is implemented over a Wi-Fi network, providing users with a better service version. The general implementation process of the differential upgrade solution is as follows: the target version of the firmware (new firmware) of the software to be upgraded is divided into multiple sub-data. For each sub-data, similar data corresponding to the sub-data is found in the current version of the firmware (old firmware). If similar data is found, the similar data in the current version of the firmware is subtracted from the corresponding sub-data. The difference value is mostly 0, which can make the data size of the resulting differential packet very small. In the process of determining the similar data corresponding to the sub-data, there may be at least two similar data corresponding to the sub-data containing the same data. Therefore, in the process of restoring and upgrading based on the differential data corresponding to the sub-data, the storage resources corresponding to the current version of the firmware in the device to be upgraded (the storage resources corresponding to the same data in the device to be upgraded) need to be used multiple times, which is not conducive to the recycling of storage resources in the device to be upgraded.

[0048] This application addresses the problem in the prior art whereby corresponding storage resources in the device to be upgraded are reused during a differential upgrade, which is detrimental to the recycling of storage resources in the device to be upgraded. This application proposes a software upgrade method to recycle existing storage resources in the device to be upgraded. This application is applicable to any scenario where the current version of software needs to be upgraded to a target version of software, and is applicable to any differential upgrade method.

[0049] Based on the application scenarios described above, 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 or a server cluster or distributed system composed of multiple physical servers. 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, and a smart car device.

[0050] The following specific embodiments describe in detail the technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[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 A flow chart of a software upgrade method provided in an embodiment of the present application is shown. The method can be executed by an electronic device, wherein the electronic device can be a terminal device or a server.

[0053] like Figure 1 As shown in , the method may include the following steps:

[0054] Step S110: In response to an upgrade request for the target software, a differential package corresponding to the target software is obtained and stored. The differential package includes upgrade control information and differential data corresponding to each of the multiple target sub-data. The target sub-data refers to sub-data contained in the second firmware that has similar data in the first firmware. The first firmware is the current version of the firmware, and the second firmware is the target version of the firmware. The upgrade control information includes position indication information, which is used to determine the storage space in the terminal device for each first data and similar data corresponding to each differential data. The first data is the same data in the similar data corresponding to the two target sub-data.

[0055] If the executor of this method is a user terminal, then in response to an upgrade request for the target software, obtaining the differential package corresponding to the target software may include the following steps: sending an upgrade request for the target software to the server, wherein the upgrade request includes identification information of the target software, and receiving the differential package sent by the server based on the identification information.

[0056] If the executor of this method is a server, then in response to an upgrade request for the target software, obtaining the differential package corresponding to the target software may include the following steps: receiving an upgrade request for the target software sent by a user terminal, the upgrade request including identification information of the target software, determining the differential package corresponding to the identification information based on the identification information, and sending the differential package to the user terminal.

[0057] It is understandable that before the server sends the differential packet to the user terminal, it usually encodes the differential packet first, and then sends the encoded differential packet to the user terminal. When the user terminal receives the encoded differential packet, it first decodes it to obtain the differential packet, and then performs subsequent processing on the differential packet.

[0058] Among them, the above-mentioned target software refers to the operating system or application that needs to be upgraded. If the target software is an application, the application can be any one of the applications installed by the user terminal. When a certain application needs to be upgraded, an upgrade response can be generated based on the user's consent to the upgrade inquiry request of the target software. The upgrade inquiry request can be an upgrade inquiry request sent by the server to the user terminal that has installed the certain application according to the set rules. For example, it can be an upgrade inquiry request sent by the server to the user terminal according to the upgrade cycle. Based on this request, an option of whether to upgrade can be displayed on the client interface of the user terminal. The option includes an option to agree to the upgrade and an option to disagree to the upgrade. If the user chooses the option to agree to the upgrade, an upgrade request is generated and sent to the server; if the user chooses the option to disagree to the upgrade, no processing is performed.

[0059] The above-mentioned upgrade request includes the identification information of the target software. After receiving the upgrade request, the server will determine which software needs to be upgraded and the current version of the firmware of the target software based on the identification information, and generate a differential package based on the current version of the firmware of the target software and the target version of the firmware. Among them, the difference between the current version of the software and the target version of the software is called a differential package. After downloading the differential package on the server side, the target version of the software can be restored on the user terminal side based on the differential package. Among them, 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 upgrade request, the target software is to be upgraded from version 2.0 to version 3.0. The differential package generated based on the current version of the firmware and the target version of the firmware is only used to upgrade the target software from the current version to the target version.

[0060] The identification information of the target software is used to identify the identity of the software. For example, the identification information may include the version identification of the target software's firmware. Based on the version identification, the current version of the target software, i.e., the version of the target software currently installed on the user terminal, can be determined. A server may correspond to multiple software programs. The identification information may also include the software identification of the target software. Based on the software identification, the server can determine which software among the multiple software programs corresponding to the server the target software corresponds to. The identification information may be represented by at least one of text, characters, and numbers. The specific form of the identification information is not limited in this application.

[0061] The above-mentioned position indication information includes the first starting storage address of the first firmware in the server, the first indication information of each first data, and the first correspondence between each differential data and the second indication information of the corresponding similar data; the first indication information of a first data is the first storage position information of the first data in the server relative to the first starting storage address; the second indication information is the second storage position information of the similar data corresponding to each differential data in the server relative to the first starting storage address.

[0062] The location indication information is used to indicate the storage location of each first data item in the server's storage space, as well as the storage location of similar data items of each differential data item in the server's storage space. For each first data item, the first indication information is used to indicate the storage location of the first data item in the server's storage space, and for each similar data item of the differential data item, the second indication information is used to indicate the storage location of the similar data item of the differential data item in the server's storage space.

[0063] Optionally, the above-mentioned location indication information may include a starting storage address and an ending storage address in the storage space of the server, and the storage space corresponding to the data corresponding to the location indication information in the storage space of the server can be determined based on the starting storage address and the ending storage address. Alternatively, the above-mentioned location indication information may include a starting storage address and a data length in the storage space of the server, and the storage space corresponding to the data corresponding to the location indication information in the storage space of the server can be determined based on the starting storage address and the data length. The storage space size corresponding to a data length is the storage space size corresponding to the data corresponding to the location indication information in the server.

[0064] The specific implementation method of the server generating a differential package based on the current version of the firmware and the target version of the firmware is as follows: based on the identification information, determine the first firmware and the second firmware of the target software, and based on the first firmware and the second firmware, determine the target sub-data in the multiple sub-data and the similar data corresponding to each target sub-data; for each target sub-data, if the similar data corresponding to at least two target sub-data contain the same data, then use the same data as the first data corresponding to the at least two target sub-data, and generate first indication information corresponding to the first data; determine the differential data between each target sub-data and the corresponding similar data, generate second indication information corresponding to each similar data, and establish a first corresponding relationship between each differential data and the second indication information of the corresponding similar data; obtain the first starting storage address of the first firmware in the server, and generate upgrade control information based on the first corresponding relationship, each first storage space identifier and the first starting storage address; generate a differential package based on the upgrade control information and each differential data.

[0065] The differential package refers to the information required to upgrade the current version of the target software to the target version. The differential package contains upgrade control information and differential data. During the upgrade, the differential data and the data of the first firmware stored on the device to be upgraded are controlled based on the upgrade control information to restore the data of the second firmware of the target version.

[0066] Optionally, the above-mentioned division of the data in the second firmware into multiple sub-data can be achieved by the following steps: determining the second firmware storage space where the data of the second firmware is located; dividing the second firmware storage space according to the set space size to obtain multiple sub-storage spaces, and treating the data corresponding to each storage space in the second firmware as a sub-data.

[0067] The second firmware storage space containing the data of the second firmware can be divided according to the set space size, and the data corresponding to each sub-storage space is a sub-data. It should be noted that since the size of the second firmware storage space may not be an integer multiple of the set space size, the size of the final storage space obtained by the division may be smaller than the set space size.

[0068] The above division is based on a set space size. The data size corresponding to the set space size is fixed. Alternatively, the data can be divided based on the set data size. Specifically, the second firmware data can be divided based on the set data size to obtain multiple sub-data, each with the set data size. It should be noted that in actual applications, since the data size of the second firmware data may not be an integer multiple of the set data size, the data size of the final sub-data obtained by the division may be smaller than the set data size.

[0069] The data in the first firmware and the data in the second firmware are typically binary numbers. Thus, similar data to sub-data in the second firmware in the first firmware can be determined based on the similarity between the binary number corresponding to the sub-data and the binary number corresponding to the data in the first firmware. Specifically, one possible implementation of determining target sub-data and similar data corresponding to each target sub-data among the multiple sub-data based on the first and second firmware is as follows: for each sub-data, similarity is calculated between the sub-data and all data in the first firmware. Based on the calculated similarity, the target sub-data and similar data corresponding to each target sub-data in the multiple sub-data are determined, where the similar data is the data in the first firmware that is similar to the target sub-data. It is understood that for each sub-data in the second firmware, there may be sub-data that does not have similar data. For example, the second firmware may contain additional data relative to the first firmware. Additional data refers to information not present in the first firmware compared to the second firmware, or it can also be understood as information added by the second firmware compared to the first firmware. If a sub-data among the multiple sub-data is additional data, then there is no similar data for that sub-data in the first firmware.

[0070] Optionally, if the first firmware has additional data compared to the second firmware, the differential package also includes the additional data. The differential data refers to information that differs between the current version of the firmware and the target version of the firmware. For example, if information a in the current version of the firmware corresponds to information b in the target version of the firmware, the differential data is the information corresponding to the difference between information b and information a. During an upgrade, the additional data can be integrated into the current version of the firmware by insertion as information in the target version of the firmware (new firmware).

[0071] The fact that at least two target sub-data in the second firmware contain identical data in the similar data corresponding to the at least two target sub-data in the first firmware may specifically fall into the following two situations: In the first situation, if the similar data corresponding to the at least two target sub-data is the same similar data, then the identical data corresponding to the at least two target sub-data is the same similar data. In the second situation, if the identical data contained in the similar data corresponding to the at least two target sub-data is overlapping data between the similar data corresponding to the at least two sub-data, then the identical data corresponding to the at least two target sub-data is the overlapping data.

[0072] As an example, Figure 2 The schematic diagram of the same data shown is illustrated by taking the target sub-data 1 and the target sub-data 2 in the second firmware as an example. The similar data corresponding to the target sub-data 1 in the first firmware is D1, and the similar data corresponding to the target sub-data 2 in the first firmware is also D1. Then, the same data contained in the similar data corresponding to the target sub-data 1 and the similar data corresponding to the target sub-data 2 is D1.

[0073] See also Figure 3 Another schematic diagram of the same data is shown. The target sub-data 1 corresponds to similar data D2 in the first firmware. The target sub-data 2 corresponds to similar data D3 in the first firmware. There is overlapping data D4 between D2 and D3. Figure 3 ), then D4 is the same data contained in the similar data corresponding to the target sub-data 1 and the similar data corresponding to the target sub-data 2.

[0074] Among them, the first starting storage address of the above-mentioned first firmware is the starting storage address corresponding to the data of the first firmware stored in the storage space of the server, and the second starting storage address of the first firmware refers to the starting storage address corresponding to the data of the first firmware stored in the storage space of the terminal device (the user terminal on which the first firmware to be upgraded is installed). Usually, the first starting storage address and the second starting storage address are different. The storage address refers to an identifier for storing data in the storage space of the corresponding device, not the data itself. The data stored in the storage space can be found through the storage address. For each first data, based on the first indication information corresponding to the first data, the second storage space corresponding to the first data can be determined in the storage space of the server, that is, which part of the storage space occupied by the first data in the storage space corresponding to the first firmware. Similarly, for each similar data, based on the second indication information corresponding to the similar data, the first storage space corresponding to the similar data can be determined in the storage space of the server, that is, which part of the storage space occupied by the similar data in the storage space corresponding to the first firmware.

[0075] As an example, for example, the first starting storage address represents that the data stored from the 5kth (k is the storage unit of data, kilobyte KB (Kilobyte)) data stored in the storage space of the server is the data of the first firmware, and the second starting storage address represents that the data stored from the 8kth data stored in the storage space of the terminal device is the data of the first firmware.

[0076] Optionally, for each target sub-data, the above-mentioned determination of the differential data between each target sub-data and the corresponding similar data can be achieved in the following manner: performing a subtraction operation on the target sub-data and the similar data corresponding to the target sub-data, and using the operation result as the differential data corresponding to the target sub-data. Each target sub-data corresponds to one similar data, and there is a one-to-one correspondence between one target sub-data, the similar data corresponding to the target sub-data, the differential data corresponding to the target sub-data, and the first storage space corresponding to the similar data in the terminal device. After determining the differential data corresponding to each target sub-data, a first correspondence relationship can be established between each differential data and the second indication information of the corresponding similar data. When one differential data is known, the second indication information of the similar data corresponding to the differential data in the first firmware can be determined based on the first correspondence relationship.

[0077] Step S120: parse the differential packet to obtain a plurality of differential data and upgrade control information.

[0078] When parsing the differential packet, all differential data can be parsed out at once, or one or more differential data can be parsed out first. The number of differential data parsed out at one time is not limited in the present application solution.

[0079] Step S130: completing the upgrade of the second firmware based on the plurality of differential data and the upgrade control information.

[0080] During the upgrade process based on each differential data point, the storage space occupied by the similar data for each differential data point in the terminal device can be determined based on the upgrade control information. Then, the second firmware can be upgraded based on each differential data point and the similar data corresponding to each differential data point. Because each differential data point has a one-to-one correspondence with its corresponding similar data point, after each differential data point is upgraded, the storage space occupied by the similar data corresponding to that differential data point in the terminal device can be released.

[0081] In an optional solution of the present application, the step of completing the upgrade of the second firmware based on the plurality of differential data and the upgrade control information includes:

[0082] Step S1301, determining, according to the upgrade control information, a first storage space in the terminal device for similar data corresponding to each differential data, and a second storage space in the terminal device for each first data;

[0083] Step S1302: For each differential data, if the first storage space corresponding to the differential data includes the second storage space, perform the following operations:

[0084] Step S13021, if there is first data in the second storage space (the second storage space included in the first storage space corresponding to the differential data), the first data is saved in a designated storage space, and the target data corresponding to the differential data is obtained based on the similar data in the first storage space (the first storage space corresponding to the differential data) and the differential data, and the data in the first storage space is deleted.

[0085] Step S13022: If the first data does not exist in the second storage space, obtain the first data corresponding to the differential data from the designated storage space, obtain the target data corresponding to the differential data based on the differential data, the data in the first storage space corresponding to the differential data, and the first data, and delete the similar data in the first storage space.

[0086] It can be understood that the above-mentioned steps S13021 and S13022 are two steps executed in parallel. The execution order of the two steps is not limited in the present application scheme. If the first data exists in the second storage space, step S13021 is executed; if the first data does not exist in the second storage space, step S13022 is executed.

[0087] For each differential data obtained by analysis, if the first storage space corresponding to the differential data includes the second storage space, it indicates that the similar data corresponding to the differential data contains the same data (first data), and the same data is the first data corresponding to at least one first indication information, that is, the data stored in the second storage space corresponding to the at least one first indication information.

[0088] The designated storage space may be any storage space in the device to be upgraded, for example, at least one of the first storage area or the second storage area, and the size of the designated storage space is not less than the size of the space occupied by the first data.

[0089] Based on the above description, it can be seen that the location indication information includes the first starting storage address of the first firmware in the server, the first indication information of each first data, and the first corresponding relationship between the second indication information of each differential data and its corresponding similar data. The first indication information of a first data is the first storage location information of the first data in the server relative to the first starting storage address; the second indication information is the second storage location information of the similar data corresponding to each differential data in the server relative to the first starting storage address; in order to determine the similar data corresponding to each parsed differential data and the storage space corresponding to each first data in the terminal device, the second indication information of the similar data corresponding to each differential data can be determined based on the first corresponding relationship, and the second starting storage address of the first firmware in the terminal device can be obtained; for each differential data, based on the second storage location information and the second starting storage address corresponding to the differential data, the first storage space of the similar data corresponding to the differential data in the terminal device is determined; for each first data, based on the first storage location information and the second starting storage address of the first data, the second storage space of the first data in the terminal device is determined.

[0090] As an example, continuing with the above example, based on the storage address corresponding to the address offset of 3k data determined by the first starting storage address and the second starting storage address, assuming that the first indication information corresponding to a certain first data in the storage space of the server is A, the storage space corresponding to the first indication information A is the storage space corresponding to the 8k to 12k data in the data stored on the server. Based on the address offset, it can be determined that the storage space corresponding to the first data in the terminal device is the storage space corresponding to the 11k to 15k data in the storage space of the terminal device.

[0091] It should be noted that the upgrade control information also includes a first identifier corresponding to each first data, which is used to identify the first data. The upgrade control information also includes a second identifier corresponding to each similar data corresponding to each differential data, which is used to identify the similar data.

[0092] In an optional solution of the present application, for each first data, the first storage location information includes a first address offset of the first data relative to the first starting storage address, and a first data length of the first data. The first data length represents the amount of data of the first data. The data length of each first data may be different. Whether it is the first firmware stored in the server or the first firmware stored in the terminal device, the storage location of the first data relative to the starting storage address of the first firmware is the same, that is, the position offset of the first data relative to the first starting storage address is the same as the position offset of the first data relative to the second starting storage address. For each first data, the second storage space of the first data in the terminal device is determined based on the first storage location information and the second starting storage address of the first data, including:

[0093] For each first data, based on the first address offset and the second starting storage address of the first data, the third starting storage address corresponding to the first data in the terminal device is determined, and based on the third starting storage address and the first data length, the second storage space of the first data in the terminal device is determined.

[0094] Among them, for a first address offset of a first data, the first address offset represents the address offset of the first data in the server relative to the first starting storage address. Optionally, the address offset can be represented by the amount of data. Since the address offset corresponding to the same first data is the same in both the server and the terminal device, the starting storage address (third starting storage address) corresponding to the first data in the terminal device can be determined based on the first address offset and the second starting storage address of the first data. Then, based on the third starting storage address and the first data length, the second storage space corresponding to the first data in the terminal device can be determined.

[0095] Similarly, for each similar data, the second storage location information includes a second address offset of the similar data corresponding to the differential data relative to the first starting storage address, and a second data length of the similar data corresponding to the differential data. The second data length represents the number of bytes of the similar data. The data length of each similar data may be different. Regardless of whether in the server or in the terminal device, for the same similar data, the address offset corresponding to the similar data is the same. Then, for each differential data, based on the second storage location information and the second starting storage address corresponding to the differential data, determining the first storage space of the similar data corresponding to the differential data in the terminal device includes:

[0096] For each differential data, based on the second address offset and the second starting storage address corresponding to the differential data, determine the fourth starting storage address corresponding to the similar data corresponding to the differential data in the terminal device; based on the fourth starting storage address and the second data length, determine the first storage space in the terminal device corresponding to the similar data corresponding to the differential data.

[0097] Among them, for a second address offset of similar data, the second address offset represents the address offset of the similar data in the server relative to the first starting storage address. Optionally, the address offset can be represented by the amount of data. Since the address offset corresponding to the same similar data is the same whether in the server or in the terminal device, the starting storage address (fourth starting storage address) corresponding to the similar data in the terminal device can be determined based on the second address offset and the second starting storage address, and then the first storage space corresponding to the similar data in the terminal device can be determined based on the fourth starting storage address and the second data length.

[0098] It should be noted that the order in which the data in the differential package is stored is the order in which it is used during the upgrade. A first data corresponds to at least two differential data. At this time, on the one hand, if a differential data is the differential data obtained by first parsing of the at least two differential data (for the convenience of description, the differential data will be referred to as differential data a below), it means that when upgrading based on differential data a, the first data is used for the first time. The first data is the data stored in the first storage space corresponding to differential data a. Before using the first data for upgrading, the first data can be saved to a designated storage space, which can also be understood as backing up the first data. Then, the upgrade process is performed based on differential data a and the data in the first storage space corresponding to differential data a (similar data corresponding to the differential data) to obtain the target data corresponding to differential data a, wherein the target data is part of the data in the second firmware of the target version. At this time, since the data in the first storage space has been used and the first data has been stored in another designated storage space, the data in the first storage space will not be used again. The data in the first storage space can be deleted to release the first storage space so that the first storage space can be recycled.

[0099] On the other hand, if the differential data is the differential data obtained after parsing the at least two differential data (for ease of description, the differential data will be referred to as differential data b below), it means that when the first data is upgraded based on differential data b, it is not the first time that the first data is used. The data (including the first data) in the first storage space corresponding to differential data a has been used and deleted. If the first data needs to be used again, the first data can be obtained from the designated storage space. Then, based on the first data and the remaining data (similar data) in the first storage space and differential data b, the upgrade process is performed to obtain the target data corresponding to differential data b. After obtaining the target data, the similar data in the first storage space corresponding to differential data b can also be deleted to release the first storage space corresponding to differential data b. For the first data existing between similar data corresponding to two differential data, if the designated storage space only stores one first data at a time, after the first data is saved in the designated storage space, after the data obtained from the designated storage space is used for upgrading, the data in the designated storage space will not be used again. After the target data corresponding to the differential data is obtained based on the data obtained from the designated storage space, the data in the designated storage space can be deleted, which can further release storage resources.

[0100] Based on the above process, used similar data can be deleted during the upgrade, continuously freeing up storage resources. At the same time, because similar data and differential data have a one-to-one correspondence, even if similar data is deleted during the upgrade, there is no need to worry about some identical data being deleted before it is fully used, thus affecting the upgrade.

[0101] It should be noted that the above scheme is a scheme for explaining the first data existing between similar data corresponding to two differential data. For three adjacent differential data, the number of first storage spaces corresponding to the similar data corresponding to each of the three differential data is three. If one of the first storage spaces contains two second storage spaces, it means that the similar data corresponding to the first storage space contains two first data. In this case, when upgrading the differential data corresponding to the first storage space containing the two second storage spaces (hereinafter referred to as differential data D2 for convenience of description), it is necessary to consider whether there is first data in the two second storage spaces. Since the first storage space at the front of the storage position is upgraded, the first storage space at the front of the storage position is upgraded. When restoring the differential data corresponding to the storage space, the first data (hereinafter referred to as data a for ease of description) in the second storage space with a forward storage position has been saved to the designated storage space. Then, when upgrading the differential data corresponding to the first storage space with a middle storage position, since the first data (hereinafter referred to as data b for ease of description) in the second storage space with a backward storage position is used for the first time, data b can be saved to the designated storage space. During the upgrade, data a can be obtained from the designated storage space, and the upgrade is performed based on the obtained data a and the similar data in the first storage space corresponding to the differential data D2 to obtain the target data corresponding to the differential data D2. When restoring the differential data corresponding to the first storage space with a backward storage position (hereinafter referred to as differential data D3 for ease of description), the upgrade is performed based on the data b obtained from the designated storage space, the similar data in the first storage space, and the differential data D3 to obtain the target data corresponding to the differential data D3.

[0102] As an example, see Figure 4 As shown, the similar data corresponding to the differential data D1 is S1, the similar data corresponding to the differential data D2 is S2, and the similar data corresponding to the differential data D3 is S3. There is first data a between the similar data S1 and the similar data S2, and there is first data b between the similar data S2 and the similar data. When the differential data D1 is upgraded, the first data a is saved to a designated storage space, and the upgrade is performed based on the differential data D1 and the similar data S1 to obtain the target data corresponding to the differential data D1, and the similar data S1 is deleted. When the differential data D2 is upgraded, the first data b is saved to a designated storage space, and the first data a is obtained from the designated storage space. Based on the first data a, the data in the differential data D2 and the similar data S2 except the first data a are upgraded to obtain the target data corresponding to the differential data D2. When the differential data D3 is upgraded, the first data b is obtained from the designated storage space, and the upgrade is performed based on the first data b, the differential data D3, and the data in the similar data S3 except the first data b to obtain the target data corresponding to the differential data D3.

[0103] As described above, the similar data corresponding to the above two target sub-data can be the same similar data, then the first data can be the same similar data (the similar data corresponding to the differential data). In this case, the similar data is the data obtained from the designated storage space, and there is no data in the first storage space corresponding to the differential data. During the upgrade, the target data corresponding to the differential data can be obtained based on the data obtained from the designated storage space and the differential data. If the same data contained in the similar data corresponding to the two target sub-data is the overlapping data between the similar data corresponding to the two target sub-data, that is, the first data is part of the similar data corresponding to the differential data, then during the upgrade, the target data corresponding to the differential data can be obtained based on the data in the first storage space, the first data obtained from the designated storage space, and the differential data. At this time, the similar data corresponding to the differential data is the sum of the data in the first storage space and the data obtained from the designated storage space.

[0104] Optionally, the above-mentioned designated storage space can only store one first data at a time, and the designated storage space can also store multiple first data at a time. Then, when the designated storage space stores multiple first data at a time, in order to ensure that the first data corresponding to the differential data can be accurately found from the designated storage space, any of the following methods can be adopted: First, when the first data is saved in the designated storage space, the storage identifier corresponding to the first data is recorded. The storage identifier represents the storage position corresponding to the first data in the designated storage space. When the first data is needed, the corresponding first data can be found in the designated storage space based on the storage identifier. Second, when the first data is saved in the designated storage space, a corresponding relationship between the first data and the storage identifier of the storage space where the first data is located in the designated storage space is established. When the first data is needed, the first data can be obtained from the storage space where the first data is located in the designated storage space based on the corresponding relationship. It can be understood that the above two implementation methods are only one possible implementation method, and the present application solution does not limit the above two implementation methods.

[0105] In an optional scheme of the present application, for each differential data, if the first storage space corresponding to the differential data does not include the second storage space, the method also includes: obtaining the target data corresponding to the differential data based on the similar data in the first storage space corresponding to the differential data and the differential data, and deleting the similar data in the first storage space.

[0106] If the first storage space corresponding to the differential data does not include the second storage space, indicating that the similar data corresponding to the differential data does not contain the same data (first data), then the upgrade process can be directly performed based on the differential data and the data in the first storage space to obtain the target data corresponding to the differential data, and the data in the first storage space can be deleted. In this way, for any differential data in the differential package, regardless of whether the similar data corresponding to the differential data contains the same data, after the upgrade process is performed using the similar data corresponding to the differential data, the similar data corresponding to the differential data can be deleted, further freeing up storage resources.

[0107] The solution provided by the embodiment of the present application is to obtain and store the corresponding differential package when the target software needs to be upgraded, that is, in response to the upgrade request. In the process of upgrading based on multiple differential data in the differential package, for each differential data obtained by parsing, if the second storage space corresponding to at least one of the first storage space identifiers contained in the upgrade control information is included in the first storage space, it indicates that the same data (first data) exists in the similar data corresponding to the differential data. At this time, if there is data in the second storage space, the data can be saved to the designated storage space first. At this time, there is a one-to-one correspondence between each differential data and the storage space where the corresponding similar data is located. Therefore, when upgrading based on the differential data and the similar data corresponding to the differential data, the target data of the differential data can be upgraded while the data in the storage space where the similar data is located can be deleted to release the storage space, so that the storage space can be recycled.

[0108] Since the present application solution is applicable to any differential upgrade algorithm, when upgrading the target software based on the differential package, any upgrade algorithm can be used for upgrading. Upgrading refers to upgrading the current version of the firmware to the target version of the firmware. After the upgrade, a corresponding target version of the software can be obtained.

[0109] Optionally, the solution of the present application can be upgraded using OTA (Over-the-Air Technology) upgrade technology. OTA technology refers to a technology in which a user terminal downloads an upgrade package (differential package) from a remote server through a wireless network and upgrades the operating system or application of the user terminal based on the differential package.

[0110] In the solution of this application, there are many ways to implement differential upgrades. The solution of this application is applicable to any differential upgrade method, such as the bsdiff algorithm, the hdiffpatch algorithm, the xdelta3 algorithm, etc.

[0111] In the scheme of the present application, since the first firmware includes second data that is not required for the upgrade, in order to further save storage resources, the third storage space corresponding to the second data can be used as the designated storage space for storing the first data. In the optional scheme of the present application, the above-mentioned server also performs the following operations: based on the first firmware and the second firmware, determine the third storage space in the server for the second data in the first firmware, where the second data is data contained in the first firmware that is not required for the upgrade; for each first data, determine the target storage space of the first data in the third storage space based on the size of the storage space required for the first data, and based on the target storage space, generate the third indication information corresponding to the first data, and establish a second correspondence between the first indication information and the third indication information corresponding to each first data.

[0112] Since the second data is included in the first firmware and is not required for the upgrade, to conserve storage resources on the device being upgraded and further improve resource utilization, the target storage space for storing the first data can be determined from the third storage space corresponding to the second data. For each piece of second data, the third indication information indicates the storage location on the server of the storage space where the first data is stored.

[0113] Specifically, the target storage space may be the entire storage space of the third storage space, or a portion of the storage space within the third storage space. The size of the target storage space may be determined based on the storage space required to store the first data, i.e., the maximum size of the target storage space must be no less than the storage space required to store the first data. If the third storage space corresponding to the second data in the server is continuous, the target storage space is continuous. If the third storage space corresponding to the second data in the server is discontinuous, the target storage space is discontinuous.

[0114] When the above-mentioned upgrade control information includes a second correspondence, the above-mentioned saving of the first data to the designated storage space includes: determining, according to the second correspondence, the third indication information corresponding to the second indication information corresponding to the first data; based on the third indication information and the second starting storage address, determining the fourth storage space corresponding to the second data corresponding to the third indication information in the firmware storage space, and using the fourth storage space as the designated storage space corresponding to the first data; deleting the data in the fourth storage space, and copying the first data to the fourth storage space.

[0115] Based on the foregoing description, the aforementioned second correspondence is a correspondence between the first indication information corresponding to the first data and the third indication information. Based on this second correspondence, the third indication information corresponding to the first indication information corresponding to the data can be determined. Since the fourth storage space corresponding to the third indication information is the storage space corresponding to the second data in the terminal device, and the second data is data contained in the first firmware and is not required for the upgrade, the second data in the fourth storage space can be deleted and the fourth storage space can be used as the target storage space for storing the first data. This allows full utilization of the storage space corresponding to the second data in the first firmware in the terminal device.

[0116] As an example, see Figure 5 The target storage space is shown in the diagram; Figure 2 Take the case where the same data (first data) contained in the similar data corresponding to the target sub-data 1 and the similar data corresponding to the target sub-data 2 in the second firmware is D1 as an example, that is, the similar data corresponding to the target sub-data 1 in the first firmware is D1, and the similar data corresponding to the target sub-data 2 in the first firmware is also D1. The first firmware also includes the second data K1, and the storage space corresponding to K1 in the server is the target storage space corresponding to D1. The second correspondence includes the correspondence between the first indication information corresponding to D1 and the fourth indication information. In this example, when the first data is saved to the designated storage space, the specific process is: according to the second correspondence, the fourth indication information corresponding to the first indication information corresponding to D1 is determined, and the second data K1 in the third storage space corresponding to the fourth indication information is deleted. At this time, the storage space corresponding to K1 is empty and no data is stored. D1 is stored in the third storage space corresponding to K1. At this time, two copies of D1 are stored. The target sub-data 1 and the storage space corresponding to the similar data D1 (the first storage space) are in a one-to-one mapping relationship, and the target sub-data 2 and the storage space corresponding to the similar data D1 (the storage space corresponding to K1) are also in a one-to-one mapping relationship.

[0117] In an optional solution of the present application, if the third storage space is a discontinuous storage space, that is, the third storage space includes multiple discontinuous fifth storage spaces, then for each first data, the target storage space of the first data in the third storage space is determined according to the storage space size required for the first data, including: determining the space size of each fifth storage space; according to the storage space size required for the first data, determining the target storage space corresponding to the first data in each fifth storage space, the target storage space includes at least one fifth storage space whose target space size is not less than and is closest to the required storage space size, and the target space size is the space size corresponding to at least one fifth storage space.

[0118] Among them, among the multiple fifth storage spaces, a storage space with a space size not less than the target space size (i.e., a storage space that can store the first data) is selected, and it is the storage space with the smallest space size among the multiple fifth storage spaces (at least one fifth storage space closest to the required storage space size), so as to save storage resources. It is understandable that if the at least one fifth storage space closest to the required storage space size is at least two fifth storage spaces, then the target space size is the space size corresponding to the at least two fifth storage spaces; if the at least one fifth storage space closest to the required storage space size is one fifth storage space, then the target space size is the space size of the fifth storage space.

[0119] As an example, for example, the third storage space includes three fifth storage spaces, and the three fifth storage spaces are discontinuous, namely storage space K1, storage space K2 and storage space K3. Among these three storage spaces, the storage space sizes are sorted from small to large as follows: storage space K1, storage space K3 and storage space k2. The target space size is larger than the space size of storage space K1 and smaller than the space size of storage space K3. Then, among these three fifth storage spaces, the storage space that can store the first data is storage space K2 and storage space K3. Among these two storage spaces, since the space size of storage space K2 is larger than the space size of storage space K3, in order to save storage resources, storage space K3 can be used as the target storage space for the first data.

[0120] If the target storage space corresponding to the first data is a discontinuous storage space, that is, the target storage space is at least two fifth storage spaces, the data in the first data can be stored in the corresponding fifth storage spaces according to the space size of each of the at least two fifth storage spaces corresponding to the target storage space. In this case, the correspondence between the first data and the target storage space corresponding to the first data includes the correspondence between a portion of the first data and the fifth storage space corresponding to the portion of the data, as well as the correspondence between the data in the first data other than the portion of the data and the fifth storage space corresponding to the data.

[0121] As an example, for example, the third storage space includes three fifth storage spaces, and the three fifth storage spaces are discontinuous, namely storage space K1, storage space K2, and storage space K3. Among these three storage spaces, the storage space sizes are sorted from small to large as follows: storage space K1, storage space K3, and storage space k2. The target space size is larger than the space size of storage space k2. Then, from these three fifth storage spaces, at least two fifth storage spaces that can store the first data can be determined, for example, storage space K1 and storage space K3. The sum of the space size of storage space K1 and the space size of storage space K3 is not less than the target space size. If the space size required to store the first data is 5k, the space size of storage space K1 is 2k, and the space size of storage space K3 is 4k, then 2k of the first data can be stored in storage space K1, and the remaining 3k of the first data can be stored in storage space K3. The sum of the space size of storage space K1 and the space size of storage space K3 is the smallest sum of the storage spaces among the three storage spaces.

[0122] In order to better illustrate and understand the principles of the method provided by this application, the solution of this application is described below in conjunction with an optional specific embodiment. It should be noted that the specific implementation of each step in this specific embodiment should not be understood as a limitation to the solution of this application. Based on the principles of the solution provided by this application, other implementations that can be thought of by those skilled in the art should also be considered within the scope of protection of this application.

[0123] See also Figure 6 A structural diagram of a software upgrade system is shown in FIG. Figure 6 As shown, the system includes a server, user terminal A, user terminal B, and user terminal C. User terminal A, user terminal B, and user terminal C all have application a installed. Application a is the target software. When any of the three user terminals sends an upgrade request to the server, application a can be upgraded using the solution of this application. User terminal A, user terminal B, and user terminal C are merely examples. The solution of this application does not limit the number or specific form of user terminal A. For example, in this example, the user terminal can be a mobile phone. It is understood that for ease of maintenance, different applications can correspond to different servers.

[0124] In this example, the target software is Application A installed on the user's phone, and the current version of Application A is 2.0. In this example, an "upgrade" icon for Application A is displayed on the client interface of the user's phone. Upon triggering this icon, an upgrade request is generated, which the phone sends to the server. This upgrade request includes identification information for Application A, including its application ID (software ID) and version ID.

[0125] After receiving the upgrade request, the server determines the target version of the second firmware (new firmware) and the current version of the first firmware (old firmware) corresponding to application a based on the version identifier of application a. If the target version is 3.0, the purpose of the upgrade request is to upgrade the target software from version 2.0 to version 3.0. After determining the target version of the second firmware, the server generates a differential package based on the first and second firmware of application a.

[0126] The specific generation process of the differential package is as follows:

[0127] Step 1: Divide the data in the second firmware into multiple sub-data (for example, A1 and A2), obtain the first starting storage address corresponding to the first firmware in the server, and determine the target sub-data in the multiple sub-data and the similar data (similar blocks) corresponding to each target sub-data based on the first firmware and the second firmware. The second data refers to the data that is not included in the second firmware and is not required for the upgrade, and the target sub-data refers to the sub-data that has similar data in the first firmware. Multiple similar blocks are formed into a differential table TB1 (for details, see Figure 7 ), since similar blocks are used to calculate differential data, similar blocks can also be called differential blocks.

[0128] Step 2: For each target sub-data, if the similar data corresponding to at least two target sub-data contain the same data, the same data is used as the first data corresponding to the at least two target sub-data, and the first indication information corresponding to the first data in the server is generated (which may be the first address offset and the first data length).

[0129] As an example, Figure 7 The schematic diagram of the differential table TB1 is shown in Figure 7In the example, the differential table TB1 includes similar blocks D1, D2, D4, D5, and D6. The target sub-data among the multiple sub-data are target sub-data A1 and target sub-data A2. The similar data corresponding to the target sub-data A1 are D1 and D4 (which can be recorded as D1+D4), and the similar data corresponding to the target sub-data A2 are D4 and D2 (which can be recorded as D2+D4). The same data corresponding to the target sub-data A1 and the target sub-data A2 is similar block D4 (which can be recorded as first data). The first address offset and first data length corresponding to the similar block D4 in the server are recorded. For example, the starting storage address of the similar block D4 is the storage address corresponding to the 3kth data stored in the server, and the first data length is the data length corresponding to the 5k data volume.

[0130] Step 3, determine the size of the storage space required to store the first data (similar block D4), determine the third storage space corresponding to the second data in the first firmware in the server, based on the size of the storage space required for the first data (similar block D4), determine the target storage space corresponding to the first data in the third storage space, and based on the target storage space, generate the third indication information corresponding to the first data (which may be a third address offset and a third data length), and the target storage space is part or all of the third storage space. Establish a second correspondence between the first indication information and the third indication information corresponding to the first data. In this example, the above-mentioned third storage space can be a plurality of discontinuous fifth storage spaces, and the data (second data) corresponding to each fifth storage space can be called a free block, and a plurality of discontinuous free blocks form a free list TB2.

[0131] Continuing with the previous example, Figure 8 The schematic diagram of free list TB2 is shown. Free list TB2 includes free block K1, free block K2, and free block K3. That is, the third storage space corresponding to the second data in the server includes the fifth storage space corresponding to free block K1, the fifth storage space corresponding to free block K2, and the fifth storage space corresponding to free block K3. These fifth storage spaces are discontinuous. The storage space required for the first data (similar block D4) is determined. For example, to store 5KB of data, if the fifth storage space corresponding to free block K1 is the size required for 5KB of data, the fifth storage space corresponding to free block K2 is the size required for 10KB of data, and the fifth storage space corresponding to free block K3 is the size required for 8KB of data. Among these three fifth storage spaces, the storage space with the smallest space (the fifth storage space corresponding to free block K1) that has a larger space than the storage space required for the first data and is larger than the space required for the first data is selected as the target storage space. A second correspondence is established between the second indication information corresponding to the first data (similar block D4) and the third indication information.

[0132] Suppose the first data (similar block D4) requires 5KB of storage space, the fifth storage space corresponding to free block K1 requires 2KB of data, the fifth storage space corresponding to free block K2 requires 4KB of data, and the fifth storage space corresponding to free block K3 requires 3KB of data. Among these three free blocks, the largest storage space is the fifth storage space corresponding to free block K2. Since the space corresponding to free block K2 is smaller than the target space size and cannot accommodate similar block D4, the fifth storage space corresponding to free block K1 and the fifth storage space corresponding to free block K2 can be combined as the target space. In this case, the sum of the space sizes corresponding to free block K1 and free block K2 is the space required to store 6KB of data, which is larger than the target space size of 5KB. Similar block D4 can be accommodated using the fifth storage space corresponding to free block K1 and the fifth storage space corresponding to free block K2. 2k data in the first data can be stored in the fifth storage space corresponding to the free block K1, and the remaining 3k data in the first data can be stored in the fifth storage space corresponding to the free block K2. The second corresponding relationship is the correspondence between the second indication information corresponding to the 2k data in the first data and the third indication information corresponding to the free block K1, and the correspondence between the second indication information corresponding to the remaining 3k data in the first data and the third indication information corresponding to the free block K2.

[0133] Step 4, determine the differential data between each target sub-data and the corresponding similar data, and establish a first correspondence between each differential data and the second indication information (which may include a second address offset and a second data length) of the corresponding similar data. In this example, based on the differential block in the TB1 table and the differential block in the TB3 table, the differential data B1 corresponding to the target sub-data A1 and the differential data B2 corresponding to the target sub-data A2 are calculated. Optionally, B1 = A1-(D1+D4), B2 = A2-(D2+D4). The first correspondence includes the correspondence between B1 and the second indication information corresponding to D1+D4 in the server, and the correspondence between B2 and the second indication information corresponding to D2+D4 in the server.

[0134] In this example, since the target sub-data participates in the calculation of the differential data, the target sub-data can also be called the differential block of the second firmware, and the differential block and additional data in the second firmware form a differential table TB3.

[0135] Step 5: Based on the first firmware and the second firmware, determine the additional data; based on the second correspondence, the first correspondence, the first indication information and the first starting storage address, generate the upgrade control information; based on the upgrade control information, the additional data and the differential data, generate the differential package.

[0136] Among them, the upgrade control information can be understood as information used to control the restoration of the target version of the firmware, and the differential data and additional data can be understood as data used for upgrading. During the upgrade, the differential data and additional data are controlled based on the upgrade control information to restore the second firmware of the target version to achieve the upgrade of the target software.

[0137] After the differential packet is generated, the differential packet is encoded and sent to the user terminal (user's mobile phone) corresponding to the upgrade request.

[0138] The upgrade request may also include a terminal identifier, which identifies the user terminal sending the upgrade request. Based on the terminal identifier, the server may send the encoded differential packet to the user terminal. The terminal identifier may be at least one of text, characters, or symbols; this application does not limit the specific form of the terminal identifier.

[0139] The user terminal stores the encoded differential packet sent by the server, decodes the encoded differential packet to obtain a differential packet, and then parses the differential packet to obtain differential data B1, differential data B2, and upgrade control information. The user terminal then upgrades the first firmware (version 2.0 application a) in the user terminal based on the parsed information. The specific upgrade process is as follows:

[0140] Step A: Obtain a second starting storage address of the first firmware in the terminal device.

[0141] Step B: For each differential data obtained through parsing, whether in the terminal device or in the server, the second address offset of the similar data corresponding to the differential data with respect to the first starting storage address is the same as the address offset of the similar data corresponding to the differential data with respect to the second starting storage address. Therefore, based on the second starting storage address and the second address offset, the fourth starting storage address corresponding to the similar data corresponding to the differential data in the terminal device can be determined; based on the fourth starting storage address and the second data length, the first storage space of the similar data corresponding to the differential data in the terminal device is determined. For differential data B1, the first storage space is the sum of the storage space corresponding to similar block D1 in the terminal device and the storage space corresponding to similar block D4 in the terminal device. For differential data B2, the first storage space is the sum of the storage space corresponding to similar block D4 in the terminal device and the storage space corresponding to similar block D2 in the terminal device.

[0142] Similarly, for each first data item, whether in the terminal device or the server, the second address offset of the first data item with respect to the first starting storage address is the same as the address offset of the first data item with respect to the second starting storage address. Therefore, based on the first address offset and the second starting storage address of the first data item, the third starting storage address corresponding to the first data item in the terminal device can be determined, and based on the third starting storage address and the first data length, the second storage space of the first data item in the terminal device can be determined. For example, for the first data item (similar block D4), the second storage space of the similar block D4 in the terminal device can be determined based on the first address offset, the second starting storage address, and the first data length.

[0143] Step D: for the differential data B1, if the first storage space corresponding to the differential data B1 includes the second storage space, for example, Figure 7 The second storage space corresponding to the similar block D4 shown in (the storage space corresponding to the similar block D4) is included in the first storage space, and the corresponding data in the second storage space is the first data corresponding to the differential data B1. The first data (similar block D4) in the second storage space is stored in a designated storage space, or, based on the above second corresponding relationship, the third indication information corresponding to the similar block D4 is determined, and based on the third indication information and the second starting storage address, the target storage space of the similar block D4 is determined (if Figure 7 The fourth storage space corresponding to the free block K1 shown in FIG, the fourth storage space is the storage space corresponding to the free block K3 in the terminal device), the fourth storage space corresponding to the free block K1 is used as the designated storage space, the data in the free block K1 is deleted, and then the similar block D4 is copied to the fourth storage space corresponding to the free block K1. For details, see Figure 7 TB1 and Figure 8 The schematic diagram of TB2 shown in FIG. 1 shows that the similar data corresponding to the differential data B1 is Figure 8 The similar block D1 shown in FIG. Figure 7 The similar blocks D1 and D4 in the table correspond to the same data, and the similar data corresponding to the differential data B2 is Figure 8 The similar block D2 and the similar block D4 in (the storage space corresponding to the similar block D4 is the storage space corresponding to the free block K3).

[0144] After saving the first data in the second storage space, an upgrade process is performed based on the differential data B1 and the similar data (D1 and D4) corresponding to the differential data B1 to obtain the target data corresponding to the differential data B1. The target data is used as part of the data in the second firmware, and the similar data (D1 and D4) is deleted.

[0145] In step E, for the differential data B2 obtained by analysis, the similar data corresponding to the differential data B2 are D2 and D4. At this time, since the similar block D4 in the second storage space has been deleted after the differential data B1 is upgraded, that is, the first data does not exist in the second storage space, and the similar block D4 has been saved to the designated storage space (the fourth storage space corresponding to the free block K3, the fourth storage space) in step D, the similar block D4 can be obtained from the fourth storage space corresponding to the free block K3, and then a differential upgrade is performed based on the differential data B2, the similar block D2 (the data in the first storage space) and the similar block D4 obtained from the fourth storage space corresponding to the free block K3 to obtain the target data corresponding to the differential data B2, and the similar block D4 and the similar block D2 in the fourth storage space corresponding to the free block K3 are deleted.

[0146] According to the above differential upgrade method, each differential data in the differential package is upgraded, and differential upgrade is performed based on the additional data in the differential package, and finally the target version of the application is obtained. At this time, the upgraded application a is a 3.0 version application.

[0147] In actual applications, if the amount of the first data is small, the storage space occupied by the first data is small. Because the storage space occupied by the first data is small, the storage resources released based on the solution of the present application are small. Therefore, when the amount of the first data is less than the set threshold, the solution of the present application may not be used for upgrading. When the amount of the first data is greater than the set threshold, the solution of the present application is used for upgrading.

[0148] Based on this application Figure 1 The same principle as the method provided, the embodiment of the present application also provides a software upgrade device, such as Figure 9 As shown, the software upgrade device 20 includes a differential packet acquisition module 210, a differential packet parsing module 220, and an upgrade module 230. The differential packet acquisition module 210 is configured to, in response to an upgrade request for the target software, acquire a differential packet corresponding to the target software. The differential packet includes upgrade control information and differential data corresponding to each of multiple target sub-data. The target sub-data refers to sub-data contained in the second firmware that has similar data in the first firmware. The upgrade control information includes location indication information, which is used to determine the storage space in the terminal device for the similar data corresponding to each differential data and each first data. The first data is the identical data in the similar data corresponding to two target sub-data. The differential packet parsing module 220 is configured to parse the differential packet to obtain multiple differential data and the upgrade control information. The upgrade module 230 is configured to complete the upgrade of the second firmware based on the multiple differential data and the upgrade control information.

[0149] The solution provided by the embodiment of the present application obtains the corresponding differential package when the target software needs to be upgraded, that is, in response to an upgrade request. In the process of upgrading based on each differential data in the differential package, for each differential data obtained through parsing, the storage space of similar data of each differential data in the terminal device can be determined based on the upgrade control information, so that there is a one-to-one correspondence between each differential data and the storage space of the corresponding similar data in the terminal device. Then, for each differential data, when upgrading based on the differential data and the similar data corresponding to the differential data, the target data of the differential data can be upgraded while the data in the storage space where the similar data is located is deleted to release the storage space, so that the storage space can be recycled.

[0150] Optionally, when completing the upgrade of the second firmware based on the plurality of differential data and the upgrade control information, the upgrade module 230 is specifically configured to: determine, according to the upgrade control information, a first storage space in the terminal device for similar data corresponding to each differential data, and a second storage space in the terminal device for each first data; and for each differential data, if the first storage space corresponding to the differential data includes the second storage space, perform the following operations:

[0151] If the first data exists in the second storage space, the first data is stored in a designated storage space, target data corresponding to the differential data is obtained based on similar data in the first storage space corresponding to the differential data and the differential data, and the similar data in the first storage space is deleted;

[0152] If the first data does not exist in the second storage space, the first data corresponding to the differential data is obtained from the designated storage space, and based on the differential data, the data in the first storage space corresponding to the differential data, and the first data, the target data corresponding to the differential data is obtained, and similar data in the first storage space is deleted.

[0153] Optionally, the location indication information includes a first starting storage address of the first firmware in the server, first indication information of each first data, and a first correspondence between each differential data and its corresponding similar data; the first indication information of a first data is the first storage location information of the first data in the server relative to the first starting storage address; the second indication information is the second storage location information of the similar data corresponding to each differential data in the server relative to the first starting storage address;

[0154] When the upgrade module 230 determines the first storage space in the terminal device of the similar data corresponding to each differential data and the second storage space in the terminal device of each first data according to the upgrade control information, it is specifically used to: determine the second indication information of the similar data corresponding to each differential data based on the first correspondence, and obtain the second starting storage address of the first firmware in the terminal device; for each differential data, determine the first storage space in the terminal device of the similar data corresponding to the differential data based on the second storage position information and the second starting storage address corresponding to the differential data; for each first data, determine the second storage space in the terminal device of the first data based on the first storage position information and the second starting storage address of the first data.

[0155] Optionally, for each first data, the first storage location information includes a first address offset of the first data relative to the first starting storage address, and a first data length of the first data; when determining, for each first data, the second storage space of the first data in the terminal device based on the first storage location information and the second starting storage address of the first data, the upgrading module 230 is specifically configured to: for each first data, determine, based on the first address offset and the second starting storage address of the first data, a third starting storage address corresponding to the first data in the terminal device, and determine, based on the third starting storage address and the first data length, the second storage space of the first data in the terminal device;

[0156] For each differential data, the above-mentioned second storage location information includes the second address offset of the similar data corresponding to the differential data relative to the first starting storage address, and the second data length of the similar data corresponding to the differential data; when the above-mentioned upgrade module 230 determines the first storage space of the similar data corresponding to the differential data in the terminal device based on the second storage location information and the second starting storage address corresponding to the differential data for each differential data, it is specifically used to: for each differential data, based on the second address offset and the second starting storage address corresponding to the differential data, determine the fourth starting storage address corresponding to the similar data corresponding to the differential data in the terminal device; based on the fourth starting storage address and the second data length, determine the first storage space of the similar data corresponding to the differential data in the terminal device.

[0157] Optionally, the upgrade request includes identification information of the target software, including the software identification and the version identification of the current version. The differential package is generated by the server in the following manner:

[0158] Based on the above identification information, the first firmware and the second firmware of the target software are determined, and the data in the second firmware is divided into multiple sub-data; based on the first firmware and the second firmware, the target sub-data in the multiple sub-data and the similar data corresponding to each target sub-data are determined; for each target sub-data, if the similar data corresponding to at least two target sub-data contain the same data, the same data is used as the first data corresponding to the at least two target sub-data, and the first indication information corresponding to the first data is generated; the differential data between each target sub-data and the corresponding similar data is determined, the second indication information of each similar data is generated, and a first corresponding relationship between each differential data and the second indication information of the corresponding similar data is established; the first starting storage address of the first firmware in the server is obtained, and based on the first corresponding relationship, each first indication information and the first starting storage address, the upgrade control information is generated; based on the upgrade control information and the differential data, a differential package is generated.

[0159] Optionally, the server further performs the following operations:

[0160] Based on the first firmware and the second firmware, determining a third storage space in the server for second data in the first firmware, where the second data refers to data that is not included in the second firmware and is not required for the upgrade; for each piece of first data, determining a target storage space for the first data in the third storage space based on the storage space required for the first data, generating third indication information corresponding to the first data based on the target storage space, and establishing a second correspondence between the first indication information and the third indication information corresponding to each piece of first data; wherein the upgrade control information also includes the second correspondence;

[0161] When the upgrade module 230 saves the first data to a designated storage space, it is specifically used to: determine the third indication information corresponding to the first indication information corresponding to the data according to the second correspondence; determine the second data corresponding to the third indication information in the fourth storage space of the terminal device based on the third indication information and the second starting storage address, and use the fourth storage space as the designated storage space corresponding to the first data; delete the data in the fourth storage space, and copy the first data to the fourth storage space.

[0162] Optionally, for each differential data, if the first storage space corresponding to the differential data does not include the second storage space, the above-mentioned upgrade module is also used to: obtain the target data corresponding to the differential data based on the similar data in the first storage space corresponding to the differential data and the differential data, and delete the similar data in the first storage space.

[0163] Optionally, if the third storage space includes multiple discontinuous fifth storage spaces; for each first data, when the above-mentioned server determines the target storage space of the first data in the third storage space based on the storage space size required for the first data, it is specifically used to: determine the space size of each fifth storage space; based on the storage space size required for the first data, determine the target storage space corresponding to the first data in each fifth storage space, the above-mentioned target storage space includes at least one fifth storage space whose target space size is not less than and is closest to the required storage space size, and the target space size is the space size corresponding to at least one fifth storage space.

[0164] The software upgrade device of the embodiment of the present application can execute the software upgrade method provided by the embodiment of the present application, and its implementation principle is similar. The actions performed by each module and unit in the software upgrade device in each embodiment of the present application correspond to the steps in the software upgrade method in each embodiment of the present application. For the detailed functional description of each module of the video playback device, please refer to the description in the corresponding software upgrade method shown in the previous text, and will not be repeated here.

[0165] The above-mentioned software upgrading device can be a computer program (including program code) running in a computer device, for example, the display device of the user interface is an application software; the device can be used to execute the corresponding steps in the method provided in the embodiment of the present application.

[0166] In some embodiments, the software upgrade device provided by the embodiment of the present invention can be implemented in a combination of software and hardware. As an example, the software upgrade device provided by the embodiment of the present invention can be a processor in the form of a hardware decoding processor, which is programmed to execute the software upgrade method provided by the embodiment of the present invention. For example, the processor in the form of a hardware decoding processor can adopt one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), or other electronic components.

[0167] In other embodiments, the software upgrade device provided by the embodiment of the present invention can be implemented in software. The software upgrade device stored in the memory can be software in the form of programs and plug-ins, and includes a series of modules, including each module in the software upgrade device 20, wherein each module in the software upgrade device 20 is used to implement the software upgrade method provided by the embodiment of the present invention.

[0168] An embodiment of the present application provides a software upgrading device. Compared with the prior art, when the target software needs to be upgraded, that is, in response to an upgrade request, a corresponding differential package is obtained. In the process of upgrading based on each differential data in the differential package, for each differential data obtained through parsing, the storage space of similar data of each differential data in the terminal device can be determined based on the upgrade control information, so that there is a one-to-one correspondence between each differential data and the storage space of the corresponding similar data in the terminal device. Then, for each differential data, when upgrading based on the differential data and the similar data corresponding to the differential data, the target data of the differential data can be upgraded while the data in the storage space where the similar data is located can be deleted to release the storage space, so that the storage space can be recycled.

[0169] The above describes the software upgrade device of the present application from the perspective of a virtual module or a virtual unit. The following describes the electronic device of the present application from the perspective of a physical device.

[0170] Based on the same principle as the method provided in the embodiments of the present application, an electronic device is provided in the embodiments of the present application, which includes a memory and a processor; a computer program is stored in the memory, and when the computer program is executed by the processor, it can implement the method provided in any optional method of the present application.

[0171] As an alternative, Figure 10 FIG. 4 shows a schematic diagram of the structure of an electronic device 4000 to which the embodiment of the present application is applicable. Figure 10 As shown, Figure 10 The electronic device 4000 shown includes a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, for example, via a bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004, which may be used for data exchange between the electronic device and other electronic devices, such as data transmission and / or data reception. It should be noted that in actual applications, the number of transceivers 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of the present application.

[0172] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, 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 4001 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.

[0173] Bus 4002 may include a path for transmitting information between the above components. Bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. Bus 4002 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 10 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.

[0174] The memory 4003 may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, 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.

[0175] The memory 4003 is used to store the application code (computer program) for executing the solution of the present application, and the execution is controlled by the processor 4001. The processor 4001 is used to execute the application code stored in the memory 4003 to implement the content shown in the above method embodiment.

[0176] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the computer can execute the corresponding contents of the aforementioned method embodiment.

[0177] According to one aspect of the present application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in various optional implementations of the above-described method embodiments.

[0178] 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.

[0179] The above are only some of the embodiments of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made 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: In response to an upgrade request for target software, obtaining a differential package corresponding to the target software, the differential package including upgrade control information and differential data corresponding to each of a plurality of target sub-data, the target sub-data being sub-data included in the second firmware for which similar data exists in the first firmware; the first firmware being firmware of a current version of the target software to be upgraded, and the second firmware being firmware of a target version to which the target software is to be upgraded; The upgrade control information includes location indication information, where the location indication information is used to determine storage space in the terminal device for similar data corresponding to each differential data and each first data, where the first data is the same data among the similar data corresponding to the two target sub-data; Parsing the differential packet to obtain the plurality of differential data and the upgrade control information; completing the upgrade of the second firmware based on the plurality of differential data and the upgrade control information; The step of completing the upgrade of the second firmware based on the plurality of differential data and the upgrade control information includes: Determining, according to the upgrade control information, a first storage space in the terminal device for similar data corresponding to each differential data, and a second storage space in the terminal device for each first data; For each differential data, if the first storage space corresponding to the differential data includes the second storage space, the following operations are performed: If the first data exists in the second storage space, the first data is stored in a designated storage space, target data corresponding to the differential data is obtained based on similar data in the first storage space corresponding to the differential data and the differential data, and the similar data in the first storage space is deleted; If the first data does not exist in the second storage space, obtaining the first data corresponding to the differential data from the designated storage space, obtaining the target data corresponding to the differential data based on the differential data, the data in the first storage space corresponding to the differential data, and the first data, and deleting similar data in the first storage space; For each differential data, if the first storage space corresponding to the differential data does not include the second storage space, the following is further included: Based on the similar data in the first storage space corresponding to the differential data and the differential data, target data corresponding to the differential data is obtained, and the similar data in the first storage space is deleted.

2. The method according to claim 1, characterized in that The location indication information includes a first starting storage address of the first firmware in the server, first indication information of each first data, and a first correspondence between each differential data and its corresponding similar data; the first indication information of a first data is the first storage location information of the first data in the server relative to the first starting storage address; the second indication information is the second storage location information of the similar data corresponding to each differential data in the server relative to the first starting storage address; The determining, according to the upgrade control information, a first storage space of similar data corresponding to each differential data in the terminal device and a second storage space of each first data in the terminal device includes: Based on the first corresponding relationship, determine second indication information of similar data corresponding to each differential data, and obtain a second starting storage address of the first firmware in the terminal device; For each differential data, based on the second storage location information corresponding to the differential data and the second starting storage address, determining a first storage space in the terminal device for similar data corresponding to the differential data; For each first data, the second storage space of the first data in the terminal device is determined according to the first storage location information of the first data and the second starting storage address.

3. The method according to claim 2, characterized in that For each first data item, the first storage location information includes a first address offset of the first data item relative to the first starting storage address, and a first data length of the first data item; and for each first data item, determining the second storage space of the first data item in the terminal device according to the first storage location information of the first data item and the second starting storage address includes: For each first data, determining a third starting storage address corresponding to the first data in the terminal device based on the first address offset and the second starting storage address of the first data, and determining a second storage space for the first data in the terminal device based on the third starting storage address and the first data length; For each differential data, the second storage location information includes a second address offset of similar data corresponding to the differential data relative to the first starting storage address, and a second data length of the similar data corresponding to the differential data; and determining, for each differential data, a first storage space in the terminal device for the similar data corresponding to the differential data based on the second storage location information corresponding to the differential data and the second starting storage address, includes: For each differential data, based on the second address offset corresponding to the differential data and the second starting storage address, determine the fourth starting storage address corresponding to the similar data corresponding to the differential data in the terminal device; based on the fourth starting storage address and the second data length, determine the first storage space in the terminal device for the similar data corresponding to the differential data.

4. The method according to any one of claims 2 to 3, characterized in that The upgrade request includes identification information of the target software, including the software identification and the version identification of the current version. The differential package is generated by the server in the following manner: Based on the identification information, determining a first firmware and a second firmware of the target software, and dividing data in the second firmware into a plurality of sub-data; determining, based on the first firmware and the second firmware, target sub-data among the plurality of sub-data and similar data corresponding to each target sub-data; For each of the target sub-data, if the similar data corresponding to at least two target sub-data include identical data, the identical data is used as the first data corresponding to the at least two target sub-data, and first indication information corresponding to the first data is generated; Determine differential data between each target sub-data and corresponding similar data, generate second indication information for each similar data, and establish a first corresponding relationship between each differential data and the second indication information for its corresponding similar data; Obtaining a first starting storage address of the first firmware in the server, and generating the upgrade control information based on the first corresponding relationship, each first indication information, and the first starting storage address; The differential package is generated based on the upgrade control information and each of the differential data.

5. The method according to claim 4, characterized in that The server also performs the following operations: Determining, based on the first firmware and the second firmware, a third storage space in the server for second data in the first firmware, where the second data refers to data that is not included in the second firmware and is not required for upgrading; For each first data item, determine a target storage space for the first data item in the third storage space based on the storage space required by the first data item, generate third indication information corresponding to the first data item based on the target storage space, and establish a second correspondence between the first indication information and the third indication information corresponding to each first data item; The upgrade control information also includes the second corresponding relationship; The step of storing the first data in a designated storage space includes: Determine, according to the second corresponding relationship, third indication information corresponding to the first indication information corresponding to the data; Based on the third indication information and the second starting storage address, determining a fourth storage space in the terminal device for the second data corresponding to the third indication information, and using the fourth storage space as the designated storage space corresponding to the first data; The data in the fourth storage space is deleted, and the first data is copied to the fourth storage space.

6. The method according to claim 5, characterized in that If the third storage space includes a plurality of discontinuous fifth storage spaces; determining, for each first data, a target storage space of the first data in the third storage space according to the storage space required by the first data, comprises: Determining the size of each of the fifth storage spaces; According to the storage space size required for the first data, a target storage space corresponding to the first data is determined in each of the fifth storage spaces, and the target storage space includes at least one fifth storage space whose target space size is not less than and is closest to the required storage space size. The target space size is the space size corresponding to the at least one fifth storage space.

7. A software upgrade device, characterized in that: include: a differential package acquisition module, configured to, in response to an upgrade request for target software, acquire a differential package corresponding to the target software, wherein the differential package includes upgrade control information and differential data corresponding to each of a plurality of target sub-data, wherein the target sub-data refers to sub-data included in the second firmware that has similar data in the first firmware; The upgrade control information includes location indication information, where the location indication information is used to determine storage space in the terminal device for similar data corresponding to each differential data and each first data, where the first data is the same data among the similar data corresponding to the two target sub-data; A differential packet parsing module, configured to parse the differential packet to obtain the plurality of differential data and the upgrade control information; An upgrading module, configured to complete the upgrading of the second firmware based on the plurality of differential data and the upgrading control information; When the upgrade module completes the upgrade of the second firmware based on the plurality of differential data and the upgrade control information, the upgrade module is specifically configured to: Determining, according to the upgrade control information, a first storage space in the terminal device for similar data corresponding to each differential data, and a second storage space in the terminal device for each first data; For each differential data, if the first storage space corresponding to the differential data includes the second storage space, the following operations are performed: If the first data exists in the second storage space, the first data is stored in a designated storage space, target data corresponding to the differential data is obtained based on similar data in the first storage space corresponding to the differential data and the differential data, and the similar data in the first storage space is deleted; If the first data does not exist in the second storage space, obtaining the first data corresponding to the differential data from the designated storage space, obtaining the target data corresponding to the differential data based on the differential data, the data in the first storage space corresponding to the differential data, and the first data, and deleting similar data in the first storage space; For each differential data, if the first storage space corresponding to the differential data does not include the second storage space, the upgrading module is further configured to: Based on the similar data in the first storage space corresponding to the differential data and the differential data, target data corresponding to the differential data is obtained, and the similar data in the first storage space is deleted.

8. An electronic device, characterized in that: The method comprises a memory and a processor, wherein a computer program is stored in the memory, and the processor executes the method according to any one of claims 1 to 6 when running the computer program.

9. A computer-readable storage medium, characterized in that The storage medium stores a computer program. When the computer program is executed by a processor, the processor executes the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Firmware upgrading method and device, and terminal

    CN111104149A

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

    CN111796856A