A method for shutting down and an electronic device
Patent Information
- Application Number
- CN202411111127.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-13
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2044-08-13
AI Technical Summary
[0004]本申请实施例提供一种关机方法及电子设备,能够在关机过程中电子设备死机的情况下,通过电源管理器控制所有电源管理集成电路下电,从而使电子设备能正常关机,改善关机过程中因电子设备死机而造成电子设备关机失败等问题,使其能正常关机
[0026]其中,第二方面至第六方面中任一种设计方式所带来的技术效果可参见第一方面中不同设计方式所带来的技术效果,此处不再赘述。
Smart Images

Figure CN120762941B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of terminal technology, and more particularly to a method for shutting down an electronic device when it freezes, and the electronic device itself. Background Technology
[0002] In the current technology, with the increasing prevalence of electronic devices, the problem of powering on and off these devices has become increasingly prominent. During the shutdown process, electronic devices often freeze, commonly known as a system crash. System crashes are one of the most common electronic device malfunctions, with many causes, and are also one of the most troublesome. Because once an electronic device crashes, it cannot be shut down normally, impacting the user experience.
[0003] Currently, during the shutdown process of electronic devices, there is a common problem where the device freezes, preventing the shutdown process from completing properly and causing the electronic device to fail to shut down. Summary of the Invention
[0004] This application provides a shutdown method and an electronic device that can shut down the electronic device normally by controlling all power management integrated circuits through a power manager when the electronic device freezes during the shutdown process. This improves the problem of shutdown failure caused by the electronic device freezing during the shutdown process, and enables the electronic device to shut down normally.
[0005] To achieve the above objectives, the embodiments of this application adopt the following technical solutions:
[0006] In a first aspect, a shutdown method is provided, applied to an electronic device, the electronic device including at least one power management integrated circuit and a power manager, wherein the at least one power management integrated circuit is controlled by the power manager, the method comprising: in response to detecting a shutdown command, executing a shutdown process; after the shutdown command is detected, if the electronic device has not completed shutdown after a first preset time period, controlling all the power management integrated circuits to power down through the power manager; and after all the power management integrated circuits are powered down, the electronic device completes shutdown.
[0007] In the above shutdown method, if the electronic device fails to shut down after a first preset time period following the detection of the shutdown command, it indicates that the shutdown process of the electronic device has stalled and a system crash has occurred. The shutdown process of the electronic device cannot end normally. In this case, the power manager can control all power management integrated circuits to power down, enabling the device to shut down normally. This improves the problem of shutdown failure caused by the electronic device crashing during the shutdown process and also achieves the purpose of normal shutdown.
[0008] In one possible implementation, after the electronic device detects a shutdown command, and after a first preset time period, some power management integrated circuits (ICs) in the electronic device remain powered on. That is, even after the software shutdown process of the electronic device is completed, because the power manager cannot respond to the power hold pin pull-down event that controls the power management ICs to power down, not all power management ICs in the electronic device are powered down. At this point, the power manager controls all power management ICs to power down, thereby improving problems such as shutdown failures caused by electronic device crashes during the shutdown process, and also achieving the goal of normal shutdown.
[0009] In one possible implementation of the first aspect, the electronic device not being powered off includes: the display screen of the electronic device being on; the electronic device being powered off includes: the display screen of the electronic device being off. Whether the electronic device has been powered off can be determined by whether the screen is on or off. When the display screen is on, it indicates that the electronic device has not been powered off; when the display screen is off, it indicates that the electronic device has been powered off. In this implementation, whether the display screen is off can help the user intuitively determine whether the electronic device has been powered off.
[0010] In one possible implementation of the first aspect, the aforementioned first preset duration is greater than the normal shutdown duration. The normal shutdown duration can be obtained by statistically analyzing the normal shutdown durations of most such electronic devices or the current electronic device, such as by calculating the average or median shutdown duration under multiple normal conditions; it can also be set according to actual needs, such as based on empirical values. If the electronic device has not completely shut down after the aforementioned normal shutdown duration, it can be determined that the electronic device may have crashed. Therefore, the first preset duration used to determine whether the electronic device has crashed only needs to be greater than the normal shutdown duration. In this implementation, since shutdown requires a certain amount of time, the determination of whether a device has crashed can be made based on the duration. Using a first preset duration greater than the normal shutdown duration provides a certain amount of redundancy in the crash determination process, improving the accuracy of crash detection.
[0011] In one possible implementation of the first aspect, the shutdown method further includes: during the shutdown process, detecting the operating state of the power management integrated circuit through the power manager; and saving the operating state of the power management integrated circuit in the power manager. If the electronic device fails to shut down after a first preset time, it indicates that the electronic device has crashed. Based on the principle that electronic devices crash, the crash may be due to the presence of a power management integrated circuit that is not powered down. Therefore, the operating state of the power management integrated circuit can be detected first to determine whether a power management integrated circuit that is not powered down exists, and then the operating state of the power management integrated circuit is saved. In this implementation, the operating state of the power management integrated circuit is detected first, and then the operating state of the power management integrated circuit is saved, in order to locate the power management integrated circuit that is not powered down.
[0012] In one possible implementation of the first aspect, the detection of the operating status of the power management integrated circuit (IC) by the power manager during the shutdown process includes: sending detection information to the power management IC during the shutdown process; and receiving target data from the respective status registers of the power management ICs, wherein the target data indicates whether the operating status of the power management ICs is normal or abnormal. The process of detecting the operating status of the power management ICs is an interactive communication process. During the detection process, detection information needs to be sent to the power management ICs first, and the power management ICs respond to the detection information by returning target data from their respective status registers. Then, the target data is received from the respective status registers of the power management ICs. The target data indicates whether the operating status of the power management ICs is normal or abnormal; in effect, this is the detection of the normal or abnormal operating status of the power management ICs. In this implementation, the operating status of the power management ICs is detected through interactive communication, thereby timely saving the normal or abnormal operating status of the power management ICs.
[0013] In one possible implementation of the first aspect, the power management integrated circuit (IC) operates normally when the target data is a target value; and abnormally when the target data is not a target value. Since the target data stored in the status registers of each IC can detect its operating status in real time, the power manager can determine the IC's operating status based on the corresponding target data. If the target data is a target value, it indicates that the IC is operating normally; if the target data is not a target value, it indicates that the IC is operating abnormally. This implementation, using whether the target data is a target value to determine the IC's operating status, improves the accuracy of determining the IC's operating status.
[0014] In one possible implementation of the first aspect, the target data in the aforementioned status register includes a preset flag bit. Since the target data corresponding to the status register includes the preset flag bit, the electronic device can determine the operating state of the power management integrated circuit based on the preset flag bit. For example, the target value can be set to 0, and a non-target value to 1, based on the preset flag bit. In this implementation, determining the operating state of the power management integrated circuit by whether the preset flag bit is a target value improves the accuracy of determining the operating state of the power management integrated circuit.
[0015] In one possible implementation of the first aspect, after the electronic device has been powered off, the method further includes: powering on; obtaining the operating state of the power management integrated circuit (IC) during the last power-off process from the power manager; and performing corresponding processing operations based on the operating state of the power management IC. After powering off, when powering on again, in order to promptly find the cause of the system crash during the last power-off process, it is necessary to obtain the operating state of the power management IC during the last power-off process from the power manager, promptly identify the power management IC that has not been powered down, and then perform corresponding processing operations based on the operating state of the power management IC. In this implementation, obtaining the operating state of the power management IC during the last power-off process and promptly identifying the power management IC that has not been powered down allows for the execution of corresponding processing operations, enabling the device to power on normally again.
[0016] In one possible implementation of the first aspect, the aforementioned processing operations performed based on the operating state of the power management integrated circuit include one or more of the following: recording the operating state of the power management integrated circuit in a log; adjusting the abnormal operating state of the power management integrated circuit to a normal operating state; and issuing an early warning based on the abnormal operating state of the power management integrated circuit. The corresponding processing operations are categorized according to the likelihood of repair: First, if it can be repaired automatically, the normal operating state is adjusted to a normal operating state; second, if it cannot be repaired automatically, external technical personnel are required to repair it, and its operating state is recorded in a log for external technical personnel to review; third, if there is no possibility of repair, an early warning is issued, such as requiring device replacement. This implementation can provide multiple processing operations based on the operating state of the power management integrated circuit to address different degrees of shutdown failures.
[0017] In one possible implementation of the first aspect, the shutdown process includes a software shutdown phase, the electronic device includes a kernel layer, and the method further includes: during the software shutdown phase, the kernel layer registers a first callback function and broadcasts shutdown indication information; after receiving the shutdown indication information, the power manager calls the first callback function; wherein the first callback function is used to start a timer to determine whether the first preset duration has been reached. During the software shutdown phase, the first callback function is registered in the kernel layer, and the shutdown indication information is broadcast, interacting with the power manager. By calling the first callback function, the power manager, after receiving the shutdown indication information, starts a timer to determine whether the shutdown is complete. Since the kernel layer is the layer between hardware and software, it includes at least a series of driver-related tasks, such as display drivers, camera drivers, audio drivers, and sensor drivers. Registering a callback function and broadcasting shutdown indication information are driver-related tasks. Therefore, the work of registering the callback function and broadcasting the shutdown indication information is performed in the kernel layer, while interaction with the hardware power manager is also implemented in the kernel layer. This implementation combines software shutdown with the power manager to determine whether shutdown is complete, thereby improving problems such as shutdown failure caused by electronic devices freezing during the shutdown process.
[0018] In one possible implementation of the first aspect, the shutdown process includes a software shutdown phase and a hardware power-down phase. The electronic device includes a kernel layer. After the shutdown command is detected, before the electronic device completes shutdown after a first preset time period, the method further includes: within the first preset time period after the shutdown command is detected, after the software shutdown phase ends, the kernel layer sends a power-down control signal to the power manager. The power-down control signal is used to instruct the power management integrated circuit to be powered down during the hardware power-down phase. The power manager does not respond to the power-down control signal. After the shutdown command is detected, the shutdown process is executed. According to the normal shutdown process, after the software shutdown phase ends, the kernel layer sends a power-down control signal to the power manager to control the power manager to power down the power management integrated circuit during the hardware power-down phase. After the normal shutdown process is completed, it is found that the power manager does not respond to the power-down control signal, i.e., the power manager cannot power down the power management integrated circuit. At this time, the normal shutdown time has been exceeded, i.e., the first preset time period has been reached, and only then is the next operation executed. Since the kernel layer is the layer between hardware and software, interaction with the hardware power manager is implemented at the kernel layer. This implementation, through the principles of software shutdown and hardware power-down, allows for timely understanding of why shutdown was incomplete, enabling prompt action to ensure a proper shutdown.
[0019] In one possible implementation of the first aspect, the sending of detection information to the power management integrated circuit during the shutdown process includes: during the software shutdown phase, the kernel layer registers a second callback function and broadcasts shutdown indication information; upon receiving the shutdown indication information, the power manager calls the second callback function; the second callback function triggers the power management module to send detection information to the power management integrated circuit. Since the kernel layer is the layer between hardware and software, it includes at least a series of driver-related tasks, such as display drivers, camera drivers, audio drivers, and sensor drivers. Registering the callback function and broadcasting the shutdown indication information are driver-related tasks. Therefore, the kernel layer performs the registration of the callback function and the broadcasting of the shutdown indication information, while simultaneously implementing interaction with the hardware power manager. In this implementation, the software and power manager are combined to send detection information to the power management integrated circuit, thereby promptly obtaining information about the normal or abnormal operating status of the power management integrated circuit.
[0020] In one possible implementation of the first aspect, the boot process includes a bootloader layer and a kernel layer. The step of obtaining the operating state of the power management integrated circuit (IC) during the last shutdown from the power manager and performing corresponding processing operations based on the IC's operating state includes: the bootloader layer receiving the IC's operating state from the power manager; the bootloader layer sending the received IC's operating state to the kernel layer; and the kernel layer performing the corresponding processing operations based on the IC's operating state during the boot process. Since the boot sequence is booting the bootloader layer first, then the kernel layer, the bootloader layer first receives the IC's operating state from the power manager, then sends it to the kernel layer, and finally, the kernel layer performs the corresponding processing operations based on the IC's operating state during the boot process. This implementation allows for the transmission of the IC's operating state during the last shutdown during the boot process, enabling timely execution of corresponding processing operations based on the IC's operating state.
[0021] Secondly, a power manager is provided for use in an electronic device. The electronic device includes at least one power management integrated circuit (IC) and a power manager. The power management IC is controlled by the power manager, which is configured to: determine that after the electronic device detects a power-off command, the power management IC has not been powered down after a first preset time period; and control all the power management ICs to power down. The power manager is configured to implement the power-off method provided in the first aspect. This function can be implemented in hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above function.
[0022] Thirdly, an electronic device is provided, which has the function of implementing the method provided in the first aspect. This function can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above-described function.
[0023] Fourthly, an electronic device is provided, comprising: one or more processors and a memory; the processor includes at least one central processing unit (CPU) core group, each CPU core group including one or more CPU cores, the memory being used to store computer execution instructions, wherein when the electronic device is running, the processor executes the computer execution instructions stored in the memory to cause the electronic device to perform a shutdown method as provided in any of the first aspects above.
[0024] Fifthly, a computer-readable storage medium is provided that stores instructions which, when executed on a computer, cause the computer to perform the shutdown method provided in any of the first aspects above.
[0025] In a sixth aspect, a computer program product containing instructions is provided that, when run on a computer, enables the computer to perform the shutdown method provided in any of the first aspects above.
[0026] The technical effects of any of the design methods in aspects two through six can be found in the technical effects of different design methods in aspect one, and will not be repeated here. Attached Figure Description
[0027] Figure 1 This is a schematic diagram illustrating a shutdown failure caused by a system crash, provided as an embodiment of this application.
[0028] Figure 2 A schematic diagram illustrating the disabling of a power holding pin when pulled low, as provided in an embodiment of this application;
[0029] Figure 3 A hardware structure diagram of an electronic device provided in an embodiment of this application;
[0030] Figure 4 This is a schematic diagram of a shutdown method provided in an embodiment of this application;
[0031] Figure 5 A schematic diagram illustrating a successful shutdown method provided in an embodiment of this application.
[0032] Figure 6 A schematic diagram illustrating a power manager detecting the operating state of a power management integrated circuit, provided as an embodiment of this application;
[0033] Figure 7 This application provides a schematic diagram of each layer in a power-on / off process according to an embodiment of the present application.
[0034] Figure 8 A schematic diagram illustrating a shutdown failure based on a shutdown process, provided as an embodiment of this application;
[0035] Figure 9 A schematic diagram illustrating the display of a dialog box during a shutdown process, provided in an embodiment of this application;
[0036] Figure 10 A schematic diagram illustrating an embodiment of this application that adds corresponding shutdown steps to the shutdown process;
[0037] Figure 11 This is a schematic diagram of a power manager module added based on a shutdown process, provided in an embodiment of this application. Detailed Implementation
[0038] The technical solutions of the embodiments of this application will be described below with reference to the accompanying drawings. In the description of this application, unless otherwise stated, " / " indicates that the objects before and after are in an "or" relationship. For example, A / B can represent A or B. "And / or" in this application is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone, where A and B can be singular or plural. Furthermore, in the description of this application, unless otherwise stated, "multiple" refers to two or more. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple. Furthermore, to facilitate a clear description of the technical solutions in the embodiments of this application, the terms "first" and "second" are used in the embodiments of this application to distinguish identical or similar items with substantially the same function and effect. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and that "first" and "second" are not necessarily different. Meanwhile, in the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is being used as an example, illustration, or description. Any embodiment or design scheme described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of terms such as "exemplary" or "for example" is intended to present related concepts in a concrete manner for ease of understanding.
[0039] A power management integrated circuit (PMIC) is a critical component specifically designed to manage and distribute power in electronic devices. In electronic devices, PMICs are used for power management, charging control, and battery management. During the power-on and power-off process, PMICs are primarily responsible for managing the power-on and power-off of the central processing unit (CPU), double data rate synchronous dynamic random access memory (DDR), and various peripheral devices.
[0040] A power management kit (PMK) is a manager that manages multiple of the aforementioned power management integrated circuits. It has a built-in clock chip and other firmware.
[0041] The power supply hold (PS_HOLD) pin is used to control power management chips (such as the power manager mentioned above) or power modules (such as the power management integrated circuit mentioned above). In certain specific applications, this pin can be used to control the power switch or reset circuit. When the power supply hold pin is pulled low, the power management chip or power module will keep the power off or in a reset state, such as during power-down. When the power supply hold pin is pulled high, the power management chip or power module will allow the power to be turned on or de-reset, such as during power-on.
[0042] In the normal boot process provided in the embodiments of this application, corresponding to the power management step, after the power manager detects the power button event, i.e. the boot event, it notifies the power management integrated circuit that needs power in the boot process to power on. Until one of the power management integrated circuits supplies power to the processor, at this time the processor is in the power-on state, the power holding pin will be pulled high, the power management integrated circuit will always be in the power-on state, and then the power manager will hand over control to the powered-on processor.
[0043] In the normal shutdown process provided in the embodiments of this application, corresponding to the power management step, after the processor software shutdown process is completed, it will immediately pull the power holding pin low. After receiving the power holding pin pull-low event, the power manager notifies all power management integrated circuits that are currently supplying power to power down.
[0044] In the current technology, with the increasing prevalence of electronic devices, the problem of powering on and off these devices has become increasingly prominent. During the shutdown process, electronic devices often freeze, commonly known as a system crash. System crashes are one of the most common electronic device malfunctions, with many causes, and are also one of the most troublesome. Because once an electronic device crashes, it cannot be shut down normally, impacting the user experience.
[0045] If the power management integrated circuit fails to power down properly during the shutdown process of an electronic device, the entire shutdown process will freeze and fail to complete, resulting in a shutdown failure. For example, during the power-on phase of the electronic device, the power-on / off register in the power manager should normally be written to 0x90, but instead, it is abnormally written to 0xAF. This means the 4th bit of the binary flag is set from 0 to 1, indicating that the power-on / off register is set to a low-level triggered disabled mode. This causes the power manager to be unable to respond to the power hold pin pull-low event. Therefore, after the software shutdown process is completed, the electronic device cannot respond to the power hold pin pull-low event, preventing all power management integrated circuits from powering down. Consequently, the entire shutdown process freezes and fails to complete, resulting in a shutdown failure. This is just one example; there are many reasons why an electronic device may freeze during shutdown, such as software conflicts, ROM problems, memory card problems, etc., which are not limited to this one.
[0046] For example, see Appendix Figure 1 In the shutdown process of an electronic device, if the device freezes, the entire shutdown process may become stuck and remain in the "shutting down" state, resulting in a shutdown failure. For examples of causes of electronic device freezes, please refer to the appendix. Figure 2 During the power-on process, the power-on / off registers in the power manager are abnormally written, which disables the power hold pin of the power manager from being pulled low. The power manager is unable to respond to the power hold pin pull-low event, which in turn causes the power management IC managed by the power manager to fail to power down, resulting in the electronic device crashing.
[0047] To address the issue of shutdown failure due to electronic device crashes during the shutdown process, this application provides a shutdown method. In this method, the electronic device, upon detecting a shutdown command, executes a shutdown process. If the electronic device fails to shut down after a first preset time period following the detection of the shutdown command, the power manager controls all power management integrated circuits to power down. After all the power management integrated circuits are powered down, the electronic device completes the shutdown. Even if the electronic device fails to shut down after the first preset time period and is stuck, the power manager controls all power management integrated circuits to power down, ensuring that the electronic device can still shut down even when it has crashed.
[0048] Based on the shutdown method provided in this application embodiment, if the electronic device fails to shut down after a first preset time following the detection of the shutdown command, it indicates that the shutdown process of the electronic device has stalled, resulting in a system crash. The shutdown process cannot end normally. In this case, the power manager can control all power management integrated circuits to power down, enabling normal shutdown. This improves the problem of shutdown failure caused by electronic device crashes during the shutdown process and achieves the goal of normal shutdown.
[0049] For example, if the power management integrated circuit fails to power down during the shutdown process, and after the electronic device detects the shutdown command and after a first preset time, the power management integrated circuits in the electronic device still cannot all be powered down, and the electronic device has not completed the shutdown, the power manager can control all power management integrated circuits to power down, thereby improving the problem of electronic device shutdown failure caused by electronic device freezing during the shutdown process, and also achieving the purpose of normal shutdown.
[0050] This application provides an electronic device having the aforementioned power-off method. The electronic device can be mobile or fixed. It can be deployed on land (e.g., indoors or outdoors, handheld or vehicle-mounted), on water (e.g., a ship), or in the air (e.g., an airplane, balloon, or satellite). This electronic device can be referred to as user equipment (UE), a terminal, or a subscriber unit. It can also be called a user equipment (UE), access terminal, terminal unit, subscriber unit, terminal station, mobile station (MS), mobile station, terminal agent, or terminal device. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, smart bracelet, smart screen, smartwatch, virtual reality (VR) device, augmented reality (AR) device, terminal in industrial control, terminal in self-driving, terminal in remote medical care, terminal in smart grid, terminal in transportation safety, terminal in smart city, terminal in smart home, etc. This application does not limit the specific type and structure of the electronic device. One possible structure of the electronic device is described below.
[0051] Taking mobile phones as an example, the attached document... Figure 3 A possible structure of an electronic device 101 is shown. The electronic device 101 may include: a processor 210, an external memory interface 220, an internal memory 221, a universal serial bus (USB) interface 230, a power management module 240, a battery 243, an audio module 270, a speaker 270A, a receiver 270B, a microphone 270C, a headphone jack 270D, buttons 290, a motor 291, an indicator 292, a camera 293, a display screen 294, and a subscriber identification module (SIM) card interface 295, etc. Optionally, in some embodiments, the power management module 240 includes a power manager 241 and a power management integrated circuit 242.
[0052] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 101. In other embodiments of this application, the electronic device 101 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0053] Processor 210 may include one or more processing units, such as: a field-programmable gate array (FPGA), an application-specific integrated circuit (ASIC), a system-on-chip (SoC), a central processing unit (CPU), an application processor (AP), a network processor (NP), a digital signal processor (DSP), a microcontroller unit (MCU), a programmable logic device (PLD), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, and a neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors. For example, processor 210 may be an application processor (AP). Alternatively, processor 210 may be integrated into a system-on-chip (SoC). Or, processor 210 may be integrated into an integrated circuit (IC) chip. The processor 210 may include an analog front end (AFE) and a micro-controller unit (MCU) in an IC chip.
[0054] The processor 210 executes the shutdown method provided in this application embodiment by executing the program and computer instructions stored in the internal memory 221.
[0055] The processor 210 may also include a memory for storing computer instructions and data. In some embodiments, the memory in the processor 210 is a cache memory. This memory can store computer instructions or data that the processor 210 has just used or that are used repeatedly. If the processor 210 needs to use the computer instructions or data again, it can directly retrieve them from the aforementioned memory. This avoids repeated accesses, reduces the waiting time of the processor 210, and thus improves the efficiency of the system.
[0056] In some embodiments, the processor 210 may include one or more interfaces. These interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a USB interface, etc.
[0057] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the electronic device 101. In other embodiments of this application, the electronic device 101 may also adopt different interface connection methods or a combination of multiple interface connection methods as described in the above embodiments.
[0058] Internal memory 221 can be used to store computer executable program code, which includes computer instructions. Processor 210 executes various functional applications and data processing of electronic device 101 by running the computer instructions stored in internal memory 221. In addition, internal memory 221 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
[0059] Electronic device 101 can implement audio functions such as music playback and recording through audio module 270, speaker 270A, receiver 270B, microphone 270C, headphone jack 270D, and application processor.
[0060] Audio module 270 is used to convert digital audio information into analog audio signal output, and also to convert analog audio input into digital audio signal. In some embodiments, audio module 270 may be located in processor 210, or some functional modules of audio module 270 may be located in processor 210. Speaker 270A, also called a "loudspeaker," is used to convert audio electrical signals into sound signals. Receiver 270B, also called a "handpiece," is used to convert audio electrical signals into sound signals. Microphone 270C, also called a "microphone" or "microphone," is used to convert sound signals into electrical signals. Electronic device 101 may be equipped with at least one microphone 270C. Headphone jack 270D is used to connect wired headphones. Headphone jack 270D may be a USB interface 230, or a 3.5mm Open Mobile Terminal Platform (OMTP) standard interface, or a Cellular Telecommunications Industry Association of the USA (CTIA) standard interface.
[0061] Buttons 290 include power buttons, volume buttons, etc. Buttons 290 can be mechanical buttons or touch buttons. Electronic device 101 can receive button input and generate key signal inputs related to user settings and function control of electronic device 101, such as power-off signals and power-on signals.
[0062] The power management module 240 includes a power manager 241 and a power management integrated circuit 242. The power management integrated circuit 242 is used for power management, charging control, and battery 243 management. In some embodiments, the power management integrated circuit 242 can perform corresponding operations in response to control signals from the power manager 241.
[0063] Power manager 241 is used to manage multiple power management integrated circuits 242. In some embodiments, power manager 241 can control the power management integrated circuits 242 to power on and off in response to power on / off indication information from button 290.
[0064] Electronic device 101 can implement shooting functions through an ISP, camera 293, video codec, GPU, display 294, and application processor. The ISP is used to process data fed back by the camera 293. In some embodiments, the ISP can be set in the camera 293. The camera 293 is used to capture still images or videos. In some embodiments, electronic device 101 may include one or N cameras 293, where N is a positive integer greater than 1.
[0065] Electronic device 101 can implement display functions through a GPU, display screen 294, and application processor. The GPU is a microprocessor for image processing, connected to the display screen 294 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 210 may include one or more GPUs, which execute computer instructions to generate or modify display information.
[0066] The display screen 294 is used to display images, videos, etc. The display screen 294 includes a display panel. In some embodiments, the electronic device 101 may include one or more display screens 294. In other embodiments, the display screen 294 may display prompts or notifications.
[0067] The wireless communication function of electronic device 101 can be realized through antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, modem processor, etc.
[0068] The following embodiments of this application use an electronic device that includes at least one power management integrated circuit and a power manager, with the at least one power management integrated circuit being controlled by the power manager, to specifically illustrate the shutdown method provided in the embodiments of this application.
[0069] See appendix Figure 4 The method may include steps S401-S403:
[0070] Step S401: The electronic device responds to the detection of a power-off command and executes the power-off process.
[0071] The shutdown command can be a hardware shutdown command (power button) or a software shutdown command, such as a slide-to-shutdown dialog box, a touch-to-click shutdown dialog box, a voice command to "shut down," or a timed shutdown. Since restarting involves shutting down and then turning on the device, the shutdown command can also include a restart command. When a shutdown command is detected, the electronic device can begin the shutdown process.
[0072] Step S402: After the power-off command is detected, if the electronic device fails to power off after a first preset time, the power manager controls all the power management integrated circuits to power down.
[0073] Under normal circumstances, electronic devices will shut down after a period of time. If, after the aforementioned shutdown command is detected, the electronic device fails to shut down after a first preset time, it indicates that the shutdown process has stalled, meaning the device has crashed and cannot complete the normal shutdown process. If the user triggers a shutdown or power-on command again (such as pressing the power button) while the device is not shutting down, the electronic device will not respond. In this case, certain measures are required to shut down the device. Therefore, in this embodiment, if the electronic device fails to shut down after the first preset time, the power manager can control all the aforementioned power management integrated circuits to power down to complete the shutdown.
[0074] In one possible implementation, after the electronic device detects a shutdown command, and after a first preset time period, some power management integrated circuits (ICs) in the electronic device remain powered on. That is, even after the software shutdown process of the electronic device is completed, because the power manager cannot respond to the power hold pin pull-down event that controls the power management ICs to power down, not all power management ICs in the electronic device are powered down. At this point, the power manager controls all power management ICs to power down, thereby improving problems such as shutdown failures caused by electronic device crashes during the shutdown process, and also achieving the goal of normal shutdown.
[0075] Step S403: After all the above power management integrated circuits are powered down, the above electronic equipment completes the shutdown process.
[0076] After all power management integrated circuits are powered down, the electronic device is in a non-powered state, and all operations of the electronic device have ceased. For example, see the appendix. Figure 5 At this point, the electronic device has been powered off.
[0077] During the shutdown process, if the electronic device fails to shut down after a first preset time period following the detection of a shutdown command, the power manager controls all the power management integrated circuits to power down. This indicates that the electronic device has crashed and cannot complete the normal shutdown process. In this case, the power manager can control all the power management integrated circuits to power down to complete the shutdown, thereby improving the problem of shutdown failure caused by electronic device crashes during the shutdown process and achieving the purpose of normal shutdown.
[0078] The above three steps S401-S403 are to power off the electronic device by controlling all the power management integrated circuits to shut down the electronic device after the first preset time period if the electronic device has not been powered off. Therefore, it is necessary to accurately and intuitively let the outside world know whether the electronic device has been powered off.
[0079] In some embodiments of this application, the electronic device not being powered off includes: the display screen of the electronic device being on; after the electronic device is powered off, the display screen of the electronic device is turned off.
[0080] For example, when the screen is on, it indicates that the electronic device has not been completely shut down; when the screen is off, it indicates that the electronic device has been completely shut down. The on / off state of the screen helps users determine whether the electronic device has been completely shut down. This is just one example; other methods can be used to determine whether an electronic device has been completely shut down, such as checking for responses when clicking the screen or the home button, etc., and are not limited to this.
[0081] In some embodiments of this application, in order to determine the accuracy of the system crash, the first preset duration is set to be longer than the normal shutdown duration.
[0082] The aforementioned normal shutdown duration can be obtained by statistically analyzing the normal shutdown durations of most such electronic devices or the current electronic device, such as the average or median shutdown duration under multiple normal conditions; it can also be set according to actual needs, such as based on empirical values. If the electronic device has not completely shut down after the aforementioned normal shutdown duration, it can be determined that the electronic device may have frozen. Therefore, the first preset duration used to determine whether the electronic device has frozen only needs to be greater than the normal shutdown duration. Since shutdown requires a certain amount of time, determining whether a device has frozen can be done by using the duration. Using a first preset duration greater than the normal shutdown duration provides a certain amount of redundancy in the freezing process, improving the accuracy of freezing detection.
[0083] In order to accurately and intuitively let the outside world know whether the electronic device has completed the shutdown, and to shut down the electronic device by controlling all the power management integrated circuits to power down the electronic device after the first preset time, in addition to steps S401-S403, steps S404-S405 are added to detect the working status of the power management integrated circuits to locate the power management integrated circuits that have not been powered down.
[0084] In this application embodiment, in order to locate the power management integrated circuit that is not powered down and causes the electronic device to freeze, i.e., the fault power management integrated circuit, see the appendix for an example. Figure 4 The above-mentioned shutdown methods also include:
[0085] Step S404: During the shutdown process, the electronic device detects the operating status of the power management integrated circuit through the power manager.
[0086] Step S405: The electronic device saves the operating state of the power management integrated circuit in the power manager.
[0087] In one possible implementation, the reason why the power management IC that is not powered down causes the electronic device to freeze is as follows: During the power-on phase of the electronic device, the power-on / off register in the power manager should normally be written to 0x90, but it is abnormally written to 0xAF, that is, the 4th bit of the binary flag is set from 0 to 1. In other words, the power-on / off register is set to a low-level triggered disabled mode, causing the power manager to be unable to respond to the power hold pin pull-down event. Therefore, after the electronic device completes the software shutdown process, it cannot respond to the power hold pin pull-down event of the power manager, causing all the power management ICs that are currently supplying power to fail to power down. Therefore, the presence of a power management IC that is not powered down indicates that the power management IC has failed, thus causing the electronic device to freeze.
[0088] If the electronic device fails to shut down after the first preset time, it indicates that the electronic device has crashed. According to the principle of electronic device crash, the failure of the power management integrated circuit to power down will cause the electronic device to crash. At this time, it is necessary to first detect the working status of the power management integrated circuit and then save the working status of the power management integrated circuit in order to locate the power management integrated circuit that has not been powered down.
[0089] In this embodiment of the application, during the shutdown process, detecting the operating status of the power management integrated circuit via the power manager includes: during the shutdown process, the electronic device sends detection information to the power management integrated circuit and receives target data from the respective status registers of the power management integrated circuit. The target data is used to indicate whether the operating status of the power management integrated circuit is normal or abnormal.
[0090] The process of an electronic device detecting the operating status of the aforementioned power management integrated circuit (IC) is an interactive process. During this process, the electronic device first sends detection information to the IC, and the IC responds by returning target data from its respective status register. Then, the electronic device receives the target data from the respective status registers of the ICs. This target data indicates whether the power management IC is operating normally or abnormally; in effect, it detects whether the power management IC is operating normally or abnormally.
[0091] In this embodiment of the application, taking five power management integrated circuits and the status register of the power management integrated circuits as an example, the interaction process between the power manager and the power management integrated circuits is illustrated.
[0092] For example, see Appendix Figure 6The power manager sends detection information to the five power management integrated circuits: power management integrated circuit 1, power management integrated circuit 2, power management integrated circuit 3, power management integrated circuit 4, and power management integrated circuit 5. The corresponding status registers for these five power management integrated circuits are 0x2A8000, 0x2A8001, 0x2A8002, 0x2A8003, and 0x2A8004, respectively. In response to the detection information, each of the five power management integrated circuits returns target data in its respective status register, such as 0 or 1. For example, 0 indicates that the power management integrated circuit is in a normal state, and 1 indicates that the power management integrated circuit is in an abnormal state. Finally, the power manager receives the target data from the respective status registers of the five power management integrated circuits.
[0093] Through the above-mentioned interactive method, the electronic device detects the working status of the power management integrated circuit, and at the same time, uses target data to characterize whether the working status of the power management integrated circuit is normal or abnormal, thereby saving the normal or abnormal working status of the power management integrated circuit in a timely manner.
[0094] In this embodiment, when the target data is a target value, the power management integrated circuit operates normally; when the target data is not a target value, the power management integrated circuit operates abnormally.
[0095] Since the target data stored in the status registers of the aforementioned power management integrated circuits can detect their operating status in real time, the power manager can determine the operating status of the power management integrated circuits based on the corresponding target data. If the target data is the target value, it indicates that the power management integrated circuit is operating normally. If the target data is not the target value, it indicates that the power management integrated circuit is operating abnormally. Determining the operating status of the power management integrated circuit by checking whether the target data is the target value can improve the accuracy of determining the operating status of the power management integrated circuit.
[0096] In this embodiment of the application, the target data in the status register includes a preset flag bit.
[0097] Since the target data corresponding to the status register includes preset flag bits, the electronic device can determine the operating status of the power management integrated circuit based on the preset flag bits. For example, the target value can be 0, and a non-target value can be 1. Determining the operating status of the power management integrated circuit by checking whether the preset flag bits in the register are the target values can improve the accuracy of determining the operating status of the power management integrated circuit.
[0098] The above shutdown process occurs when a fault or system crash occurs during shutdown. The power manager controls all power management ICs to power down in order to force a shutdown. However, the ultimate goal after shutdown is to power on normally. Therefore, it is necessary to check the working status during the shutdown process in order to perform the corresponding processing operations.
[0099] In this embodiment of the application, after the electronic device has been powered off, the method further includes: powering on; obtaining the operating state of the power management integrated circuit during the last power-off process from the power manager; and performing corresponding processing operations based on the operating state of the power management integrated circuit.
[0100] After shutting down and restarting, in order to find out the cause of the crash during the last shutdown and enable normal startup, it is necessary to obtain the working status of the power management IC during the last shutdown from the power manager, find the power management IC that was not powered down, and then perform the corresponding processing operation according to the working status of the power management IC.
[0101] Since the power management integrated circuit that is not powered off has been identified, the corresponding processing operation can be performed according to the working state of the power management integrated circuit. The corresponding processing operation is based on the severity of the fault and the probability of performing the corresponding repair.
[0102] In this embodiment of the application, the above-mentioned processing operation based on the working state of the power management integrated circuit includes one or more of the following: recording the working state of the power management integrated circuit in a log; adjusting the abnormal working state of the power management integrated circuit to a normal working state; and providing an early warning based on the abnormal working state of the power management integrated circuit.
[0103] For example, the corresponding processing operations above are categorized based on the likelihood of repair: First, if it can be repaired automatically, the normal operating state will be adjusted back to normal operating state; second, if it cannot be repaired automatically, external technical personnel are required to repair it, and its operating status will be recorded in a log for external technical personnel to review; third, if there is no possibility of repair, a warning will be issued, such as replacing the device. The above corresponding processing operations are multiple processing operations provided based on the operating status of the power management integrated circuit to deal with different degrees of shutdown failures.
[0104] Since the power-off and power-on processes of electronic devices each correspond to their own processes, and each process corresponds to a software layer, the power-off method described above can also be explained in detail through the software layer. The power-off process is the reverse of the power-on process; therefore, the power-on process can be used to explain the power-off process.
[0105] This application uses a layered architecture software system of an electronic device as an example to illustrate its boot process.
[0106] The software system of electronic devices can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application uses a layered architecture software system as an example. A layered architecture divides the software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces.
[0107] The power-on of electronic devices is achieved through a software system. In the software implementation process, from powering on to logging into the desktop, a series of software processes need to be started. Different processes correspond to different stages of the power-on process, and different stages of the power-on process correspond to the startup of different layers of the software system.
[0108] For example, see Appendix Figure 7 :
[0109] The boot process of an electronic device includes the bootloader layer, kernel layer, local layer, application framework layer (also known as the FW stage), and application layer (also known as the application layer).
[0110] The bootloader layer is used to boot from memory initialization and the kernel layer. When the power manager detects a power button press (i.e., a power-on event), it notifies the power management ICs that require power during the boot process to power on. Once one of these power management ICs supplies power to the processor, the processor is in a powered-on state, and the power hold pin is immediately pulled high, keeping the power management IC powered on. When the device powers on or restarts, the processor is first booted by the bootloader layer. The bootloader layer includes the execution of a series of initialization code (such as ROM code), followed by loading the operating system kernel into memory (such as ROM or RAM). The bootloader layer is typically stored in the device's firmware, and its main task is to initialize the hardware and load and boot the operating system kernel. In the bootloader layer, memory initialization is performed first, followed by loading the operating system kernel into memory and booting the kernel layer.
[0111] The kernel layer is the layer between hardware and software. At a minimum, the kernel layer includes a series of processes creation tasks, such as creating kworker, ksoftirqd, and thermal processes. The kernel layer also includes at least a series of driver-related tasks, such as display drivers, camera drivers, audio drivers, and sensor drivers.
[0112] The local layer includes service management, media services, and the startup of HAI using standard interfaces. Service management includes services such as boot animations.
[0113] The application framework layer includes the application layer's application programming interface (API) and the startup of the programming framework. The application framework layer includes some predefined functions. It may include a window manager, content provider, activity manager, input manager, view system, phone manager, resource manager, power manager, notification manager, etc.
[0114] The application layer can include a series of application packages. These application packages can include applications such as camera, gallery, calendar, phone, login, map, navigation, network (WLAN), Bluetooth, music, video, browser, email, and SMS.
[0115] In the boot process, the software layers start in the following order: bootloader layer, kernel layer, native layer, application framework layer, and application layer. In the shutdown process, which is the reverse of the boot process, the software layers shut down in the following order: application layer, application framework layer, native layer, kernel layer, and bootloader layer. The reboot process is a shutdown followed by a boot process; it starts the bootloader layer, kernel layer, native layer, application framework layer, and application layer in the software layer, and then shuts down the application layer, application framework layer, native layer, kernel layer, and bootloader layer.
[0116] In related technologies, system crashes occur due to a fault between the kernel layer in the software and the power manager in the hardware. For example, after the processor software shutdown process is completed (i.e., the kernel layer shuts down), the power hold pin is immediately pulled low. Upon receiving this low-level event, the power manager notifies all power management ICs currently supplying power to power down. However, if the power-on / off register in the power manager is abnormally written during the power-on process, causing it to be set to a low-level triggered disabled mode, the power hold pin pull-down is disabled. This prevents the power manager from responding to the low-level event, and consequently, the electronic device cannot respond to the power hold pin pull-down event after the software shutdown process is complete, resulting in all power management ICs failing to power down. This application's embodiments, combining software and hardware, use a shutdown flowchart as an example to illustrate the cause of the system crash, corresponding to each layer in the software shutdown process and the power manager in the hardware.
[0117] For example, see Appendix Figure 8 :
[0118] Step 1: The electronic device detects a shutdown event.
[0119] The shutdown event can be a hardware shutdown event triggered by the power button, or a software shutdown event triggered by screen swiping, screen clicking, etc.
[0120] Step 2: The application layer displays a shutdown or restart dialog box.
[0121] Upon detecting a shutdown event, the shutdown operation is first performed in the software. At this time, the electronic device's display screen will show two dialog boxes: "Shutdown" and "Restart". See the appendix for an example. Figure 9 This allows users to choose between shutting down or restarting. Regardless of whether the user chooses to shut down or restart, the electronic device will first perform a shutdown process. Specifically, when the user chooses to shut down, the shutdown process alone completes all procedures; when the user chooses to restart, the shutdown process must be performed first, followed by the power-on / off process to complete all procedures. Therefore, after selecting a shutdown or restart operation, the electronic device executes the shutdown process. Since the application layer includes a series of application packages, which may include applications such as camera, gallery, calendar, phone, login, map, navigation, network (WLAN), Bluetooth, music, video, browser, email, and SMS, and displaying a shutdown or restart dialog box is one of these application packages, the shutdown or restart dialog box is displayed at the application layer.
[0122] Step 3: The application framework layer wakes up the lock, shuts down or restarts, and broadcasts shutdown information.
[0123] The shutdown process involves closing many programs and tasks, requiring the electronic device to be powered on continuously. Therefore, a wake-up lock is needed. In this embodiment, the lock refers to a power-maintaining lock, and the wake-up lock is used to wake up this power-maintaining lock, keeping the electronic device powered on. In the previous step (the second step), a shutdown or restart dialog box was displayed, and the user selected either option. Now, it's necessary to respond to the user's shutdown or restart operation, broadcasting shutdown information to subsequent layers to complete the shutdown process. The application framework layer includes the application layer's application programming interface (API) and the shutdown mechanism. The application framework layer includes predefined functions. It may include a window manager, content provider, activity manager, input manager, view system, phone manager, resource manager, power manager, and notification manager. The wake-up lock is a type of API provided by the application layer, restart or shutdown is a type of content provider, and broadcasting shutdown information is a type of notification manager. Therefore, the wake-up lock, restart or shutdown, and broadcast shutdown information are executed at the application framework layer.
[0124] Step 4: Stop all services, cancel all services, synchronize data, and unmount the file system at the local level.
[0125] Upon receiving the broadcast shutdown message, the system performs tasks such as suspending and canceling all services, synchronizing data, and unloading the file system. Since the local layer includes service management, media services, and the shutdown of standard interfaces provided by HAI, and suspending, canceling, synchronizing data, and unloading the file system fall under service management, these tasks are performed at the local layer.
[0126] Step 5: Disable interrupts, shutdown broadcasts, and destroy all device drivers at the kernel level.
[0127] Next, tasks such as disabling interrupts and drivers are performed, including disabling interrupts, broadcasting a shutdown, and destroying all device drivers. In the previous step (step four), services were already disabled; now, it's necessary to disable interrupts and drivers, and also broadcast a shutdown to the power manager to power down the power management ICs. Since the kernel layer is the layer between hardware and software, it includes at least a series of driver-related tasks, such as display drivers, camera drivers, audio drivers, and sensor drivers. Disabling interrupts, broadcasting a shutdown, and destroying all device drivers are driver-related tasks; therefore, these tasks are performed at the kernel layer.
[0128] Step 6: The power manager broadcasts power down to the full power management integrated circuit.
[0129] Upon receiving the power-off broadcast, the power manager broadcasts a power-down message to the full power management ICs. At this time, it immediately pulls the power hold pin low. After receiving the power hold pin pull-down event, the power manager notifies all power management ICs that are currently supplying power to power down.
[0130] The above six steps are the normal shutdown procedure. However, due to an abnormal write to the power-on / off registers in the power manager during the power-on process, the power-on / off registers are set to a low-level triggered disabled mode, which corresponds to the attached... Figure 8 A fault occurred in step ① between the kernel layer and the power manager. At this time, the power hold pin of the power manager was disabled, causing the power manager to be unable to respond to the power hold pin pull-low event. Therefore, the electronic device could not respond to the power hold pin pull-low event of the power manager after the software shutdown process was completed, causing all the power management integrated circuits that were being powered to fail to power down.
[0131] To resolve the aforementioned system crashes and improve the issue of electronic devices failing to shut down due to system crashes during the shutdown process, enabling them to shut down normally, the above shutdown method can be implemented by combining software shutdown procedures and power management (hardware).
[0132] In this embodiment, the shutdown process includes a software shutdown stage and a hardware power-down stage. The electronic device includes a kernel layer. After the shutdown command is detected, before the electronic device completes shutdown after a first preset time, the method further includes: within the first preset time after the shutdown command is detected, after the software shutdown stage ends, the kernel layer sends a power-down control signal to the power manager. The power-down control signal is used to instruct the power management integrated circuit to be powered down during the hardware power-down stage; the power manager does not respond to the power-down control signal.
[0133] Upon detecting a shutdown command, the shutdown process is executed. Following the normal shutdown procedure, after the software shutdown phase, the kernel layer sends a power-down control signal to the power manager to control the hardware power-down phase, whereby the power manager powers down the aforementioned power management integrated circuit. However, after completing the normal shutdown process, if the power manager fails to respond to the power-down control signal (i.e., it cannot power down the power management integrated circuit), and the normal shutdown duration has exceeded the first preset time, then the next step is executed. Since the kernel layer is the layer between hardware and software, it implements interaction with the hardware power manager. Furthermore, by understanding the principles of software shutdown and hardware power-down, the reasons for incomplete shutdown can be identified promptly, allowing for timely measures to ensure a successful shutdown.
[0134] Furthermore, corresponding steps can be added to the above-mentioned software shutdown process and power manager to implement the shutdown method described above.
[0135] In this embodiment, during the software shutdown phase, a first callback function is registered in the kernel layer, and a shutdown instruction is broadcast. Correspondingly, upon receiving the shutdown instruction, the power manager calls the first callback function. This first callback function starts a timer to determine if the first preset duration has been reached.
[0136] During the software shutdown phase, a first callback function is registered in the kernel layer and a shutdown instruction message is broadcast. This message is then used to interact with the power manager. By calling the first callback function, the power manager, upon receiving the shutdown instruction message, starts a timer to count the shutdown duration to determine whether the first preset duration has been reached, thus determining whether the shutdown is complete.
[0137] Since the kernel layer is the layer between hardware and software, it includes at least a series of driver-related tasks, such as display drivers, camera drivers, audio drivers, and sensor drivers. Registering callback functions and broadcasting shutdown instructions are among these driver-related tasks. Therefore, the kernel layer executes the registration of callback functions and the broadcast of shutdown instructions, while also implementing interaction with the hardware power manager. This combination of software shutdown and power management, enabling the determination of whether shutdown is complete, can mitigate problems such as shutdown failures caused by electronic device crashes.
[0138] For example, in the shutdown process, see Appendix Figure 10 :
[0139] Step 1. Register callback functions at the kernel level.
[0140] In this step, the callback functions mentioned above include a first callback function and a second callback function. Registering the first and second callback functions at the kernel level is for subsequent power management to call them and perform the corresponding operations.
[0141] Step 2. The kernel layer broadcasts a shutdown instruction message.
[0142] Step 3. After receiving the shutdown instruction information, the power manager calls the first callback function to execute the shutdown method, thereby shutting down the device. The first callback function is used to start a timer to determine whether the first preset duration has been reached.
[0143] This step implements communication and interaction between the kernel layer and the power manager. For example, a shutdown broadcast is executed at the kernel layer, and the power manager receives the shutdown instruction information from the broadcast. A first callback function is registered at the kernel layer. After receiving the shutdown instruction information, the power manager calls the first callback function to execute the shutdown method, thereby forcibly shutting down the device. The shutdown method uses a timer to determine whether a first preset duration has been reached, thus determining whether the shutdown is complete. The two communicate and are interconnected, combining software shutdown with the power manager to determine whether the shutdown is complete, thereby improving problems such as shutdown failures caused by electronic device crashes during the shutdown process.
[0144] Furthermore, the operating status of the aforementioned power management integrated circuit is detected in order to locate the power management integrated circuit that is not powered down. Corresponding to the software shutdown process, corresponding steps can also be added to the aforementioned software shutdown process and power manager.
[0145] In this embodiment of the application, sending detection information to the power management integrated circuit during the shutdown process includes: during the software shutdown phase, the kernel layer registers a second callback function and broadcasts shutdown instruction information; after receiving the shutdown instruction information, the power manager calls the second callback function; the second callback function is used to trigger the power management module to send detection information to the power management integrated circuit.
[0146] Since the kernel layer is the layer between hardware and software, it includes at least a series of driver-related tasks, such as display drivers, camera drivers, audio drivers, and sensor drivers. Registering callback functions and broadcasting shutdown instructions are among these driver-related tasks. Therefore, the kernel layer executes the registration of callback functions and the broadcasting of shutdown instructions, while also implementing interaction with the hardware power manager. By combining the software with the power manager, detection information is sent to the aforementioned power management integrated circuit, thereby promptly obtaining information about the normal or abnormal operating status of the power management integrated circuit.
[0147] For example, in the shutdown process, see Appendix Figure 10 :
[0148] Step 4. After receiving the shutdown instruction information, the power manager calls the second callback function to execute the detection method. The second callback function triggers the power management module to send detection information to the power management integrated circuit.
[0149] This step also involves communication and interaction between the kernel layer and the power manager. Similarly, for example, a shutdown broadcast is performed at the kernel layer, and the power manager receives the shutdown instruction information from the broadcast. A second callback function is registered at the kernel layer, and after the power manager receives the shutdown instruction information, it calls the second callback function to execute the detection method. This detection method completes the detection step by triggering the power management module to send detection information to the power management integrated circuit. The two communicate and are interconnected, combining software shutdown with the power manager to send detection information, thereby promptly obtaining information about the normal or abnormal operating status of the power management integrated circuit.
[0150] The ultimate goal of shutting down is to enable normal startup. Therefore, during the startup process, it's necessary to check the operating status during shutdown to locate and repair faults or provide user feedback. Correspondingly, similar steps can be added to the software shutdown process and power manager.
[0151] In this embodiment, the boot process includes a bootloader layer and a kernel layer. The step of obtaining the operating state of the power management integrated circuit (IC) during the last shutdown from the power manager and performing corresponding processing operations based on the IC's operating state includes: the bootloader layer receiving the IC's operating state from the power manager; the bootloader layer sending the received IC's operating state to the kernel layer; and the kernel layer performing the corresponding processing operations based on the IC's operating state during the boot process.
[0152] Since the boot sequence is to start the bootloader layer first, followed by the kernel layer, the bootloader layer first receives the operating status of the power management integrated circuit (IC) from the power manager, then sends the received IC's operating status to the kernel layer. Finally, the kernel layer executes the corresponding processing operations based on the IC's operating status during the boot process. This method enables the transmission of the power management IC's operating status from the previous shutdown process during the boot process, allowing for timely execution of corresponding processing operations based on the IC's operating status.
[0153] For example, in the boot process, see Appendix Figure 10 :
[0154] Step 1. The power manager detected the power-on command.
[0155] In this step, the power-on command can be either a physical power button command or a software power-on command, such as sliding the restart dialog box or typing "restart" in voice. When the power-on command is detected, the electronic device can then begin the power-on process.
[0156] Step 2. The power manager obtains the operating status of the power management integrated circuit during the last shutdown and sends it to the bootloader layer.
[0157] In this step, the working status of the power management integrated circuit was detected by the power manager during the previous shutdown process; the working status of the power management integrated circuit was saved in the power manager; at this time, the working status of the power management integrated circuit during the previous shutdown process was obtained and sent to the boot loading layer to complete the information transmission.
[0158] Step 3. The bootloader layer sends the received operating status of the power management integrated circuit to the kernel layer.
[0159] In this step, information transmission is achieved by sending the received operating status of the power management integrated circuit to the kernel layer, thus completing the information transmission.
[0160] Step 4. During the power-on process, the kernel layer performs corresponding processing operations based on the operating state of the power management integrated circuit.
[0161] In this step, since the kernel layer is the layer between hardware and software, and the above-mentioned processing operation is performed according to the working state of the power management integrated circuit, it is a kind of interaction between inner and outer layers. Therefore, the above-mentioned processing operation is performed in the kernel layer.
[0162] In the four steps above, the software boot sequence is: bootloader layer, kernel layer, local layer, application framework layer, and application layer, while the power manager is hardware. The kernel layer is the layer between hardware and software. Therefore, after obtaining the operating state of the power management IC during the last shutdown from the power manager, it needs to be transmitted to the kernel layer. According to the boot process, this transmission must first be sent to the bootloader layer, and then through the bootloader layer to the kernel layer. Finally, the kernel layer executes the corresponding processing operations based on the operating state of the power management IC during the boot process, ensuring timely execution of the appropriate processing based on the IC's operating status.
[0163] This application also provides a power manager. The above-described shutdown method can also be implemented by adding a corresponding module to the power manager. For example, see the appendix. Figure 11 Add a shutdown module corresponding to the above shutdown method and a detection module for executing the detection steps in the above shutdown method to the power manager to achieve the following: Figure 10 The power manager provides various functions and steps to improve the shutdown process, addressing issues such as electronic devices failing to shut down due to crashes, and enabling normal shutdown.
[0164] It is understood that, in order to achieve the above functions, the electronic device includes hardware and / or software modules that perform the respective functions. Based on the algorithmic steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is implemented in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments, but such implementation should not be considered beyond the scope of this application.
[0165] This embodiment can divide the electronic device into functional modules according to the above method example. For example, each function can be divided into its own functional modules, or two or more functions can be integrated into one processing module. The integrated modules can be implemented in hardware. It should be noted that the module division in this embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.
[0166] This application also provides an electronic device that may include one or more processors and a memory.
[0167] The memory is coupled to the processor. For example, the memory and the processor can be coupled together via a bus.
[0168] The memory stores computer program code. This computer program code includes computer instructions, which, when executed by the processor, cause the electronic device to perform the shutdown method described in this embodiment.
[0169] The processor can be a processor or controller, such as a central processing unit (CPU), a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with this disclosure. The processor can also be a combination that implements computational functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0170] The bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. These buses can be categorized as address buses, data buses, control buses, etc.
[0171] This application also provides a computer-readable storage medium storing computer program code. When the processor executes the computer program code, the electronic device executes the relevant method steps in the above method embodiments.
[0172] This application also provides a computer program product that, when run on a computer, causes the computer to execute the relevant method steps described in the above method embodiments.
[0173] The electronic devices, computer storage media, or computer program products provided in this application are all used to execute the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0174] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0175] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0176] The units described above as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0177] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The functions of the integrated unit can be implemented in hardware or as software functional units.
[0178] If the integrated units described above are implemented as software functional units and sold or used as independent products, they can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, in essence, or the contributing parts, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0179] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for shutting down a device, characterized in that, Applied to an electronic device, the electronic device including a kernel layer; the electronic device including at least one power management integrated circuit and a power manager, the at least one power management integrated circuit being controlled by the power manager, the method comprising: In response to the detection of a shutdown command, a shutdown process is executed; the shutdown process includes a software shutdown phase and a hardware power-off phase. During the software shutdown phase, the kernel layer registers a first callback function and broadcasts shutdown instruction information; After receiving the power-off instruction, the power manager calls the first callback function; wherein, the first callback function is used to start a timer to determine whether a first preset duration has been reached; Within the first preset time after the shutdown command is detected, after the software shutdown phase ends, the kernel layer sends a power-down control signal to the power manager. The power-down control signal is used to instruct the power management integrated circuit to be powered down during the hardware power-down phase. The power manager did not respond to the power-down control signal; After the power-off command is detected, if there are any power management integrated circuits in the electronic device that have not been powered off after the first preset time, the power manager controls all power management integrated circuits to power off; the first preset time is longer than the normal power-off time. After all the power management integrated circuits are powered down, the electronic device completes the shutdown process.
2. The shutdown method according to claim 1, characterized in that, The electronic device is not completely powered off, including: the display screen of the electronic device is on; After the electronic device is powered off, the display screen of the electronic device is turned off.
3. The shutdown method according to any one of claims 1-2, characterized in that, Also includes: During the shutdown process, the power manager detects the operating status of the power management integrated circuit; The operating status of the power management integrated circuit is stored in the power manager.
4. The shutdown method according to claim 3, characterized in that, The step of detecting the operating status of the power management integrated circuit through the power manager during the shutdown process includes: During the shutdown process, detection information is sent to the power management integrated circuit; The system receives target data from the status registers of each of the power management integrated circuits, the target data being used to indicate whether the power management integrated circuit is operating normally or abnormally.
5. The shutdown method according to claim 4, characterized in that, When the target data is the target value, the power management integrated circuit is operating normally. If the target data is not the target value, the power management integrated circuit will malfunction.
6. The shutdown method according to claim 5, characterized in that, The target data in the status register includes a preset flag bit.
7. The shutdown method according to any one of claims 1-2 and 4-6, characterized in that, After the electronic device has finished shutting down, the method further includes: Startup upon power-on; Obtain the operating state of the power management integrated circuit during the last shutdown process from the power manager; The corresponding processing operation is performed according to the operating state of the power management integrated circuit.
8. The shutdown method according to claim 7, characterized in that, The step of performing corresponding processing operations based on the operating state of the power management integrated circuit includes one or more of the following: The operating status of the power management integrated circuit is recorded in a log; Adjust the abnormal operating state of the power management integrated circuit to a normal operating state; Early warning prompts will be issued based on the abnormal operating status of the power management integrated circuit.
9. The method according to any one of claims 4-6, characterized in that, The step of sending detection information to the power management integrated circuit during the shutdown process includes: During the software shutdown phase, the kernel layer registers a second callback function and broadcasts shutdown instruction information; After receiving the power-off instruction, the power manager calls the second callback function; the second callback function is used to trigger the power management module to send detection information to the power management integrated circuit.
10. The shutdown method according to claim 8, characterized in that, The boot process includes a boot loading layer and a kernel layer. The step of retrieving the operating state of the power management integrated circuit during the last shutdown from the power manager and performing corresponding processing operations based on the operating state of the power management integrated circuit includes: The bootloader layer receives the operating status of the power management integrated circuit obtained from the power manager; The bootloader layer sends the received operating status of the power management integrated circuit to the kernel layer; During the power-on process, the kernel layer performs the corresponding processing operations based on the operating state of the power management integrated circuit.
11. A power manager, characterized in that, This invention relates to an electronic device, which includes a kernel layer; the shutdown process of the electronic device includes a software shutdown phase and a hardware power-down phase; in the software shutdown phase, the kernel layer registers a first callback function and broadcasts shutdown instruction information; the electronic device includes at least one power management integrated circuit and a power manager, wherein the at least one power management integrated circuit is controlled by the power manager; the power manager is configured to: Upon receiving the power-off instruction, the first callback function is invoked; wherein, the first callback function is used to start a timer to determine whether a first preset duration has been reached; Within the first preset time period after the electronic device detects the shutdown command, after the software shutdown phase ends, a power-down control signal sent by the kernel layer is received. The power-down control signal is used to instruct the power management integrated circuit to be powered down during the hardware power-down phase. The power-down control signal was not responded to. It is determined that after the electronic device detects a power-off command, the power management integrated circuit has not been powered down after a first preset time; the first preset time is longer than the normal power-off time. Control the power-down of all the aforementioned power management integrated circuits.
12. An electronic device, characterized in that, The device includes a memory and one or more processors, the one or more processors including at least one power management integrated circuit and a power manager, the at least one power management integrated circuit being controlled by the power manager, the memory storing computer program code including computer instructions that, when executed by the processor, cause the electronic device to perform the shutdown method as described in any one of claims 1-10.
13. A computer-readable storage medium, characterized in that, Includes computer instructions that, when executed on the electronic device, cause the electronic device to perform the shutdown method as described in any one of claims 1-10.
14. A computer program product, characterized in that, When the computer program product is run on a computer, it causes the computer to perform the shutdown method as described in any one of claims 1-10.
Citation Information
Patent Citations
Domain controller power-off and reset method, domain controller, equipment and medium
CN115981217A
Intelligent shutdown method and system, medium, program product and robot
CN118312223A