Ota upgrading method and device of terminal equipment, readable storage medium and terminal equipment
By setting the partition to be loaded and adjusting the partition type consistency according to the upgrade result during the OTA upgrade process of the terminal device, the problem of device bricking caused by OTA upgrade anomalies was solved, and the system was able to be rolled back or upgraded stably.
Patent Information
- Application Number
- CN202310074355.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-19
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2043-01-19
AI Technical Summary
In dual-partition system upgrades, if an OTA upgrade fails, the terminal device cannot roll back to the system before the upgrade, resulting in the device becoming unusable.
By identifying the first and second types of image data, OTA upgrades are performed on the first target partition and other target partitions. Based on the upgrade results, the partitions to be loaded are set, and the consistency of partition types is checked during the reboot process. If necessary, the partition types are changed to ensure consistency, thereby enabling rollback or entry into the OTA-upgraded system.
It effectively prevents terminal devices from becoming bricked due to OTA upgrade anomalies, ensuring that devices can be rolled back to the system before the upgrade or enter the upgraded system, thus improving system stability.
Smart Images

Figure CN115981694B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, and particularly relates to an OTA upgrading method and device of terminal equipment, a readable storage medium and terminal equipment. BACKGROUND
[0002] In the field of software upgrading technology, after the virtual AB (V-AB) partition scheme is put forward, many terminal equipment manufacturers use the V-AB partition mode to perform software dual-partition on the hardware storage space of the terminal equipment, due to the advantages such as seamless upgrading. In the V-AB partition scheme, the A partition can be named as slot A, and the B partition can be named as slot B. The upgrading is performed in a spiral manner between the two slots, and the terminal equipment runs on one slot during the upgrading, and the other idle slot is upgraded in the background.
[0003] Specifically, the V-AB partition scheme is based on a part of the User Data Area (UDA) in the hardware storage space, and two software partitions, a slot A partition (hereinafter referred to as another main partition) and a slot B partition (hereinafter referred to as another target partition), are divided. The slot A partition includes uboot_a partition, dtbo_a partition and the like, and the slot B partition includes uboot_b partition, dtbo_b partition and the like. Two software partitions, a main SPL partition (hereinafter referred to as a first main partition) and a SPL_BAK partition (hereinafter referred to as a first target partition), are divided based on the Boot hardware partition. The main SPL partition is obtained based on Boot0, and the SPL_BAK partition is obtained based on Boot1.
[0004] In the over-the-air technology (OTA), after the upgrade package downloaded from the server is unpacked and verified, the second program loader (SPL) image data is used to upgrade the main SPL partition (i.e., the first target partition) or the SPL_BAK partition (i.e., the first backup partition) on the Boot hardware partition, and the Userdata image data is used to upgrade the slot A partition (i.e., the other main partition) or the slot B partition (i.e., the other target partition) on the Userdata hardware partition.
[0005] In the prior art, for some old processor chips which do not support V-AB system, after the OTA upgrade is completed, the terminal device is restarted, and the main SPL partition and the SPL_BAK partition on the Boot hardware partition cannot be selectively loaded. However, in this case, if an abnormal interruption occurs during the OTA upgrade, it is difficult to ensure that the program version of the SPL_BAK partition (the first target partition) is consistent with the program version of the slot B partition (another target partition). For example, during the OTA upgrade, the SPL_BAK partition is upgraded successfully by using a new version of SPL image data, and the upgrade of the slot B partition fails by using the same version of UserData image data, so that during the restart of the terminal device, the terminal device cannot normally start and enter the system after the OTA upgrade. Since the selective loading of the partitions cannot be performed, when the terminal device fails to enter the system after the OTA upgrade, it cannot be rolled back to enter the system before the OTA upgrade, and the terminal device becomes a brick. SUMMARY
[0006] The technical problem solved by the embodiments of the present application is how to confirm that the system before the upgrade can be rolled back when the OTA upgrade is abnormal during the dual-partition system upgrade, and prevent the terminal device from becoming a brick.
[0007] To achieve the above object, the embodiments of the present application provide an OTA upgrade method of a terminal device, comprising the following steps: determining first type image data and second type image data; performing OTA upgrade on a first target partition by using the first type image data, and performing OTA upgrade on another target partition by using the second type image data; setting one of the first target partition or a first main partition as a first to-be-loaded partition, and setting the other target partition or another main partition as another to-be-loaded partition according to the upgrade result; pre-restarting the terminal device, and judging whether the type of the first to-be-loaded partition and the type of the other to-be-loaded partition are consistent during the restart; if the type of the first to-be-loaded partition and the type of the other to-be-loaded partition are inconsistent, confirming that the OTA upgrade is abnormal; changing the type of the first to-be-loaded partition to be consistent with the type of the other to-be-loaded partition according to the type of the other to-be-loaded partition, and then restarting the terminal device.
[0008] Optionally, the first type image data is SPL image data, the second type image data is UserData image data, the first main partition and the first target partition are software partitions based on a Boot hardware partition of the terminal device, and the other main partition and the other target partition are software partitions based on a UserData hardware partition of the terminal device.
[0009] Optionally, according to the type of the other to-be-loaded partition, the type of the first to-be-loaded partition is changed to be consistent with the type of the other to-be-loaded partition, and then the terminal device is restarted, including: if the other to-be-loaded partition is another master partition, the first to-be-loaded partition is changed from a first target partition to a first master partition; the terminal device is restarted to load the first master partition and the other master partition, and is rolled back to the system before the OTA upgrade.
[0010] Optionally, according to the type of the other to-be-loaded partition, the type of the first to-be-loaded partition is changed to be consistent with the type of the other to-be-loaded partition, and then the terminal device is restarted, including: if the other to-be-loaded partition is another target partition, the first to-be-loaded partition is changed from a first master partition to a first target partition; the terminal device is restarted to load the first target partition and the other target partition, and attempts to enter the system after the OTA upgrade.
[0011] Optionally, the method further includes: if the first to-be-loaded partition set is a first target partition, and the other to-be-loaded partition set is another target partition, the terminal device is restarted to load the first target partition and the other target partition, and attempts to enter the system after the OTA upgrade.
[0012] Optionally, if the attempt to enter the system after the OTA upgrade fails, the terminal device is restarted and attempts to enter the system after the OTA upgrade in a loop until the number of restarts reaches a preset threshold, and it is confirmed that the OTA upgrade fails; the first to-be-loaded partition is changed from a first target partition to a first master partition, and the other to-be-loaded partition is changed from another target partition to another master partition; the terminal device is restarted again to load the first master partition and the other master partition, and is rolled back to the system before the OTA upgrade.
[0013] Optionally, the setting one of the first target partition or the first main partition as the first to-be-loaded partition and the setting the other target partition or the other main partition as the other to-be-loaded partition according to the upgrade result comprises: if the first target partition and the other target partition are both upgraded successfully, setting the first target partition as the first to-be-loaded partition and setting the other target partition as the other to-be-loaded partition; if the first target partition and the other target partition are both upgraded unsuccessfully, setting the first main partition as the first to-be-loaded partition and setting the other main partition as the other to-be-loaded partition; if the first target partition is upgraded successfully and the other target partition is upgraded unsuccessfully, setting the first target partition as the first to-be-loaded partition and setting the other main partition as the other to-be-loaded partition; if the first target partition is upgraded unsuccessfully and the other target partition is upgraded successfully, setting the first main partition as the first to-be-loaded partition and setting the other target partition as the other to-be-loaded partition.
[0014] Optionally, the first to-be-loaded partition has partition indication information; the setting one of the first target partition or the first main partition as the first to-be-loaded partition comprises: assigning the partition indication information of the first to-be-loaded partition as one of a first value or a second value; wherein, when the first value is assigned, the first to-be-loaded partition is the first main partition, and when the second value is assigned, the first to-be-loaded partition is the first target partition.
[0015] Optionally, the other target partition and the other main partition have respective loading priority indication information; the setting the other target partition or the other main partition as the other to-be-loaded partition comprises: assigning the loading priority indication information of the other main partition as a third value and assigning the loading priority indication information of the other target partition as a fourth value; wherein, when the third value is greater than the fourth value, the other to-be-loaded partition is the other main partition, and when the third value is less than the fourth value, the other to-be-loaded partition is the other target partition; wherein, the greater the value of the loading priority indication information, the higher the loading priority in the restart process.
[0016] Optionally, the determining the first type of image data and the second type of image data comprises: in response to receiving an OTA upgrade instruction, downloading an upgrade package; and parsing the upgrade package to obtain the first type of image data and the second type of image data.
[0017] The embodiment of the present application also provides an OTA upgrading device of a terminal device, comprising: a mirror data determining module, configured to determine first mirror data and second mirror data; a target partition upgrading module, configured to perform OTA upgrading on a first target partition by using the first mirror data, and perform OTA upgrading on other target partitions by using the second mirror data; a loading partition setting module, configured to set one of the first target partition or a first main partition as a first to-be-loaded partition, and set the other target partitions or other main partitions as other to-be-loaded partitions according to an upgrading result; a partition loading module, configured to perform pre-restart on the terminal device, and judge whether the type of the first to-be-loaded partition and the type of the other to-be-loaded partition are consistent during the restart process; an upgrading abnormality judging module, configured to confirm that the OTA upgrading is abnormal if the type of the first to-be-loaded partition and the type of the other to-be-loaded partition are not consistent; and a loading partition changing module, configured to change the type of the first to-be-loaded partition to be consistent with the type of the other to-be-loaded partition according to the type of the other to-be-loaded partition, and then restart the terminal device.
[0018] The embodiment of the present application also provides a readable storage medium, which stores a computer program, and the computer program is run by a processor to execute the steps of the OTA upgrading method of the terminal device.
[0019] The embodiment of the present application also provides a terminal, comprising a memory and a processor, wherein the memory stores a computer program capable of being run on the processor, and the processor executes the steps of the OTA upgrading method of the terminal device when running the computer program.
[0020] Compared with the prior art, the technical scheme of the embodiment of the present application has the following beneficial effects:
[0021] The embodiment of the present application provides an OTA upgrading method of a terminal device, which adopts a dual-partition upgrading scheme, and specifically, after upgrading a first target partition and other target partitions in an OTA upgrading process, one of the first target partition or a first main partition is set as a first to-be-loaded partition, and the other target partitions or other main partitions are set as other to-be-loaded partitions according to an upgrading result; then the terminal device is pre-restarted, and whether the OTA upgrading is abnormal is judged according to whether the type of the first to-be-loaded partition and the type of the other to-be-loaded partition are consistent (if the types are not consistent, it is confirmed that the OTA upgrading is abnormal); then the type of the first to-be-loaded partition is changed to be consistent with the type of the other to-be-loaded partition, and the terminal device is restarted.
[0022] In the embodiment of the present application, since the to-be-loaded partition can be set (or selected) according to the upgrade result, and then based on the inconsistency of the type of the set to-be-loaded partition, it is confirmed that the OTA upgrade is abnormal, and then the to-be-loaded partition type is changed to restart the terminal device, for example, the to-be-loaded partition can be changed to master partition, so that after restarting, it can be rolled back to the system before the OTA upgrade, thereby preventing the terminal device from becoming a brick.
[0023] Further, if the set first to-be-loaded partition is the first target partition, and the set other to-be-loaded partition is the other target partition, the terminal device is restarted to load the first target partition and the other target partition, and to attempt to enter the system after the OTA upgrade. In the embodiment of the present application, if the type of the set first to-be-loaded partition and the other to-be-loaded partition is the target partition, it can be confirmed that the OTA upgrade of the first target partition and the other target partition is normal. In this case, the terminal device can be restarted to load the first target partition and the other target partition, and to attempt to enter the system after the OTA upgrade.
[0024] Further, if the attempt to enter the system after the OTA upgrade fails, the terminal device is restarted and attempts to enter the system after the OTA upgrade, until the number of restarts reaches a preset threshold, confirming that the OTA upgrade fails; the first to-be-loaded partition is changed from the first target partition to the first master partition, and the other to-be-loaded partition is changed from the other target partition to the other master partition; the terminal device is restarted again to load the first master partition and the other master partition, and to roll back to the system before the OTA upgrade.
[0025] In the embodiment of the present application, even if the OTA upgrade of the first target partition and the other target partition is normal, various abnormal situations may occur in the subsequent boot process, resulting in failure to successfully enter the system after the OTA upgrade. In this case, through the above restart mechanism, the terminal device has a certain opportunity to attempt to restart, which can avoid boot failure caused by accidental factors. Only when multiple attempts to restart fail, it is confirmed that the OTA upgrade fails, and then the to-be-loaded partition is changed (i.e., the first to-be-loaded partition is changed to the first master partition, and the other to-be-loaded partition is changed to the other master partition), and the terminal device is restarted to roll back to the system before the OTA upgrade, thereby solving the problem of the terminal device becoming a brick. BRIEF DESCRIPTION OF DRAWINGS
[0026] Figure 1 is a flowchart of an OTA upgrade method of a terminal device in the embodiment of the present application;
[0027] Figure 2 isFigure 1 a flow chart of one specific implementation of step S16;
[0028] Figure 3 is Figure 1 a flow chart of another specific implementation of step S16;
[0029] Figure 4 is a part of flow chart of another OTA upgrade method of terminal device in embodiments of the present application;
[0030] Figure 5 is a structural schematic diagram of an OTA upgrade apparatus of terminal device in embodiments of the present application. DETAILED DESCRIPTION
[0031] As described in the background, in the OTA upgrade process, after unpacking and verifying the upgrade package downloaded from the server, the SPL image data in the upgrade package is often used to upgrade the main SPL partition or SPL_BAK partition on the Boot hardware partition, and the UserData image data in the upgrade package is often used to upgrade the slotA partition or slot B partition on the UserData hardware partition.
[0032] In the prior art, for some old processor chips that do not support V-AB system, after the OTA upgrade is completed, the terminal device cannot be loaded with the main SPL partition and the SPL_BAK partition on the Boot hardware partition during the restart process of the terminal device. However, in this case, if the OTA upgrade process is interrupted abnormally, it is difficult to ensure that the program version of the SPL_BAK partition (first target partition) is consistent with the program version of the slot B partition (other target partition). For example, in the OTA upgrade process, the SPL_BAK partition is successfully upgraded by using the new version of SPL image data, but the upgrade of the slot B partition fails by using the same version of UserData image data, which causes the terminal device to fail to normally boot into the system after the OTA upgrade during the restart process of the terminal device. Since the terminal device cannot be loaded with the selected partition, it is also impossible to roll back to the system before the OTA upgrade when the terminal device fails to enter the system after the OTA upgrade, thereby causing the terminal device to become a brick.
[0033] To solve the above technical problems, the embodiment of the present application provides an OTA upgrade method of a terminal device, which specifically comprises: determining first type mirror image data and second type mirror image data; using the first type mirror image data to perform OTA upgrade on a first target partition, and using the second type mirror image data to perform OTA upgrade on other target partitions; according to an upgrade result, setting one of the first target partition or a first main partition as a first to-be-loaded partition, and setting the other target partitions or other main partitions as other to-be-loaded partitions; pre-restarting the terminal device, and judging whether the type of the first to-be-loaded partition and the type of the other to-be-loaded partition are consistent in a restarting process; if the type of the first to-be-loaded partition and the type of the other to-be-loaded partition are inconsistent, confirming that the OTA upgrade is abnormal; and changing the type of the first to-be-loaded partition to be consistent with the type of the other to-be-loaded partition according to the type of the other to-be-loaded partition, and then restarting the terminal device.
[0034] From the above, in the embodiment of the present application, in the OTA upgrade process using the dual-partition scheme, because the to-be-loaded partition can be set (or selected) according to the upgrade result, and then based on the inconsistency of the types of the set to-be-loaded partitions, it is confirmed that the OTA upgrade is abnormal, and then the terminal device is restarted after the types of the to-be-loaded partitions are changed to be consistent, for example, the to-be-loaded partitions can all be changed to main partitions, so that after the restart, the system before the OTA upgrade can be rolled back, and the terminal device can be prevented from being bricked.
[0035] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the specific embodiments of the present application will be described in detail below with reference to the drawings.
[0036] Reference Figure 1 , Figure 1 is a flowchart of an OTA upgrade method of a terminal device in the embodiment of the present application. The method can be applied to a terminal device installed or configured with an Android system and having an OTA upgrade function, and the terminal device can include, for example, a mobile phone, a tablet computer, a vehicle-mounted terminal, a smart wearable terminal (for example, a smart watch), and the like.
[0037] The method can include steps S11 to S16:
[0038] Step S11: determining first type mirror image data and second type mirror image data;
[0039] Step S12: using the first type mirror image data to perform OTA upgrade on a first target partition, and using the second type mirror image data to perform OTA upgrade on other target partitions;
[0040] Step S13: according to the upgrade result, setting one of the first target partition or the first main partition as a first to-be-loaded partition, and setting the other target partition or the other main partition as other to-be-loaded partitions;
[0041] Step S14: pre-restarting the terminal device, and judging whether the type of the first to-be-loaded partition and the type of the other to-be-loaded partition are consistent in the restarting process;
[0042] Step S15: if the type of the first to-be-loaded partition and the type of the other to-be-loaded partition are inconsistent, confirming that the OTA upgrade is abnormal;
[0043] Step S16: according to the type of the other to-be-loaded partition, changing the type of the first to-be-loaded partition to be consistent with the type of the other to-be-loaded partition, and then restarting the terminal device.
[0044] In the implementation of step S11, the determining of the first type of image data and the second type of image data can include: in response to receiving an OTA upgrade instruction, downloading an upgrade package; and parsing the upgrade package to obtain the first type of image data and the second type of image data.
[0045] The upgrade package can be a software package of an updated version downloaded from an OTA upgrade server. Before parsing the upgrade package, signature verification can be performed on the upgrade package. If the verification is passed, the parsing is performed; if the verification fails, the upgrade process can be directly stopped.
[0046] In the implementation of step S12, as an example, the first type of image data can be SPL image data; the second type of image data can be UserData data; the first main partition and the first target partition are software partitions based on a Boot hardware partition of the terminal device; and the other main partition and the other target partition are software partitions based on a UserData hardware partition of the terminal device.
[0047] The Boot hardware partition and the UserData (UDA) hardware partition can be two main hardware partitions divided on a non-volatile memory / erasable memory (Flash Memory) (equivalent to a hard disk) of the terminal device.
[0048] The User Data hardware partition is a region in which a user can read and write storage, is a core storage region in an embedded multi media card (EMMC), and has a space size of about 93% of the size of the entire EMMC space. The EMMC can be mainly divided into three parts: a non-volatile memory (Flash Memory), a non-volatile controller (Flash Controller), and a host interface (Host Interface).
[0049] The Boot hardware partition is another important storage region on the Flash Memory, and can be divided into two sub-hardware partitions: Boot1 and Boot2. The Boot hardware partition has better storage stability, reliability, and erasing times than the User Data hardware partition, and is thus often used to store some critical data (for example, SPL image data).
[0050] The first main partition (base partition) divided based on the Boot hardware partition can be a partition in which system data before upgrading is stored (for example, can include a main SPL partition), and the first target partition is a partition to be upgraded (for example, can include an SPL_BAK partition). Other main partitions divided based on the User Data hardware partition can include: an Sml_a partition, an Uboot_a partition, a Dtbo_a partition, a Socko_a partition, and the like; and the other target partitions can include an Sml_b partition, an Uboot_b partition, a Dtbo_b partition, a Socko_b partition, and the like.
[0051] In the process of OTA upgrading, the first type of image data (for example, SPL image data) is usually written into the first target partition (for example, the SPL_BAK partition and the like); and the second type of image data (for example, User Data image data) is usually written into the other target partitions (for example, the Sml_b partition, the Uboot_b partition, the Dtbo_b partition, and the like).
[0052] It should be noted that the above-mentioned partitions and their names are only non-limiting examples, and do not constitute a limitation on the specific number and names of the partitions of the terminal device in actual applications.
[0053] In the implementation of step S13, the first to-be-loaded partition can be a partition that is loaded first in the booting process of the terminal device, and the other to-be-loaded partition can be a partition that is loaded later in the booting process of the terminal device.
[0054] Further, the upgrade result in the step S13 and the set first to-be-loaded partition and other to-be-loaded partition can be selected from any one of the following four cases.
[0055] Case one: if the first target partition and the other target partition are both upgraded successfully, the first target partition is set as the first to-be-loaded partition, and the other target partition is set as the other to-be-loaded partition;
[0056] Case two: if the first target partition and the other target partition are both upgraded unsuccessfully, the first main partition is set as the first to-be-loaded partition, and the other main partition is set as the other to-be-loaded partition;
[0057] Case three: if the first target partition is upgraded successfully and the other target partition is upgraded unsuccessfully, the first target partition is set as the first to-be-loaded partition, and the other main partition is set as the other to-be-loaded partition;
[0058] Case four: if the first target partition is upgraded unsuccessfully and the other target partition is upgraded successfully, the first main partition is set as the first to-be-loaded partition, and the other target partition is set as the other to-be-loaded partition.
[0059] In a specific implementation, the first to-be-loaded partition can have partition indication information, and the other main partition and the other target partition can respectively have respective loading priority indication information.
[0060] Further, the step of setting one of the first target partition or the first main partition as the first to-be-loaded partition in the step S13 can include: assigning partition indication information of the first to-be-loaded partition as one of a first value or a second value; when the first value is assigned, the first to-be-loaded partition is the first main partition, and when the second value is assigned, the first to-be-loaded partition is the first target partition.
[0061] Further, the step of setting the other target partition or the other main partition as the other to-be-loaded partition in the step S13 can include: assigning loading priority indication information of the other main partition as a third value, and assigning loading priority indication information of the other target partition as a fourth value; when the third value is greater than the fourth value, the other to-be-loaded partition is the other main partition, and when the third value is less than the fourth value, the other to-be-loaded partition is the other target partition; the greater the value of the loading priority indication information, the higher the loading priority in the restart process (specifically, the greater the value of the loading priority indication information, the partition to which the loading priority indication information with the greater value belongs is loaded preferentially in the restart process).
[0062] As a non-limiting example, the partition indication information of the first to-be-loaded partition can be stored in a first structure, and the loading priority indication information of the other main partition and the loading priority indication information of the other target partition can be stored in a second structure and a third structure, respectively.
[0063] For example, the SPL image data signature header SPLHeader structure can be used as the first structure, and the value of the slot member in the first structure can be used as the partition indication information of the first to-be-loaded partition. When the slot is assigned a first value (e.g., 1), the first to-be-loaded partition is a first main partition; when the slot is assigned a second value (e.g., 2), the first to-be-loaded partition is a first target partition.
[0064] For example, the bootloader_control structure data stored in the MISC partition can be used to indicate the slot of the loading partition, and the loading priority indication information (also referred to as loading information) of the other main partition and the other target partition can be recorded in the slot_metadata structure array in the structure data. For convenience of description, the slot_metadata structure recording the loading priority indication information of the other main partition is referred to as a second structure, and the slot_metadata structure recording the loading priority indication information of the other target partition is referred to as a third structure.
[0065] Specifically, the value of the priority member in the second structure can be used as the loading priority indication information of the other main partition, and the value of the priority member in the third structure can be used as the loading priority indication information of the other target partition. When the value of the priority member in the second structure is greater than the value of the priority member in the third structure, the other to-be-loaded partition is the other main partition; when the value of the priority member in the second structure is less than the value of the priority member in the third structure, the other to-be-loaded partition is the other target partition. The greater the value of the priority member, the higher the loading priority of the corresponding slot partition in the startup loading process.
[0066] In the implementation of step S14, the terminal device is pre-restarted, and it is determined whether the type of the first to-be-loaded partition and the type of the other to-be-loaded partition loaded in the restarting process are consistent.
[0067] In practical applications, as mentioned earlier, the step of setting the first partition to be loaded and other partitions to be loaded based on the upgrade result can be achieved by assigning values to partition indication information or loading priority indication information. However, the assignment operation may encounter anomalies or failures, making it impossible to confirm whether the OTA upgrade is abnormal. Therefore, by pre-rebooting the terminal device and verifying whether the assignment was successful during the reboot process, it is possible to determine whether the type of the first partition to be loaded is consistent with that of the other partitions to be loaded. This allows for an accurate and effective determination of whether an OTA upgrade is abnormal.
[0068] In the specific implementation of step S15, the primary partition and the target partition can be divided by type. If the first partition to be loaded and the other partitions to be loaded are both primary partitions or both are target partitions, they can be considered to be of the same type. If one of the first partition to be loaded and the other partitions to be loaded is a primary partition and the other is a target partition, they can be considered to be of different types.
[0069] If the type of the first partition to be loaded is inconsistent with the types of the other partitions to be loaded, it indicates that there is an anomaly in the OTA upgrade process. In this case, directly restarting the terminal device may cause the terminal device to become bricked.
[0070] In the specific implementation of step S16, if the other partitions to be loaded are other primary partitions or other target partitions based on the UserData hardware partition, it is often necessary to change the first partition to be loaded to be of the same type as the other partitions to be loaded, and then restart the terminal device.
[0071] Reference Figure 2 , Figure 2 yes Figure 1 A flowchart illustrating a specific implementation of step S16. In this embodiment of the invention, step S16 may specifically include steps S21 to S22.
[0072] In step S21, if the other partition to be loaded is another primary partition, then the first partition to be loaded is changed from the first target partition to the first primary partition.
[0073] In specific implementation, it can be referred to Figure 1 In the embodiment provided in step S13, the value of the partition indication information of the first partition to be loaded (e.g., the value of the slot member in the first structure) is changed from a second value to a first value, thereby changing the first partition to be loaded from the first target partition to the first primary partition (e.g., changing from the SPL_BAK partition to the primary SPL partition).
[0074] In step S22, the terminal device is restarted to load the first master partition and the other master partition and rollback to the system before the OTA upgrade.
[0075] Referring to Figure 3 , Figure 3 is Figure 1 a flowchart of another specific implementation of step S16 in the method. In the embodiment of the application, step S16 can include steps S31-S32.
[0076] In step S31, if the other to-be-loaded partition is the other target partition, the first to-be-loaded partition is changed from the first master partition to the first target partition.
[0077] In the implementation, the value of the partition indication information (for example, the value of the slot member in the first structure) of the first to-be-loaded partition can be changed from the first value to the second value to change the first to-be-loaded partition from the first master partition to the first target partition, as provided in the embodiment of step S13 in Figure 1 .
[0078] In step S32, the terminal device is restarted to load the first target partition and the other target partition and attempt to enter the system after the OTA upgrade.
[0079] Further, if the set first to-be-loaded partition is the first target partition and the set other to-be-loaded partition is the other target partition (indicating that the upgrades of the first target partition and the other target partition are both normal), the terminal device can be restarted to load the first target partition and the other target partition and attempt to enter the system after the OTA upgrade.
[0080] Referring to Figure 4 , Figure 4 is a partial flowchart of another OTA upgrade method of a terminal device in the embodiment of the application. The another OTA upgrade method of the terminal device can include steps S11-S14 shown in Figure 1 , further include steps S31-S32 shown in Figure 3 , and further include steps S41-S44. The steps S41-S44 can be executed after step S32.
[0081] In step S41, it is determined whether the attempt to enter the system after the OTA upgrade is successful.
[0082] If the judgment result is no, that is, if the attempt to enter the system after the OTA upgrade fails, steps S42 to S44 can be continued to execute; if the judgment result is yes, that is, if the attempt to enter the system after the OTA upgrade succeeds, it can be confirmed that the OTA upgrade of the first target partition and other target partitions succeeds.
[0083] In specific implementation, after it is confirmed that the OTA upgrade of the first target partition and other target partitions succeeds, the subsequent process in the OTA upgrade can be continued, for example, the updated version data in the first target partition and other target partitions after the upgrade can be used to overwrite the old version data of the corresponding first main partition and other main partition, so as to complete the dual-partition upgrade of the entire system of the terminal device.
[0084] In step S42, the terminal device is restarted and the attempt to enter the system after the OTA upgrade is performed repeatedly until the number of restarts reaches a preset threshold, and it is confirmed that the OTA upgrade fails.
[0085] In specific implementation, the preset threshold can be set according to actual application needs, for example, any appropriate number between 8 and 15 times can be set.
[0086] In step S43, the first to-be-loaded partition is changed from the first target partition to the first main partition, and the other to-be-loaded partition is changed from the other target partition to the other main partition.
[0087] In step S44, the terminal device is restarted again to load the first main partition and the other main partition, and to roll back to the system before the OTA upgrade.
[0088] In the embodiment of the application, even if the OTA upgrades of the first target partition and the other target partition are both normal, various abnormal situations (for example, there are loading abnormal situations in the Uboot or kernel process) can occur in the subsequent boot process, which can cause the terminal device to fail to enter the system after the OTA upgrade successfully. In this case, through the above-mentioned restart mechanism, the terminal device has a certain opportunity to attempt to restart, which can avoid the boot failure caused by accidental factors. Only when multiple attempts to restart all fail, it is confirmed that the OTA upgrade fails, and then the partition rollback (that is, the first to-be-loaded partition is changed to the first main partition, and the other to-be-loaded partition is changed to the other main partition) is performed, and the terminal device is restarted again to roll back to the system before the OTA upgrade, so that the terminal device brick problem can be solved.
[0089] In specific implementation, as to Figure 4 More details of the OTA upgrade method of another terminal device in the embodiment shown in the above table can be referred to the foregoing and the following. Figures 1 to 3The related description of the OTA upgrade method of the terminal device is shown above, and will not be repeated here.
[0090] Figure 5 is a structural schematic diagram of an OTA upgrade device of a terminal device in an embodiment of the present application. The device can include:
[0091] The mirror image data determination module 51 is configured to determine the first type of mirror image data and the second type of mirror image data.
[0092] The target partition upgrade module 52 is configured to perform OTA upgrade on the first target partition using the first type of mirror image data, and perform OTA upgrade on the other target partitions using the second type of mirror image data.
[0093] The loading partition setting module 53 is configured to set one of the first target partition or the first main partition as a first to-be-loaded partition according to the upgrade result, and set the other target partition or the other main partition as another to-be-loaded partition.
[0094] The partition loading module 54 is configured to perform pre-restart on the terminal device, and determine whether the type of the first to-be-loaded partition and the type of the other to-be-loaded partition are consistent in the restart process.
[0095] The upgrade exception determination module 55 is configured to determine that there is an exception in the OTA upgrade if the type of the first to-be-loaded partition and the type of the other to-be-loaded partition are inconsistent.
[0096] The loading partition changing module 56 is configured to change the type of the first to-be-loaded partition to be consistent with the type of the other to-be-loaded partition according to the type of the other to-be-loaded partition, and then restart the terminal device.
[0097] In specific implementation, Figure 5 The OTA upgrade device of the terminal device shown can correspond to a chip with a data processing function in the terminal; or correspond to a chip or a chip module with a data processing function in the terminal, or correspond to the terminal.
[0098] For the principle, specific implementation, and beneficial effects of the OTA upgrade device of the terminal device, please refer to the foregoing and Figures 1 to 4 The related description of the OTA upgrade method of the terminal device is shown above, and will not be repeated here.
[0099] The present application also provides a readable storage medium, for example, a computer readable storage medium, which stores a computer program. When the computer program is run by a processor, the above-mentioned Figures 1 to 4The steps of the OTA upgrade method of the terminal device shown. The computer readable storage medium can include a non-volatile or non-transitory memory, and can also include an optical disc, a mechanical hard disk, a solid state disk, etc.
[0100] Specifically, in the embodiments of the present application, the processor can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.
[0101] It should also be understood that the memory in the embodiments of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM) or flash memory. The volatile memory can be random access memory (RAM) used as an external cache. By way of example, but not by way of limitation, many forms of random access memory (RAM) are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct memory bus random access memory (DR RAM).
[0102] The embodiments of the present application also provide a terminal device, comprising a memory and a processor, the memory stores a computer program capable of running on the processor, and the processor executes the steps of the OTA upgrade method of the terminal device shown above when running the computer program. The terminal device can include but is not limited to a mobile phone, a tablet computer, a vehicle-mounted terminal, a smart wearable terminal device configured or installed with an Android system. Figures 1 to 4 The terminal device can include but is not limited to a mobile phone, a tablet computer, a vehicle-mounted terminal, a smart wearable terminal device configured or installed with an Android system.
[0103] Specifically, the terminal in the embodiments of the present application can refer to various forms of user equipment (UE for short) installed or configured with an Android system, access terminal, user unit, user station, mobile station, mobile station (MS for short), remote station, remote terminal, mobile device, user terminal, terminal equipment, wireless communication device, user agent or user device. The terminal equipment can also be a cellular phone, a cordless phone, a Session Initiation Protocol (SIP for short) phone, a Wireless Local Loop (WLL for short) station, a Personal Digital Assistant (PDA for short), a handheld device with wireless communication function, a computing device or other processing device connected to a wireless modem, a vehicle-mounted device, a wearable device, a terminal device in a future 5G network or a terminal device in a future evolved Public Land Mobile Network (PLMN for short), etc., and the embodiments of the present application are not limited thereto.
[0104] In addition, each of the functional units in the various embodiments of the present application can be integrated in one processing unit, or each unit can be physically included separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a hardware plus software function unit. For example, for each device or product applied to or integrated in a chip, each module / unit contained therein can be realized in the form of a circuit or hardware, or at least part of the modules / units can be realized in the form of a software program running on a processor integrated in the chip, and the remaining (if any) part of the modules / units can be realized in the form of a circuit or hardware; for each device or product applied to or integrated in a chip module, each module / unit contained therein can be realized in the form of a circuit or hardware, and different modules / units can be located in the same component (for example, a chip, a circuit module, etc.) or different components of the chip module, or at least part of the modules / units can be realized in the form of a software program running on a processor integrated in the chip module, and the remaining (if any) part of the modules / units can be realized in the form of a circuit or hardware; for each device or product applied to or integrated in a terminal, each module / unit contained therein can be realized in the form of a circuit or hardware, and different modules / units can be located in the same component (for example, a chip, a circuit module, etc.) or different components of the terminal, or at least part of the modules / units can be realized in the form of a software program running on a processor integrated in the terminal, and the remaining (if any) part of the modules / units can be realized in the form of a circuit or hardware.
[0105] It should be understood that the term "and / or" herein merely describes an association relationship of associated objects, and indicates that there can be three relationships, for example, A and / or B can represent three cases of A alone, A and B together, and B alone. In addition, the character " / " herein represents an "or" relationship between the front and rear associated objects.
[0106] "Multiple" appearing in the embodiments of the present application means two or more.
[0107] The first, second, and the like appearing in the embodiments of the present application are only for illustrative and distinguishing purposes, and do not have an order, nor represent a special limitation on the number of devices in the embodiments of the present application, and cannot constitute any limitation on the embodiments of the present application.
[0108] It should be noted that the serial numbers of the steps in the embodiments do not represent a limitation on the execution order of the steps.
[0109] Although the present application has been disclosed with reference to the above embodiments, the application is not limited to the above embodiments. It will be apparent to those skilled in the art that various modifications and changes can be made thereto without departing from the spirit and scope of the application. The scope of the application should be limited only by the appended claims.
Claims
1. A method for OTA upgrade of a terminal device, characterized in that, The method comprises the following steps: determining first type of mirror data and second type of mirror data, wherein the first type of mirror data is SPL mirror data, and the second type of mirror data is UserData mirror data; using the first type of mirror data to perform OTA upgrade on a first target partition, and using the second type of mirror data to perform OTA upgrade on other target partitions; according to an upgrade result, setting one of the first target partition or a first main partition as a first to-be-loaded partition, and setting other target partitions or other main partitions as other to-be-loaded partitions; pre-restarting the terminal device, and judging whether the type of the first to-be-loaded partition and the type of the other to-be-loaded partition are consistent in a restarting process, wherein the type is used to divide main partitions and target partitions; if the type of the first to-be-loaded partition and the type of the other to-be-loaded partition are inconsistent, confirming that the OTA upgrade is abnormal; according to the type of the other to-be-loaded partition, changing the type of the first to-be-loaded partition to be consistent with the type of the other to-be-loaded partition, and then restarting the terminal device; wherein the first main partition and the first target partition are software partitions based on a Boot hardware partition of the terminal device; the other main partition and the other target partition are software partitions based on a UserData hardware partition of the terminal device; the target partition is a to-be-upgraded partition, and the main partition is a partition where system data before upgrade is located.
2. The method of claim 1, wherein, According to the type of the other to-be-loaded partition, changing the type of the first to-be-loaded partition to be consistent with the type of the other to-be-loaded partition, and then restarting the terminal device, comprising: if the other to-be-loaded partition is the other main partition, changing the first to-be-loaded partition from the first target partition to the first main partition; restarting the terminal device to load the first main partition and the other main partition, and rolling back to the system before OTA upgrade.
3. The method of claim 1, wherein, According to the type of the other to-be-loaded partition, changing the type of the first to-be-loaded partition to be consistent with the type of the other to-be-loaded partition, and then restarting the terminal device, comprising: if the other to-be-loaded partition is the other target partition, changing the first to-be-loaded partition from the first main partition to the first target partition; restarting the terminal device to load the first target partition and the other target partition, and attempting to enter the system after OTA upgrade.
4. The method of claim 1, wherein, Further comprising: if the set first to-be-loaded partition is the first target partition, and the set other to-be-loaded partition is the other target partition, restarting the terminal device to load the first target partition and the other target partition, and attempting to enter the system after OTA upgrade.
5. The method according to claim 3 or 4, characterized in that, if the attempt to enter the system after OTA upgrade fails, restarting the terminal device and attempting to enter the system after OTA upgrade in a loop until the number of restarts reaches a preset threshold, and confirming that the OTA upgrade fails; change the first to-be-loaded partition from the first target partition to a first main partition, and change the other to-be-loaded partition from the other target partition to a other main partition; restarting the terminal device to load the first main partition and the other main partition and roll back to the system before the OTA upgrade.
6. The method of claim 1, wherein, The setting of one of the first target partition or the first main partition as the first to-be-loaded partition and the setting of the other target partition or the other main partition as the other to-be-loaded partition include: If the first target partition and the other target partition are both upgraded successfully, the first target partition is set as the first to-be-loaded partition, and the other target partition is set as the other to-be-loaded partition; If the first target partition and the other target partition are both upgraded unsuccessfully, the first main partition is set as the first to-be-loaded partition, and the other main partition is set as the other to-be-loaded partition; If the first target partition is upgraded successfully and the other target partition is upgraded unsuccessfully, the first target partition is set as the first to-be-loaded partition, and the other main partition is set as the other to-be-loaded partition; If the first target partition is upgraded unsuccessfully and the other target partition is upgraded successfully, the first main partition is set as the first to-be-loaded partition, and the other target partition is set as the other to-be-loaded partition.
7. The method of claim 1, wherein, The first to-be-loaded partition has partition indication information; The setting of one of the first target partition or the first main partition as the first to-be-loaded partition includes: The partition indication information of the first to-be-loaded partition is assigned one of a first value or a second value; When the first value is assigned, the first to-be-loaded partition is the first main partition, and when the second value is assigned, the first to-be-loaded partition is the first target partition.
8. The method of claim 1, wherein, The other target partition and the other main partition have respective loading priority indication information; The setting of the other target partition or the other main partition as the other to-be-loaded partition includes: The loading priority indication information of the other main partition is assigned a third value, and the loading priority indication information of the other target partition is assigned a fourth value; When the third value is greater than the fourth value, the other to-be-loaded partition is the other main partition, and when the third value is less than the fourth value, the other to-be-loaded partition is the other target partition; The greater the value of the loading priority indication information, the higher the loading priority in the restarting process.
9. The method of claim 1, wherein, The determination of the first type of image data and the second type of image data includes: In response to receiving an OTA upgrade instruction, downloading an upgrade package; Parsing the upgrade package to obtain the first type of image data and the second type of image data.
10. An OTA upgrade apparatus of a terminal device, characterized by comprising: It includes: An image data determination module is configured to determine first type of image data and second type of image data, wherein the first type of image data is SPL image data, and the second type of image data is User Data image data; a target partition upgrading module, configured to perform OTA upgrading on a first target partition by using the first type of image data, and perform OTA upgrading on other target partitions by using the second type of image data; a loading partition setting module, configured to set one of the first target partition or the first main partition as a first to-be-loaded partition, and set the other target partition or the other main partition as another to-be-loaded partition according to the upgrading result; a partition loading module, configured to perform pre-restarting on the terminal device, and determine whether the type of the first to-be-loaded partition and the type of the other to-be-loaded partition are consistent in the restarting process, wherein the type is used to divide the main partition and the target partition; an upgrading exception judging module, configured to confirm that the OTA upgrading is abnormal if the type of the first to-be-loaded partition and the type of the other to-be-loaded partition are inconsistent; a loading partition changing module, configured to change the type of the first to-be-loaded partition to be consistent with the type of the other to-be-loaded partition according to the type of the other to-be-loaded partition, and then restart the terminal device; wherein the first main partition and the first target partition are software partitions based on a Boot hardware partition of the terminal device; the other main partition and the other target partition are software partitions based on a UserData hardware partition of the terminal device; the target partition is a partition to be upgraded, and the main partition is a partition where system data before upgrading is located.
11. A readable storage medium, having stored thereon a computer program, characterized in that, The computer program is run by the processor to perform the steps of the OTA upgrading method of the terminal device in any one of claims 1 to 9. 12.A terminal device, comprising a memory and a processor, wherein the memory stores a computer program capable of running on the processor, and the computer program comprises the following steps of: The processor runs the computer program to perform the steps of the OTA upgrading method of the terminal device in any one of claims 1 to 9.
Citation Information
Patent Citations
Firmware upgrading method, system and device and computer readable storage medium
CN110502262A
Automobile combination instrument rollback starting method, device and equipment and storage medium
CN111638999A