System starting method and device, electronic equipment and storage medium
By monitoring the system startup time and the number of consecutive startups, the system startup log is obtained, and the system or auxiliary system is restarted if necessary, the problem of difficulty in detecting and handling unpredictable exceptions in the prior art is solved, and the high reliability and user experience of system startup are improved.
Patent Information
- Application Number
- CN202311246834.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-25
- Publication Date
- 2025-03-25
AI Technical Summary
The prior art is difficult to effectively detect and handle unpredictable exceptions that occur during system startup, resulting in the system being unable to enter an interactive state in time.
By monitoring the system startup time and the number of consecutive startups, obtain the system startup log, and restart the system or start the auxiliary system under preset conditions to export the logs for developers to analyze the causes of the exception.
It realizes the detection and handling of any abnormal problems during the system startup process, takes timely measures to try to resolve abnormalities, or exports the system startup log to facilitate analysis and resolution of problems, thereby improving the reliability and user experience of system startup.
Smart Images

Figure CN119690525A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of operating systems, and in particular to a system startup method, device, electronic device and storage medium. Background Art
[0002] The operating system includes the system kernel and parts outside the system kernel. The parts outside the system kernel include the system initialization program, system core services and components, etc. When starting the operating system, the system kernel is started first and then the parts outside the system kernel are started. When both are started successfully, the system enters the interactive state. To ensure that the operating system enters the interactive state, it is necessary to detect whether an exception occurs when starting the operating system and try to resolve the system exception. Summary of the invention
[0003] In order to overcome the problems existing in the related art, the present disclosure provides a system startup method, device, electronic device and storage medium.
[0004] According to a first aspect of an embodiment of the present disclosure, a system startup method is provided, the method comprising:
[0005] Monitor the startup time of the first system;
[0006] Obtaining a system startup log of the first system, and storing the system startup log in a preset storage area;
[0007] If the first system does not enter an interactive state when the startup duration is less than or equal to a first threshold, the first system is restarted or a second system is started, and the second system is used to export the system startup log.
[0008] In an exemplary embodiment, restarting the first system or starting the second system includes:
[0009] If the number of consecutive startups of the first system is less than or equal to a second threshold, restarting the first system;
[0010] If the number of consecutive startups is greater than the second threshold, the second system is started.
[0011] In an exemplary embodiment, the method further comprises:
[0012] When the second system is started, in the second system, the system startup log is exported and sent to a cloud server or a storage device.
[0013] In an exemplary embodiment, the system startup log includes first-level log information, and obtaining the system startup log of the first system includes:
[0014] If the first system does not enter an interactive state when the number of consecutive startup times is less than or equal to the second threshold and the startup duration is greater than a first set value, the first level log information is obtained, the first set value includes at least one duration, and the first set value is less than the first threshold.
[0015] In an exemplary embodiment, the system startup log includes second-level log information, and obtaining the system startup log of the first system includes:
[0016] If the first system does not enter the interactive state when the number of consecutive startup times is less than or equal to the second threshold and the startup duration is greater than a second set value, the second level log information is obtained, the second set value is less than the first set value, and the second set value changes with the change of the number of consecutive startup times.
[0017] In an exemplary embodiment, the second setting value changes with the change of the number of consecutive starts, including:
[0018] The second set value is the product of the number of consecutive starts and a preset value.
[0019] In an exemplary embodiment, the method further comprises:
[0020] A log acquisition flag is set, where the log acquisition flag indicates that the first level log information or the second level log information has been acquired.
[0021] In an exemplary embodiment, the system startup log includes third-level log information, and obtaining the system startup log of the first system includes:
[0022] If the first system does not enter an interactive state when the number of consecutive startup times is greater than the second threshold and the startup duration is greater than a third set value, the third level log information is obtained, and the third set value is less than the second set value.
[0023] In an exemplary embodiment, the types of log data in the first-level log information, the types of log data in the second-level log information, and the types of log data in the third-level log information are in descending order.
[0024] In an exemplary embodiment, storing the system startup log in a preset storage area includes:
[0025] If the system startup log is valid log information, the system startup log is stored in the preset storage area.
[0026] In an exemplary embodiment, the method further comprises:
[0027] If the system startup log is invalid log information, and the acquisition method of the system startup log is the first acquisition method, storing the error information in the preset storage area;
[0028] If the system startup log is invalid log information, and the acquisition method of the system startup log is the second acquisition method, the second acquisition method is modified to the first acquisition method, and the system startup log is acquired again.
[0029] In an exemplary embodiment, the method further comprises:
[0030] If the currently acquired system startup log is valid log information, the system startup log acquired last time is deleted, and the system startup log acquired last time and the currently acquired system startup log are system startup logs of the same level.
[0031] In an exemplary embodiment, the method further comprises:
[0032] If the startup duration is less than or equal to a first threshold, the first system enters an interactive state and the number of consecutive startups is cleared.
[0033] In an exemplary embodiment, the method further comprises:
[0034] If the number of consecutive starts is greater than the second threshold, the number of consecutive starts is cleared.
[0035] In an exemplary embodiment, the method further comprises:
[0036] If the number of consecutive startup times is a third threshold and the startup duration is greater than a first set value, an exception flag is set, and the exception flag indicates that when restarting the first system, loading of a preset service is prohibited, and the preset service is at least one of a peripheral driver, a non-core kernel module, and a non-core system service, and the third threshold is less than the second threshold.
[0037] According to a second aspect of an embodiment of the present disclosure, a system startup device is provided, the device comprising:
[0038] A monitoring unit configured to monitor the startup time of the first system;
[0039] a log unit, configured to obtain a system startup log of the first system, and store the system startup log in a preset storage area;
[0040] The rescue unit is configured to restart the first system or start a second system if the first system does not enter an interactive state when the startup duration is less than or equal to a first threshold, and the second system is used to export the system startup log.
[0041] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0042] processor;
[0043] a memory for storing processor-executable instructions;
[0044] The processor is configured to execute the system startup method as described in the first aspect of the embodiment of the present disclosure.
[0045] According to the fourth aspect of an embodiment of the present disclosure, a non-temporary computer-readable storage medium is provided. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the system startup method as described in the first aspect of the embodiment of the present disclosure.
[0046] The above method disclosed in the present invention has the following beneficial effects: the method can detect any abnormal problems that occur during the system startup process, and when it is determined that an abnormality has occurred, the method promptly restarts the first system to try to resolve the abnormality, or starts the second system to export the system startup log when the abnormality occurs, so as to facilitate developers to analyze the cause of the abnormality.
[0047] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0049] Figure 1 is a flow chart of a system startup method according to an exemplary embodiment;
[0050] Figure 2 is a schematic diagram of a main system startup process flow according to an exemplary embodiment;
[0051] Figure 3A is a schematic diagram showing the startup timing of a system startup monitor according to an exemplary embodiment;
[0052] Figure 3B is a schematic diagram showing the startup timing of a system startup monitor according to an exemplary embodiment;
[0053] Figure 4 is a flow chart of a system startup method according to an exemplary embodiment;
[0054] Figure 5 is a system startup log capture schedule shown according to an exemplary embodiment;
[0055] Figure 6 is a block diagram of a system startup device according to an exemplary embodiment;
[0056] Figure 7 is a flow chart of a system startup method according to an exemplary embodiment;
[0057] Figure 8 is a schematic diagram of exporting a system startup log according to an exemplary embodiment;
[0058] Fig. 9 is a workflow diagram of a system startup monitor according to an exemplary embodiment;
[0059] Fig.10 is a block diagram of a system startup device according to an exemplary embodiment;
[0060] Fig.11 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0061] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0062] In the related art, when starting the system kernel, a watchdog module is set on a chip related to the system kernel to detect whether an abnormality occurs in the system kernel. The watchdog module is essentially a timing clock. When the timing ends, the chip is automatically reset, and the system kernel will automatically restart. In order to prevent the watchdog from resetting, the system kernel must set the watchdog clock regularly to prevent the clock from timing out. Therefore, the watchdog mechanism can detect whether an abnormality occurs in the system kernel. When an abnormality occurs and the watchdog clock cannot be set, the watchdog will trigger a chip reset and cause the system kernel to restart in an attempt to resolve the abnormality.
[0063] When starting the parts outside the system kernel, the watchdog mechanism can be implemented by software, that is, the watchdog timer function is executed by one or several threads, and each system service in the parts outside the system kernel needs to update the watchdog timer regularly to prevent the watchdog timer from expiring and causing the parts outside the system kernel to restart. However, when the watchdog mechanism is implemented by software, the watchdog timer will only be stopped when a preset abnormal problem occurs. If an abnormality other than the preset abnormal problem occurs, that is, an unpredictable abnormality, the system cannot perceive the abnormality and will continue to update the watchdog timer. Therefore, for unpredictable abnormalities, the watchdog mechanism cannot handle them in time when the abnormality occurs, such as taking a restart to try to solve the abnormality, and a lot of manpower is required to analyze and handle the abnormality.
[0064] When starting parts other than the system kernel, it is also possible to use a specific exception handler to detect whether a loop crash exception occurs during startup. This method also has the above-mentioned problem, that is, it can only detect predictable exceptions. For unpredictable exceptions, it is impossible to handle them in time when exceptions other than loop crashes occur. At this time, a lot of manpower is required to analyze and handle the exceptions.
[0065] Therefore, when starting parts other than the system kernel, there is an urgent need for a method that can detect any abnormalities and try to resolve the abnormalities in a timely manner.
[0066] In an exemplary embodiment of the present disclosure, in order to overcome the problem that it is difficult to handle unpredictable exceptions in a timely manner in the related art, a system startup method is provided, including: monitoring the startup time of the first system; obtaining the system startup log of the first system, and storing the system startup log in a preset storage area; if the first system does not enter an interactive state when the startup time is less than or equal to the first threshold, restarting the first system or starting the second system, and the second system is used to export the system startup log. The method can detect any abnormal problems that occur during the system startup process, and when it is determined that an abnormality occurs, it promptly restarts the first system to try to solve the abnormality, or starts the second system to export the system startup log when the abnormality occurs, so as to facilitate developers to analyze the cause of the abnormality.
[0067] In an exemplary embodiment of the present disclosure, a system startup method is provided. Figure 1 is a flow chart of a system startup method according to an exemplary embodiment. Figure 1 As shown, the following steps are included:
[0068] Step S101, monitoring the startup time of the first system;
[0069] Step S102, obtaining a system startup log of the first system, and storing the system startup log in a preset storage area;
[0070] Step S103: If the first system does not enter the interactive state when the startup duration is less than or equal to the first threshold, restart the first system or start the second system, and the second system is used to export the system startup log.
[0071] The system startup method in the disclosed embodiments is applied to electronic devices, including smart phones, tablets, laptops, computer devices, smart watches and other electronic devices with an operating system. The operating system can be a mobile operating system, such as an Android operating system, an embedded operating system, an iOS operating system, a Hongmeng operating system, etc., or it can be a PC (Personal Computer) operating system, such as a Windows operating system, a Linux operating system, a macOS operating system, etc.
[0072] In step S101, Figure 2 FIG. 1 is a flowchart of a main system startup process according to an exemplary embodiment. Figure 2 As shown, after the device is powered on, that is, when the device is turned on, the startup process of the main system of the electronic device includes: starting the system kernel, starting the first system, and the first system entering an interactive state, wherein the first system is the part of the main system of the electronic device except the system kernel, for example, the first system is the part of the Android operating system except the system kernel, and the startup process of the first system includes starting the system initialization program, starting the system, and starting the system core services and components.
[0073] The startup duration of the first system is monitored by a monitoring module with a timing function, such as a timer or a system startup monitor, with the timing starting when the system initialization program is started. A positive timing method can be used, and the startup time of the system initialization program is recorded as 0, or a countdown method can be used, and the startup time of the system initialization program is recorded as the first threshold.
[0074] In some possible ways, if the system kernel can be modified, the function of monitoring the startup time of the first system is enabled through the system kernel. When the system kernel starts successfully, the function is enabled and the startup time of the first system begins to be monitored. If the system kernel cannot be modified, the function of monitoring the startup time is enabled through the system initialization program. Before the system initialization program runs, the function is enabled and the startup time of the first system begins to be monitored.
[0075] In one example, the boot time of the first system is monitored by a system boot monitor. Figure 3A and Figure 3B is a schematic diagram of the startup timing of the system startup monitor according to an exemplary embodiment. If the system kernel can be modified, Figure 3AAs shown, when the system kernel is successfully started, the system boot monitor is started; if the system kernel cannot be modified, Figure 3B As shown, when the system initialization program is started, the system startup monitor is started.
[0076] In step S102, after starting the first system, the system startup log when the system is abnormal is captured by the log capture module, including system kernel log, system log, system core service and component log, system peripheral driver log, system application log, etc. The preset storage area is used to store the system startup log when the system is abnormal, which can be a partition of the memory used by the main system of the electronic device, or a separate memory that only stores the system startup log, so as to improve the storage reliability and stability of the system startup log.
[0077] In step S103, the second system is an auxiliary system of the electronic device, which can be called a "rescue system". The first system and the second system are independent of each other, and the second system and the main system are parallel systems. When the startup time is less than or equal to the first threshold, the first system does not enter the interactive state, indicating that there is an abnormality in the system startup and it cannot be started. At this time, restart the first system to try to solve the abnormality. When it is determined that the abnormality cannot be solved by restarting, restart the electronic device to start the second system for exporting the system startup log. The developer analyzes the system startup log to determine the cause of the system startup abnormality. The first threshold is an empirical value, which can be determined according to actual conditions, such as N times 90% of the worst value of the normal startup of the first system, such as 4 times.
[0078] In the exemplary embodiment of the present disclosure, by determining whether the first system has timed out when entering the interactive state, it is determined whether an abnormality has occurred in the system startup process, and the system startup log when the abnormality occurs is captured, so that any abnormal problems that occur in the system startup process, especially unpredictable abnormalities, can be detected. At the same time, when it is determined that an abnormality has occurred, the first system is promptly restarted to try to solve the abnormality, and the system startup log is exported by starting the second system, so that developers can analyze the cause of the abnormality. In addition, the solution can also prompt the user that there is a problem with the system startup, so as to avoid being stuck in the boot animation or progress bar, and the user believes that the system is still in the normal startup process, thereby greatly improving the efficiency of handling the problem of failure to boot and the probability of solving it, and improving the user's experience.
[0079] In an exemplary embodiment of the present disclosure, a system startup method is provided. Figure 4 is a flow chart of a system startup method according to an exemplary embodiment. Figure 4 As shown, the following steps are included:
[0080] Step S401, monitoring the startup time of the first system;
[0081] Step S402, monitoring the number of consecutive startups of the first system;
[0082] The number of consecutive startups of the first system is monitored by a counter or a system startup monitor. The number of consecutive startups is stored in a preset storage area and is a positive integer, which is used to record the number of failed startups of the first system. The number of consecutive startups can be stored in the preset storage area using a startup number identifier. When the startup number identifier is read, the number of consecutive startups is obtained. The initial value of the number of consecutive startups is 0 or 1. When the first system is started for the first time, the number of consecutive startups of the device in the preset storage area is the initial value, for example, the initial value is set to 0. Each subsequent restart of the first system is increased by 1 based on the previous time. When the first system is started for the last time, the number of consecutive startups is cleared.
[0083] Step S403, obtaining a system startup log of the first system;
[0084] The system startup log includes first-level log information, second-level log information, and third-level log information.
[0085] 1) Obtain the first level log information in the following ways:
[0086] If the first system does not enter an interactive state when the number of consecutive startup times is less than or equal to a second threshold and the startup duration is greater than a first set value, first level log information is obtained, the first set value includes at least one duration, and the first set value is less than the first threshold.
[0087] The first setting value is a fixed value, that is, each time the first system is started, when the startup duration reaches the same duration, the first system does not enter the interactive state, and the first level log information is obtained. In order to obtain as much log information as possible during the startup process, the first setting value may include as many durations as possible, for example, the first setting value includes 4 durations, and the first level log information is obtained once each time the startup duration reaches a duration.
[0088] Multiple time durations in the first setting value can be evenly distributed within the first threshold range, or can be distributed progressively. For example, if the first threshold is N seconds, the first setting value includes 4 time durations, and the 4 time durations are evenly distributed, then the first setting values are N / 4, N / 2, 3N / 4, and N, respectively. That is, when the startup time duration is greater than N / 4, the first system does not enter the interactive state, and the first level log information is obtained; when the startup time duration is greater than N / 2, the first system does not enter the interactive state, and the first level log information is obtained; when the startup time duration is greater than 3N / 4, the first system does not enter the interactive state, and the first level log information is obtained; when the startup time duration is greater than N, the first system does not enter the interactive state, and the first level log information is obtained.
[0089] The first level log information is obtained so that the log information covers the entire startup process and as much log information as possible during the startup process can be obtained.
[0090] 2) Obtain the second level log information in the following ways:
[0091] If the first system does not enter an interactive state when the number of consecutive startup times is less than or equal to a second threshold and the startup duration is greater than a second set value, second level log information is obtained, the second set value is less than the first set value, and the second set value changes with the number of consecutive startup times.
[0092] If the first setting value includes multiple durations, the second setting value is less than the minimum duration of the multiple durations of the first setting value. The second setting value changes with the change of the number of consecutive startups. The second setting value can increase as the number of consecutive startups increases, or decrease as the number of consecutive startups increases, or can be alternately distributed as the number of consecutive startups increases, so as to capture log information close to the time point when the abnormality occurs as much as possible.
[0093] In one example, the second set value is the product of the number of consecutive starts and the preset value, and the preset value is an empirical value. To ensure that the second set value is less than the first set value when the number of consecutive starts is the previous one of the second threshold value, the preset value is less than the second set value / (second threshold value-1). The second set value increases according to the change of the number of consecutive starts, which is more convenient for R&D personnel to analyze the abnormal occurrence point. For example, when the log information is obtained at 40 seconds for the second start, and the log information is obtained at 60 seconds for the third start, it is easy to know whether an abnormality occurs within 40 seconds to 60 seconds.
[0094] Obtaining the second-level log information can capture the log information as close to the time point when the exception occurred as possible to increase the probability of capturing the log information at the time when the exception occurred.
[0095] In order to prevent repeated capture of log information at the same time, a log acquisition flag is set to indicate that the first level log information or the second level log information has been acquired.
[0096] 3) Obtain the third level log information in the following ways:
[0097] If the first system does not enter an interactive state when the number of consecutive startup times is greater than the second threshold and the startup duration is greater than a third set value, third level log information is obtained, and the third set value is less than the second set value.
[0098] The third setting value is smaller than the minimum duration in the second setting value. If the exception cannot be resolved after multiple starts, it means that the exception occurred earlier than the second setting value. Therefore, when the first system is started for the last time, log information is captured in a shorter duration to capture the log information of the exception occurrence point as quickly as possible.
[0099] According to the characteristics of the first-level log information, the second-level log information, and the third-level log information, they can be called timeout logs, progressive logs, and rescue logs respectively. Obtaining three different levels of system startup logs can capture log information at different startup periods to make the acquired log information cover the abnormality occurrence point as much as possible.
[0100] In one example, the first threshold is 1200 seconds, the second threshold is 5 times, the number of consecutive starts is recorded as 0, 1, 2, 3, and 4 respectively, the first setting value is 300 seconds, 600 seconds, 900 seconds, and 1200 seconds, the preset value is 20 seconds, the second setting value is the product of the number of consecutive starts and the preset value, which are 0 seconds, 20 seconds, 40 seconds, 60 seconds, and 80 seconds respectively, and the third preset value is 5 seconds. Figure 5 is a system startup log capture schedule according to an exemplary embodiment. Figure 5 As shown, the horizontal axis is the number of consecutive starts, and the vertical axis is the start time.
[0101] Since the capture speed of the first-level log information, the second-level log information, and the third-level log information needs to be continuously improved, the types of log data in the first-level log information, the types of log data in the second-level log information, and the types of log data in the third-level log information decrease in sequence.
[0102] In one example, the types of log data in the first level log information include: system kernel log, system log, system core service log and component log, system peripheral driver log, system auxiliary program log, log left due to abnormal exit of watchdog, and main user program log; the types of log data in the second level log information include: system kernel log, system log, system core service log and component log, system peripheral driver log, system auxiliary program log, and log left due to abnormal exit of watchdog; the types of log data in the third level log information include: system kernel log, system log, system core service log and component log, system peripheral driver log, and system auxiliary program log.
[0103] Step S404, determining whether the system startup log is valid;
[0104] If the system startup log is valid log information, execute step S405; if the system startup log is invalid log information, execute steps S406-S408;
[0105] The conditions for judging the validity of logs are empirical values and can be set according to actual needs, for example, judging from multiple angles such as log information size, number of log information entries, log tags, etc.
[0106] Step S405: storing the system startup log in a preset storage area.
[0107] If the currently acquired system startup log is valid log information, the last acquired system startup log is deleted, and the last acquired system startup log and the currently acquired system startup log are system startup logs of the same level.
[0108] Only the latest log information is retained in the system startup logs of the same level, which ensures that the log information can reflect system abnormalities while saving storage space in the preset storage area.
[0109] Step S406, determining a method for obtaining the system startup log;
[0110] If the system startup log acquisition method is the first acquisition method, execute step S407; if the system startup log acquisition method is the second acquisition method, execute step S408;
[0111] The first acquisition method is to directly capture the system's original log data, and the second acquisition method is to use a third-party tool to capture formatted log data.
[0112] Step S407, storing the error information in a preset storage area;
[0113] If the original system log is captured directly and the captured log is invalid, it means that the system is abnormal, and the log capture error information is saved to the preset storage area.
[0114] Step S408, changing the second acquisition method to the first acquisition method, and reacquiring the system startup log;
[0115] If a third-party tool is used to capture logs, and the captured logs are invalid, it may be that an exception occurs in the third-party tool. Therefore, it is modified to directly capture the system original log data, re-capture the system startup log, and re-execute step S404 after re-obtaining the system startup log.
[0116] Step S409, when the startup duration is less than or equal to the first threshold, determining whether the first system enters an interactive state;
[0117] If the first system has not entered the interactive state, execute steps S410-S412; if the first system has entered the interactive state, execute step S413;
[0118] Step S410, determining whether the number of consecutive startups of the first system is greater than a second threshold;
[0119] If the number of consecutive startups of the first system is less than or equal to the second threshold, step S411 is executed; if the number of consecutive startups of the first system is greater than the second threshold, step S412 is executed;
[0120] If the number of consecutive startup times is a third threshold and the startup duration is greater than a first set value, an exception flag is set. The exception flag indicates that when the first system is restarted, loading of a preset service is prohibited. The preset service is at least one of a peripheral driver, a non-core kernel module, and a non-core system service. The third threshold is less than the second threshold.
[0121] The exception mark can also be called a rescue mark. In order to make as many attempts as possible to restart the first system to resolve the exception, the third threshold can be the second threshold minus 1. When the number of consecutive startups is the third threshold, the rescue mark is set. When the number of consecutive startups is the second threshold, the rescue mark is read, and the loading of the preset service is prohibited to exclude the occurrence of an exception in the preset service. If the number of consecutive startups is the second threshold, and the first system enters an interactive state when the startup time is less than or equal to the first threshold, it means that an exception has occurred in the preset service; if the number of consecutive startups is the second threshold, and the first system does not enter an interactive state when the startup time is less than or equal to the first threshold, it means that the exception is not in the preset service.
[0122] By prohibiting the loading of the preset service, further attempts can be made to resolve the system abnormality and enable the first system to enter an interactive state.
[0123] The second threshold is an empirical value, which is determined according to actual conditions, for example, 5 times. When the number of consecutive startups is less than the second threshold, it means that the abnormal problem can still be solved by restarting the first system. When the number of consecutive startups is equal to the second threshold, it means that the system is completely damaged and the abnormal problem cannot be solved by restarting the second system. At this time, the second system is started and the number of consecutive startups is set to 0 to avoid the accumulation of times when the electronic device is forcibly restarted by physical buttons.
[0124] By determining the method to resolve exceptions through the number of consecutive startups, you can try to resolve the exceptions by yourself as much as possible. If you cannot resolve the exceptions by yourself, you can export the system startup log for researchers to analyze and handle the exceptions. This can greatly improve the efficiency and probability of resolving the problem of not being able to boot, and improve the user experience.
[0125] Step S411, restarting the first system;
[0126] Step S412, clearing the number of consecutive startups, starting the second system, exporting the system startup log in the second system, and sending the system startup log to the cloud server or storage device;
[0127] When the second system is started, it means that the system abnormality problem cannot be automatically solved and the first system is completely damaged. At this time, the electronic device will be restarted to enter the second system, and the system startup log will be exported in the second system. According to the current actual situation, the system startup log will be sent to the cloud server or storage device. If the network can be connected at present, connect the network and send the system startup log to the cloud server; if the network cannot be connected at present, connect the electronic device to another electronic device and export the system startup abnormality log in the electronic device through transmission protocols such as Bluetooth, near-field communication or data cable connection. R&D personnel analyze the exported system startup log and repair the abnormal part of the system.
[0128] Before starting the second system, the number of consecutive starts is cleared to prevent the number from accumulating, which would cause the second system to be directly started the next time the electronic device is restarted.
[0129] It should be noted that if the number of consecutive startups of the first system is greater than the second threshold, after executing the steps of obtaining the third level log information and clearing the number of consecutive startups, the electronic device is restarted to start the second system.
[0130] Step S413, clearing the number of consecutive starts.
[0131] If the first system enters an interactive state when the startup duration is less than or equal to the first threshold, it means that the abnormality of the first system has been resolved or there is no abnormality. At this time, the number of consecutive startups is cleared to avoid the accumulation of the number of subsequent startup abnormalities, causing the number of consecutive startups to quickly reach the second threshold.
[0132] In an exemplary embodiment of the present disclosure, a system startup device is provided. Figure 6 is a block diagram of a system startup device according to an exemplary embodiment. Figure 6 As shown, including:
[0133] The electronic device main system 601 includes a system kernel 6011 and a first system 6012, and the second system is a rescue system 602. The first system and the second system are independent of each other. The system startup device of the first system 6012 is a system startup monitor 603, and the system startup monitor 603 includes a startup failure number check module 6031, a startup failure check module 6032, a system log capture module 6033, a log validity check module 6034, an expired log cleaning module 6035, and a rescue module 6036. The rescue system 602 includes a log export module 6021.
[0134] The functions of each module in the system startup monitor 603 are as follows:
[0135] The startup failure number checking module 6031 monitors the number of consecutive startup failures of the first system 6012;
[0136] The startup failure checking module 6032 detects whether the first system 6012 enters an interactive state when the startup duration is less than or equal to a first threshold. If the first system 6012 does not enter an interactive state, it is considered that the startup of the first system 6012 fails and an abnormality occurs.
[0137] The system log capture module 6033 automatically captures the system startup log, including the log information of the system kernel, system, system components and their services, and system applications, and stores it in the system abnormality log storage area;
[0138] The log validity check module 6034 detects whether the captured system startup log is valid;
[0139] The expired log cleaning module 6035 deletes the old system logs of the same level after capturing the valid system startup logs;
[0140] The rescue module 6036 triggers rescue measures to restart the first system 6012 or start the rescue system 602 when the first system 6012 fails to start.
[0141] The function of the log export module 6021 is to support the export of system startup logs using multiple log export methods, such as uploading to a cloud server via the Internet or exporting to other devices by connecting to other devices.
[0142] Based on the above system startup device, Figure 7 is a flow chart of a system startup method according to an exemplary embodiment. Figure 7 As shown, the following steps are included:
[0143] Step S7-1, determining that an abnormality occurs during startup of the first system;
[0144] Step S7-2, the system startup monitor captures the startup exception log, that is, the current log information of the system, that is, the system startup log, and stores the startup exception log in the exception log storage area;
[0145] Step S7-3, the system starts the monitor to start the rescue mechanism, restarting the first system or entering the rescue system;
[0146] Step S7-4, when entering the rescue system, reading the abnormality log information from the system abnormality log storage, that is, reading the startup abnormality log from the abnormality log storage area;
[0147] Step S7-5, transmitting the system startup abnormality log to another electronic device, or uploading it to a server.
[0148] In one example, Figure 8 FIG. 1 is a schematic diagram of exporting a system startup log according to an exemplary embodiment. Figure 8 As shown, the following steps are included:
[0149] Step S8-1, after-sales personnel operate device A to enter the rescue system;
[0150] Step S8-2, after-sales personnel enable the log export module in the rescue system;
[0151] Step S8-3: After-sales personnel select one of the following two methods to start exporting abnormal logs according to the current environment:
[0152] Method 1: When device A is connected to the Internet, upload the system startup failure log to the server via the network;
[0153] Method 2: Connect device A to device B and export the system startup failure log in device A to device B.
[0154] In step S8-4, the R&D personnel analyze the logs and repair the abnormal parts of the system.
[0155] Based on the above system startup device, a workflow diagram of a system startup monitor is provided. Fig. 9 is a flowchart of a system startup monitor according to an exemplary embodiment. Fig. 9 As shown, the following steps are included:
[0156] Step S9-1, start the system startup monitor;
[0157] Boot time reference for system boot monitor Figure 3A and Figure 3B .
[0158] Step S9-2, reading the "start-up times mark" from the abnormal log storage area;
[0159] The number of startup times is marked as a positive integer, which represents the number of times the first system fails to start.
[0160] Step S9-3, the system startup monitor adds 1 to the value of the "start-up times mark" and writes it back to the abnormal log storage area;
[0161] If the current startup fails, the "startup count mark" with 1 added will be read next time.
[0162] Step S9-4, the system startup monitor determines whether the "start-up times mark" is greater than the "start-up failure threshold";
[0163] The startup failure threshold refers to the limit value of the system's continuous startup failure, that is, the second threshold. When the limit value is reached, the system will be considered completely damaged and cannot be entered, and the system will be prepared to enter the rescue system;
[0164] If the "start-up times mark" is greater than the "start-up failure times threshold", execute steps S9-5-S9-6; if the "start-up times mark" is less than or equal to the "start-up failure times threshold", execute step S9-7;
[0165] Step S9-5, capturing the system startup log of the "rescue level" and recording it in the abnormal log storage area; at the same time, clearing the "start-up times mark" in the abnormal log storage area;
[0166] This prevents the device from booting directly into the rescue system instead of the main system when it is booted later.
[0167] Step S9-6, restarting the electronic device and entering the rescue system;
[0168] The system boot monitor has completed its operation.
[0169] Step S9-7, the system startup monitor calculates the startup time of the first system;
[0170] The startup duration is a multiple of X seconds, where X is between 1 and 20 seconds. For example, X is 10 seconds.
[0171] Step S9-8, the system starts the monitor and checks for X seconds whether the system has entered the "interactive state";
[0172] If the system enters the "interactive state", execute step S9-9; if the system does not enter the "interactive state", execute step S9-10;
[0173] Step S9-9, the first system is successfully started, and the system startup monitor clears the "start-up times mark" of the abnormal log storage area;
[0174] The system boot monitor has completed its operation.
[0175] Step S9-10, the system starts the monitor to check whether the logs of the "progressive level" have been captured;
[0176] The "progressive level" log is designed to capture system startup information within 0-N seconds of system startup time, as close as possible to the time when the exception occurred. For example, N is 300 seconds.
[0177] If it has not been captured, execute step S9-11; if it has been captured, execute step S9-13.
[0178] Step S9-11, the system startup monitor determines whether the first system startup duration exceeds "startup times mark" × Y seconds;
[0179] Y seconds is a value less than N / 4 seconds, and the value of Y is between 10 and 30 seconds. For example, Y is 20 seconds.
[0180] If the startup time exceeds "startup times mark" × Y seconds, execute step S9-12; if it does not exceed "startup times mark" × Y seconds, execute step S9-13.
[0181] Step S9-12, capture the log of the "progressive level", store it in the abnormal log storage area, and set the captured mark of the log of the "progressive level";
[0182] Step S9-13, the system startup monitor determines whether the first system startup time exceeds 4×N seconds;
[0183] 4×N seconds refers to the system startup timeout threshold set by the system startup monitor, that is, the first threshold, which can be dynamically changed through cloud control or policy. The value of N can be 90% of the worst value of the normal startup of the first system and is a multiple of X seconds.
[0184] If it exceeds 4×N seconds, execute steps S9-14-S9-16; if it does not exceed 4×N seconds, execute step S9-17.
[0185] Step S9-14, capture the system startup log information of the "timeout level", store it in the abnormal log storage area, and set the 4N log capture mark;
[0186] Step S9-15, the system startup monitor determines whether the "start-up times mark" is equal to the "start-up failure times threshold - 1";
[0187] If the "boot count mark" is equal to the "boot failure count threshold - 1", a "rescue mark" is set in the exception log storage area. The next time the first system is started, when the "rescue mark" is read, loading of peripheral drivers, non-core kernel modules, and non-core system services will be prohibited; if the "boot count mark" is not equal to the "boot failure count threshold - 1", no processing will be performed.
[0188] Step S9-16, restarting the first system;
[0189] The system boot monitor has completed its operation.
[0190] Step S9-17, the system startup monitor determines whether the first system startup time exceeds 3×N seconds;
[0191] If it exceeds 3×N seconds, capture the system startup log information of the "timeout level", store it in the abnormal log storage area, and set the 3N log capture mark; if it does not exceed 3×N seconds, execute step S9-18.
[0192] Step S9-18, the system startup monitor determines whether the first system startup time exceeds 2×N seconds;
[0193] If it exceeds 2×N seconds, capture the system startup log information of the "timeout level", store it in the abnormal log storage area, and set the 2N log capture mark; if it does not exceed 2×N seconds, execute step S9-19.
[0194] Step S9-19, the system startup monitor determines whether the first system startup time exceeds N seconds;
[0195] If it exceeds N seconds, capture the system startup log information of the "timeout level", store it in the abnormal log storage area, and set the N log capture mark; if it does not exceed N seconds, execute step S9-9.
[0196] In an exemplary embodiment of the present disclosure, a system startup device is provided. Fig.10 is a block diagram of a system startup device according to an exemplary embodiment. Fig.10 As shown, the device comprises:
[0197] The monitoring unit 1001 is configured to monitor the startup time of the first system;
[0198] The log unit 1002 is configured to obtain a system startup log of the first system and store the system startup log in a preset storage area;
[0199] The rescue unit 1003 is configured to restart the first system or start the second system if the first system does not enter the interactive state when the startup time is less than or equal to the first threshold, and the second system is used to export the system startup log.
[0200] In an exemplary embodiment, the rescue unit 1003 is further configured to:
[0201] If the number of consecutive startups of the first system is less than or equal to a second threshold, restarting the first system;
[0202] If the number of consecutive starts is greater than the second threshold, the second system is started.
[0203] In an exemplary embodiment, the rescue unit 1003 is further configured to:
[0204] When the second system is started, in the second system, the system startup log is exported and sent to the cloud server or the storage device.
[0205] In an exemplary embodiment, the system startup log includes first level log information, and the log unit 1002 is further configured to:
[0206] If the first system does not enter an interactive state when the number of consecutive startup times is less than or equal to a second threshold and the startup duration is greater than a first set value, first level log information is obtained, the first set value includes at least one duration, and the first set value is less than the first threshold.
[0207] In an exemplary embodiment, the system startup log includes second level log information, and the log unit 1002 is further configured to:
[0208] If the first system does not enter an interactive state when the number of consecutive startup times is less than or equal to a second threshold and the startup duration is greater than a second set value, second level log information is obtained, the second set value is less than the first set value, and the second set value changes with the number of consecutive startup times.
[0209] In an exemplary embodiment, the log unit 1002 is further configured to:
[0210] The second set value is the product of the number of consecutive starts and the preset value.
[0211] In an exemplary embodiment, the log unit 1002 is further configured to:
[0212] Set the log acquisition flag, which indicates that the first-level log information or the second-level log information has been acquired.
[0213] In an exemplary embodiment, the system startup log includes third level log information, and the log unit 1002 is further configured to:
[0214] If the first system does not enter an interactive state when the number of consecutive startup times is greater than the second threshold and the startup duration is greater than a third set value, third level log information is obtained, and the third set value is less than the second set value.
[0215] In an exemplary embodiment, the types of log data in the first level log information, the types of log data in the second level log information, and the types of log data in the third level log information are in descending order.
[0216] In an exemplary embodiment, the log unit 1002 is further configured to:
[0217] If the system startup log is valid log information, the system startup log is stored in a preset storage area.
[0218] In an exemplary embodiment, the log unit 1002 is further configured to:
[0219] If the system startup log is invalid log information, and the acquisition method of the system startup log is the first acquisition method, storing the error information in a preset storage area;
[0220] If the system startup log is invalid log information, and the acquisition method of the system startup log is the second acquisition method, the second acquisition method is changed to the first acquisition method, and the system startup log is acquired again.
[0221] In an exemplary embodiment, the log unit 1002 is further configured to:
[0222] If the currently acquired system startup log is valid log information, the last acquired system startup log is deleted, and the last acquired system startup log and the currently acquired system startup log are system startup logs of the same level.
[0223] In an exemplary embodiment, the rescue unit 1003 is further configured to:
[0224] If the startup duration is less than or equal to the first threshold, the first system enters an interactive state and the number of consecutive startups is cleared.
[0225] In an exemplary embodiment, the rescue unit 1003 is further configured to:
[0226] If the number of consecutive starts is greater than the second threshold, the number of consecutive starts is cleared.
[0227] In an exemplary embodiment, the rescue unit 1003 is further configured to:
[0228] If the number of consecutive startup times is a third threshold and the startup duration is greater than a first set value, an exception flag is set. The exception flag indicates that when the first system is restarted, loading of a preset service is prohibited. The preset service is at least one of a peripheral driver, a non-core kernel module, and a non-core system service. The third threshold is less than the second threshold.
[0229] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0230] Fig.11 is a block diagram of an electronic device 1100 according to an exemplary embodiment.
[0231] Reference Fig.11 , the electronic device 1100 may include one or more of the following components: a processing component 1102 , a memory 1104 , a power component 1106 , a multimedia component 1108 , an audio component 1110 , an input / output (I / O) interface 1112 , a sensor component 1114 , and a communication component 1116 .
[0232] The processing component 1102 generally controls the overall operation of the electronic device 1100, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 1102 may include one or more processors 1120 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 1102 may include one or more modules to facilitate the interaction between the processing component 1102 and other components. For example, the processing component 1102 may include a multimedia module to facilitate the interaction between the multimedia component 1108 and the processing component 1102.
[0233] The memory 1104 is configured to store various types of data to support operations on the electronic device 1100. Examples of such data include instructions for any application or method operating on the electronic device 1100, contact data, phone book data, messages, pictures, videos, etc. The memory 1104 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk.
[0234] The power supply component 1106 provides power to various components of the electronic device 1100. The power supply component 1106 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 1100.
[0235] The multimedia component 1108 includes a screen that provides an output interface between the electronic device 1100 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 1108 includes a front camera and / or a rear camera. When the electronic device 1100 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and the rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0236] The audio component 1110 is configured to output and / or input audio signals. For example, the audio component 1110 includes a microphone (MIC), and when the electronic device 1100 is in an operation mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 1104 or sent via the communication component 1116. In some embodiments, the audio component 1110 also includes a speaker for outputting audio signals.
[0237] I / O interface 1112 provides an interface between processing component 1102 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0238] The sensor assembly 1114 includes one or more sensors for providing various aspects of status assessment for the electronic device 1100. For example, the sensor assembly 1114 can detect the open / closed state of the electronic device 1100, the relative positioning of components, such as the display and keypad of the electronic device 1100, and the sensor assembly 1114 can also detect the position change of the electronic device 1100 or a component of the electronic device 1100, the presence or absence of user contact with the electronic device 1100, the orientation or acceleration / deceleration of the electronic device 1100, and the temperature change of the electronic device 1100. The sensor assembly 1114 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 1114 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 1114 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0239] The communication component 1116 is configured to facilitate wired or wireless communication between the electronic device 1100 and other devices. The electronic device 1100 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 1116 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 1116 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0240] In an exemplary embodiment, the electronic device 1100 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0241] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 1104 including instructions, and the instructions can be executed by a processor 1120 of the electronic device 1100 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0242] A non-transitory computer-readable storage medium, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute a system startup method, the method including any of the above methods.
[0243] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0244] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A system startup method, characterized in that: The method comprises: Monitor the startup time of the first system; Obtaining a system startup log of the first system, and storing the system startup log in a preset storage area; If the first system does not enter an interactive state when the startup duration is less than or equal to a first threshold, the first system is restarted or a second system is started, and the second system is used to export the system startup log.
2. The system startup method according to claim 1, characterized in that: The restarting the first system or starting the second system includes: If the number of consecutive startups of the first system is less than or equal to a second threshold, restarting the first system; If the number of consecutive startups is greater than the second threshold, the second system is started.
3. The system startup method according to claim 2, characterized in that: The method further comprises: When the second system is started, in the second system, the system startup log is exported and sent to a cloud server or a storage device.
4. The system startup method according to claim 2, characterized in that: The system startup log includes first-level log information, and obtaining the system startup log of the first system includes: If the first system does not enter an interactive state when the number of consecutive startup times is less than or equal to the second threshold and the startup duration is greater than a first set value, the first level log information is obtained, the first set value includes at least one duration, and the first set value is less than the first threshold.
5. The system startup method according to claim 4, characterized in that: The system startup log includes second-level log information, and obtaining the system startup log of the first system includes: If the first system does not enter the interactive state when the number of consecutive startup times is less than or equal to the second threshold and the startup duration is greater than a second set value, the second level log information is obtained, the second set value is less than the first set value, and the second set value changes with the change of the number of consecutive startup times.
6. The system startup method according to claim 5, characterized in that: The second setting value changes as the number of consecutive starts changes, including: The second set value is the product of the number of consecutive starts and a preset value.
7. The system startup method according to claim 5, characterized in that: The method further comprises: A log acquisition flag is set, where the log acquisition flag indicates that the first level log information or the second level log information has been acquired.
8. The system startup method according to claim 5, characterized in that: The system startup log includes third-level log information, and obtaining the system startup log of the first system includes: If the first system does not enter an interactive state when the number of consecutive startup times is greater than the second threshold and the startup duration is greater than a third set value, the third level log information is obtained, and the third set value is less than the second set value.
9. The system startup method according to claim 8, characterized in that: The types of log data in the first-level log information, the types of log data in the second-level log information, and the types of log data in the third-level log information decrease in sequence.
10. The system startup method according to any one of claims 1 to 9, characterized in that: The storing the system startup log to a preset storage area includes: If the system startup log is valid log information, the system startup log is stored in the preset storage area.
11. The system startup method according to claim 10, characterized in that: The method further comprises: If the system startup log is invalid log information, and the acquisition method of the system startup log is the first acquisition method, storing the error information in the preset storage area; If the system startup log is invalid log information, and the acquisition method of the system startup log is the second acquisition method, the second acquisition method is modified to the first acquisition method, and the system startup log is acquired again.
12. The system startup method according to claim 11, characterized in that: The method further comprises: If the currently acquired system startup log is valid log information, the system startup log acquired last time is deleted, and the system startup log acquired last time and the currently acquired system startup log are system startup logs of the same level.
13. The system startup method according to claim 2, characterized in that: The method further comprises: If the startup duration is less than or equal to a first threshold, the first system enters an interactive state and the number of consecutive startups is cleared.
14. The system startup method according to claim 2, characterized in that: The method further comprises: If the number of consecutive starts is greater than the second threshold, the number of consecutive starts is cleared.
15. The system startup method according to claim 2, characterized in that: The method further comprises: If the number of consecutive startup times is a third threshold and the startup duration is greater than a first set value, an exception flag is set, and the exception flag indicates that when restarting the first system, loading of a preset service is prohibited, and the preset service is at least one of a peripheral driver, a non-core kernel module, and a non-core system service, and the third threshold is less than the second threshold.
16. A system startup device, characterized in that: The device comprises: A monitoring unit configured to monitor the startup time of the first system; a log unit, configured to obtain a system startup log of the first system, and store the system startup log in a preset storage area; The rescue unit is configured to restart the first system or start a second system if the first system does not enter an interactive state when the startup duration is less than or equal to a first threshold, and the second system is used to export the system startup log.
17. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to execute the system startup method according to any one of claims 1 to 15.
18. A non-transitory computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the system startup method as described in any one of claims 1 to 15.
Citation Information
Patent Citations
Log uploading method and device and computer readable storage medium
CN107276789A
Vehicle-mounted terminal log processing method, device and system
CN113985852A
System firmware option rollback configuration method and device, equipment and medium
CN114721874A