Software upgrading method and device, storage medium and embedded equipment

By dividing the target firmware package into multiple blocks and generating differential blocks, the problem of data corruption caused by abnormal power outage and restart during the embedded device upgrade process is solved, the hardware resource utilization and program scalability are improved, and the target program is ensured availability.

CN118535202APending Publication Date: 2024-08-23BEIJING QISHENG SCIENCE AND TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310126565.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-02-16
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

During the program upgrade process of embedded devices, abnormal power outages and restarts lead to data destruction in the storage area, resulting in update failures and inability to operate normally. Moreover, due to the large amount of data in the original firmware package, the backup area occupies a large area, limiting other areas. space utilization and program expansion.

Method used

By dividing the target firmware package into a plurality of first firmware blocks and second firmware blocks, generating differential firmware blocks, storing the differential firmware blocks in the backup area, and replacing the first firmware block in the program execution area with the matching second firmware block, if an abnormal power outage occurs and restarts, use the differential firmware block in the backup area to perform differential restoration processing to ensure the availability of the target program.

Benefits of technology

It reduces the space occupied by the backup area, improves the utilization of hardware resources, increases the space in other areas, makes program expansion more flexible, and ensures the availability of the target program under abnormal circumstances.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535202A
    Figure CN118535202A
Patent Text Reader

Abstract

The invention provides a software upgrading method and device, a storage medium and embedded device.The method comprises the steps that a target firmware package used for updating a target program is received; dividing a current firmware package of the target program and the target firmware package to obtain a plurality of first firmware blocks corresponding to the current firmware package and a plurality of second firmware blocks corresponding to the target firmware package; wherein the number of the first firmware blocks is the same as that of the second firmware blocks; according to each first firmware block and a second firmware block matched with the first firmware block, generating a differential firmware block corresponding to the first firmware block; and storing a differential firmware block corresponding to the first firmware block to a first backup area of the embedded device, and replacing the first firmware block in a program running area of the embedded device with the matched second firmware block.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a software upgrading method, apparatus, storage medium and embedded device. Background Art

[0002] When upgrading the programs and firmware deployed on embedded devices, Over-the-Air Technology (OTA) can be used to remotely implement it; for example, the embedded device can download the update firmware package of the program to be upgraded through the network, and copy the update firmware package to the storage area running the application APP to update the program to be upgraded.

[0003] During the program upgrade process, if the embedded device experiences an abnormal power outage and restart, the data in the storage area running the APP will be destroyed, which will cause the program to be upgraded to fail to update and fail to run normally. In order to ensure the availability of the embedded device, a backup area can be divided from the storage area, and the original firmware package of the program to be upgraded can be stored in the backup area before the program is upgraded, so that when the program update fails, the original firmware package can be obtained from the backup area for recovery. Since the amount of data in the original firmware package is large, the area of ​​the divided backup area is large, resulting in the limitation of the space of other areas running the program in the storage area, which is not conducive to the expansion of the program and the effective use of hardware resources. Summary of the invention

[0004] The embodiments of the present disclosure at least provide a software upgrading method, apparatus, storage medium and embedded device.

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

[0006] receiving a target firmware package for updating a target program;

[0007] The current firmware package of the target program and the target firmware package are divided to obtain the

[0008] a plurality of first firmware blocks corresponding to the current firmware package, and a plurality of second firmware blocks corresponding to the target firmware package; wherein the number of the first firmware blocks is the same as the number of the second firmware blocks;

[0009] According to each of the first firmware blocks and the second firmware blocks matching the first firmware blocks, a differential firmware block corresponding to the first firmware block is generated; and the differential firmware block corresponding to the first firmware block is stored in the first backup area of ​​the embedded device, and the first firmware block in the program running area of ​​the embedded device is replaced with the matching second firmware block.

[0010] In an optional implementation, generating a differential firmware block corresponding to the first firmware block according to each of the first firmware blocks and the second firmware block matching the first firmware block; storing the differential firmware block corresponding to the first firmware block in a first backup area of ​​the embedded device, and replacing the first firmware block in a program running area of ​​the embedded device with the matching second firmware block, includes:

[0011] Determining a firmware block to be upgraded from the plurality of first firmware blocks according to the division order;

[0012] For the firmware block to be upgraded, the firmware block to be upgraded is stored in the second backup area in an overwritten manner; a differential firmware block corresponding to the firmware block to be upgraded is generated according to the firmware block to be upgraded and a second firmware block matching the firmware block to be upgraded; the differential firmware block corresponding to the firmware block to be upgraded is stored in the first backup area, and the firmware block to be upgraded in the program running area is replaced with the matching second firmware block;

[0013] Return to the step of determining the firmware block to be upgraded from the plurality of first firmware blocks in the divided order until there is no first firmware block that has not been replaced.

[0014] In an optional implementation, the number of the plurality of first firmware blocks is n, and the determined firmware block to be upgraded is the i-th first firmware block, n is a positive integer greater than 1, and i is a positive integer less than or equal to n, and the method further includes:

[0015] If, in the process of storing the firmware block to be upgraded in the second backup area in an overwritten manner, generating a differential firmware block corresponding to the firmware block to be upgraded according to the firmware block to be upgraded and a second firmware block matching the firmware block to be upgraded, and storing the differential firmware block corresponding to the firmware block to be upgraded in the first backup area, the embedded device is abnormally powered off and restarted, the execution

[0016] Follow these steps:

[0017] Using the differential firmware blocks stored in the first backup area, differential restoration processing is performed on the i-1th second firmware block to the first second firmware block in the program running area to obtain the i-1th first firmware block to the first first firmware block.

[0018] In an optional implementation, the number of the plurality of first firmware blocks is n, and the determined firmware block to be upgraded is the i-th first firmware block, n is a positive integer greater than 1, and i is a positive integer greater than 1 and less than or equal to n, and the method further includes:

[0019] If the embedded device is abnormally powered off and restarted during the process of replacing the firmware block to be upgraded in the program running area with the matching second firmware block, the following steps are performed:

[0020] Using the firmware block to be upgraded stored in the second backup area, replacing the i-th first firmware block that is damaged in the program running area;

[0021] Using the differential firmware blocks stored in the first backup area, differential restoration processing is performed on the i-1th second firmware block to the first second firmware block to obtain the i-1th first firmware block to the first first firmware block.

[0022] In an optional implementation manner, the target firmware package is issued by the server, and the method further includes:

[0023] Feedback information is generated and sent to a server, wherein the feedback information includes first feedback information indicating that the target program is updated successfully, or second feedback information indicating that the target program is updated unsuccessfully.

[0024] In a second aspect, an embodiment of the present disclosure further provides an embedded device, including: a storage component and a processing component;

[0025] The storage component includes: a first backup area, and a program running area; a current firmware package of a target program is running in the program running area; the first backup area is used to store differential firmware blocks corresponding to each first firmware block after the current firmware package is divided, wherein the differential firmware block is generated according to the first firmware block and the second firmware block matching the first firmware block,

[0026] The second firmware block is obtained by dividing the received target firmware package for updating the target program;

[0027] The processing component is used to execute the software upgrade method as described in the first aspect or any one of the embodiments.

[0028] In an optional implementation, the storage component further includes: a second backup area;

[0029] The second backup area is used to store the firmware blocks to be upgraded determined from the multiple first firmware blocks.

[0030] In a third aspect, the present disclosure also provides a software upgrade device, including:

[0031] A receiving module, used for receiving a target firmware package for updating a target program;

[0032] a partitioning module, configured to partition the current firmware package and the target firmware package of the target program to obtain a plurality of first firmware blocks corresponding to the current firmware package and a plurality of second firmware blocks corresponding to the target firmware package; wherein the number of the first firmware blocks is the same as the number of the second firmware blocks;

[0033] A replacement module is used to generate a differential firmware block corresponding to the first firmware block according to each of the first firmware blocks and the second firmware block matching the first firmware block; and store the differential firmware block corresponding to the first firmware block in the first backup area of ​​the embedded device, and replace the first firmware block in the program running area of ​​the embedded device with the matching second firmware block.

[0034] In an optional implementation manner, the replacement module generates a differential firmware block corresponding to the first firmware block according to each of the first firmware blocks and the second firmware block matching the first firmware block; and stores the differential firmware block corresponding to the first firmware block in the first backup area of ​​the embedded device, and replaces the first firmware block in the program running area of ​​the embedded device with the matching second firmware block, for:

[0035] Determining a firmware block to be upgraded from the plurality of first firmware blocks according to the division order;

[0036] For the firmware block to be upgraded, the firmware block to be upgraded is stored in a first

[0037] second backup area; generating a differential firmware block corresponding to the firmware block to be upgraded according to the firmware block to be upgraded and the second firmware block matching the firmware block to be upgraded; storing the differential firmware block corresponding to the firmware block to be upgraded in the first backup area, and replacing the firmware block to be upgraded in the program running area with the matching second firmware block;

[0038] Return to the step of determining the firmware block to be upgraded from the plurality of first firmware blocks in the divided order until there is no first firmware block that has not been replaced.

[0039] In an optional implementation, the number of the plurality of first firmware blocks is n, and the determined firmware block to be upgraded is the i-th first firmware block, n is a positive integer greater than 1, and i is a positive integer less than or equal to n, and the device further includes: a restoration module, configured to:

[0040] If, during the process of storing the firmware block to be upgraded in the second backup area in an overwritten manner, generating a differential firmware block corresponding to the firmware block to be upgraded based on the firmware block to be upgraded and a second firmware block matching the firmware block to be upgraded, and storing the differential firmware block corresponding to the firmware block to be upgraded in the first backup area, the embedded device is abnormally powered off and restarted, the following steps are performed:

[0041] Using the differential firmware blocks stored in the first backup area, differential restoration processing is performed on the i-1th second firmware block to the first second firmware block in the program running area to obtain the i-1th first firmware block to the first first firmware block.

[0042] In an optional implementation, the number of the plurality of first firmware blocks is n, and the determined firmware block to be upgraded is the i-th first firmware block, n is a positive integer greater than 1, i is a positive integer greater than 1 and less than or equal to n, and the restoration module is further used to:

[0043] If the embedded device is abnormally powered off and restarted during the process of replacing the firmware block to be upgraded in the program running area with the matching second firmware block, the following steps are performed:

[0044] Using the firmware block to be upgraded stored in the second backup area, replacing the i-th first firmware block that is damaged in the program running area;

[0045] Using the differential firmware blocks stored in the first backup area, differential restoration is performed on the i-1th second firmware block to the first second firmware block to obtain the i-1th first firmware block to the first second firmware block.

[0046] 1 first firmware block.

[0047] In an optional implementation manner, the target firmware package is issued by the server, and the device further includes: a generating module, configured to:

[0048] Feedback information is generated and sent to a server, wherein the feedback information includes first feedback information indicating that the target program is updated successfully, or second feedback information indicating that the target program is updated unsuccessfully.

[0049] In a fourth aspect, an embodiment of the present disclosure further provides a computer device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the computer device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the above-mentioned first aspect, or any possible implementation of the first aspect, are performed.

[0050] In a fifth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned first aspect or any possible implementation of the first aspect are executed.

[0051] The software upgrade method provided by the embodiment of the present disclosure divides the current firmware package and the target firmware package of the target program after receiving the target firmware package, obtains multiple first firmware blocks corresponding to the current firmware package, and multiple second firmware blocks corresponding to the target firmware package, generates a differential firmware block corresponding to the first firmware block according to each first firmware block and the second firmware block matching the first firmware block, the data volume of the differential firmware block is smaller than the first firmware block, and the differential firmware block corresponding to the first firmware block is stored in the first backup area of ​​the embedded device, thereby reducing the size of the area space occupied by the first backup area, and the other area space in the storage area for running the program is larger, thereby improving the utilization rate of hardware resources, and the larger space in the other area makes the expansion of the program more flexible.

[0052] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the technical solution of the embodiment of the present disclosure, the following will describe the technical solution required in the embodiment.

[0054] The accompanying drawings to be used are briefly introduced. The accompanying drawings here are incorporated into the specification and constitute a part of the specification. These drawings show embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only show certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.

[0055] Figure 1 A flowchart of a software upgrade method provided by an embodiment of the present disclosure is shown;

[0056] Figure 2 A flowchart of a software upgrade method provided by an embodiment of the present disclosure is shown;

[0057] Figure 3 A schematic diagram showing a processing procedure when an embedded device is abnormally powered off and restarted in a software upgrade method provided by an embodiment of the present disclosure;

[0058] Figure 4 A schematic diagram of the structure of an embedded device provided by an embodiment of the present disclosure is shown;

[0059] Figure 5 A schematic diagram of the architecture of a software upgrade device provided by an embodiment of the present disclosure is shown;

[0060] Figure 6 A schematic diagram of a computer device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0061] In order to make the purpose, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.

[0062] According to research, during the program upgrade process, if the embedded device is abnormally powered off and restarted, the data in the storage area where the APP is running will be destroyed, which will cause the program to be upgraded to fail to update and cannot run normally.

[0063] A backup area is divided in the domain, and the original firmware package of the program to be upgraded is stored in the backup area before the program is upgraded, so that when the program update fails, the original firmware package can be obtained from the backup area for recovery and restoration; it can be seen that the storage area stores the updated firmware package, the original firmware package, and the backed-up original firmware package. Since the data volume of the original firmware package is large, the area of ​​the divided backup area is large, that is, the backup area occupies a larger area space, resulting in other area spaces for running programs in the storage area being limited, which is not conducive to the expansion of the program and the effective use of hardware resources.

[0064] In order to alleviate the above-mentioned problem, the present disclosure provides a software upgrade method. After receiving a target firmware package, the current firmware package and the target firmware package of the target program are divided to obtain multiple first firmware blocks corresponding to the current firmware package and multiple second firmware blocks corresponding to the target firmware package. According to each first firmware block and the second firmware block matching the first firmware block, a differential firmware block corresponding to the first firmware block is generated, and the data volume of the differential firmware block is smaller than that of the first firmware block. When the differential firmware block corresponding to the first firmware block is stored in the first backup area of ​​the embedded device, the size of the area space occupied by the first backup area is reduced, and the other area space for running the program in the storage area is larger, thereby improving the utilization rate of hardware resources, and the larger space in the other area makes the expansion of the program more flexible.

[0065] The defects existing in the above schemes and the proposed solutions are the results obtained by the inventor after practice and careful research. Therefore, the discovery process of the above problems and the solutions proposed by the present disclosure for the above problems below should be the contributions made by the inventor to the present disclosure during the disclosure process.

[0066] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0067] To facilitate understanding of this embodiment, a software upgrade method disclosed in the embodiment of the present disclosure is first introduced in detail. The execution subject of the software upgrade method provided in the embodiment of the present disclosure is generally a computer device with certain computing capabilities.

[0068] The following takes the execution subject as an embedded device as an example to illustrate the software upgrade method provided by the embodiment of the present disclosure. The embedded device may be, for example, a microcontroller unit (Microcontroller Unit,

[0069] MCU) embedded devices, etc.

[0070] See also Figure 1 FIG. 1 is a flowchart of a software upgrade method provided by an embodiment of the present disclosure, which is applied to an embedded device. The method includes S101 to S103, wherein:

[0071] S101, receiving a target firmware package for updating a target program;

[0072] S102, dividing the current firmware package and the target firmware package of the target program to obtain a plurality of first firmware blocks corresponding to the current firmware package and a plurality of second firmware blocks corresponding to the target firmware package; wherein the number of the first firmware blocks is the same as the number of the second firmware blocks;

[0073] S103, generating a differential firmware block corresponding to the first firmware block according to each of the first firmware blocks and the second firmware block matching the first firmware block; and storing the differential firmware block corresponding to the first firmware block in the first backup area of ​​the embedded device, and replacing the first firmware block in the program running area of ​​the embedded device with the matching second firmware block.

[0074] S101 to S103 are described in detail below.

[0075] In S101, the target firmware package is used to update the target program, and the embedded device also includes the current firmware package of the target program, wherein the target firmware package and the current firmware package can be written function code modules. The target firmware package is received, for example, the target firmware package sent by the server can be received, so as to use the target firmware package to upgrade the target program installed in the embedded device.

[0076] In S102, after receiving the target firmware package, the current firmware package and the target firmware package of the target program are divided to obtain a plurality of first firmware blocks corresponding to the current firmware package and a plurality of second firmware blocks corresponding to the target firmware package. During implementation, the current firmware package and the target firmware package can be evenly divided according to the preset data volume to obtain a plurality of first firmware blocks and a plurality of second firmware blocks, wherein the number of the first firmware blocks and the second firmware blocks is the same, and the data volume of the first firmware blocks and the second firmware blocks is the same, that is, the data volume of the first firmware blocks and the second firmware blocks are respectively consistent with the preset data volume. Here, the preset data volume can be set as needed.

[0077] For example, the preset data size is 8K, the data size of the current firmware package is 56K, and the data size of the target firmware package is 60K. It can be seen that the current firmware package can be divided into 7 blocks and the target firmware package can be divided into 8 blocks. The maximum number is taken as the number of the first firmware block and the second firmware block, that is, the first firmware block and the second firmware block are

[0078] The number of second firmware blocks is 8. Then the current firmware package is divided to obtain first firmware blocks 1, ..., first firmware block 7, and first firmware block 8 is obtained according to a preset value such as 0; and the target firmware package is divided to obtain second firmware blocks 1, ..., second firmware block 7, and remaining firmware blocks. It can be seen that the data size of the remaining firmware blocks is 4K (less than 8K). At this time, the preset value such as 0 can be used to supplement the remaining firmware blocks to obtain the second firmware block 8 with a data size of 8K.

[0079] Here, a matching relationship may be established between the first firmware block and the second firmware block, for example, the first firmware block and the second firmware block may be matched according to the division order. Exemplarily, when the number of first firmware blocks is m (m is a positive integer greater than 1), the first firmware block 1 matches the second firmware block 1, the first firmware block 2 matches the second firmware block 2, ..., the first firmware block m matches the second firmware block m, etc.

[0080] In S103, during implementation, a differential compression algorithm can be used to generate a differential firmware block corresponding to the first firmware block according to the first firmware block and the second firmware block that matches the first firmware block, wherein the differential compression algorithm can be determined as needed. A first backup area is provided in the embedded device, and after obtaining the differential firmware block corresponding to the first firmware block, the differential firmware block corresponding to the first firmware block is stored in the first backup area. And after determining that the differential firmware block corresponding to the first firmware block has been stored in the first backup area, the first firmware block in the program running area of ​​the embedded device is replaced with the matching second firmware block. Here, when each first firmware block in the program running area is replaced with the second firmware block, the update of the target program is completed.

[0081] In an optional implementation, generating a differential firmware block corresponding to the first firmware block according to each of the first firmware blocks and the second firmware block matching the first firmware block; storing the differential firmware block corresponding to the first firmware block in a first backup area of ​​the embedded device, and replacing the first firmware block in a program running area of ​​the embedded device with the matching second firmware block, includes:

[0082] Step a1, determining a firmware block to be upgraded from the plurality of first firmware blocks according to the division order;

[0083] Step a2, for the firmware block to be upgraded, overwrite the firmware block to be upgraded,

[0084] storing the firmware block to the second backup area; generating a differential firmware block corresponding to the firmware block to be upgraded according to the firmware block to be upgraded and the second firmware block matching the firmware block to be upgraded; storing the differential firmware block corresponding to the firmware block to be upgraded to the first backup area, and replacing the firmware block to be upgraded in the program running area with the matching second firmware block;

[0085] Step a3, returning to the step of determining the firmware block to be upgraded from the plurality of first firmware blocks in the order of division, until there is no first firmware block that has not been replaced.

[0086] During implementation, the firmware block to be upgraded can be determined from the multiple first firmware blocks according to the division order. For example, when the number of the multiple first firmware blocks is n, and n is a positive integer greater than 1, the division order is first firmware block 1, ..., first firmware block n, so the first firmware block 1 can be determined as the firmware block to be upgraded first, and then the first firmware block 2 can be determined as the firmware block to be upgraded, and so on, and the first firmware block n is the last firmware block to be upgraded.

[0087] After determining the firmware block to be upgraded, the firmware block to be upgraded can be first stored in the second backup area in an overwritten manner. The second backup area can match the data volume of the first firmware block, for example, when the data volume of the first firmware block is 8K, the second backup area can be 8K.

[0088] After the firmware block to be upgraded is stored in the second backup area, a differential firmware block corresponding to the firmware block to be upgraded can be generated based on the firmware block to be upgraded and the second firmware block that matches the firmware block to be upgraded. For example, when the firmware block to be upgraded is the first firmware block 1, a differential firmware block 1 corresponding to the first firmware block 1 can be generated based on the first firmware block 1 and the second firmware block 1. The differential firmware block corresponding to the firmware block to be upgraded is stored in the first backup area, and then after the differential firmware block is stored in the first backup area, the firmware block to be upgraded in the program running area is replaced with the matching second firmware block. Then, the process returns to the step of determining the firmware block to be upgraded from the multiple first firmware blocks in the order of division until there is no first firmware block that has not been replaced, that is, until all the first firmware blocks in the program running area are replaced with the second firmware blocks.

[0089] Here, according to the division order, the firmware block to be upgraded is determined from the multiple first firmware blocks, that is, the first firmware block in the program running area is replaced with the second firmware block according to the division order, so as to achieve the orderly upgrade of the target program.

[0090] The firmware block to be upgraded is stored in the second backup area in an overwriting manner. If the firmware block to be upgraded is damaged, the firmware block to be upgraded can be obtained from the second backup area to ensure the availability of the target program; and a differential firmware block corresponding to the firmware block to be upgraded is generated according to the firmware block to be upgraded and the second firmware block matching the firmware block to be upgraded, and the differential firmware block corresponding to the firmware block to be upgraded is stored in the first backup area. Since the data volume of the differential firmware block is smaller than that of the first firmware block, compared with the method of directly backing up the current firmware block, the area space of the first backup area is smaller, and the area space of other areas in the storage area except the first backup area and the second backup area (such as the program running area) becomes larger accordingly, so that the scalability of the target program is better and the utilization rate of hardware resources is higher.

[0091] During the program upgrade process, the embedded device may experience an abnormal power outage and restart, which may cause the data in the storage area where the target program is running to be destroyed, resulting in the failure of the target program update and the inability to use the target program normally. In order to alleviate the above problems, when this happens, the target program can be restored to the current firmware package to ensure that the target program can be used normally.

[0092] In an optional implementation, the number of the plurality of first firmware blocks is n, and the determined firmware block to be upgraded is the i-th first firmware block, n is a positive integer greater than 1, and i is a positive integer less than or equal to n, and the method further includes:

[0093] Step b1: if the embedded device is abnormally powered off and restarted during the process of storing the firmware block to be upgraded in the second backup area in an overwritten manner, generating a differential firmware block corresponding to the firmware block to be upgraded based on the firmware block to be upgraded and a second firmware block matching the firmware block to be upgraded, and storing the differential firmware block corresponding to the firmware block to be upgraded in the first backup area, the following steps are performed:

[0094] Step b2: using the differential firmware blocks stored in the first backup area, respectively perform differential restoration processing on the i-1th second firmware block to the first second firmware block in the program running area to obtain the i-1th first firmware block to the first first firmware block.

[0095] Here, if the firmware block to be upgraded is stored in the second backup area in an overwritten manner, a pair of the firmware block to be upgraded is generated according to the firmware block to be upgraded and the second firmware block matching the firmware block to be upgraded.

[0096] In the process of storing the differential firmware block corresponding to the firmware block to be upgraded in the first backup area, the embedded device has an abnormal power outage and restart. At this time, the firmware block to be upgraded has not been updated, that is, what is stored in the program running area is the firmware block to be upgraded, the second firmware block before the firmware block to be upgraded that has been replaced, and the first firmware block before the firmware block to be upgraded that has not been replaced. It can be seen that in order to enable the target program to be used normally, the second firmware block before the firmware block to be upgraded that has been replaced needs to be restored.

[0097] Exemplarily, if the firmware block to be upgraded is the 1st first firmware block, then no restore operation is required at this time. If the firmware block to be upgraded is the i-th first firmware block, n≥i>1, then the firmware block to be upgraded (i.e., the i-th first firmware block), the 1st second firmware block to the i-1th second firmware block, the i+1th first firmware block to the nth first firmware block are stored in the program running area. At the same time, according to the process of the above steps a1 to a3, it can be known that the first backup area stores the differential firmware block 1 corresponding to the 1st first firmware block to the differential firmware block i-1 corresponding to the i-1th first firmware block.

[0098] Therefore, the differential firmware blocks (i.e., differential firmware block 1 to differential firmware block i-1) stored in the first backup area can be used to perform differential restoration processing on the i-1th second firmware block to the first second firmware block in the program running area, respectively, to obtain the i-1th first firmware block to the first first firmware block. During implementation, the differential firmware block i-1 can be used to perform differential restoration processing on the i-1th second firmware block to obtain the i-1th first firmware block; then the differential firmware block i-2 can be used to perform differential restoration processing on the i-2th second firmware block to obtain the i-2th first firmware block, and so on, until the first first firmware block is obtained. Here, the program running area stores the first first firmware block to the nth first firmware block, i.e., the complete current firmware block. It can be seen that the program running area can run the target program normally, and the target program can be used normally.

[0099] Here, during the program update process, the differential firmware block corresponding to the first firmware block is first stored in the first backup area, and then the first firmware block in the program running area is replaced by the second firmware block. In the event of an abnormal power outage and restart in the embedded device, the target program can be restored in real time to ensure the availability of the target program.

[0100] At the same time, in the process of storing the firmware block to be upgraded in the second backup area in an overwritten manner, generating a differential firmware block corresponding to the firmware block to be upgraded according to the firmware block to be upgraded and the second firmware block matching the firmware block to be upgraded, and storing the differential firmware block corresponding to the firmware block to be upgraded in the first backup area, the embedded device has an abnormal power-off and restart situation. In this scheme, the first backup area backs up the differential firmware block corresponding to the 1st first firmware block to the differential firmware block corresponding to the i-1th first firmware block, rather than the differential firmware blocks corresponding to all the first firmware blocks. The amount of data of the generated differential firmware block is small, and the resources used for generating the differential firmware block are small; and in this scheme, it is necessary to perform differential restoration processing on the i-1th second firmware block to the 1st second firmware block. Compared with the related art of restoring the entire original firmware package (i.e., the current firmware package), the processing amount of the differential restoration processing is small and the restoration efficiency is high.

[0101] In another optional implementation, the number of the plurality of first firmware blocks is n, and the determined firmware block to be upgraded is the i-th first firmware block, n is a positive integer greater than 1, and i is a positive integer greater than 1 and less than or equal to n, and the method further includes:

[0102] Step c1: if the embedded device is abnormally powered off and restarted during the process of replacing the firmware block to be upgraded in the program running area with the matching second firmware block, perform the following steps:

[0103] Step c2, using the firmware block to be upgraded stored in the second backup area to replace the damaged i-th first firmware block in the program running area;

[0104] Step c3: using the differential firmware blocks stored in the first backup area, respectively perform differential restoration processing on the i-1th second firmware block to the first second firmware block to obtain the i-1th first firmware block to the first first firmware block.

[0105] Here, if the embedded device experiences an abnormal power outage and restart during the process of replacing the firmware block to be upgraded in the program running area with a matching second firmware block, then the firmware block to be upgraded is destroyed, that is, what is stored in the program running area is the destroyed firmware block to be upgraded, the replaced second firmware block before the firmware block to be upgraded, and the unreplaced first firmware block before the firmware block to be upgraded. It can be seen that in order to enable the target program to be used normally, it is necessary to restore the replaced second firmware block before the firmware block to be upgraded and to restore the firmware block to be upgraded.

[0106] For example, if the firmware block to be upgraded is the first first firmware block, then

[0107] The firmware block to be upgraded is obtained, and the upgraded firmware block is used to replace the damaged first firmware block in the program running area.

[0108] If the firmware block to be upgraded is the i-th first firmware block, n≥i>1, then what is stored in the program running area is the damaged firmware block to be upgraded, the 1st second firmware block to the i-1th second firmware block, and the i+1th first firmware block to the nth first firmware block. At the same time, according to the process of the above steps a1 to a3, it can be known that what is stored in the first backup area is the differential firmware block 1 corresponding to the 1st first firmware block to the differential firmware block i-1 corresponding to the i-1th first firmware block, and what is stored in the second backup area is the i-th first firmware block.

[0109] Therefore, the i-th first firmware block stored in the second backup area can be used to replace the i-th first firmware block that is damaged in the program running area; then, the differential firmware blocks (i.e., differential firmware block 1 to differential firmware block i-1) stored in the first backup area can be used to perform differential restoration processing on the i-1th second firmware block to the 1st second firmware block in the program running area, respectively, to obtain the i-1th first firmware block to the 1st first firmware block.

[0110] During implementation, the differential firmware block i-1 may be used to perform differential restoration processing on the i-1th second firmware block to obtain the i-1th first firmware block; and then the differential firmware block i-2 may be used to perform differential restoration processing on the i-2th second firmware block to obtain the i-2th first firmware block, and so on, until the first first firmware block is obtained. Here, the program running area stores the first first firmware block to the nth first firmware block, that is, the complete current firmware block. It can be seen that the program running area can run the target program normally, and the target program can be used normally.

[0111] Here, during the program update process, the firmware block to be upgraded is first stored in the second backup area, the differential firmware block corresponding to the firmware block to be upgraded is stored in the first backup area, and then the first firmware block in the program running area is replaced with the second firmware block. In this way, when the embedded device has an abnormal power outage and restart, the target program can be restored in real time to ensure the availability of the target program.

[0112] At the same time, in the process of replacing the firmware block to be upgraded in the program running area with the matching second firmware block, the embedded device has an abnormal power failure and restart. In this solution, the first backup area backs up the differential firmware block corresponding to the 1st first firmware block to the differential firmware block corresponding to the i-1th first firmware block.

[0113] The differential firmware block is a differential firmware block, rather than a differential firmware block corresponding to all the first firmware blocks, the data volume of the generated differential firmware block is small, and the resources used to generate the differential firmware block are small; and in this scheme, it is necessary to perform differential restoration processing on the i-1th second firmware block to the first second firmware block, and use the firmware blocks to be upgraded stored in the second backup area to replace the i-th first firmware block destroyed in the program running area. Compared with the related art of restoring the entire original firmware package (i.e., the current firmware package), the differential restoration processing has a smaller processing volume and a higher restoration efficiency.

[0114] In an optional implementation, the target firmware package is issued by a server, and the method further includes: generating feedback information and sending the feedback information to the server, wherein the feedback information includes first feedback information indicating that the target program is updated successfully, or second feedback information indicating that the target program is updated unsuccessfully.

[0115] During implementation, the target firmware package can be issued by the server, and the software upgrade method mentioned in this solution can be remotely implemented using the over-the-air download technology OTA.

[0116] When all the first firmware blocks in the program running area are replaced with the second firmware blocks, the update process of the target program is completed, that is, the target program is successfully updated, and a first feedback message indicating that the target program is successfully updated can be generated, and the first feedback message can be sent to the server. If during the update process of the target program, the embedded device has an abnormal power outage and restart, the target program needs to be restored to the current firmware package, that is, the target program update fails, and a second feedback message indicating that the target program update failed can be generated, and the second feedback message can be sent to the server. For example, the second feedback message can be "Program update failed."

[0117] Alternatively, if the firmware block to be upgraded is the i-th first firmware block, and during the update process of the i-th first firmware block, the embedded device has an abnormal power outage and restart, causing the target program update to fail, then the second feedback information can be "the i-th first firmware block update failed, the program update failed".

[0118] See also Figure 2 As shown, combined Figure 2 The software upgrade method is illustrated by way of example. Figure 2 The APP to be upgraded is the target firmware package proposed in this solution, the original APP is the current firmware package proposed in this solution, the differential backup area is the first storage area proposed in this solution, and the block backup area is the second storage area proposed in this solution.

[0119] APP is further divided to obtain a first firmware block A1, a first firmware block A2, ..., a first firmware block An, and a second firmware block B1, a second firmware block B2, ..., a second firmware block Bn.

[0120] The first firmware block A1 is used as the firmware block to be upgraded. Step 1: store the firmware block to be upgraded in the block backup area. Step 2: generate a differential firmware block (such as B1->A1 differential package) corresponding to the firmware block to be upgraded according to the firmware block to be upgraded and the second firmware block that matches the firmware block to be upgraded (the first firmware block A1 matches the second firmware block B1), and store the differential firmware block corresponding to the firmware block to be upgraded in the differential backup area. Step 3: update the current block Flash (fast storage area), specifically, replace the firmware block to be upgraded in the program running area with the matching second firmware block, that is, replace the first firmware block A1 with the second firmware block B1. Then, the first firmware block A2 is used as the firmware block to be upgraded, and steps 1 to 3 are re-executed until the first firmware block An is replaced with the second firmware block Bn.

[0121] See also Figure 3 As shown, combined Figure 3 The processing process of the embedded device in the software upgrade method when there is an abnormal power failure and restart is exemplified. The following description is made by taking the firmware block to be upgraded as the first firmware block Ai.

[0122] In one possible method, if during step 1 and step 2, the embedded device experiences an abnormal power outage and restart, here, the first firmware block Ai in the original APP has not been replaced, so the following process is performed: using the differential firmware blocks stored in the differential backup area (i.e., Bi-1->Ai-1 differential package to B1->A1 differential package), the second firmware block Bi-1 to the second firmware block B1 in the original APP are differentially restored to obtain the first firmware block Ai-1 to the first firmware block A1, so that the original APP includes the first firmware blocks, completing the APP restoration process and ensuring that the APP is available.

[0123] In another possible method, if the embedded device experiences an abnormal power outage and restart during step 3, here, the first firmware block Ai in the original APP is damaged, so the following process is performed: first, the first firmware block Ai stored in the block backup area is used to replace the damaged first firmware block Ai in the original APP, and then the differential firmware blocks stored in the differential backup area (i.e., Bi-1->Ai-1 differential package to B1->A1 differential package) are used to perform differential restoration processing on the second firmware block Bi-1 to the second firmware block B1 in the original APP, respectively, to obtain the first firmware block Ai-1 to the first firmware block A1, so that the original APP includes each first firmware block, completing the APP restoration process and ensuring that the APP is available.

[0124] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.

[0125] Based on the same inventive concept, an embedded device is also provided in the embodiment of the present disclosure, see Figure 4As shown, it includes: a storage component 41 and a processing component 42; the storage component includes: a first backup area 411, and a program running area 412; the current firmware package of the target program is running in the program running area; the first backup area is used to store differential firmware blocks corresponding to each first firmware block after the current firmware package is divided, wherein the differential firmware block is generated according to the first firmware block and the second firmware block matching the first firmware block, and the second firmware block is obtained by dividing the received target firmware package for updating the target program; the processing component is used to execute the software upgrade method as described in the above-mentioned embodiment.

[0126] Among them, the processing component can be, for example, a central processing unit (CPU), and the storage component can be, for example, a fast memory Flash, etc. During implementation, a first backup area and a program running area are divided in the storage component. Before the target program is upgraded, the current firmware package of the target program runs in the program running area. The first backup area is used to store the differential firmware blocks corresponding to each first firmware block after the current firmware package is divided. After the processing component executes the software upgrade method as described in the aforementioned embodiment, after the target program is successfully updated, the target firmware package of the target program runs in the program running area. Among them, the process of the processing component executing the software upgrade method described in the aforementioned embodiment can refer to the aforementioned description of the software upgrade method, which will not be repeated here.

[0127] In an optional implementation manner, the storage component 41 further includes: a second backup area 413; the second backup area 413 is used to store the firmware blocks to be upgraded determined from the multiple first firmware blocks.

[0128] During implementation, a second backup area may be divided in the storage component, and the area size of the second backup area matches the data volume of the first firmware package.

[0129] Based on the same inventive concept, the embodiment of the present disclosure also provides a software upgrade device corresponding to the software upgrade method.

[0130] The software upgrade method is similar to the above example, so the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0131] Reference Figure 5 As shown, it is a schematic diagram of the architecture of a software upgrade device provided by an embodiment of the present disclosure, and the device includes: a receiving module 501, a dividing module 502, and a replacing module 503; specifically:

[0132] A receiving module 501 is used to receive a target firmware package for updating a target program;

[0133] A division module 502 is used to divide the current firmware package and the target firmware package of the target program to obtain a plurality of first firmware blocks corresponding to the current firmware package and a plurality of second firmware blocks corresponding to the target firmware package; wherein the number of the first firmware blocks is the same as the number of the second firmware blocks;

[0134] The replacement module 503 is used to generate a differential firmware block corresponding to the first firmware block according to each of the first firmware blocks and the second firmware block matching the first firmware block; and store the differential firmware block corresponding to the first firmware block in the first backup area of ​​the embedded device, and replace the first firmware block in the program running area of ​​the embedded device with the matching second firmware block.

[0135] In an optional implementation manner, the replacement module 503 generates a differential firmware block corresponding to the first firmware block according to each of the first firmware blocks and the second firmware block matching the first firmware block; and stores the differential firmware block corresponding to the first firmware block in the first backup area of ​​the embedded device, and replaces the first firmware block in the program running area of ​​the embedded device with the matching second firmware block, is used to:

[0136] Determining a firmware block to be upgraded from the plurality of first firmware blocks according to the division order;

[0137] For the firmware block to be upgraded, the firmware block to be upgraded is stored in the second backup area in an overwritten manner; a differential firmware block corresponding to the firmware block to be upgraded is generated according to the firmware block to be upgraded and a second firmware block matching the firmware block to be upgraded; the differential firmware block corresponding to the firmware block to be upgraded is stored in the first backup area, and the firmware block to be upgraded in the program running area is replaced with the matching second firmware block;

[0138] Return to the step of determining the firmware to be upgraded from the plurality of first firmware blocks according to the division order.

[0139] The steps of replacing the first firmware block are repeated until there is no first firmware block that has not been replaced.

[0140] In an optional implementation, the number of the plurality of first firmware blocks is n, and the determined firmware block to be upgraded is the i-th first firmware block, n is a positive integer greater than 1, and i is a positive integer less than or equal to n, and the device further includes: a restoration module 504, which is used to:

[0141] If, during the process of storing the firmware block to be upgraded in the second backup area in an overwritten manner, generating a differential firmware block corresponding to the firmware block to be upgraded based on the firmware block to be upgraded and a second firmware block matching the firmware block to be upgraded, and storing the differential firmware block corresponding to the firmware block to be upgraded in the first backup area, the embedded device is abnormally powered off and restarted, the following steps are performed:

[0142] Using the differential firmware blocks stored in the first backup area, differential restoration processing is performed on the i-1th second firmware block to the first second firmware block in the program running area to obtain the i-1th first firmware block to the first first firmware block.

[0143] In an optional implementation, the number of the plurality of first firmware blocks is n, and the determined firmware block to be upgraded is the i-th first firmware block, n is a positive integer greater than 1, i is a positive integer greater than 1 and less than or equal to n, and the restoration module 504 is further used to:

[0144] If the embedded device is abnormally powered off and restarted during the process of replacing the firmware block to be upgraded in the program running area with the matching second firmware block, the following steps are performed:

[0145] Using the firmware block to be upgraded stored in the second backup area, replacing the i-th first firmware block that is damaged in the program running area;

[0146] Using the differential firmware blocks stored in the first backup area, differential restoration processing is performed on the i-1th second firmware block to the first second firmware block to obtain the i-1th first firmware block to the first first firmware block.

[0147] In an optional implementation manner, the target firmware package is issued by the server, and the device further includes: a generating module 505, which is used to:

[0148] Generate feedback information and send the feedback information to the server, wherein the feedback information

[0149] The information includes first feedback information for indicating that the target program is updated successfully, or second feedback information for indicating that the target program is updated unsuccessfully.

[0150] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.

[0151] Based on the same technical concept, the embodiment of the present disclosure also provides a computer device. Figure 6As shown, it is a schematic diagram of the structure of a computer device 600 provided in an embodiment of the present disclosure, including a processor 601, a memory 602, and a bus 603. Among them, the memory 602 is used to store execution instructions, including a memory 6021 and an external memory 6022; the memory 6021 here is also called an internal memory, which is used to temporarily store the operation data in the processor 601, and the data exchanged with the external memory 6022 such as a hard disk. The processor 601 exchanges data with the external memory 6022 through the memory 6021. When the computer device 600 is running, the processor 601 communicates with the memory 602 through the bus 603, so that the processor 601 executes the following instructions:

[0152] receiving a target firmware package for updating a target program;

[0153] Dividing the current firmware package and the target firmware package of the target program to obtain a plurality of first firmware blocks corresponding to the current firmware package and a plurality of second firmware blocks corresponding to the target firmware package; wherein the number of the first firmware blocks is the same as the number of the second firmware blocks;

[0154] According to each of the first firmware blocks and the second firmware blocks matching the first firmware blocks, a differential firmware block corresponding to the first firmware block is generated; and the differential firmware block corresponding to the first firmware block is stored in the first backup area of ​​the embedded device, and the first firmware block in the program running area of ​​the embedded device is replaced with the matching second firmware block.

[0155] In a possible design, the instructions executed by the processor 601 include: generating a differential firmware block corresponding to the first firmware block according to each of the first firmware blocks and the second firmware block matching the first firmware block; and storing the differential firmware block corresponding to the first firmware block in a first backup area of ​​the embedded device, and replacing the first firmware block in a program running area of ​​the embedded device with the matching second firmware block, including:

[0156] Determining a firmware block to be upgraded from the plurality of first firmware blocks according to the division order;

[0157] For the firmware block to be upgraded, the firmware block to be upgraded is stored in the second backup area in an overwritten manner; a differential firmware block corresponding to the firmware block to be upgraded is generated according to the firmware block to be upgraded and a second firmware block matching the firmware block to be upgraded; the differential firmware block corresponding to the firmware block to be upgraded is stored in the first backup area, and the firmware block to be upgraded in the program running area is replaced with the matching second firmware block;

[0158] Return to the step of determining the firmware block to be upgraded from the plurality of first firmware blocks in the divided order until there is no first firmware block that has not been replaced.

[0159] In a possible design, in the instruction executed by the processor 601, the number of the multiple first firmware blocks is n, and the determined firmware block to be upgraded is the i-th first firmware block, n is a positive integer greater than 1, and i is a positive integer less than or equal to n, and the method further includes:

[0160] If, during the process of storing the firmware block to be upgraded in the second backup area in an overwritten manner, generating a differential firmware block corresponding to the firmware block to be upgraded based on the firmware block to be upgraded and a second firmware block matching the firmware block to be upgraded, and storing the differential firmware block corresponding to the firmware block to be upgraded in the first backup area, the embedded device is abnormally powered off and restarted, the following steps are performed:

[0161] Using the differential firmware blocks stored in the first backup area, differential restoration processing is performed on the i-1th second firmware block to the first second firmware block in the program running area to obtain the i-1th first firmware block to the first first firmware block.

[0162] In a possible design, in the instruction executed by the processor 601, the number of the multiple first firmware blocks is n, and the determined firmware block to be upgraded is the i-th first firmware block, n is a positive integer greater than 1, and i is a positive integer greater than 1 and less than or equal to n, and the method further includes:

[0163] If the embedded device is abnormally powered off and restarted during the process of replacing the firmware block to be upgraded in the program running area with the matching second firmware block, the following steps are performed:

[0164] Using the firmware block to be upgraded stored in the second backup area, replacing the i-th first firmware block that is damaged in the program running area;

[0165] Using each differential firmware block stored in the first backup area, the i-1th second firmware block is

[0166] The differential restoration process is performed from the i-1th first firmware block to the 1st second firmware block to obtain the i-1th first firmware block to the 1st first firmware block.

[0167] In a possible design, in the instruction executed by the processor 601, the target firmware package is issued by the server, and the method further includes:

[0168] Feedback information is generated and sent to a server, wherein the feedback information includes first feedback information indicating that the target program is updated successfully, or second feedback information indicating that the target program is updated unsuccessfully.

[0169] The embodiment of the present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the software upgrade method described in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.

[0170] The embodiments of the present disclosure also provide a computer program product, which carries a program code. The instructions included in the program code can be used to execute the steps of the software upgrade method described in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.

[0171] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).

[0172] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed may be through some communication

[0173] An interface, an indirect coupling or communication connection between devices or units, may be electrical, mechanical or other.

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

[0175] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0176] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0177] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be based on the protection scope of the claims.

Claims

1. A software upgrade method, characterized in that: Applications in embedded devices, including: receiving a target firmware package for updating a target program; Dividing the current firmware package and the target firmware package of the target program to obtain a plurality of first firmware blocks corresponding to the current firmware package and a plurality of second firmware blocks corresponding to the target firmware package; wherein the number of the first firmware blocks is the same as the number of the second firmware blocks; According to each of the first firmware blocks and the second firmware blocks matching the first firmware blocks, a differential firmware block corresponding to the first firmware block is generated; and the differential firmware block corresponding to the first firmware block is stored in the first backup area of ​​the embedded device, and the first firmware block in the program running area of ​​the embedded device is replaced with the matching second firmware block.

2. The method according to claim 1, characterized in that The method of generating a differential firmware block corresponding to the first firmware block according to each of the first firmware blocks and the second firmware block matching the first firmware block; storing the differential firmware block corresponding to the first firmware block in a first backup area of ​​the embedded device, and replacing the first firmware block in a program running area of ​​the embedded device with the matching second firmware block includes: Determining a firmware block to be upgraded from the plurality of first firmware blocks according to the division order; For the firmware block to be upgraded, the firmware block to be upgraded is stored in the second backup area in an overwritten manner; a differential firmware block corresponding to the firmware block to be upgraded is generated according to the firmware block to be upgraded and a second firmware block matching the firmware block to be upgraded; the differential firmware block corresponding to the firmware block to be upgraded is stored in the first backup area, and the firmware block to be upgraded in the program running area is replaced with the matching second firmware block; Return to the step of determining the firmware block to be upgraded from the plurality of first firmware blocks in the divided order until there is no first firmware block that has not been replaced.

3. The method according to claim 2, characterized in that The number of the plurality of first firmware blocks is n, and the determined firmware block to be upgraded is the i-th first firmware block, n is a positive integer greater than 1, and i is a positive integer less than or equal to n, and the method further includes: If, during the process of storing the firmware block to be upgraded in the second backup area in an overwritten manner, generating a differential firmware block corresponding to the firmware block to be upgraded based on the firmware block to be upgraded and a second firmware block matching the firmware block to be upgraded, and storing the differential firmware block corresponding to the firmware block to be upgraded in the first backup area, the embedded device is abnormally powered off and restarted, the following steps are performed: Using the differential firmware blocks stored in the first backup area, differential restoration processing is performed on the i-1th second firmware block to the first second firmware block in the program running area to obtain the i-1th first firmware block to the first first firmware block.

4. The method according to claim 2, characterized in that: The number of the plurality of first firmware blocks is n, and the determined firmware block to be upgraded is the i-th first firmware block, n is a positive integer greater than 1, and i is a positive integer greater than 1 and less than or equal to n, and the method further includes: If the embedded device is abnormally powered off and restarted during the process of replacing the firmware block to be upgraded in the program running area with the matching second firmware block, the following steps are performed: Using the firmware block to be upgraded stored in the second backup area, replacing the i-th first firmware block that is damaged in the program running area; Using the differential firmware blocks stored in the first backup area, differential restoration processing is performed on the i-1th second firmware block to the first second firmware block to obtain the i-1th first firmware block to the first first firmware block.

5. The method according to any one of claims 1 to 4, characterized in that: The target firmware package is issued by the server, and the method further includes: Feedback information is generated and sent to a server, wherein the feedback information includes first feedback information indicating that the target program is updated successfully, or second feedback information indicating that the target program is updated unsuccessfully.

6. An embedded device, characterized in that: include: storage components and processing components; The storage component includes: a first backup area, and a program running area; a current firmware package of a target program is running in the program running area; the first backup area is used to store differential firmware blocks corresponding to each first firmware block after the current firmware package is divided, wherein the differential firmware block is generated according to the first firmware block and the second firmware block matching the first firmware block, and the second firmware block is obtained by dividing the received target firmware package for updating the target program; The processing component is used to execute the software upgrading method according to any one of claims 1 to 5.

7. The embedded device according to claim 6, characterized in that: The storage component further includes: a second backup area; The second backup area is used to store the firmware blocks to be upgraded determined from the multiple first firmware blocks.

8. A software upgrade device, characterized in that: include: A receiving module, used for receiving a target firmware package for updating a target program; a partitioning module, configured to partition the current firmware package and the target firmware package of the target program to obtain a plurality of first firmware blocks corresponding to the current firmware package and a plurality of second firmware blocks corresponding to the target firmware package; wherein the number of the first firmware blocks is the same as the number of the second firmware blocks; A replacement module is used to generate a differential firmware block corresponding to the first firmware block according to each of the first firmware blocks and the second firmware block matching the first firmware block; and store the differential firmware block corresponding to the first firmware block in the first backup area of ​​the embedded device, and replace the first firmware block in the program running area of ​​the embedded device with the matching second firmware block.

9. The device according to claim 8, characterized in that The replacement module, when generating a differential firmware block corresponding to the first firmware block according to each of the first firmware blocks and the second firmware block matching the first firmware block; and storing the differential firmware block corresponding to the first firmware block in the first backup area of ​​the embedded device, and replacing the first firmware block in the program running area of ​​the embedded device with the matching second firmware block, is used to: Determining a firmware block to be upgraded from the plurality of first firmware blocks according to the division order; For the firmware block to be upgraded, storing the firmware block to be upgraded in a second backup area in an overwritten manner; generating a differential firmware block corresponding to the firmware block to be upgraded according to the firmware block to be upgraded and a second firmware block matching the firmware block to be upgraded; storing the differential firmware block corresponding to the firmware block to be upgraded in the first backup area, and replacing the firmware block to be upgraded in the program running area with the matching second firmware block; Return to the step of determining the firmware block to be upgraded from the plurality of first firmware blocks in the divided order until there is no first firmware block that has not been replaced.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the software upgrading method according to any one of claims 1 to 5 are executed.