Terminal device and upgrade method thereof
By setting the second partition table space and read identifier in the storage space of the terminal device, the problem that system upgrades in the prior art do not support partition adjustments is solved, and the convenience and reliability of system upgrades are achieved.
Patent Information
- Application Number
- CN202310859730.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-12
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2043-07-12
AI Technical Summary
Existing terminal devices do not support partition adjustments when system upgrades, resulting in complex and inconvenient system upgrade process.
By setting the second partition table space in the storage space of the terminal device, storing the second partition table in the system upgrade package, and setting a read identifier in the table header of the main partition table, adjusting and upgrading the startup partition is achieved.
It supports adjusting the boot partition during system upgrade to ensure that the system upgrade is successful and can be rolled back to the original partition table in case of failure, avoiding the risk of the system being unable to restart.
Smart Images

Figure CN117707565B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of terminal equipment, and in particular to a terminal equipment and an upgrade method thereof. Background Art
[0002] The storage space of the terminal device is divided into multiple partitions and areas to store different partition files. The partition table records the information of each partition and area (including the partition size, the starting position of the partition, etc.), and the partition table is usually stored in a fixed position in the device storage space. Partitions are divided into several categories according to their functions, such as basic partitions, boot partitions (boot, bootloader), system partitions (super), and data partitions (userdata). Among them, the basic partition stores basic information such as operating system logs and calibration parameters, the bootlaoder partition stores system boot files, the boot partition stores the operating system kernel, the super partition stores the system files of the Android system, and the userdata partition stores various files of the terminal device (user files, application files, etc.), users and user data, etc. The partition content loading during the operating system startup process or operation process must first obtain the starting position and size of the partition from the partition table.
[0003] Existing terminal devices using virtual AB partitions (including boot partition A and boot partition B) support upgrading the AB partitions and system partition contents through Over-the-Air Technology (OTA), but do not support partition adjustment (including partition deletion, addition, and partition size adjustment). System upgrades that require partition adjustment (e.g., boot partition) can only be done through other non-OTA system upgrade methods, first updating the partition table to complete the re-division of the terminal device's storage space, and then completing the upgrade of each partition based on the new partition table, which brings inconvenience to the system upgrade. Summary of the invention
[0004] The present application provides a terminal device and an upgrading method thereof.
[0005] In a first aspect, an embodiment of the present application provides an upgrade method, which is applied to a terminal device, wherein the storage space of the terminal device includes a first boot partition, a second boot partition, a system partition, a first partition table space, and a second partition table space, and the method includes:
[0006] The terminal device is started through the first boot partition based on the first partition table contained in the first partition table space;
[0007] Obtain a system upgrade package, wherein the system upgrade includes a second partition table and partition upgrade data corresponding to a target software version, and the boot partition information in the second partition table is different from the boot partition information in the first partition table; based on the second partition table and the partition upgrade data, update data of a second boot partition and a system partition; based on the second partition table of the second partition table space, start the terminal device through the second boot partition.
[0008] In the present application, the terminal device here may include various terminal devices that support the virtual AB system, such as: mobile phones, tablet computers, etc. The first partition table space here may be a main partition table space, storing a first partition table, that is, a main partition table; the second partition table space stores a second partition table in the system upgrade package. The first boot partition and the second boot partition may be boot partition A and boot partition B. The operating system of the terminal device is started through the first boot partition, obtains the second partition table in the system upgrade package, compares the second partition table with the first partition table, and determines that the boot partition information in the second partition table is different from the boot partition information in the first partition table, that is, when the upgrade involves adjusting the boot partition, according to the second partition table, the partition upgrade data (also referred to as a partition upgrade file) in the system upgrade package is used to upgrade the boot partition B, that is, the data of the boot partition B is updated. After the upgrade, the operating system of the terminal device is started based on the second partition table stored in the second partition table space.
[0009] It can be seen that through the above method, the terminal device can support system upgrades that require adjustment of the boot partition. During the system upgrade process, the second partition table space is set to store the second partition table, so that after the system is upgraded, the upgrade can be completed by loading the second partition table and restarting. During the upgrade, the original main partition table is retained, which avoids the situation where once the main partition table is replaced with the second partition table, if the system upgrade fails or the restart fails, the existing boot partition is inconsistent with the boot partition recorded in the replaced second partition table, and the system cannot be restarted. Even if the system update fails or the system startup fails, the system can be rolled back to normal operation before the upgrade by loading the original main partition table.
[0010] In a possible implementation of the first aspect, the present invention further includes:
[0011] The second partition table is stored in the second partition table space, and a read identifier is set for the table header of the first partition table; the terminal device restarts through the second boot partition based on the second partition table in the second partition table space according to the read identifier.
[0012] In the present application, the second partition table is stored in the second partition table space, and an identifier for enabling the second partition table is set in the header of the main partition table, i.e., a read identifier. The read identifier indicates that the terminal device restarts, and when the main partition table is loaded, the boot partition information of the second boot partition in the second partition table is obtained according to the set identifier of the second partition table for restarting.
[0013] It can be seen that during the system upgrade process, by setting the second partition table space to store the second partition table and setting the second partition table identifier for the main partition table, the second partition table can be loaded for restart after the system is upgraded.
[0014] In a possible implementation of the first aspect, updating data of the second boot partition and the system partition based on the second partition table and the partition upgrade data includes:
[0015] The partition size or partition address of the second boot partition is adjusted based on the boot partition information in the second partition table; and the data of the second boot partition is updated using the partition upgrade data.
[0016] In the present application, the partition size or partition address of the second boot partition is adjusted according to the boot partition information in the second partition table, and the partition upgrade data (also referred to as the partition upgrade file) in the system upgrade package is used to update the data of the second boot partition.
[0017] In a possible implementation of the first aspect, the present invention further includes:
[0018] If the terminal device fails to start through the second boot partition based on the second partition table of the second partition table space, the partition size or partition address of the second boot partition is set based on the boot partition information of the second boot partition in the first partition table;
[0019] The data of the second boot partition is cleared, and the data of the first boot partition is written into the second boot partition.
[0020] In the present application, if the terminal device fails to boot through the second boot partition, the first boot partition can be used to restore the second boot partition. That is, the partition size or partition address of the second boot partition is adjusted using the boot partition information in the main partition table, and the data of the first boot partition is used to replace the data of the second boot partition, that is, the first boot partition and the second boot partition are synchronized, that is, the data of the second boot partition is cleared, and the data of the first boot partition is written into the second boot partition.
[0021] In a possible implementation of the first aspect, after the terminal device fails to start up through the second boot partition based on the second partition table of the second partition table space, the method further includes:
[0022] The read flag set in the header of the second partition table and the first partition table stored in the second partition table space is cleared, and an upgrade failure is prompted.
[0023] In the present application, after the second boot partition is restored, the second partition table stored in the second partition table space and the read flag set in the header of the first partition table may also be cleared.
[0024] In a possible implementation of the first aspect, the present invention further includes:
[0025] If the terminal device successfully boots through the second boot partition based on the second partition table of the second partition table space, adjust the partition size or partition address of the first boot partition based on the boot partition information in the second partition table;
[0026] The data of the first boot partition is cleared, and the data of the second boot partition is written into the first boot partition.
[0027] In the present application, if the terminal device successfully boots through the second boot partition, the second boot partition is used to merge the first boot partition, that is, the first boot partition is adjusted according to the boot partition information stored in the second partition table, and then the data of the second boot partition is used to synchronize the first boot partition, that is, the data of the first boot partition is cleared and the data of the second boot partition is written into the second boot partition, so that the data of the first boot partition is consistent with the data of the second boot partition.
[0028] In a possible implementation of the first aspect, the present invention further includes:
[0029] The boot partition information of the second partition table is used to update the boot partition information of the first partition table and the backup partition table.
[0030] In the present application, the second partition table in the second partition table space is used to replace the primary partition table stored in the first partition table space and the backup partition table stored in the backup partition table space as the new primary partition table and the backup partition table, that is, the second partition table is stored as the primary partition table and the backup partition table, that is, the boot partition information of the second partition table is used to update the boot partition information of the primary partition table and the backup partition table, so that the partition information stored in the primary partition table and the backup partition table is consistent with the partition information after the system upgrade.
[0031] In a possible implementation of the first aspect, the present invention further includes:
[0032] The read flag set in the header of the second partition table and the first partition table stored in the second partition table space is cleared, and a prompt indicating that the upgrade is successful is displayed.
[0033] In the present application, after the upgrade is completed, the read identifier set in the header of the second partition table and the first partition table stored in the second partition table space may also be cleared.
[0034] In a possible implementation of the first aspect, the present invention further includes:
[0035] If the terminal device fails to load the first partition table, the first partition table of the first partition table space is cleared, and the backup partition table of the backup partition table space is stored in the first partition table space as the first partition table.
[0036] In the present application, during the use of the terminal device, if the primary partition table is damaged, the backup partition table can be used to restore the first partition table, that is, the primary partition table.
[0037] In a second aspect, an embodiment of the present application provides a terminal device, including:
[0038] a memory for storing instructions to be executed by one or more processors of the terminal device, and
[0039] The processor is one of the processors of the terminal device and is used to execute the upgrading method of the first aspect.
[0040] In a third aspect, an embodiment of the present application provides a computer program product, comprising: a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium contains a computer program code for executing the upgrade method of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 A schematic diagram of updating a system partition of a storage space of a terminal device provided in an embodiment of the present application;
[0042] Figure 2 A schematic diagram of various partitions in the storage space of a terminal device provided in an embodiment of the present application;
[0043] Figure 3 A schematic diagram of various partitions in the storage space of a terminal device provided in an embodiment of the present application;
[0044] Figure 4 A schematic diagram of various partitions in the storage space of a terminal device provided in an embodiment of the present application;
[0045] Figure 5 A flowchart of an upgrade method provided in an embodiment of the present application;
[0046] Figure 6 A schematic diagram of a process for restarting a terminal device after the upgrade is completed provided in an embodiment of the present application;
[0047] Figure 7A schematic diagram of a process for updating partitions after a terminal device is restarted provided in an embodiment of the present application;
[0048] Figure 8 A schematic diagram of a process for restoring a terminal device provided in an embodiment of the present application;
[0049] Fig. 9 A schematic diagram of partition information in a storage space of a terminal device provided in an embodiment of the present application;
[0050] Fig.10 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application;
[0051] Fig.11 A software structure block diagram of the terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] The technical solutions in the embodiments of the present application will be described clearly and in detail below with reference to the accompanying drawings.
[0053] It can be understood that the technical method of the present application is applicable to various terminal devices that support the virtual AB system, such as mobile phones, tablet computers, wearable devices, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPC), netbooks, personal digital assistants (PDA) and other mobile terminals.
[0054] As mentioned above, in some current technical solutions, system upgrades do not support modifying the partition table, and to modify the partition, the terminal device needs to be flashed. In order to facilitate understanding of the technical solution of this application, the process of updating the system partition by the terminal device is first introduced below.
[0055] Specifically, Figure 1As shown in (a), the storage space of the terminal device includes a partition table, a basic partition, a boot partition A, a boot partition B, a system partition and a data partition. Among them, the partition files and partition sizes of the boot partition A and the boot partition B are the same, and only the partition names and partition addresses are different. In some embodiments, the boot partition A may also include: a boot loading partition A, a boot sub-partition A and a memory disk partition A (not shown). Under normal circumstances, the operating system can start and run the operating system from slot A (also referred to as the A system, loading the system partition and data partition through the boot partition A, etc.). During the operation, the system upgrade service of the operating system can upgrade slot B (also referred to as the B system, loading the system partition and data partition through the boot partition B, etc.), and the user's use of the terminal device will not be affected during the upgrade. In some embodiments, if the operating system runs on slot A (the operating system starts running through slot A), the new software version can be upgraded to slot B. After the upgrade is completed, the operating system switches to slot B for operation. If a newer software version appears, the software version will be upgraded to slot A. After the upgrade is completed, it switches to slot A, and so on. Each OTA upgrade will perform a slot switch.
[0056] In some embodiments, for the upgrade of partitions AB, if the upgrade method is differential upgrade, assuming that the current operating system is running in slot A, the data in the boot partition A (partition file) and the differential data (differential file) packaged in the upgrade package will be used to synthesize new data and then written into the boot partition B. If it is a full upgrade, the partition corresponding image data (image file) packaged in the upgrade package is directly written into the boot partition B.
[0057] In other embodiments, for the upgrade of the system partition, if the upgrade method is a differential upgrade, a Copy On Write (COW) file is created in the data partition, and then the data blocks involved in the update in the system partition are processed, and the data corresponding to the block and the corresponding differential data (differential file) in the upgrade package are merged and written into the COW file. If the upgrade method is a full upgrade, a COW file is created in the data partition, and then the data of each block of the system partition corresponding to the image file packaged in the upgrade package is written into the COW file.
[0058] It can be understood that no matter it is a differential upgrade or a full upgrade, after the COW file is written, it can also be called installation completion, the operating system restarts (for example: switching from slot A to slot B), merges the COW file into the system partition, and completes the system partition upgrade. The AB partition here can be called a static partition, and the system partition can be called a dynamic partition.
[0059] Specifically, the process of the system upgrade service executing the system partition upgrade may include:
[0060] Continue to refer Figure 1 (a), the operating system runs in slot A, obtains and verifies the upgrade package, creates a COW file in the data partition, upgrades the blocks involved in the update in the system partition, and writes the upgrade target data into the COW file. Figure 1 As shown in (b), the operating system switches to slot B, mounts the data partition, and mounts the system partition and COW file in snapshot mode. After the system partition is mounted, the use effect is equivalent to the upgraded system partition. After the device is successfully started, the upgraded target data included in the COW file is merged into the system partition. Figure 1 As shown in (c), the data in the system partition is already the upgrade target data corresponding to the upgrade package. After the upgrade is completed, the COW file is deleted. It can be understood that the snapshot mode here means a read-only copy, and mounting a COW file read-only copy does not occupy additional disk space.
[0061] As mentioned above, in the existing technical solutions, since the adjustment of partitions is not supported, the system upgrade involving the adjustment of the boot partition cannot be completed through OTA upgrade. Specifically, for example, the upgrade package (target software version) is obtained to load the target partition table, and it is determined that the system upgrade requires the adjustment of the boot partition size. Since the operating system runs in slot A, slot B will be upgraded first. After slot B is upgraded (including: adjusting the size of boot partition B corresponding to slot B, updating the partition file of boot partition B, etc.), since the operating system only supports loading the main partition table for restarting, it is necessary to replace the main partition table with the target partition table, that is, store the target partition table as the main partition table, that is, use the boot partition information of the target partition table to update the boot partition information of the main partition table, and the operating system loads the replaced main partition table and switches to slot B for operation (restarting through slot B). If the operating system restarts successfully, slot A is updated based on slot B to complete the system upgrade (that is, boot partition A is updated based on boot partition B, and boot partition B synchronizes boot partition A); if the operating system restarts failed, since the information of slot A in the main partition table (for example, partition address, etc.) has been updated, and slot A has not yet completed the upgrade, it cannot be restored by restarting again, for example: restarting through slot A again, restoring slot B through the main partition table and the partition file of slot A, and the operating system can only be restored by re-dividing the storage space of the terminal device.
[0062] To this end, the embodiment of the present application proposes a method for realizing partition adjustment through OTA upgrade, which is used to realize the process of upgrading the operating system of the terminal device, and supports the adjustment of the AB partitions, that is, the above-mentioned boot partition A and boot partition B, under the premise of keeping the system partition and the data partition unchanged (the partition information of the system partition and the data partition unchanged). Specifically, the method reserves an area in advance in the storage space of the terminal device, for example: the end of the storage space is close to the backup partition table space, which can be called the second partition table space. The second partition table space is empty by default. In the OTA upgrade scenario involving the adjustment of the AB partition, the second partition table space can store the second partition table (also called the target partition table) corresponding to the target software version (upgrade package), and the second partition table space will be cleared after the upgrade is completed. The second partition table here can record the upgraded partition information, for example: the partition name, partition size and partition address corresponding to each partition such as the boot partition, the system partition, etc., and set the flag of enabling the second partition table in the header of the main partition table, which can indicate that the operating system can restart without loading the first partition table (main partition table) but the second partition table. In this way, when the system upgrade involves the need to adjust the boot partition, the operating system can upgrade the non-running boot partition. If the upgrade fails or the restart fails after a successful upgrade, the main partition table can be loaded and the adjusted boot partition can be restored by restarting the boot partition that has not been upgraded, that is, synchronizing the boot partition that has not been upgraded and the boot partition that has been adjusted.
[0063] In addition, in order to avoid modifying the storage space of other partitions when adjusting the partition to be upgraded, a reserved partition can be set at the front or back of the partition so that storage space can be allocated from the reserved partition when adjusting the partition without adjusting the adjacent partitions. Figure 2 (a) shows a schematic diagram of the distribution of various partitions in the storage space of a common terminal device. Figure 2As shown in (a), the storage space of the terminal device includes a first partition table space (primary partition table space), which can store a first partition table (primary_GPT), which can also be called a primary partition table or an original partition table, a backup partition table space, which can store another copy of the first partition table as a backup partition table (backup_GPT), an OEM information partition (oeminfo), a log partition (log), AB partitions, i.e., boot partition A and boot partition B, reserved partitions 1 (reserved1) to 3 (reserved3), a system partition (super), a data partition (userdata), and other partitions, etc. Boot partition A can include boot loader partition A (bootlaoder_a), boot sub-partition A (boot_a), and memory disk partition A (ramdisk_a), and boot partition B can include boot loader partition B (bootlaoder_b), boot sub-partition B (boot_b), and memory disk partition B (ramdisk_b).
[0064] In order to adjust the partition that needs to be adjusted and upgraded, avoid modifying the storage space of other partitions. Figure 2 (b) shows a schematic diagram of the distribution of each partition in the storage space of a terminal device. Figure 2 (a) In Figure 2 In (b), the first partition table space, OEM information partition, reserved partition 1, and log partition are set at the front of all partitions to ensure that other partitions will not be affected when the system upgrade involves adjustments. Set the entire boot partition A and boot partition B separately. For example, set boot partition A before boot partition B, and set a reserved partition after boot partition A and boot partition B to reserve space for adjusting the boot partition. For example, continue to refer to Figure 2 (b) Reserved partition 2 is set after boot partition A. If the size of boot partition A in boot partition A needs to be increased, the partition end address of boot partition A can be moved back, and space can be allocated from reserved partition 2 to boot partition A without adjusting the subsequent boot partition B. It can be understood that adding a second partition table space to store the second partition table avoids directly replacing the main partition table with the second partition table (that is, storing the second partition table as the main partition table). If the system upgrade fails or the merge fails, the system cannot be restored.
[0065] Specifically, for example, in some embodiments, the process of adjusting and upgrading the boot partition may include: Figure 3 As shown in (a), the operating system is instructed to run in slot A, the system upgrade package is obtained, and the second partition table in the system upgrade package is obtained. Figure 3As shown in (b), the second partition table and the main partition table are compared. When it is determined that the system upgrade involves adjusting the partition (for example, the boot partition), the boot partition B is upgraded according to the second partition table using the partition upgrade data (also referred to as the partition upgrade file) in the system upgrade package, that is, the data of the boot partition B is updated, and the second partition table is stored in the second partition table space and an indicator for enabling the second partition table is set in the header of the main partition table. Figure 4 As shown in (a), the operating system is instructed to restart, load the main partition table, and obtain the information of slot B in the second partition table according to the set identifier of the second partition table to restart. Figure 4 As shown in (b), after the operating system is restarted, slot A is adjusted according to the second partition table, and the data of slot B that has been upgraded is used to replace slot A, that is, the data of slot B is synchronized with slot A. The second partition table is used to replace the main partition table and the backup partition table, that is, the second partition table is stored as the main partition table and the backup partition table, that is, the boot partition information of the second partition table is used to update the boot partition information of the main partition table and the backup partition table, and then the identifier of the second partition table and the second partition table stored in the second partition table space are cleared to complete the system upgrade. The partition information in the backup partition table here is consistent with the partition information in the main partition table. The backup partition table can be used to synchronize the main partition table through the backup partition table when the main partition table is damaged, that is, when the operating system cannot load the main partition table.
[0066] It can be seen that through the above-mentioned upgrade method, the operating system of the terminal device can support the system upgrade that requires the adjustment of the partition, especially the system upgrade that requires the adjustment of the boot partition (i.e., AB partition). During the system upgrade process, by setting the second partition table space to store the second partition table and setting the second partition table identifier for the main partition table, the system can be upgraded by loading the second partition table and restarting to complete the upgrade. The original main partition table is retained during the upgrade, which avoids the situation that once the main partition table is replaced with the second partition table, if the system upgrade fails or the restart fails, the existing boot partition is inconsistent with the boot partition recorded in the replaced second partition table, and cannot be restarted. Even if the system update fails or the system startup fails, the system can be rolled back to normal operation before the upgrade by loading the original main partition table.
[0067] In order to more clearly and in detail introduce the partition upgrade method provided by the embodiment of the present application, Figure 5 First, a flowchart of the terminal device implementing the system upgrade package installation in the embodiment of the present application is introduced. Figure 5 The method shown can be implemented by a processor of a terminal device executing relevant instructions, and the process of installing a system upgrade package can include the following steps.
[0068] Understandable, can refer to Figure 3 (a) to Figure 3 (b) Yes Figure 5 The upgrade method described is explained below. Figure 3 As shown in (a), the storage space of the terminal device includes a first partition table space, which can store the main partition table, a backup partition table space, which is used to store the backup partition table, and a second partition table space, which can store the second partition table (target partition table) in the upgrade package. The storage space of the terminal device also includes: OEM information partition (oeminfo), log partition (log), AB partition, i.e. boot partition A and boot partition B, reserved partition 1 (reserved1) to reserved partition 3 (reserved3), system partition (super), data partition (userdata) and other partitions, etc. Boot partition A can include boot loading partition A (bootlaoder_a), boot sub-partition A (boot_a) and memory disk partition A (ramdisk_a), and boot partition B can include boot loading partition B (bootlaoder_b), boot sub-partition B (boot_b) and memory disk partition B (ramdisk_b). Among them, the operating system of the terminal device runs in slot A (loading system partition and data partition, etc. through boot partition A).
[0069] S501: Start the operating system through slot A, and obtain and verify the system upgrade package.
[0070] Exemplarily, the operating system of the terminal runs in slot A. The terminal device and the server use Over The Air (OTA) technology to obtain the system upgrade package of the operating system of the terminal device, where the system upgrade package can also be called an OTA upgrade package. The upgrade download service of the operating system can enable the terminal device to obtain the system upgrade package from the server through the air interface of mobile communication. The operation of verifying the system upgrade package here may include: the upgrade download service performs a file integrity check on the downloaded system upgrade package, for example: whether the upgrade file in the system upgrade package (i.e., the partition upgrade file or partition upgrade data) is complete. For example: the file integrity check can use the Secure Hash Algorithm (SHA256), and the MD algorithm can generate a 128-bit (16-byte) hash value (Hash value) to ensure the integrity and consistency of the system upgrade package before and after transmission.
[0071] S502: Parse and save the second partition table in the system upgrade package.
[0072] Exemplarily, the system upgrade service of the operating system can decompress the system upgrade package to the storage space of the terminal device, load and save the second partition table in the system upgrade package. The main partition table here can be as follows Figure 3 (a) shows the first partition table stored in the first partition table space. The system upgrade service can compare the partition information stored in the second partition table and the main partition table. The main partition table stores the current partition information of the system, and the second partition table stores the partition information after the system upgrade. The partition information may include: partition name, partition size, partition start address, etc.
[0073] S503: Determine whether there is any partition change in the second partition table.
[0074] Optionally, the partition information of the second partition table and the main partition table can be compared to determine whether there is a partition change in the second partition table relative to the first partition table. Exemplarily, if the partition information stored in the second partition table and the main partition table is inconsistent, for example, the partition name, partition size, partition start address, etc. in the second partition table are inconsistent with the partition information stored in the main partition table, it means that there is a partition change in the second partition table, that is, the system upgrade involves a partition change, and step S505 is executed to further determine whether the partition change involves a system partition, a data partition, or a non-boot partition. Otherwise, step S504 is executed to set the partition change flag to no.
[0075] S504: Set the partition change flag to no.
[0076] Exemplarily, the partition change flag here can be represented by needUpdateGpt, the partition change flag can be a variable set in the memory of the operating system, and the partition change flag can be set to false by needUpdateGpt==false. After setting the partition change flag to false, step S509 is executed. In some embodiments, the partition change flag here can also be saved with any other name or form.
[0077] S505: Determine whether the partition change involves a system partition, a data partition, or a non-boot partition.
[0078] For example, continue to refer to Figure 3 (a), the system partition and data partition here can be called super partition and userdata partition, and the non-boot partition can include basic partition or other partitions, etc. If the partition change only involves the boot partition, that is, the judgment result of step S505 is no, then execute step S506 to further determine whether the system upgrade package is a full package. Otherwise, execute step S508 to prompt that the system upgrade package installation failed. In some embodiments, the partition size and partition address of the above-mentioned system partition, data partition or non-boot partition do not support adjustment. If the partition change involves the system partition, data partition or non-boot partition, it means that the system upgrade package configuration is incorrect, the system upgrade does not support OTA upgrade, and it is necessary to prompt that the system upgrade package installation failed.
[0079] S506: Determine whether the system upgrade package is a full package.
[0080] Exemplarily, the full package here can be a type of system upgrade package, that is, it includes all upgrade files (upgrade data) in the upgraded version of the operating system. The differential package corresponds to the full package. If the partition change involves a partition change and it is determined that the system upgrade package is a full package, step S507 is executed to set the partition change flag to yes. Otherwise, step S508 is executed to prompt that the system upgrade package installation failed. In some embodiments, compared to the full package, if the system upgrade involves a partition change, if the system upgrade package is a differential package instead of a full package, the system upgrade cannot be completed by differential upgrade because the partition change will cause the address of the partition file to change.
[0081] S507: Parse and save the upgrade file in the system upgrade, and set the partition change flag to yes.
[0082] Exemplarily, if a partition change flag, namely needUpdateGpt, has been set in the memory of the operating system, the partition change flag is read and set to yes, for example: needUpdateGpt = true. Otherwise, a partition change flag is created and set to yes.
[0083] S508: prompting that the system upgrade package installation failed.
[0084] Exemplarily, at this time, the operating system is running in slot A, and the system upgrade service of the operating system can prompt the terminal device through a prompt box on the screen of the terminal device that the system upgrade package installation has failed.
[0085] S509: Determine whether the partition change flag is yes.
[0086] Exemplarily, the partition change flag in the memory of the operating system is read. If the partition change flag is yes, step S510 is executed, the partition is adjusted by the partition information stored in the saved second partition table, and the partition is upgraded using the upgrade file in the system upgrade package. The partition here can be the boot partition B corresponding to slot B. In some embodiments, the partition may also include a system partition, a data partition, etc. Otherwise, step S511 is executed, and the system upgrades the partition using the upgrade file in the system upgrade package according to the partition information stored in the main partition table.
[0087] S510: Upgrade slot B using the partition information and upgrade file stored in the second partition table.
[0088] Exemplarily, if the system upgrade involves partition changes, and the operating system runs in slot A, the boot partition B corresponding to slot B can be upgraded; accordingly, if the operating system runs in slot B, the boot partition A in slot A can be upgraded.
[0089] like Figure 3 As shown in (b), the system upgrade service of the operating system can adjust the boot partition B corresponding to slot B through the partition information stored in the second partition table, for example: expand, reduce, merge or delete each sub-partition of the boot partition B corresponding to slot B. Figure 3 (b), expand the boot sub-partition B in the boot partition B corresponding to slot B, and adjust the partition address of the memory disk partition B. After adjusting slot B, use the upgrade file in the system upgrade package saved in the storage space to upgrade the partition, that is, use the upgrade file (data) to update slot B. The system upgrade service of the operating system can be achieved through Figure 1 The system partition is upgraded in the manner of (a), that is, a COW file is created in the data partition, the blocks involved in the update in the system partition are upgraded, and the upgrade target data included in the upgrade file is written into the COW file.
[0090] S511: Slot B is upgraded using the partition information stored in the primary partition table and the saved upgrade file.
[0091] For example, if the system upgrade does not involve partition changes, it can be directly done through Figure 1 (a) to upgrade the system partition.
[0092] S512: Determine whether slot B is updated successfully.
[0093] Exemplarily, during the process of adjusting the partition by the system upgrade service of the operating system and upgrading the partition using the upgrade file, if no error occurs, such as: the upgrade file copy fails, the upgrade file is damaged, etc., it is determined that the partition update is successful, and step S513 is executed to perform data integrity check on the upgraded partition. Otherwise, step S518 is executed to synchronize the upgraded partition through the main partition table.
[0094] S513: Perform data integrity check on the upgraded slot B.
[0095] Exemplarily, the system upgrade service of the operating system may use the file integrity check described in step S501 to perform data integrity check on the upgraded partition.
[0096] S514: Determine whether the data integrity check is successful.
[0097] Exemplarily, if the data integrity check of the upgraded partition fails, it means that the upgrade file of the system upgrade package is not completely upgraded to the partition, and step S518 is executed to restore the upgraded partition through the main partition table. Otherwise, step S515 is executed.
[0098] In some embodiments, steps S513 and S514 may be executed in a loop until the partition files corresponding to the upgraded boot partition B or the system partition have completed the data integrity check.
[0099] S515: Determine whether the partition change flag is yes.
[0100] Exemplarily, if the partition update is successful and the data integrity check is successful, the system upgrade service of the operating system can read the partition change identifier in the memory of the operating system. If the partition change identifier is yes, execute step S516, save the second partition table in the storage space of the operating system (not in the memory) and set the identifier of the second partition table to indicate that the main partition table is not loaded but the second partition table during restart.
[0101] S516: Write the saved second partition table into the second partition table space and add an identifier of the second partition table in the header of the main partition table.
[0102] For example, continue to refer to Figure 3 (b), the second partition table space here can be a newly added area in the storage space of the operating system, which can store the second partition table. The identifier of the second partition table (i.e., the read identifier) can be represented by GPT2:b, which can be added to the header of the main partition table. After the system is upgraded, the identifier of the second partition table indicates that the system needs to load the second partition table when it is restarted, that is, to obtain the partition information of the boot partition in the second partition table.
[0103] S517: Switch to slot B to start the operating system.
[0104] Exemplarily, if the operating system runs in slot A, the boot partition B corresponding to slot B can be upgraded. After the system is upgraded, the system upgrade service of the operating system can instruct the operating system to switch to slot B to start running.
[0105] S518: Use the partition information stored in the primary partition table and slot A to restore slot B.
[0106] Exemplarily, if the partition update fails or the data integrity check fails, it is necessary to restore the adjusted partition or clear the system upgrade file. The system upgrade service of the operating system can obtain the partition information stored in the main partition table to restore the adjusted partition. For the boot partition, the system upgrade service can use the unadjusted boot partition to restore the adjusted boot partition. For example: the operating system runs in slot A, and the boot partition B corresponding to slot B is upgraded. If the upgrade of boot partition B fails, or the data integrity check of the upgraded boot partition B fails, the boot partition information of boot partition B in the main partition table is used to set the partition size or partition address of boot partition B, and the partition file of boot partition A corresponding to slot A is used to restore the partition file corresponding to slot B. That is, synchronize boot partition B and boot partition A, that is, clear the data of boot partition B of slot B, and write the data of boot partition A of slot A to boot partition B of slot B. It can be understood that for the system partition, the COW file created in the data partition can be deleted.
[0107] S519: Clear the second partition table stored in the second partition table space and the flag for loading the second partition table in the header of the main partition table.
[0108] Exemplarily, if the partition update fails or the data integrity check fails, and the second partition table has been saved and the flag of the second partition table has been set, it is necessary to clear the flag of the set second partition table and the saved second partition table.
[0109] S520: prompts that the upgrade fails.
[0110] Exemplarily, the system upgrade service of the operating system may prompt an upgrade failure through a prompt box on the screen of the terminal device.
[0111] In passing Figure 5 After introducing the process of installing the upgrade package in the embodiment of the present application, the following is a Figure 6 The following further describes the process of restarting the system after the upgrade package is successfully installed in the embodiment of the present application. The process of restarting the system may include the following steps.
[0112] Understandably, Figure 5 During the upgrade package installation process shown, the operating system of the terminal device runs in slot A. After the upgrade package is successfully installed, the operating system switches to slot B for operation.
[0113] S601: Start the operating system through slot B and load the primary partition table header.
[0114] Exemplarily, the system startup service can be used to manage the restart of the operating system of the terminal device, and the system startup service can load the main partition table to obtain the partition information of each partition of the operating system, for example, determining the addresses of the boot partition, system partition, and data partition through the main partition table.
[0115] S602: Determine whether there is an identifier of the second partition table in the header of the primary partition table.
[0116] Exemplarily, the identifier of the second partition table here can be represented by GPT2:b, where b: indicates that the operating system is started and runs from slotB. The system startup service of the terminal device can load the header of the main partition table to determine whether there is an identifier of the second partition table in the header. If so, execute step S603 to determine whether there is a second partition table. Otherwise, execute step S605.
[0117] S603: Determine whether the second partition table exists in the second partition table space.
[0118] Exemplarily, the system startup service can determine whether the second partition table is saved from the second partition table space according to the identifier of the second partition table, and if the second partition table is saved, execute step S604 to load the second partition table, obtain the partition information of each partition of the operating system stored in the second partition table, and start again. Otherwise, execute step S605 to load the main partition table.
[0119] S604: Load the partition information in the second partition table.
[0120] Exemplarily, the system startup service can load the second partition table to obtain the partition information of each partition of the operating system. Figure 4 As shown in (a), the system startup service can switch to slot B for startup.
[0121] S605: Loading partition information in the primary partition table.
[0122] Exemplarily, the system startup service may load the primary partition table to obtain partition information of each partition of the operating system.
[0123] In passing Figure 6 After introducing the process of restarting the system after the upgrade package of the embodiment of the present application is successfully installed, the following is a Figure 7 The partition update process after the system restarts in the embodiment of the present application is further introduced. The partition update process may include the following steps.
[0124] It can be understood that the operating system of the terminal device is provided with slot A and slot B. Figure 5During the upgrade package installation process shown in the figure, the operating system of the terminal device runs in slot A. After the upgrade package is successfully installed, the operating system switches to slot B to start running.
[0125] S701: Merge slot A.
[0126] Exemplarily, the system upgrade service of the operating system can adjust slotA according to the partition information stored in the second partition table, and then use the partition file of the boot partition B corresponding to slot B to update the boot partition A corresponding to slot A, that is, use the partition file of the boot partition B corresponding to slot B to update the boot partition A in slot A, so that the partition file of slot A is consistent with the partition file of slot B.
[0127] In some embodiments, after the operating system switches to slot B and starts running, the system partition needs to be mounted, and the COW files of the system partition and the data partition are mounted using snapshots. The use effect after mounting is equivalent to the upgraded system partition.
[0128] S702: Determine whether the merge is successful.
[0129] Exemplarily, the system upgrade service of the operating system may use the file integrity check described in step S501 to perform data integrity check on the merged slot A and the system partition. If the merge is successful, execute step S704 to clear the second partition table, otherwise execute step S703.
[0130] S703: The upgrade fails.
[0131] Exemplarily, the system upgrade service of the operating system may prompt an upgrade failure through a prompt box on the screen of the terminal device.
[0132] S704: Determine whether there is an identifier of the second partition table in the primary partition table.
[0133] Exemplarily, the identifier of the second partition table here can be represented by GPT2:b, and the system startup service of the terminal device can load the header of the primary partition table to determine whether the identifier of the second partition table exists in the header. If it exists, execute step S705 to replace the primary partition table and the backup partition table with the second partition table. Otherwise, execute step S707 to perform partition replication.
[0134] S705: Use the second partition table to replace the primary partition table and the backup partition table.
[0135] For example, continue to refer to Figure 4(b) The system upgrade service of the operating system can use the second partition table in the second partition table space to replace the primary partition table stored in the first partition table space and the backup partition table stored in the backup partition table space as new primary partition table and backup partition table, that is, store the second partition table as the primary partition table and the backup partition table, that is, use the boot partition information of the second partition table to update the boot partition information of the primary partition table and the backup partition table, so that the partition information stored in the primary partition table and the backup partition table is consistent with the partition information after the system upgrade.
[0136] S706: Clear the second partition table stored in the second partition table space.
[0137] For example, continue to refer to Figure 4 (b) After the system upgrade service completes overwriting the primary partition table and the backup partition table with the second partition table, the second partition table in the second partition table space may be cleared.
[0138] S707: Merge the upgrade target data of the system partition.
[0139] Exemplarily, the system upgrade service also needs to merge the COW file mounted by the snapshot, that is, merge the upgrade target data of the system partition included in the COW file into the system partition.
[0140] It can be understood that the partition information in the backup partition table is consistent with the partition information in the primary partition table. During the use of the terminal device, if the primary partition table is damaged, the backup partition table can be used to restore the primary partition table.
[0141] In some embodiments, if the system involves a boot partition change, and a system upgrade package installation failure or a restart failure occurs during the system upgrade process, you can Figure 8 The system recovery process of the embodiment of the present application shown in the figure is used to perform system recovery. Taking the failure of the operating system to restart after the system upgrade involves adjusting the boot partition as an example, the system recovery process may include the following steps.
[0142] It can be understood that the operating system of the terminal device runs in slot A. When the boot partition B corresponding to slot B is upgraded, the system upgrade package installation fails or after the boot partition B corresponding to slot B is upgraded, the operating system switches to slot B and fails to start. It is necessary to restore the boot partition B corresponding to slot B through the partition file of the boot partition A corresponding to slot A.
[0143] S801: Load the primary partition table, obtain partition information of the boot partition stored in the primary partition table, and obtain a partition file of the boot partition according to the partition information.
[0144] Exemplarily, the system upgrade service of the operating system can load the primary partition table and obtain the partition information stored in the primary partition table. Fig. 9 , load the partition information of boot partition A and boot partition B in the partition information stored in the primary partition table.
[0145] S802: Determine whether there is an adjusted boot partition.
[0146] For example, the partition information and the partition files can be compared, and reference is made to Fig. 9 The system upgrade service can determine the adjusted boot partition according to the comparison result between the partition information of the boot partition A and the boot partition B stored in the main partition table and the partition information of the boot partition A and the boot partition B of the storage space of the current operating system and the difference of the partition files between the partition information of the boot partition A and the boot partition B. If there is an adjusted boot partition, for example, the adjusted boot partition is the boot partition B, then step S803 is executed to restore the boot partition B corresponding to the slot B using the partition information of the boot partition B stored in the main partition table and the partition file of the boot partition A corresponding to the slot A. If they are the same, then step S804 is executed to clear the identifier of the second partition table and the second partition table.
[0147] S803: Using the partition information of the boot partition stored in the primary partition table to set the adjusted boot partition and the partition file of the unadjusted boot partition to replace the partition file of the adjusted boot partition.
[0148] For example, continue to refer to Fig. 9 , the system upgrade service can use the partition file of the boot partition A corresponding to slot A to restore the boot partition B corresponding to slot B, and restore the partition information of the boot partition. That is, use the partition information of the boot partition B stored in the primary partition table to adjust the boot partition B, and use the partition file of the boot partition A corresponding to slot A to replace the partition file of the boot partition B corresponding to slot B, that is, synchronize the boot partition B and the boot partition A, that is, clear the data of the boot partition B of slot B, and write the data of the boot partition A of slot A to the boot partition B of slot B.
[0149] S804: Clear the identifier of the second partition table in the header of the main partition table.
[0150] For example, continue to refer to Fig. 9 Here, the identifier of the second partition table can be represented by GPT2:b. The system startup service can load the header of the primary partition table and clear the identifier of the second partition table.
[0151] S805: Clear the second partition table stored in the second partition table space.
[0152] For example, reference Fig. 9 , clear the second partition table saved in the second partition table space.
[0153] Fig.10 1 is a schematic diagram of the structure of a terminal device 100 provided in an embodiment of the present application. Figure 4 As shown, the terminal device (such as a mobile phone) may include: a processor 1010, an external memory interface 1020, an internal memory 1021, a universal serial bus (USB) interface 1030, a charging management module 1040, a power management module 1041, a battery 1042, an antenna 1, an antenna 2, a mobile communication module 1050, a wireless communication module 1060, an audio module 1070, a speaker 1070A, a receiver 1070B, a microphone 1070C, an earphone interface 1070D, a sensor module 1080, a button 1090, a motor 1091, an indicator 1092, a camera 1093, a display screen 1094, and a subscriber identification module (SIM) card interface 1095, etc.
[0154] Among them, the above-mentioned sensor module 1080 may include sensors such as a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor and an ambient light sensor.
[0155] It is to be understood that the structure illustrated in this embodiment does not constitute a specific limitation on the terminal device. In other embodiments, the terminal device may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0156] The processor 1010 may include one or more processing units, for example, the processor 1010 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0157] The processor 1010 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 1010 is a cache memory. The memory may store instructions or data that the processor 1010 has just used or cyclically used. If the processor 1010 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 1010, and thus improves the efficiency of the system.
[0158] In some embodiments, the processor 1010 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0159] It is understandable that the interface connection relationship between the modules illustrated in this embodiment is only a schematic illustration and does not constitute a structural limitation on the terminal device. In other embodiments, the terminal device may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0160] The terminal device implements the display function through a GPU, a display screen 1094, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 1094 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 1010 may include one or more GPUs that execute program instructions to generate or change display information.
[0161] The display screen 1094 is used to display images, videos, etc. The display screen 1094 includes a display panel.
[0162] The terminal device can realize the shooting function through the ISP, the camera 1093, the video codec, the GPU, the display screen 1094 and the application processor. The ISP is used to process the data fed back by the camera 1093. The camera 1093 is used to capture a static image or a video. In some embodiments, the terminal device may include 1 or N cameras 1093, where N is a positive integer greater than 1.
[0163] The external memory interface 1020 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the terminal device. The external memory card communicates with the processor 1010 through the external memory interface 1020 to implement a data storage function. For example, files such as music and videos can be stored in the external memory card.
[0164] The internal memory 1021 may be used to store computer executable program codes, which include instructions. The processor 1010 executes various functional applications and data processing of the terminal device by running the instructions stored in the internal memory 1021. For example, in an embodiment of the present application, the processor 1010 may execute the instructions stored in the internal memory 1021, and the internal memory 1021 may include a program storage area and a data storage area.
[0165] The program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the terminal device (such as audio data, a phone book, etc.), etc. In addition, the internal memory 1021 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0166] It is to be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the terminal device. In other embodiments of the present application, the terminal device may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0167] Fig.11 It is a software structure block diagram of the terminal device 100 according to an embodiment of the present invention.
[0168] The layered architecture divides the software into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: application layer (APK), application framework layer (FWK), hardware abstraction layer (HAL) and kernel layer.
[0169] like Fig.11 As shown, the application layer may include applications such as life, video, reading, shopping, gallery, calendar, call, navigation and music. It is understood that the application here may be an application or service installed by the terminal device 100, or an application or service not installed by the terminal device 100 retrieved by the quick service center.
[0170] The application framework layer may include a layout service, an upgrade download service, a system upgrade service, a system startup service, and the like. Among them, the layout service is used to determine the position of each display element in the screen of the terminal device. The upgrade download service is used to communicate with the upgrade server, obtain the upgrade package corresponding to the operating system of the terminal device and save it. The system upgrade service is used to load the system upgrade package and obtain the second partition table in the system upgrade package. Compare the second partition table with the main partition table. When it is determined that the system upgrade involves adjusting the partition (for example, the boot partition), according to the second partition table, use the upgrade file in the system upgrade package to upgrade the second boot partition (that is, the B system or slot B, that is, the boot partition B included in slot B) and store the second partition table in the second partition table space and set the second partition table identifier for the main partition table. Instruct the operating system to restart, load the main partition table, and load the information of slot B in the second partition table according to the set second partition table identifier to restart. After the operating system restarts, adjust the first boot partition (also called A system or slot A, that is, adjust the boot partition A included in slot A) according to the second partition table, and update slot A with the upgraded slot B. The second partition table is used to replace the primary partition table and the backup partition table, and the second partition table identifier and the second partition table stored in the second partition table space are cleared to complete the system upgrade. The system startup service is used to manage the startup of the terminal operating system, including the restart after the upgrade is successful / failed / recovered.
[0171] The hardware abstraction layer may include a drawing service module (SurfaceFlinger) and a view module, etc. Among them, the drawing service module (SurfaceFlinger) is used to draw and synthesize one or more layers in the windows of one or more applications to obtain frame data. The view module can be used to manage the operating mode of the user interface in the window.
[0172] The kernel layer includes display driver, event driver, sensor driver, etc.
[0173] It should be understood that although the terms "first", "second", etc. may be used herein to describe various features, these features should not be limited by these terms. These terms are used only to distinguish and should not be understood as indicating or implying relative importance. For example, a first feature may be referred to as a second feature, and similarly a second feature may be referred to as a first feature without departing from the scope of the exemplary embodiments.
[0174] In addition, various operations will be described as multiple separate operations in a manner that is most helpful for understanding the illustrative embodiments; however, the order of description should not be interpreted as implying that these operations must rely on the order of description, and many of the operations can be implemented in parallel, concurrently, or simultaneously. In addition, the order of the operations can also be rearranged. When the described operations are completed, the process can be terminated, but there can also be additional operations not included in the drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.
[0175] References in the specification to "one embodiment," "an embodiment," "an illustrative embodiment," etc. indicate that the described embodiment may include a particular feature, structure, or property, but each embodiment may or may not necessarily include the particular feature, structure, or property. Moreover, these phrases are not necessarily directed to the same embodiment. In addition, when particular features are described in conjunction with a specific embodiment, the knowledge of those skilled in the art can affect the combination of these features with other embodiments, whether or not these embodiments are explicitly described.
[0176] Unless the context dictates otherwise, the terms "comprising," "having," and "including" are synonymous. The phrase "A / B" means "A or B." The phrase "A and / or B" means "(A), (B), or (A and B)."
[0177] As used herein, the term "module" may refer to, be part of, or include: a memory (shared, dedicated, or group) for running one or more software or firmware programs, an application-specific integrated circuit (ASIC), an electronic circuit and / or processor (shared, dedicated, or group), a combinational logic circuit, and / or other suitable components that provide the described functionality.
[0178] In the accompanying drawings, some structural or method features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order is not required. Instead, in some embodiments, these features may be described in a manner and / or order different from that shown in the illustrative drawings. In addition, the structural or method features included in a specific figure do not mean that all embodiments need to include such features. In some embodiments, these features may not be included, or these features may be combined with other features.
[0179] The embodiments of the present application are described in detail above in conjunction with the accompanying drawings, but the use of the technical solution of the present application is not limited to the various applications mentioned in the embodiments of the present patent. Various structures and variations can be easily implemented with reference to the technical solution of the present application to achieve the various beneficial effects mentioned herein. Various changes made within the knowledge of ordinary technicians in the field without departing from the purpose of the present application should all fall within the scope of the patent application.
Claims
1. An upgrading method, characterized in that: Applied to a terminal device, the storage space of the terminal device includes a first boot partition, a second boot partition, a system partition, a first partition table space and a second partition table space, and the method includes: The terminal device is started through the first boot partition based on the first partition table contained in the first partition table space; Obtaining a system upgrade package, wherein the system upgrade package includes a second partition table and partition upgrade data corresponding to the target software version, and the boot partition information in the second partition table is different from the boot partition information in the first partition table; Based on the second partition table and the partition upgrade data, updating the data of the second boot partition and the system partition; The second partition table is stored in the second partition table space, and a read flag is set for the table header of the first partition table; The terminal device restarts through the second boot partition according to the read identifier and based on the second partition table of the second partition table space; If the terminal device fails to restart through the second boot partition based on the second partition table of the second partition table space, the update of the second boot partition is restored based on the first partition table and the first boot partition.
2. The method according to claim 1, characterized in that The updating of data of the second boot partition and the system partition based on the second partition table and the partition upgrade data includes: adjusting the partition size or partition address of the second boot partition based on the boot partition information in the second partition table; The partition upgrade data is used to update data of the second boot partition.
3. The method according to claim 2, characterized in that The updating of the second boot partition based on the first partition table and the first boot partition restoration includes: If the terminal device fails to start up through the second boot partition based on the second partition table of the second partition table space, setting the partition size or partition address of the second boot partition based on the boot partition information of the second boot partition in the first partition table; The data of the second boot partition is cleared, and the data of the first boot partition is written into the second boot partition.
4. The method according to claim 3, characterized in that The terminal device, after failing to start up through the second boot partition based on the second partition table of the second partition table space, further includes: The read identifier set in the header of the second partition table and the first partition table stored in the second partition table space is cleared, and an upgrade failure is prompted.
5. The method according to claim 2, characterized in that: Also includes: If the terminal device successfully boots through the second boot partition based on the second partition table of the second partition table space, adjust the partition size or partition address of the first boot partition based on the boot partition information in the second partition table; The data of the first boot partition is cleared, and the data of the second boot partition is written into the first boot partition.
6. The method according to claim 5, characterized in that Also includes: The boot partition information of the second partition table is used to update the boot partition information of the first partition table and the backup partition table.
7. The method according to claim 6, characterized in that Also includes: The read identifier set in the header of the second partition table and the first partition table stored in the second partition table space is cleared, and a prompt indicating that the upgrade is successful is displayed.
8. The method according to claim 6, characterized in that Also includes: If the terminal device fails to load the first partition table, the first partition table of the first partition table space is cleared, and the backup partition table of the backup partition table space is stored in the first partition table space as the first partition table.
9. A terminal device, characterized in that: include: a memory for storing instructions to be executed by one or more processors of the terminal device, and The processor is one of the processors of the terminal device, and is used to execute the upgrading method described in any one of claims 1-8.
10. A computer program product, characterized in that include: A non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium contains a computer program code for executing the upgrading method according to any one of claims 1 to 8.
Citation Information
Patent Citations
System file burning method and device applied to mobile terminal
CN105955851A
Upgrade abnormality repair method and device and intelligent terminal
CN107341074A