Operating system upgrade method and electronic device
By analyzing and comparing the partition tables of electronic devices, on-demand relocation of partitions is achieved, which solves the problem of low reliability of partition relocation in the existing technology and improves reliability and versatility in the process of format change.
Patent Information
- Application Number
- CN202311071800.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-23
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2043-08-23
AI Technical Summary
In the existing technology, during the process of changing the format of electronic equipment, the partition relocation process has problems of high restriction and low reliability, making it difficult to achieve efficient partition relocation.
By obtaining and parsing the first partition table and the second partition table, determine the starting physical address of the sub-partition in the dynamic partition, and compare it to find the target sub-partition with the same name but different starting address, so as to perform on-demand Partition relocation enables partition overwriting and table modification.
It improves the reliability and versatility of partition migration, ensuring that unchanged partitions remain intact and only changed partitions are moved, which improves partition management efficiency during operating system upgrades.
Smart Images

Figure CN117707566B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of terminal devices, and in particular to an operating system upgrade method and electronic device. Background Art
[0002] An operating system is a software system that controls and manages the hardware and software resources of an electronic device. An electronic device needs to be installed with an operating system before it can be used by a user. For example, when the electronic device is a mobile phone, the mobile phone needs to be installed with an operating system corresponding to the mobile phone (for example, an IOS operating system or an Android operating system) before it can be used by a user.
[0003] The operating system of the electronic device needs to be configured with the corresponding standard (vendor_country, VC). The system partitions of the operating system under different standards are different. For example, the standard of the demonstration prototype is demo_cn, and the Version subpartition in the system partition of this standard is used to store a large number of operation demonstration samples, which occupies a large amount of memory, while the standard of the commercial machine is all_cn, and the Version subpartition in the system partition of this standard does not need to store operation demonstration samples and does not require a large memory. Therefore, after the electronic device is removed from the market, in order to sell the demonstration prototype to users, the standard of the demonstration prototype needs to be changed to the standard of the commercial machine.
[0004] In this way, electronic devices need to remotely upgrade their operating systems to achieve the change from demonstration mode to commercial mode. However, in the current process of changing the mode, the partition migration process involved has the problems of strong restrictions and low reliability. Summary of the invention
[0005] The embodiments of the present application provide an operating system upgrade method and an electronic device, which can solve the problem that the partition migration process involved in the current format change process is highly restrictive and has low reliability, and improve the reliability and versatility of partition migration.
[0006] In a first aspect, an embodiment of the present application provides an operating system upgrade method, which is applied to an electronic device, and the method includes: obtaining a first partition table; obtaining a second partition table; based on the first partition table, determining the starting physical addresses of multiple first sub-partitions in a dynamic partition in the memory of the electronic device; based on the second partition table, determining the starting physical addresses of multiple second sub-partitions in the dynamic partition, wherein the multiple second sub-partitions are sub-partitions obtained after moving at least a part of the multiple first sub-partitions; determining a first target sub-partition among the multiple first sub-partitions, wherein the first target sub-partition is the first sub-partition in the multiple first sub-partitions that has the same name as that in the multiple second sub-partitions, but has a different starting physical address; moving the sub-partition in the target area to the user data partition in the memory, wherein the sub-partition in the target area is a sub-partition in the multiple first sub-partitions that is located between the first target sub-partition and the user data partition; overwriting the sub-partition in the target area with the target offset address in the dynamic partition, and modifying the first partition table in the dynamic partition to the second partition table.
[0007] The operating system upgrade method provided in the embodiment of the present application can parse and compare the first partition table and the second partition table to obtain a first target sub-partition with the same name but different starting physical addresses among multiple first sub-partitions and multiple second sub-partitions, so as to start the migration from the first target sub-partition, keep the unchanged partitions in their original state, and only migrate the changed partitions, thereby realizing the on-demand migration of partitions and improving the reliability and versatility of the partition migration process during the operating system upgrade process.
[0008] In one implementation, obtaining the first partition table includes: in the first format, sequentially loading the basic partition in the memory, the first static partition in the memory, and the dynamic partition, and obtaining the first partition table after loading the dynamic partition; obtaining the second partition table includes: obtaining a system upgrade package, and obtaining the second partition table based on the system upgrade package. With this implementation, after starting based on the virtual A / B upgrade mode, the first partition table and the second partition table are obtained, so as to parse the first partition table and the second partition table.
[0009] In one implementation, after obtaining the system upgrade package, the method further includes: after completing the system upgrade based on the system upgrade package, entering the recovery mode for the first time, calling the recovery process to change the operating system of the electronic device from the first standard to the second standard; wherein, when the operating system of the electronic device is changed from the first standard to the second standard, updating the multiple third sub-partitions of the dynamic partition under the first standard to the multiple first sub-partitions under the second standard. With this implementation, the system change can be completed after entering the recovery mode for the first time, and the third sub-partition is updated to the first sub-partition, so as to facilitate the partition migration of the first sub-partition when entering the recovery mode for the second time.
[0010] In one implementation, the first standard includes a demonstration standard, and the second standard includes a commercial standard. This implementation shows the specific implementation forms of the first standard and the second standard.
[0011] In one implementation, based on the first partition table, determining the starting physical addresses of multiple first sub-partitions in the dynamic partition in the memory of the electronic device includes: entering the recovery mode for the second time, determining the first number corresponding to the continuous physical blocks of each first sub-partition, and determining the starting physical address corresponding to the continuous physical block of each first sub-partition based on the first number. With this implementation, the starting physical address corresponding to the continuous physical block of the first sub-partition can be obtained, so as to compare it with the starting physical address corresponding to the continuous physical block of the second sub-partition, and then perform partition migration.
[0012] In one implementation, based on the first partition table, determining the starting physical addresses of multiple first sub-partitions in the dynamic partition in the memory of the electronic device includes: entering the recovery mode for the second time, calling the recovery process to traverse the multiple first sub-partitions in the first partition table, and determining the first number corresponding to the continuous physical blocks of each first sub-partition; based on the first number, reversely indexing to the first data structure in the first partition table, and determining the starting physical address corresponding to the continuous physical block of each first sub-partition from the first data structure. With this implementation, the starting physical address corresponding to the continuous physical block of the first sub-partition can be obtained through the recovery process, so as to compare it with the starting physical address corresponding to the continuous physical block of the second sub-partition, and then perform partition migration.
[0013] In one implementation, based on the second partition table, determining the starting physical addresses of multiple second sub-partitions in the dynamic partition includes: entering the recovery mode for the second time, determining the second number of continuous physical blocks corresponding to each second sub-partition, and determining the starting physical address corresponding to the continuous physical block of each second sub-partition based on the second number. With this implementation, the starting physical address corresponding to the continuous physical block of the second sub-partition can be obtained, so as to compare it with the starting physical address corresponding to the continuous physical block of the first sub-partition, and then perform partition migration.
[0014] In one implementation, based on the second partition table, determining the starting physical addresses of multiple second sub-partitions in the dynamic partition includes: entering the recovery mode for the second time, calling the recovery process to traverse the multiple second sub-partitions in the second partition table, and determining the second number corresponding to the continuous physical blocks of each second sub-partition; based on the second number, reversely indexing to the second data structure in the second partition table, and determining the starting physical address corresponding to the continuous physical block of each second sub-partition from the second data structure. With this implementation, the starting physical address corresponding to the continuous physical block of the second sub-partition can be obtained through the recovery process, so as to compare it with the starting physical address corresponding to the continuous physical block of the first sub-partition, and then perform partition migration.
[0015] In one implementation, the recovery mode is entered for the second time, and the recovery process is called to traverse multiple first sub-partitions in the first partition table to determine the first number of continuous physical blocks corresponding to each first sub-partition, including: based on the first Lp metadata partition table structure in the first Lp metadata structure corresponding to the first partition table, traverse multiple first sub-partitions in the first partition table to determine the index structure of each first sub-partition; based on the first continuous physical block number structure in the index structure of each first sub-partition, determine the first number of continuous physical blocks corresponding to each first sub-partition in the first partition table. This implementation shows a specific method for obtaining the first number, so as to obtain the starting physical address corresponding to the continuous physical block of the first sub-partition, compare it with the starting physical address corresponding to the continuous physical block of the second sub-partition, and then move the partition.
[0016] In one implementation, the recovery mode is entered for the second time, and the recovery process is called to traverse multiple second sub-partitions in the second partition table to determine the second number of continuous physical blocks corresponding to each second sub-partition, including: based on the second Lp metadata partition table structure in the second Lp metadata structure corresponding to the second partition table, traverse multiple second sub-partitions in the second partition table to determine the index structure of each second sub-partition; based on the second continuous physical block number structure in the index structure of each second sub-partition, determine the second number of continuous physical blocks corresponding to each second sub-partition in the second partition table. This implementation shows a specific method for obtaining the second number, so as to obtain the starting physical address corresponding to the continuous physical block of the second sub-partition, compare it with the starting physical address corresponding to the continuous physical block of the first sub-partition, and then move the partition.
[0017] In one implementation, the first data structure is the first Lp metadata continuous physical block structure in the first partition table; based on the first quantity, the first data structure in the first partition table is reversely indexed, and the starting physical address corresponding to the continuous physical block of each first sub-partition is obtained from the first data structure, including: based on the first quantity, the first Lp metadata continuous physical block structure in the first partition table is reversely indexed; based on the first target data structure in the first Lp metadata continuous physical block structure, the starting physical address corresponding to the continuous physical block of each first sub-partition is determined. This implementation shows a specific method for obtaining the starting physical address corresponding to the continuous physical block of the first sub-partition, so as to compare it with the starting physical address corresponding to the continuous physical block of the second sub-partition, and then perform partition migration.
[0018] In one implementation, the second data structure is a second Lp metadata continuous physical block structure in the second partition table; based on the second number, the second data structure in the second partition table is reversely indexed, and the starting physical address corresponding to the continuous physical block of each second sub-partition is obtained from the second data structure, including: based on the second number, the second Lp metadata continuous physical block structure in the second partition table is reversely indexed; based on the second target data structure in the second Lp metadata continuous physical block structure, the starting physical address corresponding to the continuous physical block of each second sub-partition is determined. This implementation shows a specific method for obtaining the starting physical address corresponding to the continuous physical block of the second sub-partition, so as to compare it with the starting physical address corresponding to the continuous physical block of the first sub-partition, and then perform partition migration.
[0019] In one implementation, determining a first target sub-partition among multiple first sub-partitions includes: obtaining a first target data structure corresponding to a continuous physical block of each first sub-partition in a first partition table; obtaining a second target data structure corresponding to a continuous physical block of each second sub-partition in a second partition table; sequentially comparing the first target data structure corresponding to the continuous physical block of each first sub-partition with the second target data structure corresponding to the continuous physical block of each second sub-partition; determining a sub-partition among multiple first sub-partitions obtained for the first time that has the same name as multiple second sub-partitions but has a different first target data structure from a second target data structure as a first target sub-partition. This implementation shows a specific method for determining the first target sub-partition, so that the migration can be started from the first target sub-partition, so that the unchanged partition remains in its original state, and the on-demand migration of the partition is realized. During the operating system upgrade process, the reliability and versatility of the partition migration process are improved.
[0020] In one implementation, the sub-partitions in the target area are moved to the user data partition in the memory, including: based on the first target data structure corresponding to the sub-partitions in the target area, the sub-partitions in the target area are moved from the first target sub-partition to the end of the user data partition in sequence. This implementation shows a specific method of partition migration, so that the migration can be started from the first target sub-partition, so that the unchanged partitions remain in their original state, and the partition migration is realized on demand, which improves the reliability and versatility of the partition migration process during the operating system upgrade process.
[0021] In one implementation, after entering the recovery mode for the second time and calling the recovery process to traverse multiple first sub-partitions in the first partition table and determining the first number of continuous physical blocks corresponding to each first sub-partition, the method further includes: based on the first number, reversely indexing to the first data structure in the first partition table, and determining the continuous physical block size corresponding to the continuous physical block of each first sub-partition from the first data structure. This implementation shows a specific method for obtaining the continuous physical block size of the continuous physical block of the first sub-partition, so that the target offset address can be further obtained according to the continuous physical block size to achieve partition migration.
[0022] In one implementation, based on the first quantity, the reverse index is directed to the first data structure in the first partition table, and the continuous physical block size corresponding to the continuous physical block of each first sub-partition is determined from the first data structure, including: based on the first quantity, the reverse index is directed to the first Lp metadata continuous physical block structure in the first partition table; based on the first quantity structure in the first Lp metadata continuous physical block structure, the continuous physical block size corresponding to the continuous physical block of each first sub-partition is determined. With this implementation, a specific method for obtaining the continuous physical block size of the continuous physical block of the first sub-partition is shown, so that the target offset address can be further obtained according to the continuous physical block size to realize partition migration.
[0023] In one implementation, the method for obtaining the target offset address includes: obtaining the preset partition size of the dynamic partition under the first standard; obtaining the total partition size of the sub-partitions of the target area; determining the difference between the preset partition size and the total partition size as the target offset address; wherein the total partition size is determined based on the sum of the continuous physical block sizes of each first sub-partition, wherein the sum of the continuous physical block sizes of each first sub-partition is determined based on the first target data structure and the corresponding first quantity structure corresponding to the continuous physical blocks of each first sub-partition. This implementation shows the method for obtaining the target offset address, so that a part of the sub-partition that has been changed can be moved from the end of the user data partition to the target offset address in the dynamic partition, completing the partition migration, realizing the on-demand migration of the partition, and improving the reliability and versatility of the partition migration process during the operating system upgrade process.
[0024] In one implementation, after the sub-partitions in the target area are overwritten with the target offset address in the dynamic partition, the method further includes: obtaining the third target data structure corresponding to each second sub-partition in the dynamic partition; verifying the third target data structure according to the second target data structure corresponding to each second sub-partition in the second partition table; modifying the first partition table in the dynamic partition to the second partition table when the second target data structure corresponding to each second sub-partition is the same as the corresponding third target data structure; and displaying an error message when the second target data structure corresponding to any second sub-partition is different from the corresponding third target data structure. With this implementation, after the partition migration is completed, the migrated partition needs to be verified to determine the accuracy of the partition migration, thereby improving the reliability of the partition migration.
[0025] In a second aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory, wherein the memory stores program instructions, and when the program instructions are executed by the processor, the electronic device executes the operating system upgrade method in the above-mentioned first aspect and any implementation method.
[0026] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, in which instructions are stored. When the instructions are executed on an electronic device, the electronic device executes an operating system upgrade method as described in the first aspect and any implementation method described above.
[0027] In a fourth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes the operating system upgrade method in the first aspect and any implementation method described above.
[0028] It can be understood that the electronic devices, computer-readable storage media and computer program products provided in the above-mentioned aspects are all applied to the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 It is a schematic diagram of the partition architecture of the operating system;
[0030] Figure 2 This is a schematic diagram of the operating system partition architecture corresponding to the demonstration prototype and commercial machine;
[0031] Figure 3 This is a schematic diagram of the first scenario of partitioning and moving electronic equipment;
[0032] Figure 4 This is a schematic diagram of the second scenario of partitioning and moving electronic equipment;
[0033] Figure 5 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0034] Figure 6 is a software structure block diagram of the electronic device provided in the embodiment of the present application;
[0035] Figure 7 It is a flowchart of the operating system upgrade method provided by the embodiment of the present application;
[0036] Figure 8 It is a schematic diagram of the virtual A / B upgrade process provided by an embodiment of the present application;
[0037] Fig. 9 This is a schematic diagram of a Merge process provided in an embodiment of the present application;
[0038] Fig.10 It is a schematic diagram of the operating system partition architecture after the Merge process provided in the embodiment of the present application is completed;
[0039] Fig.11 is a flow chart of a partition migration method provided in an embodiment of the present application;
[0040] Fig.12 is a schematic diagram of a scenario of a partition migration method provided in an embodiment of the present application;
[0041] Fig.13 It is a schematic diagram of the partition structure corresponding to the first partition table and the second partition table provided in the embodiment of the present application;
[0042] Fig.14 It is a schematic diagram of the data structure of the sub-partition table provided in an embodiment of the present application;
[0043] Fig.15 It is a schematic diagram of a target offset address calculation method provided in an embodiment of the present application;
[0044] Fig.16 It is a structural diagram of an operating system upgrading device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0045] The technical solution of the embodiment of the present application will be clearly described below in conjunction with the drawings in the embodiment of the present application.
[0046] In the description of this application, unless otherwise specified, " / " means "or", for example, A / B can mean A or B. "And / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, "at least one" means one or more, and "plurality" means two or more. The words "first", "second", etc. do not limit the quantity and execution order, and the words "first", "second", etc. do not limit them to be different.
[0047] It should be noted that, in this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in this application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0048] The following first describes the application scenarios of the embodiments of the present application.
[0049] An operating system is a software system that controls and manages the hardware and software resources of electronic devices. It provides an interactive interface between users and electronic devices and is responsible for coordinating and executing various tasks to achieve normal operation and resource management of electronic devices.
[0050] The operating system of the electronic device may be any one of Windows operating system, Mac OS, Linux operating system, Unix operating system, DOS operating system, Magic OS, Android operating system, iOS or Harmony OS. The embodiment of the present application is only exemplified by the Android operating system, and the various operating systems can be referred to each other.
[0051] When an electronic device implements wireless communication functions, the operating system of the electronic device needs to be configured with the corresponding standard. The standard refers to a standard or specification used for wireless signal transmission in a mobile communication system, which defines the communication method and parameters between the electronic device and the mobile communication infrastructure.
[0052] Electronic devices for different purposes may be configured with different operating system versions. For example, when an electronic device is used as a prototype for display, the operating system version configured is different from the operating system version configured when the electronic device is used for sale.
[0053] Specifically, during the sales process of electronic devices, sales stores usually provide users with demonstration samples with demonstration functions so that users can experience the functions of the electronic devices. After the user has the intention to purchase, the sales store usually sells the user a commercial machine for actual use.
[0054] Among them, the standard version of the operating system of the demonstration prototype is usually the demonstration ROM version. The demonstration ROM version refers to a specific standard version produced for the purpose of product demonstration or display. This standard version is usually specially customized to demonstrate the functions and characteristics of the product during the display, promotion or sales process.
[0055] The demo ROM version may include the following features:
[0056] 1. Demonstration functions: The demo ROM version may emphasize the main functions and features of the product and provide some pre-set demonstration content so that users can quickly understand the advantages of the product.
[0057] 2. Interface customization: The interface of the demo ROM version may be customized to enhance the product display effect in order to provide users with a better visual experience.
[0058] 3. Limit or disable some functions: The demo ROM version can limit or disable some functions to prevent users from operating them incorrectly.
[0059] 4. Demonstration mode: The demonstration ROM version can be set with a demonstration mode. The demonstration mode can include functions such as automatic playback of demonstration content and loop playback to meet the needs of display activities.
[0060] The demo ROM version may also have other features, which are not described in detail in this application. It should be noted here that the demo ROM version is not the official version provided to users, but a temporary version customized to showcase the product in a specific scenario.
[0061] For example, the demo ROM version of the demo prototype is vendor-country=demo_cn version. This standard version is an example version, and demo_cn represents a virtual device manufacturer and country / region.
[0062] The version of a commercial machine is usually a commercial standard version, which is provided by equipment manufacturers to meet the requirements of equipment reliability, security, and flexibility in commercial environments.
[0063] The commercial version may include the following features:
[0064] 1. Reliability and stability: Commercial standard versions usually undergo rigorous testing and verification to determine their reliability and stability under various workloads and environmental conditions.
[0065] 2. Security: The commercial version is designed with security in mind. Equipment manufacturers will pay close attention to potential security vulnerabilities in the commercial version and fix them through regular version updates.
[0066] 3. Compatibility: Commercial versions are usually developed and optimized to be compatible with other commercial hardware and software, which ensures that commercial machines can be seamlessly integrated with other electronic devices and systems and provide stable performance.
[0067] 4. Function and performance optimization: The commercial version may introduce new functions, improve existing functions, or enhance the performance of electronic devices. In this way, by updating the firmware of the commercial version, users can obtain a better user experience, increase the functionality of electronic devices, and improve the performance of electronic devices.
[0068] The commercial version may also have other features, which are not described in detail in this application. It should be noted here that the commercial version is usually the official version provided by the equipment manufacturer to users, so that users have a reliable, safe and stable user experience.
[0069] For example, the commercial standard version of a commercial machine is a vendor-country=all_cn version, which is a specific version provided according to a specific device manufacturer and country / region.
[0070] After a sales cycle, the demo prototype usually needs to upgrade the demo ROM version to a commercial version so that the demo prototype can be sold as a commercial machine.
[0071] The first method is to return the demo sample to the factory for flashing to upgrade the demo ROM version to the commercial version. Factory flashing means sending the electronic device back to the device manufacturer for professional technicians to update the format. In this way, the technicians can use special tools and programs to re-flash the electronic device's format. This method consumes more manpower costs and the process is more cumbersome.
[0072] The second method is to use Over-The-Air (OTA) technology to upgrade the demo ROM version to the commercial standard version. OTA refers to the technology of remotely updating the version of electronic devices through the wireless network interface of electronic devices to achieve the purpose of remotely upgrading the terminal system version. Electronic devices can save costs by changing the standard version through OTA upgrades.
[0073] Before introducing the OTA upgrade process, the partition architecture of the operating system is first explained.
[0074] Figure 1 It is a schematic diagram of the partition architecture of the operating system.
[0075] like Figure 1 As shown in A, the operating system of the electronic device includes a basic partition (Common partition), a system partition and a user data partition (Userdata partition). Among them, the Common partition is used to store system data that does not participate in the operating system upgrade. The system partition is used to store operating system data. The system partition includes multiple sub-partitions, for example, a boot loader Bootloader partition, a boot Boot partition, a vendor boot Vendor_boot partition, a device tree overlay Dtbo partition, a trusted boot metadata Vbmeta partition, and a super Super partition. Furthermore, the Super partition includes multiple sub-partitions, for example, a system System sub-partition, a product Product sub-partition, a version Version sub-partition, and a preload Preload sub-partition. The Super partition may also include other sub-partitions, which are not described in detail in this application. The Userdata partition is used to store the user's personal data, for example, application data installed by the user, picture data, document data, and video data saved by the user.
[0076] The operating system standard information is usually stored in an independent sub-partition in the Common partition, for example, in the device manufacturer oeminfo sub-partition or the non-volatile storage nv sub-partition of the Common partition. For example, the oeminfo sub-partition can store demo_cn, all_cn, cmcc_cn, etc. demo_cn is used to indicate the demonstration model standard, all_cn is used to indicate the general Chinese standard, and cmcc_cn is used to indicate the China Mobile Chinese standard.
[0077] The above partition architecture is a physical or logical partition of an electronic device. This partitioning method is based on the division for the purpose of managing storage space, resource isolation, security and performance.
[0078] like Figure 1 As shown in B, based on the virtual A / B partition, the system partition of the electronic device can also be divided as follows.
[0079] The system partitions of the electronic device include static partition A (slot_a), static partition B (slot_b) and dynamic partition (Super).
[0080] Among them, virtual A / B partitioning is a technology used for A / B testing to dynamically allocate user traffic to different partitions. This partitioning method is usually implemented at the application or service level, and can control user access to any partition through code or configuration. This partitioning method is usually temporary and is only used during testing, and no physical changes are made to the underlying system.
[0081] For the static partition A and static partition B of the virtual A / B partition, these two partitions are used to display or test different variants, functions or design elements. The structures of static partition A and static partition B correspond to each other, and the sub-partitions in the system partition can be divided. For example, the sub-partitions corresponding to static partition A are distinguished by the suffix _a, and the sub-partitions corresponding to static partition B are distinguished by the suffix _b. Static partition A can include Bootloader_a, Boot_a, Vendor_boot_a, Dtbo_a, and Vbmeta_a. Static partition B can include: Bootloader_b, Boot_b, Vendor_boot_b, Dtbo_b, and Vbmeta_b.
[0082] When the system partition has static partition A and static partition B, the electronic device can virtualize two operating systems, for example: operating system A1 and operating system B1. When the electronic device starts, it needs to run based on any one of the operating systems. For example, when the electronic device runs based on operating system A1, the electronic device starts from static partition A, and loads Common partition, static partition A and Super partition in sequence. When the electronic device runs based on operating system B1, the electronic device starts from static partition B, and loads Common partition, static partition B and Super partition in sequence.
[0083] Among them, taking the Universal Flash Storage (UFS) in the Master Boot Record (MBR) format adopted by the electronic device as an example, in the MBR (Master Boot Sector, the first sector of the UFS, i.e., the 0th cylinder 0th head 1st sector of the C / H / S address) of the UFS, the boot sequence description of the electronic device is stored, for example, booting from the static partition A (the boot sequence is identified as A) or booting from the static partition B (the boot sequence is identified as B). After the electronic device is started, the boot sequence of the electronic device is first read from the MBR of the UFS, and then, according to the boot sequence read, the electronic device can sequentially load the Common partition, the static partition A and the Super partition, or sequentially load the Common partition, the static partition B and the Super partition.
[0084] When an electronic device loads a Super partition, the types of sub-areas contained in the Super partition of the same electronic device are the same. However, when the same electronic device uses different standards, the sizes of the sub-partitions in the Super partition are different. Specifically, in a demo prototype, the Version sub-partition needs to be used to store a large number of operation demonstration samples, but in a commercial machine, the Version sub-partition does not need to store a large number of operation demonstration samples. In this way, there are differences in the Version sub-partition and Preload sub-partition of the demo prototype and the commercial machine.
[0085] Figure 2 This is a schematic diagram of the operating system partition architecture corresponding to the demonstration prototype and commercial machine.
[0086] like Figure 2 As shown, the sizes of the Version subpartitions of the demo machine and the commercial machine are different, and the starting addresses of the Perload subpartitions are different. The starting address can also be called the starting physical address in the memory.
[0087] In this way, during the OTA upgrade process, the system upgrade package downloaded and installed by the electronic device can be used to change the partition structure of the operating system, so that the partition structure of the operating system is changed from the standard of the demonstration prototype to the standard of the commercial machine.
[0088] The OTA upgrade process involves the following processes:
[0089] 1. Download and install the system upgrade package: If there is a system upgrade package available, the electronic device will download the new system upgrade package. The system upgrade package is usually provided in the form of a compressed file, which contains the files and data that need to be updated.
[0090] 2. Verify the system upgrade package: After the download is complete, the electronic device will verify the system upgrade package to determine its integrity. This will help prevent the downloaded file from being damaged or tampered with.
[0091] 3. Updating and updating according to the system upgrade package: If the system upgrade package passes the verification, the electronic device starts to upgrade and update according to the system upgrade package. This process may involve copying new files to the appropriate locations.
[0092] 4. Update completion and restart: After the electronic device is upgraded and updated, it will restart to apply the new software version. Among them, after the OTA update is completed, the electronic device will restart twice and enter the recovery mode to perform the system update.
[0093] Taking the electronic device being started by static partition A in the initial state as an example, since the electronic device has written the data in static partition A into static partition B during the OTA upgrade process, and has created a virtual dynamic partition in the Userdata partition, and written the upgrade data of the Super partition into the virtual dynamic partition (this process will be described in detail later), when the electronic device enters the Recovery mode for the first time, a Merge operation is performed to write the upgrade data of the Super partition written in the virtual dynamic partition into the Super partition, and a Copy operation is performed to write the data written in static partition B into static partition A. In this way, the electronic device completes the format change. After the electronic device changes the format, it is also necessary to further solve the problem of low space utilization of each sub-partition.
[0094] When the electronic device enters the Recovery mode for the second time, the partition migration operation is performed.
[0095] Figure 3 This is a schematic diagram of the first scenario of partitioning and moving electronic equipment.
[0096] like Figure 3 As shown, taking the Super partition including System, Product, Version, Preload and other sub-partitions as an example, during the partition migration process, the electronic device can reduce the size of the Version sub-partition, move the Preload sub-partition upward as a whole, and expand the Size of the Userdata partition.
[0097] However, if the Preload sub-partition is a dynamically changeable partition, such as including Preload1 and Preload2, data anomalies and restructuring failures may occur.
[0098] That is to say, in the first scenario where the electronic device changes its format, partition migration can only be performed when all sub-partitions are independent integral partitions.
[0099] Figure 4 This is a schematic diagram of the second scenario of partitioning and moving electronic equipment.
[0100] like Figure 4As shown, taking the Super partition including System1, Product, Version, Preload, System2 and other sub-partitions as an example, during the partition migration process, the electronic device can first move all sub-partitions of the Super partition to the Userdata partition, and then move and integrate all sub-partitions of the Super partition from the Userdata partition to the Super partition. In this way, some sub-partitions in the Super partition need to move and rewrite data even if the data has not been changed, which will reduce the reliability of the data.
[0101] In other words, during the current OTA upgrade process of electronic devices, there are certain limitations when it comes to partition migration, and dynamic partitions in the operating system cannot be migrated on demand.
[0102] In order to solve the above problems, an embodiment of the present application provides an operating system upgrade method.
[0103] The operating system upgrade method provided in the embodiment of the present application can be applied to electronic devices. Among them, electronic devices include but are not limited to mobile phones, tablet computers, personal computers, workstation devices, large-screen devices (such as smart screens, smart TVs, etc.), wearable devices (such as smart bracelets, smart watches), handheld game consoles, home game consoles, virtual reality devices, augmented reality devices, mixed reality devices, etc., in-vehicle smart terminals, etc.
[0104] Figure 5 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application.
[0105] like Figure 5 As shown, the electronic device 100 may include a processor 110, a memory 120, a Universal Serial Bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 01, an antenna 02, a mobile communication module 150, a wireless communication module 160, an audio module 170, a sensor module 180, a button 190, a motor 191, a camera 192, a display screen 193, and a Subscriber Identification Module (SIM) card interface 194, etc.
[0106] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 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.
[0107] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processor (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0108] The memory 120 can be used to store computer executable program codes, and the executable program codes include instructions. The memory 120 may include a program storage area and a data storage area. Among them, 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 electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the memory 120 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 memory (Universal Flash Storage, UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by running instructions stored in the memory 120, and / or instructions stored in a memory provided in the processor. In the embodiment of the present application, the memory 120 may include a Cmmon partition 120A, a system partition 120B, and a Userdate partition 120C, wherein the Common partition 120A is used to save system data that does not participate in the operating system upgrade, the system partition 120B is used to save operating system data, and the Userdata partition is used to save the user's personal data.
[0109] The USB interface 130 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transfer data between the electronic device 100 and a peripheral device. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as AR devices, etc.
[0110] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0111] The charging management module 140 is used to receive charging input from a charger.
[0112] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to power the processor 110, the memory 120, the display screen 193, the camera 192, and the wireless communication module 160.
[0113] The wireless communication function of the electronic device 100 can be implemented through the antenna 01, the antenna 02, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0114] Antenna 01 and antenna 02 are used to transmit and receive electromagnetic wave signals.
[0115] The mobile communication module 150 can provide wireless communication solutions including 2G / 3G / 4G / 5G etc. applied on the electronic device 100 .
[0116] A modem processor may include a modulator and a demodulator.
[0117] The wireless communication module 160 can provide wireless communication solutions for application in the electronic device 100, including Wireless Local Area Networks (WLAN) (such as Wireless Fidelity (Wi-Fi) network), Bluetooth (BT), Global Navigation Satellite System (GNSS), Frequency Modulation (FM), Near Field Communication (NFC), infrared technology (IR), etc.
[0118] The electronic device 100 implements the display function through a GPU, a display screen 193, and an application processor, etc. The GPU is a microprocessor for image processing, and is connected to the display screen 193 and the application processor.
[0119] The display screen 193 is used to display images, videos, etc.
[0120] The electronic device 100 can realize the shooting function through ISP, camera 192, video codec, GPU, display screen 193 and application processor.
[0121] The ISP is used to process the data fed back by the camera 192 .
[0122] Camera 192 is used to capture still images or videos.
[0123] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
[0124] The touch sensor 180A is also called a "touch control device". The touch sensor 180A can be set on the display screen 193. The touch sensor 180A and the display screen 193 form a touch screen, also called a "touch control screen". The touch sensor 180A is used to detect touch operations acting on or near it.
[0125] The gyro sensor 180B may be used to determine the motion posture of the electronic device 100 .
[0126] The air pressure sensor 180C is used to measure air pressure.
[0127] The geomagnetic sensor 180D includes a Hall sensor.
[0128] The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes).
[0129] The distance sensor 180F is used to measure the distance.
[0130] The proximity light sensor 180G is used to determine whether there is an object near the electronic device 100 .
[0131] The fingerprint sensor 180H is used to collect fingerprints.
[0132] The temperature sensor 180J is used to detect the temperature.
[0133] Buttons 190 include a power button, a volume button, and the like.
[0134] Motor 191 can generate vibration prompts.
[0135] The SIM card interface 194 is used to connect a SIM card.
[0136] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device 100.
[0137] Figure 6 It is a software structure block diagram of the electronic device provided in the embodiment of the present application.
[0138] The layered architecture divides the software into several layers, each with clear roles 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: the application layer, the application framework layer, the Android runtime and system library, and the kernel layer.
[0139] The application layer can include a series of application packages.
[0140] like Figure 6 As shown, the application package may include applications such as battery management, camera, gallery, calendar, call, map, navigation, music, video, short message, game, etc.
[0141] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.
[0142] like Figure 6 As shown, the application framework layer may include a window manager, an input manager, a sensor manager, a phone manager, a resource manager, a notification manager, and the like.
[0143] The input manager can be used to monitor the user's input events, such as click events and slide events performed by the user's finger on the display screen 193 of the electronic device 100. By monitoring the input events, the electronic device 100 can determine whether the electronic device is being used.
[0144] The sensor manager is used to monitor the data returned by various sensors in the electronic device, such as motion sensor data, proximity light sensor data, temperature sensor data, etc. Using the data returned by each sensor, the electronic device can determine whether it is shaking, or whether the display screen 193 is blocked, etc.
[0145] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.
[0146] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
[0147] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0148] The system library may include multiple functional modules, such as: Surface Manager, Media Libraries, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
[0149] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.
[0150] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0151] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0152] A 2D graphics engine is a drawing engine for 2D drawings.
[0153] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
[0154] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic 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.
[0155] The embodiment of the present application is exemplified by an electronic device using a virtual A / B operating system. The operating system upgrade method can be executed by an operating system update program installed on the electronic device. The operating system update program can include an online update client tool (online update client apk, ouc apk) and an upgrade engine (UpdateEngine). The ouc apk is used to obtain a system upgrade package for the operating system, and the upgrade engine is used to drive the upgrade of the operating system.
[0156] For example, the operating system upgrade process in the embodiment of the present application is described with the electronic device booting from static partition A and based on the running of operating system A1.
[0157] It should be noted here that the embodiment of the present application is only exemplified by the electronic device starting from static partition A and running based on operating system A1. In fact, the electronic device can also be started from static partition B and run based on operating system B1, and the embodiment of the present application is not limited to this.
[0158] Figure 7 It is a flowchart of the operating system upgrade method provided in an embodiment of the present application.
[0159] like Figure 7 As shown, the OTA upgrade process includes the following steps S101-S120.
[0160] Step S101, creating a system upgrade package based on a package server.
[0161] Among them, the system upgrade package can be a full upgrade package. The full upgrade package refers to a complete software upgrade package or firmware upgrade package, which includes all update contents of the corresponding software or firmware. The full upgrade package can directly upgrade any version of the software or firmware to the latest version without multiple upgrades in the middle.
[0162] The system upgrade package includes data indicating that the operating system of the electronic device is upgraded from the currently running system standard to the target standard. The target standard is different from the currently running system standard in the electronic device. The currently running system standard may be a first standard, for example, the first standard is demo_cn, and the target standard may be a second standard, for example, the second standard is all_cn.
[0163] Specifically, the system upgrade package includes a modified packet, which is used to instruct the operating system of the electronic device to change from the first standard to the second standard. The modified packet can be used when the electronic device enters the Recovery mode. The Recovery mode refers to a special state in which the electronic device enters in order to repair system failures or restore the device to factory settings. In the Recovery mode, the user can perform some advanced operations to solve the problem, such as clearing the cache, resetting the device, and installing system updates.
[0164] For example, the data structure of the system upgrade package is as follows:
[0165] demochange.tag;
[0166] META-INF;
[0167] payload.bin;
[0168] payload_properties.txt;
[0169] SOFTWARE_VER.mbn;
[0170] update_base_demochange.zip;
[0171] vendor_country.mbn;
[0172] VERSION.mbn;
[0173] Among them, demochange.tag is a modification tag, which is used to indicate that the system upgrade package can modify the demonstration prototype into a commercial machine. META-INF is the signature information, which is used to perform signature verification on the system upgrade package. payload.bin includes data that can upgrade the operating system from the current system format to the target format. payload_properties.txt is a file that carries parameters such as the file hash value FILE_HASH, the file size FILE_SIZE, and the metadata hash value METADATA_HASH. These parameters are used to ensure the integrity and uniqueness of the file. SOFTWARE_VER.mbn is a software version file used to store the format information of the operating system. The second format can be saved in the root directory of the system upgrade package in the form of the vendor_country.mbn file. update_base_demochange.zip is a modification package.
[0174] For example, the data structure of update_base_demochange.zip is as follows:
[0175] Ptable;
[0176] Image;
[0177] super_metadata.img;
[0178] META-INF;
[0179] OTA_update.tag;
[0180] PTABLE_SUPER.mbn;
[0181] skipauth_pkg.tag;
[0182] vendor_country.mbn;
[0183] Among them, Ptable is the total partition table corresponding to the target format. The partition table refers to the data structure or table used to manage disk partitions in the storage process of the electronic device, which is used to define the starting address and size of each partition. In this way, Ptable can describe the partition deployment in the storage device (ROM) after upgrading to the target format. For example, Ptable includes the starting address and ending address in the storage space of the Common partition, system partition, and Userdata partition.
[0184] For example, the total partition table is shown in Table 1 below.
[0185]
[0186] Image may include super_metadata.img, which is a sub-partition table of the Super partition corresponding to the second standard, used to describe the start address and end address of each sub-partition in the Super partition after the electronic device is upgraded to the second standard. The setting method of the sub-partition table can refer to the above-mentioned general partition table.
[0187] The META-INF in the modified package can play the same verification role as the META-INF in the system upgrade package.
[0188] The second format can be saved in the root directory of the modified package as the vendor_country.mbn file.
[0189] The modified package can also include empty images such as userdata.img and metadata.img. EmptyImage usually refers to an image file that does not contain any actual data. Its size depends on the required capacity or reserved space. Since an empty image does not contain any actual data, the required data needs to be written or copied to the image before using it.
[0190] It should be noted here that step S101 can be executed before the electronic device is started from the static partition A, or it can be executed after the electronic device is started from the static partition A, and the embodiment of the present application is not limited to this.
[0191] Step S102: the packet upload server uploads the system upgrade package to the cloud server.
[0192] Step S103: the electronic device downloads and installs the system upgrade package from the cloud server.
[0193] In one implementation, the electronic device downloads the system upgrade package through ouc apk. The electronic device can periodically initiate a package search request to the cloud server through ouc apk. The package search request contains the version number of the operating system currently running on the electronic device (for example, version 1.1). The cloud server searches whether there is a system upgrade package with a newer version number (for example, version 1.2) according to the version number of the operating system in the package search request. When there is a newer version of the system upgrade package, the cloud server feeds back the download address of the system upgrade package (for example, the full system upgrade package of version 1.2) to the electronic device, and the electronic device downloads it according to the download address of the system upgrade package to obtain the system upgrade package.
[0194] In one implementation, after obtaining the system upgrade package, the cloud server can actively push the system upgrade package to the electronic device, and the electronic device downloads the system upgrade package according to the push.
[0195] After the electronic device downloads the system upgrade package, it installs the system upgrade package.
[0196] Taking the example of an electronic device downloading a system upgrade package through ouc apk, after the electronic device obtains the system upgrade package, it saves the system upgrade package to the Userdata partition through ouc apk.
[0197] Step S104, the electronic device verifies the system upgrade package.
[0198] After the electronic device completes downloading and installing the system upgrade package, it starts the upgrade engine, which then upgrades the operating system according to the system upgrade package.
[0199] In one implementation, after the ouc apk obtains the system upgrade package, the ouc apk sets the startup attribute of the upgrade engine and sets the startup attribute to true. In this way, the servicemanger resident in the operating system background of the electronic device monitors the startup attribute of the upgrade engine. When the servicemanger detects that the startup attribute of the upgrade engine is true, the servicemanger starts the upgrade engine.
[0200] Ouc apk obtains the status of the upgrade engine through messenger binder communication. When ouc apk confirms that the upgrade engine has been successfully started, ouc apk passes the upgrade parameters to the upgrade engine, thereby triggering the upgrade engine to enter the upgrade process. Among them, the upgrade parameters can be used to indicate whether the current upgrade operation is a file update operation or a file drop operation. File update is the process of replacing the old version of the file with the new version of the file when the software or system is upgraded. File update can ensure that the new version of the code and data can run normally on the electronic device. File drop is the process of temporarily storing the new version of the file in the memory after the file update is completed. In order to ensure the stability of the upgrade and the integrity of the data, these files need to be written to the persistent storage of the electronic device, which is called file drop. File drop can ensure the security and consistency of the data.
[0201] After the upgrade engine is successfully started, the system upgrade package is verified.
[0202] In one implementation, the upgrade engine can verify whether the META-INF in the system upgrade package is legal, and determine whether the system upgrade package is a legal upgrade package. The specific process of the verification is not described in detail in this application.
[0203] Step S105: the electronic device is upgraded according to the system upgrade package.
[0204] After the upgrade engine successfully verifies the system upgrade package, the electronic device can start executing the virtual A / B upgrade process. The virtual A / B upgrade process includes the electronic device starting the upgrade process for the operating system B1 based on the system upgrade package when the operating system A1 is running.
[0205] The specific upgrade process of step S105 can be as follows: Figure 8 shown.
[0206] Figure 8 It is a schematic diagram of the virtual A / B upgrade process provided in an embodiment of the present application.
[0207] like Figure 8 As shown, the virtual A / B upgrade process includes the following steps S1051-S1056.
[0208] Step S1051, the electronic device reads the saved system upgrade package from the Userdata partition, and writes data to the static partition B according to the system upgrade package to upgrade the static partition.
[0209] That is, the electronic device writes the static image to the static partition B. A static image is a static, unchangeable image created based on a system upgrade package, which contains the complete content and status of the original system or file and is usually in a read-only form. For example, a system upgrade package with version 1.2 contains data of a static partition (i.e., a static image), and the upgrade engine overwrites the static image to the static partition B.
[0210] It should be noted here that the data operation of the static partition upgrade is only for the static partition B, and will not affect the data operation in the currently started static partition A.
[0211] Step S1052: the electronic device creates a virtual dynamic partition in the Userdata partition according to the system upgrade package, and writes the upgrade data of the Super partition into the virtual dynamic partition.
[0212] That is, the electronic device writes the dynamic image in the system upgrade package into the virtual dynamic partition. A dynamic image is an image or picture created based on the system upgrade package that can be modified, updated, and expanded. Unlike a static image, a dynamic image allows its content to be changed and can be dynamically adjusted and managed as needed. For example, the system upgrade package with version 1.2 contains the data of the Super partition, and the electronic device writes the data of the Super partition into the virtual dynamic partition.
[0213] In one implementation, an incremental upgrade method is used for the Super partition. During the upgrade process, the virtual dynamic partition of Userdata does not store all the files of the upgraded new version of the Super partition, but the upgraded results of the data that needs to be upgraded in the old version of the Super partition. That is, the virtual dynamic partition of Userdata stores the updated data of the Super partition.
[0214] Take the System subpartition in the Super partition as an example, if in the version 1.1 operating system, the data in the System subpartition can be divided into System1 and System2, and System2 does not change when upgrading from version 1.1 to version 1.2, then System1 can be upgraded to System3. Then, when the electronic device creates a virtual dynamic partition in the Userdata partition, it writes the data of System3 in the virtual dynamic partition.
[0215] It should be noted here that in the virtual A / B upgrade mode, the incremental upgrade of the Super partition can be implemented based on the snapshot technology (Snapshot).
[0216] Specifically, in the virtual dynamic partition in the Userdata partition, a Copy-On-Write (COW) file is used to save the upgrade data of the Super partition.
[0217] In the system upgrade package, the COW file containing the upgrade data of the Super partition is compressed and saved in binary code form. Each COW file corresponds to a subpartition of the Super partition. The COW file is named according to the subpartition of the Super partition. For example, the COW file is named system-cow-img.img.0000.
[0218] The electronic device unpacks the system upgrade package to obtain all COW files and attaches virtual A / B partition marks to each COW file. For example, when the electronic device starts from static partition A, it can be understood that the Super partition loaded by the operating system currently running on the electronic device is dynamic partition A, that is, Super_a. In the process of upgrading the operating system, the virtual dynamic partition created in the Userdata partition is for dynamic partition B, that is, Super_b. At this time, the name mark _b of the corresponding dynamic partition B can be attached to the COW file. For example, appending _b to system-cow-img.img.0000 generates system_b-cow-img.img.0000.
[0219] Furthermore, an Update folder is created in the Userdata partition, and the renamed COW file is saved in the Update folder. In this way, the writing of the COW file in the virtual dynamic partition is realized.
[0220] For example, the Update folder in the Userdata partition contains the following COW files:
[0221] system_b-cow-img.img.0000;
[0222] product_b-cow-img.img.0000;
[0223] Version_b-cow-img.img.0000;
[0224] preload_b-cow-img.img.0000.
[0225] The COW file includes the COW file map (snapshot map) and upgrade data of the COW file itself.
[0226] The COW file map corresponds to the file map in the sub-partition of the Super partition, and the file map in the sub-partition of the Super partition is used to describe each file in the sub-partition of the Super partition in the current version of the operating system and the corresponding storage address. The current version of the operating system refers to the operating system before this upgrade, such as the version 1.1 operating system.
[0227] The upgrade data in the COW file is the update file of the sub-partition of the new version of the Super partition. The COW file map in the COW file is used to describe the correspondence between the update file of the sub-partition of the new version of the Super partition and the file of the sub-partition of the current version, as well as the save address of the update file.
[0228] Based on the file map in the sub-partition of the Super partition and the COW file map in the COW file, the corresponding files in the sub-partition of the Super partition can be replaced with the upgraded data in the COW file, thereby realizing the data upgrade of the Super partition.
[0229] In one implementation, when it is necessary to obtain a file map of a sub-partition of a Super partition, the electronic device may perform a snapshot operation on the data of the sub-partition of the Super partition based on the Snapshot to generate a file map of the sub-partition of the Super partition.
[0230] In one implementation, during the process of making the system upgrade package, a file map of the sub-partition of the Super partition is generated in advance, and the file map is stored in the COW file.
[0231] The following takes the System sub-partition in the Super partition as an example to describe the data upgrade process of the Super partition.
[0232] For example, the System subpartition stores data according to the following path:
[0233] / system / app / A0.XXX;
[0234] / system / app / A1.XXX;
[0235] / system / app / A2.XXX;
[0236] / system / B0.XXX;
[0237] / system / B1.XXX;
[0238] / system / user / C0.XXX;
[0239] / system / user / C1.XXX;
[0240] / system / user / C2.XXX;
[0241] / system / user / C3.XXX.
[0242] For the above save path, the file map of the System subpartition can be:
[0243] / system / app / A0.XXX:024010~024013;
[0244] / system / app / A1.XXX: 024014~024017;
[0245] / system / app / A2.XXX: 024018~024020;
[0246] / system / B0.XXX:024021~024026;
[0247] / system / B1.XXX: 024027~024028;
[0248] / system / user / C0.XXX: 024029~024032;
[0249] / system / user / C1.XXX: 024033~024035;
[0250] / system / user / C2.XXX: 024036~024040;
[0251] / system / user / C3.XXX:024041~024044.
[0252] The value after the file name is the physical storage address (also called block address) of the file in the System subpartition.
[0253] For example, in “ / system / app / A0.XXX:024010~024013”, 024010~024013 is the physical storage address.
[0254] If the current operating system upgrade requires updating data / system / app / A2.XXX and / system / user / C2.XXX, then / system / app / A2.XXX and / system / user / C2.XXX can be considered as the System1 part of the System subpartition, and accordingly, / system / app / A0.XXX, / system / app / A1.XXX, / system / B0.XXX, / system / B1.XXX, / system / user / C0.XXX, / system / user / C1.XXX and / system / user / C3.XXX are the System2 part of the System subpartition.
[0255] Therefore, the COW file system_b-cow-img.img.0000 of the System subpartition contains the new version of / system / app / A2.XXX and / system / user / C2.XXX. In this way, the new version of / system / app / A2.XXX and / system / user / C2.XXX can be regarded as System3, and System1 can be upgraded from version 1.1 to version 1.2 to System3.
[0256] When the size of the updated data in the COW file is consistent with the size of the original data to be updated, and the storage location of the updated data in the COW file in the subpartition after the data is updated is consistent with the storage location of the original data to be updated in the subpartition, the file map of the COW file can be in the following form:
[0257] Take the COW file system_b-cow-img.img.0000 as an example, where:
[0258] / system / app / A2.XXX:
[0259] Map1: starting address address start: 024018; offset size size: 2.
[0260] Among them, Map1 is the address of the data to be updated in the original Super partition, the starting address 024018 is the offset relative to the starting address of System, and the offset size 2 is the data in the address segment of 024018 to 024020.
[0261] Map2: starting address address start: 045033; offset size size: 2.
[0262] Among them, Map2 is the address of the updated data stored in the COW file, the starting address 045033 is the offset relative to the starting address stored in the COW file, and the offset size 2 is the data in the address segment of 045033 to 045035.
[0263] / system / user / C2.XXX:
[0264] Map1: starting address address start: 024036; offset size size: 4.
[0265] Among them, Map1 is the address of the data to be updated in the original Super partition, the starting address 024036 is the offset relative to the starting address of System, and the offset size 4 is the data in the address segment of 024036 to 024040.
[0266] Map2: starting address address start: 045036; offset size size: 4.
[0267] Among them, Map2 is the address of the updated data stored in the COW file, the starting address 045036 is the offset relative to the starting address stored in the COW file, and the offset size 2 is the data in the address segment of 045036 to 045040.
[0268] When the size of the updated data in the COW file is inconsistent with the size of the original data to be updated, the file map of the COW file can be in the following form:
[0269] Take the COW file system_b-cow-img.img.0000 as an example, where:
[0270] / system / app / A2.XXX:
[0271] Map1.1: starting address address start: 024018; offset size size: 2.
[0272] Among them, Map1 is the address of the data to be updated in the original Super partition, the starting address 024018 is the offset relative to the starting address of System, and the offset size 2 is the data in the address segment of 024018 to 024020.
[0273] Map2.1: starting address address start: 045033; offset size size: 2.
[0274] Among them, Map2.1 is the address of the updated data stored in the COW file, the starting address 045033 is the offset relative to the starting address stored in the COW file, and the offset size 2 is the data in the address segment of 045033 to 045035.
[0275] Map1.2: starting address address start: 025018; offset size size: 1.
[0276] Among them, Map1.2 is the address to be written in the original Super partition of the part of the updated data in the COW file that exceeds the data to be updated. The starting address 025018 is the offset relative to the System starting address, and the offset size 1 is the data in the address range of 025018 to 025020.
[0277] Map2.2: starting address address start: 046033; offset size size: 2.
[0278] Among them, Map2.2 is the update data address stored in the COW file for overwriting Map1.2, the starting address 046033 is the offset relative to the starting address stored in the COW file, and the offset size 2 is the data in the address segment of 046033 to 046035.
[0279] In the following embodiments, exemplary description is only given when the size of the updated data in the COW file is consistent with the size of the original data to be updated, and the storage location of the updated data in the COW file in the sub-partition after the data is updated is consistent with the storage location of the original data to be updated in the sub-partition.
[0280] In the above embodiment, address segment 045033-045035 is the physical storage address of / system / app / A2.XXX in the Userdata partition in the COW file, and address segment 045036-045040 is the physical storage address of / system / user / C2.XXX in the Userdata partition in the COW file. In this way, if A2.XXX at addresses 045033-045035 is used to replace A2.XXX at addresses 024018-024020, and C2.XXX at addresses 045036-045040 is used to replace C2.XXX at addresses 024036-024040, the data upgrade of the System sub-partition in the Super partition can be completed.
[0281] Furthermore, after the COW file is written to the Userdata partition, the Super partition and the COW file need to be verified as a whole. In this way, the validity of the Super partition and the COW file can be verified, and it can be verified whether the synthesis result of the data of the current version of the Super partition and the COW file is the data of the new version of the Super partition.
[0282] For example, taking the upgrade from version 1.1 to version 1.2 as an example, the electronic device calculates the hash value of the data that does not need to be upgraded in the Super partition and the upgraded data in the COW file, and determines whether the hash value is consistent with the hash value of the complete data of the Super partition in version 1.2. If they are consistent, the COW file is valid. If they are inconsistent, the COW file is invalid, the operating system upgrade fails, the upgrade engine process is interrupted and an error is reported. Among them, the hash value of the complete data of the Super partition is stored in the system upgrade package.
[0283] Among them, when verifying the validity of the Super partition and the COW file, it is necessary to merge the Super partition and the COW file based on the Snapshot. It should be noted here that the merging of the Super partition and the COW file based on the Snapshot is not a physical merger, but a merger of the overall file map of the System subpartition and the COW file map of the COW file to generate a new version of the file map of the System subpartition data.
[0284] For example, the file map of the System subpartition is:
[0285] / system / app / A0.XXX:024010~024013;
[0286] / system / app / A1.XXX: 024014~024017;
[0287] / system / app / A2.XXX: 024018~024020;
[0288] / system / B0.XXX:024021~024026;
[0289] / system / B1.XXX: 024027~024028;
[0290] / system / user / C0.XXX: 024029~024032;
[0291] / system / user / C1.XXX: 024033~024035;
[0292] / system / user / C2.XXX: 024036~024040;
[0293] / system / user / C3.XXX:024041~024044.
[0294] The COW file map is:
[0295] / system / app / A2.XXX:
[0296] Map1: address start: 024018; size: 2 (i.e. data in the address segment 024018 to 024020);
[0297] Map2: address start: 045033; size: 2 (i.e., data in the address segment 045033 to 045035).
[0298] / system / user / C2.XXX:
[0299] Map1: address start: 024036; size: 4 (i.e. data in the address segment 024036 to 024040);
[0300] Map2: address start: 045036; size: 4 (i.e. data in the address segment 045036 to 045040).
[0301] Merge the above file map of the System subpartition with the COW file map to obtain the new version of the file map of the System subpartition:
[0302] / system / app / A0.XXX: 024010~024013 (pointing to A0.XXX under / system / app in Super partition);
[0303] / system / app / A1.XXX: 024014~024017 (pointing to A1.XXX under / system / app in Super partition);
[0304] / system / app / A2.XXX: 045033~045035;
[0305] (pointing to A2.XXX in / Update / system_b-cow-img.img.0000 in Userdata partition);
[0306] / system / B0.XXX: 024021-024026 (pointing to B0.XXX under / system / app in the Super partition);
[0307] / system / B1.XXX: 024027~024028 (pointing to B1.XXX under / system / app in Super partition);
[0308] / system / user / C0.XXX: 024029-024032 (pointing to C0.XXX under / system / app in the Super partition);
[0309] / system / user / C1.XXX: 024033~024035 (pointing to C1.XXX under / system / app in Super partition);
[0310] / system / user / C2.XXX: 045036~045040;
[0311] (pointing to C2.XXX in / Update / system_b-cow-img.img.0000 in Userdata partition);
[0312] / system / user / C3.XXX: 024041~024044 (pointing to C3.XXX under / system / app in the Super partition).
[0313] It can be seen that in the file map of the new version of the System subpartition, the storage address of / system / app / A2.XXX does not point to A2.XXX under system / app in the Super partition on the memory, but points to A2.XXX in / Update / system_b-cow-img.img.0000 in the Userdata partition. The storage address of / system / user / C2.XXX does not point to C2.XXX under system / app in the Super partition on the memory, but points to C2.XXX in / Update / system_b-cow-img.img.0000 in the Userdata partition. In this way, during the verification process, according to the above-mentioned synthesis method, the new version of the file map of all subpartitions in the Super partition is obtained, and the new version of the file map of all subpartitions is combined to generate a new version of the file system of the Super partition. Among them, if the COW file corresponding to a subpartition is not written in the Userdata partition, then the file map of the subpartition can be directly used as the new version of the file map.
[0314] After the electronic device obtains the new version of the file system of the Super partition, it reads data based on the file system, obtains all files contained in the file system and calculates hash values.
[0315] When it is determined that the COW file is valid, the electronic device changes the disk-falling status information in the metadata partition ( / metadata) of the Common partition from "fallen to disk (merged)" to "not fallen to disk (wait for merge)". The disk-falling status information is used to indicate whether there is a COW file that needs to be fallen to disk in the Super partition. Among them, the disk-falling status information includes an overall identification for the Super and a sub-partition identification for each sub-partition. When the overall identification is "fallen to disk", it means that all sub-partitions of the Super partition do not need to be fallen to disk. When the overall identification is "not fallen to disk", it means that one or more sub-partitions of the Super partition need to be fallen to disk. When the sub-partition identification is "fallen to disk", it means that the sub-partition does not need to be fallen to disk. When the sub-partition identification is "not fallen to disk", it means that the sub-partition needs to be fallen to disk.
[0316] In this way, the upgrade data of the Super partition written by the virtual dynamic partition can be used for effective upgrade.
[0317] It should be noted that the data operation of the Super partition upgrade is completed on the virtual dynamic partition in the Userdata partition and will not affect the currently mounted Super partition. Therefore, during the entire operating system upgrade process, users can use electronic devices normally. For the Super partition, a virtual dynamic partition is only created on the Userdata partition when upgrading, which effectively improves the utilization of data storage space.
[0318] In one implementation, after step S1052, the electronic device may also perform a card slot switching operation. The card slot switching operation of the electronic device will not immediately change the currently running operating system, that is, the electronic device will not immediately switch the running operating system A1 to the operating system B1, but will load the system data corresponding to the operating system B1 when the electronic device is started next time, and run with the operating system B1.
[0319] It should be noted here that the electronic device may execute step S1053 after step S1052, or may execute step S1053 after performing a card slot switching operation, and this embodiment of the present application is not limited to this.
[0320] Step S1053: the electronic device detects the modified small package in the system upgrade package through the upgrade engine.
[0321] In one implementation, the upgrade engine detects the package name of the modified small package from the system upgrade package, for example, the package name is update_base_demochange.zip. In this way, it can be determined that the upgrade engine detects the modified small package.
[0322] In one implementation, the upgrade engine detects a remade tag from the system upgrade package, for example, the remade tag is: demochange.tag. In this way, it can be determined that there is a remade small package in the system upgrade package.
[0323] Step S1054: the electronic device reads the second standard from the system upgrade package through the upgrade engine.
[0324] In one implementation, the system upgrade package includes a second standard file, such as vendor_country.mbn. After the electronic device parses the system upgrade package, it can read the second standard all_cn from the vendor_country.mbn file.
[0325] Step S1055: the electronic device writes the second standard into the first temporary file through the upgrade engine.
[0326] For example, the first temporary file is the oeminfo_vc_tmp file. The oeminfo_vc_tmp file is a temporary file in the oeminfo subpartition in the Common partition, occupying temporary storage space in the oeminfo subpartition. The oeminfo_vc_tmp file is different from the oeminfo_vc file in the oeminfo subpartition. This is because the oeminfo_vc file includes the standard information before the operating system upgrade (for example, the standard information of version 1.1). Therefore, the physical addresses actually occupied by the oeminfo_vc_tmp file and the oeminfo_vc file in the oeminfo subpartition are different, and the storage address corresponding to the oeminfo_vc file is the address where the electronic device loads the standard information. In this way, when the electronic device loads system data, it will load the oeminfo_vc file but not the oeminfo_vc_tmp file.
[0327] It should be noted here that step S1055 is only an exemplary description of the second standard temporarily stored in the system upgrade package. The second standard can also be written into other temporary storage areas that can be read, and the embodiment of the present application is not limited to this.
[0328] Step S1056: The electronic device decompresses the reformed small package into the first update directory through the upgrade engine.
[0329] For example, the first update directory is the cache / update directory. The cache / update directory is a directory under the Cache subpartition in the Common partition. The Cache subpartition is a storage partition that the electronic device can access in Recovery mode. Since the reformed small package includes Ptable and super_metadata.img, after the electronic device decompresses the reformed small package to the cache / update directory, the directory includes Ptable and super_metadata.img.
[0330] Specifically, the electronic device stores super_metadata.img in the / cache / recovery path, and writes a command instructing to modify the upgrade data into the / cache / recovery / command file.
[0331] It should be noted here that, in the process of the electronic device running based on the operating system A1, after the operating system A1 starts the Common partition, static partition A and Super partition in sequence, since the super_metadata.img corresponding to the first standard, that is, the first partition table, has been pre-stored in the Super partition, the electronic device can read the first partition table after loading the Super partition. In the above steps, the electronic device stores the super_metadata.img in the modified package, that is, the second partition table, to the / cache / recovery path, and can then read the second partition table.
[0332] Step S106: The electronic device restarts for the first time and enters Recovery mode.
[0333] The electronic device exits the current operating system, cuts off the power of the electronic device, and then turns on the power of the electronic device again.
[0334] It should be noted here that after the electronic device completes steps S101 to S105, it does not need to restart immediately, and the restart time can be selected according to the user's wishes. In this way, the operating system upgrade process will not affect the user's normal operation, thereby greatly improving the user experience.
[0335] Step S107: the electronic device loads the Common partition and the static partition B in sequence.
[0336] The Common partition of the electronic device includes an MBR, which is configured with a boot sequence identifier. When the electronic device starts the operating system, it can read the boot sequence identifier from the MBR and determine the static partition to be loaded according to the boot sequence identifier, so that the electronic device can determine to start the operating system A1 or the operating system B1.
[0337] In one implementation, after the electronic device performs the card slot switching operation, the electronic device may rewrite the boot sequence identifier of the MBR, for example, rewrite the boot sequence identifier from A to B.
[0338] In this way, after the electronic device is powered on, if the boot sequence identifier read is A, the electronic device starts from static partition A and loads static partition A during the boot process. If the boot sequence identifier read is B, the electronic device starts from static partition B and loads static partition B during the boot process.
[0339] In a specific implementation, the electronic device first loads the Common partition. During the process of loading the Common partition, the electronic device reads the startup mark in the Common partition. When the startup sequence is marked as B, the electronic device loads the static partition B after loading the Common partition, and is started by the static partition B. This is because the embodiment of the present application is initially started from the static partition A, and is exemplarily described based on the operation of the operating system A1.
[0340] Step S108, the electronic device loads the virtual dynamic partition of the Super partition and the Userdata partition.
[0341] In one implementation, the electronic device reads the disk-falling status information in the metadata partition, determines whether it is necessary to retrieve the COW file from the specified path of the Userdata partition based on the disk-falling status information, and uses Snapshot to merge and load the Super partition and the COW file.
[0342] The electronic device does not load all COW files in the Super partition and the Userdata partition, but determines the files to be loaded according to the operating system running requirements, and loads the files based on the new version of the file map of the sub-partition of the Super partition.
[0343] For example, the operating system operation requirement is to load all the data in the directory user ( / system / user) under the System subpartition, then the electronic device reads the disk status information in the metadata partition. When the subpartition mark of the System subpartition in the disk status information is "not flushed to disk", the electronic device searches for the COW file under / Update in the Userdata partition.
[0344] After the electronic device searches for the COW file system_b-cow-img.img.0000 under / Update, based on the Snapshot, the electronic device generates a new version of the file map of the System subpartition according to the file map of the COW file in system_b-cow-img.img.0000, and loads data according to the save addresses of all files under / system / user in the new version of the file map of the System subpartition.
[0345] For example, the new version of the file map for the System subpartition:
[0346] / system / user / C0.XXX: 024029~024032;
[0347] / system / user / C1.XXX: 024033~024035;
[0348] / system / user / C2.XXX: 045036~045040;
[0349] / system / user / C3.XXX:024041~024044.
[0350] The electronic device can load C0.XXX at addresses 024029-024032, C1.XXX at addresses 024033-024035, C2.XXX at addresses 045036-045040, and C3.XXX at addresses 024041-024044.
[0351] In one implementation, when an electronic device loads all the data in the directory user ( / system / user) under the System subpartition, when the subpartition of the System subpartition in the disk status information is marked as "already flushed to disk", the electronic device will not search for the COW file under / Update in the Userdata partition, but directly loads all the data in the directory user ( / system / user) under the System subpartition.
[0352] In one implementation, when the electronic device loads all the data in the directory user ( / system / user) under the System subpartition, when the subpartition identifier of the System subpartition in the disk status information is "not stored on disk", if the electronic device does not search for the COW file corresponding to the System subpartition under / Update in the Userdata partition, it means that there is a data writing error in the electronic device during the upgrade process, for example: a COW file writing error or a disk status information writing error. At this time, the electronic device rolls back the system and reports an error.
[0353] In one implementation, before the electronic device loads the file, the electronic device also needs to verify the loaded file. Different from the verification process in step S1052, in this step, the Super partition and COW file are not verified as a whole, and only the file to be loaded is verified.
[0354] For example, the electronic device can verify the loaded file based on dm-verity. Among them, dm-verity is a target (Target) of the device mapper (Dm), which is a virtual block device used for file system verification. In this way, if the electronic device verifies successfully, the file is loaded. If the electronic device verifies unsuccessfully, the electronic device is restarted, the system is rolled back, or the file is tried to be loaded again.
[0355] Step S109: the electronic device triggers a merge process through the upgrade engine.
[0356] In one implementation, after the electronic device is restarted for the first time, the new system takes effect, that is, when the updated operating system B1 takes effect, the Merge process is started.
[0357] Fig. 9 It is a schematic diagram of a Merge process provided in an embodiment of the present application.
[0358] like Fig. 9 As shown, the Merge process includes steps S1091 to S1092.
[0359] Step S1091, after the electronic device is restarted for the first time, it enters the user interaction interface.
[0360] Step S1092: the electronic device merges the data of the virtual dynamic partition into the Super partition in the background.
[0361] That is to say, the electronic device writes the data of the virtual dynamic partition to the Super partition in the background. The write operation means that during the upgrade process of the operating system, the electronic device writes the COW file of the Super partition saved in the virtual dynamic partition on Userdata to the Super partition, so that the file in the Super partition completes the data upgrade, so that the electronic device does not need to load the Super partition and the virtual dynamic partition when it starts next time, and only needs to load the Super partition to complete the startup of the electronic device.
[0362] In one implementation, after the electronic device starts successfully, a power-on broadcast is performed, and after the power-on broadcast, the process corresponding to the upgrade engine is started. The process corresponding to the upgrade engine reads the disk-falling status information in the metadata partition of the Common partition. If the disk-falling status information is "fallen to disk", the electronic device enters the normal operation mode. If the disk-falling status information is "not fallen to disk", the process corresponding to the upgrade engine will fall the COW file in the Userdata partition to the Super partition. Specifically, the process corresponding to the upgrade engine writes the upgrade data in the COW file in the Userdata partition to the corresponding address in Super, so that all data in the Super partition are the data of the new version after the upgrade.
[0363] For example, based on / system / app / A2.XXX:024018-024020 in the file map of the System subpartition and / system / app / A2.XXX:045033-045035 in the COW file map, the data at addresses 045033-045035 are written to addresses 024018-024020. Based on / system / user / C2.XXX:024036-024040 in the file map of the System subpartition and / system / user / C2.XXX:045036-045040 in the COW file map, the data at addresses 045036-045040 are written to addresses 024036-024040.
[0364] Furthermore, the process corresponding to the upgrade engine deletes the COW file in the Userdata partition, returns the storage space to the Userdata partition, and changes the disk-falling status information in the metadata partition in the Common partition from "not fallen to disk" to "fallen to disk".
[0365] After the Merge process is completed, the space occupied by the data in the Version subpartition of the Super partition becomes smaller. At the same time, the position of the Preload subpartition remains unchanged. At this time, free space will be formed between the Version subpartition and the Preload subpartition. This free space is a storage space that cannot be actually used.
[0366] Fig.10 This is a schematic diagram of the operating system partition architecture after the Merge process provided in an embodiment of the present application is completed.
[0367] like Fig.10 As shown in the figure, after the Merge process is completed, the starting address of the Version subpartition remains unchanged, and the ending address becomes smaller, so that the physical storage space occupied by the Version subpartition is reduced. For example, the size of the Version subpartition is reduced from 8GB to 2GB.
[0368] The start address and end address of the Preload subpartition remain unchanged, so an idle physical storage area, namely, Free space, appears between the Version subpartition and the Preload subpartition.
[0369] Before the Merge process, the sub-partition in the Super partition is the third sub-partition under the first standard. After the Merge process is completed, the sub-partition in the Super partition is updated to the first sub-partition under the second standard.
[0370] Step S110 , the electronic device copies the static partition B of the operating system B1 to the static partition A of the operating system A1 through the upgrade engine.
[0371] It should be noted here that the embodiments of the present application include but are not limited to updating the static partition A through step S110. The upgrade engine can also use the system upgrade package to update the data in the static partition A. The embodiments of the present application do not specifically limit the update method of the static partition A.
[0372] Step S111: the electronic device writes the second format in the first temporary file into the first storage file in the first storage sub-partition through the upgrade engine.
[0373] In one implementation, the first temporary file is an oeminfo_vc_tmp file, the first storage subpartition is an oeminfo subpartition, and the first storage file is an oeminfo_vc file. Since the second standard written in oeminfo_vc_tmp is read from the system upgrade package, for example, all_cn, the second standard is different from the first standard demo_cn that the electronic device has before the operating system upgrade, that is, the second standard in oeminfo_vc_tmp is different from the first standard in the oeminfo_vc file, so that after the second standard in oeminfo_vc_tmp is written into the oeminfo_vc file, the original first standard of the oeminfo_vc file can be overwritten, thereby realizing the change of the standard and changing demo_cn to all_cn.
[0374] Since the oeminfo sub-partition belongs to the Common partition, when the operating system is started by the Common partition, the second standard all_cn is read from the oeminfo_vc file of the oeminfo sub-partition, thereby realizing the change of the standard of the electronic device.
[0375] After electronic devices complete the format change, they still need to further improve the problem of low storage space utilization.
[0376] Step S112: When the electronic device detects through the upgrade engine that the first update directory includes a remade packet, it writes data indicating the remade upgrade into the first path file.
[0377] In one implementation, the first update directory is cache / update, and the first path file is cache / recovery / command file. For example, the data indicating the modification and upgrade may be information of the storage path of the standard modification package. For example, when the modification package is stored in the cache / update directory, the path information indicating the storage of the modification package may be "update_package= / cache / update / update_base_demochange.zip". In this way, after the electronic device enters the Recovery mode, the modification package can be found according to the storage path.
[0378] It should be noted here that after the electronic device enters the Recovery mode, it can also obtain the modified small package in other ways. For example, when the electronic device detects that the cache / update directory includes the modified small package, it can use the modified small package as data indicating the modification and upgrade. Specifically, after the electronic device detects that the cache / update directory includes the modified small package, it moves the modified small package to the cache / recovery directory.
[0379] Step S113: the electronic device restarts for the second time and enters the Recovery mode.
[0380] The electronic device triggers a restart through the upgrade engine, and starts the Recovery process after being instructed to enter the Recovery mode.
[0381] Step S114: the electronic device verifies the integrity of the system upgrade package through the Recovery process.
[0382] Among them, the specific implementation method of this step can refer to the implementation method of verifying the integrity of the upgrade package in the relevant technology, and the embodiment of the present application will not go into details about it.
[0383] Step S115 , when the Recovery process of the electronic device determines that the current scenario is a remodeling and upgrading scenario based on the first path file, the global variables are configured.
[0384] In one implementation, the first path file is the cache / recovery / command file, and the global variable is vcdemo. The Recovery process of the electronic device can parse the command file in the cache / recovery / directory to obtain the storage path. At this time, the Recovery process accesses the corresponding storage space based on the storage path. If there is a data packet in the storage space, if it is determined that the package name of the data packet is the same as the predefined modified small package name, it is determined that the current scenario is a modification upgrade. Alternatively, if it is determined that there is an indication of modification in the data packet, it can also be determined that the current scenario is a modification upgrade.
[0385] In one implementation, when the electronic device determines that the current scenario is a remodeling and upgrading scenario, the global variable vcdemo is written into a specified storage location through the Recovery process, wherein the specified storage location may be a cache accessible to the Recovery process.
[0386] It should be noted here that the electronic device can indicate that this upgrade is a re-engineering upgrade by configuring the global variable vcdemo, or it can indicate the re-engineering upgrade in other ways. For example, the electronic device actively queries whether there is a re-engineering package in the cache / update directory, so as to remind the Recovery process to execute the subsequent process of the re-engineering upgrade after the re-engineering package is queried.
[0387] Step S116: When the electronic device recognizes the global variable, it performs partition migration through the Recovery process.
[0388] Fig.11 It is a flow chart of the partition migration method provided in an embodiment of the present application.
[0389] Fig.12 Schematic diagram of a partition migration method provided in an embodiment of the present application. Fig.11 and Fig.12 As shown, step S116 includes steps S1161-S1168.
[0390] Step S1161: the electronic device obtains a first partition table.
[0391] Fig.13 It is a schematic diagram of the partition structure corresponding to the first partition table and the second partition table provided in an embodiment of the present application.
[0392] like Fig.13 As shown, the electronic device obtains the first partition table from the Super partition through the Recovery process.
[0393] In one implementation, the Super partition has Super header information, which can be stored in the top 1M storage space of the Super partition. The Super partition includes a first partition table, namely, super_metadata.img corresponding to the Super partition in the current operating system.
[0394] It should be noted here that when the electronic device is started by the static partition A under the first standard, after loading the Common partition, the static partition A and the Super partition in sequence, the first partition table can be read from the Super partition, and the Merge process in the aforementioned step S109 also involves updating the first partition table. Therefore, in step S1161, the first partition table obtained by the Recovery process is actually the updated first partition table, and the updated first partition table corresponds to the following Fig.13 The partition structure of the first sub-partition shown in A.
[0395] Step S1162: the electronic device obtains a second partition table.
[0396] The electronic device obtains the second partition table from the modified packet through the Recovery process. The modified packet includes the second partition table, which is the data structure of super_metadata.img stored in the modified packet. The second partition table corresponds to Fig.13 The partition structure of the second sub-partition is shown in B. The plurality of second sub-partitions are sub-partitions obtained by moving at least a part of the plurality of first sub-partitions.
[0397] It should be noted here that the first partition table and the second partition table are actually sub-partition tables in the Super partition, rather than the total partition table corresponding to the partition architecture of the operating system.
[0398] It should be noted that step S1161 can be executed simultaneously with step S1162, or can be executed before or after step S1162, and this embodiment of the present application is not limited to this.
[0399] Step S1163: Based on the first partition table, the electronic device determines the starting physical addresses of the multiple first sub-partitions in the Super partition.
[0400] Step S1164: Based on the second partition table, the electronic device determines the starting physical addresses of the plurality of second sub-partitions in the Super partition.
[0401] It should be noted that step S1163 can be executed simultaneously with step S1164, or can be executed before or after step S1163, and this embodiment of the present application is not limited to this.
[0402] Fig.14 It is a schematic diagram of the sub-partition table data structure provided in an embodiment of the present application.
[0403] like Fig.14As shown, the sub-partition table can indicate the data stored between the memory addresses 0x0-0x100000. Among them, the memory addresses 0x0-0x1000 can include the reserved partition, which can have a storage capacity of 4 kilobytes, and the memory addresses 0x1000-0x2000 can include the initial geometry Primary Geometry partition, which can only use 52 bytes of storage capacity to indicate the capacity size of the storage device, the number of partitions and the size of each partition, the starting address of each partition on the storage device, and the file system type of the data in each partition. The memory addresses 0x2000-0x3000 can include the backup Backup Geometry partition, which can be used as a backup partition of the Primary Geometry partition, store the same content as in the Primary Geometry partition, and also use 52 bytes of storage capacity. The memory address 0x3000-0x13000 may include the initial data Primary Metadata partition, which may have a storage capacity of 64 kilobytes and is used to store the data in the static partition A. The memory address 0x13000-0x23000 may include the backup data Backup Metadata partition, which may have a storage capacity of 64 kilobytes and is used to store the data in the static partition B. The memory address 0x23000 may include other Backup Metadata partitions, and the memory address of each Backup Metadata partition may be 0x23000-0x33000, 0x33000-0x43000, 0x43000-0x53000, etc. Each Backup Metadata partition may have a storage capacity of 64 kilobytes and is used to back up the static partition A or the static partition B or other data.
[0404] Since some of the above partitions store the same content, the Primary Metadata partition when the current operating system is A1 is used as an example to introduce the data storage structure in this partition.
[0405] The data in the Primary Metadata partition is stored in the Lp metadata (Linux Partition Metadata, LpMetadata) structure. The Lp metadata structure has an Lp metadata partition table (LpMetadataTableDescriptor partitions) (abbreviated as partitions) structure, and the partitions structure is used to indicate the number of partitions in the sub-partition table.
[0406] It should be noted here that the abbreviated data structure involved in the embodiments of the present application is only for the convenience of expression and is not the corresponding abbreviation of the actual data structure.
[0407] For example, the Super partition in the current operating system includes four sub-partitions, namely, the System sub-partition, the Product sub-partition, the Version sub-partition, and the Preload sub-partition. Then, the partitions structure is used to describe that the first partition table has four sub-partitions.
[0408] Furthermore, the partition structure contains a description of each sub-partition.
[0409] Taking the description of the System sub-partition in the partitions structure as an example, the partitions structure has an index (first_extents_index) (referred to as extents) structure, and the extents structure has a number of continuous physical blocks (Number of extents in the partition) (referred to as Number) structure. The Number structure is used to indicate the number of continuous physical blocks in the System sub-partition.
[0410] like Fig.13 As shown in A, since the System subpartition in the Super partition is an independent and complete subpartition, the System subpartition has continuous physical blocks, and the number of continuous physical blocks is 1.
[0411] Correspondingly, the partitions structure also includes descriptions of other subpartitions, and the description of each subpartition has a corresponding Number structure. Therefore, since the Product subpartition and the Version subpartition are both independent and complete subpartitions, the number of continuous physical blocks corresponding to the Product subpartition and the Version subpartition is 1, and since the Preload subpartition has Preload1 and Preload2, the number of continuous physical blocks corresponding to the Preload subpartition is 2.
[0412] Furthermore, the Lp metadata structure also has an Lp metadata continuous physical block (LpMetadataTableDescriptor extents) (abbreviated as Lp extents) structure, wherein the extents structure can reversely index the Lp extents structure to determine the specific data information corresponding to the Lp extents structure according to the extents structure.
[0413] Taking the Lp extents structure corresponding to the System subpartition as an example, the Lp extents structure includes 24 bytes, specifically including:
[0414] unit64_t num_sectors; system, 0x6ac000×512;
[0415] The above quantity structure is used to represent the logical partition size of the continuous physical blocks of the System subpartition.
[0416] The Lp extents structure also includes:
[0417] unit64_t target_data;
[0418] The target data structure is used to represent the starting physical address of the continuous physical block of the System sub-partition. For example, the starting physical address of the System sub-partition may be 0x800×512.
[0419] In this way, the electronic device can obtain the starting physical address of the continuous physical block of the System sub-partition and the logical partition size.
[0420] Accordingly, the electronic device can obtain the starting physical address and logical partition size of each continuous physical block in other sub-partitions. For example, since the Preload sub-partition has Preload1 and Preload2, based on the number in the extents structure, the starting physical address and logical partition size corresponding to the two continuous physical blocks in the Lp extents structure can be reversely indexed, that is, the starting physical address and logical partition size of Preload1, and the starting physical address and logical partition size of Preload2.
[0421] That is to say, the specific implementation process of step S1163 is as follows:
[0422] The electronic device calls the Recovery process, and based on the first Lp metadata partition table (LpMetadataTableDescriptor partitions) structure in the first Lp metadata (LpMetadata) structure corresponding to the first partition table, traverses multiple first sub-partitions in the first partition table, and determines the index (first_extent_index) structure of each first sub-partition.
[0423] The electronic device determines the first number of continuous physical blocks of each first sub-partition in the first partition table based on the first continuous physical block number (Number of extents in the partition) structure in the index (first_extent_index) structure of each first sub-partition.
[0424] The electronic device reversely indexes to the first Lp metadata continuous physical block (LpMetadataTableDescriptor extents) structure in the first partition table based on the first quantity.
[0425] The electronic device obtains the starting physical address corresponding to the continuous physical blocks of each first sub-partition based on the first target data (target_data) structure in the continuous physical blocks of the first Lp metadata.
[0426] In one implementation, the method further includes:
[0427] The electronic device determines the size of the continuous physical blocks corresponding to the continuous physical blocks in each sub-partition based on the first number (num_sectors) structure in the first Lp metadata continuous physical block.
[0428] Accordingly, the specific implementation process of step S1164 is as follows:
[0429] The electronic device calls the Recovery process, and based on the second Lp metadata partition table (LpMetadataTableDescriptor partitions) structure in the second Lp metadata (LpMetadata) structure corresponding to the second partition table, traverses multiple second sub-partitions in the second partition table to obtain the index (first_extent_index) structure of each second sub-partition.
[0430] The electronic device determines the second number of continuous physical blocks of each second sub-partition in the second partition table based on the second continuous physical block number (Number of extents in the partition) structure in the index (first_extent_index) structure of each second sub-partition.
[0431] The electronic device reversely indexes to a second Lp metadata continuous physical block (LpMetadataTableDescriptor extents) structure in the second partition table based on the second quantity.
[0432] The electronic device obtains the starting physical address corresponding to the continuous physical blocks of each first sub-partition based on the second target data (target_data) structure in the continuous physical blocks of the second Lp metadata.
[0433] In one implementation, the method further includes:
[0434] The electronic device determines the size of the continuous physical blocks corresponding to the continuous physical blocks in each sub-partition based on the second number (num_sectors) structure in the second Lp metadata continuous physical block. Step S1165: The electronic device determines a first target sub-partition among the plurality of first sub-partitions.
[0435] The first target sub-partition is the first sub-partition among the multiple first sub-partitions, which has the same name as the multiple second sub-partitions but a different starting physical address.
[0436] Further Fig.13 As shown, for example, the electronic device can obtain the starting physical address of each sub-partition in the first partition table and the starting physical address of each sub-partition in the second partition table in sequence, wherein the electronic device can first obtain the starting physical address of the System sub-partition in the first partition table as 0x800×512, and obtain the starting physical address of the System sub-partition in the second partition table as 0x800×512, then the starting physical address of the System sub-partition is the same, and the System sub-partition is not the first target sub-partition.
[0437] Furthermore, the electronic device can obtain the starting physical address of Preload2 in the first partition table and the starting physical address of the Product subpartition in the second partition table. At this time, since the names of the Preload2 and Product subpartitions are different, the first target subpartition cannot be determined.
[0438] Furthermore, the electronic device can obtain the starting physical address of the Product subpartition in the first partition table. At this time, since the electronic device has obtained the starting physical address of the Product subpartition in the second partition table, and the starting physical addresses of the Product subpartition in the first partition table and the second partition table are different, the Product subpartition is the first subpartition among multiple first subpartitions that has the same name as multiple second subpartitions but a different starting physical address. In this way, the Product subpartition can be determined as the first target subpartition.
[0439] That is to say, the specific implementation process of step S1165 is as follows:
[0440] The electronic device obtains a first target data structure corresponding to the continuous physical blocks of each first sub-partition in the first partition table.
[0441] The electronic device obtains a second target data structure corresponding to the continuous physical blocks of each sub-partition in the second partition table.
[0442] The electronic device sequentially compares the first target data structure corresponding to the continuous physical blocks of each first sub-partition and the second target data structure corresponding to the continuous physical blocks of each second sub-partition.
[0443] A subpartition obtained for the first time in the plurality of first subpartitions and the plurality of second subpartitions with the same name but with a first target data structure different from a second target data structure is determined as a first target subpartition.
[0444] It should be noted here that in the above embodiment, the electronic device can simultaneously compare the first target data structure corresponding to the continuous physical blocks in the first subpartition and the second target data structure corresponding to the continuous physical blocks in the second subpartition, for example, obtain the first target data structure of the System subpartition in the first subpartition, and obtain the second target data structure of the System subpartition in the second subpartition for comparison. It is also possible to first obtain the first target data structure corresponding to all continuous physical blocks in the first subpartition, for example, obtain the System subpartition, Preload2 physical block, Product subpartition, Version subpartition, and Preload1 physical block in sequence, and then obtain the second target data of the second subpartition for comparison, for example, first obtain the second target data structure of the System subpartition, determine that System is not the first target subpartition, and then obtain the second target data structure of the Product subpartition. At this time, it can be determined that the Product subpartition is the first target subpartition. The embodiment of the present application does not limit the specific method of obtaining the first target data and the second target data structure.
[0445] Step S1166, the electronic device moves the sub-partition in the target area to the Userdata partition. The starting physical address of the Userdata partition is the ending physical address of the Super partition. The sub-partition in the target area is a sub-partition located between the first target sub-partition and the Userdata partition among the multiple first sub-partitions.
[0446] Specifically, the electronic device sequentially obtains the first target_data structure corresponding to the continuous physical blocks of all sub-partitions between the first target sub-partition and the Userdata partition, and sequentially moves the sub-partitions in the target area starting from the first target sub-partition to the end of the Userdata partition based on the first target_data structure.
[0447] Further Fig.13As shown, when the first target subpartition is the Product subpartition, the subpartitions in the target area include: Product subpartition, Version subpartition and Preload subpartition, among which the Preload subpartition corresponds to two continuous physical blocks of Preload1 and Preload2. Therefore, although the continuous physical blocks of Preload2 are not between the starting physical addresses corresponding to the Product subpartition and the Userdata partition, the continuous physical blocks of Preload2 also need to be moved.
[0448] Further Fig.12 As shown, the electronic device moves the Product subpartition to the end of the Userdata partition according to the first target_data structure corresponding to the Product subpartition, moves the Version subpartition to the end of the Userdata partition according to the first target_data structure corresponding to the Version subpartition, moves Preload1 to the end of the Userdata partition according to the first target_data structure corresponding to Preload1, and moves Preload2 to the end of the Userdata partition according to the first target_data structure corresponding to Preload2. At this time, Preload1 and Preload2 generate a Preload subpartition.
[0449] In one implementation, during or after the migration, the electronic device needs to determine the total partition size of the sub-partitions in the target area. The total partition size is determined based on the sum of the continuous physical block sizes of each first sub-partition. The sum of the continuous physical block sizes of each first sub-partition is determined based on the first target_data structure and the first num_sectors structure corresponding to the continuous physical blocks of each first sub-partition.
[0450] For example, after the Product subpartition, Version subpartition, and Preload subpartition are moved to the end of the Userdata partition, the Product subpartition, Version subpartition, and Preload subpartition have a total partition size of Total_size.
[0451] Step S1167, the electronic device overwrites the sub-partition in the target area to the target offset address in the Super partition.
[0452] Fig.15 It is a schematic diagram of a target offset address calculation method provided in an embodiment of the present application.
[0453] like Fig.15As shown, the target offset address is determined by the electronic device after obtaining the preset partition size of the Super partition under the first standard, based on the difference between the preset partition size and the total partition size.
[0454] To facilitate explanation of the calculation method, the example numerical values in this embodiment have no connection with the aforementioned embodiments.
[0455] For example, the starting physical address of the System subpartition is 0x100000, and the size of the System subpartition is 4GB; the starting physical address of Preload2 is 0x100000+4GB, and the size of Preload2 is 2GB; the starting physical address of the Product subpartition is 0x100000+6GB, and the size of the Product subpartition is 2GB; the starting physical address of the Version subpartition is 0x100000+8GB, and the size of the Version subpartition is 8GB; the starting physical address of Preload1 is 0x100000+16GB, and the size of Preload1 is 2GB; the starting physical address of the Userdata partition is 0x100000+18GB.
[0456] Therefore, Total_size is the sum of the sizes of the Product subpartition, Version subpartition, and Preload subpartition, which is 14 GB.
[0457] The preset partition size Super_size of the Super partition can be the size between the starting physical address of the System subpartition and the starting physical address of the Userdata partition. For example, it is the size between 0x100000 and 0x100000+18GB, which is equal to 18GB. Super_size can be obtained from Ptable or according to the first partition table. The embodiment of the present application is not limited to this.
[0458] In this way, the electronic device can determine the target offset address dstOffset. The dstOffset can be determined according to the difference between Super_size and Total_size. For example, the difference is 4GB, so dstOffset can be 0x100000+4GB.
[0459] The electronic device copies the Product subpartition, Version subpartition, and Preload subpartition at the end of the Userdata partition to the dstOffset of the Super partition, thereby realizing the migration of the partition.
[0460] It should be noted here that since the Size of the Version subpartition is reduced after the reform, there is a free space after the Version subpartition. Therefore, the Version subpartition actually moved is the reduced subpartition, and no operation is performed on the free space. Therefore, the starting physical address of Preload1 has not changed, and Total_size includes the storage space occupied by the free space.
[0461] Step S1168: The electronic device moves up the starting physical address of the Userdata partition.
[0462] After the partition migration is completed, free space will be generated in the Super partition. At this time, the electronic device moves the starting physical address of the Userdata partition upward, so that the Userdata partition has more area for the user to control.
[0463] Step S117: After the electronic device completes the partition migration, it verifies the migrated partition.
[0464] The step S117 includes steps S1171 - S1172 .
[0465] Step S1171: the electronic device obtains the third target_data structure corresponding to each sub-partition in the Super partition.
[0466] Step S1172: the electronic device checks the third target_data structure according to the second target_data structure corresponding to each sub-partition in the second partition table.
[0467] When the second target_data structure corresponding to each sub-partition is the same as the corresponding third target_data structure, the electronic device modifies the first partition table in the Super partition into the second partition table, that is, executes step S118.
[0468] When the second target_data structure corresponding to any sub-partition is different from the corresponding third target_data structure, the electronic device displays an error message.
[0469] For example, after the electronic device completes the partition migration, the third target_data structure corresponding to the System sub-partition can be 0x100000, the third target_data structure corresponding to the Product sub-partition can be 0x100000+2GB, the third target_data structure corresponding to the Version sub-partition can be 0x100000+4GB, and the third target_data structure corresponding to the Preload sub-partition can be 0x100000+8GB.
[0470] If the second target_data structure corresponding to the System subpartition in the second partition table is 0x100000, the second target_data structure corresponding to the Product subpartition is 0x100000+2GB, the second target_data structure corresponding to the Version subpartition is 0x100000+4GB, and the second target_data structure corresponding to the Preload subpartition is 0x100000+8GB, then it indicates that the partition migration is successful. Otherwise, any second target_data structure cannot correspond to the third target_data structure, indicating that the partition migration has failed, and the electronic device displays an error message.
[0471] Step S118: The electronic device modifies the first partition table into the second partition table in the Super partition.
[0472] Specifically, the electronic device updates the second partition table to the Super header information through the Recovery process, overwriting the first partition table.
[0473] Step S119: The electronic device determines through the Recovery process that the system information in the first storage sub-partition has been changed.
[0474] In one implementation, the first storage subpartition is an oeminfo subpartition. The electronic device detects whether the standard information in the oeminfo subpartition has changed through the Recovery process, that is, the electronic device determines that the current standard is no longer demo_cn. If it is determined that the standard information has changed, the electronic device executes step S120. If it is determined that the standard information has not changed, the above standard information change process is re-executed. For example, step S1055 is re-executed.
[0475] Step S120: the electronic device formats the Userdata partition and restarts.
[0476] In one implementation, the Userdata partition needs to be reset, and the electronic device formats the Userdata partition and restarts to complete the entire operating system upgrade process.
[0477] The operating system upgrade method provided in the embodiment of the present application can parse and compare the first partition table and the second partition table to obtain the difference sub-partitions in the first partition table and the second partition table, so as to only move the difference sub-partitions and keep the unchanged partitions in their original state, thereby realizing the on-demand migration of partitions and improving the reliability and versatility of partition migration.
[0478] In one implementation, taking operating system upgrade of an electronic device running operating system A1 as an example, the implementation process of the above operating system upgrade method includes the following steps S201-S220.
[0479] Step S201: The Recovery process obtains a first partition table and a second partition table.
[0480] Among them, the specific implementation details of step S201 can be found in step S1161, and this embodiment of the application will not be elaborated on this.
[0481] Step S202: The Recovery process parses the first Lp metadata structure corresponding to the first partition table and the second Lp metadata structure corresponding to the second partition table.
[0482] In step S203, the Recovery process traverses each sub-partition in the first partition table according to the first Lp metadata partition table structure in the first Lp metadata structure, obtains a first index structure in each sub-partition, and determines a first number of continuous physical blocks corresponding to each sub-partition in the first partition table according to the first continuous physical block number structure in the first index structure; and traverses each sub-partition in the second partition table according to the second metadata partition table structure in the second Lp metadata structure, obtains a second index structure in each sub-partition, and determines a second number of continuous physical blocks corresponding to each sub-partition in the second partition table according to the second continuous physical block number structure in the second index structure.
[0483] In step S204, the Recovery process reversely indexes to the first Lp metadata continuous physical block structure in the first partition table based on the first quantity, determines the first starting physical address corresponding to the continuous physical blocks in each sub-partition based on the first target data structure in the first Lp metadata continuous physical block structure, and determines the first partition size corresponding to the continuous physical blocks in each sub-partition based on the first quantity structure in the first Lp metadata continuous physical block structure; and, reversely indexes to the second Lp metadata continuous physical block structure in the second partition table based on the second quantity, and determines the second starting physical address corresponding to the continuous physical blocks in each sub-partition based on the second target data structure in the second Lp metadata continuous physical block structure.
[0484] Among them, the specific details of steps S202-S204 can be found in step S1162, and this embodiment of the application will not be repeated here.
[0485] Step S205: The Recovery process sequentially obtains a first target data structure corresponding to each sub-partition in the first partition table, and sequentially obtains a second target data structure corresponding to each sub-partition in the second partition table.
[0486] Step S206: The Recovery process compares the first target data structure corresponding to each sub-partition in the first partition table with the second target data structure corresponding to each sub-partition in the second partition table in sequence to determine a first differential sub-partition.
[0487] Among them, the specific details of steps S205-S206 can be found in step S1163, and this embodiment of the application will not be repeated here.
[0488] Step S207, the Recovery process sequentially obtains the first target data structure corresponding to the continuous physical blocks of all sub-partitions between the first differential sub-partition and the Userdata partition, and sequentially moves the first target sub-partitions from the first differential sub-partition to the end of the Userdata partition according to the first target data structure.
[0489] Among them, the specific details of step S207 can be found in step S1164, and this embodiment of the application will not be repeated here.
[0490] In step S208, the Recovery process writes the first target sub-partition into the target offset address in the Super partition by overwriting. The specific details of step S208 can be found in step S1165, which will not be described in detail in this embodiment of the application.
[0491] Step S209: The Recovery process moves the starting physical address of the Userdata partition upward.
[0492] Among them, the specific details of step S209 can be found in step S1166, and this embodiment of the application will not be repeated here.
[0493] Step S210, after the Recovery process completes the partition migration, the third target data structure corresponding to each sub-partition in the Super partition is obtained, and the third target data structure is verified according to the second target data structure corresponding to each sub-partition in the second partition table.
[0494] The specific details of step S210 can be found in step S117, which will not be elaborated in the embodiment of the present application.
[0495] Step S211: The Recovery process modifies the first partition table into the second partition table in the Super partition.
[0496] The specific details of step S211 can be found in step S118, which will not be elaborated in the embodiment of the present application.
[0497] Step S212: The Recovery process determines that the system information in the oeminfo sub-partition has been changed.
[0498] The specific details of step S212 can be found in step S119, which will not be elaborated in the embodiment of the present application.
[0499] Step S213, the Recovery process formats the Userdata partition and restarts.
[0500] The specific details of step S213 can be found in step S120, which will not be elaborated in the embodiment of the present application.
[0501] Fig.16 It is a structural diagram of an operating system upgrading device provided in an embodiment of the present application.
[0502] like Fig.16 As shown, in one embodiment, the electronic device can Fig.16 The hardware device shown implements the corresponding functions. The device may include: a touch screen 701, a memory 702, a processor 703 and a communication module 704. The above-mentioned devices may be connected through one or more communication buses 705. The above-mentioned devices may be connected through one or more communication buses 705. The touch screen 701 may include a display panel 7011 and a touch sensor 7012, wherein the display panel 7011 is used to display an image, and the touch sensor 7012 may pass the detected touch operation to the application processor to determine the type of touch event, and provide visual output related to the touch operation through the display panel 7011. The processor 703 may include one or more processing units, for example: the processor 703 may include an application processor, a modem processor, a graphics processor, an image signal processor, a controller, a video codec, a digital signal processor, a baseband processor, and / or a neural network processor, etc. Among them, different processing units may be independent devices or integrated in one or more processors. The memory 702 is coupled to the processor 703 for storing various software programs and / or computer instructions, and the memory 702 may include a volatile memory and / or a non-volatile memory. When the processor executes the computer instructions, the electronic device can perform the various functions or steps of the above method embodiments.
[0503] When the software program and / or the plurality of groups of instructions in the memory 702 are executed by the processor 703, the electronic device implements the following method steps: obtaining a first partition table and a second partition table, the first partition table being used to store a first data structure corresponding to each sub-partition in the Super partition under the first standard, the second partition table being used to store a second data structure corresponding to each sub-partition in the Super partition under the second standard, the Super partition being located in the memory of the electronic device; parsing the first partition table and the second partition table, obtaining a first starting physical address corresponding to each sub-partition from the first data structure, and obtaining a second starting physical address corresponding to each sub-partition from the second data structure; determining a first difference Different sub-partitions, the first differential sub-partition is the first sub-partition in the first partition table and the second partition table, with the same name but different corresponding first starting physical addresses and second starting physical addresses; all sub-partitions between the first differential sub-partition and the Userdata partition are determined as the first target sub-partitions, and the first target sub-partitions are moved from the first differential sub-partition to the end of the Userdata partition in sequence, wherein the starting physical address of the Userdata partition is the ending physical address of the Super partition; the first target sub-partition is written to the target offset address in the Super partition by overwriting; the first partition table is modified to the second partition table in the Super partition.
[0504] The present application also provides an electronic device, including: a processor, a memory and a touch screen; the memory stores program instructions, and when the program instructions are executed by the processor, the electronic device executes the operating system upgrade method in any implementation method of the above embodiments.
[0505] The embodiment of the present application also provides a chip system, which includes at least one processor and at least one interface circuit. The processor and the interface circuit can be interconnected by lines. For example, the interface circuit can be used to receive signals from other devices (such as a memory of an electronic device). For another example, the interface circuit can be used to send signals to other devices. Exemplarily, the interface circuit can read instructions stored in the memory and send the instructions to the processor. When the instruction is executed by the processor, the electronic device can perform the various steps in the above embodiments. Of course, the chip system can also include other discrete devices, which is not specifically limited in the embodiment of the present application.
[0506] An embodiment of the present application also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on the above-mentioned electronic device, the electronic device executes each function or step executed in the above-mentioned method embodiment.
[0507] The embodiment of the present application also provides a computer program product. When the computer program product is run on a computer, it enables the computer to execute each function or step executed in the above method embodiment.
[0508] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0509] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0510] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0511] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0512] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0513] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A method for upgrading an operating system, characterized in that: Applied to electronic equipment, the method comprises: Get the first partition table; Get the second partition table; Based on the first partition table, determining the starting physical addresses of a plurality of first sub-partitions in the dynamic partition in the memory of the electronic device; Based on the second partition table, determining starting physical addresses of a plurality of second sub-partitions in the dynamic partition, the plurality of second sub-partitions being sub-partitions obtained by moving at least a portion of the plurality of first sub-partitions; Determine a first target subpartition among the plurality of first subpartitions, where the first target subpartition is a first subpartition among the plurality of first subpartitions having the same name as the plurality of second subpartitions but a different starting physical address; Move a sub-partition in a target area to a user data partition in the memory, wherein the sub-partition in the target area is a sub-partition located between the first target sub-partition and the user data partition among the plurality of first sub-partitions; Writing the sub-partition in the target area overwriting the target offset address in the dynamic partition, wherein the target offset address is obtained in a manner including: obtaining a preset partition size of the dynamic partition under a first standard; obtaining a total partition size of the sub-partitions of the target area; and determining a difference between the preset partition size and the total partition size as the target offset address; The first partition table in the dynamic partition is modified to the second partition table.
2. The method according to claim 1, characterized in that The obtaining of the first partition table comprises: In the first format, the basic partition in the memory, the first static partition in the memory, and the dynamic partition are loaded in sequence; After loading the dynamic partition, obtaining the first partition table; The obtaining of the second partition table comprises: Get the system upgrade package; Based on the system upgrade package, the second partition table is obtained.
3. The method according to claim 2, characterized in that After obtaining the system upgrade package, the method further includes: After the system upgrade is completed based on the system upgrade package, entering the recovery mode for the first time, calling the recovery process to change the operating system of the electronic device from the first standard to the second standard; When the operating system of the electronic device is changed from the first standard to the second standard, the multiple third sub-partitions of the dynamic partition under the first standard are updated to the multiple first sub-partitions under the second standard.
4. The method according to claim 3, characterized in that The first format includes a demonstration format, and the second format includes a commercial format.
5. The method according to claim 3, characterized in that: The determining, based on the first partition table, the starting physical addresses of the plurality of first sub-partitions in the dynamic partition in the memory of the electronic device comprises: Entering the recovery mode for the second time, calling the recovery process to traverse the multiple first sub-partitions in the first partition table, and determining a first number corresponding to the continuous physical blocks of each first sub-partition; Based on the first number, a first data structure in the first partition table is reversely indexed, and a starting physical address corresponding to the continuous physical blocks of each first sub-partition is determined from the first data structure.
6. The method according to claim 5, characterized in that The determining, based on the second partition table, the starting physical addresses of the plurality of second sub-partitions in the dynamic partition comprises: Entering the recovery mode for the second time, calling the recovery process to traverse the multiple second sub-partitions in the second partition table, and determining a second number corresponding to the continuous physical blocks of each second sub-partition; Based on the second number, a second data structure in the second partition table is reversely indexed, and a starting physical address corresponding to the continuous physical blocks of each second sub-partition is determined from the second data structure.
7. The method according to claim 6, characterized in that The second time entering the recovery mode, calling the recovery process to traverse the plurality of first sub-partitions in the first partition table, and determining the first number corresponding to the continuous physical blocks of each first sub-partition, comprises: Based on a first Lp metadata partition table structure in a first Lp metadata structure corresponding to the first partition table, traverse the plurality of first sub-partitions in the first partition table to determine an index structure of each first sub-partition; Based on the first continuous physical block quantity structure in the index structure of each first sub-partition, a first quantity corresponding to the continuous physical blocks of each first sub-partition in the first partition table is determined.
8. The method according to claim 7, characterized in that The second time entering the recovery mode, calling the recovery process to traverse the plurality of second sub-partitions in the second partition table, and determining the second number of continuous physical blocks corresponding to each second sub-partition, comprises: Based on the second Lp metadata partition table structure in the second Lp metadata structure corresponding to the second partition table, traverse the plurality of second sub-partitions in the second partition table to determine an index structure of each second sub-partition; Based on the second continuous physical block quantity structure in the index structure of each second sub-partition, a second quantity corresponding to the continuous physical blocks of each second sub-partition in the second partition table is determined.
9. The method according to claim 8, characterized in that The first data structure is a first Lp metadata continuous physical block structure in the first partition table; The step of reversely indexing the first data structure in the first partition table based on the first quantity, and obtaining the starting physical address corresponding to the continuous physical block of each first sub-partition from the first data structure, includes: reversely indexing the first Lp metadata continuous physical block structure in the first partition table based on the first quantity; Based on the first target data structure in the first Lp metadata continuous physical block structure, a starting physical address corresponding to the continuous physical blocks of each first sub-partition is determined.
10. The method according to claim 9, characterized in that The second data structure is a second Lp metadata continuous physical block structure in the second partition table; The step of reversely indexing the second data structure in the second partition table based on the second number, and obtaining the starting physical address corresponding to the continuous physical block of each second sub-partition from the second data structure, includes: Reversely index to the second Lp metadata continuous physical block structure in the second partition table based on the second number; Based on the second target data structure in the second Lp metadata continuous physical block structure, a starting physical address corresponding to the continuous physical blocks of each second sub-partition is determined.
11. The method according to claim 10, characterized in that The determining a first target sub-partition among the plurality of first sub-partitions comprises: Acquire the first target data structure corresponding to the continuous physical blocks of each first sub-partition in the first partition table; Acquire the second target data structure corresponding to the continuous physical blocks of each second sub-partition in the second partition table; Compare the first target data structure corresponding to the continuous physical blocks of each first sub-partition and the second target data structure corresponding to the continuous physical blocks of each second sub-partition in sequence; A subpartition among the plurality of first subpartitions acquired for the first time, which has the same name as that among the plurality of second subpartitions but has a different first target data structure from that of the second target data structure, is determined as the first target subpartition.
12. The method according to claim 11, characterized in that The step of moving the sub-partition in the target area to the user data partition in the memory includes: Based on the first target data structure corresponding to the sub-partitions in the target area, the sub-partitions in the target area are moved, starting from the first target sub-partition, to the end of the user data partition in sequence.
13. The method according to claim 9, characterized in that The second time entering the recovery mode, calling the recovery process to traverse the multiple first sub-partitions in the first partition table, and determining the first number of continuous physical blocks corresponding to each first sub-partition, further includes: Based on the first number, a first data structure in the first partition table is reversely indexed, and a size of continuous physical blocks corresponding to the continuous physical blocks of each first sub-partition is determined from the first data structure.
14. The method according to claim 13, characterized in that The step of reversely indexing the first data structure in the first partition table based on the first quantity and determining the size of the continuous physical blocks corresponding to the continuous physical blocks of each first sub-partition from the first data structure includes: Reversely index to the first Lp metadata continuous physical block structure in the first partition table based on the first quantity; Based on the first quantity structure in the first Lp metadata continuous physical block structure, a continuous physical block size corresponding to the continuous physical blocks of each first sub-partition is determined.
15. The method according to claim 14, characterized in that The method of obtaining the target offset address includes: Obtaining a preset partition size of the dynamic partition under the first standard; Obtain the total partition size of the sub-partitions of the target area; Determine the difference between the preset partition size and the total partition size as the target offset address; The total partition size is determined based on the sum of the sizes of the continuous physical blocks of each first sub-partition, wherein the sum of the sizes of the continuous physical blocks of each first sub-partition is determined based on the first target data structure and the corresponding first quantity structure corresponding to the continuous physical blocks of each first sub-partition.
16. The method according to claim 11, characterized in that After writing the sub-partition in the target area overwriting the target offset address in the dynamic partition, the method further includes: Acquire a third target data structure corresponding to each second sub-partition in the dynamic partition; Verify the third target data structure according to the second target data structure corresponding to each second sub-partition in the second partition table; In a case where the second target data structure corresponding to each second sub-partition is the same as the corresponding third target data structure, modifying the first partition table in the dynamic partition to the second partition table; When the second target data structure corresponding to any of the second sub-partitions is different from the corresponding third target data structure, an error message is displayed.
17. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores program instructions, and when the program instructions are executed by the processor, the electronic device executes the method according to any one of claims 1 to 16.
18. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on an electronic device, the electronic device executes the method according to any one of claims 1 to 16.
19. A computer program product, characterized in that When the computer program product is run on an electronic device, the electronic device is enabled to execute the method according to any one of claims 1 to 16.
