CN117707630A - Interrupt processing method, device and storage medium in partition switching process - Google Patents

Interrupt processing method, device and storage medium in partition switching process Download PDF

Info

Publication number
CN117707630A
CN117707630A CN202311024567.8A CN202311024567A CN117707630A CN 117707630 A CN117707630 A CN 117707630A CN 202311024567 A CN202311024567 A CN 202311024567A CN 117707630 A CN117707630 A CN 117707630A
Authority
CN
China
Prior art keywords
partition
electronic device
interrupted
currently
switching
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311024567.8A
Other languages
Chinese (zh)
Inventor
石磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Honor Device Co Ltd
Original Assignee
Honor Device Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Honor Device Co Ltd filed Critical Honor Device Co Ltd
Priority to CN202311024567.8A priority Critical patent/CN117707630A/en
Publication of CN117707630A publication Critical patent/CN117707630A/en
Pending legal-status Critical Current

Links

Landscapes

  • Stored Programmes (AREA)

Abstract

The application provides an interrupt processing method, device and storage medium in a partition switching process. In the method, when the electronic equipment receives the pressing operation of a shutdown key by a user, whether PMIC watch interrupt occurs or not is further determined by determining whether the current pressing time length is greater than or equal to a preset time threshold. When the PMIC watchdog interrupt occurs, whether the current interrupted operation is the partition switching operation or not is determined, and when the current interrupted operation is the partition switching operation is determined, the interrupted partition operation is recovered, and the operation of restarting the electronic equipment is not started in response to the power failure corresponding to the PMIC watchdog interrupt, so that the process flow of the partition switching is effectively prevented from being interrupted by the PMIC watchdog, and the electronic equipment is ensured to complete the partition switching and restart normally.

Description

Interrupt processing method, device and storage medium in partition switching process
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method, an apparatus, and a storage medium for processing interrupts in a partition switching process.
Background
For electronic devices with data storage structures in virtual AB mode, the operating system may be started by different partitions. That is, the operating system may be run by partition switching from different partitions.
However, currently some chip platforms assign globally unique identifiers (Globally Unique Identifier, GUID) to all of the backup partitions to be identical and invalid. This results in the processor not being able to boot the operating system directly from the GUID of the backup partition during the partition switch. Thus, an exchange of partition information, such as a handover GUID, is required.
However, in the process of exchanging partition information, it may happen that a user presses a Power key for a long time, so that a watchdog (PMIC watch dog) in the Power management integrated circuit outputs a reset signal, and triggers the electronic device to Power down and restart, so that the exchange of partition information is interrupted, and the electronic device cannot be started from the backup partition.
Disclosure of Invention
In order to solve the technical problems, the application provides an interrupt processing method, device and storage medium in the partition switching process, which aim to prevent the processing flow of partition switching from being interrupted by PMIC (pulse mode controller) watchdog, and further ensure that the electronic device can be restarted normally.
In a first aspect, the present application provides a method for processing an interrupt in a partition switching process. The method is applied to the electronic equipment and comprises the following steps: when the pressing operation of the user on the shutdown key is received, the pressing time of the user on the shutdown key is recorded, and the shutdown key is positioned on a side frame of the electronic equipment; when the pressing time length is greater than or equal to a preset time length threshold value, interrupting the operation currently being executed; when the interrupted operation exists currently, determining whether the operation which is interrupted currently is a partition switching operation or not; restoring the partition switching operation when the current interrupted operation is the partition switching operation; after the partition switching operation is completed, the electronic device is restarted.
The Power key is, for example, a Power key, or a combination of the Power key and other mechanical keys, such as a volume up/down key.
The preset duration threshold is, for example, a time that triggers the electronic device to generate a PMIC watchdog interrupt.
When the pressing time of the shutdown key is greater than or equal to a preset time threshold, the electronic device will generate PMIC watch.
The partition switching operation is resumed, that is, the power-down restarting executed by the PMIC watchdog interrupt is not triggered in response to the pressing operation of the shutdown key, but the incomplete partition switching operation is continuously completed, and finally, after the partition switching is completed, the electronic equipment is automatically triggered to restart from the switched partition.
When the electronic equipment receives the pressing operation of the shutdown key by the user, whether the PMIC watchdog interrupt occurs currently or not is determined by determining whether the current pressing time length is greater than or equal to a preset time threshold. When the PMIC watchdog interrupt occurs, whether the current interrupted operation is the partition switching operation or not is determined, and when the current interrupted operation is the partition switching operation is determined, the interrupted partition operation is recovered, and the operation of restarting the electronic equipment is not started in response to the power failure corresponding to the PMIC watchdog interrupt, so that the process flow of the partition switching is effectively prevented from being interrupted by the PMIC watchdog, and the electronic equipment is ensured to complete the partition switching and restart normally.
According to a first aspect, after restarting the electronic device after the partition switching operation is completed, the method further comprises: acquiring 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 equipment is the restart triggered after partition switching.
Wherein the first identifier, e.g. SWRest.
Therefore, when the restart reason obtained after restarting the electronic equipment is SWRest, the electronic equipment can be determined to be automatically triggered after the partition switching operation is completed, and the electronic equipment is not powered down and restarted by PMIC (pulse interrupt). That is, the partition switch process is not interrupted by PMIC watchdog, resulting in no power on.
According to the first aspect, or any implementation manner of the first aspect, the method further includes: when there is no interrupted operation at present, the electronic apparatus is restarted in response to the pressing operation.
Where there is currently no interrupted operation, e.g., no operation is currently performed or an operation has been performed.
For operations that have already been performed to completion, partition switch operations may be included. For this case, the automatically triggered restart after partition switching may be prevented by the PMIC patchdog interrupt, i.e., the subsequent restart of the electronic device is a power-down restart.
According to the first aspect, or any implementation manner of the first aspect, the method further includes: when the operation that is currently interrupted is not the partition switching operation, the electronic device is restarted in response to the pressing operation.
Since partition switching operation involves the switching of GUID, and GUID switching is interrupted, an exception may occur between the GUID recorded in the GPT partition table and the GUID of the actual physical partition, and thus the electronic device may not be started according to the starting sequence recorded in the base partition (recorded in the risc sub-partition), which finally results in the failure of starting up the electronic device.
Thus, the electronic device may perform a power-down restart when the currently interrupted operation is not a partition switch operation.
According to the first aspect, or any implementation manner of the first aspect, after restarting the electronic device in response to the pressing operation, the method further includes: acquiring a restart reason identifier from the current stack information; the restarting reason identifier is a second identifier, and the second identifier indicates that the restarting of the electronic equipment is a power-down restarting triggered by the pressing operation.
Wherein the second identifier, e.g., XVDD.
Therefore, when the restart reason mark acquired after the electronic equipment is restarted is XVDD, the electronic equipment can be determined to be the power-down restart triggered by PMIC watch dog interrupt.
According to a first aspect, or any implementation manner of the first aspect, determining whether the operation that is currently interrupted is a partition switch operation includes: acquiring running state information of a program executing a currently interrupted operation; and determining whether the operation which is interrupted currently is a partition switching operation or not according to the running state information.
According to a first aspect, or any implementation manner of the first aspect, determining whether the operation that is currently interrupted is a partition switch operation includes: determining the PC value of an instruction counter of the program according to the running state information; and when the PC value is in a PC value interval corresponding to a program for executing the partition switching operation, determining that the operation which is interrupted currently is the partition switching operation.
According to a first aspect, or any implementation manner of the first aspect, the memory of the electronic device includes a base 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 identity, and each sub-partition included in the backup partition shares an invalid identity.
Wherein an identity identifier, such as a GUID.
The base partition may be denoted as Common, the first static partition may be denoted as SlotA, the second static partition may be denoted as SlotB, the dynamic partition may be denoted as Super, and the user data partition may be denoted as Userdata.
For the data storage structure described above, it can be understood as a virtual AB mode.
According to a first aspect, or any implementation manner of the first aspect, the operation of partition switching includes: the identification mark of each sub-partition in the backup partition recorded in the GPT partition table of the read memory is modified to be the identification mark of the corresponding sub-partition in the active partition, and the identification mark of each sub-partition in the active partition is modified to be an invalid identification mark; modifying the starting sequence recorded in the basic partition from the first static partition to the second static partition; and updating the identity identifiers of each sub-partition in the backup partition and the active partition in the memory according to the identity identifiers of each sub-partition in the backup partition and the active partition recorded in the GPT partition table in the memory.
According to a first aspect, or any implementation manner of the first aspect, the partition switch operation is completed, including: and the step of updating the identity identifiers of each sub-partition in the backup partition and the active partition in the memory according to the identity identifiers of each sub-partition in the backup partition and the active partition recorded in the GPT partition table in the memory is completed.
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 coupled; the memory stores program instructions that, when executed by the processor, cause the electronic device to perform the instructions of the first aspect or of the method in any possible implementation of the first aspect.
Any implementation manner of the second aspect and the second aspect corresponds to any implementation manner of the first aspect and the first aspect, respectively. The technical effects corresponding to the second aspect and any implementation manner of the second aspect may be referred to the technical effects corresponding to the first aspect and any implementation manner of the first aspect, which are not described herein.
In a third aspect, the present application provides a computer readable medium for storing a computer program comprising instructions for performing the method of the first aspect or any possible implementation of the first aspect.
Any implementation manner of the third aspect and any implementation manner of the third aspect corresponds to any implementation manner of the first aspect and any implementation manner of the first aspect, respectively. The technical effects corresponding to the third aspect and any implementation manner of the third aspect may be referred to the technical effects corresponding to the first aspect and any implementation manner of the first aspect, which are not described herein.
In a fourth aspect, the present application provides a computer program comprising instructions for performing the method of the first aspect or any possible implementation of the first aspect.
Any implementation manner of the fourth aspect and any implementation manner of the fourth aspect corresponds to any implementation manner of the first aspect and any implementation manner of the first aspect, respectively. Technical effects corresponding to any implementation manner of the fourth aspect may be referred to the technical effects corresponding to any implementation manner of the first aspect, and are not described herein.
In a fifth aspect, the present application provides a chip comprising processing circuitry, a transceiver pin. Wherein the transceiver pin and the processing circuit communicate with each other via an internal connection path, the processing circuit performing the method of the first aspect or any one of the possible implementation manners of the first aspect to control the receiving pin to receive signals and to control the transmitting pin to transmit signals.
Any implementation manner of the fifth aspect and any implementation manner of the fifth aspect corresponds to any implementation manner of the first aspect and any implementation manner of the first aspect, respectively. Technical effects corresponding to any implementation manner of the fifth aspect may be referred to the technical effects corresponding to any implementation manner of the first aspect, and are not described herein.
Drawings
FIG. 1A is a schematic diagram illustrating partitioning of internal memory of a data storage structure in virtual AB mode;
FIG. 1B is a schematic diagram illustrating partitioning of internal memory of a virtual AB mode for yet another data storage structure;
FIG. 2 is a flow diagram illustrating an exemplary interruption of a partition switch operation by PMIC watchdog;
FIG. 3 is a schematic diagram illustrating an upgrade flow of an electronic device of a virtual AB mode data storage structure;
fig. 4 is a schematic diagram of a hardware structure of an exemplary electronic device;
FIG. 5 is a schematic diagram of a software architecture of an exemplary electronic device;
fig. 6 is a schematic flow chart of an interrupt processing method in a partition switching process according to an exemplary embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present application.
The term "and/or" is herein merely an association relationship describing an associated object, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone.
The terms first and second and the like in the description and in the claims of embodiments of the present application are used for distinguishing between different objects and not necessarily for describing a particular sequential order of objects. For example, the first target object and the second target object, etc., are used to distinguish between different target objects, and are not used to describe a particular order of target objects.
In the embodiments of the present application, words such as "exemplary" or "such as" are used to mean serving as examples, illustrations, or descriptions. Any embodiment or design described herein as "exemplary" or "for example" should not be construed as preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "such as" is intended to present related concepts in a concrete fashion.
In the description of the embodiments of the present application, unless otherwise indicated, the meaning of "a plurality" means two or more. For example, the plurality of processing units refers to two or more processing units; the plurality of systems means two or more systems.
As more applications become available for electronic devices, the storage space occupied by user data is increasingly required. Currently, in order to ensure the success of system upgrade and reduce the occupation of system data to storage space as much as possible, so as to leave more storage space for storing user data, electronic devices with data storage structures in Virtual AB mode (Virtual AB) are becoming popular.
It is understood that the storage space in this embodiment refers specifically to the storage space of the internal memory in the electronic device. For internal memory, in one possible implementation, it may be divided into a base partition (subsequently represented by Common), a static partition (subsequently represented by Slot), a dynamic partition (subsequently represented by Super), and a user data partition (subsequently represented by Userdata). Among them, common, slot, super are used to store an operating system, application programs (such as a sound playing function, an image playing function, etc.) required for at least one function, and the like, that is, the above-mentioned system data. Userdata is used to store data created during use of the electronic device (e.g., audio data, phonebook, etc.), etc., namely, the user data described above.
Based on the partition, when the electronic device starts to load the operating system, specifically, system data in Common, slot and Super are sequentially loaded.
In addition, it should be noted that, for the system data stored in the Common, the system data will not be modified when the system is updated, while the system data in the Slot and Super will be updated with the version update iteration. The system data stored in the Slot usually occupies a smaller memory space, and the system data stored in the Super usually occupies a larger memory space.
Based on the characteristics of the partitions, in the data storage structure in the virtual AB mode, the Slot exists as a double partition, and the other partitions exist as single partitions, as shown in fig. 1A.
For electronic devices with data storage structures in virtual AB mode, the operating system may be booted through different partitions, such as SlotA or SlotB in FIG. 1A. And for the data storage structure of the virtual AB mode, after a certain partition fails to be started for a plurality of times, the next starting is supported to be switched to another partition for starting. That is, the operating system may be run by partition switching from different partitions.
For ease of understanding, the following description is presented for a partition switch flow.
It should be noted that, for Slot, a plurality of sub-partitions are included, such as X-loader, boot, dtbo. Each sub-partition stores therein the mirror image required for the electronic device to boot up and other services.
In particular to a data storage structure in virtual AB mode, slotA and SlotB can be understood as a set of partitions with the same name of the two groups of partitions, i.e. SlotA and SlotB include the same sub-partition. For ease of distinction, the child partitions belonging to SlotA may be identified by "_a" and the child partitions belonging to SlotB may be identified by "_b". For example, as shown in FIG. 1B, X-loader, boot, dtbo belonging to SlotA may be denoted as X-loader_a, boot_a, dtbo_a, and X-loader, boot, dtbo belonging to SlotB may be denoted as X-loader_b, boot_b, dtbo_b.
It should be understood that the above description is only an example for better understanding of the technical solution of the present embodiment, and is not to be taken as the only limitation of the present embodiment.
With continued reference to FIG. 1B, slotA and SlotB are backup to each other because the child partitions included in SlotA and SlotB are the same. For ease of description, in some possible implementations, a Slot that is currently in use may be referred to as an active partition (active partition) and a Slot that is not currently in use may be referred to as a backup partition.
Taking the SlotA and SlotB illustrated in fig. 1B as an example, if SlotA is currently being used, slotA is an active partition and SlotB is a backup partition. If SlotB is currently being used, slotB is the active partition and SlotA is the backup partition.
In addition, it should be noted that, when the electronic device is started, common, slot and Super are loaded in sequence. Whereas in the virtual AB mode data storage structure, slot has two partitions, slotA and SlotB. Therefore, when the electronic device is started, the processor (CPU) needs to know from which Slot the start needs to be started, i.e. whether to load Slot a or Slot b after loading the command.
Partition information about the Slot that needs to be started at each start, specifically, the MIsc child partition recorded in the Common partition.
For example, in one possible implementation, a default slave SlotA start may be set. For this case, partition information of the Slot recorded in the misc sub-partition may be Slot a or a. Accordingly, when the default slave SlotB is set to be started, the partition information of the Slot recorded in the MIsc sub-partition may be SlotB or_b.
Taking a scenario that a default is set to start 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 service requirements), partition switching may be automatically triggered, and partition information of Slot in a misc sub-partition is modified from SlotA to SlotB or from_a to_b.
It should be understood that the above description is only an example for better understanding of the technical solution of the present embodiment, and is not to be taken as the only limitation of the present embodiment.
In addition, it should be noted that, due to the different selected startup modes, the sub-partitions in the Slot that may need to be run are also different. Thus, there is one valid and unique GUID for each child partition of the active partition. In this way, in the process of starting the electronic device, the CPU can load the sub-partition corresponding to each GUID in turn according to a group of preset GUIDs.
For backup partitions, illustratively, in some chip platforms, each child partition will be assigned a valid and unique GUID. In this way, when the active partition fails to be started for multiple times, the partition information of the Slot in the MIsc sub-partition is directly modified when the active partition is switched to the backup partition for starting next time.
In other chip platforms (denoted subsequently as A-platforms), however, the GUIDs assigned by all the child partitions in the backup partition are identical and invalid. Therefore, even if the partition information of the Slot in the misc child partition is modified to the backup partition, the CPU cannot be used at all because the GUIDs of all the child partitions in the backup partition are the same and invalid. That is, the CPU cannot directly boot the operating system from the GUID of the backup partition.
In order to enable the electronic equipment adopting the A platform to be started normally from the backup partition after the active partition fails to be started for a plurality of times. In the partition switching process, not only the partition information in the Misc sub-partition needs to be modified, but also the GUID of each sub-partition in the two partitions needs to be switched, namely, the GUID of each sub-partition in the active partition is switched to the corresponding sub-partition in the backup partition, and the GUID of each sub-partition in the active partition is switched to the invalid and same GUID in the backup partition.
For ease of explanation, the following description is given in connection with examples.
Illustratively, in the case that the active partition is SlotA, the sub-partition to be run includes X-loader_a, boot_a, dtbo_a, and the GUID of X-loader_a is GUID1, the GUID of boot_a is GUID2, the GUID of dtbo_a is GUID3, and the GUID of X-loader_b, boot_b, and dtbo_b in the backup partition SlotB is GUID4 that is invalid (GUID 1, GUID2, GUID3, and GUID4 are 4 different GUIDs, and GUID1 to GUID3 are valid GUIDs, GUID4 is an invalid GUID), when starting from SlotA a preset number of times fails, the electronic device switches from SlotA to SlotB, and the switching about GUID at least includes the following procedures:
step 1: GUIDs of each of the child partitions in SlotA and SlotB are swapped.
Specifically, the GUID of X-loader_b is switched from GUID4 to GUID1, and the GUID of X-loader_a is switched from GUID1 to GUID4; the GUID of boot_b is switched from GUID4 to GUID2, and the GUID of boot_a is switched from GUID2 to GUID4; the GUID of dtbo_b is switched from GUID4 to GUID3, and the GUID of dtbo_a is switched from GUID3 to GUID4.
It should be noted that, during the process of starting the electronic device, the globally unique identification partition table (GUID Partition Table, GPT) is first read from the internal memory to the memory. Then, GUID, start address, end address, partition name, etc. of the partition to be loaded are determined based on the information recorded in the GPT, and the partition (physical partition) corresponding thereto is loaded internally according to these pieces of information.
Therefore, the exchange of GUID in step 1 is only the exchange in the memory, i.e. the modification is the information recorded in the GPT, and the GUID of the actual physical partition in the internal memory is not updated yet.
Step 2: partition information of a Slot in a misc sub-partition is modified from indicating a start from Slot a to indicating a start from Slot b.
For example, the partition information of the Slot in the misc sub-partition is modified from Slot a to Slot b or from a to b.
Step 3: and updating the GUID exchanged in the step 1 to SlotB. That is, the update of the GUID of the actual physical partition is completed.
Thus, after the above steps 1 to 3 are completed, the switch from SlotA to SlotB is realized. Thus, the electronic device can take SlotB as an active partition, and then start from SlotB after loading the Common partition.
However, in some possible scenarios, in the process of performing the partition information exchange, that is, performing the above steps 1 to 3, the user may press the Power key for a long time, or the Power key may operate with other mechanical keys, such as a volume up/down key. Such operation may cause a watchdog (watchdog) in the power management integrated circuit (Power Management Integrated Circuist, PMIC) to output a reset signal, i.e., trigger a PMIC watchdog interrupt.
It should be appreciated that when a PMIC watchdog interrupt occurs, the currently executing operation is interrupted and the electronic device is restarted with a power down. Thus, if a PMIC watch interrupt occurs, the operation of the partition signal switch is not completed, such as only step 1 is completed, or steps 1 and 2, step 3 is not completed. This results in that when the electronic device is restarted, the GUID read from the actual physical partition is all the same GUID4, which is invalid, when the CPU is started from SlotB, and thus the electronic device cannot be started.
As shown in fig. 2, when the partition switching is triggered, bootloader in the electronic device performs partition information exchange according to the steps 1 to 3.
For example, for convenience of explanation, the time period spent by the electronic device to complete partition switching is taken as T1 in this embodiment.
With continued reference to fig. 2, for example, if the user presses a mechanical key of the electronic device, such as a Power key (or a Power key and a volume up/down key), during the partition switch of the electronic device, the electronic device receives the pressing operation, and may record a duration, such as T2, of the user pressing the key.
With continued reference to fig. 2, by way of example, after deriving the duration T2 for which the user presses the key, the electronic device may further determine the relationship of T1, T2, and t_sx.
The t_sx is a time threshold value at which the PMIC watchdog interrupt is triggered, that is, when the time period of pressing the key by the user is greater than or equal to the time threshold value, the PMIC watchdog interrupt will occur, and thus the currently ongoing operation, such as the partition switching operation, is interrupted, and the electronic device is triggered to be powered down and restarted.
With continued reference to FIG. 2, by way of example, if T1, T2, and T_Sx satisfy the relationship of T1> T2+.gtoreq.T_Sx, then it may be determined that a PMIC watchdog interrupt (Sx_reset in FIG. 2) is currently occurring, but because T1> T2, it indicates that the partition switch operation has not been completed, i.e., that step 3 above has not been performed. Thus, the currently performed partition switch operation will be interrupted, i.e. the partition switch fails.
With continued reference to FIG. 2, by way of example, if T1, T2, and T_Sx do not satisfy the relationship T1> T2. Gtoreq.T_Sx, such as T1< T2. Gtoreq.T_Sx, this may determine that a PMIC watchdog interrupt (Sx_reset in FIG. 2) is currently occurring, but because T1< T2 indicates that the partition switch operation has been completed, i.e., steps 1-3 described above have all been performed. In this case, the partition switching has been successful, and the electronic device will respond to the PMIC watchdog interrupt and restart with power down.
With continued reference to FIG. 2, by way of example, if T1, T2, and T_Sx do not satisfy the relationship T1> T2+.gtoreq.T_Sx, such as T1< T2< T_Sx, this may determine that no PMIC watchdog interrupt (Sx_reset in FIG. 2) is currently occurring, and because T1< T2, indicates that the partition switch operation has been completed, i.e., steps 1-3 described above have all been performed. In this case, the partition switch has been successful and the electronic device will perform an automatically triggered restart after the partition switch.
With continued reference to FIG. 2, by way of example, if T1, T2, and T_Sx do not satisfy the relationship of T1> T2+.gtoreq.T_Sx, such as T1> T2< T_Sx, this may determine that a PMIC watchdog interrupt (Sx_reset in FIG. 2) is not currently occurring, and therefore, the electronic device may continue to perform partition switch operations.
It should be understood that the above description is only an example for better understanding of the technical solution of the present embodiment, and is not to be taken as the only limitation of the present embodiment.
In view of this, the embodiment of the application provides an interrupt processing method in the partition switching process, which aims to avoid that the processing flow of partition switching is interrupted by PMIC watchdog, so as to ensure that the electronic equipment can be restarted normally.
In order to better understand the technical solution provided by the embodiments of the present application, a scenario that triggers partition switching is described below.
It should be noted that, the partition switching mainly occurs in the upgrade process of the operating system, and the upgrade process of the electronic device related to the data storage structure of the virtual AB mode may include a packet searching (Payload Fetch) link, a Download (Payload Download) link, a first verification (Payload Verify) link, an installation (Payload Install) link, a second verification (Payload Verify) link, a partition switching (Slot Switch) link, a restart (Reboot) link, a Merge link, a rollback link, and so on, as shown in fig. 3.
Referring to fig. 3, an exemplary packet searching procedure is the first procedure in the upgrade process. Specifically, in the searching step, the electronic device detects whether an available upgrade package exists in the server.
By way of example, in some possible implementations, the server storing the upgrade package may be, for example, a so-called fly-swatch server.
For example, in other possible implementations, the server hosting the upgrade package may be, for example, an OTA (Over-the-Air Technology) server.
It can be appreciated that, for the upgrade package stored in the OTA server, the upgrade package may be actively obtained from the package beating server, or may be actively issued to the OTA server by the package beating server.
It should be understood that the above description is only an example for better understanding of the technical solution of the present embodiment, and is not to be taken as the only limitation of the present embodiment.
With continued reference to fig. 3, for example, when there is an available upgrade package on the server, for example, an upgrade package required for the current electronic device to perform an operating system upgrade, the second link of the upgrade procedure, that is, the download link, is entered. Specifically, in the downloading link, the electronic device downloads 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.
It should be noted that, in the process of downloading the upgrade package, a power failure restart may occur. When the situation occurs, the electronic equipment can conduct breakpoint continuous transmission through the breakpoint record file, and the integrity of the content in the downloaded upgrade package is ensured.
With continued reference to fig. 3, the exemplary electronic device, after downloading the successful upgrade package from the server, may enter a third link of the upgrade process, i.e., a first verification link. Specifically, the electronic device may verify the downloaded upgrade package in the first verification step, for example, by using a corresponding signature, so as to ensure the integrity and correctness of the upgrade package.
With continued reference to fig. 3, an exemplary process may enter a fourth step of the upgrade process, i.e., an installation step, after the upgrade package is verified. In particular, in the technical solution provided in the embodiments of the present application, because the electronic device is configured to address the data storage structure of the virtual AB mode, in the installation link, the electronic device will Write the content related to the static partition (Slot) in the upgrade package into the data corresponding to each sub-partition, write the data corresponding to each sub-partition in the current backup partition, into the corresponding sub-partition in the Slot, and temporarily Write the data corresponding to each sub-partition in the dynamic partition (Super) into the Copy-On-Write (cow) file created in the user data partition (Userdata).
It should be understood that the upgrade package in this link is only written to 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 that the upgrade of the operating system is not completed yet.
With continued reference to fig. 3, after the electronic device writes the data in the upgrade package into the corresponding partition (the backup partition and the COW file), the upgrade process may enter a fifth link, i.e., a second verification link. Specifically, in the second verification step, the electronic device verifies the content written into each partition, so as to ensure the integrity and correctness of the content read from the upgrade package and written into the corresponding partition.
With continued reference to fig. 3, in the case where the second verification is successful, the sixth link of the upgrade procedure, that is, the partition switching link, is entered. For specific operations performed in the partition switching link, refer to steps 1 to 3 involved in the partition information exchange flow in the foregoing embodiments, and are not described herein again.
With continued reference to fig. 3, exemplary, after completing steps 1 to 3 in the above embodiment, the partition switching is completed, and the upgrade process may enter a seventh link, i.e., a restart link. Specifically, when the electronic device triggers a restart, if the electronic device can be started normally, it indicates that the electronic device is restarted successfully, and in this case, the electronic device executes a Merge link, that is, performs a Merge operation.
It should be noted that, the Merge operation is a process of writing the upgrade file of the upgrade Super in the Userdata, that is, the COW file of the Userdata temporarily written in the installation link, onto the corresponding sub-partition in the Super.
With continued reference to fig. 3, by way of example, when the electronic device triggers a reboot, if the electronic device fails to boot up normally, in some possible implementations a rollback procedure will be performed. Specifically, in the rollback link, the electronic device may perform partition switching again, that is, switch back to the Slot, such as SlotA, of the upgrade file regarding the static partition, which is not written in the upgrade package.
It should be understood that the above description is only an example for better understanding of the technical solution of the present embodiment, and is not to be taken as the only limitation of the present embodiment.
Thus, as can be seen from the description of each link involved in the upgrade process of the electronic device of the data storage structure in the virtual AB mode, in the whole upgrade process, the links involved in partition switching include the partition switching link and the rollback link shown in fig. 3. That is, the technical solution provided in the embodiment of the present application occurs in the handover link and the rollback link shown in fig. 3.
In addition, in order to better understand the technical solution provided in the embodiments of the present application, before describing the technical solution of the embodiments of the present application, a hardware structure of an electronic device to which the embodiments of the present application are applicable is first described with reference to the accompanying drawings.
It should be noted that, since the PMIC watch interrupt is a timer interrupt, and is an interrupt that is triggered when the user presses the Power key for a long time, or presses the Power key and other mechanical keys (e.g., volume up/down keys) for a long time. Therefore, the electronic device suitable for the technical scheme provided by the embodiment of the application is an electronic device, such as a mobile phone, a tablet computer, a PC and the like, which is provided with a Power key, a volume up/down key and other mechanical keys capable of triggering the PMIC watch interrupt, and the application is not limited to this.
Referring to fig. 4, the electronic device 100 may include: processor 110, external memory interface 120, internal memory 121, universal serial bus (universal serial bus, USB) interface 130, charge management module 140, power management module 141, battery 142, antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headset interface 170D, sensor module 180, keys 190, motor 191, indicator 192, camera 193, display 194, and subscriber identity module (subscriber identification module, SIM) card interface 195, etc.
By way of example, the audio module 170 may include a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, and the like.
By way of example, the sensor module 180 may include a pressure sensor, a gyroscope sensor, a barometric pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, and the like.
By way of example, the processor (CPU) 110 may include one or more processing units, such as: the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a memory, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and/or a neural network processor (neural-network processing unit, NPU), etc.
It will be appreciated that in particular implementations, the different processing units may be separate devices or may be integrated in one or more processors.
In addition, it should be noted that the controller in the processor 110 may be a neural center and a command center of the electronic device 100. In practical application, the controller can generate operation control signals according to the instruction operation codes and the time sequence signals to complete instruction fetching and instruction execution control.
It should be noted that, a storage (memory) may also 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 hold instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to reuse the instruction or data, it can be called directly from the memory. Repeated accesses are avoided and the latency of the processor 110 is reduced, thereby improving the efficiency of the system.
With continued reference to fig. 4, the exemplary charge management module 140 is operable to receive a charge input from a charger. The charger can be a wireless charger or a wired charger.
With continued reference to fig. 4, an exemplary power management module 141 (referred to as a power management integrated circuit PMIC, described above) is used to connect the battery 142, the charge management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and/or the charge management module 140 and provides power to the processor 110, the internal memory 121, the external memory, the display 194, the camera 193, the wireless communication module 160, and the like. The power management module 141 may also be configured to monitor battery capacity, battery cycle number, battery health (leakage, impedance) and other parameters. In other implementations, the power management module 141 may also be provided in the processor 110. In other implementations, the power management module 141 and the charge management module 140 may also be disposed in the same device.
Specifically, in the technical solution provided in this embodiment of the present application, a hardware watchdog is integrated in the power management module, which may trigger a PMIC watchdog interrupt when a user presses the key 190 for a long time, and further send a RESET signal to the processor 110, for example, send the RESET signal to the processor 110 through a RESET pin, so that the processor 110 may respond to an operation of pressing the key by the user, and trigger the electronic device 100 to perform power-down restart.
With continued reference to fig. 4, exemplary wireless communication functions of the electronic device 100 may be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, a modem processor, a baseband processor, and the like.
The antennas 1 and 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 100 may be used to cover a single or multiple communication bands. Different antennas may also be multiplexed to improve the utilization of the antennas. For example: the antenna 1 may be multiplexed into a diversity antenna of a wireless local area network. In other implementations, the antenna may be used in conjunction with a tuning switch.
With continued reference to fig. 4, the exemplary mobile communication module 150 may provide a solution for wireless communications, including 2G/3G/4G/5G, as applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (low noise amplifier, LNA), etc. The mobile communication module 150 may receive electromagnetic waves from the antenna 1, perform processes such as filtering, amplifying, and the like on the received electromagnetic waves, and transmit the processed electromagnetic waves to the modem processor for demodulation. The mobile communication module 150 can amplify the signal modulated by the modem processor, and convert the signal into electromagnetic waves through the antenna 1 to radiate. In some implementations, at least some of the functional modules of the mobile communication module 150 may be disposed in the processor 110. In some implementations, at least some of the functional modules of the mobile communication module 150 may be disposed in the same device as at least some of the modules of the processor 110.
With continued reference to fig. 4, exemplary wireless communication module 160 may provide solutions for wireless communication including wireless local area network (wireless local area networks, WLAN) (e.g., wireless fidelity (wireless fidelity, wi-Fi) network), bluetooth (BT), global navigation satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field wireless communication technology (near field communication, NFC), infrared technology (IR), etc., as applied to electronic device 100. The wireless communication module 160 may be one or more devices that integrate at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the electromagnetic wave signals, filters the electromagnetic wave signals, and transmits the processed signals to the processor 110. The wireless communication module 160 may also receive a signal to be transmitted from the processor 110, frequency modulate it, amplify it, and convert it to electromagnetic waves for radiation via the antenna 2.
In particular, in the technical solution provided in the embodiment of the present application, a precondition for triggering the electronic device 100 to exchange partition information is that the electronic device 100 upgrades an operating system. Regarding an upgrade package required in the operating system upgrade process, the electronic device 100 may communicate with a cloud server (brand package server, OTA server, etc.) through the mobile communication module 150 or the wireless communication module 160, so as to obtain an upgrade package or cold patch Ding Bao of the operating system.
With continued reference to FIG. 4, exemplary display 194 is used to display images, videos, and the like. In some implementations, the electronic device 100 may include 1 or N display screens 194, N being a positive integer greater than 1.
With continued reference to fig. 4, exemplary camera 193 is used to capture still images or video. In some implementations, the electronic device 100 may include 1 or N cameras 193, N being a positive integer greater than 1.
With continued reference to fig. 4, an exemplary external memory interface 120 may be used to interface with an external memory card, such as a Micro SD card, to enable expansion of the memory capabilities of the electronic device 100. The external memory card communicates with the processor 110 through an external memory interface 120 to implement data storage functions. For example, files such as music, video, etc. are stored in an external memory card.
With continued reference to fig. 4, by way of example, the internal memory 121 may be used to store computer executable program code that includes instructions.
In particular, in the technical solution provided in the embodiment of the present application, the relevant instructions involved in the process of starting the electronic device 100, upgrading the operating system, and interacting partition information may be stored in advance in the internal memory 121. In the starting process of the electronic device 100, the Bootloader started first executes the instruction 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.
In addition, it should be noted that, in a specific implementation, the internal memory 121 may include a storage program area and a storage data area. For the internal memory 121 of the data storage structure of the virtual AB mode, the storage program areas are Common, slotA, slotB and Super shown in fig. 1A and 1B; the storage data area is Userdata shown in fig. 1A and 1B.
By way of example, in some possible implementations, the internal memory 121 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 memory (universal flash storage, UFS), and the like.
It should be noted that, in particular, to practical applications, the partition deployment information for the internal memory 121 in the electronic device 100 may be described by a partition table shown in table 1.
TABLE 1 partition Table
In this way, the starting address and size of each partition are defined by the partition table, so that the corresponding partition size can be adjusted as needed for different hardware.
That is, in practical applications, the partitions recorded in the partition table may be set in a partition manner according to the actual service requirements.
In addition, it should be noted that, except for the specially reserved partition, basically, each partition has its corresponding image (image) file, where the image file is compiled by software code, and various functional files and configurations related to the starting or running process of the electronic device are integrated therein. Without the image file, the electronic device is not operational. A complete system version includes many images, partition table images gpt.img, boot related images (xloader.img, boot. Img), system images super.img (integrating android system cores), user data images userdata.img (storing user data), etc.
In addition, it should be noted that, the distribution of the partitions in the internal memory 121 of the data storage structure of the virtual AB mode shown in fig. 1A and 1B is not limited to that shown in fig. 1A and 1B, and the positions of the partitions are determined according to the assigned start address and end address in practical application.
It should be understood that the above description is only an example for better understanding of the technical solution of the present embodiment, and is not to be taken as the only limitation of the present embodiment.
With continued reference to fig. 4, exemplary keys 190 include a Power on key (Power key), a volume key (volume up key, volume down key), and the like.
In particular, 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 may receive key inputs and generate signals related to user settings and function controls of the electronic device 100.
With continued reference to FIG. 4, exemplary, the motor 191 may generate a vibration alert. The motor 191 may be used for incoming call vibration alerting as well as for touch vibration feedback.
With continued reference to fig. 4, the indicator 192 may be, for example, an indicator light, may be used to indicate a state of charge, a change in charge, may be used to indicate a message, missed call, notification, or the like.
As to the hardware architecture of the electronic device 100, it should be understood that the electronic device 100 shown in fig. 4 is merely an example, and in particular implementations, the electronic device 100 may have more or fewer components than shown, may combine two or more components, or may have different component configurations. The various components shown in fig. 4 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.
In order to better understand the relationship between Bootloader and each hardware that implements the technical solution provided in the embodiments of the present application, the following describes a software structure of the electronic device 100.
Before explaining the software structure of the electronic device, an architecture that a software system of the electronic device can employ is first explained.
Specifically, in practical applications, the software system of the electronic device may employ a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture.
Furthermore, it is understood that software systems currently in use in mainstream electronic devices include, but are not limited to, windows systems, android systems, and iOS systems. For convenience of explanation, the embodiment of the application takes an Android system with a layered architecture as an example, and illustrates a software structure of an electronic device.
In addition, it should be understood that the interrupt processing method in the partition switching process provided in the embodiment of the present application is applicable to other systems in the specific implementation.
Referring to fig. 5, a software architecture block diagram of an electronic device according to an embodiment of the present application is shown.
As shown in fig. 5, the layered architecture of the electronic device divides the software into several layers, each with a clear role and division of work. The layers communicate with each other through a software interface. In some implementations, the Android system may be divided into six layers, from top to bottom, an application layer/application layer (Applications) belonging to the application part, a framework layer/application framework layer (Application Framework, FWK) belonging to the core part, a Runtime (run) and a system library, a hardware abstraction layer (Hardware Abstract Layer, HAL) belonging to the bottom part, a Linux Kernel layer, and a boot loader layer (Bootloader).
The application layer may include a series of application packages, among other things. As shown in FIG. 5, the application package may include camera, game, video, live, etc. applications, which are not explicitly recited herein, and are not limiting in this application.
Wherein the framework layer may provide an application programming interface (application programming interface, API) and programming framework for application programs of the application layer. In some implementations, these programming interfaces and programming frameworks can be described as functions. As shown in FIG. 5, the framework layer may include functions of a content provider, a window manager, a resource manager, a telephony manager, etc., which are not to be limiting in this application.
It should be noted that, the window manager located in the framework layer is used for managing the window program. The window manager can acquire the size of the display screen, judge whether a status bar exists, lock the screen, intercept the screen and the like.
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, image, audio, phone calls made and received, browsing history and bookmarks, phone book, etc., which are not listed here, but are not limiting in this application.
In addition, it should be further noted that the resource manager in the framework layer is used to provide various resources for the application program, such as localization strings, icons, pictures, layout files, video files, and the like, which are not listed here, but are not limited in this application.
In addition, it should be noted that the phone manager located in the application framework layer is used to provide the communication function of the electronic device. Such as the management of call status (including on, hung-up, etc.).
With continued reference to fig. 5, an exemplary Runtime, specifically An Zhuoyun (Android run), may include a core library and virtual machines, primarily responsible for scheduling and management of the Android system.
The core library comprises two parts: one part is a function which needs to be called by java language, and the other part is a core library of android. The application layer and the framework layer run in virtual machines. The virtual machine executes java files of the application layer and the framework layer as binary files. The virtual machine is used for executing the functions of object life cycle management, stack management, thread management, security and exception management, garbage collection and the like.
With continued reference to FIG. 5, an exemplary system library may include a plurality of functional modules. For example: surface manager (surface manager), media Libraries (Media Libraries), three-dimensional (3D) graphics processing Libraries (e.g., openGL ES), two-dimensional (2D) graphics engines (e.g., SGL), etc.
The surface manager is used for managing the display subsystem and providing fusion of 2D and 3D layers for a plurality of application programs. Media libraries support a variety of commonly used audio, video formats for playback and recording, still image files, and the like. The media library may support a variety of audio video encoding formats, such as: MPEG4, h.264, MP3, AAC, AMR, JPG, pnG, etc. The three-dimensional graphic processing library is used for realizing three-dimensional graphic drawing, image rendering, synthesis, layer processing and the like.
Further, it is understood that the 2D graphics engine described above is a drawing engine for 2D drawing.
With continued reference to FIG. 5, an exemplary HAL layer is an interface layer between the operating system kernel (kernel layer) and the hardware circuitry that aims to isolate the FWK from the kernel so that Android does not depend excessively on the kernel, thereby enabling development of the FWK without regard to drivers.
With continued reference to FIG. 5, exemplary HAL layers may include various interfaces therein, such as an audio-visual interface, a GPS interface, a call interface, a WiFi interface, etc., which are not to be limiting in this application.
With continued reference to FIG. 5, the kernel layer in the Android system is illustratively the layer between hardware and software. The kernel layer may include various processes/threads, power management, various drivers, such as WiFi drivers, and the like.
With continued reference to fig. 5, an exemplary Bootloader in the Android system is a program that is first run before the operating system kernel runs after the electronic device is powered on. The Bootloader can initialize the hardware device and establish the memory space map. After the Bootloader completes the initialization of the CPU and related hardware, the operating system image or the solidified embedded application program is loaded into the memory, and then jumps to the space where the operating system is located, and the operating system is started to run.
With continued reference to fig. 5, by way of example, the program integrated in the Bootloader may also vary due to the different modes employed by the data storage structure of the internal memory of the electronic device. In particular, in the technical solution provided in the embodiments of the present application, in the case where the data storage structure is in the virtual AB mode, it is considered that the virtual AB mode involves partition switching, and partition starting. Thus, the Bootloader may include a function/function module for implementing partition switching and partition starting, such as the AB partition switching module and AB partition starting module shown in fig. 5.
It is understood that in some possible implementations, the AB partition switching module and the AB partition starting module may be integrated in one functional function/module, which is not limited in this application.
Specific logic for implementing the interrupt processing method in the partition switching process provided in the embodiment of the present application by using Bootloader is described in the embodiment shown in fig. 5 below, and is not repeated here.
The description of the software structure of the electronic device is presented herein, and it is understood that the layers and components included in the layers in the software structure shown in fig. 5 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, and more or fewer components may be included in each layer, as the present application is not limited.
Based on the above hardware structure and software structure, the following describes a specific interrupt processing method in the partition switching process according to the embodiment of the present application with reference to fig. 6.
As shown in fig. 6, when the partition switching is triggered, bootloader in the electronic device performs the partition information exchange according to the steps 1 to 3.
For example, for convenience of explanation, the time period spent by the electronic device to complete partition switching is taken as T1 in this embodiment.
For example, regarding the determination of partition switching time, for example, the timestamp corresponding to the last active partition failed to boot and the timestamp of switching to the backup partition may be obtained through the getttstime () function.
With continued reference to fig. 6, for example, if the user presses a mechanical key of the electronic device, such as a Power key (or a Power key and a volume up/down key), during the partition switch of the electronic device, the electronic device receives the pressing operation, and may record a duration, such as T2, of the user pressing the key.
With continued reference to fig. 6, by way of example, after deriving the duration T2 for which the user presses the key, the electronic device may further determine the relationship of T1, T2, and t_sx.
The t_sx is a time threshold value at which the PMIC watchdog interrupt is triggered, that is, when the time period of pressing the key by the user is greater than or equal to the time threshold value, the PMIC watchdog interrupt will occur, and thus the currently ongoing operation, such as the partition switching operation, is interrupted, and the electronic device is triggered to be powered down and restarted.
With continued reference to FIG. 6, by way of example, if T1, T2, and T_Sx satisfy the relationship of T1> T2+.gtoreq.T_Sx, then it can be determined that a PMIC watchdog interrupt (Sx_reset in FIG. 6) is currently occurring, but because T1> T2, the operation currently being performed by the surface is still complete.
It should be noted that, when the PMIC watchdog interrupt occurs, the currently performed operation may not be a partition switch operation, and for a non-partition switch operation, the PMIC watchdog interrupt does not cause the electronic device to be unable to restart. Thus, upon determining that a PMIC watchdog interrupt is currently occurring, bootloder may determine whether the operation currently being performed is a partition switch operation by traversing current program stack/SP stack information, and further based on the current program stack/SP stack information.
It is appreciated that in the ARM (Advanced RISC Machines) architecture, the running state information of the interrupted program is saved prior to any interrupt handling.
By way of example, in one possible implementation, the running state information of the interrupted program may include, for example, data, code, registers, and stack information of the current program. The registers may include rax, rbx, rcx, rdx, rsi, rdi, rbp, rsp, r, r9, r10, r11, r12, r13, r14, r15, etc., among others.
In particular, in the present embodiment, three registers r13, r14, r15 are mainly focused. The r13 register is a register for storing stack information of the current interrupted program; r14 Register, i.e. Link Register (LR) Register; the r15 register (also called a Program Count (PC) register) is a register that holds interrupted program instructions.
Regarding LR registers, there are two special purposes in the ARM architecture, one is to hold the subroutine return address; and secondly, when the abnormality occurs, the value stored in the LR register is equal to the value of the PC when the abnormality occurs minus 4 (or minus 2), so that the operation of the interrupted program can be continuously executed according to the value of the LR register to the corresponding position before the abnormality occurs in various abnormal modes.
Understandably, the above-mentioned PC value, i.e., the instruction counter value (Program counter). In particular, in order to ensure that a program (understood as a process in an operating system) can execute continuously, the CPU must have some means to determine the address of the next instruction. The program counter is what is known as an instruction counter. Before the program starts to execute, its start address, i.e. 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 fetched from memory. When executing an instruction, the CPU will automatically modify the contents of the PC, i.e. the PC is increased per execution of an instruction by an amount equal to the number of bytes the instruction contains, so that it maintains the address of the next instruction to be executed at all times. Since most instructions are executed sequentially, the modified process is typically simply a 1-to-PC addition. The number of bits of the PC is generally the same as the number of bits of the memory address register MAR.
For example, if it is determined by traversing the current program stack/SP stack information that the operation currently being performed is not a partition switch operation, the electronic device may directly perform the PMIC watchdog interrupt (Sx_reset in FIG. 6), i.e., power-down reboot or power-down.
Illustratively, if it is determined that the operation currently being performed is a partition switch operation by traversing the current program stack/SP stack information, since T1> T2, it indicates that the operation of partition switch has not been completed, i.e., step 3 described above has not been performed. In order to avoid interruption of partition switching operation by PMIC watchdog, in the technical scheme provided by the embodiment, bootloader directly exits from Sx_reset, so that partition switching operation can be continuously executed until partition switching is completed.
For example, in some possible implementations, the following pseudocode may be integrated in Bootloader, so as to implement the interrupt processing method in the partition switching process provided in this embodiment.
Pseudo code integrated in Bootloader:
it should be understood that the above description is only an example for better understanding of the technical solution of the present embodiment, and is not to be taken as the only limitation of the present embodiment.
In addition, it should be noted that, since the power-down restart triggered by the PMIC watchdog interrupt and the restart performed automatically after the partition switch is completed, the method is two different types of restarting methods. In the Android system, different identifiers are used to indicate reboots caused by the two reasons.
For example, for a power-down restart triggered by a PMIC watchdog interrupt, after an electronic device is restarted, the restart reason recorded in the stack information is typically XVDD, i.e., sreason str=xvdd; for a restart triggered after completion of a partition switch, the restart reason recorded in the stack information is typically SWReset after the electronic device is restarted, i.e., sreason str=swreset.
That is, after the electronic device receives the operation of pressing the key by the user and triggers the PMIC watchdog interrupt, the electronic device can determine whether the restart is a power-down restart triggered by the PMIC watchdog interrupt or a PMIC watchdog interrupt is blocked by checking the restart reason recorded in the stack information, and after the partition switching operation is completed, the restart is automatically triggered.
With continued reference to FIG. 6, by way of example, if T1, T2, and T_Sx do not satisfy the relationship T1> T2. Gtoreq.T_Sx, such as T1< T2. Gtoreq.T_Sx, this may determine that a PMIC watchdog interrupt (Sx_reset in FIG. 6) is currently occurring, but because T1< T2 indicates that the partition switch operation has been completed, i.e., steps 1-3 described above have all been performed. In this case, the partition switching has been successful, and the electronic device will respond to the PMIC watchdog interrupt and restart with power down.
With continued reference to FIG. 6, by way of example, if T1, T2, and T_Sx do not satisfy the relationship T1> T2+.gtoreq.T_Sx, such as T1< T2< T_Sx, this may determine that no PMIC watchdog interrupt (Sx_reset in FIG. 6) is currently occurring, and because T1< T2, indicates that the partition switch operation has been completed, i.e., steps 1-3 described above have all been performed. In this case, the partition switch has been successful and the electronic device will perform an automatically triggered restart after the partition switch.
With continued reference to FIG. 6, by way of example, if T1, T2, and T_Sx do not satisfy the relationship of T1> T2+.gtoreq.T_Sx, such as T1> T2< T_Sx, this may determine that a PMIC watchdog interrupt (Sx_reset in FIG. 6) is not currently occurring, and therefore, the electronic device may continue to perform partition switch operations.
It should be understood that the above description is only an example for better understanding of the technical solution of the present embodiment, and is not to be taken as the only limitation of the present embodiment.
Therefore, when the PMIC watchdog interrupt occurs, whether the operation currently executed is the partition switching operation or not is determined, and when the operation currently executed is determined to be the partition switching operation, the power-down restarting operation or the shutdown operation to be carried out by the PMIC watchdog interrupt per se is selected not to be executed, but the partition switching operation is continuously executed, so that the process flow of partition switching is effectively prevented from being interrupted by the PMIC watchdog, and the electronic equipment is further ensured to be capable of completing partition switching and normal restarting.
Furthermore, it will be appreciated that the electronic device, in order to achieve the above-described functions, comprises corresponding hardware and/or software modules that perform the respective functions. The steps of an algorithm for each example described in connection with the embodiments disclosed herein may be embodied in hardware or a combination of hardware and computer software. Whether a function is implemented as hardware or computer software driven hardware depends upon the particular application and design constraints imposed on the solution. Those skilled in the art may implement the described functionality using different approaches for each particular application in conjunction with the embodiments, but such implementation is not to be considered as outside the scope of this application.
In addition, it should be noted that, in an actual application scenario, the interrupt processing method in the partition switching process provided in the foregoing embodiments implemented by the electronic device may also be executed by a chip system included in the electronic device, where the chip system may include a processor. The chip system may be coupled to a memory such that the chip system, when running, invokes a computer program stored in the memory, implementing the steps performed by the electronic device described above. The processor in the chip system can be an application processor or a non-application processor.
In addition, the embodiment of the application further provides a computer readable storage medium, where computer instructions are stored, when the computer instructions are executed on the electronic device, cause the electronic device to execute the related method steps to implement the interrupt processing method in the partition switching process in the embodiment.
In addition, the embodiment of the application further provides a computer program product, when the computer program product runs on the electronic device, the electronic device is caused to execute the related steps, so as to implement the interrupt processing method in the partition switching process in the embodiment.
In addition, embodiments of the present application also provide a chip (which may also be a component or module) that may include one or more processing circuits and one or more transceiver pins; the processing circuit executes the related method steps to realize the interrupt processing method in the partition switching process in the embodiment so as to control the receiving pin to receive signals and control the transmitting pin to transmit signals.
In addition, as can be seen from the foregoing description, the electronic device, the computer-readable storage medium, the computer program product, or the chip provided in the embodiments of the present application are used to perform the corresponding methods provided above, and therefore, the advantages achieved by the method can refer to the advantages in the corresponding methods provided above, which are not repeated herein.
The above embodiments are merely for illustrating the technical solution of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.

Claims (12)

1. An interrupt handling method in a partition switching process, applied to an electronic device, said method comprising:
when a pressing operation of a shutdown key by a user is received, recording the pressing time of the shutdown key by the user, wherein the shutdown key is positioned on a side frame of the electronic equipment;
when the pressing time length is greater than or equal to a preset time length threshold value, interrupting the operation currently being executed;
when the interrupted operation exists currently, determining whether the operation which is interrupted currently is a partition switching operation or not;
restoring the partition switching operation when the operation which is interrupted currently is the partition switching operation;
and restarting the electronic equipment after the partition switching operation is completed.
2. The method of claim 1, wherein after restarting the electronic device after the partition switch operation is completed, the method further comprises:
acquiring a 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 equipment is a restart triggered after partition switching.
3. The method according to claim 1, wherein the method further comprises:
when there is no interrupted operation at present, restarting the electronic device in response to the pressing operation.
4. The method according to claim 1, wherein the method further comprises:
and restarting the electronic device in response to the pressing operation when the currently interrupted operation is not the partition switching operation.
5. The method according to claim 3 or 4, wherein after restarting the electronic device in response to the pressing operation, the method further comprises:
acquiring 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 equipment is restarted when power is turned off and triggered by pressing operation.
6. The method of any of claims 1 to 5, wherein the determining whether the currently interrupted operation is a partition switch operation comprises:
acquiring running state information of a program executing a currently interrupted operation;
and determining whether the operation which is interrupted currently is the partition switching operation or not according to the running state information.
7. The method of claim 6, the determining whether the currently interrupted operation is the partition switch operation based on the run state information, comprising:
determining an instruction counter PC value of the program according to the running state information;
and when the PC value is in a PC value interval corresponding to a program for executing the partition switching operation, determining that the operation which is interrupted currently is the partition switching operation.
8. The method of any of claims 1 to 7, wherein the memory of the electronic device comprises a base 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 identity identifier, and each sub-partition included in the backup partition shares an invalid identity identifier.
9. The method of claim 8, wherein the operation of partition switching comprises:
the identification mark of each sub-partition in the backup partition recorded in the GPT partition table of the read memory is modified to be the identification mark of the corresponding sub-partition in the active partition, and the identification mark of each sub-partition in the active partition is modified to be the invalid identification mark;
modifying the starting sequence 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.
10. The method of claim 9, wherein the partition switch operation is complete, comprising:
and 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 is completed.
11. An electronic device, the electronic device comprising: a memory and a processor, the memory and the processor coupled; the memory stores program instructions that, when executed by the processor, cause the electronic device to perform the interrupt handling method in a partition switching process as claimed in any one of claims 1 to 10.
12. A computer readable storage medium comprising a computer program which, when run on an electronic device, causes the electronic device to perform the interrupt handling method in a partition switching process as claimed in any one of claims 1 to 10.
CN202311024567.8A 2023-08-14 2023-08-14 Interrupt processing method, device and storage medium in partition switching process Pending CN117707630A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311024567.8A CN117707630A (en) 2023-08-14 2023-08-14 Interrupt processing method, device and storage medium in partition switching process

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311024567.8A CN117707630A (en) 2023-08-14 2023-08-14 Interrupt processing method, device and storage medium in partition switching process

Publications (1)

Publication Number Publication Date
CN117707630A true CN117707630A (en) 2024-03-15

Family

ID=90146723

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311024567.8A Pending CN117707630A (en) 2023-08-14 2023-08-14 Interrupt processing method, device and storage medium in partition switching process

Country Status (1)

Country Link
CN (1) CN117707630A (en)

Similar Documents

Publication Publication Date Title
US8539471B2 (en) Updating firmware of an electronic device
WO2011127845A2 (en) Method, system and terminal for system update between mobile communication terminals
CN105468410B (en) Method for upgrading system and device
CN115328563B (en) System starting method and electronic equipment
CN110633090A (en) Patch method, related device and system
CN112527301B (en) Method for realizing application plug-in and electronic equipment
CN114968384B (en) Function calling method and device
CN114265616B (en) Upgrading method of operating system, electronic equipment and storage medium
CN112068903A (en) Application loading method, application loading device, medium and equipment
CN114661322B (en) Upgrade method of operating system, electronic equipment and storage medium
CN115357295B (en) System rollback method, device and storage medium
CN116400938B (en) Operating system upgrading method, device and storage medium
CN116382791B (en) Configuration file protection method and electronic equipment
CN117707630A (en) Interrupt processing method, device and storage medium in partition switching process
CN114489814B (en) Terminal equipment starting method and terminal equipment
US20230350738A1 (en) Method for Reusing Shared Library and Electronic Device
CN115951920A (en) Mobile equipment upgrading method and device, storage unit and mobile equipment
CN116700768A (en) Application processing method and related device
CN114138343A (en) Terminal and terminal starting method
CN115562697B (en) Upgrade method, device and storage medium
CN117177246B (en) Method for locking electronic equipment, electronic equipment and server
CN117290164B (en) Information recording method at restarting, electronic device and readable storage medium
CN114968314B (en) Firmware upgrading method and device for display equipment, electronic equipment and storage medium
CN116069370A (en) Method, apparatus, storage medium and computer program product for upgrading a cold patch
KR100588199B1 (en) Method for recovering download mode in program download fail state of portable terminal, and portable terminal employing it

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination