Application upgrading method and device, computer equipment and storage medium
By generating and using progress identifiers in the embedded system to execute the upgrade package installation strategy, the problem of abnormal situations causing device crash during application upgrade is solved, and the stable operation of the application under abnormal situations is achieved and the user experience is improved.
Patent Information
- Application Number
- CN202411999143.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-04-11
AI Technical Summary
During the application upgrade process, abnormal situations in the upgrade package often cause the device to crash and affect the user experience. It is difficult for the existing technology to identify and deal with these abnormal situations.
By obtaining the application's upgrade package, upgrade the application based on the upgrade package, and generate a progress identifier. Execute the corresponding upgrade package installation strategy based on the progress identification until the application reaches the target state of stable operation. The method includes setting an identification bit area in the flash memory to store progress identifiers, simplifying software design and saving device memory resources.
When there are abnormalities in the upgrade package, the application can still run normally, reducing the occurrence of device flashing and improving the user experience.
Smart Images

Figure CN119806607A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of embedded device control and software technology, and in particular to an application upgrading method, device, computer equipment and storage medium. Background Art
[0002] Currently, many embedded products support the IAP upgrade (In-Application Programming) function. Here, the IAP upgrade function allows embedded devices to update and upgrade their own firmware or software through a specific software mechanism during operation without stopping the normal operation of the device or removing its functions from the working environment. For example, when the old version of the software has program errors or system vulnerabilities, or the new version of the software has added or optimized some functions, the original software needs to be upgraded through the serial port or other methods.
[0003] However, some abnormal conditions during the upgrade process may cause the upgrade to fail, or even cause the device to freeze. For example, the upgrade package may be distorted during transmission, or damaged when saved to the memory, or there may be a program error in the upgrade package itself. In related application upgrade solutions, it is often impossible to identify and handle abnormal conditions of the upgrade package, which may cause the device to freeze when the application fails to upgrade, affecting the user experience. Summary of the invention
[0004] In view of this, the present invention provides an application upgrade method, apparatus, computer device and storage medium to solve the problem that when an application upgrade fails, the device may crash and affect the user experience.
[0005] In a first aspect, the present invention provides an application upgrade method, which is applied to an embedded system, and the method comprises:
[0006] Get the upgrade package corresponding to the application;
[0007] Upgrading the application based on the upgrade package, and generating a progress indicator based on the upgrade progress of the application;
[0008] The corresponding upgrade package installation strategy is executed based on the progress indicator until the application reaches a target state, wherein the target state is used to indicate that the application runs stably.
[0009] In an optional implementation, executing a corresponding upgrade package installation strategy based on the progress indicator until the application reaches a target state includes:
[0010] Get the progress flag and write it into the flag bit area of the memory;
[0011] The progress indicator is read based on the indicator bit area, and the corresponding upgrade package installation strategy is executed based on the progress indicator until the application reaches the target state.
[0012] In an embodiment of the present invention, an identification bit area can be separately set in the flash memory to store the progress identifier, so that the progress identifier is independently stored to facilitate reading the progress identifier, providing a basis for executing the corresponding upgrade package installation strategy based on the progress identifier, thereby eliminating the need to design a multi-level boot architecture, simplifying software design and saving device memory resources.
[0013] In an optional implementation, the progress indicator includes: a software upgrade indicator and a software rollback indicator;
[0014] Execute the corresponding upgrade package installation strategy based on the progress indicator until the application reaches the target state, which also includes:
[0015] After obtaining the upgrade package, generate a software upgrade identifier, and install the upgrade package based on the software upgrade identifier;
[0016] After the upgrade package is installed and the target version application is obtained, a software rollback identifier is generated, wherein the target version application is the application after the version corresponding to the application program is upgraded;
[0017] The target version application is run based on the software rollback identifier, and after the running time of the target version application reaches a time threshold, it is determined that the target version application reaches a target state.
[0018] In an embodiment of the present invention, the progress identifier can be read and the corresponding upgrade package installation strategy can be executed based on the read progress identifier. Here, the boot program only needs to execute the corresponding upgrade package installation strategy according to the progress identifier, and the logic design can be relatively simple. Therefore, there is no need to design a multi-level boot architecture, which simplifies the software design and saves device memory resources.
[0019] In an optional implementation, installing the upgrade package based on the software upgrade identifier includes:
[0020] When a software upgrade identifier is detected and a software rollback identifier is not detected, the upgrade package is installed.
[0021] In an embodiment of the present invention, the progress identifier can be read and the corresponding upgrade package installation strategy can be executed based on the read progress identifier. Here, the boot program only needs to execute the corresponding upgrade package installation strategy according to the progress identifier, and the logic design can be relatively simple. Therefore, there is no need to design a multi-level boot architecture, which simplifies the software design and saves device memory resources.
[0022] In an optional implementation, after the running time of the target version application reaches a time threshold, determining that the target version application reaches a target state includes:
[0023] After the running time of the target version application reaches the time threshold, the software rollback flag is cleared, and after no software rollback flag is detected, it is determined that the target version application has reached the target state.
[0024] In an embodiment of the present invention, the progress identifier can be read and the corresponding upgrade package installation strategy can be executed based on the read progress identifier. Here, the boot program only needs to execute the corresponding upgrade package installation strategy according to the progress identifier, and the logic design can be relatively simple. Therefore, there is no need to design a multi-level boot architecture, which simplifies the software design and saves device memory resources.
[0025] In an optional embodiment, the method further includes:
[0026] When the target version application is in an abnormal state during runtime, a reset signal is triggered after a software rollback flag is detected;
[0027] Based on the reset signal, a backup package corresponding to the application is obtained;
[0028] Install and run the backup package.
[0029] In an embodiment of the present invention, when the runtime of the target version application is in an abnormal state, it can be considered that the application upgrade has failed, and the execution of the version rollback installation strategy is triggered by a reset signal, thereby ensuring that the application can roll back to a stable version to run when the application upgrade fails, reducing the probability of device freezing.
[0030] In an optional embodiment, the method further includes:
[0031] After the upgraded application reaches the target state, the upgrade package is determined as a backup package corresponding to the application, and the backup package is saved in the flash memory.
[0032] In an embodiment of the present invention, when the application is successfully upgraded and reaches the target state, it can be determined that the upgraded version is a stable running version. Therefore, an upgrade package can be obtained and determined as a backup package to update the software version of the backup package, thereby ensuring that the application can roll back to a stable version to run when the application upgrade fails, reducing the probability of device crashes and avoiding too many version rollbacks that affect the user experience.
[0033] In a second aspect, the present invention provides an application upgrade device, the device comprising:
[0034] An acquisition module is used to obtain the upgrade package corresponding to the application;
[0035] An upgrade module, used to upgrade the application based on the upgrade package and generate a progress indicator based on the running status of the application;
[0036] The policy execution module is used to execute the corresponding upgrade package installation policy based on the progress indicator until the upgraded application reaches a target state, wherein the target state is used to indicate that the application runs stably.
[0037] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the application upgrade method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0038] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the application upgrade method of the first aspect or any corresponding embodiment thereof.
[0039] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions for causing a computer to execute the application upgrade method of the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0041] Figure 1 is a flow chart of an application upgrade method according to an embodiment of the present invention;
[0042] Figure 2 is a flow chart of another application upgrade method according to an embodiment of the present invention;
[0043] Figure 3 is a schematic diagram of flash memory area division in an embedded device according to an embodiment of the present invention;
[0044] Figure 4 is a flowchart of another application upgrade method according to an embodiment of the present invention;
[0045] Figure 5 is a structural block diagram of an application upgrading device according to an embodiment of the present invention;
[0046] Figure 6 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0048] In conjunction with the application scenario on which the execution of the application upgrade method depends, the application scenario is described here.
[0049] Currently, many embedded products support the IAP upgrade (In-Application Programming) function. Here, the IAP upgrade function allows embedded devices to update and upgrade their own firmware or software through a specific software mechanism during operation without stopping the normal operation of the device or removing its functions from the working environment. For example, when the old version of the software has program errors or system vulnerabilities, or the new version of the software has added or optimized some functions, the original software needs to be upgraded through the serial port or other methods.
[0050] However, some abnormal conditions during the upgrade process may cause the upgrade to fail, or even cause the device to freeze. For example, the upgrade package may be distorted during transmission, or damaged when saved to the memory, or there may be a program error in the upgrade package itself. In related application upgrade solutions, it is often impossible to identify and handle abnormal conditions of the upgrade package, which may cause the device to freeze when the application fails to upgrade, affecting the user experience.
[0051] For example, in relevant application upgrade solutions, the device's flash memory is usually divided into at least two major areas: the bootloader area and the app user code area. In the bootloader area, the boot program is responsible for upgrading the application program, and in the app user code area, the app program is responsible for the business process. The IAP upgrade is to upgrade the app program.
[0052] Here, the boot program usually contains multiple levels, such as the first-level BootLoader (BL0), the second-level BootLoader (BL1), the third-level BootLoader (BL2), etc. Each level of BootLoader has its specific responsibilities and functions. During the IAP upgrade process, multiple levels of BootLoader can work together. For example, BL0 is responsible for initializing the hardware and loading BL1, BL1 is responsible for further hardware initialization or loading a higher-level BootLoader, and the final BootLoader is responsible for receiving the new version of the upgrade package and writing it to the flash memory. However, the multi-level boot architecture makes the design of the boot program more complicated, and the flash memory space occupied on the device side is larger. At the same time, it is still unable to identify and handle the problem of abnormal conditions in the upgrade package causing the device to freeze.
[0053] Based on this, an embodiment of the present invention provides an application upgrade method, which is applied to an embedded system. The method can first obtain an upgrade package corresponding to the application. Next, the application can be upgraded based on the upgrade package, and a progress indicator can be generated based on the running status of the application. Then, the corresponding upgrade package installation strategy can be executed based on the progress indicator until the application reaches the target state, wherein the target state is used to indicate that the application is running stably, so that the corresponding upgrade package installation strategy can be executed based on the different running states during the application upgrade process, so that the application can still run normally when there is an abnormality in the upgrade package, reducing the occurrence of device freezes and improving the user experience.
[0054] According to an embodiment of the present invention, an application upgrade method embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0055] In this embodiment, an application upgrade method is provided, which can be used for embedded system devices, such as smart home appliances, medical devices, communication devices, etc. Figure 1 is a flow chart of an application upgrade method according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:
[0056] Step S101, obtaining an upgrade package corresponding to the application.
[0057] In the embodiment of the present invention, it can be seen from the above that the flash memory of the device is divided into at least two major areas: the bootloader area and the app user code area, wherein in the bootloader area, the boot program is responsible for upgrading the application program, and in the app user code area, the app program is responsible for the business process. Here, the application program can be the app program in the app user code area. The upgrade package is a set of files for updating the application firmware or software, for example, the upgrade package may include a new firmware image, a configuration file, a library file, and necessary scripts, etc.
[0058] Here, after the embedded device's host computer updates the application version, it can determine the new version of the upgrade package and transmit the upgrade package to the embedded device through the serial port. After the embedded device obtains the upgrade package, it can store the upgrade package in the specified flash memory area and jump to the entry address of the new program for execution.
[0059] In addition, when acquiring the upgrade package, the embedded device can also establish a level with the host computer and send an upgrade request to obtain the upgrade package sent by the host computer based on Ethernet. It should be understood that the embedded device can also obtain the upgrade package through other communication methods, which is subject to implementation, and the present invention does not specifically limit this.
[0060] Step S102: upgrading the application based on the upgrade package, and generating a progress indicator based on the upgrade progress of the application.
[0061] In the embodiment of the present invention, the progress identifier is used to indicate a stage identifier in the application upgrade process. Here, the progress identifiers generated corresponding to different upgrade stages may be different.
[0062] When the embedded device is powered on for the first time, the boot program can be run first, and then jump to the app program to start executing the business process. Here, after the app program upgrade event is triggered, the microcontroller unit (Embedded Microcontroller Unit, hereinafter referred to as MCU) receives the upgrade command, clears the old firmware of the application in the app user code area, and copies the new version of the firmware in the upgrade package stored in the flash memory to the app user code area.
[0063] Then, the boot program may be instructed to perform an upgrade operation of the application program based on the new version of the firmware, and detect whether the running state of the application program is normal operation in each upgrade stage to generate a corresponding progress identifier.
[0064] Step S103: executing the corresponding upgrade package installation strategy based on the progress indicator until the application reaches a target state, wherein the target state is used to indicate that the application runs stably.
[0065] In the embodiment of the present invention, the target state may be a normal operating state, such as a successful application upgrade and normal operation, or an application failure but normal operation of the application. Here, a variety of upgrade package installation strategies may be pre-set to cope with different installation situations. For example, when the application fails to run normally, the installation strategy may be set to version rollback, that is, abandoning the installation of the upgrade package and installing a stable version of the firmware pre-stored in the flash memory instead.
[0066] Here, the installation status of the application can be identified based on the progress identifier, for example, the installation status may include the application can run normally, the application fails to run normally, the upgrade package fails to be unpacked, the upgrade package fails to load, etc. Specifically, the status of the application can be determined based on the type and number of progress identifiers.
[0067] It can be seen from the above description that in an embodiment of the present invention, first, the upgrade package corresponding to the application can be obtained. Next, the application can be upgraded based on the upgrade package, and a progress indicator can be generated based on the running status of the application. Then, the corresponding upgrade package installation strategy can be executed based on the progress indicator until the application reaches the target state, wherein the target state is used to indicate that the application is running stably, so that the corresponding upgrade package installation strategy can be executed based on the different running states during the application upgrade process, so that the application can still run normally when there is an abnormality in the upgrade package, reducing the occurrence of device freezes and improving the user experience.
[0068] In this embodiment, another application upgrade method is provided, which can be used for embedded system devices, such as smart home appliances, medical equipment, communication equipment, etc. Figure 2 is a flow chart of another application upgrade method according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0069] Step S201, obtain the upgrade package corresponding to the application. For details, see Figure 1 Step S101 of the illustrated embodiment will not be described in detail here.
[0070] Step S202: Upgrade the application based on the upgrade package, and generate a progress indicator based on the upgrade progress of the application. Figure 1 Step S102 of the illustrated embodiment will not be described in detail here.
[0071] Step S203: executing the corresponding upgrade package installation strategy based on the progress indicator until the application reaches a target state, wherein the target state is used to indicate that the application runs stably.
[0072] Specifically, the above step S203 includes:
[0073] Step S2031, obtaining a progress indicator, and writing the progress indicator into an indicator bit area of a memory.
[0074] Step S2032, reading the progress indicator based on the indicator bit area, and executing the corresponding upgrade package installation strategy based on the progress indicator until the application reaches the target state.
[0075] In an embodiment of the present invention, the identification bit area may be a storage area set in a flash memory of an embedded device, and the identification bit area may be used to store the generated progress identifier. Figure 3 The figure shows a schematic diagram of the flash memory area division in an embedded device, wherein the internal flash memory includes the bootloader area, the app user code area and the identification bit area F, wherein there is no intersection between the three internal flash memory areas.
[0076] After the progress indicator is generated based on the upgrade progress of the application, the progress indicator can be written into the flag bit area. Then, the progress indicator in the flag bit area can be read by the MCU, and a corresponding policy execution command can be generated based on the progress indicator to instruct the boot program to execute the corresponding upgrade package installation policy based on the policy execution command.
[0077] For example, if the progress indicator is used to indicate that the application fails to run normally, a version rollback instruction may be generated, that is, an upgrade package installation strategy of abandoning the installation of the current version and installing the stable version firmware pre-stored in the flash memory instead may be executed.
[0078] In an embodiment of the present invention, an identification bit area can be separately set in the flash memory to store the progress identifier, so that the progress identifier is independently stored to facilitate reading the progress identifier, providing a basis for executing the corresponding upgrade package installation strategy based on the progress identifier, thereby eliminating the need to design a multi-level boot architecture, simplifying software design and saving device memory resources.
[0079] In some optional implementations, the progress indicator includes: a software upgrade indicator and a software rollback indicator. The step S103 executes the corresponding upgrade package installation strategy based on the progress indicator until the application reaches the target state, including:
[0080] Step S11, after acquiring the upgrade package, generating a software upgrade identifier, and installing the upgrade package based on the software upgrade identifier.
[0081] Step S12, after the upgrade package is installed and the target version application is obtained, a software rollback identifier is generated, wherein the target version application is the application after the version corresponding to the application program is upgraded.
[0082] Step S13: running the target version application based on the software rollback identifier, and after the running time of the target version application reaches a time threshold, determining that the target version application reaches a target state.
[0083] In the embodiment of the present invention, the installation status indicated by the software upgrade mark may be that the new version of the firmware in the upgrade package is successfully saved in the external flash memory. The installation status indicated by the software rollback mark may be that the new version of the firmware of the application is successfully installed.
[0084] When executing the upgrade process of the application based on the above boot program, the above software upgrade identifier can be generated after the new version of the firmware in the upgrade package is successfully saved in the external flash memory, and the software upgrade identifier can be written into the above identifier bit area.
[0085] Next, the new version of the firmware can be installed through the boot program. Specifically, the above step S11, installing the upgrade package at the software upgrade mark, includes:
[0086] When a software upgrade identifier is detected and a software rollback identifier is not detected, the upgrade package is installed.
[0087] In an embodiment of the present invention, if the MCU detects a software upgrade flag in the identification bit area and does not detect a software rollback flag, it can instruct the boot program to install the new version of the firmware into the app user code area, and generate a version rollback flag after the installation is completed and the target version is applied.
[0088] Then, the version rollback flag can be written into the above flag bit area, and the target version application can be jumped to run to determine whether the target version application can be in the target state where it can run normally and stably. Here, after the running time of the target version application reaches the time threshold, it is determined that the target version application has reached the target state.
[0089] Specifically, the above step S13, after the running time of the target version application reaches the time threshold, determines that the target version application reaches the target state, includes:
[0090] After the running time of the target version application reaches the time threshold, the software rollback flag is cleared, and after no software rollback flag is detected, it is determined that the target version application has reached the target state.
[0091] In an embodiment of the present invention, after jumping to the target version application for execution, the software upgrade flag in the flag bit area can be cleared first, and each thread in the target version can be executed to detect whether the normal operation time of all threads reaches the time threshold.
[0092] Here, after the running time of the target version application reaches the time threshold, that is, the normal running time of each thread in the target version reaches the time threshold, for example, the time threshold can be 10 minutes, then the software rollback flag is cleared. Here, the MCU can detect the software rollback flag in the flag bit area in real time during the running of the target version application, and determine that the target version application has reached the target state after the software rollback flag and the software upgrade flag are not detected.
[0093] In an embodiment of the present invention, the progress identifier can be read and the corresponding upgrade package installation strategy can be executed based on the read progress identifier. Here, the boot program only needs to execute the corresponding upgrade package installation strategy according to the progress identifier, and the logic design can be relatively simple. Therefore, there is no need to design a multi-level boot architecture, which simplifies the software design and saves device memory resources.
[0094] In some optional implementations, the above step S103 further includes:
[0095] Step S21 : when the target version application is in an abnormal state during operation, a reset signal is triggered after a software rollback flag is detected.
[0096] Step S22: based on the reset signal, obtaining a backup package corresponding to the application.
[0097] Step S23, installing and running the backup package.
[0098] In an embodiment of the present invention, an abnormal state can be used to indicate that an application upgrade has failed, for example, at least some threads in the target version application fail to run normally, or at least some threads in the target version application are in a normal running state for less than a threshold time. As can be seen from the above, the installation strategy that can be executed after the application upgrade fails is set to version rollback, that is, abandoning the installation of the upgrade package and installing the stable version of the firmware pre-stored in the flash memory instead.
[0099] Specifically, when the target version application is in an abnormal state, a preset watchdog reset can be triggered to generate a reset signal. Here, the watchdog can be pre-configured for the MCU, wherein when the actual process of the application is executed through the boot program, the watchdog can be first configured through the MCU.
[0100] After detecting the reset signal, the boot program can be run to perform version rollback. Figure 3 It can be known that a backup package can be set in advance in the external flash memory, and the backup package can include the firmware of the stable running version of the application, wherein the stable running version can be the version before the application is upgraded.
[0101] Specifically, the boot program can copy the firmware in the backup package in the external flash memory to the app user code area, and run the firmware after the firmware installation is completed to implement version rollback of the application program.
[0102] In an embodiment of the present invention, when the runtime of the target version application is in an abnormal state, it can be considered that the application upgrade has failed, and the execution of the version rollback installation strategy is triggered by a reset signal, thereby ensuring that the application can roll back to a stable version to run when the application upgrade fails, reducing the probability of device freezing.
[0103] In some optional embodiments, the above Figure 1 The corresponding embodiments also include:
[0104] After the upgraded application reaches the target state, the upgrade package is determined as a backup package corresponding to the application, and the backup package is saved in the flash memory.
[0105] In the embodiment of the present invention, it can be known from the above that the firmware of the stable running version of the application can be backed up, so that when the application upgrade fails, the version of the application can be rolled back based on the backup to avoid the device from freezing.
[0106] Based on this, when the application is successfully upgraded and reaches the target state, it can be determined that the upgraded version is a stable running version. Therefore, the upgrade package can be obtained and determined as a backup package to store the backup package in a Figure 3 in the external flash memory shown.
[0107] It should be understood that since the external flash memory usually has a larger storage capacity and can provide storage space of several MB to GB, while the internal flash memory usually has a relatively small capacity and is mainly used to store key program codes and data, and the reference frequency of the backup package is usually low, therefore, the backup package can be stored in the external flash memory to avoid occupying the storage space of key program codes and data and affecting the performance of the embedded system.
[0108] In an embodiment of the present invention, when the application is successfully upgraded and reaches the target state, it can be determined that the upgraded version is a stable running version. Therefore, an upgrade package can be obtained and determined as a backup package to update the software version of the backup package, thereby ensuring that the application can roll back to a stable version to run when the application upgrade fails, reducing the probability of device crashes and avoiding too many version rollbacks that affect the user experience.
[0109] In this embodiment, another application upgrade method is provided, which can be used for embedded system devices, such as smart home appliances, medical equipment, communication equipment, etc. Figure 4 is a flow chart of another application upgrade method according to an embodiment of the present invention. Figure 4 As shown, the process includes the following steps:
[0110] Step S401, configuring the watchdog.
[0111] In an embodiment of the present invention, the watchdog may be pre-configured for the MCU, wherein when the actual process of the application is executed by the boot program, the watchdog may be first configured by the MCU. When the application is in an abnormal state, the pre-set watchdog reset may be triggered to generate a reset signal.
[0112] Step S402, determine whether there is a software rollback mark, if so, execute step S403, if not, execute step S405.
[0113] Step S403, determining whether reset information is detected, if so, executing step S404, if not, executing step S405.
[0114] Step S404, executing version rollback.
[0115] In the embodiment of the present invention, version rollback means giving up installing the upgrade package of the application program and installing the stable version of the firmware pre-stored in the flash memory instead.
[0116] Step S405, determine whether there is a software upgrade mark, if so, execute step S406, if not, execute step S408.
[0117] Step S406, copy the new version of the firmware in the upgrade package to the app user code area.
[0118] Step S407: Generate a software rollback identifier.
[0119] Step S408, configuring the watchdog.
[0120] Step S409, clearing the software upgrade mark after it is detected.
[0121] Step S410: running the target version application.
[0122] Step S411, feeding the dog in the dog feeding task.
[0123] Step S412, determine whether the number of times of feeding the dog exceeds 100 times, if so, execute step S413, if not, execute step S410.
[0124] Step S413, determining whether the normal operation time T of the target version application exceeds the duration threshold Ts, that is, whether T>Ts holds. If so, executing step S414, if not, executing step S410.
[0125] Step S414, determine whether a software rollback flag is detected, if so, execute step S415, if not, execute step S416.
[0126] Step S415, back up the upgrade package to the external flash memory and clear the software rollback flag.
[0127] Step S416, running the application.
[0128] In summary, in an embodiment of the present invention, first, the upgrade package corresponding to the application can be obtained. Next, the application can be upgraded based on the upgrade package, and a progress indicator can be generated based on the running status of the application. Then, the corresponding upgrade package installation strategy can be executed based on the progress indicator until the application reaches the target state, wherein the target state is used to indicate that the application is running stably, so that the corresponding upgrade package installation strategy can be executed based on the different running states during the application upgrade process, so that the application can still run normally when there is an abnormality in the upgrade package, reducing the occurrence of device freezes and improving the user experience.
[0129] In this embodiment, an application upgrade device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0130] This embodiment provides an application upgrade device, such as Figure 5 As shown, including:
[0131] The acquisition module 501 is used to acquire the upgrade package corresponding to the application program;
[0132] An upgrade module 502, configured to upgrade the application based on the upgrade package and generate a progress indicator based on the running state of the application;
[0133] The policy execution module 503 is used to execute the corresponding upgrade package installation policy based on the progress indicator until the upgraded application reaches a target state, wherein the target state is used to indicate that the application runs stably.
[0134] In some optional implementations, the policy execution module 503 is further configured to:
[0135] Get the progress flag and write it into the flag bit area of the memory;
[0136] The progress indicator is read based on the indicator bit area, and the corresponding upgrade package installation strategy is executed based on the progress indicator until the application reaches the target state.
[0137] In some optional implementations, the progress indicator includes: a software upgrade indicator and a software rollback indicator; the policy execution module 503 is further used to:
[0138] After obtaining the upgrade package, generate a software upgrade identifier, and install the upgrade package based on the software upgrade identifier;
[0139] After the upgrade package is installed and the target version application is obtained, a software rollback identifier is generated, wherein the target version application is the application after the version corresponding to the application program is upgraded;
[0140] The target version application is run based on the software rollback identifier, and after the running time of the target version application reaches a time threshold, it is determined that the target version application reaches a target state.
[0141] In some optional implementations, the policy execution module 503 is further configured to:
[0142] When a software upgrade identifier is detected and a software rollback identifier is not detected, the upgrade package is installed.
[0143] In some optional implementations, the policy execution module 503 is further configured to:
[0144] After the running time of the target version application reaches the time threshold, the software rollback flag is cleared, and after no software rollback flag is detected, it is determined that the target version application has reached the target state.
[0145] In some optional implementations, the policy execution module 503 is further configured to:
[0146] When the target version application is in an abnormal state during runtime, a reset signal is triggered after a software rollback flag is detected;
[0147] Based on the reset signal, a backup package corresponding to the application is obtained;
[0148] Install and run the backup package.
[0149] In some optional embodiments, the device is also used for:
[0150] After the upgraded application reaches the target state, the upgrade package is determined as a backup package corresponding to the application, and the backup package is saved in the flash memory.
[0151] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0152] The application upgrade device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0153] The embodiment of the present invention also provides a computer device having the above Figure 5 The application upgrade device shown.
[0154] See also Figure 6 , Figure 6 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 6 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 6 A processor 10 is taken as an example.
[0155] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0156] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.
[0157] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0158] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0159] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0160] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0161] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0162] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the accompanying description.
Claims
1. An application upgrade method, characterized in that: Applied to an embedded system, the method comprises: Get the upgrade package corresponding to the application; Upgrading the application based on the upgrade package, and generating a progress indicator based on the upgrade progress of the application; The corresponding upgrade package installation strategy is executed based on the progress indicator until the application reaches a target state, wherein the target state is used to indicate that the application runs stably.
2. The method according to claim 1, characterized in that The executing a corresponding upgrade package installation strategy based on the progress indicator until the application reaches a target state includes: Obtaining the progress indicator, and writing the progress indicator into the indicator bit area of the memory; The progress identifier is read based on the identifier bit area, and a corresponding upgrade package installation strategy is executed based on the progress identifier until the application reaches a target state.
3. The method according to claim 1, characterized in that The progress indicator includes: a software upgrade indicator and a software rollback indicator; The executing a corresponding upgrade package installation strategy based on the progress indicator until the application reaches a target state further includes: After acquiring the upgrade package, generating the software upgrade identifier, and installing the upgrade package based on the software upgrade identifier; After the upgrade package is installed and the target version application is obtained, the software rollback identifier is generated, wherein the target version application is the application after the version corresponding to the application program is upgraded; The target version application is run based on the software rollback identifier, and after the running time of the target version application reaches a time threshold, it is determined that the target version application reaches a target state.
4. The method according to claim 3, characterized in that The step of installing the upgrade package based on the software upgrade identifier includes: When the software upgrade identifier is detected and the software rollback identifier is not detected, the upgrade package is installed.
5. The method according to claim 3, characterized in that: After the running time of the target version application reaches the time threshold, determining that the target version application reaches the target state includes: After the running time of the target version application reaches a time threshold, the software rollback flag is cleared, and after the software rollback flag is not detected, it is determined that the target version application has reached a target state.
6. The method according to claim 3, characterized in that The method further comprises: When the target version application is in an abnormal state during runtime, triggering a reset signal after detecting the software rollback identifier; Based on the reset signal, obtaining a backup package corresponding to the application; Install and run the backup package.
7. The method according to claim 1, characterized in that The method further comprises: After the upgraded application reaches the target state, the upgrade package is determined as a backup package corresponding to the application, and the backup package is saved in the flash memory.
8. An application upgrade device, characterized in that: The device comprises: An acquisition module is used to obtain the upgrade package corresponding to the application; An upgrade module, used to upgrade the application based on the upgrade package and generate a progress indicator based on the running state of the application; A policy execution module is used to execute the corresponding upgrade package installation policy based on the progress indicator until the upgraded application reaches a target state, wherein the target state is used to indicate that the application runs stably.
9. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the application upgrade method according to any one of claims 1 to 7 by executing the computer instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the application upgrade method according to any one of claims 1 to 7.