Disclosure of Invention
The invention provides a method for upgrading firmware based on terminal states, aiming at solving the problems that all terminals are consistent and cannot be dynamically adjusted according to terminal resource conditions when the firmware is upgraded in the prior art, and simultaneously, the resources of the terminals with surplus resources cannot be fully utilized to reduce data traffic consumption and improve user experience.
In order to solve the technical problems, the technical scheme of the invention is as follows:
a method for upgrading firmware based on terminal state includes:
s10, the terminal actively or passively triggers to check whether the matched upgrade package information exists or not to the cloud;
s20, if yes, acquiring resource information of the terminal, and judging whether the resource information of the terminal meets the resource requirement required by the upgrade package;
s30, if yes, downloading the upgrade package, and otherwise, regenerating a new upgrade package according to the resource information of the terminal and downloading the new upgrade package;
s40, judging whether the source version is matched with the new upgrade package according to the verification information in the downloaded upgrade package;
and S50, if so, executing upgrading and reporting an upgrading result to the cloud, otherwise, directly reporting the upgrading result to the cloud.
Further, as a preferred technical solution, step S10 specifically includes:
the terminal actively or passively triggers to send related information to the cloud end, and the cloud end matches the related information with the existing upgrade package information on the cloud end after receiving the related information;
wherein the active trigger comprises the trigger of a user through a UI interface or the trigger of the polling cycle;
the passive trigger comprises pushing a Push message by a cloud end;
the related information comprises equipment ID and software version information.
Further, as a preferred technical solution, the acquired resource information of the terminal includes the acquired available resource condition of the terminal;
step S20 specifically includes:
s201, if matched upgrade package information exists, the cloud sends instruction information to inform the terminal of reporting available resource conditions;
s202, after receiving an instruction issued by a cloud, the terminal calculates available resource information according to the upgrade package information and reports the available resource information to the cloud;
and S203, after receiving the available resource information reported by the terminal, the cloud compares whether the resources required by the existing upgrade package are matched with the available resources of the terminal.
Further, as a preferred technical solution, step S30 specifically includes:
if the upgrade package information is matched with the available resource information, the cloud sends the matched existing upgrade package information to the terminal, and the terminal downloads the upgrade package according to the upgrade package information sent by the cloud, otherwise, the cloud regenerates a new upgrade package according to the available resource information reported by the terminal, sends the new upgrade package information to the terminal, and the terminal downloads the new upgrade package according to the new upgrade package information.
Further, as a preferred technical solution, the specific step of judging whether the resources required by the existing upgrade package are matched with the available resources of the terminal is as follows:
and judging whether the resources required by the existing upgrade package are larger than the product of the minimum threshold coefficient and the available resources of the terminal and smaller than the product of the maximum threshold coefficient and the available resources of the terminal, if so, judging that the resources required by the existing upgrade package are matched with the available resources of the terminal, and otherwise, judging that the resources are not matched.
Further, as a preferred technical solution, before acquiring the resource information of the terminal, the method further includes:
if the matched upgrade package information exists, the cloud end issues the related information of the upgrade package to the terminal;
and after receiving the relevant information sent by the cloud, the terminal judges whether a new upgrade package exists, and if so, acquires resource information required by the corresponding upgrade package to perform restoration from the cloud.
Further, as a preferred technical solution, the acquired resource information of the terminal includes a terminal available resource condition;
step S20 specifically includes:
and if the matched upgrade package information exists, judging whether the available resources of the terminal can meet the resource requirement required by the upgrade package during the execution of the restoration.
Further, as a preferred technical solution, step S30 specifically includes:
if so, downloading the upgrade package, otherwise, reporting the available resource information of the current terminal to the cloud;
the cloud terminal regenerates a new upgrade package according to the available resource information reported by the terminal and issues the new upgrade package information to the terminal;
and the terminal downloads the upgrade package.
Further, as a preferred technical solution, step S40 specifically includes:
and verifying the Flash data block to be updated in the equipment by using the verification information in the downloaded update package so as to judge whether the data on the corresponding Flash in the current equipment is consistent with the new version.
Further, as a preferred technical solution, the upgrade result reported to the cloud in step S50 includes: when the verification is passed and the upgrading is completed, the terminal reports upgrading success to the cloud end, and when the verification fails, the terminal directly reports upgrading failure to the cloud end.
Compared with the prior art, the technical scheme of the invention has the beneficial effects that:
according to the invention, the idle prediction of the terminal resources during upgrading can be given to the greatest extent according to the resource use condition of the terminal, and the idle prediction is fed back to the cloud end to manufacture a corresponding upgrading packet, or the upgrading process is accelerated, or the size of the upgrading packet is reduced, so that the occupation of storage space is reduced, the upgrading of the terminal with short resources can be successfully executed, the optimal solution is achieved in the aspects of resources and performance as far as possible, the size of the upgrading packet can be reduced as much as possible, the time consumed by upgrading is prolonged, and the user experience is further improved; the problem that package making parameters are fixed when the upgrade package is made currently, and for terminal equipment under different working conditions, the performance of the terminal equipment is not optimal when the upgrade package is used for upgrading is solved.
Detailed Description
The following detailed description of the preferred embodiments of the present invention, taken in conjunction with the accompanying drawings, will make the advantages and features of the invention easier to understand for those skilled in the art and will therefore make the scope of the invention more clearly defined. .
The same or similar reference numerals in the drawings of the embodiments of the present invention correspond to the same or similar components; in the description of the present invention, it is to be understood that the terms "upper", "lower", "left", "right", "top", "bottom", "inner", "outer", and the like, if any, are used in the orientations and positional relationships indicated in the drawings only for the convenience of describing the present invention and simplifying the description, but not for indicating or implying that the referred device or element must have a specific orientation, be constructed in a specific orientation, and be operated, and therefore the terms describing the positional relationships in the drawings are used for illustrative purposes only and are not to be construed as limiting the present patent.
Furthermore, if the terms "first," "second," and the like are used for descriptive purposes only, they are used for mainly distinguishing different devices, elements or components (the specific types and configurations may be the same or different), and they are not used for indicating or implying relative importance or quantity among the devices, elements or components, but are not to be construed as indicating or implying relative importance.
Example 1
The embodiment discloses a method for upgrading firmware based on a terminal state, as shown in fig. 1, including:
a method for upgrading firmware based on terminal state is characterized by comprising the following steps:
s10, the terminal actively or passively triggers to check whether the upgrade package information is matched with the cloud.
The method specifically comprises the following steps:
the terminal actively or passively triggers to send relevant information to the cloud end, and the cloud end matches the existing upgrade package information on the cloud end by using the relevant information after receiving the relevant information.
In the step, the active triggering comprises the triggering of a user through a UI interface or the triggering of a polling cycle;
the passive triggering comprises pushing a Push message by a cloud end;
the related information includes a device ID, software version information, and the like.
And S20, if so, acquiring the resource information of the terminal, and judging whether the resource information of the terminal meets the resource requirement required by the upgrade package.
In this step, the acquired resource information of the terminal includes the acquired available resource condition of the terminal.
The method specifically comprises the following steps:
s201, if the matched upgrade package information exists, the cloud sends instruction information to inform the terminal of reporting the available resource condition.
In this step, the reported available resource condition includes a CPU, a memory, an IO, or a storage space, which may be adjusted according to a specific upgrade package generation algorithm.
The method also comprises the following steps: and if the matched upgrade package information does not exist, issuing instruction information to the terminal to finish the upgrade process.
And S202, after receiving the command issued by the cloud, the terminal calculates the available resource information according to the upgrade package information and reports the available resource information to the cloud.
In this step, the calculation of the available resource information includes: the terminal counts the resource use condition of the terminal side within a period of time through the resource monitoring module of the terminal, and the terminal counts the minimum available resource within the period of time and reserves a certain proportion of margin.
For example: 0.7 multiplied by the minimum available resource, 0.8 multiplied by the minimum available resource, 0.9 multiplied by the minimum available resource, 0.7, 0.8, 0.9 are all scaling factors, which can be adjusted according to specific items.
And S203, after receiving the available resource information reported by the terminal, the cloud compares whether the resources required by the existing upgrade package are matched with the available resources of the terminal, namely, the cloud judges whether the existing upgrade package executed by the current terminal has resource surplus.
In this step, the specific steps of judging whether the resources required by the existing upgrade package are matched with the available resources of the terminal are as follows:
and judging whether the resources required by the existing upgrade package are larger than the product of the minimum threshold coefficient and the available resources of the terminal and smaller than the product of the maximum threshold coefficient and the available resources of the terminal, if so, judging that the resources required by the existing upgrade package are matched with the available resources of the terminal, and otherwise, judging that the resources are not matched.
That is, the resources required by the currently existing upgrade package need to be in the following interval [ minimum threshold coefficient x terminal available resources, maximum threshold coefficient x terminal available resources ].
Wherein the minimum threshold coefficient can be set to 0.7-0.8, and the maximum threshold coefficient can be set to 0.9-1, and as a preferred embodiment, the minimum threshold coefficient is 0.8, and the maximum threshold coefficient is 1.
And S30, if so, downloading the upgrade package, otherwise, regenerating a new upgrade package according to the resource information of the terminal and downloading.
The method comprises the following specific steps:
if the current terminal executes the existing upgrade package, the cloud end judges that the existing upgrade package executed by the current terminal has no resource surplus, the cloud end sends the matched existing upgrade package information to the terminal, and the terminal downloads the upgrade package according to the upgrade package information sent by the cloud end, otherwise, the cloud end judges that the existing upgrade package executed by the current terminal has resource surplus, the cloud end regenerates a new upgrade package according to available resource information reported by the terminal, sends the new upgrade package information to the terminal, and the terminal downloads the new upgrade package according to the new upgrade package information.
And S40, judging whether the source version is matched with the new upgrade package according to the verification information in the downloaded upgrade package.
The method specifically comprises the following steps: after the upgrade package is downloaded, the Flash data block to be upgraded in the equipment is verified by using the verification information in the downloaded upgrade package, and the data in the related data block in the current equipment is ensured to be consistent with the expected data, so that the data block information restored after the upgrade is ensured to be consistent with the corresponding data block on the new version, namely, the data on the corresponding Flash in the equipment is ensured to be consistent with the new version after the upgrade is executed.
And S50, if so, executing upgrading and reporting an upgrading result to the cloud, otherwise, directly reporting the upgrading result to the cloud.
The method specifically comprises the following steps:
if the data is matched with the new version, namely the verification is passed, the data on the corresponding flash in the equipment after the upgrade is finished is ensured to be consistent with the new version, the upgrade operation is executed, the upgrade result is reported to the cloud after the upgrade is finished, otherwise, the verification is not passed, at this moment, the upgrade operation is not executed, and the upgrade result is directly reported to the cloud.
In this step, the upgrade result reported to the cloud includes: when the verification is passed and the upgrading is completed, the terminal reports upgrading success to the cloud end, and when the verification fails, the terminal directly reports upgrading failure to the cloud end.
In the embodiment, the current resource use information of the terminal is collected through the cloud, whether the terminal executes the current existing upgrade package resource is appropriate or not is judged, namely, in the range of the reserved allowance, if the terminal executes the current existing upgrade package resource, the existing corresponding upgrade package is issued, and if the terminal executes the current existing upgrade package resource, the upgrade package is regenerated according to the condition of the residual resource of the terminal equipment; the upgrade process and the generation method of the upgrade package of this embodiment can make the corresponding upgrade package according to the resource usage of the terminal to the maximum extent, or accelerate the upgrade process, or reduce the size of the upgrade package, thereby reducing the occupation of the storage space and enabling the terminal with short resources to successfully execute the upgrade.
Example 2
A method for upgrading firmware based on terminal state is characterized by comprising the following steps:
s10, the terminal actively or passively triggers to check whether the upgrade package information is matched with the cloud.
The method specifically comprises the following steps:
the terminal actively or passively triggers to send relevant information to the cloud end, and the cloud end matches the existing upgrade package information on the cloud end by using the relevant information after receiving the relevant information.
In the step, the active triggering comprises the triggering of a user through a UI interface or the triggering of a polling cycle;
the passive triggering comprises pushing a Push message by a cloud end;
the related information includes a device ID, software version information, and the like.
And S20, if so, acquiring the resource information of the terminal, and judging whether the resource information of the terminal meets the resource requirement required by the upgrade package.
In this step, before acquiring the resource information of the terminal, the method further includes:
if the matched upgrade package information does not exist, the cloud end returns information to inform the terminal that no new upgrade package exists so as to end the upgrade process;
if the matched upgrade package information exists, the cloud end issues the related information of the upgrade package to the terminal;
and after receiving the relevant information sent by the cloud, the terminal judges whether a new upgrade package exists, and if so, acquires resource information required by the corresponding upgrade package to perform restoration from the cloud.
The method specifically comprises the following steps:
if the matched upgrade package information exists, the cloud end issues the related information of the upgrade package to the terminal, the terminal judges whether a new upgrade package exists after receiving the related information issued by the cloud end, if not, the upgrade flow is ended, and if yes, the resource information required when the corresponding upgrade package is executed and restored is obtained from the cloud end.
And meanwhile, acquiring available resource information of the terminal, and judging whether the available resources of the terminal can meet the resource requirement required by the upgrade package during the execution of the restoration.
And S30, if so, downloading the upgrade package, otherwise, regenerating a new upgrade package according to the resource information of the terminal and downloading.
The method specifically comprises the following steps:
if the available resources of the terminal can meet the resource requirements required by the restoration executed by the upgrade package, downloading the upgrade package, and executing the step S40, otherwise, reporting the current available resources of the terminal to the cloud;
and the cloud terminal regenerates a new upgrade package according to the available resource information reported by the terminal, issues the new upgrade package information to the terminal, and the terminal downloads the upgrade package.
And S40, judging whether the source version is matched with the new upgrade package according to the verification information in the downloaded upgrade package.
The method specifically comprises the following steps: after the upgrade package is downloaded, the Flash data block to be upgraded in the equipment is verified by using the verification information in the downloaded upgrade package, and the data in the related data block in the current equipment is ensured to be consistent with the expected data, so that the data block information restored after the upgrade is ensured to be consistent with the corresponding data block on the new version, namely, the data on the corresponding Flash in the equipment is ensured to be consistent with the new version after the upgrade is executed.
And S50, if so, executing upgrading and reporting an upgrading result to the cloud, otherwise, directly reporting the upgrading result to the cloud.
The method specifically comprises the following steps:
if the data is matched with the new version, namely the verification is passed, the data on the corresponding flash in the equipment after the upgrade is finished is ensured to be consistent with the new version, the upgrade operation is executed, the upgrade result is reported to the cloud after the upgrade is finished, otherwise, the verification is not passed, at this moment, the upgrade operation is not executed, and the upgrade result is directly reported to the cloud.
In this step, the upgrade result reported to the cloud includes: when the verification is passed and the upgrading is completed, the terminal reports upgrading success to the cloud end, and when the verification fails, the terminal directly reports upgrading failure to the cloud end.
In this embodiment, the terminal determines resource matching when the upgrade package executes upgrade, and when the effect of embodiment 1 is achieved, for a terminal with a short resource, the resource occupation can be reduced by adjusting the manufacturing parameters of the upgrade package, so that the terminal can be guaranteed to complete upgrade successfully.
It should be understood that the above-described embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. Other variations and modifications will be apparent to persons skilled in the art in light of the above description. And are neither required nor exhaustive of all embodiments. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the claims of the present invention.