Interrupt processing method, device and storage medium during partition switching

By recording the length of time the user presses the power off button and determining the type of interruption, the partition switching operation is resumed, which solves the problem of device power-off and restart caused by PMIC watchdog interruption, ensuring that electronic devices can restart normally and complete partition switching.

CN117707630BActive Publication Date: 2024-10-15HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311024567.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-14
Publication Date
2024-10-15
Estimated Expiration
2043-08-14

AI Technical Summary

Technical Problem

During the partition switching process, the interruption of the PMIC watchdog caused the electronic device to power off and restart, and thus the partition information exchange and startup could not be completed normally, resulting in the device being unable to start normally from the backup partition.

Method used

By recording the length of time the user presses the shutdown button, it is determined whether a PMIC watchdog interruption occurs, and the partition switching operation is resumed when the interruption is determined to be a partition switching operation to avoid power failure and restart, and ensure automatic restart after the partition switching is completed.

Benefits of technology

It effectively avoids interruptions during the partition switching process, ensures that electronic devices can restart normally and complete partition switching, and avoids the problem of equipment being unable to boot due to PMIC watchdog interruption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117707630B_ABST
    Figure CN117707630B_ABST
Patent Text Reader

Abstract

The present application provides an interrupt processing method, device and storage medium in a partition switching process. In the method, when an electronic device receives a user's pressing operation on a power-off key, it determines whether a PMIC watchdog interrupt has occurred by determining whether the current pressing duration is greater than or equal to a preset time threshold. When it is determined that a PMIC watchdog interrupt has occurred, it determines whether the currently interrupted operation is a partition switching operation, and when it is determined that the currently interrupted operation is a partition switching operation, it restores the interrupted partition operation and does not respond to the power-off restart operation of the electronic device corresponding to the PMIC watchdog interrupt, thereby effectively avoiding the partition switching process from being interrupted by the PMIC watchdog, thereby ensuring that the electronic device can complete the partition switching and restart normally.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an interrupt processing method, device and storage medium during a partition switching process. Background Art

[0002] For an electronic device whose data storage structure is a virtual AB mode, the operating system can be started through different partitions, that is, the operating system can be started from different partitions through partition switching, and then run.

[0003] However, currently some chip platforms assign the same and invalid Globally Unique Identifier (GUID) to all partitions in the backup partition. This results in the processor being unable to directly start the operating system according to the GUID of the backup partition during the partition switching process. Therefore, it is necessary to exchange partition information, such as switching GUID.

[0004] However, during the partition information exchange process, the user may press and hold the power button, causing the watchdog in the power management integrated circuit (PMIC watchdog) to output a reset signal, triggering the electronic device to power off and restart, thereby interrupting the exchange of partition information and making the electronic device unable to start from the backup partition. Summary of the invention

[0005] In order to solve the above technical problems, the present application provides an interrupt processing method, device and storage medium in the partition switching process, aiming to avoid the partition switching processing flow being interrupted by the PMIC watchdog, thereby ensuring that the electronic device can restart normally.

[0006] In the first aspect, the present application provides an interruption processing method in a partition switching process. The method is applied to an electronic device, comprising: when receiving a user's pressing operation on a power-off key, recording the user's pressing duration of the power-off key, the power-off key being located on the side frame of the electronic device; when the pressing duration is greater than or equal to a preset duration threshold, interrupting the currently executed operation; when there is an interrupted operation, determining whether the currently interrupted operation is a partition switching operation; when the currently interrupted operation is a partition switching operation, resuming the partition switching operation; after the partition switching operation is completed, restarting the electronic device.

[0007] The power off button is, for example, a Power button, or a combination of the Power button and other mechanical buttons, such as a volume up / down button.

[0008] The preset time threshold, for example, is the time that triggers a PMIC watchdog interrupt in the electronic device.

[0009] When the power-off button is pressed for a duration greater than or equal to a preset duration threshold, the electronic device will enter a PMIC watchdog state.

[0010] Among them, the partition switching operation is restored, that is, not responding to the pressing operation of the power off button this time, not triggering the power-off restart executed due to the PMICwatchdog interrupt, but continuing to complete the unfinished partition switching operation, and finally after the partition switching is completed, automatically triggering the electronic device to restart from the switched partition.

[0011] Therefore, when the electronic device receives a user's pressing operation on the power-off button, it determines whether a PMIC watchdog interrupt has occurred by determining whether the current pressing duration is greater than or equal to a preset time threshold. When it is determined that a PMIC watchdog interrupt has occurred, it determines whether the currently interrupted operation is a partition switching operation, and when it is determined that the currently interrupted operation is a partition switching operation, it restores the interrupted partition operation and does not respond to the operation of powering off and restarting the electronic device corresponding to the PMIC watchdog interrupt, thereby effectively avoiding the partition switching process from being interrupted by the PMIC watchdog, thereby ensuring that the electronic device can complete the partition switching and restart normally.

[0012] According to the first aspect, after the partition switching operation is completed and the electronic device is restarted, the method further includes: obtaining a restart reason identifier from the current stack information; the restart reason identifier is a first identifier, and the first identifier indicates that the restart of the electronic device is triggered by the partition switching.

[0013] Among them, the first identifier, for example, SWRest.

[0014] Therefore, when the restart reason obtained after the electronic device restarts is SWRest, it can be determined that the electronic device is automatically restarted after the partition switching operation is completed, and is not a power-off restart triggered by the PMIC watchdog interrupt. That is, the partition switching process is not interrupted by the PMIC watchdog to cause it to not start.

[0015] According to the first aspect, or any implementation of the first aspect above, the method further includes: when there is no interrupted operation currently, in response to a pressing operation, restarting the electronic device.

[0016] There is no interrupted operation currently, for example, no operation is currently being executed or the operation has been completed.

[0017] For the operations that have been completed, which may include a partition switching operation, in this case, the restart automatically triggered after the partition switching can be blocked by the PMIC watchdog interrupt, that is, the next restart of the electronic device is a power-off restart.

[0018] According to the first aspect, or any implementation of the first aspect above, the method further includes: when the currently interrupted operation is not a partition switching operation, restarting the electronic device in response to a pressing operation.

[0019] Since the partition switching operation involves the switching of GUID, and the GUID switching is interrupted, it may cause anomalies between the GUID recorded in the GPT partition table and the GUID of the actual physical partition, which in turn makes it impossible to boot according to the boot sequence recorded in the basic partition (recorded in the misc subpartition), ultimately causing the electronic device to fail to boot.

[0020] Therefore, when the currently interrupted operation is not a partition switching operation, the electronic device can be powered off and restarted.

[0021] According to the first aspect, or any implementation method of the first aspect above, after restarting the electronic device in response to a pressing operation, the method also includes: obtaining a restart reason identifier from the current stack information; the restart reason identifier is a second identifier, and the second identifier indicates that the electronic device is restarted this time due to a power-off restart triggered by a pressing operation.

[0022] The second identifier is, for example, XVDD.

[0023] Therefore, when the restart reason identifier obtained after the electronic device is restarted is XVDD, it can be determined that the electronic device is restarted due to power failure triggered by the PMIC watchdog interrupt.

[0024] According to the first aspect, or any implementation method of the first aspect above, determining whether the currently interrupted operation is a partition switching operation includes: obtaining the running status information of the program that executes the currently interrupted operation; and determining whether the currently interrupted operation is a partition switching operation based on the running status information.

[0025] According to the first aspect, or any implementation method of the first aspect above, determining whether the currently interrupted operation is a partition switching operation includes: determining the PC value of the program's instruction counter based on the running status information; when the PC value is in the PC value interval corresponding to the program that performs the partition switching operation, determining that the currently interrupted operation is a partition switching operation.

[0026] According to the first aspect, or any implementation of the first aspect above, the memory of the electronic device includes a basic partition, a first static partition, a second static partition, a dynamic partition and a user data partition; wherein, when the first static partition is an active partition, the second static partition is a backup partition; each sub-partition included in the active partition has a valid and unique identifier, and each sub-partition included in the backup partition shares an invalid identifier.

[0027] Wherein, an identity identifier, such as a GUID.

[0028] Among them, the basic partition can be expressed as Common, the first static partition can be expressed as SlotA, the second static partition can be expressed as SlotB, the dynamic partition can be expressed as Super, and the user data partition can be expressed as Userdata.

[0029] The above data storage structure can be understood as a virtual AB mode.

[0030] According to the first aspect, or any implementation method of the first aspect above, the partition switching operation includes: modifying the identity identifier of each sub-partition in the backup partition recorded in the GPT partition table read into the memory to the identity identifier of the corresponding sub-partition in the active partition, and modifying the identity identifier of each sub-partition in the active partition to an invalid identity identifier; modifying the boot order recorded in the basic partition from the first static partition to the second static partition; and updating the identity identifier of each sub-partition in the backup partition and the active partition in the memory according to the identity identifier of each sub-partition in the backup partition and the active partition recorded in the GPT partition table in the memory.

[0031] According to the first aspect, or any implementation of the first aspect above, the partition switching operation is completed, including: completing the step of updating the identity identifier of each sub-partition in the backup partition and the active partition in the memory according to the identity identifier of each sub-partition in the backup partition and the active partition recorded in the GPT partition table in the memory.

[0032] In a second aspect, the present application provides an electronic device. The electronic device includes: a memory and a processor, the memory and the processor are coupled; the memory stores program instructions, and when the program instructions are executed by the processor, the electronic device executes instructions of the method in the first aspect or any possible implementation of the first aspect.

[0033] The second aspect and any implementation of the second aspect correspond to the first aspect and any implementation of the first aspect respectively. The technical effects corresponding to the second aspect and any implementation of the second aspect can refer to the technical effects corresponding to the above-mentioned first aspect and any implementation of the first aspect, which will not be repeated here.

[0034] In a third aspect, the present application provides a computer-readable medium for storing a computer program, wherein the computer program includes instructions for executing the method in the first aspect or any possible implementation of the first aspect.

[0035] The third aspect and any implementation of the third aspect correspond to the first aspect and any implementation of the first aspect, respectively. The technical effects corresponding to the third aspect and any implementation of the third aspect can refer to the technical effects corresponding to the first aspect and any implementation of the first aspect, which will not be repeated here.

[0036] In a fourth aspect, the present application provides a computer program, comprising instructions for executing the method in the first aspect or any possible implementation of the first aspect.

[0037] The fourth aspect and any implementation of the fourth aspect correspond to the first aspect and any implementation of the first aspect, respectively. The technical effects corresponding to the fourth aspect and any implementation of the fourth aspect can refer to the technical effects corresponding to the above-mentioned first aspect and any implementation of the first aspect, which will not be repeated here.

[0038] In a fifth aspect, the present application provides a chip, the chip comprising a processing circuit and a transceiver pin, wherein the transceiver pin and the processing circuit communicate with each other through an internal connection path, and the processing circuit executes the method in the first aspect or any possible implementation of the first aspect to control the receiving pin to receive a signal and control the sending pin to send a signal.

[0039] The fifth aspect and any implementation of the fifth aspect correspond to the first aspect and any implementation of the first aspect, respectively. The technical effects corresponding to the fifth aspect and any implementation of the fifth aspect can refer to the technical effects corresponding to the first aspect and any implementation of the first aspect, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1A It is a schematic diagram showing the partition division of an internal memory in a virtual AB mode in which a data storage structure is exemplarily shown;

[0041] Figure 1BA schematic diagram showing partition division of an internal memory in a virtual AB mode in which another data storage structure is exemplarily shown;

[0042] Figure 2 is a flowchart showing an exemplary partition switching operation being interrupted by a PMIC watchdog;

[0043] Figure 3 A schematic diagram showing an exemplary upgrade process of an electronic device with a data storage structure in a virtual AB mode;

[0044] Figure 4 is a schematic diagram of the hardware structure of an electronic device shown as an example;

[0045] Figure 5 A schematic diagram of the software structure of an electronic device is shown as an example;

[0046] Figure 6 The present invention is a flowchart of an interrupt processing method in a partition switching process provided by an embodiment of the present application. DETAILED DESCRIPTION

[0047] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0048] The term "and / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.

[0049] The terms "first" and "second" in the description and claims of the embodiments of the present application are used to distinguish different objects rather than to describe a specific order of objects. For example, a first target object and a second target object are used to distinguish different target objects rather than to describe a specific order of target objects.

[0050] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0051] In the description of the embodiments of the present application, unless otherwise specified, the meaning of "multiple" refers to two or more than two. For example, multiple processing units refer to two or more processing units; multiple systems refer to two or more systems.

[0052] As more and more applications can be installed on electronic devices, the storage space occupied by user data is increasing. At present, in order to ensure the success of system upgrades and reduce the storage space occupied by system data as much as possible to leave more storage space for user data, electronic devices with a data storage structure in virtual AB mode are becoming more and more popular.

[0053] It is understandable that the storage space mentioned in this embodiment specifically refers to the storage space of the internal memory in the electronic device. For the internal memory, in a possible implementation, it can be divided into a basic partition (hereinafter represented by Common), a static partition (hereinafter represented by Slot), a dynamic partition (hereinafter represented by Super) and a user data partition (hereinafter represented by Userdata). Among them, Common, Slot and Super are used to store the operating system, at least one application required for a function (such as a sound playback function, an image playback function, etc.), etc., that is, the system data mentioned above. Userdata is used to store data created during the use of the electronic device (such as audio data, phone book, etc.), etc., that is, the user data mentioned above.

[0054] Based on the above partition division, when the electronic device starts to load the operating system, the system data in Common, Slot and Super are loaded in sequence.

[0055] In addition, it should be noted that the system data stored in Common is usually not modified during system upgrades, while the system data in Slot and Super are updated with the version update iteration. Among them, the system data stored in Slot usually occupies a smaller storage space, while the system data stored in Super usually occupies a larger storage space.

[0056] Based on the characteristics of the above partitions, in the data storage structure of the virtual AB mode, Slot exists in the form of dual partitions, and other partitions exist in the form of single partitions, such as Figure 1A shown.

[0057] For electronic devices whose data storage structure is a virtual AB mode, the operating system can be started through different partitions, such as through Figure 1AIn addition, for the data storage structure in the virtual AB mode, after a partition fails to start multiple times, it supports switching to another partition for the next startup. That is, you can start from different partitions through partition switching and then run the operating system.

[0058] For ease of understanding, the partition switching process is introduced below.

[0059] It should be noted that Slot includes multiple sub-partitions, such as X-loader, boot, dtbo, etc. Each sub-partition stores images required for electronic device startup and other services.

[0060] Specifically, in the data storage structure of the virtual AB mode, SlotA and SlotB can be understood as two sets of partitions with the same partition name, that is, SlotA and SlotB include the same sub-partitions. For easy distinction, the sub-partitions belonging to SlotA can be identified by "_a", and the sub-partitions belonging to SlotB can be identified by "_b". For example Figure 1B As shown in the figure, X-loader, boot, and dtbo belonging to SlotA can be expressed as X-loader_a, boot_a, and dtbo_a, and X-loader, boot, and dtbo belonging to SlotB can be expressed as X-loader_b, boot_b, and dtbo_b.

[0061] It should be understood that the above description is merely an example listed for a better understanding of the technical solution of this embodiment, and is not intended to be the sole limitation to this embodiment.

[0062] Continue to see Figure 1B Since SlotA and SlotB include the same sub-partitions, SlotA and SlotB are backups of each other. For ease of description, in some possible implementations, the currently used Slot may be referred to as an active partition, and the currently unused Slot may be referred to as a backup partition.

[0063] Still Figure 1B Taking SlotA and SlotB shown in as an example, if SlotA is currently being used, SlotA is the active partition and SlotB is the backup partition. If SlotB is currently being used, SlotB is the active partition and SlotA is the backup partition.

[0064] In addition, it should be noted that when the electronic device is started, Common, Slot and Super are loaded in sequence. In the data storage structure of the virtual AB mode, Slot has two partitions, SlotA and SlotB. Therefore, when the electronic device is started, the processor (CPU) needs to know which Slot to start from, that is, after loading Common, whether to load SlotA or SlotB.

[0065] The partition information of the slot that needs to be started each time is specifically recorded in the misc subpartition in the Common partition.

[0066] Exemplarily, in a possible implementation, it can be set to boot from SlotA by default. In this case, the partition information of Slot recorded in the misc sub-partition can be SlotA or _a. Correspondingly, when setting the default boot from SlotB, the partition information of Slot recorded in the misc sub-partition can be SlotB or _b.

[0067] Taking the scenario of setting the default startup from SlotA as an example, for example, when the electronic device fails to start from SlotA for a preset number of times (which can be set according to business needs), the partition switching can be automatically triggered, and the partition information of the Slot in the misc subpartition can be changed from SlotA to SlotB, or from _a to _b.

[0068] It should be understood that the above description is merely an example listed for a better understanding of the technical solution of this embodiment, and is not intended to be the sole limitation to this embodiment.

[0069] In addition, it should be noted that due to different selected startup modes, the sub-partitions in the slots that may need to be run may also be different. Therefore, each sub-partition of the active partition has a valid and unique GUID. In this way, during the startup of the electronic device, the CPU can load the sub-partitions corresponding to each GUID in turn according to a set of pre-configured GUIDs.

[0070] For the backup partition, for example, in some chip platforms, a valid and unique GUID is assigned to each sub-partition. In this way, if the active partition fails to start multiple times, the next time the backup partition is switched to start, the partition information of the Slot in the misc sub-partition can be directly modified.

[0071] However, in some other chip platforms (hereinafter referred to as platform A), the GUIDs assigned to all sub-partitions in the backup partition are the same and invalid. Therefore, even if the partition information of the slot in the misc sub-partition is modified to the backup partition, the CPU cannot be used at all because the GUIDs of all sub-partitions in the backup partition are the same and invalid. That is, the CPU cannot directly start the operating system according to the GUID of the backup partition.

[0072] In order to enable an electronic device using the A platform to boot normally from the backup partition after the active partition fails to boot for multiple times, during the partition switching process, it is necessary not only to modify the partition information in the misc subpartition, but also to switch the GUID of each subpartition in the two partitions, that is, to switch the GUID of each subpartition in the active partition to the corresponding subpartition in the backup partition, and to switch the GUID of each subpartition in the active partition to the invalid and identical GUID in the backup partition.

[0073] For ease of explanation, the following description is given with reference to examples.

[0074] Exemplarily, when the active partition is SlotA, the sub-partitions to be run include X-loader_a, boot_a, and dtbo_a, and the GUID of X-loader_a is GUID1, the GUID of boot_a is GUID2, and the GUID of dtbo_a is GUID3, and the GUIDs of X-loader_b, boot_b, and dtbo_b in the backup partition SlotB are all invalid GUID4 (GUID1, GUID2, GUID3, and GUID4 are 4 different GUIDs, and GUID1 to GUID3 are valid GUIDs, and GUID4 is an invalid GUID), when the preset number of startups from SlotA fails, the process of switching the electronic device from SlotA to SlotB includes at least the following process regarding the switching of GUIDs:

[0075] Step 1: Exchange the GUID of each sub-partition in SlotA and SlotB.

[0076] Specifically, the GUID of X-loader_b is switched from GUID4 to GUID1, while the GUID of X-loader_a is switched from GUID1 to GUID4; the GUID of boot_b is switched from GUID4 to GUID2, while the GUID of boot_a is switched from GUID2 to GUID4; the GUID of dtbo_b is switched from GUID4 to GUID3, while the GUID of dtbo_a is switched from GUID3 to GUID4.

[0077] It should be noted that during the startup of an electronic device, the GUID Partition Table (GPT) is first read from the internal memory to the memory. Then, based on the information recorded in the GPT, the GUID, start address, end address, partition name, etc. of the partition to be loaded are determined, and then the corresponding partition (physical partition) in the internal storage is loaded according to this information.

[0078] Therefore, the exchange of GUIDs in step 1 is only an exchange in memory, that is, the information recorded in the GPT is modified, and the GUID of the actual physical partition in the internal memory has not been updated.

[0079] Step 2: Change the partition information of Slot in the misc subpartition from indicating booting from SlotA to indicating booting from SlotB.

[0080] For example, the partition information of Slot in the misc subpartition is modified from SlotA to SlotB, or from _a to _b.

[0081] Step 3: Update the GUID exchanged in step 1 to Slot B. That is, the update of the GUID of the actual physical partition is completed.

[0082] Therefore, after completing the above steps 1 to 3, the switching from SlotA to SlotB is realized. In this way, the electronic device can use SlotB as the active partition, and then start from SlotB after loading the Common partition.

[0083] However, in some possible scenarios, during the partition information exchange, i.e., during the above steps 1 to 3, the user may press and hold the power button, or the power button and other mechanical buttons, such as the volume up / down button. Such operations will cause the watchdog in the power management integrated circuit (PMIC) to output a reset signal, i.e., trigger the PMIC watchdog interrupt.

[0084] It should be understood that when a PMIC watchdog interrupt occurs, the currently executed operation will be interrupted, and the electronic device will be powered off and restarted. Therefore, if a PMIC watchdog interrupt occurs, the partition signal switching operation has not been completed, such as only step 1 has been completed, or step 1 and step 2, and step 3 has not been completed. This results in that when the electronic device is restarted, when the CPU starts from SlotB, the GUIDs read from the actual physical partition are all invalid and identical GUID4, resulting in a restart failure and the electronic device cannot be turned on.

[0085] As Figure 2 shown, when the partition switch is triggered, the Bootloader in the electronic device will exchange partition information according to the above steps 1 to 3.

[0086] Exemplarily, for the sake of convenience of description, in this embodiment, the time taken for the electronic device to complete the partition switch is taken as T1.

[0087] Continue to refer to Figure 2 , exemplarily, during the process of the electronic device performing the partition switch, if the user presses the mechanical key of the electronic device, such as the Power key (or the Power key and the volume up / down keys), and the electronic device receives this pressing operation, it can record the duration of the user pressing the key, such as T2.

[0088] Continue to refer to Figure 2 , exemplarily, after obtaining the duration T2 of the user pressing the key, the electronic device can further determine the relationship among T1, T2, and T_Sx.

[0089] Among them, T_Sx is the time threshold at which the PMIC watchdog interrupt is triggered, that is, when the duration of the user pressing the key is greater than or equal to this time threshold, the PMIC watchdog interrupt will occur, thereby interrupting the currently ongoing operation, such as the partition switch operation, and triggering the electronic device to power off and restart.

[0090] Continue to refer to Figure 2 , exemplarily, if the relationship among T1, T2, and T_Sx satisfies T1>T2≥T_Sx, it can be determined that the PMIC watchdog interrupt (Sx_reset in Figure 2 ) has occurred at present. However, since T1>T2, it indicates that the partition switch operation has not been completed, that is, step 3 above has not been executed yet. Therefore, the currently executed partition switch operation will be interrupted, that is, the partition switch fails.

[0091] Continue to refer to Figure 2 , exemplarily, if the relationship among T1, T2, and T_Sx does not satisfy T1>T2≥T_Sx, for example, T1<T2≥T_Sx, in this case, it can be determined that the PMIC watchdog interrupt (Sx_reset in Figure 2 ) has occurred at present. However, since T1<T2, it indicates that the partition switch operation has been completed, that is, steps 1 to 3 above have all been executed. In this case, the partition switch has been successful, and the electronic device will respond to the PMIC watchdog interrupt and perform a power-off restart.

[0092] Continue to refer to Figure 2, Exemplarily, if T1, T2, and T_Sx do not satisfy the relationship T1>T2≥T_Sx, for example, T1<T2<T_Sx, it can be determined that the PMIC watchdog interrupt ( Figure 2 Sx_reset in) has not occurred currently, and since T1<T2, it indicates that the partition switching operation has been completed, that is, the above steps 1 to 3 have all been executed. In this case, the partition switching has been successful, and the electronic device will perform a restart automatically triggered after the partition switching.

[0093] Continue to refer to Figure 2 , Exemplarily, if T1, T2, and T_Sx do not satisfy the relationship T1>T2≥T_Sx, for example, T1>T2<T_Sx, it can be determined that the PMIC watchdog interrupt ( Figure 2 Sx_reset in) has not occurred currently. Therefore, the electronic device can continue to perform the partition switching operation.

[0094] It should be understood that the above description is only an example listed for better understanding of the technical solution of this embodiment and does not serve as the only limitation to this embodiment.

[0095] In view of this, the embodiment of the present application provides an interrupt handling method during partition switching, aiming to avoid the processing flow of partition switching being interrupted by the PMIC watchdog, so as to ensure that the electronic device can restart normally.

[0096] To better understand the technical solution provided by the embodiment of the present application, the scenarios that will trigger partition switching are described below first.

[0097] It should be noted that the partition switching mainly occurs during the upgrade process of the operating system. The upgrade process of the electronic device regarding the data storage structure of the virtual AB mode may include Figure 3 the shown Payload Fetch link, Payload Download link, Payload Verify for the first time link, Payload Install link, Payload Verify for the second time link, Slot Switch link, Reboot link, Merge link, rollback link, etc.

[0098] Refer to Figure 3 , Exemplarily, the Payload Fetch link is the first link in the upgrade process. Specifically, in the Payload Fetch link, the electronic device will detect whether there is an available upgrade package in the server.

[0099] Exemplarily, in some possible implementations, the server storing the upgrade package may be, for example, a so-called package-shooting server.

[0100] Exemplarily, in some other possible implementations, the server storing the upgrade package may be, for example, an OTA (Over-the-Air Technology) server.

[0101] It is understandable that the upgrade package stored in the OTA server may be actively obtained from the packet-snapping server, or may be actively sent from the packet-snapping server to the OTA server.

[0102] It should be understood that the above description is merely an example listed for a better understanding of the technical solution of this embodiment, and is not intended to be the sole limitation to this embodiment.

[0103] Continue to see Figure 3 For example, when there is an available upgrade package on the server, such as an upgrade package required for the current electronic device to upgrade the operating system, the second step of the upgrade process, i.e., the download step, will be entered. Specifically, in the download step, the electronic device will download the upgrade package suitable for the electronic device from the corresponding address according to the address information of the upgrade package returned by the server.

[0104] It should be noted that during the process of downloading the upgrade package, a power failure and restart may occur. When this happens, the electronic device can perform breakpoint-resume transmission through the breakpoint record file to ensure the integrity of the content in the downloaded upgrade package.

[0105] Continue to see Figure 3 For example, after the electronic device successfully downloads the upgrade package from the server, it will enter the third stage of the upgrade process, namely the first verification stage. Specifically, in the first verification stage, the electronic device will verify the downloaded upgrade package, for example, through the corresponding signature to ensure the integrity and correctness of the upgrade package.

[0106] Continue to see Figure 3 , exemplarily, after the upgrade package is successfully verified, the fourth step of the upgrade process, namely the installation step, will be entered. Specifically, in the technical solution provided in the embodiment of the present application, since it is aimed at an electronic device with a data storage structure in a virtual AB mode, in the installation step, the electronic device will write the contents of the static partition (Slot) in the upgrade package, the data corresponding to each sub-partition, into the current backup partition, into the corresponding sub-partition in SlotB, and temporarily write the data corresponding to each sub-partition in the dynamic partition (Super) into the corresponding copy-on-write (cow) file created in the user data partition (Userdata).

[0107] It should be understood that in this step, the upgrade package is only written into the backup partition and the user data partition to create the COW file, and the operating system is still running in the active partition, so the upgrade of the operating system has not been completed.

[0108] Continue to see Figure 3 For example, after the electronic device writes the data in the upgrade package to the corresponding partition (backup partition and COW file), the upgrade process will enter the fifth link, namely the second verification link. Specifically, in the second verification link, the electronic device will verify the content written into each partition to ensure the integrity and correctness of the content read from the upgrade package and written into the corresponding partition.

[0109] Continue to see Figure 3 For example, if the second verification is successful, the sixth step of the upgrade process, i.e., the partition switching step, will be entered. For specific operations performed in the partition switching step, please refer to steps 1 to 3 involved in the partition information exchange process described in the above embodiment, which will not be repeated here.

[0110] Continue to see Figure 3 , exemplarily, after completing steps 1 to 3 in the above embodiment, the partition switching is completed, and the upgrade process will enter the seventh link, that is, the restart link. Specifically, when the electronic device triggers a restart, if it can be turned on normally, it indicates that the electronic device has restarted successfully. In this case, the electronic device will execute the Merge link, that is, perform a Merge operation.

[0111] It should be noted that the so-called Merge operation is the process of upgrading the upgrade file of Super in Userdata, that is, temporarily writing the COW file of Userdata during the installation process, to the corresponding sub-partition in Super.

[0112] Continue to see Figure 3 For example, when the electronic device triggers a restart, if the electronic device cannot start normally, a rollback process will be performed in some possible implementations. Specifically, in the rollback process, the electronic device will switch partitions again, that is, switch back to the Slot where the upgrade file for the static partition in the upgrade package is not written, such as SlotA.

[0113] It should be understood that the above description is merely an example listed for a better understanding of the technical solution of this embodiment, and is not intended to be the sole limitation to this embodiment.

[0114] Therefore, through the description of each link involved in the upgrade process of the electronic device with the data storage structure of the virtual AB mode, it can be known that in the entire upgrade process, the links involving partition switching include: Figure 3That is, the technical solution provided by the embodiment of the present application occurs in Figure 3 The switching and rollback steps are shown.

[0115] In addition, in order to better understand the technical solution provided by the embodiments of the present application, before describing the technical solution of the embodiments of the present application, the hardware structure of the electronic device to which the embodiments of the present application are applicable is first described in conjunction with the accompanying drawings.

[0116] It should be noted that since the PMIC watchdog interrupt is a timer interrupt and is triggered when the user long presses the Power button, or long presses the Power button and other mechanical buttons (such as the volume up / down button) for a certain period of time, the technical solution provided in the embodiment of the present application is applicable to electronic devices that have mechanical buttons such as the Power button and the volume up / down button that can trigger the PMIC watchdog interrupt, such as mobile phones, tablet computers, PCs, etc., which will not be listed one by one this time, and this application does not limit this.

[0117] See also Figure 4 The electronic device 100 may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.

[0118] Exemplarily, the audio module 170 may include a speaker 170A, a receiver 170B, a microphone 170C, an earphone jack 170D, and the like.

[0119] Exemplarily, the sensor module 180 may include a pressure sensor, a gyro sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, and the like.

[0120] Exemplarily, the processor (CPU) 110 may include one or more processing units, for example: the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc.

[0121] It is understandable that, in a specific implementation, different processing units may be independent devices or may be integrated into one or more processors.

[0122] In addition, it should be noted that the controller in the processor 110 may be the nerve center and command center of the electronic device 100. In practical applications, the controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0123] In addition, it should be noted that a memory (internal memory) may be provided in the processor 110 for storing instructions and data. In some implementations, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or circulated. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0124] Continue to see Figure 4 Exemplarily, the charging management module 140 is used to receive charging input from a charger, where the charger can be a wireless charger or a wired charger.

[0125] Continue to see Figure 4Exemplarily, the power management module 141 (i.e., the power management integrated circuit PMIC mentioned above) is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and provides power for the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other implementations, the power management module 141 can also be set in the processor 110. In other implementations, the power management module 141 and the charging management module 140 can also be set in the same device.

[0126] Specifically in the technical solution provided in the embodiment of the present application, a hardware watchdog is integrated in the power management module, which can trigger a PMIC watchdog interrupt when the user presses the button 190 for a long time, and then send a reset signal to the processor 110, such as sending the reset signal to the processor 110 through the RESET pin, so that the processor 110 can respond to the button pressing operation made by the user and trigger the electronic device 100 to power off and restart.

[0127] Continue to see Figure 4 , exemplarily, the wireless communication function of the electronic device 100 can be implemented through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor.

[0128] It should be noted that antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other implementations, the antenna can be used in combination with a tuning switch.

[0129] Continue to see Figure 4, exemplarily, the mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some implementations, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some implementations, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.

[0130] Continue to see Figure 4 Exemplarily, the wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of the signal, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0131] Specifically, in the technical solution provided in the embodiment of the present application, a prerequisite for triggering the electronic device 100 to exchange partition information is that the electronic device 100 has upgraded the operating system. Regarding the upgrade package required during the operating system upgrade process, the electronic device 100 can communicate with the cloud server (brand package server, OTA server, etc.) through the mobile communication module 150 or the wireless communication module 160 to obtain the upgrade package or cold patch package of the operating system.

[0132] Continue to see Figure 4Exemplarily, the display screen 194 is used to display images, videos, etc. In some implementations, the electronic device 100 may include 1 or N display screens 194 , where N is a positive integer greater than 1.

[0133] Continue to see Figure 4 , exemplarily, the camera 193 is used to capture still images or videos. In some implementations, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.

[0134] Continue to see Figure 4 Exemplarily, the external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, files such as music and videos are stored in the external memory card.

[0135] Continue to see Figure 4 Exemplarily, the internal memory 121 may be used to store computer executable program codes, wherein the executable program codes include instructions.

[0136] Specifically, in the technical solution provided in the embodiment of the present application, the relevant instructions involved in the startup of the electronic device 100, the operating system upgrade process, and the partition information interaction process can be pre-stored in the internal memory 121. During the startup process of the electronic device 100, the first bootloader will execute the instructions stored in the internal memory 121, so that the electronic device 100 can execute the interrupt processing method in the partition switching process provided in the embodiment of the present application.

[0137] In addition, it should be noted that, in a specific implementation, the internal memory 121 may include a program storage area and a data storage area. For the internal memory 121 of the data storage structure of the virtual AB mode, the program storage area is Figure 1A and Figure 1B Common, SlotA, SlotB and Super shown in; the storage data area is Figure 1A and Figure 1B Userdata shown in .

[0138] Exemplarily, in some possible implementations, the internal memory 121 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0139] It should be noted that, in practical applications, the partition deployment information of the internal memory 121 in the electronic device 100 can be described by the partition table shown in Table 1.

[0140] Table 1 Partition table

[0141]

[0142]

[0143] In this way, the starting address and size of each partition are defined through the partition table, so that the corresponding partition size can be adjusted as needed for different hardware.

[0144] That is to say, in actual applications, the partitions recorded in the partition table can be divided and set according to actual business needs.

[0145] In addition, it should be noted that, except for the specially reserved partitions, basically each partition has its corresponding image file. The image file is compiled by software code, which integrates various functional files and configurations related to the startup or operation process of the electronic device. Without the image file, the electronic device cannot run. A complete system version includes many images, partition table image gpt.img, startup related images (xloader.img, boot.img), system image super.img (integrated with the Android system core) and user data image userdata.img (used to store user data), etc.

[0146] In addition, it should be noted that Figure 1A and Figure 1B The distribution of each partition in the internal memory 121 of the data storage structure of the virtual AB mode shown in FIG. Figure 1A and Figure 1B As shown, in actual applications, the location of each partition is determined according to the allocated start address and end address.

[0147] It should be understood that the above description is merely an example listed for a better understanding of the technical solution of this embodiment, and is not intended to be the sole limitation to this embodiment.

[0148] Continue to see Figure 4 Exemplarily, the buttons 190 include a power button (Power button), volume buttons (volume up button, volume down button), etc.

[0149] Specifically, in the technical solution provided in the embodiment of the present application, the key 190 of the electronic device 100 is a mechanical key. The electronic device 100 can receive key input and generate signals related to user settings and function control of the electronic device 100.

[0150] Continue to see Figure 4 For example, the motor 191 can generate a vibration prompt. The motor 191 can be used for an incoming call vibration prompt or for touch vibration feedback.

[0151] Continue to see Figure 4 , exemplarily, the indicator 192 can be an indicator light, which can be used to indicate the charging status, power change, and can also be used to indicate messages, missed calls, notifications, etc.

[0152] The hardware structure of the electronic device 100 is introduced here. It should be understood that: Figure 4 The electronic device 100 shown is only an example. In a specific implementation, the electronic device 100 may have more or fewer components than those shown in the figure, may combine two or more components, or may have a different component configuration. Figure 4 The various components shown in the EMBODIMENTS 2000 may be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application specific integrated circuits.

[0153] In order to better understand the relationship between the Bootloader and various hardware that implement the technical solution provided in the embodiment of the present application, the software structure of the electronic device 100 is described below.

[0154] Before describing the software structure of the electronic device, the architecture that can be adopted by the software system of the electronic device is described first.

[0155] Specifically, in practical applications, the software system of the electronic device may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture.

[0156] In addition, it is understandable that the software systems currently used by mainstream electronic devices include but are not limited to Windows systems, Android systems, and iOS systems. For ease of explanation, the embodiment of the present application takes the Android system of layered architecture as an example to exemplify the software structure of the electronic device.

[0157] In addition, it should be understood that the subsequent interrupt processing method in the partition switching process provided in the embodiment of the present application is also applicable to other systems in specific implementation.

[0158] See also Figure 5 , which is a software structure block diagram of the electronic device according to an embodiment of the present application.

[0159] like Figure 5As shown, the layered architecture of the electronic device divides the software into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces. In some implementations, the Android system can be divided into six layers, from top to bottom, the application layer / application layer (Applications) belonging to the application part, the framework layer / application framework layer (Application Framework, FWK) belonging to the core part, the runtime (Runtime) and the system library, the hardware abstraction layer (HAL), the Linux kernel (Linux Kernel) layer and the boot loader layer (Bootloader) belonging to the bottom part.

[0160] The application layer can include a series of application packages. Figure 5 As shown, the application package may include camera, game, video, live broadcast and other applications, which are not listed here one by one and are not limited in this application.

[0161] The framework layer can provide application programming interfaces (APIs) and programming frameworks for applications in the application layer. In some implementations, these programming interfaces and programming frameworks can be described as functions. Figure 5 As shown, the framework layer may include functions such as content provider, window manager, resource manager, phone manager, etc., which are not listed here one by one and are not limited in this application.

[0162] It should be noted that the window manager located in the framework layer is used to manage window programs. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc.

[0163] In addition, it should be noted that the content provider located in the framework layer is used to store and obtain data and make the data accessible to the application. The data may include video, images, audio, dialed and received calls, browsing history and bookmarks, phone book, etc., which are not listed here one by one and are not limited by this application.

[0164] In addition, it should be noted that the resource manager located in the framework layer is used to provide various resources for the application, such as localized strings, icons, pictures, layout files, video files, etc., which are not listed here one by one and this application does not impose any restrictions on this.

[0165] In addition, it should be noted that the telephone manager located in the application framework layer is used to provide communication functions of the electronic device, such as management of call status (including connection, disconnection, etc.).

[0166] Continue to see Figure 5 , exemplarily, the runtime, specifically the Android runtime (Android Runtime) may include a core library and a virtual machine, which is mainly responsible for the scheduling and management of the Android system.

[0167] The core library consists of two parts: one is the function that the Java language needs to call, and the other is the Android core library. The application layer and the framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the framework layer as binary files. The virtual machine is used to perform object life cycle management, stack management, thread management, security and exception management, and garbage collection.

[0168] Continue to see Figure 5 Exemplarily, the system library may include multiple functional modules, such as a surface manager, a media library, a three-dimensional (3D) graphics processing library (such as OpenGL ES), a two-dimensional (2D) graphics engine (such as SGL), etc.

[0169] The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications. The media library supports multiple commonly used audio and video format playback and recording, as well as static image files. The media library can support multiple audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PnG, etc. The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing.

[0170] In addition, it can be understood that the 2D graphics engine mentioned above is a drawing engine for 2D drawing.

[0171] Continue to see Figure 5 For example, the HAL layer is an interface layer between the operating system kernel (kernel layer) and the hardware circuit. Its purpose is to isolate the FWK from the kernel so that Android does not rely too much on the kernel, so that the development of FWK can be carried out without considering the driver.

[0172] Continue to see Figure 5 For example, the HAL layer may include various interfaces, such as audio and video interface, GPS interface, call interface, WiFi interface, etc., which are not listed here one by one and are not limited in this application.

[0173] Continue to see Figure 5, exemplary, the kernel layer in the Android system is a layer between hardware and software. The kernel layer may include various processes / threads, power management, various drivers, such as WiFi drivers, etc.

[0174] Continue to see Figure 5 For example, the Bootloader in the Android system is the first program that runs after the electronic device is powered on, before the operating system kernel runs. Through the Bootloader, hardware devices can be initialized and memory space mapping can be established. After completing the initialization of the CPU and related hardware, the Bootloader will load the operating system image or solidified embedded application into the memory, and then jump to the space where the operating system is located to start the operating system.

[0175] Continue to see Figure 5 , for example, because the data storage structure of the internal memory of the electronic device adopts different modes, the programs integrated in the Bootloader will also be different. Specifically, in the technical solution provided in the embodiment of the present application, when the data storage structure is in virtual AB mode, considering that the virtual AB mode involves partition switching and partition startup. Therefore, the Bootloader may include functional functions / functional modules for implementing partition switching and partition startup, such as Figure 5 The AB partition switching module and the AB partition starting module are shown in FIG.

[0176] It is understandable that in some possible implementations, the AB partition switching module and the AB partition starting module can be integrated into one functional function / module, and the present application does not impose any limitation on this.

[0177] For details about the specific logic of the interrupt handling method in the partition switching process provided by the embodiment of the present application implemented by the Bootloader, see the following Figure 5 The embodiments shown will not be described in detail here.

[0178] This is the end of the introduction to the software structure of electronic devices. It can be understood that: Figure 5 The layers in the software structure shown and the components contained in each layer do not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer layers than shown in the figure, and each layer may include more or fewer components, which is not limited by the present application.

[0179] Based on the above hardware and software structures, the following Figure 6 , the interrupt handling method in the partition switching process provided in the embodiment of the present application is specifically described.

[0180] like Figure 6As shown, when partition switching is triggered, the Bootloader in the electronic device will exchange partition information according to the above steps 1 to 3.

[0181] For example, for the sake of convenience of description, this embodiment takes the time T1 taken for the electronic device to complete the partition switching as an example.

[0182] Exemplarily, the partition switching time can be determined by, for example, obtaining the timestamp corresponding to the last failed startup of the active partition and the timestamp of switching to the backup partition through the getrtctime() function.

[0183] Continue to see Figure 6 For example, during the partition switching process of the electronic device, if the user presses a mechanical button of the electronic device, such as the Power button (or the Power button and the volume up / down button), the electronic device receives the pressing operation and can record the length of time the user presses the button, such as T2.

[0184] Continue to see Figure 6 For example, after obtaining the duration T2 of the user pressing the key, the electronic device can further determine the relationship between T1, T2 and T_Sx.

[0185] Among them, T_Sx is the time threshold for triggering the PMIC watchdog interrupt, that is, when the user presses the button for a time greater than or equal to the time threshold, a PMIC watchdog interrupt will occur, thereby interrupting the current operation, such as the partition switching operation, and triggering the electronic device to power off and restart.

[0186] Continue to see Figure 6 , for example, if T1, T2 and T_Sx satisfy the relationship T1>T2≥T_Sx, it can be determined that a PMIC watchdog interrupt has occurred ( Figure 6 However, since T1>T2, the operation currently being executed on the surface is not yet completed.

[0187] It should be noted that when a PMIC watchdog interrupt occurs, the currently executed operation may not be a partition switching operation. For non-partition switching operations, the PMIC watchdog interrupt does not cause the electronic device to be unable to restart. Therefore, when it is determined that a PMIC watchdog interrupt has occurred, the Bootloader can traverse the current program stack / SP stack information, and then determine whether the currently executed operation is a partition switching operation based on the current program stack / SP stack information.

[0188] Understandably, in the ARM (Advanced RISC Machines) architecture, before any interrupt processing, the running status information of the interrupted program is saved.

[0189] Exemplarily, in a possible implementation, the running status information of the interrupted program may include, for example, data, code, registers and stack information of the current program, wherein registers may include rax, rbx, rcx, rdx, rsi, rdi, rbp, rsp, r8, r9, r10, r11, r12, r13, r14, r15, etc.

[0190] Specifically in this embodiment, the three registers r13, r14 and r15 are mainly concerned. Among them, the r13 register is a register for storing the stack information of the currently interrupted program; the r14 register is the link register (LR) register; and the r15 register (also called the program counter (PC) register) is a register for storing the interrupted program instructions.

[0191] Regarding the LR register, it has two special uses in the ARM architecture. One is to save the subroutine return address; the other is that when an exception occurs, the value saved in the LR register is equal to the value of PC when the exception occurs minus 4 (or minus 2). Therefore, in various exception modes, the value of the LR register can be used to return to the corresponding position before the exception occurs, and then continue to execute the interrupted program.

[0192] It can be understood that the PC value mentioned above is the instruction counter value (Program Countere). Specifically, in order to ensure that the program (understood as a process in the operating system) can be executed continuously, the CPU must have some means to determine the address of the next instruction. The program counter plays this role, so it is usually called the instruction counter. Before the program starts executing, its starting address, that is, the address of the memory unit where an instruction of the program is located, must be sent to the PC, so the content of the program counter (PC) is the address of the first instruction extracted from the memory. When executing instructions, the CPU will automatically modify the content of the PC, that is, each time an instruction is executed, the PC increases by an amount, which is equal to the number of bytes contained in the instruction, so that it always maintains the address of the next instruction to be executed. Since most instructions are executed in sequence, the modification process is usually just a simple addition of 1 to the PC. The number of bits of the PC is generally the same as the number of bits of the memory address register MAR.

[0193] For example, if it is determined that the currently executed operation is not a partition switching operation by traversing the current program stack / SP stack information, the electronic device can directly execute the PMIC watchdog interrupt ( Figure 6Sx_reset in the command output) to restart or shut down the device after power failure.

[0194] For example, if it is determined that the currently executed operation is a partition switching operation by traversing the current program stack / SP stack information, since T1>T2, it indicates that the partition switching operation has not been completed, that is, the above step 3 has not been completed. In order to prevent the partition switching operation from being interrupted by the PMIC watchdog, in the technical solution provided in this embodiment, the Bootloader will directly exit Sx_reset, so that the partition switching operation can continue to be executed until the partition switching is completed.

[0195] Exemplarily, in some possible implementations, the following pseudo code may be integrated into the Bootloader to implement the interrupt handling method in the partition switching process provided in this embodiment.

[0196] Pseudo code integrated in the Bootloader:

[0197]

[0198] It should be understood that the above description is merely an example listed for a better understanding of the technical solution of this embodiment, and is not intended to be the sole limitation to this embodiment.

[0199] In addition, it should be noted that the power-off restart triggered by the PMIC watchdog interrupt and the automatic restart after the partition switch are two different forms of restart. In the Android system, different flags are used to indicate the restart caused by these two reasons.

[0200] For example, for a power-off restart triggered by a PMIC watchdog interrupt, after the electronic device restarts, the restart reason recorded in the stack information is usually XVDD, that is, sreason str=XVDD; for a restart triggered after a partition switch is completed, after the electronic device restarts, the restart reason recorded in the stack information is usually SWReset, that is, sreason str=SWReset.

[0201] That is to say, after the electronic device receives the user's button pressing operation, triggering the PMIC watchdog interrupt, and the electronic device restarts, it can be determined by checking the restart reason recorded in the stack information whether this restart is caused by a power-off restart triggered by the PMICwatchdog interrupt, or a restart automatically triggered after the PMIC watchdog interrupt is blocked and the partition switching operation is completed.

[0202] Continue to see Figure 6, Exemplarily, if T1, T2, and T_Sx do not satisfy the relationship T1>T2≥T_Sx, for example, T1<T2≥T_Sx, in this case, it can be determined that a PMIC watchdog interrupt has occurred (Sx_reset in Figure 6 ). However, since T1<T2, it indicates that the partition switching operation has been completed, that is, the above steps 1 to 3 have all been executed. In this case, the partition switching has been successful, and the electronic device will respond to the PMIC watchdog interrupt and perform a power-off restart.

[0203] Continue to refer to Figure 6 , Exemplarily, if T1, T2, and T_Sx do not satisfy the relationship T1>T2≥T_Sx, for example, T1<T2<T_Sx, in this case, it can be determined that a PMIC watchdog interrupt has not occurred (Sx_reset in Figure 6 ). And since T1<T2, it indicates that the partition switching operation has been completed, that is, the above steps 1 to 3 have all been executed. In this case, the partition switching has been successful, and the electronic device will perform a restart automatically triggered after the partition switching.

[0204] Continue to refer to Figure 6 , Exemplarily, if T1, T2, and T_Sx do not satisfy the relationship T1>T2≥T_Sx, for example, T1>T2<T_Sx, in this case, it can be determined that a PMIC watchdog interrupt has not occurred (Sx_reset in Figure 6 ). Therefore, the electronic device can continue to perform the partition switching operation.

[0205] It should be understood that the above description is only an example listed for better understanding the technical solution of this embodiment and does not serve as the sole limitation of this embodiment.

[0206] Thus, when a PMIC watchdog interrupt occurs, by determining whether the currently executed operation is a partition switching operation, when it is determined that the currently executed operation is a partition switching operation, instead of performing the power-off restart operation or shutdown operation that the PMIC watchdog interrupt itself is supposed to perform, the partition switching operation is continued, thereby effectively avoiding the partition switching processing flow being interrupted by the PMIC watchdog interrupt, and further ensuring that the electronic device can complete the partition switching and restart normally.

[0207] In addition, it is understandable that, in order to implement the above functions, the electronic device includes hardware and / or software modules corresponding to the execution of each function. In combination with the algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or 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 combination with the embodiments, but such implementation should not be considered to be beyond the scope of the present application.

[0208] In addition, it should be noted that the interrupt handling method in the partition switching process provided by the above embodiments implemented by the electronic device in the actual application scenario can also be executed by a chip system included in the electronic device, wherein the chip system may include a processor. The chip system can be coupled to the memory so that the chip system calls the computer program stored in the memory when it is running to implement the steps executed by the above electronic device. The processor in the chip system can be an application processor or a processor other than an application processor.

[0209] In addition, an embodiment of the present application also provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the above-mentioned related method steps to implement the interrupt processing method in the partition switching process in the above-mentioned embodiment.

[0210] In addition, an embodiment of the present application further provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes the above-mentioned related steps to implement the interrupt processing method in the partition switching process in the above-mentioned embodiment.

[0211] In addition, an embodiment of the present application also provides a chip (which may also be a component or module), which may include one or more processing circuits and one or more transceiver pins; wherein the transceiver pins and the processing circuit communicate with each other through an internal connection path, and the processing circuit executes the above-mentioned related method steps to implement the interrupt processing method in the partition switching process in the above-mentioned embodiment, so as to control the receiving pin to receive the signal, so as to control the sending pin to send the signal.

[0212] In addition, it can be seen from the above description that the electronic device, computer-readable storage medium, computer program product or chip provided in the embodiments of the present application are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above, and will not be repeated here.

[0213] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for handling interruptions during partition switching, characterized in that: Applied to electronic equipment, the method comprises: When receiving a user's pressing operation on a power-off key, recording the pressing time of the power-off key by the user, wherein the power-off key is located on a side frame of the electronic device; When the pressing duration is greater than or equal to a preset duration threshold, interrupting the currently executed operation; When there is an interrupted operation currently, determining whether the currently interrupted operation is a partition switching operation; When the currently interrupted operation is the partition switching operation, resuming the partition switching operation; After the partition switching operation is completed, restart the electronic device.

2. The method according to claim 1, characterized in that After the partition switching operation is completed, after restarting the electronic device, the method further includes: Get the restart reason identifier from the current stack information; The restart reason identifier is a first identifier, and the first identifier indicates that the current restart of the electronic device is a restart triggered by a partition switch.

3. The method according to claim 1, characterized in that The method further comprises: When there is no interrupted operation currently, in response to the pressing operation, the electronic device is restarted.

4. The method according to claim 1, characterized in that: The method further comprises: When the currently interrupted operation is not the partition switching operation, in response to the pressing operation, the electronic device is restarted.

5. The method according to claim 3 or 4, characterized in that: After restarting the electronic device in response to the pressing operation, the method further includes: Get the restart reason identifier from the current stack information; The restart reason identifier is a second identifier, and the second identifier indicates that the current restart of the electronic device is a power-off restart triggered by a pressing operation.

6. The method according to any one of claims 1 to 4, characterized in that: The determining whether the currently interrupted operation is a partition switching operation includes: Get the running status information of the program that is executing the currently interrupted operation; It is determined, according to the running status information, whether the currently interrupted operation is the partition switching operation.

7. The method according to claim 6, wherein determining whether the currently interrupted operation is the partition switching operation according to the running status information comprises: Determine the instruction counter PC value of the program according to the running status information; When the PC value is in a PC value interval corresponding to the program that performs the partition switching operation, it is determined that the currently interrupted operation is the partition switching operation.

8. The method according to any one of claims 1 to 4, characterized in that: The memory of the electronic device includes a basic partition, a first static partition, a second static partition, a dynamic partition and a user data partition; Wherein, when the first static partition is an active partition, the second static partition is a backup partition; Each sub-partition included in the active partition has a valid and unique identifier, and each sub-partition included in the backup partition shares an invalid identifier.

9. The method according to claim 8, characterized in that The partition switching operation includes: Modify the identification number of each sub-partition in the backup partition recorded in the GPT partition table read into the memory to the identification number of the corresponding sub-partition in the active partition, and modify the identification number of each sub-partition in the active partition to the invalid identification number; Modify the boot order recorded in the basic partition from the first static partition to the second static partition; According to the identification identifier of each sub-partition in the backup partition and the active partition recorded in the GPT partition table in the memory, the identification identifier of each sub-partition in the backup partition and the active partition in the memory is updated.

10. The method according to claim 9, characterized in that The partition switching operation is completed, including: The step of updating the identification identifier of each sub-partition in the backup partition and the active partition in the memory is completed according to the identification identifier of each sub-partition in the backup partition and the active partition recorded in the GPT partition table in the memory.

11. An electronic device, characterized in that: The electronic device comprises: a memory and a processor, wherein the memory and the processor are coupled; the memory stores program instructions, and when the program instructions are executed by the processor, the electronic device executes the interrupt processing method in the partition switching process as described in any one of claims 1 to 10.

12. A computer-readable storage medium, characterized in that: It comprises a computer program, and when the computer program is run on an electronic device, the electronic device executes the interrupt processing method in the partition switching process as claimed in any one of claims 1 to 10.