Embedded software FOTA upgrading method and device, storage medium and equipment
By detecting the status of electronic devices and calculating the comprehensive evaluation value, combined with block download and partition storage, the failure caused by blind upgrades during the FOTA upgrade process is solved, the success rate and resource utilization efficiency are improved, and the risks are reduced.
Patent Information
- Application Number
- CN202510445711.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-10
- Publication Date
- 2025-08-08
AI Technical Summary
During the existing FOTA upgrade process, the upgrade failure is often caused by blind downloads, resulting in waste of resources. The traditional method requires manual intervention and is less efficient.
By detecting the current status information of the electronic device, using the mapping relationship between the state value of the target factor and the upgrade evaluation value, the comprehensive evaluation value is calculated, and the upgrade instruction is sent only when the evaluation value is greater than the threshold, and the upgrade is carried out by block download, partition storage and data verification.
It improves the success rate of FOTA upgrades, avoids resource waste caused by blind upgrades, optimizes network resource utilization, reduces the risk of upgrade failure, and provides traceability and recovery of the upgrade process.
Smart Images

Figure CN120447924A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software upgrade technology, and more specifically, to an embedded software FOTA upgrade method, apparatus, storage medium, and device. Background Art
[0002] In traditional embedded systems, software upgrades are primarily performed via wired connections (such as USB and serial ports) or local area networks (LANs). However, these methods require manual intervention and are inefficient. In recent years, the FOTA (Firmware Over-The-Air) upgrade method has gained popularity, allowing device firmware to be updated remotely by downloading an upgrade package over the network.
[0003] The existing FOTA upgrade process involves the following: when a user needs to upgrade device firmware, the FOTA client directly sends an upgrade command to the FOTA server, downloads the complete upgrade package from the FOTA server to the local computer, and then restarts the embedded software to complete the upgrade. However, this blind download and upgrade method based on user needs often leads to download failures due to various abnormal reasons, resulting in upgrade failures and wasted resources. Summary of the Invention
[0004] The present application provides an embedded software FOTA upgrade method, device, storage medium and equipment, which can improve the success rate of FOTA upgrades and avoid upgrade failures caused by blind upgrades, resulting in waste of resources.
[0005] The specific technical solutions are as follows:
[0006] In a first aspect, an embodiment of the present application provides an embedded software FOTA upgrade method, the method comprising:
[0007] Detecting current state information of an electronic device, wherein the electronic device has embedded software to be upgraded installed therein, the current state information including current state values corresponding to at least two target factors, the target factors being factors affecting a success rate of a firmware over the air (FOTA) upgrade;
[0008] Determining the current upgrade evaluation value corresponding to the current state value of each target factor based on the mapping relationship between the state value and the upgrade evaluation value of each target factor, and obtaining a weight value corresponding to each of the at least two target factors, wherein the weight value corresponding to each target factor is obtained based on analysis of historical upgrade data;
[0009] Performing a weighted summation on the current upgrade evaluation values and weight values corresponding to the at least two target factors to obtain a current upgrade comprehensive evaluation value;
[0010] If the current comprehensive upgrade evaluation value is greater than or equal to a preset evaluation threshold, sending an upgrade instruction to the FOTA server;
[0011] When the current comprehensive evaluation value of the upgrade is less than the preset evaluation threshold, the upgrade operation is canceled.
[0012] In a possible implementation, after sending the upgrade instruction to the FOTA server, the method further includes:
[0013] Generate an upgrade flag and restart the embedded software;
[0014] Download the FOTA upgrade package in blocks from the FOTA server side according to the current network signal strength, wherein the current network signal strength is positively correlated with the block size;
[0015] Write the downloaded FOTA upgrade package into the preset memory space;
[0016] The upgrade flag is cleared, and the embedded software is restarted to complete the upgrade of the embedded software.
[0017] In a possible implementation, the preset memory space includes a primary partition, a backup partition, and a transfer partition, wherein the primary partition is a partition for running the upgrade package;
[0018] Writing the downloaded FOTA upgrade package into a preset memory space includes:
[0019] The blocks of the downloaded FOTA upgrade package are written into the transit partition, and data integrity verification is performed on each block. When the downloaded FOTA upgrade packages are verified to be passed, the FOTA upgrade package is copied from the transit partition to the main partition, and the FOTA upgrade package in the main partition is backed up to the backup partition.
[0020] In a possible implementation, after writing the downloaded FOTA upgrade package into the preset memory space and before restarting the embedded software, the method further includes:
[0021] Performing data consistency check on the FOTA upgrade packages of the main partition and the transit partition, and performing data integrity check on the FOTA upgrade package in the main partition;
[0022] If all checks are passed, the step of restarting the embedded software is performed.
[0023] In one possible implementation, the method further includes:
[0024] During the process of restarting the embedded software, checking the data integrity of each partition;
[0025] When the data integrity of the main partition is abnormal and the data integrity of the transit partition is normal, copying the FOTA upgrade package in the transit partition to the main partition to replace the original FOTA upgrade package of the main partition;
[0026] When the data integrity of the main partition and the transit partition are abnormal, and the data integrity of the backup partition is normal, the embedded software code before the upgrade in the backup partition is copied to the main partition to replace the original FOTA upgrade package of the main partition.
[0027] In a possible implementation, the preset memory space further includes a state partition, and the state partition includes various operating states during the upgrade process;
[0028] And / or, the at least two target factors include at least two of remaining battery capacity, network signal strength, and remaining memory.
[0029] In one possible implementation, the method further includes:
[0030] During the FOTA upgrade process, if an interruption occurs, the interruption point is recorded and the upgrade is retried from the interruption point;
[0031] When the number of retries exceeds the preset threshold, the rollback process is initiated.
[0032] In a second aspect, an embodiment of the present application provides an embedded software FOTA upgrade device, the device comprising:
[0033] a detection unit configured to detect current state information of an electronic device, wherein the electronic device has embedded software to be upgraded installed therein, the current state information comprising current state values corresponding to at least two target factors, the target factors being factors affecting a success rate of a firmware over the air (FOTA) upgrade;
[0034] a determining unit, configured to determine a current upgrade evaluation value corresponding to the current state value of each target factor according to a mapping relationship between the state value of each target factor and the upgrade evaluation value;
[0035] an acquiring unit, configured to acquire a weight value corresponding to each of the at least two target factors, wherein the weight value corresponding to each of the target factors is obtained based on analysis of historical upgrade data;
[0036] a calculation unit, configured to perform a weighted summation of the current upgrade evaluation values and weight values corresponding to the at least two target factors to obtain a current comprehensive upgrade evaluation value;
[0037] A sending unit, configured to send an upgrade instruction to the FOTA server when the current upgrade comprehensive evaluation value is greater than or equal to a preset evaluation threshold;
[0038] The canceling unit is configured to cancel the upgrade operation if the current comprehensive upgrade evaluation value is less than the preset evaluation threshold.
[0039] In a possible implementation, the device further includes:
[0040] A generating unit, configured to generate an upgrade flag after sending an upgrade instruction to the FOTA server;
[0041] A restart unit, used to restart the embedded software;
[0042] A downloading unit, configured to download the FOTA upgrade package in blocks from the FOTA server side according to the current network signal strength, wherein the current network signal strength is positively correlated with the block size;
[0043] A writing unit, configured to write the downloaded FOTA upgrade package into a preset memory space;
[0044] a clearing unit, configured to clear the upgrade flag;
[0045] The restart unit is further configured to restart the embedded software to complete the upgrade of the embedded software.
[0046] In a possible implementation, the preset memory space includes a primary partition, a backup partition, and a transfer partition, the primary partition being used to run pre-upgrade embedded software, and the backup partition being used to back up pre-upgrade embedded software codes from the primary partition;
[0047] The download unit is used to write the blocks of the downloaded FOTA upgrade package into the transit partition and perform data integrity verification on each block. When the downloaded FOTA upgrade packages are verified to be passed, the FOTA upgrade packages are copied from the transit partition to the main partition.
[0048] In a possible implementation, the device further includes:
[0049] A verification unit, configured to, after writing the downloaded FOTA upgrade package into the preset memory space and before restarting the embedded software, perform a data consistency check on the FOTA upgrade packages in the main partition and the transit partition, and perform a data integrity check on the FOTA upgrade package in the main partition;
[0050] The restart unit is used to restart the embedded software when all the checks are passed.
[0051] In a possible implementation, the device further includes:
[0052] A checking unit, configured to check the data integrity of each partition during the process of restarting the embedded software;
[0053] A copy unit is used to copy the FOTA upgrade package in the transit partition to the main partition to replace the original FOTA upgrade package in the main partition when the data integrity of the main partition is abnormal and the data integrity of the transit partition is normal; and to copy the embedded software code in the backup partition before the upgrade to the main partition to replace the original FOTA upgrade package in the main partition when the data integrity of the main partition and the transit partition are both abnormal and the data integrity of the backup partition is normal.
[0054] In a possible implementation, the preset memory space further includes a state partition, and the state partition includes various operating states during the upgrade process;
[0055] And / or, the at least two target factors include at least two of remaining battery capacity, network signal strength, and remaining memory.
[0056] In a possible implementation, the device further includes:
[0057] A breakpoint resume unit is used to record the breakpoint when an interruption occurs during the FOTA upgrade process, and to continue the upgrade from the breakpoint;
[0058] The rollback unit is used to start the rollback process when the number of retries exceeds a preset threshold.
[0059] In a third aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any possible implementation manner of the first aspect.
[0060] In a fourth aspect, an embodiment of the present application provides an electronic device, comprising:
[0061] one or more processors;
[0062] The processor is coupled to a storage device, wherein the storage device is configured to store one or more programs;
[0063] When the one or more programs are executed by the one or more processors, the electronic device implements the method as described in any possible implementation manner of the first aspect.
[0064] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes instructions. When the instructions are executed on a computer or a processor, the computer or the processor executes the method described in any possible implementation of the first aspect.
[0065] The embedded software FOTA upgrade method, apparatus, storage medium and device provided in the embodiments of the present application no longer directly send upgrade instructions to the FOTA server, but first detect the current status information of the electronic device itself, obtain the current status values corresponding to at least two target factors, and then determine the current upgrade evaluation value corresponding to the current status value of each target factor based on the mapping relationship between the status value of each target factor and the upgrade evaluation value, and obtain the weight value corresponding to each target factor, and perform weighted summation on the current upgrade evaluation value and the weight value to obtain the current upgrade comprehensive evaluation value. Only when the current upgrade comprehensive evaluation value is greater than or equal to the preset evaluation threshold, it means that the success rate of the current FOTA upgrade is high, and the upgrade instruction will be sent to the FOTA server. When the current upgrade comprehensive evaluation value is less than the preset evaluation threshold, it means that the success rate of the current FOTA upgrade is low, and the upgrade operation is directly canceled to avoid upgrade failure due to blind upgrade and waste of resources.
[0066] In addition, the embodiments of the present application can also achieve the following technical effects:
[0067] 1. When downloading the FOTA upgrade package from the FOTA server, the embodiment of the present application determines the block size of the download based on the current network signal strength, and downloads the FOTA upgrade package in blocks according to the determined block size, thereby making full use of network resources and avoiding the following problem: when the network signal is weak, downloading large data leads to download failure, and the download needs to be restarted, resulting in a waste of resources and time.
[0068] 2. The embodiment of the present application divides the preset memory space into at least three partitions, including a main partition, a backup partition, and a transfer partition. When writing the downloaded FOTA upgrade package into the preset memory space, the downloaded FOTA upgrade package is not directly written to the main partition. Instead, the downloaded block is first written to the transfer partition by performing integrity verification while downloading. When all the downloaded FOTA upgrade packages are verified to be passed, the FOTA upgrade package is copied from the transfer partition to the main partition. This allows the main partition running the FOTA upgrade package to directly obtain the complete FOTA upgrade package, avoiding the waste of the main partition's operating resources due to incomplete FOTA upgrade packages. In addition, before copying the FOTA upgrade package from the transfer partition to the main partition, the backup partition can also back up the embedded software code originally stored in the main partition before the upgrade in advance, so that in the event of subsequent abnormalities that cause the upgrade to fail or abnormal operation after the upgrade, the backup partition can be used to implement rollback.
[0069] 3. After writing the downloaded FOTA upgrade package into the preset memory space and before restarting the embedded software, the embodiment of the present application will also perform data consistency verification on the FOTA upgrade packages of the main partition and the transit partition, as well as data integrity verification on the FOTA upgrade package in the main partition, to again confirm from multiple angles that the FOTA upgrade package in the main partition is intact, ensuring that the system restarts normally, thereby further improving the success rate of the FOTA upgrade.
[0070] 4. During the process of restarting the embedded software, the embodiments of the present application can check the data integrity of each partition. If the data integrity of the primary partition is found to be abnormal, the data of the primary partition can be restored from the transit partition. If the data integrity of the transit partition is also found to be abnormal, the data of the primary partition can be restored from the backup partition, and the upgrade can be rolled back to the version before the upgrade. Restoring the primary partition through the transit partition can reduce the risk of upgrade failure. Restoring the primary partition through the backup partition can ensure that the primary partition can at least run the version before the upgrade, solving the problem of firmware bricking.
[0071] 5. The preset memory space of the embodiment of the present application also includes a status partition, which can record various operating states during the upgrade process. By outputting various operating states to users, technical personnel can intuitively view the progress of the upgrade, problems encountered, etc., and it is also convenient for technical personnel to use the various operating states recorded in the status partition to troubleshoot and solve existing problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] To more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. Obviously, the drawings described below are merely some embodiments of the present application. Those skilled in the art can derive other drawings based on these drawings without inventive effort.
[0073] Figure 1 A flowchart of an embedded software FOTA upgrade method provided in an embodiment of the present application;
[0074] Figure 2 A flowchart of another embedded software FOTA upgrade method provided in an embodiment of the present application;
[0075] Figure 3 This is a block diagram of the composition of an embedded software FOTA upgrade device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0076] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0077] It should be noted that, in the absence of conflict, the embodiments in this application and the features in the embodiments can be combined with each other. The terms "including" and "having" in the embodiments of this application and the accompanying drawings, as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices.
[0078] Figure 1 This is a flow chart of a method for FOTA upgrade of embedded software. The method can be applied to electronic devices, specifically to a FOTA client in an electronic device that supports FOTA upgrades. The method includes:
[0079] S110: Detecting current state information of the electronic device, where the current state information includes current state values corresponding to at least two target factors.
[0080] Among them, the electronic device is installed with embedded software to be upgraded, and the target factors are factors that affect the success rate of firmware over the air (FOTA) upgrade. Firmware is a kind of embedded software. Figure 2As shown, the status detection before the upgrade can be called a pre-check mechanism, and at least two target factors include at least two of the remaining battery capacity, network signal strength, and remaining memory (such as the remaining flash space). The current status value of the remaining battery capacity refers to the current value of the remaining battery capacity, for example, 50%; the current status value of the network signal strength refers to the current strength value of the network signal, and the network signal refers to the network to which the electronic device is currently connected. For example, when currently connected to a WiFi network, the network signal strength refers to the signal strength of the WiFi network, such as a medium WiFi network signal. When not currently connected to a WiFi network but connected to a mobile network, the network signal strength refers to the signal strength of the mobile network, such as a full mobile signal. The current status value of the remaining memory, etc., refers to the current remaining amount of memory, for example, the specific value can be the percentage of the remaining memory to the total memory.
[0081] S120: Determine the current upgrade evaluation value corresponding to the current state value of each target factor according to the mapping relationship between the state value and the upgrade evaluation value of each target factor, and obtain the weight value corresponding to each target factor of at least two target factors.
[0082] Among them, the weight value corresponding to each target factor is obtained based on the analysis of historical upgrade data. For example, based on a machine learning algorithm or a statistical model, the degree of influence of each target factor on the future upgrade success rate can be determined by analyzing historical data, and the weight value of each target factor can be determined based on the degree of influence. Among them, the sum of the weight values of all target factors is 1. The weight of each target factor provided in the embodiment of the present application can be dynamically adjusted as the historical upgrade data is updated to reflect the changes in the importance of different factors in the upgrade score.
[0083] As for the upgrade evaluation value, different status value ranges can be divided for each target factor, and an upgrade evaluation value can be set for each status value range, thereby establishing a mapping table for each target factor. When the current upgrade evaluation value of each target factor in the current status information needs to be determined later, it can be directly determined by looking up the table. The following examples illustrate the mapping table corresponding to each target factor. Table 1 shows the mapping relationship between remaining battery capacity and evaluation value, Table 2 shows the mapping relationship between remaining memory and evaluation value, and Table 3 shows the mapping relationship between network signal strength and evaluation value.
[0084] Table 1
[0085] Remaining battery capacity (percentage) Evaluation value (out of 10 points) 100%-85% 10 85%-70% 8 70%-55% 6 55%-40% 4 40%-25% 2 25%-0% 0
[0086] Table 2
[0087] Remaining memory (percentage) Evaluation value (out of 10 points) More than 80% 10 60%-80% 8 40%-60% 6 20%-40% 4 10%-20% 2 Below 10% 0
[0088] Table 3
[0089]
[0090]
[0091] S130: Perform weighted summation on the current upgrade evaluation values and weight values corresponding to at least two target factors to obtain a current comprehensive upgrade evaluation value.
[0092] Among them, the current upgrade comprehensive evaluation value = w1*power evaluation value + w2*memory evaluation value + w3*network signal evaluation value. w1, w2, and w3 are dynamic weight values and can be adaptively adjusted according to historical upgrade data.
[0093] S140: When the current comprehensive evaluation value of the upgrade is greater than or equal to a preset evaluation threshold, an upgrade instruction is sent to the FOTA server.
[0094] The preset evaluation threshold can be determined based on actual experience, or it can be dynamically adjusted as historical data increases. If the current comprehensive evaluation value of the upgrade is greater than or equal to the preset evaluation threshold, it means that the electronic device is in good condition in all aspects and the probability of completing the upgrade is high, so an upgrade instruction (such as Figure 2 AT (Attention) commands in the system) to update the embedded software through over-the-air download technology.
[0095] S150: When the current comprehensive evaluation value of the upgrade is less than the preset evaluation threshold, cancel the upgrade operation.
[0096] When the current comprehensive upgrade evaluation value is less than the preset evaluation threshold, it means that the electronic device is in poor condition in all aspects and the probability of completing the upgrade is small. The upgrade instruction will no longer be sent to the FOTA server, but the upgrade operation will be canceled directly to avoid wasting resources.
[0097] The embedded software FOTA upgrade method provided in the embodiment of the present application no longer directly sends an upgrade instruction to the FOTA server, but first detects the current status information of the electronic device itself, obtains the current status values corresponding to at least two target factors, and then determines the current upgrade evaluation value corresponding to the current status value of each target factor based on the mapping relationship between the status value of each target factor and the upgrade evaluation value, and obtains the weight value corresponding to each target factor, and performs weighted summation on the current upgrade evaluation value and the weight value to obtain the current upgrade comprehensive evaluation value. Only when the current upgrade comprehensive evaluation value is greater than or equal to the preset evaluation threshold, it means that the success rate of the current FOTA upgrade is high, and the upgrade instruction will be sent to the FOTA server. When the current upgrade comprehensive evaluation value is less than the preset evaluation threshold, it means that the success rate of the current FOTA upgrade is low, and the upgrade operation is directly canceled to avoid upgrade failure due to blind upgrade and waste of resources.
[0098] In one possible implementation, after sending the upgrade instruction to the FOTA server, the embedded software is updated through over-the-air download technology. The following description focuses on the upgrade process, which includes steps A1-A4:
[0099] A1. Generate an upgrade flag and restart the embedded software.
[0100] like Figure 2 As shown in the figure, after generating the upgrade flag, the upgrade flag can be written to the flash memory. The upgrade flag includes information such as whether the upgrade phase is in progress, the upgraded version information, and verification information for block downloads. In addition, other flag information can be added to the flash memory, such as the previous and next target versions, the number of retry attempts for resuming breakpoint downloads, and a verification completion flag.
[0101] In embedded software, the bootloader runs before the embedded software kernel runs. It can initialize hardware devices and establish a memory space mapping map, thereby bringing the system's hardware and software environment to a suitable state, so as to prepare the correct environment for the final call to the embedded software kernel.
[0102] A2. Download the FOTA upgrade package in blocks from the FOTA server based on the current network signal strength.
[0103] like Figure 2 As shown, the downloaded FOTA upgrade package can be first saved in NVM (Non-Volatile Memory).
[0104] The current network signal strength is positively correlated with the block size. That is, the stronger the current network signal strength, the larger each downloaded block is, and the weaker the current network signal strength, the smaller each downloaded block is. This allows full utilization of network resources and avoids the following problems: when the network signal is weak, downloading large data leads to download failure, and the download needs to be restarted, resulting in a waste of resources and time.
[0105] A3. Write the downloaded FOTA upgrade package into the preset memory space.
[0106] Among them, the preset memory space can be FLAS space or other storage space. The preset memory space includes a primary partition, a backup partition and a transit partition. The primary partition is used to run the embedded software before the upgrade, and the backup partition is used to back up the embedded software code before the upgrade from the primary partition. The preset memory space can also include a status partition. The status partition includes various operating states during the upgrade process, such as upgrade progress, breakpoint information, etc. The information recorded in the status partition can be in the form of a log. For example, in the backup, writing, exception handling and other stages, corresponding logs can be generated and saved in the status partition.
[0107] exist Figure 2 In the example, area A is the primary partition, area B is the backup partition, area C is the transit partition, and area D is the status partition. Areas B and C are the same size as area A.
[0108] The FOTA upgrade package can be a full upgrade package or a differential upgrade package. Regardless of the type of upgrade, the specific implementation process of writing the downloaded FOTA upgrade package to the preset memory space can include:
[0109] Write the blocks of the downloaded FOTA upgrade package to the transit partition and perform data integrity verification on each block. When all the downloaded FOTA upgrade packages pass the verification, copy the FOTA upgrade package from the transit partition to the main partition.
[0110] The data integrity check ensures that all required data has been loaded without omission, and that the data has not been tampered with or damaged during transmission or storage. Traditional data integrity check algorithms can be adapted to the embodiments of this application and will not be described in detail here. In terms of the overall solution, the difference from the traditional method is that the traditional method is to perform data integrity check on the complete FOTA upgrade package after downloading the entire FOTA upgrade package, while the embodiment of this application is a block download method, and integrity check is performed while downloading. Combined with the subsequent breakpoint resume function, it can avoid downloading and checking from the beginning in the event of a block download failure, which causes a waste of resources.
[0111] A4. Clear the upgrade flag and restart the embedded software to complete the embedded software upgrade.
[0112] After writing the downloaded FOTA upgrade package into the preset memory space, you can directly clear the upgrade flag and restart the embedded software to complete the upgrade of the embedded software.
[0113] However, in order to further ensure the success rate of the upgrade, after writing the downloaded FOTA upgrade package to the preset memory space and before restarting the embedded software, you can first perform a data consistency check on the FOTA upgrade package in the main partition and the transit partition, and perform a data integrity check on the FOTA upgrade package in the main partition. If all checks pass, then execute the step of restarting the embedded software.
[0114] There are many methods for data consistency verification, for example, a cyclic redundancy check (CRC) check may be used.
[0115] In addition, if Figure 2 As shown, during the process of restarting the embedded software, the data integrity of each partition can also be checked; when the data integrity of the main partition is abnormal and the data integrity of the transfer partition is normal, the FOTA upgrade package in the transfer partition is copied to the main partition to replace the original FOTA upgrade package of the main partition; when the data integrity of both the main partition and the transfer partition is abnormal and the data integrity of the backup partition is normal, the embedded software code before the upgrade in the backup partition is copied to the main partition to replace the original FOTA upgrade package of the main partition. It can be seen from this that restoring the main partition through the transfer partition can reduce the risk of upgrade failure, and restoring the main partition through the backup partition can ensure that the main partition can at least run the version before the upgrade, solving the problem of firmware bricking.
[0116] In one possible implementation, during the FOTA upgrade process, when an interruption occurs, the interruption point can be recorded and the upgrade can be retried from the interruption point to achieve the function of resuming the upload from the breakpoint; however, when the number of retries exceeds the preset threshold, it means that the current status of the electronic device may not be good and the upgrade cannot be successful. The rollback process can be initiated, that is, by copying the embedded software code before the upgrade stored in the backup partition to the main partition, the main partition is returned to the previous firmware (or embedded software) version.
[0117] In addition, after the primary partition is successfully upgraded, if an exception occurs during the operation of the upgraded embedded software, you can also copy the pre-upgrade embedded software code stored in the backup partition to the primary partition to implement a rollback downgrade operation and solve the problem of firmware bricking.
[0118] Based on the above method embodiment, another embodiment of the present application provides an embedded software FOTA upgrade device, such as Figure 3As shown, the device includes:
[0119] A detection unit 210 is configured to detect current status information of an electronic device, wherein the electronic device has embedded software to be upgraded installed therein, the current status information including current status values corresponding to at least two target factors, the target factors being factors affecting the success rate of a firmware over the air (FOTA) upgrade;
[0120] A determining unit 220 is configured to determine a current upgrade evaluation value corresponding to the current state value of each target factor according to a mapping relationship between the state value of each target factor and the upgrade evaluation value;
[0121] An acquiring unit 230 is configured to acquire a weight value corresponding to each of the at least two target factors, wherein the weight value corresponding to each target factor is obtained based on analysis of historical upgrade data;
[0122] The calculation unit 240 is configured to perform a weighted summation of the current upgrade evaluation values and the weight values corresponding to the at least two target factors to obtain a current comprehensive upgrade evaluation value;
[0123] The sending unit 250 is configured to send an upgrade instruction to the FOTA server when the current upgrade comprehensive evaluation value is greater than or equal to a preset evaluation threshold;
[0124] The canceling unit 260 is configured to cancel the upgrade operation if the current comprehensive upgrade evaluation value is less than the preset evaluation threshold.
[0125] In a possible implementation, the device further includes:
[0126] A generating unit, configured to generate an upgrade flag after sending an upgrade instruction to the FOTA server;
[0127] A restart unit, used to restart the embedded software;
[0128] A downloading unit, configured to download the FOTA upgrade package in blocks from the FOTA server side according to the current network signal strength, wherein the current network signal strength is positively correlated with the block size;
[0129] A writing unit, configured to write the downloaded FOTA upgrade package into a preset memory space;
[0130] a clearing unit, configured to clear the upgrade flag;
[0131] The restart unit is further configured to restart the embedded software to complete the upgrade of the embedded software.
[0132] In a possible implementation, the preset memory space includes a primary partition, a backup partition, and a transfer partition, the primary partition being used to run pre-upgrade embedded software, and the backup partition being used to back up pre-upgrade embedded software codes from the primary partition;
[0133] The download unit is used to write the blocks of the downloaded FOTA upgrade package into the transit partition and perform data integrity verification on each block. When the downloaded FOTA upgrade packages are verified to be passed, the FOTA upgrade packages are copied from the transit partition to the main partition.
[0134] In a possible implementation, the device further includes:
[0135] A verification unit, configured to, after writing the downloaded FOTA upgrade package into the preset memory space and before restarting the embedded software, perform a data consistency check on the FOTA upgrade packages in the main partition and the transit partition, and perform a data integrity check on the FOTA upgrade package in the main partition;
[0136] The restart unit is used to restart the embedded software when all the checks are passed.
[0137] In a possible implementation, the device further includes:
[0138] A checking unit, configured to check the data integrity of each partition during the process of restarting the embedded software;
[0139] A copy unit is used to copy the FOTA upgrade package in the transit partition to the main partition to replace the original FOTA upgrade package in the main partition when the data integrity of the main partition is abnormal and the data integrity of the transit partition is normal; and to copy the embedded software code in the backup partition before the upgrade to the main partition to replace the original FOTA upgrade package in the main partition when the data integrity of the main partition and the transit partition are both abnormal and the data integrity of the backup partition is normal.
[0140] In a possible implementation, the preset memory space further includes a state partition, and the state partition includes various operating states during the upgrade process;
[0141] And / or, the at least two target factors include at least two of remaining battery capacity, network signal strength, and remaining memory.
[0142] In a possible implementation, the device further includes:
[0143] A breakpoint resume unit is used to record the breakpoint when an interruption occurs during the FOTA upgrade process, and to continue the upgrade from the breakpoint;
[0144] The rollback unit is used to start the rollback process when the number of retries exceeds a preset threshold.
[0145] The embedded software FOTA upgrade device provided in the embodiment of the present application no longer directly sends an upgrade instruction to the FOTA server, but first detects the current status information of the electronic device itself, obtains the current status values corresponding to at least two target factors, and then determines the current upgrade evaluation value corresponding to the current status value of each target factor according to the mapping relationship between the status value of each target factor and the upgrade evaluation value, and obtains the weight value corresponding to each target factor, and performs weighted summation on the current upgrade evaluation value and the weight value to obtain the current upgrade comprehensive evaluation value. Only when the current upgrade comprehensive evaluation value is greater than or equal to the preset evaluation threshold, it means that the success rate of the current FOTA upgrade is high, and the upgrade instruction will be sent to the FOTA server. When the current upgrade comprehensive evaluation value is less than the preset evaluation threshold, it means that the success rate of the current FOTA upgrade is low, and the upgrade operation is directly canceled to avoid upgrade failure due to blind upgrade and waste of resources.
[0146] Based on the above method embodiments, another embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the method described in any possible implementation manner above when the program is executed by a processor.
[0147] Based on the above method embodiment, another embodiment of the present application provides an electronic device, the electronic device comprising:
[0148] one or more processors;
[0149] The processor is coupled to a storage device, wherein the storage device is configured to store one or more programs;
[0150] When the one or more programs are executed by the one or more processors, the electronic device implements the method described in any one of the above embodiments.
[0151] Based on the above embodiments, another embodiment of the present application provides a computer program product, which includes instructions. When the instructions are executed on a computer or a processor, the computer or the processor executes the method described in any possible implementation manner above.
[0152] The above electronic device embodiments all correspond to the system embodiments and have the same technical effects. For detailed descriptions, please refer to the system embodiments. Those skilled in the art will understand that the accompanying drawings are only schematic diagrams of one embodiment, and the modules or processes in the accompanying drawings are not necessarily required to implement this application.
[0153] Those skilled in the art will appreciate that the modules in the apparatuses of the embodiments may be distributed in the apparatuses of the embodiments as described in the embodiments, or may be located in one or more apparatuses different from the embodiments with corresponding changes. The modules in the above embodiments may be combined into one module or further divided into multiple sub-modules.
[0154] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A FOTA upgrade method for embedded software, characterized in that: The method comprises: Detecting current state information of an electronic device, wherein the electronic device has embedded software to be upgraded installed therein, the current state information including current state values corresponding to at least two target factors, the target factors being factors affecting a success rate of a firmware over the air (FOTA) upgrade; Determining the current upgrade evaluation value corresponding to the current state value of each target factor based on the mapping relationship between the state value and the upgrade evaluation value of each target factor, and obtaining a weight value corresponding to each of the at least two target factors, wherein the weight value corresponding to each target factor is obtained based on analysis of historical upgrade data; Performing a weighted summation on the current upgrade evaluation values and weight values corresponding to the at least two target factors to obtain a current upgrade comprehensive evaluation value; If the current comprehensive upgrade evaluation value is greater than or equal to a preset evaluation threshold, sending an upgrade instruction to the FOTA server; When the current comprehensive evaluation value of the upgrade is less than the preset evaluation threshold, the upgrade operation is canceled.
2. The method according to claim 1, characterized in that After sending the upgrade instruction to the FOTA server, the method further includes: Generate an upgrade flag and restart the embedded software; Download the FOTA upgrade package in blocks from the FOTA server side according to the current network signal strength, wherein the current network signal strength is positively correlated with the block size; Write the downloaded FOTA upgrade package into the preset memory space; The upgrade flag is cleared, and the embedded software is restarted to complete the upgrade of the embedded software.
3. The method according to claim 2, characterized in that The preset memory space includes a main partition, a backup partition, and a transfer partition, wherein the main partition is used to run the embedded software before the upgrade, and the backup partition is used to back up the embedded software code before the upgrade from the main partition; Writing the downloaded FOTA upgrade package into a preset memory space includes: The blocks of the downloaded FOTA upgrade package are written into the transit partition, and a data integrity check is performed on each block. When the downloaded FOTA upgrade packages are all verified, the FOTA upgrade packages are copied from the transit partition to the main partition.
4. The method according to claim 3, characterized in that After writing the downloaded FOTA upgrade package into the preset memory space and before restarting the embedded software, the method further includes: Performing data consistency check on the FOTA upgrade packages of the main partition and the transit partition, and performing data integrity check on the FOTA upgrade package in the main partition; If all checks are passed, the step of restarting the embedded software is performed.
5. The method according to claim 3, characterized in that The method further comprises: During the process of restarting the embedded software, checking the data integrity of each partition; When the data integrity of the main partition is abnormal and the data integrity of the transit partition is normal, copying the FOTA upgrade package in the transit partition to the main partition to replace the original FOTA upgrade package of the main partition; When the data integrity of the main partition and the transit partition are abnormal, and the data integrity of the backup partition is normal, the embedded software code before the upgrade in the backup partition is copied to the main partition to replace the original FOTA upgrade package of the main partition.
6. The method according to claim 3, characterized in that The preset memory space also includes a state partition, and the state partition includes various operating states during the upgrade process; And / or, the at least two target factors include at least two of remaining battery capacity, network signal strength, and remaining memory.
7. The method according to any one of claims 1 to 6, characterized in that The method further comprises: During the FOTA upgrade process, if an interruption occurs, the interruption point is recorded and the upgrade is retried from the interruption point; When the number of retries exceeds the preset threshold, the rollback process is initiated.
8. An embedded software FOTA upgrade device, characterized in that: The device comprises: a detection unit configured to detect current state information of an electronic device, wherein the electronic device has embedded software to be upgraded installed therein, the current state information comprising current state values corresponding to at least two target factors, the target factors being factors affecting a success rate of a firmware over the air (FOTA) upgrade; a determining unit, configured to determine a current upgrade evaluation value corresponding to the current state value of each target factor according to a mapping relationship between the state value of each target factor and the upgrade evaluation value; an acquiring unit, configured to acquire a weight value corresponding to each of the at least two target factors, wherein the weight value corresponding to each of the target factors is obtained based on analysis of historical upgrade data; a calculation unit, configured to perform a weighted summation of the current upgrade evaluation values and weight values corresponding to the at least two target factors to obtain a current comprehensive upgrade evaluation value; A sending unit, configured to send an upgrade instruction to the FOTA server when the current upgrade comprehensive evaluation value is greater than or equal to a preset evaluation threshold; The canceling unit is configured to cancel the upgrade operation if the current comprehensive upgrade evaluation value is less than the preset evaluation threshold.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. An electronic device, characterized in that: The electronic device comprises: one or more processors; The processor is coupled to a storage device, wherein the storage device is configured to store one or more programs; When the one or more programs are executed by the one or more processors, the electronic device is enabled to implement the method according to any one of claims 1 to 7.