WO2023130946A1 - Operating system upgrade method, electronic device, storage medium, and chip system - Google Patents

Operating system upgrade method, electronic device, storage medium, and chip system Download PDF

Info

Publication number
WO2023130946A1
WO2023130946A1 PCT/CN2022/140016 CN2022140016W WO2023130946A1 WO 2023130946 A1 WO2023130946 A1 WO 2023130946A1 CN 2022140016 W CN2022140016 W CN 2022140016W WO 2023130946 A1 WO2023130946 A1 WO 2023130946A1
Authority
WO
WIPO (PCT)
Prior art keywords
partition
sub
data
upgrade
static
Prior art date
Application number
PCT/CN2022/140016
Other languages
French (fr)
Chinese (zh)
Inventor
张赠辉
王艳召
陈超
黄九林
Original Assignee
荣耀终端有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Priority claimed from CN202210135613.0A external-priority patent/CN116450169A/en
Application filed by 荣耀终端有限公司 filed Critical 荣耀终端有限公司
Priority to EP22899609.6A priority Critical patent/EP4242835A1/en
Publication of WO2023130946A1 publication Critical patent/WO2023130946A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates

Definitions

  • the present application relates to the field of computer technology, in particular to an operating system upgrade method, electronic equipment, storage media and a chip system.
  • the operating system is the most basic and most important basic system software.
  • a terminal device can only be used by a user when an operating system is installed.
  • the mobile phone operating system needs to be installed on the mobile phone, such as the Apple mobile device operating system (iPhone Operation System, IOS), Android (Android) system, etc., before it can be used by the user.
  • the Apple mobile device operating system iPhone Operation System, IOS
  • Android Android
  • the operating system is provided by the operating system provider (for example, the provider of Android system is Google).
  • the operating system provided by the operating system supplier is a basic operating system, which only includes the most basic functions, and cannot fully meet the application requirements of users.
  • terminal equipment suppliers will optimize the basic operating system according to different customer needs and application scenarios, add customized content on the basis of the basic operating system, and build a customized operating system. After the customized operating system is installed on the terminal device, the terminal device can provide optimized system functions.
  • the customer service system of the designated network operator is added to the Android system, so that after the mobile phone is turned on, the user can log in to the user account under the network operator to realize the calculation. Fee recharge and other functions.
  • the customized operating system After the customized operating system is installed on the terminal device, when a version upgrade occurs, the customized operating system installed on the terminal device needs to be upgraded. Moreover, in the customized operating system, a large number of upgrade requirements only need to upgrade the data in some storage areas in the customized operating system.
  • the OS upgrade solution is provided by the OS vendor.
  • the upgrade solution provided by the operating system supplier is usually aimed at upgrading the entire operating system. If this upgrade plan is used for the upgrade requirements of the customized operating system, when the data in any part of the storage area in the customized operating system needs to be upgraded, the new version of the part that needs to be upgraded and the current version of the part that does not need to be upgraded After being combined into a new version, it is released as a combined upgrade package. Then, upgrade the entire customized operating system according to the combined upgrade package. In this way, as the upgrade demand of the customized operating system increases, a large number of large-version upgrade packages will be obtained, which is not conducive to flexible management of the customized operating system version by the terminal equipment supplier.
  • Embodiments of the present application provide an operating system upgrade method, electronic equipment, storage media, and a chip system, which can be combined and upgraded for multiple sub-partitions in the operating system to flexibly meet various upgrade requirements.
  • the embodiment of the present application provides a method for upgrading an operating system, and the method can be applied to an electronic device.
  • the electronic device includes a processor and a memory
  • the memory includes a basic partition, a first static partition, a second static partition, a dynamic partition and a user data partition
  • the dynamic partition includes first slot data and second slot data
  • the dynamic partition includes multiple sub
  • the first slot data includes a plurality of first description groups corresponding to a plurality of sub-partitions
  • the second slot data includes a plurality of second description groups corresponding to a plurality of sub-partitions.
  • the first upgrade installation package and the second upgrade installation package are dynamic
  • the third data includes the partition information of the first sub-partition and the partition information of the second sub-partition
  • the multiple third description groups include information related to the first sub-partition.
  • a description group corresponding to a sub-partition, a description group corresponding to a second sub-partition, and a description group corresponding to a third sub-partition, the third sub-partition is a dynamic partition other than the first sub-partition and the second sub-partition subpartition.
  • Restart the electronic device load the data of the basic partition, the second static partition and the dynamic partition to run the second operating system, and read the values of the address items in multiple third description groups during the process of loading the data of the dynamic partition, based on The values of the address items in the plurality of third description groups load the data of the dynamic partition.
  • the electronic device merges the manifests parsed from the multiple upgrade installation packages to obtain all the updates including dynamic partitions that need to be upgraded.
  • the manifest of the subpartitions (such as the first subpartition and the second subpartition).
  • sub-partitions (such as the third sub-partition) not involved in the partition information of the manifest will not be included in the second slot data its deleted.
  • the description group of the sub-partition not to be upgraded still remains in the second slot data, and when the second operating system is run subsequently, the data of the sub-partition not to be upgraded can be loaded according to the second slot data. In this way, there will be no incomplete loading, and finally the dynamic partition can be successfully loaded.
  • the above further includes: writing a plurality of second description groups into the target file, and deleting them in the target file A description group corresponding to the third sub-partition generates a first index.
  • the electronic device when the electronic device creates the first index, it will delete the description group corresponding to the non-upgraded sub-partition in the multiple second description groups, so that the created first index can only indicate that the electronic device obtains the updated sub-partition. Upgrade data. Therefore, the electronic device can be accurately instructed to obtain the upgrade data.
  • the above-mentioned target files are located in the basic partition.
  • the above further includes: obtaining the third upgrade installation package, the third upgrade installation package is used to upgrade the fourth The sub-partition, the fourth sub-partition is a sub-partition of the dynamic partition, the third upgrade installation package includes third data, and the third data includes partition information of the fourth sub-partition. Multiple third description groups are obtained according to the third data and multiple second description groups. The third data also includes the partition information of the fourth sub-partition. Partition and subpartitions other than the fourth subpartition.
  • the first upgrade installation package includes first upgrade data
  • the first upgrade data is used to upgrade the first sub-partition
  • the second upgrade installation package includes second upgrade data
  • the second upgrade The data is used to upgrade the second child partition.
  • the above method further includes: saving the first upgrade data and the second upgrade data in the user data partition. During the process of loading the data of the dynamic partition, the target file is read, and the first upgrade data and the second upgrade data in the user data partition are loaded based on the first index in the target file.
  • the electronic device implements writing the upgrade data in each upgrade installation package into the in the user data partition. Rather than just saving data for one upgrade installation package, omissions can be avoided and complete upgrades of various combinations can be realized. Then, when loading the dynamic partition, it is necessary to obtain all the upgrade data from the user data partition, so as to realize the full loading of the dynamic partition.
  • the above-mentioned deletion of the description group corresponding to the second sub-partition in the target file and generating the first index includes: deleting the description group corresponding to the third sub-partition in the target file , get the description group corresponding to the first sub-partition and the description group corresponding to the second sub-partition, the description group corresponding to the first sub-partition includes the name of the first sub-partition, and the description group corresponding to the second sub-partition includes The name of the second subpartition.
  • the first file name corresponding to the first sub-partition is generated based on the name of the first sub-partition
  • the second file name corresponding to the second sub-partition is generated based on the name of the second sub-partition.
  • the first index includes the first file name and the second file name.
  • the electronic device can generate the first index including the first file name and the second file name, so as to accurately indicate the file where the electronic device needs to find the upgrade data when loading the dynamic partition.
  • the first file name corresponding to the first sub-partition is generated based on the name of the first sub-partition
  • the file name corresponding to the second sub-partition is generated based on the name of the second sub-partition.
  • it also includes: creating a first initial cow file with the first file name in the user data partition, and creating a second initial cow file with the second file name, the first initial cow No upgrade data is stored in the file and the second initial cow file.
  • the aforementioned saving of the first upgrade data and the second upgrade data in the user data partition includes: saving the first upgrade data in the first initial cow file, and saving the second upgrade data in the second initial cow file.
  • the electronic device can create an initial cow file in the user data partition that is consistent with the file name in the first index, and save the upgrade data in the initial cow file. Subsequently, when the electronic device reads the upgrade data, it can accurately obtain the upgrade data by retrieving the file name.
  • the second static partition includes a plurality of sub-partitions
  • the first upgrade installation package further includes third upgrade data
  • the third upgrade data is used to upgrade the fifth sub-partition
  • the second The upgrade installation package also includes fourth upgrade data
  • the fourth upgrade data is used to upgrade the sixth sub-partition
  • the fifth sub-partition and the sixth sub-partition are sub-partitions of the second static partition.
  • the electronic device can upgrade the dynamic partition and some sub-partitions of the static partition. In order to flexibly meet the needs of various partial upgrades.
  • the first static partition includes multiple sub-partitions, and the multiple sub-partitions of the first static partition correspond one-to-one to the multiple sub-partitions of the second static partition.
  • the method further includes: if the second static partition includes the seventh sub-partition, detecting the fifth sub-partition and the sixth sub-partition Whether the partition includes a preset sub-partition, and the seventh sub-partition is a sub-partition other than the fifth sub-partition and the sixth sub-partition in the second static partition. If the fifth sub-partition and the sixth sub-partition include the preset sub-partition, the data of the seventh sub-partition of the first static partition is synchronized to the seventh sub-partition of the second static partition.
  • the electronic device can only synchronize the data of the sub-partition (ie, the seventh sub-partition) that does not need to be upgraded in the first static partition to the second static partition, so as to It is ensured that the data of the sub-partition that does not need to be upgraded (that is, the seventh sub-partition) in the second static partition is up-to-date. Therefore, the synchronization of sub-partition data that does not need to be upgraded currently can be realized through the synchronization of a small part of data.
  • the data of all sub-partitions in the first static partition are synchronized to the corresponding sub-partitions of the second static partition.
  • the device does not need to remove data that does not need to be synchronized from the first static partition, but can simplify the steps of synchronization by synchronizing all.
  • the latest data of sub-partitions that do not need to be upgraded can be synchronized between the first static partition and the second static partition. Then perform data update on the second static partition. In this way, it can be guaranteed that the data of each sub-partition in the second static partition is up-to-date.
  • writing the third upgrade data into the fifth sub-partition and writing the fourth upgrade data into the sixth sub-partition includes: if the second static partition does not include the seventh For the sub-partition, the third upgrade data is written into the fifth sub-partition, and the fourth upgrade data is written into the sixth sub-partition. That is to say, with the method of this embodiment, if all the data in the static partition needs to be updated, the data can be updated directly without synchronization. Thereby, the operation of system upgrade can be saved.
  • the above-mentioned storing the first upgrade data and the second upgrade data in the user data partition includes: traversing the first upgrade installation package and the second upgrade installation package, traversing to the first When upgrading the installation package, save the first upgrade data in the user data partition, and save the second upgrade data in the user data partition when traversing to the second upgrade installation package.
  • the above method further includes: recording the progress of saving the upgrade data included in the currently traversed upgrade installation package, and recording the traverse sequence number of the currently traversed upgrade installation package. Calculate the update progress corresponding to the save progress and the traversal sequence number, and display the update progress.
  • the electronic device can calculate and display the real-time update progress by recording the saving progress and the traversal sequence number.
  • the above process of saving the first upgrade data and the second upgrade data in the user data partition further includes: if the electronic device is powered off and restarted, the first upgrade installation package Locating the target upgrade installation package corresponding to the traversal sequence number in the second upgrade installation package, and locating the target data corresponding to the write progress in the upgrade data of the target upgrade installation package. Starting from the target data of the target upgrade installation package, the first upgrade data and the second upgrade data are continuously stored in the user data partition.
  • the electronic device can continue to save the data accurately from the position where it was updated when the power was turned off, for the abnormal situation of restarting after power failure during the data updating process.
  • the first aspect before obtaining the multiple third description groups according to the third data and the multiple second description groups, it further includes: combining the first data and the second data to obtain the third data.
  • a manifest including partition information of all sub-partitions to be upgraded in a dynamic partition can be obtained by merging manifests in multiple upgrade installation packages. This facilitates subsequent upgrades based on the merged manifest.
  • the above further includes: storing multiple first upgrade data and second upgrade data in the user data partition The data is moved to the corresponding subpartition of the dynamic partition.
  • the file of the dynamic partition can be upgraded through the disk operation, so that the device does not need to load the dynamic partition and the virtual dynamic partition when the device is started next time, and only needs to load the dynamic partition to complete the device. start up.
  • the first sub-partition, the second sub-partition, the third sub-partition, ... may all include one or more sub-partitions. In this way, combined upgrades of various sub-partitions can be flexibly realized.
  • the embodiment of the present application further provides an electronic device, the electronic device includes a processor and a memory, and the memory includes a basic partition, a first static partition, a second static partition, a dynamic partition, and a user data partition.
  • the dynamic partition includes a plurality of sub-partitions, and the processor is configured to execute software codes stored in the memory, so that the electronic device executes the method of the above-mentioned first aspect and any possible design manner thereof.
  • an embodiment of the present application provides a chip system, which is applied to an electronic device including a display screen and a memory; the chip system includes one or more interface circuits and one or more processors; the interface The circuit and the processor are interconnected by a line; the interface circuit is configured to receive a signal from a memory of the electronic device and send the signal to the processor, the signal including computer instructions stored in the memory; When the processor executes the computer instruction, the electronic device executes the method described in the first aspect and any possible design manner thereof.
  • the embodiment of the present application further provides a computer storage medium, the computer storage medium includes computer instructions, and when the computer instructions are run on the electronic device, the electronic device is executed as described in the first aspect and any possibility thereof.
  • the present application provides a computer program product.
  • the computer program product runs on a computer, the computer executes the method described in the first aspect and any possible design manner thereof.
  • FIG. 1 is a schematic diagram of a data storage structure according to an embodiment of the present application.
  • FIG. 2 is a flowchart of an operating system upgrade according to an embodiment of the present application
  • FIG. 3 is a schematic diagram of a data storage structure according to an embodiment of the present application.
  • FIG. 4 is a schematic diagram of part of card slot data according to an embodiment of the present application.
  • FIG. 5A is a flow chart showing an operating system upgrade according to an embodiment of the present application.
  • FIG. 5B is a schematic diagram of adjusting card slot data according to an embodiment of the present application.
  • FIG. 6 is a schematic diagram of a data storage structure according to an embodiment of the present application.
  • FIG. 7 is a schematic diagram of component division in a data storage structure according to an embodiment of the present application.
  • FIG. 8 is a schematic diagram of upgrading an independent component according to an embodiment of the present application.
  • FIG. 9 is a flowchart of an operating system upgrade according to an embodiment of the present application.
  • FIG. 10 is a schematic diagram of the merging process of manifests according to an embodiment of the present application.
  • FIG. 11 is a schematic diagram of adjusting card slot data according to an embodiment of the present application.
  • FIG. 12 is a flow chart showing an operating system upgrade according to an embodiment of the present application.
  • FIG. 13 is a schematic diagram of creating an index according to an embodiment of the present application.
  • FIG. 14 is a flow chart showing an operating system upgrade according to an embodiment of the present application.
  • FIG. 15 is a schematic diagram of data update according to an embodiment of the present application.
  • FIG. 16 is a flow chart showing an operating system upgrade according to an embodiment of the present application.
  • FIG. 17 is a flowchart of an operating system upgrade according to an embodiment of the present application.
  • FIG. 18 is a schematic diagram of data update after power failure according to an embodiment of the present application.
  • FIG. 19 is a flow chart showing an operating system upgrade according to an embodiment of the present application.
  • FIG. 20 is a schematic structural diagram of a chip system according to an embodiment of the present application.
  • OTA Over-the-Air Technology
  • the devices in this embodiment of the present application include, but are not limited to, smart phones, smart earphones, tablet computers, smart refrigerators, smart speakers, etc. on which an operating system can be installed.
  • the device may also be a control panel on which an operating system can be installed inside the device.
  • Exemplary embodiments of operating systems include, but are not limited to Linux or other operating systems.
  • a virtual A/B upgrade solution can be used to complete the upgrade of the operating system.
  • the virtual A/B upgrade solution can be applied to the upgrade of the operating system with the data storage structure shown in FIG. 1 .
  • the Android system data storage area includes a basic partition (Common), a static partition (A), a static partition (B), a dynamic partition (Super), and a user data partition (Userdata).
  • Each partition is introduced as follows: the user data partition (Userdata) is used to save the user's personal data, for example, the APP installed by the user personally, the pictures, documents and videos saved by the user personally, and other personal data.
  • the basic partition (Common) is used to save system data, and the data saved in the basic partition does not participate in the operating system upgrade.
  • the structure of the static partition (A) and the static partition (B) correspond to each other.
  • the static partition (A) and the static partition (B) can include multiple sub-partitions.
  • the sub-partitions corresponding to the static partition (A) and the static partition (B) are named by The suffixes _a and _b distinguish each other.
  • static partition (A) includes bootloader_a, boot_a, vendor_boot_a, dtbo_a, vbmeta_a
  • static partition (B) includes bootloader_b, boot_b, vendor_boot_b, dtbo_b, vbmeta_b.
  • a dynamic partition (Super) can contain multiple subpartitions, such as System, system_ext, vendor, product, Cust, Odm.
  • the static partition (A) may be called the first static partition
  • the static partition (B) may be called the second static partition.
  • the device When the device is started, it starts from a static partition, that is, the operating system is started by loading the static partition. For example, if the device starts from the static partition (A), it needs to load the basic partition (Common), static partition (A) and dynamic partition (Super) in sequence; when the device starts from the static partition (B), it needs to load the basic partition (Common ), static partition (B) and dynamic partition (Super).
  • a static partition that is, the operating system is started by loading the static partition.
  • the static partition For example, if the device starts from the static partition (A), it needs to load the basic partition (Common), static partition (A) and dynamic partition (Super) in sequence; when the device starts from the static partition (B), it needs to load the basic partition (Common ), static partition (B) and dynamic partition (Super).
  • UFS Universal Flash Storage
  • MBR Master Boot Record
  • the device boot sequence description can be used to indicate booting from the static partition (A) (the boot sequence mark is A) or from the static partition (B) (the boot sequence mark is A).
  • MBR is usually recorded in the base partition (Common). Certainly, on different platforms, the MBR may also be recorded in different locations, which is not specifically limited in this embodiment of the present application.
  • Figure 2 is a flow chart of upgrading the operating system for the operating system with the data storage structure shown in Figure 1, assuming that the device is currently booted from the static partition (A), and the device is upgraded according to the virtual A/B shown in Figure 2
  • the process of the program implements the upgrade of the operating system.
  • the device loads the basic partition (Common), the static partition (A) and the dynamic partition (Super) in sequence, and starts from the static partition (A).
  • the device acquires an operating system upgrade installation package.
  • the device periodically initiates a packet search request to the packet search server, and the packet search request includes the version number (for example, version 1.1) of the operating system currently running on the device.
  • the package search server retrieves whether there is an operating system installation package with a newer version number (for example, an operating system installation package of version 1.2) according to the version number of the operating system in the package search request.
  • the package search server feeds back the download address of the operating system upgrade installation package (for example, the system incremental upgrade installation package upgraded from version 1.1 to version 1.2) to the device.
  • the device downloads the OS upgrade installation package according to the download address of the OS upgrade installation package.
  • the device performs a data writing operation on the static partition (B) according to the operating system upgrade installation package to upgrade the static partition (B).
  • the system incremental upgrade installation package from version 1.1 to version 1.2 contains the full data of the static partition of version 1.2, and the device overwrites the data of the static partition of version 1.2 into the static partition (B).
  • the device creates a virtual dynamic partition in the user data partition (Userdata) according to the operating system upgrade installation package, and writes upgrade data of the dynamic partition (Super) in the virtual dynamic partition.
  • the operating system upgrade installation package contains the data of the dynamic partition (Super) of version 1.2, and the device writes the data of the dynamic partition (Super) of version 1.2 in the virtual dynamic partition.
  • an incremental upgrade method is adopted for the dynamic partition (Super).
  • the virtual dynamic partition of the user data partition (Userdata) does not save all the files of the new version of the dynamic partition (Super) after the upgrade, but the data that needs to be upgraded in the old version of the dynamic partition (Super). The result of the upgrade after the upgrade.
  • the data in the System subpartition can be divided into data system1 and data system2.
  • the data system2 has not changed, and the data syetem1 has been upgraded to the data system3.
  • the device creates a virtual dynamic partition in the user data partition (Userdata), and writes data system3 in the virtual dynamic partition.
  • the system incremental upgrade installation package from version 1.1 to version 1.2 includes dynamic partition (Super) update data from version 1.1 to version 1.2
  • the dynamic partition (Super) update data includes data system3.
  • the incremental upgrade of the dynamic partition (Super) is realized based on the snapshot technology (snapshot).
  • snapshot technology snapshot technology
  • a copy-on-write (Copy-On-Write, cow) file is used to save the upgrade data of the dynamic partition (Super).
  • the upgrade data of the dynamic partition (Super) stored in the user data partition (Userdata) includes multiple cow files, and each cow file corresponds to a sub-partition of the dynamic partition (Super).
  • the cow file of the upgrade data of the dynamic partition (Super) is compressed and stored in the form of binary code, and each cow file is named according to the sub-partition of the corresponding dynamic partition (Super).
  • the cow file for the system subpartition is named system-cow-img.img.0000.
  • the device obtains the operating system upgrade installation package, unpacks the operating system upgrade installation package to obtain all cow files, and appends an A/B partition mark to each cow file. And further, create an Update folder in the user data partition (Userdata), and save the cow file to the Update folder.
  • the device obtains the operating system upgrade installation package, unpacks the operating system upgrade installation package to obtain all cow files, and attaches the name mark _b corresponding to the dynamic partition (B) to the cow files.
  • append_b for system-cow-img.img.0000 generates system_b-cow-img.img.0000.
  • an Update folder is created in the user data partition (Userdata), and the cow file is saved in the Update folder.
  • the Update folder of the user data partition (Userdata) contains the following files:
  • the cow file includes a cow file map (snapshot map) of the cow file itself and upgrade data.
  • a cow file map snapshot map
  • the cow file map corresponds to the file map of the subpartition of the dynamic partition (Super) targeted by the cow file.
  • the file map of the sub-partition of the dynamic partition (Super) is used to describe all the files in the sub-partition of the dynamic partition (Super) and the storage address of each file in the current version of the operating system (the version before this upgrade, for example, version 1.1) .
  • the upgrade data in the cow file is the updated data in the sub-partition data of the new version compared with the sub-partition data of the current version; the cow file map of the cow file itself is used to describe the updated file and the sub-partition of the current version The correspondence between the files in and the storage address of the updated files.
  • the upgrade data in the cow file can be used to replace the corresponding files in the sub-partition of the dynamic partition (Super), so as to realize the dynamic partition (Super) ) data upgrade.
  • a snapshot operation may be performed on the data of the sub-partition of the dynamic partition (Super) based on the snapshot to generate the file map of the sub-partition of the dynamic partition (Super). It is also possible to pre-generate the file map of the sub-partition of the dynamic partition (Super) when making the operating system upgrade installation package, and add the file map to the cow file.
  • the disk placement status information includes an overall identifier for the dynamic partition (Super) and a sub-partition identifier for each sub-partition.
  • the overall flag is "merged”, it means that all sub-partitions of the dynamic partition (Super) do not need to be merged; when the overall flag is "not merged (wait for merge)", it means dynamic One or more sub-partitions of a partition (Super) need to be merged; when the sub-partition is marked as "merged”, it means that the sub-partition does not need to be merged; when the sub-partition is marked as "merged Disk (wait for merge)” means that the sub-partition needs to be moved to disk. If it is invalid, the upgrade will fail, the upgrade process will be interrupted and an error will be reported.
  • the boot sequence identifier of the Master Boot Record For example, rewrite the boot sequence identifier of the Master Boot Record (MBR), and rewrite the boot sequence identifier from A to B.
  • MLR Master Boot Record
  • the device After the device is powered on, when the device reads the boot sequence ID as A, the device starts from the static partition (A), and loads the static partition (A) during startup; when the device reads the boot sequence ID as B, the device starts from the static partition (A). Partition (B) starts, and static partition (B) is loaded during startup.
  • the device sequentially loads the basic partition (Common) and the static partition (B).
  • the device loads the dynamic partition (Super) and the virtual dynamic partition of the user data partition (Userdata).
  • the device reads the storage status information in the metadata (/metadata), determines whether to retrieve the cow file from the specified path of the user data partition (Userdata) based on the storage status information, and uses snapshot to merge and load the dynamic partition ( Super) and the cow file retrieved from the specified path of the user data partition (Userdata).
  • the device does not load all the cow files in the dynamic partition (Super) and the user data partition (Userdata), but loads corresponding files according to operating requirements of the operating system. Specifically, in S241, the device determines the files to be loaded according to the operation requirements of the operating system, and extracts the corresponding files from the cow files in the virtual dynamic partition of the dynamic partition (Super) or user data partition (Userdata) based on the snapshot to load.
  • the device before loading the file, the device needs to verify the loaded file.
  • the dynamic partition (Super)+cow file is not verified as a whole, but only the files to be loaded are verified. For example, verify based on dmverity (dm-verity is a target of dm (device mapper), which is a virtual block device, specially used for file system verification). If the verification is successful, load the file; if the verification fails, restart the device, roll back the system or try to load the file again.
  • dm-verity is a target of dm (device mapper), which is a virtual block device, specially used for file system verification.
  • the device puts the data of the virtual dynamic partition to the dynamic partition (Super).
  • the disk operation refers to writing the dynamic partition (Super) upgrade file (cow file) stored in the virtual dynamic partition on the user data partition (Userdata) to the In the dynamic partition (Super), the files of the dynamic partition (Super) are upgraded, so that the device does not need to load the dynamic partition (Super) and the virtual dynamic partition at the next startup, and only needs to load the dynamic partition (Super) to complete the device. start up.
  • the device After the device is successfully started, it performs a power-on broadcast, and starts an upgrade process after the power-on broadcast.
  • the upgrade process reads the migration status information in the metadata (/metadata) of the basic partition (Common). If the migration status information is "merged", the device enters the normal operation mode.
  • the upgrade process transfers the cow files in the user data partition (Userdata) to the dynamic partition (Super).
  • the upgrade process writes the upgrade data in the cow file in the user data partition (Userdata) to the corresponding address in the dynamic partition (Super), so that all the data in the dynamic partition (Super) are updated new Version data.
  • the data at addresses 045033-045035 Write to address 024014 ⁇ 024017; 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 to 045040 are written to addresses 024036 to 024040.
  • the upgrade process deletes the cow file in the user data partition (Userdata), and returns the storage space to the user data partition (Userdata); and, the disk status information in the metadata (/metadata) of the basic partition (Common) Changed from "wait for merge” to "merged".
  • the device does not need to be restarted immediately, and the user can choose the restarting time; in this way, the upgrade process of the operating system will not affect the user's normal mobile phone operation, thereby greatly improving the user experience.
  • the dynamic partition (Super)
  • a virtual dynamic partition will be created on the user data partition (Userdata) only when an upgrade is required, thus effectively improving the utilization rate of data storage space.
  • FIG. 3 is a schematic diagram of a data storage structure according to an embodiment of the present application.
  • the metadata (/supermetadata) of the header of the dynamic partition (Super) includes Slot0 corresponding to the static partition (A) and Slot1 of the static partition (B). Slot0 and Slot1 are used to save the partition table of the Super partition.
  • Slot0 corresponding to the static partition (A) can be called the first slot
  • the data in Slot0 is called the first slot data
  • Slot1 corresponding to the static partition (B) is called the second slot
  • Slot1 The data in is called the second slot data.
  • configuring Slot0 corresponds to booting from the static partition (A)
  • configuring Slot1 corresponds to booting from the static partition (B).
  • the device selects to obtain the partition information of the Super partition from Slot0 or Slot1 according to the static partition to be started. Take the device currently booting from the static partition (A) as an example.
  • the device When loading the dynamic partition (Super), the device first reads Slot0 to obtain the sub-partition address of the dynamic partition (Super); when the device starts from the static partition B, in When loading the Super partition, the device first reads Slot1 to obtain the sub-partition address of the dynamic partition (Super).
  • Slot0 and Slot1 include multiple sub-partition description groups, and one sub-partition description group corresponds to one sub-partition of the Super partition. That is to say, Slot0 includes multiple description groups corresponding to multiple subpartitions, and Slot1 also includes multiple description groups corresponding to multiple subpartitions.
  • the multiple sub-partition description groups in Slot0 may be referred to as multiple first description groups
  • the multiple sub-partition description groups in Slot1 may be referred to as multiple second description groups.
  • the sub-partition description group includes: at least one of a name (Name), a group (Group), an attribute (Attributes), and an address (Extents). The following describes the items contained in the sub-partition description group:
  • Group (Group) item whose value is the subpartition type, for example, subpartition (ry_dynamic_partitions_b);
  • Attributes item its value is the read-write attribute of the sub-partition, for example, the read-only attribute (readonly);
  • Slot0 When starting from static partition A and loading the Super partition, Slot0 is first read.
  • the device When reading Slot0, since the suffix _a corresponds to the static partition (A), the device reads the value of the Extents item in the sub-partition description group whose Name item and/or Group item suffix _a in Slot0 to obtain the dynamic partition ( Super) sub-partition address.
  • Slot1 When booting from static partition B and loading the Super partition, Slot1 is first read. When reading Slot1, since the suffix _b corresponds to the static partition (B), the device reads the value of the Extents item in the partition description group with the suffix _b in the Name item and/or Group item in Slot0 to obtain the dynamic partition (Super ) subpartition address.
  • the initial Slot0 and Slot1 there are two sub-partition description groups for each sub-partition of the Super partition, one sub-partition description group corresponds to the static partition (A), and one sub-partition Description groups correspond to static partitions (B).
  • the device selects the sub-partition description group to be read according to the suffix (_a or _b).
  • FIG. 4 shows part of the data stored in the initial Slot0 in an embodiment.
  • the value of the Extents item is the real address of the sub-partition.
  • the value of the Extents item is blank.
  • the device When reading Slot0, since the suffix _a corresponds to the static partition (A), the device reads the value of the Extents item in the sub-partition description group whose Name item and/or Group item suffix _a in Slot0 to obtain the super partition The address of the sub-partition, so that the super partition can be loaded smoothly.
  • the device When reading Slot0, since the suffix _b corresponds to the static partition (B), the device does not need to read the sub-partition description group whose Name item and/or Group item suffix _b in Slot0, therefore, the values of the Name item and the Group item In the description group of subpartitions whose suffix is _b, setting the value of Extents to blank will not affect the loading of super partitions.
  • the data stored in the initial Slot1 is similar to the data structure shown in Figure 4, the difference is that, in order to ensure the smooth loading of the Super partition, in the data of Slot1, the suffix of the value of the Name item and the Group item In the sub-partition description group of _b, the value of the Extents item is the real address of the sub-partition. In the sub-partition description group with the suffix _a in the value of the Name item and the Group item, the value of the Extents item is blank.
  • the device needs to update the sub-partition description group in slot0 or slot1 in time. In this way, the device can read the correct description of the sub-partitions, such as the Extents item, when switching to the static partition that starts up subsequently, so as to successfully load the dynamic partition (Super) partition.
  • the device can read the correct description of the sub-partitions, such as the Extents item, when switching to the static partition that starts up subsequently, so as to successfully load the dynamic partition (Super) partition.
  • the device when loading the dynamic partition (Super) (as in S241), it is necessary to read the cow file from the virtual dynamic partition of the user data partition (Userdata).
  • the device can also create an index of the cow file in the basic partition (Common). The index of the cow file is used to instruct the device to read the cow file from the user data partition (Userdata).
  • the device loads the dynamic partition (Super), it can read the corresponding cow file from the user data partition (Userdata) according to the index.
  • the flow of the virtual A/B upgrade solution will be described below on the basis of FIG. 3 , combined with the update of slot1 and the creation of the index of the cow file. Specifically, when the device is currently booted from the static partition (A), the device implements an operating system upgrade according to the process shown in FIG. 5A .
  • the device sequentially loads the basic partition (Common), the static partition (A) and the dynamic partition (Super), and starts from the static partition (A).
  • the device acquires an operating system upgrade installation package.
  • the device parses the operating system upgrade installation package to obtain application manifest data (manifest).
  • the mainfest records the partition information of the static partition (referred to as the static partition information) and the partition information of the dynamic partition (referred to as the dynamic partition information) in the data storage structure of the updated operating system (such as version 1.2).
  • the static partition information includes the name and size of each sub-partition in the static partition, the check value (such as hash value) of the upgraded data, and the upgrade data (difference or full mirror data) in the operating system upgrade installation package.
  • the dynamic partition information includes the name and size of each sub-partition in the dynamic partition, the check value (such as hash value) of the upgraded data, and the location of the upgraded data (differential or full mirrored data) in the operating system upgrade installation package.
  • the dynamic partition of the updated operating system includes the following six subpartitions: system, system_ext, vendor, product, cust and odm.
  • the manifest includes the following dynamic partition information:
  • the name and size of the product partition the verification value (such as hash value) of the upgraded data, and the location of the upgraded data in the operating system upgrade installation package;
  • the name and size of the odm partition, the check value (such as the hash value) of the upgraded data, and the location of the upgraded data in the operating system upgrade installation package are defined.
  • the sub-partitions involved in the dynamic partition information in the manifest will not be included in the current operating system. All subpartitions in the dynamic partition.
  • the dynamic partition (Super) includes 6 sub-partitions of system, system_ext, vendor, product, cust, and odm
  • the dynamic partition (Super) includes 4 sub-partitions including system, product, cust, and odm.
  • the manifest includes the following dynamic partition information:
  • the name and size of the product partition the verification value (such as hash value) of the upgraded data, and the location of the upgraded data in the operating system upgrade installation package;
  • the name and size of the odm partition, the check value (such as the hash value) of the upgraded data, and the location of the upgraded data in the operating system upgrade installation package are defined.
  • the dynamic partition information included in the manifest does not involve the system_ext and vendor partitions.
  • the device adjusts the sub-partition description group of slot1 in the dynamic partition (Super) according to the dynamic partition information in the manifest, and obtains the adjusted slot1.
  • the sub-partitions involved in the sub-partition description group in the adjusted slot1 are in one-to-one correspondence with the sub-partitions involved in the dynamic partition information in the manifest.
  • the device adjusts the address (Extents) item of the corresponding subpartition in slot1 according to the name and size of the subpartition, so that the adjusted address (Extents) item of each subpartition in slot1 matches the size of the corresponding subpartition.
  • the device deletes the subpartition description group of the subpartition not involved in the dynamic partition information of the manifest from slot1. That is, the sub-partitions involved in the updated sub-partition description group of slot1 are in one-to-one correspondence with the sub-partitions involved in the dynamic partition information in the manifest.
  • the initial slot1 includes system, system_ext, product, vendor, cust, odm
  • the initial slot1 includes system, system_ext, product, vendor, cust, odm
  • the manifest parsed from the operating system upgrade package this time includes the dynamic partition information of 4 subpartitions including system, product, cust and odm.
  • slot1 as shown in (b) in Figure 5B can be obtained.
  • the sub-partition description groups of system_ext and vendor partitions are deleted in slot1 after adjustment, and only the sub-partition description groups of four sub-partitions including system, product, cust, and odm are included.
  • the adjusted slot1 only retains the sub-partition corresponding to the static partition (B)
  • the description group that is, the sub-partition description group with the suffix _b, and the sub-partition description group corresponding to the static partition (A), that is, the sub-partition description group with the suffix _a is deleted.
  • the device records the index of the cow file in the basic partition (Common) according to the adjusted slot1.
  • the index of the cow file can instruct the device to search the corresponding cow file from the user data partition (Userdata) to complete the loading of the dynamic partition (Super).
  • the device copies the updated sub-partition description group in slot1 to the basic partition (Common), such as the /gsi/ota/lp_metadata file under the metadata (/metadate) of the basic partition (Common), and the cow file is obtained index of.
  • the basic partition such as the /gsi/ota/lp_metadata file under the metadata (/metadate) of the basic partition (Common)
  • the cow file is obtained index of.
  • the /metadate/gsi/ota/lp_metadata file can record the index of the cow file corresponding to the four subpartitions including system, product, cust, and odm.
  • the index of the cow file in /metadate/gsi/ota/lp_metadata looks like this:
  • the device performs a data writing operation on the static partition (B) according to the operating system upgrade installation package to upgrade the static partition (B).
  • the device creates a virtual dynamic partition in the user data partition (Userdata) according to the operating system upgrade installation package.
  • a cow file is used to store the upgrade data of the dynamic partition (Super).
  • a cow file stores the upgrade data of a sub-partition.
  • the system_b_cow_img.img.000 file stores the upgrade data of the system partition
  • the cust_b_cow_img.img.000 file stores the upgrade data of the cust partition.
  • the device sequentially loads the basic partition (Common) and the static partition (B), and starts from the static partition (B).
  • the device loads the cow file in the dynamic partition (Super) and the virtual dynamic partition of the user data partition (Userdata) according to the adjusted slot1 and the index of the cow file.
  • the device When the device loads a dynamic partition (Super), it can read the sub-partition description group from the adjusted slot1, and read the index and storage status information of the cow file. Wherein, the device reads the sub-partition description group, and can obtain the address (Extents) item of each sub-partition, that is, the offset address of each sub-partition in the dynamic partition. The device reads the storage state information, and can determine whether to retrieve the cow files corresponding to each sub-partition from the user data partition (Userdata). Specifically, when it is read that the overall flag of the disk placement status information is "displaced", it is determined that there is no need to retrieve the cow files corresponding to all sub-partitions from the user data partition (Userdata).
  • the sub-partition identifiers for each sub-partition in the disk placement status information can be further read. If the sub-partition is identified as "placed”, it is determined that there is no need to retrieve the cow file corresponding to the corresponding sub-partition from the user data partition (Userdata). If the sub-partition is identified as "not placed on the disk”, it is determined that the cow file corresponding to the corresponding sub-partition needs to be retrieved from the user data partition (Userdata). The device reads the index of the cow file, and can retrieve the corresponding cow file from the user data partition (Userdata) according to the file name indicated by the index of the cow file.
  • the device reads the storage state information, and determines that the cow file corresponding to the system subpartition needs to be retrieved. The device then reads the index of the cow file which contains the following:
  • the name item "system_b” corresponding to the system sub-partition can be read. Then, according to the naming rule of the cow file, the device can determine that the file name of the cow file corresponding to the name item "system_b" is system_b_cow_img. The device can retrieve the cow file named system_b_cow_img from the user data partition (Userdata). Thus, the cow file corresponding to the system partition is retrieved.
  • Userdata user data partition
  • the device can merge and load dynamic partition (Super) and cow files by using snapshot.
  • Super dynamic partition
  • the device is successfully started and enters the user interaction interface.
  • the device puts the data of the virtual dynamic partition into the dynamic partition (Super).
  • the device After the device obtains the operating system upgrade installation package, it can adjust the slot1 of the dynamic partition (Super) and create the index of the cow file. Then, the device uses the adjusted slot1 and the index of the cow file to load and obtain the data required for starting the dynamic partition (Super), thereby successfully starting the dynamic partition (Super).
  • the upgrade solution shown in FIG. 5A will have certain shortcomings.
  • the customized operating system will be used as an example below to illustrate the requirement for upgrading some partitions, and the disadvantages of using the upgrade solution shown in FIG. 5A in the face of this requirement.
  • the basic operating system (the system corresponding to the data storage structure shown in FIG. 1 and FIG. 3 ) only includes the most basic functions, which cannot fully meet the application requirements of users. Therefore, in order to improve user experience, equipment suppliers will optimize the basic operating system according to different customer needs and application scenarios, add customized content on the basis of the basic operating system, and build a customized operating system. Install a customized operating system on the device so that the device can provide optimized system functions.
  • FIG. 6 is a schematic diagram of a data storage structure according to an embodiment of the present application.
  • the Android system data storage area includes a basic partition (Common), a static partition (A), a static partition (B), a customized dynamic partition (Super), and a user data partition (Userdata).
  • the customized dynamic partition (Super) not only includes all the subpartitions of the dynamic partition (Super) in the basic operating system data storage structure shown in FIG. 1 and FIG. 3 .
  • custom data is added to the custom dynamic partition (Super) in the form of a sub-partition of the dynamic partition.
  • the custom dynamic partition (Super) also includes custom (version) partitions, shelf (preload) partitions . Version partition and preload partition are used to save customized data.
  • the version partition can be used to store customized data related to operators (such as China Mobile and China Unicom).
  • the preload partition can be used to store data related to third-party applications pre-installed on the device when it leaves the factory. It should be noted here that, in the embodiment shown in FIG. 6 , customized data is stored in the version partition and the preload partition. In other embodiments of the present application, other partition structures may also be used to store customized data. For example, keep only the version partition or only the preload partition. Another example is to add an additional service partition.
  • FIG. 7 is a schematic diagram of a data storage structure according to an embodiment of the present application.
  • the version partition in the customized dynamic partition and the partition (such as the vbmeta_version partition) used to store the verification content of the version partition in the static partition can be collectively referred to as a custom (version) component
  • the custom (version) component in the dynamic partition can be customized
  • the preload partition and the partition used to store the verification content of the preload partition (such as the vbmeta_preload partition) in the static partition are collectively called the shelf (preload) component
  • all sub-partitions in the dynamic partition in the basic operating system data storage structure in the customized dynamic partition Partitions, such as system, system_ext, product, vendor, etc., and the rest of the static partition are collectively called the base component.
  • each partition in the custom dynamic partition and the space used to verify the partition in the static partition can be divided into a component.
  • the solution of this application will be described mainly by taking the base component, the version component and the preload component divided as shown in FIG. 7 as examples.
  • partitions with strong associations for example, partitions with similar functions of stored data
  • partitions with similar functions of stored data can be divided into the same component.
  • the data of any component is updated, there will be an upgrade requirement.
  • the preload component has a huge demand for upgrades.
  • the version partition and preload partition are sub-partitions of the custom dynamic partition (Super). Therefore, the entire customized operating system (basic data + customized data) can also be upgraded using the upgrade solution shown in FIG. 5A.
  • the new version of the component that needs to be upgraded (such as the version component and the preload component) can be combined with the new version that does not need
  • the current version of the upgraded components (such as the base component) is combined into a new version and released, that is, the combined upgrade package is released. Then, after the device obtains the combined upgrade package, it can use the upgrade process shown in FIG. 5A to complete the upgrade.
  • the upgrade installation package (also referred to as base installation package) of the base component can be released; If the version component needs to be upgraded, an upgrade installation package of the version component (also called a version upgrade package) can be released; if the preload component needs to be upgraded, an upgrade installation package of the preload component can be released (also called a preload upgrade package). That is, the version of each component can evolve independently.
  • the upgrade installation packages corresponding to the multiple components may be published.
  • the device will only adjust slot 1 and create an index of the cow file for the manifest parsed out of one of the upgrade installation packages. In this way, the adjustment to slot1 will be incomplete, and the index of the created cow file will be inaccurate, which will eventually affect the loading of the customized dynamic partition (Super).
  • Super customized dynamic partition
  • the present application provides a method for upgrading a combination of multiple components in an operating system.
  • at least two combinations of components in the operating system can be upgraded and updated, so that it can be flexibly Adapt to various upgrade needs.
  • the combination upgrade requirements of base component and version component the combination upgrade requirement of version component and preload component, etc.
  • the device implements combined upgrade of multiple components according to the process shown in FIG. 9 .
  • the device loads the basic partition (Common), the static partition (A) and the dynamic partition (Super) in sequence, and starts from the static partition (A).
  • the dynamic partition (Super) refers to the dynamic partition (Super) in the basic operating system.
  • the dynamic partition (Super) refers to the customized dynamic partition (Super) in the customized operating system. The same is true in the following, and details will not be repeated one by one.
  • the device acquires multiple upgrade packages of multiple components.
  • the plurality of upgrade packages includes a combination of a base upgrade package and a version upgrade package, a combination of a base upgrade package and a preload upgrade package, a combination of a version upgrade package and a preload upgrade package, a base upgrade package, a version upgrade package and a preload One of the combinations of upgrade packages.
  • the device can download multiple upgrade packages for multiple components at one time. Then, the multiple components are uniformly upgraded for the multiple upgrade packages.
  • each upgrade package can be used to upgrade the dynamic sub-partition (ie, the sub-partition of the dynamic partition) and/or the static sub-partition (ie, the sub-partition of the static partition) involved in the corresponding component.
  • each component may involve one or more dynamic subpartitions, and may also involve one or more static subpartitions.
  • multiple components include a version component.
  • the dynamic sub-partition involved in the version component is the version partition
  • the static sub-partition involved is the vbmeta_version partition.
  • the version upgrade package can be used to upgrade the version partition and the vbmeta_version partition.
  • the upgrade package of one component can be called an upgrade installation package.
  • the base upgrade package may be called the first upgrade installation package
  • the version upgrade package may be called the second upgrade installation package.
  • the dynamic subpartition used for upgrading by the first upgrade installation package may be called the first subpartition
  • the dynamic subpartition used for upgrading by the second upgrade installation package may be called the second subpartition.
  • the subpartition other than the dynamic subpartition used for upgrading by the first upgrade package is called the third subpartition.
  • the static sub-partition used for upgrading by the first upgrade installation package can be called the fifth sub-partition
  • the dynamic sub-partition used for upgrading by the second upgrade installation package can be called the sixth sub-partition.
  • Subpartitions other than the static subpartition of are called seventh subpartitions.
  • there may also be a third upgrade installation package, a fourth upgrade installation package, etc., and corresponding to these upgrade installation packages, other dynamic sub-partitions and static sub-partitions may be upgraded.
  • Partitions, for example, the third upgrade package can be used to upgrade the fourth sub-partition of the dynamic partition. This embodiment of the present application does not specifically limit it.
  • the device periodically initiates a packet search request to the packet search server, and the packet search request includes the version number of each component in the operating system currently running on the device; the packet search server , to retrieve whether there is currently an upgrade package for each component with a newer version number.
  • the version numbers of the base component, version component, and preload component in the operating system currently running on the device are all version 1.1. If the latest version number of the base component retrieved by the package search server is still version 1.1, but the If the latest version number is 1.2, it indicates that there is an upgrade package for the version component and the preload component with a newer version number.
  • the package search server feeds back the download addresses of the upgrade packages for the multiple components to the device. The device can download the upgrade package of the corresponding component according to the download address.
  • the online update client (OUC) in the device can update the upgrade package to The location in the device is sent to the device's update engine. Afterwards, the update engine performs specific upgrade operations, such as subsequent upgrade package parsing, data writing, and other operations, to complete the upgrade.
  • the device parses each upgrade package to obtain multiple application manifest data (manifest) corresponding to the multiple upgrade packages.
  • the device can read the offset position and size of the header data of payload.bin in the upgrade package. Then, the device can obtain the manifest from the upgrade package according to the offset position and size of the header data of the payload.bin in the upgrade package.
  • part of the content recorded in the metadata (/metadata) of the upgrade package is as follows:
  • the meaning of payload_metadata.bin:720:1346 is: the offset position (such as 720, unit byte) and size (such as 1346, unit byte) of the header data (ie manifest) of payload.bin in the upgrade package . Then, according to the offset position and size, the device can obtain the original raw data of the manifest (that is, the original data recorded in the upgrade package), and then call the decoding of the original raw data to obtain the specific content of the manifest.
  • the static partition information contained in the manifest parsed from each upgrade package only involves the subpartitions of the static partitions included in the multiple components
  • the dynamic partition information only involves the sub-partitions of the dynamic partitions included in the multiple components.
  • Other components refer to components other than the plurality of components.
  • the static partition information or dynamic partition information includes the name of the sub-partition (also can be understood as a partition identifier), size, check value (such as hash value) of the upgraded data, and the upgraded data The position in the upgrade package.
  • first data For the convenience of description, multiple application list data parsed from multiple upgrade packages may be referred to as first data, second data..., for example, the application list data parsed from the first upgrade installation package is called For the first data, the application list data parsed from the second upgrade installation package is referred to as the second data . . . .
  • the multiple components include a version component. Since the version component includes the vbmeta_version partition in the static partition and the version partition in the dynamic partition, correspondingly, the parsed manifest can include the following partition information:
  • the name and size of the version partition the check value (such as hash value) information of the upgraded data, and the location of the upgraded data in the version upgrade package.
  • the multiple components include a preload component. Since the preload component includes the vbmeta_preload partition in the static partition and the preload partition in the dynamic partition, correspondingly, the parsed manifest can include the following partition information:
  • the name and size of the preload partition, the check value (such as hash value) information of the upgraded data, and the location of the upgraded data in the preload upgrade package are defined.
  • the multiple components include a base component. Since the base component includes partitions other than vbmeta_version and vbmeta_preload in the static partition, such as partitions such as boot and recovery, and subpartitions included in dynamic partitions in the basic operating system, such as partitions such as system and product, the parsed manifest is corresponding can include the following partition information:
  • the name and size of the vendor partition the check value (such as hash value) information of the upgraded data, and the location of the upgraded data in the operating system upgrade package;
  • the device merges multiple manifests to obtain a merged manifest.
  • the combined manifest may be called third data.
  • the device can splice multiple manifests end to end according to a first preset order.
  • the first preset order from front to back is the manifest parsed from the base upgrade package, the manifest parsed from the version upgrade package, and the manifest parsed from the preload upgrade package.
  • the device may also splice the static partition information and dynamic partition information in multiple manifests according to a first preset order. Exemplarily, referring to FIG.
  • the device may sequentially
  • the manifest parsed from the base upgrade package, the manifest parsed from the version upgrade package, and the static partition information in the manifest parsed from the preload upgrade package are stitched together, and the manifest parsed from the base upgrade package, from The manifest parsed from the version upgrade package is spliced with the dynamic partition information in the manifest parsed from the preload upgrade package to obtain the spliced manifest.
  • the device can obtain the merged manifest, and can put the merged manifest into a newly created object, such as mergedmanifest. Subsequent devices can complete the corresponding processing only according to the value of the mergedmanifest, such as adjusting slot1, creating an index of the cow file, and so on.
  • the device adjusts the sub-partition description group in slot1 in the dynamic partition (Super) according to the dynamic partition information in the merged manifest, and obtains the adjusted slot1. Wherein, during the process of adjusting the sub-partition description group, the device does not delete the sub-partition description group of the sub-partitions included in other components from slot1, and the other components are components other than the plurality of components.
  • the merged manifest includes: dynamic partition information of sub-partitions included in multiple components in the dynamic partition, and the dynamic partition information includes the name and size of the sub-partitions.
  • the device adjusts slot1 according to the merged manifest, the device adjusts the address (Extents) item in the corresponding subpartition description group in slot1 according to the name and size of the subpartition in the dynamic partition information. If the size of the sub-partition does not change, the address (Extents) item in the corresponding sub-partition description group in slot1 does not change. If the size of the sub-partition changes, adjust the address (Extents) item in the corresponding sub-partition description group in slot1.
  • the adjusted address (Extents) item of each sub-partition description group in slot1 matches the size of the corresponding sub-partition.
  • the solution of the present application will be described mainly with the fact that the size of the sub-partition does not change.
  • the device will not delete the subpartition description groups of subpartitions included in other components from slot1, that is, delete the subpartition description groups of subpartitions included in components that do not need to be upgraded.
  • Partition description group For convenience of description, the multiple sub-partition description groups included in the adjusted slot1 may be referred to as multiple third description groups.
  • the multiple components are a version component and a preload component, that is, only the version component and the preload component need to be upgraded, but the base component does not need to be upgraded.
  • the subpartition included in the version component is the version partition
  • the subpartition included in the preload component is the preload partition
  • the merged manifest includes the dynamic partition information of the version partition and the preload partition.
  • the slot1 before adjustment includes the sub-partition description group shown in (a) in Figure 11, that is, the slot1 before adjustment includes system, system_ext, A subgroup description group of 8 subpartitions including product, vendor, cust, odm, version, and preload.
  • the adjusted slot1 includes the sub-partition description group shown in (b) in FIG. 11 .
  • the sub-partition description groups other than the version partition and the preload partition are not deleted in the adjusted slot1.
  • slot1 before adjustment, slot1 includes sub-partition description groups of partitions such as system, system_ext, and product (belonging to the sub-partitions included in the base component), and after adjustment, slot1 also includes partitions such as system, system_ext, and product (belonging to the sub-partitions included in the base component)
  • the sub-partitions of ) describe groups (as shown by the dotted box in (b) in Figure 11).
  • the corresponding sub-partition description group in slot1 after adjustment is the same.
  • the address (Extents) item in the sub-partition description group of the at least one sub-partition in slot1 may be different Change accordingly.
  • the description group of sub-partitions (such as the third sub-partition) not involved in the dynamic partition information in the merged manifest will not be deleted.
  • the device will delete the sub-partition description group corresponding to the static partition (A), that is, the sub-partition description with the suffix _a group, and only retain the sub-partition description group corresponding to the static partition (B), that is, the sub-partition description group with the suffix _b.
  • the device records the index of the cow file in the basic partition (Common) according to the dynamic partition information in the merged manifest. Wherein, the index is consistent with the sub-partition involved in the dynamic partition information in the manifest.
  • the index of the cow file in S905 and its subsequent steps may be referred to as the first index.
  • the adjusted slot1 not only includes sub-partition description groups corresponding to multiple components (ie, components that need to be upgraded), but also retains sub-partition description groups corresponding to other components (ie, components that do not need to be upgraded).
  • the index will not only instruct the device to read multiple components from the user data partition (userdata) component) contains the cow file corresponding to the sub-partition, and also instructs the device to read the cow file corresponding to the sub-partition included in other components (that is, components that do not need to be upgraded) from the user data partition (userdata).
  • the device will not write cow files corresponding to subpartitions included in other components in the user data partition (userdata). Therefore, instruct the device to read from the user data partition (userdata)
  • the cow files corresponding to subpartitions included in other components are obviously unreasonable.
  • the device records the index of the cow file under the basic partition (Common) according to the dynamic partition information in the merged manifest.
  • the index is consistent with the sub-partition involved in the dynamic partition information in the merged manifest.
  • the index may only instruct the device to read the cow file corresponding to the sub-partition included in the component to be upgraded from the user data partition (userdata).
  • the merged manifest includes the dynamic partition information of the version partition and the preload partition.
  • the device can only record the index of the cow file of the version partition and the index of the cow file of the preload partition in the basic partition (Common), so as to instruct the device to read the version partition and the index corresponding to the preload partition from the user data partition (userdata). cow file.
  • the device can create a /gsi/ota/lp_metadata file under the metadata (/metadate) of the basic partition (Common), and create the /gsi/ota/lp_metadata file in the /gsi/ota/lp_metadata file
  • the index of the cow file is recorded in . Therefore, it is convenient for the device to obtain the index of the cow file from a fixed location.
  • the index of the cow file includes the name of the cow file.
  • the device can generate the subpartitions involved in the dynamic partition information according to the merged manifest including the subpartitions involved in the dynamic partition information (such as the first subpartition and the second subpartition) and the naming rules of the cow file.
  • the suffix _b corresponds to the static partition (B), and can be read to load the dynamic partition when restarting from the static partition (B).
  • the device can write the name version_b_cow_img into the basic partition (Common) as the index of the cow file in the version partition; the device can write the name preload_b_cow_img into the basic partition (Common) as the index of the cow file in the preload partition.
  • the cow file that needs to be found can be accurately indicated by the name.
  • the name of the cow file of the first sub-partition may be referred to as the first file name
  • the name of the cow file of the second sub-partition may be referred to as the second file name.
  • the index of the cow file also includes the storage location of the cow file.
  • the storage location may be a user data partition (userdata).
  • the storage location may be the target directory of the user data partition (userdata) (for example, the /data/gsi/ota directory), and the target directory of the user data partition (userdata) is used to store the upgrade data, if the upgrade data is in cow file storage, the cow file is also stored in the target directory. In this way, the storage location can be used to indicate exactly where to find the cow file.
  • the index of the obtained cow file can include the following information:
  • the above index indicates that there are cow files named version_b_cow_img and named preload_b_cow_img in the user data partition (userdata).
  • S904 and S905 are not in a strict sequence.
  • S905 may also be performed before S904, or S904 and S905 may be performed simultaneously, which is not specifically limited in this embodiment of the present application.
  • the device can adjust slot1 according to the merged manifest, and the adjusted slot1 still retains the subpartitions of the subpartitions included in the components that have not been upgraded this time. Partition description group.
  • the device can create the index of the cow file according to the merge or manifest, so that the index of the cow file only instructs the device to read the cow file corresponding to the sub-partition included in the component that needs to be upgraded this time from the user data partition (userdata) .
  • the device creates a virtual dynamic partition in the user data partition (Userdata) according to multiple upgrade packages, and sequentially performs data writing operations on the static partition (B) according to the multiple upgrade packages to upgrade the static partition, and write data in the virtual dynamic partition. Import the upgrade data of the dynamic partition (Super). In the virtual dynamic partition, the cow file is used to save the upgrade data of the dynamic partition (Super).
  • each upgrade package includes upgrade data for upgrading the dynamic sub-partition and upgrade data for upgrading the static sub-partition.
  • the upgrade data used by the first upgrade installation package to upgrade the dynamic sub-partition can be called the first upgrade data
  • the second upgrade installation package can be used to upgrade the dynamic sub-partition (such as the second sub-partition).
  • the upgrade data of sub-partitions is called the second upgrade data.
  • the upgrade data that the first upgrade installation package is used to upgrade the static sub-partition (such as the fifth sub-partition) can be called the third upgrade data
  • the second upgrade installation package is used to upgrade the static sub-partition (such as the sixth sub-partition). ) is called the fourth upgrade data.
  • the device writes the data used to upgrade the static sub-partitions in the multiple upgrade packages into the corresponding sub-partitions (such as the fifth sub-partition and the sixth sub-partition) of the static partition (B), and writes the multiple upgrade packages
  • the data in the package used to upgrade the dynamic sub-partition is written into the virtual dynamic partition.
  • the multiple components are a version component and a preload component as an example.
  • the version component includes a vbmeta_version partition (a sub-partition belonging to a static partition) and a version partition (a sub-partition belonging to a dynamic partition)
  • the preload component includes a vbmeta_preload partition (a sub-partition belonging to a static partition) and a preload partition (a sub-partition belonging to a dynamic partition).
  • the device when the data is updated, the device writes the data of the vbmeta_version partition in the version upgrade package and the data of the vbmeta_preload partition in the preload upgrade package into corresponding partitions of the static partition (B).
  • the device may sequentially write the data for upgrading the static sub-partition and the data for upgrading the dynamic sub-partition in each upgrade package to corresponding locations.
  • the data update cannot be completed only by writing the data of one upgrade package.
  • the device when the device writes data to the static partition (B) and the virtual dynamic partition, it can sequentially traverse multiple upgrade packages according to the second preset order, for example, the second preset order is the base upgrade package, version upgrade package and preload upgrade package. And when each upgrade package is traversed, the upgrade data is obtained from the upgrade package and written to the corresponding position to complete the data update. Wherein, if it is the upgrade data of the static partition, it is written into the static partition (B), and if it is the upgrade data of the dynamic partition, it is written into the user data partition (Userdata) in the form of a cow file. After completing the writing of the data corresponding to an upgrade package, it is judged whether there are any upgrade packages to be updated, and if so, the traversal is continued. If not, end S906.
  • the second preset order is the base upgrade package, version upgrade package and preload upgrade package.
  • the upgrade data is obtained from the upgrade package and written to the corresponding position to complete the data update.
  • the device may put the multiple upgrade packages into the target array in a second preset order, where each upgrade package is an element of the target array.
  • the device can sequentially fetch elements from the array, and after fetching an element, write the data of the corresponding upgrade package.
  • the device can continue to fetch elements from the target array. If the elements can be fetched, it is determined that there are upgrade packages that need to be updated, and the data writing continues. On the contrary, if the element cannot be obtained, it is determined that the data of all upgrade packages have been updated, and S906 ends.
  • the second preset order from front to back is base upgrade package, version upgrade package and preload upgrade package as an example. Since the base component is not included in the multiple components, the device can only Put the version upgrade package and preload upgrade package into the target array.
  • the device can take out the version upgrade package from the target array for the first time, write the data of the vbmeta_version partition in the version upgrade package into the vbmeta_version partition of the static partition (B), and write the data of the version partition in the version upgrade package as cow The file is written into the virtual dynamic partition to complete the data update for the version upgrade package.
  • the device can take out the preload upgrade package from the target array for the second time, write the data of the vbmeta_preload partition in the preload upgrade package into the vbmeta_preload partition of the static partition (B), and write the data of the preload partition in the preload upgrade package to the cow file Write to the virtual dynamic partition to complete the data update for the preload upgrade package. So far, all the upgrade packages in the target array have been taken out, and the device can no longer obtain the upgrade packages from the target array, it can be determined that all upgrade packages have been updated, and S906 ends.
  • the device checks the updated data of each sub-partition.
  • the device can complete the verification according to the merged manifest.
  • the device can calculate the check value (such as hash value) of the upgraded data of the sub-partition in the operating system, and then compare the check value with the target of the corresponding sub-partition in the merged manifest.
  • the verification value (such as the hash value) is compared, and if the two are the same, the verification is successful.
  • the device after the device finishes writing data to the vbmeta_version partition, it can calculate the sha256 value of the data in the /dev/block/by-name/vbmeta_version_b directory, and combine the sha256 value with the vbmeta_version partition in the merged manifest Compare the sha256 values of , if the two are the same, the verification is successful.
  • the device can calculate the check value (such as hash value) of the result of combining the data of the sub-partition and the data in the cow file of the sub-partition in the virtual dynamic partition, and then the hash value Compared with the target verification value (such as hash value) of the corresponding sub-partition in the merged manifest, if the two are the same, the verification is successful.
  • the version partition as an example, after the device writes the upgrade data of the version partition to the cow file named version_b_cow_img in the virtual dynamic partition, it can calculate the data of the version partition in the dynamic partition and the cow file named version_b_cow_img in the virtual dynamic partition. The sha256 value of the synthesis result of the data, and compare the sha256 value with the sha256 value of the version partition in the merged manifest. If the two are the same, the verification is successful.
  • the device sequentially loads the basic partition (Common) and the static partition (B), and starts from the static partition (B).
  • the upgraded operating system is started from the static partition (B), which may also be called the second operating system.
  • the device loads the dynamic partition (Super) and the cow file of the virtual dynamic partition in the user data partition (Userdata) according to the adjusted slot1 and the index of the cow file.
  • the adjusted slot1 includes sub-partition description groups corresponding to the base component, the version component, and the preload component. Therefore, when the device reads the sub-partition description group in the adjusted slot1, it can obtain address (Extents) items of all sub-partitions in the dynamic partition. And, the index of the cow file only includes the index of the cow file corresponding to the subpartitions included in multiple components (that is, the components that need to be upgraded this time). Therefore, the device reads the index of the cow file, and can only obtain the cow files corresponding to all the upgraded sub-partitions in the dynamic partition, that is, the first upgrade data and the second upgrade data.
  • the device is successfully started and enters a user interaction interface.
  • the device puts the data of the virtual dynamic partition into the dynamic partition (Super).
  • the device can process the multiple upgrade packages to complete the upgrade of the multiple components. In this way, the requirement that at least two components need to be upgraded can be flexibly met.
  • the device can use the pre-adjusted subpartition description group in slot1 as the basic data for adjusting slot1 and creating the index of the cow file, and then obtain the adjusted slot1 and the index of the cow file through modification operations such as addition, deletion, modification, and query.
  • modification operations such as addition, deletion, modification, and query.
  • the device stores the subpartition description group in slot1 corresponding to the static partition (B) into the first temporary object and the first file, respectively.
  • the first temporary object (such as target_metadata) is a temporary object created by the update engine process, and is used to adjust slot1.
  • the first file (such as lp_metadata) is a file created by the update engine under the metadata (metadata) of the basic partition (common), and is used to create the index of the cow file.
  • the first file may also be referred to as a target file.
  • the device may copy the sub-partition description group in the slot1 corresponding to the static partition (B) (slot1 before adjustment at this time) to the first temporary object and the first file, as the basic data and the first file for adjusting slot1, respectively.
  • S904 in FIG. 9 further includes S1201 and S1202:
  • the device adjusts data in the first temporary object according to the dynamic partition information in the merged manifest. Wherein, during the process of adjusting the data in the first temporary object, the device does not delete the subpartition description group of the subpartitions included in other components, and the other components are components other than the plurality of components.
  • the device updates the adjusted data in the first temporary object to slot1 to obtain the adjusted slot1.
  • the device may write the adjusted data in the first temporary object into slot1 to overwrite the original data in slot1, so as to obtain the adjusted slot1. And, after the adjusted data in the first temporary object is written into slot1, the first temporary object is released.
  • the device completes the adjustment of the slot1 in the first temporary object, instead of directly adjusting the slot1. In this way, the adjustment process does not directly target slot1, thereby preventing the adjustment process from affecting the operation of the operating system.
  • S905 in FIG. 9 further includes S1203 and S1204:
  • the device adjusts the data in the first file according to the dynamic partition information in the merged manifest. Wherein, during the process of adjusting the data in the first file, the device deletes the subpartition description group of the subpartitions included in other components, and the other components are components other than the multiple components.
  • the sub-partitions involved in the dynamic partition information in the merged manifest are the version partition and the preload partition, and the other components are the base components.
  • the basic data of the first file is shown in (a) in Figure 13, when the device adjusts the data in the first file, it will describe the sub-partitions of the sub-partitions (such as system, product, etc.) included in the base component Group deletion. After deletion, the remaining data is as shown in (b) in Figure 13, only the sub-partition description groups of the version partition and the preload partition remain.
  • the device generates an index of the cow file according to the adjusted data in the first file.
  • the device can generate the file name of the cow file according to the value of the name item in the remaining description group in the first file and the naming rule of the cow file, and use it as an index of the cow file. For details, refer to the description in S904 above.
  • the file name of the generated cow file may be called the first file name, and the first file name corresponds to the sub-partition of the dynamic partition involved by multiple components.
  • the device uses the data in slot1 before adjustment as the basic data for creating the index of the cow file, and then the creation of the index can be completed through simple addition, deletion, modification and query.
  • the device may further create an empty cow file (also called an initial cow file) under the user data partition (userdata) according to the index to store the upgrade data.
  • creating an empty cow file can be understood as creating a virtual dynamic partition in the previous article.
  • S906 in Figure 9 further includes S1400 and S1401:
  • the device creates an empty cow file under the user data partition (userdata) according to the index of the cow file.
  • the index of the cow file records the relevant information of each sub-partition that needs to be upgraded in the dynamic partition, such as the name of the sub-partition and the name of the cow file corresponding to the sub-partition. According to the relevant information, the device can generate an empty cow file corresponding to each sub-partition to be upgraded in the dynamic partition.
  • the partition name "version" is recorded in the index of the cow file, and the device can generate the name of the cow file corresponding to the version partition as: version_b_cow_img according to the naming rules of the cow file.
  • the suffix _b corresponds to the static partition (B), and can be read to load the dynamic partition when restarting from the static partition (B).
  • the device creates an empty cow file named version_b_cow_img under the user data partition (userdata), and sets the space occupied by the cow file according to the size of the version partition to leave enough space for storing the upgrade data.
  • the device can obtain the size of the version partition according to the size of the version partition in the manifest.
  • the index of the cow file includes the name of the cow file.
  • the device can directly create a named cow file under the user data partition (userdata), and set the space occupied by the cow file according to the size of the partition.
  • the initial cow file generated according to the first file name can be called the first initial cow file
  • the initial cow file generated according to the second file name can be called the second initial cow file. It should be clear that if there are multiple first sub-partitions, then there are multiple first file names, and correspondingly, there are also multiple first initial cow files. Similarly, if there are multiple second sub-partitions, then there are multiple second file names, and correspondingly, there are also multiple second initial cow files.
  • an empty cow file can be created at any time after the index of the cow file is created.
  • the device obtains the upgrade package, it is running normally until it is restarted, and there is always running data occupying the space of the user data partition (userdata). Therefore, the sooner an empty cow file is created, the sooner it can occupy space for storing upgrade data. In this way, too much space occupied by the user data partition (userdata) due to device operation can be avoided, resulting in insufficient space for storing upgrade data.
  • the device sequentially performs data writing operations on the static partition (B) according to multiple upgrade packages to upgrade the static partition, and writes the upgrade data of the dynamic partition (Super) in an empty cow file. Among them, the upgrade data of a sub-partition in the dynamic partition (Super) is written in an empty cow file.
  • the first upgrade data is written in the first initial cow file
  • the second upgrade data is written in the second initial cow file.
  • the device creates an empty cow file according to the index of the cow file, so as to occupy the space for storing the upgrade data, so as to avoid insufficient space to store the upgrade data due to the operation of the device.
  • the initial data in the static partition (A) and the static partition (B) are the same, the initial data of the vbmeta_version partition is X1, and the initial data of the vbmeta_preload partition All are Y1, and the initial data of other sub-partitions are all Z1.
  • the device will update the data of the vbmeta_version partition in the static partition (B) when updating the data of the static partition (such as in S906) , get the updated data X2, and update the data of the vbmeta_preload partition in the static partition (B), and get the updated data Y2.
  • the data of the vbmeta_version partition in the static partition (A) and the static partition (B) are different.
  • the device when the device is currently started from the static partition (B), and the preload component and the base component need to be upgraded, the device will update the vbmeta_preload partition in the static partition (B) when performing data update on the static partition (such as in S906)
  • the updated data Y3 is obtained, and the data of the system and system_ext partitions (subpartitions included in the base component) are updated in the static partition (B), and the updated data Z2 is obtained.
  • the data of the vbmeta_version partition included in the version component that does not need to be upgraded is still the initial data X1, not the previously updated X2. In this way, the data in the static partition (B) will not correspond to the latest version of the data.
  • the multiple components are two of the base component, the version component and the preload component, and the device is currently started from the static partition (A)
  • the latest data of sub-partitions included in other components in the static partition (A) can be synchronized to the static partition (B).
  • the device is currently booted from the static partition (B), after the device obtains multiple upgrade packages, it can synchronize the latest data of sub-partitions included in other components in the static partition (B) (that is, components that do not need to be upgraded currently) to Static partition (A).
  • the device detects whether the multiple components include a base (base) component, a custom (version) component, and a shelf (preload) component. If yes, execute S906; if not, execute S1601 or S1602.
  • multiple components include base component, version component and preload component, it indicates that all components need to be upgraded.
  • all component subpartitions need to be updated.
  • all the components involve all sub-partitions of the static partition (B), that is, all sub-partitions of the static partition (B) need to be updated, and there are no sub-partitions (such as the seventh sub-partition) that do not need to be updated.
  • the device does not need to synchronize the latest data between the static partition (A) and the static partition (B), but can directly traverse multiple upgrade packages to update data.
  • the device needs to synchronize the latest data between the static partition (A) and the static partition (B).
  • the device synchronizes data of sub-partitions included in other components in the static partition (A) to corresponding sub-partitions in the static partition (B).
  • base base
  • other components are components other than the plurality of components.
  • the multiple components are the base component and the version component, or the base component and the preload component.
  • other components except the plurality of components do not include the base component.
  • the device can synchronize the data of the sub-partition (seventh sub-partition) included in other components in the static partition (A) to the corresponding sub-partition in the static partition (B).
  • multiple components are base components and preload components, and other components are version components, and the device can synchronize data in the vbmeta_version partition (ie vbmeta_version_a) of the static partition (A) to the vbmeta_version partition ( That is vbmeta_version_b).
  • the device can synchronize the data of sub-partitions that do not need to be upgraded currently in the static partition through the synchronization of a small part of data.
  • a sub-partition involving a large amount of data in the static partition (B), for example, a sub-partition related to a base component in the static partition (B), may be called a preset sub-partition.
  • the device synchronizes data of all sub-partitions in the static partition (A) to corresponding sub-partitions in the static partition (B).
  • Multiple components are version components and preload components, and multiple components do not include base components.
  • other components are base components. That is, most data in static partitions does not need to be upgraded. Therefore, when multiple components do not include the base component, the device can directly synchronize the data of all sub-partitions in the static partition (A) to the corresponding sub-partitions of the static partition (B). In this way, when most of the data does not need to be updated, the device does not need to remove data that does not need to be synchronized from the static partition (A), but can simplify the steps of synchronization by synchronizing all.
  • S1600-S1602 are not limited to those shown in FIG. 16 .
  • the device may execute the foregoing S1600-S1602 at any time between S902-S906, which is not specifically limited in this embodiment of the present application.
  • the device can synchronize the latest data of sub-partitions that do not need to be upgraded in the static partition (A) to the static partition (B), and then update the data of the static partition (B). In this way, it can be guaranteed that the data of each sub-partition in the static partition (B) is up-to-date.
  • the device may display the updating progress of the data updating, for example, 50%, 80% and so on. When the update progress reaches 100%, it means that the data update of multiple components is completed. As shown in Figure 17, during the process of the device executing S906 in Figure 9, S1700 and S1701 are also included:
  • the device records the writing progress of the component currently targeted for data update, and records the sequence number of the component currently targeted for data update.
  • the writing progress may reflect the amount of data written by the currently targeted component, and may also be referred to as saving progress.
  • the sort number reflects the number of sort bits when the currently targeted component is updated in multiple components.
  • the device may record the above-mentioned writing progress and sorting number (that is, payload_id, which may also be called the traversal sequence number) in the directory /data/misc/update_log/perfs in the user data partition (Userdata).
  • the device first performs data update for the version component.
  • the component currently targeted by the current data update is the version component, and the version component is the first component of this data update, so the sort number is 1.
  • the device can update in real time the amount of data written to the version component, that is, the writing progress of the version component. After the amount of data written for the version component reaches the total amount of data that the version component needs to write, the device starts to update the data for the preload component.
  • the current data update is for the preload component
  • the preload component is the The second component of the update
  • the sort count is updated to 2.
  • the device can update in real time the amount of data written to the preload component, that is, the writing progress of the preload component.
  • the device calculates the update progress according to the write progress and the sort number, and displays the update progress.
  • the update progress refers to the amount of data that has been written for multiple components, as a percentage of the total amount of data that needs to be written by multiple components.
  • the device can obtain the total amount of data to be written by each component according to the merged manifest.
  • each piece of partition information includes the location of the upgrade data in the corresponding upgrade installation package, and the location includes the offset of the start location, the offset of the end location, and the size of the data volume.
  • the size of the data volume is the data volume of the corresponding sub-partition.
  • the device sums the data volumes of multiple sub-partitions included in the same component to obtain the total data volume of the corresponding component.
  • the device can accurately display the update progress during the update process of multiple component data.
  • the device updates data in the order of the base component, version component, and preload component, and the device is powered off during the update of the version component. After the device is restarted, if the data is updated from the base component again, data may be written repeatedly, affecting the upgrade. In addition, it will also affect the extension of the upgrade time.
  • the device can continue to update from the corresponding update progress at the time of power failure according to the write progress and sorting number recorded in the embodiment shown in the foregoing Figure 17. Specifically, after the device is restarted, the device may determine whether it is a case of restarting after a power failure during the process of updating data, and if so, determine that data update needs to be continued (resume). The device can locate the component being updated when the power is off according to the sort number, and it can also be understood as locating the target upgrade package being written. As shown in (b) in Figure 18, the version component is located according to the sort number 2, that is, the data writing of the version upgrade package is in progress.
  • the device may delete the index of the cow file after the disk transfer (eg, S912 in FIG. 9 ) is completed. Specifically, as shown in FIG. 19, after S912 in FIG. 9, S1900 is also included:
  • the dynamic partition needs to be loaded again according to the index of the cow file. Therefore, in this embodiment, when the transfer status information of all sub-partitions in the metadata (/metadata) of the basic partition (Common) is changed from "wait for merge” to "merged )", it indicates that all the data has been transferred to the disk, and at this time, the index of the cow file will be deleted. In this way, the device can continue to use the index of the cow file to load the dynamic partition in the case of an abnormal power failure and restart during the disk transfer process.
  • An embodiment of the present application provides an electronic device, and the electronic device may include: a memory and one or more processors.
  • the memory is coupled to the processor.
  • the memory is used to store computer program code comprising computer instructions.
  • the processor executes the computer instructions, the electronic device can execute various functions or steps performed by the device in the foregoing method embodiments.
  • the embodiment of the present application further provides a chip system, as shown in FIG. 20
  • the chip system 2000 includes at least one processor 2001 and at least one interface circuit 2002 .
  • the processor 2001 and the interface circuit 2002 can be interconnected through lines.
  • interface circuit 2002 may be used to receive signals from other devices, such as memory of an electronic device.
  • the interface circuit 2002 may be used to send signals to other devices (such as the processor 2001).
  • the interface circuit 2002 can read instructions stored in the memory, and send the instructions to the processor 2001 .
  • the electronic device may be made to execute various steps in the foregoing embodiments.
  • the chip system may also include other discrete devices, which is not specifically limited in this embodiment of the present application.
  • the embodiment of the present application also provides a computer storage medium, the computer storage medium includes computer instructions, and when the computer instructions are run on the electronic device, the electronic device is made to perform various functions or steps performed by the device in the above method embodiments.
  • the embodiments of the present application also provide a computer program product, which, when running on a computer, causes the computer to execute the various functions or steps performed by the device in the above method embodiments.
  • the disclosed devices and methods may be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods.
  • multiple units or components can be combined Or it can be integrated into another device, or some features can be omitted, or not implemented.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
  • the unit described as a separate component may or may not be physically separated, and a component displayed as a unit may be one physical unit or multiple physical units, that is, it may be located in one place, or may be distributed to multiple different places. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
  • the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a readable storage medium.
  • 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, and the software product is stored in a storage medium Among them, several instructions are included to make a device (which may be a single-chip microcomputer, a chip, etc.) or a processor (processor) execute all or part of the steps of the method in various embodiments of the present application.
  • the aforementioned storage medium includes: various media that can store program codes such as U disk, mobile hard disk, read only memory (ROM), random access memory (random access memory, RAM), magnetic disk or optical disk.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

Embodiments of the present application relate to the technical field of computers, and provide an operating system upgrade method, an electronic device, a storage medium, and a chip system. Multiple sub-partitions in an operating system can be combined and upgraded to flexibly meet various upgrade requirements. The method comprises: acquiring a first upgrade installation package and a second upgrade installation package, the first upgrade installation package comprising first data, the first data comprising partition information of a first sub-partition, the second upgrade installation package comprising second data, and the second data comprising partition information of a second sub-partition; obtaining a plurality of third description groups according to third data and a plurality of second description groups, the third data comprising the partition information of the first sub-partition and the second sub-partition, and the plurality of third description groups comprising description groups respectively corresponding to the first sub-partition, the second sub-partition and a third sub-partition; and restarting an electronic device, reading values of address items in the plurality of third description groups, and loading data of dynamic partitions on the basis of the values of the address items in the plurality of third description groups.

Description

操作系统升级方法、电子设备、存储介质及芯片系统Operating system upgrade method, electronic equipment, storage medium and chip system
本申请要求于2022年1月10日提交国家知识产权局、申请号为202210023196.0、发明名称为“操作系统升级方法、设备、存储介质及计算机程序产品”的中国专利申请,以及要求于2022年2月14日提交国家知识产权局、申请号为202210135613.0、发明名称为“操作系统升级方法、电子设备、存储介质及芯片系统”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application requires submission of a Chinese patent application with the State Intellectual Property Office on January 10, 2022, with the application number 202210023196.0, and the title of the invention is "Operating System Upgrade Method, Equipment, Storage Medium, and Computer Program Product", and requires filing on February 2022. The priority of a Chinese patent application filed with the State Intellectual Property Office on April 14, with the application number 202210135613.0, and the title of the invention is "operating system upgrade method, electronic equipment, storage medium and chip system", the entire contents of which are incorporated in this application by reference .
技术领域technical field
本申请涉及计算机技术领域,尤其涉及一种操作系统升级方法、电子设备、存储介质及芯片系统。The present application relates to the field of computer technology, in particular to an operating system upgrade method, electronic equipment, storage media and a chip system.
背景技术Background technique
在手机、笔记本电脑等终端设备中,操作系统是其最基本也是最为重要的基础性系统软件。终端设备在安装操作系统的情况下,才能被用户使用。以终端设备是手机为例,手机上需要安装手机操作系统,如苹果移动设备操作系统(iPhone Operation System,IOS)、安卓(Android)系统等,才可以被用户使用。In terminal equipment such as mobile phones and notebook computers, the operating system is the most basic and most important basic system software. A terminal device can only be used by a user when an operating system is installed. Taking the terminal device as a mobile phone as an example, the mobile phone operating system needs to be installed on the mobile phone, such as the Apple mobile device operating system (iPhone Operation System, IOS), Android (Android) system, etc., before it can be used by the user.
通常情况下,操作系统由操作系统供应商(如安卓系统的供应商为谷歌)提供。并且,操作系统供应商所提供的操作系统是基础操作系统,其仅包含最基础的功能,其并不能完全满足用户的应用需求。为了满足用户的应用需求,提升用户体验,终端设备供应商会根据客户需求、应用场景的不同,对基础操作系统进行优化,在基础操作系统的基础上增加定制内容,构建定制操作系统。在终端设备上安装定制操作系统后,终端设备可以提供优化的系统功能。以终端设备是安装安卓系统的手机为例,在手机出厂前,在安卓系统中增加指定网络运营商的客户服务系统,令手机开机后可以登录用户在该网络运营商下的用户账户以实现计费充值等功能。Usually, the operating system is provided by the operating system provider (for example, the provider of Android system is Google). Moreover, the operating system provided by the operating system supplier is a basic operating system, which only includes the most basic functions, and cannot fully meet the application requirements of users. In order to meet the application needs of users and improve user experience, terminal equipment suppliers will optimize the basic operating system according to different customer needs and application scenarios, add customized content on the basis of the basic operating system, and build a customized operating system. After the customized operating system is installed on the terminal device, the terminal device can provide optimized system functions. Taking the mobile phone with the Android system installed as the terminal device as an example, before the mobile phone leaves the factory, the customer service system of the designated network operator is added to the Android system, so that after the mobile phone is turned on, the user can log in to the user account under the network operator to realize the calculation. Fee recharge and other functions.
在终端设备安装定制操作系统后,当出现版本升级时,需要升级终端设备上所安装的定制操作系统。并且,在定制操作系统中,大量的升级需求仅需升级定制操作系统中部分存储区中的数据。After the customized operating system is installed on the terminal device, when a version upgrade occurs, the customized operating system installed on the terminal device needs to be upgraded. Moreover, in the customized operating system, a large number of upgrade requirements only need to upgrade the data in some storage areas in the customized operating system.
然而,目前操作系统的升级方案是由操作系统供应商提供的。操作系统供应商提供的升级方案通常是针对操作系统整体进行升级。若将该升级方案用于定制操作系统的升级需求,则当定制操作系统中任一部分存储区中的数据需要升级时,均需将需要升级的部分的新版本和不需要升级的部分的当前版本组合为一个新版本后发布,即发布组合升级包。然后,根据组合升级包对整个定制操作系统升级。如此,随着定制操作系统的升级需求变大,则会得到大量大版本的升级包,不利于终端设备供应商对定制操作系统的版本进行灵活管理。However, currently the OS upgrade solution is provided by the OS vendor. The upgrade solution provided by the operating system supplier is usually aimed at upgrading the entire operating system. If this upgrade plan is used for the upgrade requirements of the customized operating system, when the data in any part of the storage area in the customized operating system needs to be upgraded, the new version of the part that needs to be upgraded and the current version of the part that does not need to be upgraded After being combined into a new version, it is released as a combined upgrade package. Then, upgrade the entire customized operating system according to the combined upgrade package. In this way, as the upgrade demand of the customized operating system increases, a large number of large-version upgrade packages will be obtained, which is not conducive to flexible management of the customized operating system version by the terminal equipment supplier.
发明内容Contents of the invention
本申请实施例提供一种操作系统升级方法、电子设备、存储介质及芯片系统,可 以针对操作系统中的多个子分区组合升级,灵活满足各种升级需求。Embodiments of the present application provide an operating system upgrade method, electronic equipment, storage media, and a chip system, which can be combined and upgraded for multiple sub-partitions in the operating system to flexibly meet various upgrade requirements.
第一方面,本申请实施例提供一种操作系统升级方法,该方法可以应用于电子设备。电子设备包括处理器以及存储器,存储器包括基础分区、第一静态分区、第二静态分区、动态分区以及用户数据分区,动态分区包括第一插槽数据和第二插槽数据,动态分区包括多个子分区,第一插槽数据包括与多个子分区对应的多个第一描述组,第二插槽数据包括与多个子分区对应的多个第二描述组。加载基础分区、第一静态分区和动态分区的数据,以运行第一操作系统,在加载动态分区的数据的过程中,读取多个第一描述组,基于多个第一描述组中地址项的值加载动态分区的数据。获取第一升级安装包和第二升级安装包,第一升级安装包用于升级第一子分区,第二升级安装包用于升级第二子分区,第一子分区和第二子分区是动态分区的子分区,第一升级安装包包括第一数据(manifest),第一数据包括第一子分区的分区信息,第二升级安装包包括第二数据,第二数据包括第二子分区的分区信息。根据第三数据和多个第二描述组得到多个第三描述组,第三数据中包括第一子分区的分区信息和第二子分区的分区信息,多个第三描述组中包括与第一子分区对应的描述组,与第二子分区对应的描述组,和与第三子分区对应的描述组,第三子分区是动态分区中除第一子分区和第二子分区之外的子分区。重启电子设备,加载基础分区、第二静态分区和动态分区的数据,以运行第二操作系统,在加载动态分区的数据的过程中,读取多个第三描述组中地址项的值,基于多个第三描述组中地址项的值加载动态分区的数据。In a first aspect, the embodiment of the present application provides a method for upgrading an operating system, and the method can be applied to an electronic device. The electronic device includes a processor and a memory, the memory includes a basic partition, a first static partition, a second static partition, a dynamic partition and a user data partition, the dynamic partition includes first slot data and second slot data, and the dynamic partition includes multiple sub For a partition, the first slot data includes a plurality of first description groups corresponding to a plurality of sub-partitions, and the second slot data includes a plurality of second description groups corresponding to a plurality of sub-partitions. Loading the data of the basic partition, the first static partition and the dynamic partition to run the first operating system, during the process of loading the data of the dynamic partition, reading multiple first description groups, based on the address items in the multiple first description groups value to load data for dynamic partitions. Obtain the first upgrade installation package and the second upgrade installation package, the first upgrade installation package is used to upgrade the first sub-partition, the second upgrade installation package is used to upgrade the second sub-partition, the first sub-partition and the second sub-partition are dynamic The sub-partition of the partition, the first upgrade installation package includes first data (manifest), the first data includes partition information of the first sub-partition, the second upgrade installation package includes second data, and the second data includes the partition of the second sub-partition information. Multiple third description groups are obtained according to the third data and multiple second description groups, the third data includes the partition information of the first sub-partition and the partition information of the second sub-partition, and the multiple third description groups include information related to the first sub-partition. A description group corresponding to a sub-partition, a description group corresponding to a second sub-partition, and a description group corresponding to a third sub-partition, the third sub-partition is a dynamic partition other than the first sub-partition and the second sub-partition subpartition. Restart the electronic device, load the data of the basic partition, the second static partition and the dynamic partition to run the second operating system, and read the values of the address items in multiple third description groups during the process of loading the data of the dynamic partition, based on The values of the address items in the plurality of third description groups load the data of the dynamic partition.
综上,采用本申请实施例的方法,在获取到多个(如两个)升级安装包后,电子设备将多个升级安装包中解析出的manifest进行合并,得到包括动态分区所有需要升级的子分区(如第一子分区和第二子分区)的manifest。然后,在基于该合并后的manifest得到多个第三描述组的过程中,针对manifest的分区信息中不涉及的子分区(如第三子分区),也不会从第二插槽数据中将其删除。如此,不升级的子分区的描述组仍然保留在第二插槽数据中,后续运行第二操作系统时,则可以依据第二插槽数据加载到不升级的子分区的数据。从而不会出现加载不完全的情况,最终可实现成功加载动态分区。To sum up, using the method of the embodiment of the present application, after obtaining multiple (for example, two) upgrade installation packages, the electronic device merges the manifests parsed from the multiple upgrade installation packages to obtain all the updates including dynamic partitions that need to be upgraded. The manifest of the subpartitions (such as the first subpartition and the second subpartition). Then, in the process of obtaining multiple third description groups based on the merged manifest, sub-partitions (such as the third sub-partition) not involved in the partition information of the manifest will not be included in the second slot data its deleted. In this way, the description group of the sub-partition not to be upgraded still remains in the second slot data, and when the second operating system is run subsequently, the data of the sub-partition not to be upgraded can be loaded according to the second slot data. In this way, there will be no incomplete loading, and finally the dynamic partition can be successfully loaded.
在第一方面的一种可能的设计方式中,上述在获取第一升级安装包和第二升级安装包之后,还包括:将多个第二描述组写入目标文件中,在目标文件中删除与第三子分区对应的描述组,生成第一索引。In a possible design of the first aspect, after obtaining the first upgrade installation package and the second upgrade installation package, the above further includes: writing a plurality of second description groups into the target file, and deleting them in the target file A description group corresponding to the third sub-partition generates a first index.
也就是说,电子设备在创建第一索引时,会删除掉多个第二描述组中未升级的子分区对应的描述组,使得创建的第一索引可仅指示电子设备获取升级的子分区的升级数据。从而可以准确指示电子设备获取升级数据。That is to say, when the electronic device creates the first index, it will delete the description group corresponding to the non-upgraded sub-partition in the multiple second description groups, so that the created first index can only indicate that the electronic device obtains the updated sub-partition. Upgrade data. Therefore, the electronic device can be accurately instructed to obtain the upgrade data.
在第一方面的一种可能的设计方式中,上述目标文件位于基础分区。In a possible design manner of the first aspect, the above-mentioned target files are located in the basic partition.
在第一方面的一种可能的设计方式中,上述在加载基础分区、第一静态分区和动态分区的数据之后,还包括:获取第三升级安装包,第三升级安装包用于升级第四子分区,第四子分区是动态分区的子分区,第三升级安装包包括第三数据,第三数据包括第四子分区的分区信息。根据第三数据和多个第二描述组得到多个第三描述组,第三数据中还包括第四子分区的分区信息,第三子分区是动态分区中除第一子分区、第二子分区和第四子分区之外的子分区。In a possible design of the first aspect, after loading the data of the basic partition, the first static partition and the dynamic partition, the above further includes: obtaining the third upgrade installation package, the third upgrade installation package is used to upgrade the fourth The sub-partition, the fourth sub-partition is a sub-partition of the dynamic partition, the third upgrade installation package includes third data, and the third data includes partition information of the fourth sub-partition. Multiple third description groups are obtained according to the third data and multiple second description groups. The third data also includes the partition information of the fourth sub-partition. Partition and subpartitions other than the fourth subpartition.
也就是说,采用本实施例的方法,还可以是使用三个升级安装包来升级更多的子分区。应理解,还可以使用四个升级安装包、五个升级安装包等来灵活实现各种组合升级的需求。本申请实施例对此不作具体限定。That is to say, using the method of this embodiment, it is also possible to use three upgrade installation packages to upgrade more sub-partitions. It should be understood that four upgrade installation packages, five upgrade installation packages, etc. can also be used to flexibly meet various combined upgrade requirements. This embodiment of the present application does not specifically limit it.
在第一方面的一种可能的设计方式中,第一升级安装包包括第一升级数据,第一升级数据用于升级第一子分区,第二升级安装包包括第二升级数据,第二升级数据用于升级第二子分区。上述方法还包括:在用户数据分区中保存第一升级数据和第二升级数据。在加载动态分区的数据的过程中,读取目标文件,基于目标文件中的第一索引加载用户数据分区中的第一升级数据和第二升级数据。In a possible design of the first aspect, the first upgrade installation package includes first upgrade data, the first upgrade data is used to upgrade the first sub-partition, the second upgrade installation package includes second upgrade data, and the second upgrade The data is used to upgrade the second child partition. The above method further includes: saving the first upgrade data and the second upgrade data in the user data partition. During the process of loading the data of the dynamic partition, the target file is read, and the first upgrade data and the second upgrade data in the user data partition are loaded based on the first index in the target file.
也就是说,采用本实施例的方法,在多个升级安装包组合升级的场景中,电子设备通过依次遍历多个升级安装包的方式,来实现将各个升级安装包中的升级数据写入到用户数据分区中。而不只是针对一个升级安装包保存数据,可以避免遗漏,实现各种组合的完全升级。然后,在加载动态分区时,需要从用户数据分区中获取所有的升级数据,从而实现动态分区的完全加载。That is to say, using the method of this embodiment, in the scenario where multiple upgrade installation packages are combined and upgraded, the electronic device implements writing the upgrade data in each upgrade installation package into the in the user data partition. Rather than just saving data for one upgrade installation package, omissions can be avoided and complete upgrades of various combinations can be realized. Then, when loading the dynamic partition, it is necessary to obtain all the upgrade data from the user data partition, so as to realize the full loading of the dynamic partition.
在第一方面的一种可能的设计方式中,上述在目标文件中删除与第二子分区对应的描述组,生成第一索引,包括:在目标文件中删除与第三子分区对应的描述组,得到与第一子分区对应的描述组和与第二子分区对应的描述组,与第一分区对应的描述组中包括第一子分区的名称,与第二子分区对应的描述组中包括第二子分区的名称。基于第一子分区的名称生成与第一子分区对应的第一文件名,基于第二子分区的名称生成与第二子分区对应的第二文件名,第一索引包括第一文件名和第二文件名。In a possible design of the first aspect, the above-mentioned deletion of the description group corresponding to the second sub-partition in the target file and generating the first index includes: deleting the description group corresponding to the third sub-partition in the target file , get the description group corresponding to the first sub-partition and the description group corresponding to the second sub-partition, the description group corresponding to the first sub-partition includes the name of the first sub-partition, and the description group corresponding to the second sub-partition includes The name of the second subpartition. The first file name corresponding to the first sub-partition is generated based on the name of the first sub-partition, and the second file name corresponding to the second sub-partition is generated based on the name of the second sub-partition. The first index includes the first file name and the second file name.
也就是说,采用本实施例的方法,电子设备可以生成包括第一文件名和第二文件名的第一索引,从而可以准确指示电子设备在加载动态分区时需要查找的升级数据所在的文件。That is to say, by using the method of this embodiment, the electronic device can generate the first index including the first file name and the second file name, so as to accurately indicate the file where the electronic device needs to find the upgrade data when loading the dynamic partition.
在第一方面的另一种可能的设计方式中,上述在基于第一子分区的名称生成与第一子分区对应的第一文件名,基于第二子分区的名称生成与第二子分区对应的第二文件名之后,还包括:在用户数据分区中创建文件名为第一文件名的第一初始cow文件,以及创建文件名为第二文件名的第二初始cow文件,第一初始cow文件和第二初始cow文件中未存储升级数据。上述在用户数据分区中保存第一升级数据和第二升级数据,包括:在第一初始cow文件中保存第一升级数据,在第二初始cow文件中保存第二升级数据。In another possible design of the first aspect, the first file name corresponding to the first sub-partition is generated based on the name of the first sub-partition, and the file name corresponding to the second sub-partition is generated based on the name of the second sub-partition. After the second file name, it also includes: creating a first initial cow file with the first file name in the user data partition, and creating a second initial cow file with the second file name, the first initial cow No upgrade data is stored in the file and the second initial cow file. The aforementioned saving of the first upgrade data and the second upgrade data in the user data partition includes: saving the first upgrade data in the first initial cow file, and saving the second upgrade data in the second initial cow file.
也就是说,采用本实施例的方法,电子设备可以在用户数据分区中创建与第一索引中的文件名一致的初始cow文件,并在该初始cow文件中保存升级数据。后续,电子设备在读取升级数据时,可以通过检索文件名准确的获取到升级数据。That is to say, by using the method of this embodiment, the electronic device can create an initial cow file in the user data partition that is consistent with the file name in the first index, and save the upgrade data in the initial cow file. Subsequently, when the electronic device reads the upgrade data, it can accurately obtain the upgrade data by retrieving the file name.
在第一方面的另一种可能的设计方式中,上述第二静态分区包括多个子分区,第一升级安装包还包括第三升级数据,第三升级数据用于升级第五子分区,第二升级安装包还包括第四升级数据,第四升级数据用于升级第六子分区,第五子分区和第六子分区是第二静态分区的子分区。上述在获取第一升级安装包和第二升级安装包后,还包括:将第三升级数据写入第五子分区,将第四升级数据写入第六子分区。In another possible design of the first aspect, the second static partition includes a plurality of sub-partitions, the first upgrade installation package further includes third upgrade data, the third upgrade data is used to upgrade the fifth sub-partition, and the second The upgrade installation package also includes fourth upgrade data, the fourth upgrade data is used to upgrade the sixth sub-partition, and the fifth sub-partition and the sixth sub-partition are sub-partitions of the second static partition. After obtaining the first upgrade installation package and the second upgrade installation package, the above method further includes: writing the third upgrade data into the fifth sub-partition, and writing the fourth upgrade data into the sixth sub-partition.
也就是说,采用本实施例的方法,电子设备可以对动态分区和静态分区的部分子分区升级。从而灵活满足各种部分升级的需求。That is to say, by using the method of this embodiment, the electronic device can upgrade the dynamic partition and some sub-partitions of the static partition. In order to flexibly meet the needs of various partial upgrades.
在第一方面的另一种可能的设计方式中,第一静态分区包括多个子分区,第一静态分区的多个子分区与第二静态分区的多个子分区一一对应。在将第三升级数据写入第五子分区,将第四升级数据写入第六子分区之前,方法还包括:若第二静态分区包括第七子分区,检测第五子分区和第六子分区中是否包括预设子分区,第七子分区是第二静态分区中除第五子分区和第六子分区之外的子分区。若第五子分区和第六子分区中包括预设子分区,将第一静态分区的第七子分区的数据同步至第二静态分区的第七子分区中。In another possible design manner of the first aspect, the first static partition includes multiple sub-partitions, and the multiple sub-partitions of the first static partition correspond one-to-one to the multiple sub-partitions of the second static partition. Before writing the third upgrade data into the fifth sub-partition and writing the fourth upgrade data into the sixth sub-partition, the method further includes: if the second static partition includes the seventh sub-partition, detecting the fifth sub-partition and the sixth sub-partition Whether the partition includes a preset sub-partition, and the seventh sub-partition is a sub-partition other than the fifth sub-partition and the sixth sub-partition in the second static partition. If the fifth sub-partition and the sixth sub-partition include the preset sub-partition, the data of the seventh sub-partition of the first static partition is synchronized to the seventh sub-partition of the second static partition.
也就是说,在此次需要升级的数据为大量数据的情况下,电子设备可以仅将第一静态分区中无需升级的子分区(即第七子分区)的数据同步给第二静态分区,以保证第二静态分区中无需升级的子分区(即第七子分区)的数据是最新的。从而可以通过小部分数据的同步而实现当前无需升级的子分区数据的同步。That is to say, when the data that needs to be upgraded this time is a large amount of data, the electronic device can only synchronize the data of the sub-partition (ie, the seventh sub-partition) that does not need to be upgraded in the first static partition to the second static partition, so as to It is ensured that the data of the sub-partition that does not need to be upgraded (that is, the seventh sub-partition) in the second static partition is up-to-date. Therefore, the synchronization of sub-partition data that does not need to be upgraded currently can be realized through the synchronization of a small part of data.
若第五子分区和第六子分区中不包括预设子分区,将第一静态分区中所有子分区的数据同步至第二静态分区的对应子分区中。If the fifth sub-partition and the sixth sub-partition do not include the preset sub-partition, the data of all sub-partitions in the first static partition are synchronized to the corresponding sub-partitions of the second static partition.
如此,在大部分数据无需升级时,设备无需从第一静态分区去剔除不需要同步的数据,而可以通过全部同步来简化同步的步骤。In this way, when most of the data does not need to be updated, the device does not need to remove data that does not need to be synchronized from the first static partition, but can simplify the steps of synchronization by synchronizing all.
也就是说,采用本实施例的方法,在更新第二静态分区中的数据之前,可以先使无需升级的子分区的最新数据,在第一静态分区和第二静态分区之间保持同步。然后对第二静态分区进行数据更新。如此,可以保证第二静态分区中各个子分区的数据都是最新的。That is to say, using the method of this embodiment, before updating the data in the second static partition, the latest data of sub-partitions that do not need to be upgraded can be synchronized between the first static partition and the second static partition. Then perform data update on the second static partition. In this way, it can be guaranteed that the data of each sub-partition in the second static partition is up-to-date.
在第一方面的另一种可能的设计方式中,上述将第三升级数据写入第五子分区,将第四升级数据写入第六子分区,包括:若第二静态分区不包括第七子分区,将第三升级数据写入第五子分区,将第四升级数据写入第六子分区。也就是说,采用本实施例的方法,若静态分区中的所有数据均需要更新,则可以直接进行数据更新,而无需同步。从而可以节省系统升级的操作。In another possible design of the first aspect, writing the third upgrade data into the fifth sub-partition and writing the fourth upgrade data into the sixth sub-partition includes: if the second static partition does not include the seventh For the sub-partition, the third upgrade data is written into the fifth sub-partition, and the fourth upgrade data is written into the sixth sub-partition. That is to say, with the method of this embodiment, if all the data in the static partition needs to be updated, the data can be updated directly without synchronization. Thereby, the operation of system upgrade can be saved.
在第一方面的另一种可能的设计方式中,上述在用户数据分区中保存第一升级数据和第二升级数据,包括:遍历第一升级安装包和第二升级安装包,遍历到第一升级安装包时,在用户数据分区中保存第一升级数据,遍历到第二升级安装包时,在用户数据分区中保存第二升级数据。上述方法还包括:记录当前遍历到的升级安装包包括的升级数据的保存进度,以及记录当前遍历的升级安装包的遍历序数。计算保存进度和遍历序数对应的更新进度,显示更新进度。In another possible design of the first aspect, the above-mentioned storing the first upgrade data and the second upgrade data in the user data partition includes: traversing the first upgrade installation package and the second upgrade installation package, traversing to the first When upgrading the installation package, save the first upgrade data in the user data partition, and save the second upgrade data in the user data partition when traversing to the second upgrade installation package. The above method further includes: recording the progress of saving the upgrade data included in the currently traversed upgrade installation package, and recording the traverse sequence number of the currently traversed upgrade installation package. Calculate the update progress corresponding to the save progress and the traversal sequence number, and display the update progress.
也就是说,采用本实施例的方法,电子设备通过记录保存进度和遍历序数,可以计算得到实时的更新进度并显示。That is to say, by using the method of this embodiment, the electronic device can calculate and display the real-time update progress by recording the saving progress and the traversal sequence number.
在第一方面的另一种可能的设计方式中,上述在用户数据分区中保存第一升级数据和第二升级数据的过程中,还包括:若电子设备掉电重启,在第一升级安装包和第二升级安装包中定位遍历序数对应的目标升级安装包,以及在目标升级安装包的升级数据中定位写入进度对应的目标数据。从目标升级安装包的目标数据开始,在用户数据分区中继续保存第一升级数据和第二升级数据。In another possible design of the first aspect, the above process of saving the first upgrade data and the second upgrade data in the user data partition further includes: if the electronic device is powered off and restarted, the first upgrade installation package Locating the target upgrade installation package corresponding to the traversal sequence number in the second upgrade installation package, and locating the target data corresponding to the write progress in the upgrade data of the target upgrade installation package. Starting from the target data of the target upgrade installation package, the first upgrade data and the second upgrade data are continuously stored in the user data partition.
也就是说,采用本实施例的方法,针对数据更新过程中掉电重启的异常情况,电子设备可以准确的从掉电时更新到的位置处继续保存数据。That is to say, by adopting the method of this embodiment, the electronic device can continue to save the data accurately from the position where it was updated when the power was turned off, for the abnormal situation of restarting after power failure during the data updating process.
在第一方面的另一种可能的设计方式中,在根据第三数据和多个第二描述组得到多个第三描述组之前,还包括:合并第一数据和第二数据,得到第三数据。In another possible design of the first aspect, before obtaining the multiple third description groups according to the third data and the multiple second description groups, it further includes: combining the first data and the second data to obtain the third data.
也就是说,采用本实施例的方法,可以通过合并多个升级安装包中的manifest,得到包括动态分区中所有需要升级的子分区的分区信息的manifest。从而便于后续据此合并后的manifest来完成升级。That is to say, by adopting the method of this embodiment, a manifest including partition information of all sub-partitions to be upgraded in a dynamic partition can be obtained by merging manifests in multiple upgrade installation packages. This facilitates subsequent upgrades based on the merged manifest.
在第一方面的另一种可能的设计方式中,上述在加载基础分区、第二静态分区和动态分区的数据之后,还包括:将用户数据分区中的多个第一升级数据和第二升级数据落盘到动态分区的对应子分区中。In another possible design of the first aspect, after loading the data of the basic partition, the second static partition, and the dynamic partition, the above further includes: storing multiple first upgrade data and second upgrade data in the user data partition The data is moved to the corresponding subpartition of the dynamic partition.
也就是说,采用本实施例的方法,通过落盘操作,使得动态分区的文件完成数据升级,以便设备在下次启动时不需要加载动态分区和虚拟动态分区,只需加载动态分区就可以完成设备启动。That is to say, by adopting the method of this embodiment, the file of the dynamic partition can be upgraded through the disk operation, so that the device does not need to load the dynamic partition and the virtual dynamic partition when the device is started next time, and only needs to load the dynamic partition to complete the device. start up.
在第一方面的另一种可能的设计方式中,上述第一子分区、第二子分区、第三子分区……都可以包括一个或多个子分区。从而可以灵活实现各种子分区的组合升级。In another possible design manner of the first aspect, the first sub-partition, the second sub-partition, the third sub-partition, ... may all include one or more sub-partitions. In this way, combined upgrades of various sub-partitions can be flexibly realized.
第二方面,本申请实施例还提供一种电子设备,所述电子设备包括处理器以及存储器,所述存储器包括基础分区、第一静态分区、第二静态分区、动态分区以及用户数据分区,所述动态分区包括多个子分区,所述处理器用于执行所述存储器上存储的软件代码,以使得所述电子设备执行上述第一方面及其任一种可能的设计方式的方法。In the second aspect, the embodiment of the present application further provides an electronic device, the electronic device includes a processor and a memory, and the memory includes a basic partition, a first static partition, a second static partition, a dynamic partition, and a user data partition. The dynamic partition includes a plurality of sub-partitions, and the processor is configured to execute software codes stored in the memory, so that the electronic device executes the method of the above-mentioned first aspect and any possible design manner thereof.
第三方面,本申请实施例提供一种芯片系统,该芯片系统应用于包括显示屏和存储器的电子设备;所述芯片系统包括一个或多个接口电路和一个或多个处理器;所述接口电路和所述处理器通过线路互联;所述接口电路用于从所述电子设备的存储器接收信号,并向所述处理器发送所述信号,所述信号包括所述存储器中存储的计算机指令;当所述处理器执行所述计算机指令时,所述电子设备执行如第一方面及其任一种可能的设计方式所述的方法。In a third aspect, an embodiment of the present application provides a chip system, which is applied to an electronic device including a display screen and a memory; the chip system includes one or more interface circuits and one or more processors; the interface The circuit and the processor are interconnected by a line; the interface circuit is configured to receive a signal from a memory of the electronic device and send the signal to the processor, the signal including computer instructions stored in the memory; When the processor executes the computer instruction, the electronic device executes the method described in the first aspect and any possible design manner thereof.
第四方面,本申请实施例还提供一种计算机存储介质,该计算机存储介质包括计算机指令,当所述计算机指令在电子设备上运行时,使得电子设备执行如第一方面及其任一种可能的设计方式所述的方法。In the fourth aspect, the embodiment of the present application further provides a computer storage medium, the computer storage medium includes computer instructions, and when the computer instructions are run on the electronic device, the electronic device is executed as described in the first aspect and any possibility thereof. The method described in the design method.
第五方面,本申请提供一种计算机程序产品,当所述计算机程序产品在计算机上运行时,使得所述计算机执行如第一方面及其任一种可能的设计方式所述的方法。In a fifth aspect, the present application provides a computer program product. When the computer program product runs on a computer, the computer executes the method described in the first aspect and any possible design manner thereof.
可以理解地,上述提供的第二方面所述的电子设备,第三方面所述的芯片系统,第四方面所述的计算机存储介质,第五方面所述的计算机程序产品所能达到的有益效果,可参考第一方面及其任一种可能的设计方式中的有益效果,此处不再赘述。It can be understood that the beneficial effects that can be achieved by the electronic device described in the second aspect, the chip system described in the third aspect, the computer storage medium described in the fourth aspect, and the computer program product described in the fifth aspect provided above , reference may be made to the beneficial effects of the first aspect and any possible design manner thereof, and details are not repeated here.
附图说明Description of drawings
为了更清楚地说明本申请实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其它的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the accompanying drawings that need to be used in the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present application. Those of ordinary skill in the art can also obtain other drawings based on these drawings without paying creative labor.
图1所示为根据本申请一实施例的数据存储结构示意图;FIG. 1 is a schematic diagram of a data storage structure according to an embodiment of the present application;
图2所示为根据本申请一实施例的操作系统升级的流程图;FIG. 2 is a flowchart of an operating system upgrade according to an embodiment of the present application;
图3所示为根据本申请一实施例的数据存储结构示意图;FIG. 3 is a schematic diagram of a data storage structure according to an embodiment of the present application;
图4所示为根据本申请一实施例的部分卡槽数据示意图;FIG. 4 is a schematic diagram of part of card slot data according to an embodiment of the present application;
图5A所示为根据本申请一实施例的操作系统升级的流程图;FIG. 5A is a flow chart showing an operating system upgrade according to an embodiment of the present application;
图5B所示为根据本申请一实施例的调整卡槽数据的示意图;FIG. 5B is a schematic diagram of adjusting card slot data according to an embodiment of the present application;
图6所示为根据本申请一实施例的数据存储结构示意图;FIG. 6 is a schematic diagram of a data storage structure according to an embodiment of the present application;
图7所示为根据本申请一实施例的数据存储结构中组件划分的示意图;FIG. 7 is a schematic diagram of component division in a data storage structure according to an embodiment of the present application;
图8所示为根据本申请一实施例的独立组件升级的示意图;FIG. 8 is a schematic diagram of upgrading an independent component according to an embodiment of the present application;
图9所示为根据本申请一实施例的操作系统升级的流程图;FIG. 9 is a flowchart of an operating system upgrade according to an embodiment of the present application;
图10所示为根据本申请一实施例的manifest的合并过程示意图;FIG. 10 is a schematic diagram of the merging process of manifests according to an embodiment of the present application;
图11所示为根据本申请一实施例的调整卡槽数据的示意图;FIG. 11 is a schematic diagram of adjusting card slot data according to an embodiment of the present application;
图12所示为根据本申请一实施例的操作系统升级的流程图;FIG. 12 is a flow chart showing an operating system upgrade according to an embodiment of the present application;
图13所示为根据本申请一实施例的创建索引的示意图;FIG. 13 is a schematic diagram of creating an index according to an embodiment of the present application;
图14所示为根据本申请一实施例的操作系统升级的流程图;FIG. 14 is a flow chart showing an operating system upgrade according to an embodiment of the present application;
图15所示为根据本申请一实施例的数据更新的示意图;FIG. 15 is a schematic diagram of data update according to an embodiment of the present application;
图16所示为根据本申请一实施例的操作系统升级的流程图;FIG. 16 is a flow chart showing an operating system upgrade according to an embodiment of the present application;
图17所示为根据本申请一实施例的操作系统升级的流程图;FIG. 17 is a flowchart of an operating system upgrade according to an embodiment of the present application;
图18所示为根据本申请一实施例的掉电后数据更新的示意图;FIG. 18 is a schematic diagram of data update after power failure according to an embodiment of the present application;
图19所示为根据本申请一实施例的操作系统升级的流程图;FIG. 19 is a flow chart showing an operating system upgrade according to an embodiment of the present application;
图20所示为根据本申请一实施例的芯片系统的结构示意图。FIG. 20 is a schematic structural diagram of a chip system according to an embodiment of the present application.
具体实施方式Detailed ways
应当明确,本文所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其它实施例,都属于本申请保护的范围。It should be clear that the embodiments described herein are only some of the embodiments of the application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by persons of ordinary skill in the art without creative efforts fall within the protection scope of this application.
为了更好的理解本申请的技术方案,下面结合附图对本申请实施例进行详细描述。In order to better understand the technical solutions of the present application, the embodiments of the present application will be described in detail below in conjunction with the accompanying drawings.
在终端设备(简称设备)出厂前,将操作系统烧录到设备中,从而实现在设备出厂前安装操作系统。此后,为了提升用户体验,可能需要对设备中的操作系统进行升级。此时,可采用空中下载技术(Over-the-Air Technology,OTA)来完成升级。其中,OTA是通过设备的无线网络接口实现对设备的操作系统进行远程版本更新的技术,实现远程升级设备中操作系统的目的。Before the terminal device (referred to as the device) leaves the factory, the operating system is burned into the device, so as to realize the installation of the operating system before the device leaves the factory. Thereafter, in order to improve user experience, it may be necessary to upgrade the operating system in the device. At this point, an Over-the-Air Technology (OTA) can be used to complete the upgrade. Among them, OTA is a technology for remotely updating the operating system of the device through the wireless network interface of the device, so as to realize the purpose of remotely upgrading the operating system in the device.
需要说明的是,本申请实施例的设备包括但不限于可以安装操作系统的智能手机、智能耳机、平板电脑、智能冰箱、智能音箱等。设备也可以是设备内部可以安装操作系统的控制板。操作系统的示例性实施例包括但不限于
Figure PCTCN2022140016-appb-000001
Figure PCTCN2022140016-appb-000002
Linux或者其它操作系统。
It should be noted that the devices in this embodiment of the present application include, but are not limited to, smart phones, smart earphones, tablet computers, smart refrigerators, smart speakers, etc. on which an operating system can be installed. The device may also be a control panel on which an operating system can be installed inside the device. Exemplary embodiments of operating systems include, but are not limited to
Figure PCTCN2022140016-appb-000001
Figure PCTCN2022140016-appb-000002
Linux or other operating systems.
在采用OTA升级操作系统时,为了可以在设备正常运行时进行无感知升级,以及提升数据存储空间的利用率,可以采用虚拟A/B升级方案来完成操作系统的升级。When using OTA to upgrade the operating system, in order to perform non-perceived upgrades when the device is running normally and improve the utilization of data storage space, a virtual A/B upgrade solution can be used to complete the upgrade of the operating system.
以安卓系统为例,虚拟A/B升级方案可以适用于具有图1所示的数据存储结构的操作系统的升级。如图1所示,安卓系统数据存储区包含基础分区(Common)、静态分区(A)、静态分区(B)、动态分区(Super)、用户数据分区(Userdata)。下面对各个分区进行介绍:用户数据分区(Userdata)用于保存用户的个人数据,例如,用户个人安装的APP、用户个人保存的图片、文档以及视频等个人数据。基础分区 (Common)用于保存系统数据,基础分区中保存的数据不参与操作系统升级。静态分区(A)与静态分区(B)的结构相互对应,静态分区(A)与静态分区(B)可以包括多个子分区,静态分区(A)与静态分区(B)对应的子分区命名通过后缀_a以及_b相互区分。例如,静态分区(A)包括bootloader_a、boot_a、vendor_boot_a、dtbo_a、vbmeta_a;静态分区(B)包括bootloader_b、boot_b、vendor_boot_b、dtbo_b、vbmeta_b。动态分区(Super)可以包含多个子分区,如System、system_ext、vendor、product、Cust、Odm。为了方便说明,可以将静态分区(A)称为第一静态分区,将静态分区(B)称为第二静态分区。Taking the Android system as an example, the virtual A/B upgrade solution can be applied to the upgrade of the operating system with the data storage structure shown in FIG. 1 . As shown in Figure 1, the Android system data storage area includes a basic partition (Common), a static partition (A), a static partition (B), a dynamic partition (Super), and a user data partition (Userdata). Each partition is introduced as follows: the user data partition (Userdata) is used to save the user's personal data, for example, the APP installed by the user personally, the pictures, documents and videos saved by the user personally, and other personal data. The basic partition (Common) is used to save system data, and the data saved in the basic partition does not participate in the operating system upgrade. The structure of the static partition (A) and the static partition (B) correspond to each other. The static partition (A) and the static partition (B) can include multiple sub-partitions. The sub-partitions corresponding to the static partition (A) and the static partition (B) are named by The suffixes _a and _b distinguish each other. For example, static partition (A) includes bootloader_a, boot_a, vendor_boot_a, dtbo_a, vbmeta_a; static partition (B) includes bootloader_b, boot_b, vendor_boot_b, dtbo_b, vbmeta_b. A dynamic partition (Super) can contain multiple subpartitions, such as System, system_ext, vendor, product, Cust, Odm. For convenience of description, the static partition (A) may be called the first static partition, and the static partition (B) may be called the second static partition.
在设备启动时,从一个静态分区启动,即通过加载该静态分区以启动操作系统。例如,设备从静态分区(A)启动,则需要依次加载基础分区(Common)、静态分区(A)以及动态分区(Super);设备从静态分区(B)启动,则需要依次加载基础分区(Common)、静态分区(B)以及动态分区(Super)。When the device is started, it starts from a static partition, that is, the operating system is started by loading the static partition. For example, if the device starts from the static partition (A), it needs to load the basic partition (Common), static partition (A) and dynamic partition (Super) in sequence; when the device starts from the static partition (B), it needs to load the basic partition (Common ), static partition (B) and dynamic partition (Super).
以采用主引导记录(Master Boot Record,MBR)格式的通用闪存(Universal Flash Storage,UFS)为例。在UFS的MBR(主引导扇区,UFS的第一个扇区,即C/H/S地址的0柱面0磁头1扇区)中,保存有设备启动顺序描述。设备启动顺序描述可以用于指示从静态分区(A)启动(启动顺序标志为A)或从静态分区(B)启动(启动顺序标志为A)。设备启动后首先从UFS的MBR中读取设备启动顺序描述,从而根据设备启动顺序描述确定需要从静态分区(A)还是静态分区(B)启动。MBR通常记录在基础分区(Common)中。当然,在不同平台中,MBR也可以记录在不同的位置,本申请实施例对此不作具体限定。Take Universal Flash Storage (UFS) in Master Boot Record (MBR) format as an example. In the MBR of UFS (master boot sector, the first sector of UFS, that is, the 0 cylinder 0 head 1 sector of the C/H/S address), the device startup sequence description is stored. The device boot sequence description can be used to indicate booting from the static partition (A) (the boot sequence mark is A) or from the static partition (B) (the boot sequence mark is A). After the device is started, first read the device boot sequence description from the MBR of the UFS, so as to determine whether to start from the static partition (A) or the static partition (B) according to the device startup sequence description. MBR is usually recorded in the base partition (Common). Certainly, on different platforms, the MBR may also be recorded in different locations, which is not specifically limited in this embodiment of the present application.
图2所示为针对具有图1所示的数据存储结构的操作系统进行操作系统升级的流程图,假设设备当前是从静态分区(A)启动,设备按照如图2所示虚拟A/B升级方案的流程实现操作系统的升级。Figure 2 is a flow chart of upgrading the operating system for the operating system with the data storage structure shown in Figure 1, assuming that the device is currently booted from the static partition (A), and the device is upgraded according to the virtual A/B shown in Figure 2 The process of the program implements the upgrade of the operating system.
S200,设备依次加载基础分区(Common)、静态分区(A)以及动态分区(Super),从静态分区(A)启动。S200, the device loads the basic partition (Common), the static partition (A) and the dynamic partition (Super) in sequence, and starts from the static partition (A).
S210,设备获取操作系统升级安装包。S210, the device acquires an operating system upgrade installation package.
示例性的,在一种可行的实现方案中,设备定期向搜包服务器发起搜包请求,搜包请求包含设备当前运行的操作系统的版本号(例如版本1.1)。搜包服务器根据搜包请求中的操作系统版本号,检索当前是否存在更新版本号的操作系统安装包(例如版本1.2的操作系统安装包)。当存在更新版本的操作系统安装包时,搜包服务器向设备反馈操作系统升级安装包(例如,由版本1.1升级到版本1.2的系统增量升级安装包)的下载地址。设备根据操作系统升级安装包的下载地址下载操作系统升级安装包。Exemplarily, in a feasible implementation solution, the device periodically initiates a packet search request to the packet search server, and the packet search request includes the version number (for example, version 1.1) of the operating system currently running on the device. The package search server retrieves whether there is an operating system installation package with a newer version number (for example, an operating system installation package of 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 operating system installation package, the package search server feeds back the download address of the operating system upgrade installation package (for example, the system incremental upgrade installation package upgraded from version 1.1 to version 1.2) to the device. The device downloads the OS upgrade installation package according to the download address of the OS upgrade installation package.
S220,设备根据操作系统升级安装包针对静态分区(B)进行数据写入操作以升级静态分区(B)。S220. The device performs a data writing operation on the static partition (B) according to the operating system upgrade installation package to upgrade the static partition (B).
例如,版本1.1升级到版本1.2的系统增量升级安装包包含版本1.2的静态分区的全量数据,设备将版本1.2的静态分区的数据覆写到静态分区(B)中。For example, the system incremental upgrade installation package from version 1.1 to version 1.2 contains the full data of the static partition of version 1.2, and the device overwrites the data of the static partition of version 1.2 into the static partition (B).
S230,设备根据操作系统升级安装包在用户数据分区(Userdata)创建虚拟动态分区,在虚拟动态分区写入动态分区(Super)的升级数据。S230. The device creates a virtual dynamic partition in the user data partition (Userdata) according to the operating system upgrade installation package, and writes upgrade data of the dynamic partition (Super) in the virtual dynamic partition.
例如,在操作系统升级安装包中包含版本1.2的动态分区(Super)的数据,设备 在虚拟动态分区中写入版本1.2的动态分区(Super)的数据。For example, the operating system upgrade installation package contains the data of the dynamic partition (Super) of version 1.2, and the device writes the data of the dynamic partition (Super) of version 1.2 in the virtual dynamic partition.
进一步的,在虚拟A/B升级方案中,针对动态分区(Super),采用增量升级方式。在升级过程中,用户数据分区(Userdata)的虚拟动态分区中保存的并不是升级后新版本的动态分区(Super)的全部文件,而是旧版本的动态分区(Super)中需要升级的数据在升级后的升级结果。Further, in the virtual A/B upgrade solution, an incremental upgrade method is adopted for the dynamic partition (Super). During the upgrade process, the virtual dynamic partition of the user data partition (Userdata) does not save all the files of the new version of the dynamic partition (Super) after the upgrade, but the data that needs to be upgraded in the old version of the dynamic partition (Super). The result of the upgrade after the upgrade.
以System子分区为例,假设在版本1.1中,System子分区中的数据可以分为数据system1、数据system2。从版本1.1升级到版本1.2,数据system2没有发生变化,数据syetem1被升级为数据system3。那么,在S230中,设备在用户数据分区(Userdata)创建虚拟动态分区,在虚拟动态分区中写入数据system3。例如,版本1.1升级到版本1.2的系统增量升级安装包包含版本1.1升级到版本1.2的动态分区(Super)更新数据,该动态分区(Super)更新数据包含数据system3。Taking the System subpartition as an example, assume that in version 1.1, the data in the System subpartition can be divided into data system1 and data system2. From version 1.1 to version 1.2, the data system2 has not changed, and the data syetem1 has been upgraded to the data system3. Then, in S230, the device creates a virtual dynamic partition in the user data partition (Userdata), and writes data system3 in the virtual dynamic partition. For example, the system incremental upgrade installation package from version 1.1 to version 1.2 includes dynamic partition (Super) update data from version 1.1 to version 1.2, and the dynamic partition (Super) update data includes data system3.
进一步的,在虚拟A/B升级方案中,基于快照技术(snapshot)实现动态分区(Super)的增量升级。具体的,用户数据分区(Userdata)的虚拟动态分区中,采用写时拷贝(Copy-On-Write,cow)文件保存动态分区(Super)的升级数据。Further, in the virtual A/B upgrade scheme, the incremental upgrade of the dynamic partition (Super) is realized based on the snapshot technology (snapshot). Specifically, in the virtual dynamic partition of the user data partition (Userdata), a copy-on-write (Copy-On-Write, cow) file is used to save the upgrade data of the dynamic partition (Super).
具体的,用户数据分区(Userdata)中保存的动态分区(Super)的升级数据包含多个cow文件,每个cow文件对应一个动态分区(Super)的子分区。在操作系统升级安装包中,动态分区(Super)的升级数据的cow文件以二进制代码形式压缩保存,每个cow文件根据其所对应的动态分区(Super)的子分区所命名。例如,针对system子分区的cow文件被命名为system-cow-img.img.0000。Specifically, the upgrade data of the dynamic partition (Super) stored in the user data partition (Userdata) includes multiple cow files, and each cow file corresponds to a sub-partition of the dynamic partition (Super). In the operating system upgrade installation package, the cow file of the upgrade data of the dynamic partition (Super) is compressed and stored in the form of binary code, and each cow file is named according to the sub-partition of the corresponding dynamic partition (Super). For example, the cow file for the system subpartition is named system-cow-img.img.0000.
进一步的,设备获取操作系统升级安装包,解包操作系统升级安装包以获取所有的cow文件后,为每个cow文件附加A/B分区标记。并进一步的,在用户数据分区(Userdata)中创建Update文件夹,将cow文件保存到Update文件夹下。Further, the device obtains the operating system upgrade installation package, unpacks the operating system upgrade installation package to obtain all cow files, and appends an A/B partition mark to each cow file. And further, create an Update folder in the user data partition (Userdata), and save the cow file to the Update folder.
比如,当设备当前从静态分区(A)启动时,可以理解为设备当前运行操作系统所加载的动态分区(Super)为动态分区(A)。在升级操作系统时,用户数据分区(Userdata)中创建的虚拟动态分区是针对动态分区(B)。因此,在S230中,设备获取操作系统升级安装包,解包操作系统升级安装包以获取所有的cow文件后,为cow文件附加对应动态分区(B)的名称标记_b。例如,为system-cow-img.img.0000附加_b生成system_b-cow-img.img.0000。进一步的,在用户数据分区(Userdata)中创建Update文件夹,将cow文件保存到Update文件夹下。例如,在一应用场景中,在向用户数据分区(Userdata)写入cow文件后,用户数据分区(Userdata)的Update文件夹中包含下述文件:For example, when the device is currently started from the static partition (A), it can be understood that the dynamic partition (Super) loaded by the operating system currently running on the device is the dynamic partition (A). When upgrading the operating system, the virtual dynamic partition created in the user data partition (Userdata) is for the dynamic partition (B). Therefore, in S230, the device obtains the operating system upgrade installation package, unpacks the operating system upgrade installation package to obtain all cow files, and attaches the name mark _b corresponding to the dynamic partition (B) to the cow files. For example, append_b for system-cow-img.img.0000 generates system_b-cow-img.img.0000. Further, an Update folder is created in the user data partition (Userdata), and the cow file is saved in the Update folder. For example, in an application scenario, after writing a cow file to the user data partition (Userdata), the Update folder of the user data partition (Userdata) contains the following files:
system_b-cow-img.img.0000;system_b-cow-img.img.0000;
system_ext_b-cow-img.img.0000;system_ext_b-cow-img.img.0000;
vendor_b-cow-img.img.0000;vendor_b-cow-img.img.0000;
product_b-cow-img.img.0000;product_b-cow-img.img.0000;
cust_b-cow-img.img.0000;cust_b-cow-img.img.0000;
odm_b-cow-img.img.0000。odm_b-cow-img.img.0000.
具体的,cow文件中包含cow文件自身的cow文件地图(快照map)以及升级数据。Specifically, the cow file includes a cow file map (snapshot map) of the cow file itself and upgrade data.
cow文件地图(快照)与cow文件所针对的动态分区(Super)的子分区的文件地图相对应。动态分区(Super)的子分区的文件地图用于描述当前版本的操作系统(本次升级之前的版本,例如,版本1.1)动态分区(Super)的子分区中的所有文件以及各个文件的保存地址。The cow file map (snapshot) corresponds to the file map of the subpartition of the dynamic partition (Super) targeted by the cow file. The file map of the sub-partition of the dynamic partition (Super) is used to describe all the files in the sub-partition of the dynamic partition (Super) and the storage address of each file in the current version of the operating system (the version before this upgrade, for example, version 1.1) .
cow文件中的升级数据为相较于当前版本的子分区数据,新版本的子分区数据中被更新的数据;cow文件自身的cow文件地图则用于描述被更新的文件与当前版本的子分区中的文件间的对应关系以及被更新的文件的保存地址。The upgrade data in the cow file is the updated data in the sub-partition data of the new version compared with the sub-partition data of the current version; the cow file map of the cow file itself is used to describe the updated file and the sub-partition of the current version The correspondence between the files in and the storage address of the updated files.
基于动态分区(Super)的子分区的文件地图以及cow文件中的cow文件地图,就可以使用cow文件中的升级数据替换动态分区(Super)的子分区中的对应文件,从而实现动态分区(Super)数据的升级。具体的,在需要获取动态分区(Super)的子分区的文件地图时,可以基于snapshot对动态分区(Super)的子分区的数据进行快照操作以生成动态分区(Super)的子分区的文件地图。也可以在制作操作系统升级安装包时,预先生成动态分区(Super)的子分区的文件地图,将该文件地图加入到cow文件中。Based on the file map of the sub-partition of the dynamic partition (Super) and the cow file map in the cow file, the upgrade data in the cow file can be used to replace the corresponding files in the sub-partition of the dynamic partition (Super), so as to realize the dynamic partition (Super) ) data upgrade. Specifically, when the file map of the sub-partition of the dynamic partition (Super) needs to be obtained, a snapshot operation may be performed on the data of the sub-partition of the dynamic partition (Super) based on the snapshot to generate the file map of the sub-partition of the dynamic partition (Super). It is also possible to pre-generate the file map of the sub-partition of the dynamic partition (Super) when making the operating system upgrade installation package, and add the file map to the cow file.
进一步的,在S230中,在将cow文件写入用户数据分区(Userdata)后,还需要对动态分区(Super)+cow文件进行整体校验,校验动态分区(Super)+cow文件的有效性,验证当前版本的动态分区(Super)数据+cow文件的合成结果是否为新版本的动态分区(Super)数据。若有效,则将基础分区(Common)的元数据分区(/metadata)中的落盘状态信息由“已落盘(merged)”改为“未落盘(wait for merge)”。落盘状态信息用于表示当前是否存在需要落盘到动态分区(Super)的cow文件。具体的,落盘状态信息包含针对动态分区(Super)的整体标识以及针对每个子分区的子分区标识。当整体标识为“已落盘(merged)”时,代表动态分区(Super)的所有子分区均不需要进行落盘操作;当整体标识为“未落盘(wait for merge)”时,代表动态分区(Super)的一个或多个子分区需要进行落盘操作;当子分区标识为“已落盘(merged)”时,代表该子分区不需要进行落盘操作;当子分区标识为“未落盘(wait for merge)”时,代表该子分区需要进行落盘操作。若无效,则升级失败,中断升级进程并报错。Further, in S230, after the cow file is written into the user data partition (Userdata), it is also necessary to perform an overall check on the dynamic partition (Super)+cow file to verify the validity of the dynamic partition (Super)+cow file , to verify whether the synthesis result of the current version of the dynamic partition (Super) data+cow file is the new version of the dynamic partition (Super) data. If it is valid, change the merge status information in the metadata partition (/metadata) of the basic partition (Common) from "merged" to "wait for merge". The flush status information is used to indicate whether there are currently cow files that need to be flushed to the dynamic partition (Super). Specifically, the disk placement status information includes an overall identifier for the dynamic partition (Super) and a sub-partition identifier for each sub-partition. When the overall flag is "merged", it means that all sub-partitions of the dynamic partition (Super) do not need to be merged; when the overall flag is "not merged (wait for merge)", it means dynamic One or more sub-partitions of a partition (Super) need to be merged; when the sub-partition is marked as "merged", it means that the sub-partition does not need to be merged; when the sub-partition is marked as "merged Disk (wait for merge)" means that the sub-partition needs to be moved to disk. If it is invalid, the upgrade will fail, the upgrade process will be interrupted and an error will be reported.
S231,将设备的启动顺序由从静态分区(A)启动变更为从静态分区(B)启动。S231. Change the boot sequence of the device from booting from the static partition (A) to booting from the static partition (B).
例如,改写主引导记录(Master Boot Record,MBR)的启动顺序标识,将启动顺序标识由A改写为B。在设备上电后,当设备读取到启动顺序标识为A,设备从静态分区(A)启动,启动过程中加载静态分区(A);当设备读取到启动顺序标识为B,设备从静态分区(B)启动,启动过程中加载静态分区(B)。For example, rewrite the boot sequence identifier of the Master Boot Record (MBR), and rewrite the boot sequence identifier from A to B. After the device is powered on, when the device reads the boot sequence ID as A, the device starts from the static partition (A), and loads the static partition (A) during startup; when the device reads the boot sequence ID as B, the device starts from the static partition (A). Partition (B) starts, and static partition (B) is loaded during startup.
S232,设备重启。退出当前的操作系统,切断设备电源,再次开启设备电源。S232, restarting the device. Exit the current operating system, cut off the power of the device, and turn on the power of the device again.
S240,设备依次加载基础分区(Common)、静态分区(B)。S240, the device sequentially loads the basic partition (Common) and the static partition (B).
S241,设备加载动态分区(Super)以及用户数据分区(Userdata)的虚拟动态分区。S241. The device loads the dynamic partition (Super) and the virtual dynamic partition of the user data partition (Userdata).
具体的,设备读取元数据(/metadata)中的落盘状态信息,基于落盘状态信息确定是否需要从用户数据分区(Userdata)的指定路径中检索cow文件,并采用snapshot合并加载动态分区(Super)以及从用户数据分区(Userdata)的指定路径检索到的cow文件。Specifically, the device reads the storage status information in the metadata (/metadata), determines whether to retrieve the cow file from the specified path of the user data partition (Userdata) based on the storage status information, and uses snapshot to merge and load the dynamic partition ( Super) and the cow file retrieved from the specified path of the user data partition (Userdata).
进一步的,在S241中,设备并不加载动态分区(Super)以及用户数据分区(Userdata)中的全部cow文件,而是根据操作系统运行需求加载对应的文件。具体的,在S241中,设备根据操作系统运行需求确定需要加载的文件,基于snapshot从动态分区(Super)或用户数据分区(Userdata)的虚拟动态分区中的cow文件中提取对应的文件进行加载。Further, in S241, the device does not load all the cow files in the dynamic partition (Super) and the user data partition (Userdata), but loads corresponding files according to operating requirements of the operating system. Specifically, in S241, the device determines the files to be loaded according to the operation requirements of the operating system, and extracts the corresponding files from the cow files in the virtual dynamic partition of the dynamic partition (Super) or user data partition (Userdata) based on the snapshot to load.
进一步的,在S241中,在加载文件之前,设备还需要对加载文件进行校验。不同于S230,在S241中,不对动态分区(Super)+cow文件进行整体验证,而是仅对需要加载的文件进行验证。例如,基于dmverity进行校验(dm-verity是dm(device mapper)的一个目标(target),是一个虚拟块设备,专门用于文件系统的校验)。校验成功则加载文件,校验失败则重启设备,回滚系统或者尝试再次加载文件。Further, in S241, before loading the file, the device needs to verify the loaded file. Different from S230, in S241, the dynamic partition (Super)+cow file is not verified as a whole, but only the files to be loaded are verified. For example, verify based on dmverity (dm-verity is a target of dm (device mapper), which is a virtual block device, specially used for file system verification). If the verification is successful, load the file; if the verification fails, restart the device, roll back the system or try to load the file again.
S250,设备成功启动,进入用户交互界面。S250, the device is successfully started and enters the user interaction interface.
S251,设备将虚拟动态分区的数据落盘到动态分区(Super)。S251. The device puts the data of the virtual dynamic partition to the dynamic partition (Super).
在本申请说明书的描述中,落盘操作指的是,在操作系统升级过程中,将用户数据分区(Userdata)上虚拟动态分区中保存的动态分区(Super)升级文件(cow文件)写入到动态分区(Super)中,使得动态分区(Super)的文件完成数据升级,以便设备在下次启动时不需要加载动态分区(Super)和虚拟动态分区,只需加载动态分区(Super)就可以完成设备启动。In the description of this application specification, the disk operation refers to writing the dynamic partition (Super) upgrade file (cow file) stored in the virtual dynamic partition on the user data partition (Userdata) to the In the dynamic partition (Super), the files of the dynamic partition (Super) are upgraded, so that the device does not need to load the dynamic partition (Super) and the virtual dynamic partition at the next startup, and only needs to load the dynamic partition (Super) to complete the device. start up.
具体的,设备在启动成功后进行开机广播,开机广播后开启升级进程。升级进程读取基础分区(Common)的元数据(/metadata)中的落盘状态信息,如果落盘状态信息为“已落盘(merged)”,则设备进入正常运行模式。Specifically, after the device is successfully started, it performs a power-on broadcast, and starts an upgrade process after the power-on broadcast. The upgrade process reads the migration status information in the metadata (/metadata) of the basic partition (Common). If the migration status information is "merged", the device enters the normal operation mode.
如果落盘状态信息为“未落盘(wait for merge)”,升级进程将用户数据分区(Userdata)中的cow文件落盘到动态分区(Super)中。If the transfer status information is "wait for merge", the upgrade process transfers the cow files in the user data partition (Userdata) to the dynamic partition (Super).
具体的,升级进程将用户数据分区(Userdata)中的cow文件中的升级数据写入到动态分区(Super)中的对应地址上,使得动态分区(Super)中的全部数据均为升级后的新版本的数据。Specifically, the upgrade process writes the upgrade data in the cow file in the user data partition (Userdata) to the corresponding address in the dynamic partition (Super), so that all the data in the dynamic partition (Super) are updated new Version data.
例如,基于system子分区的文件地图中的/system/app/A2.XXX:024018~024020以及cow文件地图中的/system/app/A2.XXX:045033~045035,将地址045033~045035上的数据写入到地址024014~024017上;基于system子分区的文件地图中的/system/user/C2.XXX:024036~024040以及cow文件地图中的/system/user/C2.XXX:045036~045040,将地址045036~045040上的数据写入到地址024036~024040上。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 Write to address 024014~024017; 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 to 045040 are written to addresses 024036 to 024040.
在此之后升级进程删除用户数据分区(Userdata)中的cow文件,将存储空间归还给用户数据分区(Userdata);并且,将基础分区(Common)的元数据(/metadata)中的落盘状态信息由“未落盘(wait for merge)”改为“已落盘(merged)”。After that, the upgrade process deletes the cow file in the user data partition (Userdata), and returns the storage space to the user data partition (Userdata); and, the disk status information in the metadata (/metadata) of the basic partition (Common) Changed from "wait for merge" to "merged".
基于图2可知,在S220中,以静态分区为粒度,独立对某个静态分区中的数据进行升级,且静态分区之间的升级互不影响,比如针对静态分区(B)中的操作系统数据的升级,其并不会影响到当前启动的静态分区(A)的操作系统数据。并且,在S230中,动态分区升级的数据操作是在用户数据分区(Userdata)中所创建的虚拟动态分区上完成的,其并不会影响到当前挂载的动态分区(Super)。因此,在整个操作系统升级的过程中,用户可以正常使用设备,比如使用动态分区中的数据等。并且,在S231 完成后,设备并不需要立即重启,可以由用户自行选择重启时机;这样,操作系统的升级过程并不会对用户的正常手机操作产生影响,从而大大提高了用户体验。进一步的,针对动态分区(Super),仅在需要进行升级时才会在用户数据分区(Userdata)上创建虚拟动态分区,因此有效提高了数据存储空间利用率。Based on Figure 2, it can be seen that in S220, the data in a static partition is independently upgraded at the granularity of the static partition, and the upgrades between static partitions do not affect each other. For example, for the operating system data in the static partition (B) upgrade, it will not affect the operating system data of the currently started static partition (A). Moreover, in S230, the data operation of the dynamic partition upgrade is completed on the virtual dynamic partition created in the user data partition (Userdata), which will not affect the currently mounted dynamic partition (Super). Therefore, during the whole process of upgrading the operating system, the user can use the device normally, such as using data in the dynamic partition. Moreover, after S231 is completed, the device does not need to be restarted immediately, and the user can choose the restarting time; in this way, the upgrade process of the operating system will not affect the user's normal mobile phone operation, thereby greatly improving the user experience. Further, for the dynamic partition (Super), a virtual dynamic partition will be created on the user data partition (Userdata) only when an upgrade is required, thus effectively improving the utilization rate of data storage space.
进一步的,图3所示为根据本申请一实施例的数据存储结构示意图。如图3所示,在动态分区(Super)的头部的元数据(/supermetadata)中,包含对应静态分区(A)的Slot0以及静态分区(B)的Slot1。Slot0以及Slot1用于保存Super分区的分区表。为了方便说明,可以将对应静态分区(A)的Slot0称为第一插槽,Slot0中的数据称为第一插槽数据,将对应静态分区(B)的Slot1称为第二插槽,Slot1中的数据称为第二插槽数据。Further, FIG. 3 is a schematic diagram of a data storage structure according to an embodiment of the present application. As shown in FIG. 3 , the metadata (/supermetadata) of the header of the dynamic partition (Super) includes Slot0 corresponding to the static partition (A) and Slot1 of the static partition (B). Slot0 and Slot1 are used to save the partition table of the Super partition. For the convenience of explanation, Slot0 corresponding to the static partition (A) can be called the first slot, the data in Slot0 is called the first slot data, and Slot1 corresponding to the static partition (B) is called the second slot, and Slot1 The data in is called the second slot data.
例如,在UFS的MBR中,设备启动顺序描述中,配置Slot0对应从静态分区(A)启动,配置Slot1对应从静态分区(B)启动。在设备启动时,根据启动的静态分区的不同,选择从Slot0或Slot1中的一个中获取Super分区的分区信息。以设备当前从静态分区(A)启动为例,在加载动态分区(Super)时,设备首先读取Slot0,以获取动态分区(Super)的子分区地址;在设备由静态分区B启动时,在加载Super分区时,设备首先读取Slot1,以获取动态分区(Super)的子分区地址。For example, in the MBR of UFS, in the device boot sequence description, configuring Slot0 corresponds to booting from the static partition (A), and configuring Slot1 corresponds to booting from the static partition (B). When the device is started, it selects to obtain the partition information of the Super partition from Slot0 or Slot1 according to the static partition to be started. Take the device currently booting from the static partition (A) as an example. When loading the dynamic partition (Super), the device first reads Slot0 to obtain the sub-partition address of the dynamic partition (Super); when the device starts from the static partition B, in When loading the Super partition, the device first reads Slot1 to obtain the sub-partition address of the dynamic partition (Super).
具体的,Slot0以及Slot1中包含多个子分区描述组,一个子分区描述组对应Super分区的一个子分区。也就是说,Slot0中包括与多个子分区对应的多个描述组,Slot1也包括与多个子分区对应的多个描述组。为了方便说明,可以将Slot0中的多个子分区描述组称为多个第一描述组,将Slot1中的多个子分区描述组称为多个第二描述组。Specifically, Slot0 and Slot1 include multiple sub-partition description groups, and one sub-partition description group corresponds to one sub-partition of the Super partition. That is to say, Slot0 includes multiple description groups corresponding to multiple subpartitions, and Slot1 also includes multiple description groups corresponding to multiple subpartitions. For convenience of description, the multiple sub-partition description groups in Slot0 may be referred to as multiple first description groups, and the multiple sub-partition description groups in Slot1 may be referred to as multiple second description groups.
子分区描述组包含:名称(Name)项,组(Group)项,属性(Attributes)项,地址(Extents)项中的至少一种。下面对子分区描述组包含的各项进行描述:The sub-partition description group includes: at least one of a name (Name), a group (Group), an attribute (Attributes), and an address (Extents). The following describes the items contained in the sub-partition description group:
名称(Name)项,其值为子分区的名称,例如,system_b;Name (Name), its value is the name of the sub-partition, for example, system_b;
组(Group)项,其值为子分区类型,例如,子分区(ry_dynamic_partitions_b);Group (Group) item, whose value is the subpartition type, for example, subpartition (ry_dynamic_partitions_b);
属性(Attributes)项,其值为子分区读写属性,例如,只读属性(readonly);Attributes item, its value is the read-write attribute of the sub-partition, for example, the read-only attribute (readonly);
地址(Extents)项,其值为子分区的地址,例如,0..6995967linear super 2048。Address (Extents), its value is the address of the sub-partition, for example, 0..6995967linear super 2048.
在Name项以及Group项中,值的后缀为_a,则对应静态分区(A);值的后缀为_b,则对应静态分区(B)。In the Name item and the Group item, if the suffix of the value is _a, it corresponds to the static partition (A); if the suffix of the value is _b, it corresponds to the static partition (B).
在由静态分区A启动,加载Super分区时,首先读取Slot0。在读取Slot0时,由于后缀为_a对应静态分区(A),设备读取Slot0中Name项和/或Group项后缀为_a的子分区描述组中Extents项的值,以获取动态分区(Super)的子分区地址。When starting from static partition A and loading the Super partition, Slot0 is first read. When reading Slot0, since the suffix _a corresponds to the static partition (A), the device reads the value of the Extents item in the sub-partition description group whose Name item and/or Group item suffix _a in Slot0 to obtain the dynamic partition ( Super) sub-partition address.
在由静态分区B启动,加载Super分区时,首先读取Slot1。在读取Slot1时,由于后缀为_b对应静态分区(B),设备读取Slot0中Name项和/或Group项后缀为_b的分区描述组中Extents项的值,以获取动态分区(Super)的子分区地址。When booting from static partition B and loading the Super partition, Slot1 is first read. When reading Slot1, since the suffix _b corresponds to the static partition (B), the device reads the value of the Extents item in the partition description group with the suffix _b in the Name item and/or Group item in Slot0 to obtain the dynamic partition (Super ) subpartition address.
一般的,在设备出厂前进行系统烧录后,初始的Slot0以及Slot1中,针对Super分区的每个子分区,存在两个子分区描述组,一个子分区描述组对应静态分区(A),一个子分区描述组对应静态分区(B)。在读取Slot0或Slot1时,设备根据后缀(_a或_b)选定需要读取的子分区描述组。Generally, after the system is burned before the device leaves the factory, in the initial Slot0 and Slot1, there are two sub-partition description groups for each sub-partition of the Super partition, one sub-partition description group corresponds to the static partition (A), and one sub-partition Description groups correspond to static partitions (B). When reading Slot0 or Slot1, the device selects the sub-partition description group to be read according to the suffix (_a or _b).
即,在Slot0以及Slot1中,针对Super分区的每个子分区,均存在两个子分区描 述组(例如,第一描述组和第二描述组)。针对同一子分区的两个子分区描述组的Name项和Group项的值的前缀相同,后缀不同(分别为_a以及_b)。针对同一子分区的两个子分区描述组的地址项的值可以不同。That is, in Slot0 and Slot1, for each sub-partition of the Super partition, there are two sub-partition description groups (for example, the first description group and the second description group). The values of the Name item and the Group item of two sub-partition description groups for the same sub-partition have the same prefix and different suffixes (_a and _b respectively). Values of address items of two sub-partition description groups for the same sub-partition may be different.
图4所示为一实施例中初始的Slot0所保存的部分数据。如图4所示,Name项以及Group项的值的后缀为_a的子分区描述组中,Extents项的值为子分区的真实地址。Name项以及Group项的值的后缀为_b的分区描述组中,Extents项的值被置空。在由静态分区A启动,加载Super分区时,首先读取Slot0。在读取Slot0时,由于后缀为_a对应静态分区(A),设备读取Slot0中Name项和/或Group项后缀为_a的子分区描述组中Extents项的值,以获取Super分区的子分区地址,从而顺利加载Super分区。FIG. 4 shows part of the data stored in the initial Slot0 in an embodiment. As shown in FIG. 4 , in the sub-partition description group with the suffix _a in the value of the Name item and the Group item, the value of the Extents item is the real address of the sub-partition. In the partition description group with the suffix of _b in the value of the Name item and the Group item, the value of the Extents item is blank. When starting from static partition A and loading the Super partition, Slot0 is first read. When reading Slot0, since the suffix _a corresponds to the static partition (A), the device reads the value of the Extents item in the sub-partition description group whose Name item and/or Group item suffix _a in Slot0 to obtain the super partition The address of the sub-partition, so that the super partition can be loaded smoothly.
在读取Slot0时,由于后缀为_b对应静态分区(B),设备无需读取Slot0中Name项和/或Group项后缀为_b的子分区描述组,因此,Name项以及Group项的值的后缀为_b的子分区描述组中,Extents项的值被置空不会影响Super分区的加载。When reading Slot0, since the suffix _b corresponds to the static partition (B), the device does not need to read the sub-partition description group whose Name item and/or Group item suffix _b in Slot0, therefore, the values of the Name item and the Group item In the description group of subpartitions whose suffix is _b, setting the value of Extents to blank will not affect the loading of super partitions.
进一步,在一些实施例中,初始的Slot1所保存的数据与图4所示的数据结构类似,区别在于,为了确保顺利加载Super分区,在Slot1的数据中,Name项以及Group项的值的后缀为_b的子分区描述组中,Extents项的值为子分区的真实地址。Name项以及Group项的值的后缀为_a的子分区描述组中,Extents项的值被置空。Further, in some embodiments, the data stored in the initial Slot1 is similar to the data structure shown in Figure 4, the difference is that, in order to ensure the smooth loading of the Super partition, in the data of Slot1, the suffix of the value of the Name item and the Group item In the sub-partition description group of _b, the value of the Extents item is the real address of the sub-partition. In the sub-partition description group with the suffix _a in the value of the Name item and the Group item, the value of the Extents item is blank.
由此可见,当系统升级时,设备需要对slot0或者slot1中的子分区描述组及时更新。如此,在后续切换启动的静态分区时,设备才能读取到正确的子分区描述,如Extents项,以成功加载动态分区(Super)分区。It can be seen that when the system is upgraded, the device needs to update the sub-partition description group in slot0 or slot1 in time. In this way, the device can read the correct description of the sub-partitions, such as the Extents item, when switching to the static partition that starts up subsequently, so as to successfully load the dynamic partition (Super) partition.
并且,在加载动态分区(Super)时(如S241中),需要从用户数据分区(Userdata)的虚拟动态分区中读取cow文件。为了可以准确的从用户数据分区(Userdata)中读取到cow文件,设备还可以在基础分区(Common)中创建cow文件的索引。该cow文件的索引用于指示设备从用户数据分区(Userdata)中读取cow文件。然后,设备在加载动态分区(Super)时,可以根据该索引从用户数据分区(Userdata)中读取到相应的cow文件。Moreover, when loading the dynamic partition (Super) (as in S241), it is necessary to read the cow file from the virtual dynamic partition of the user data partition (Userdata). In order to accurately read the cow file from the user data partition (Userdata), the device can also create an index of the cow file in the basic partition (Common). The index of the cow file is used to instruct the device to read the cow file from the user data partition (Userdata). Then, when the device loads the dynamic partition (Super), it can read the corresponding cow file from the user data partition (Userdata) according to the index.
下面将在图3的基础上,结合slot1的更新和cow文件的索引的创建来说明虚拟A/B升级方案的流程。具体的,当设备当前是从静态分区(A)启动时,设备按照如图5A所示的流程实现操作系统的升级。The flow of the virtual A/B upgrade solution will be described below on the basis of FIG. 3 , combined with the update of slot1 and the creation of the index of the cow file. Specifically, when the device is currently booted from the static partition (A), the device implements an operating system upgrade according to the process shown in FIG. 5A .
S200、设备依次加载基础分区(Common)、静态分区(A)以及动态分区(Super),从静态分区(A)启动。S200, the device sequentially loads the basic partition (Common), the static partition (A) and the dynamic partition (Super), and starts from the static partition (A).
S210、设备获取操作系统升级安装包。S210. The device acquires an operating system upgrade installation package.
S510、设备解析操作系统升级安装包,获得应用清单数据(manifest)。S510. The device parses the operating system upgrade installation package to obtain application manifest data (manifest).
在操作系统升级安装包中,mainfest中记录了更新后的操作系统(如版本1.2)的数据存储结构中静态分区的分区信息(简称静态分区信息)和动态分区的分区信息(简称动态分区信息)。其中,静态分区信息包括静态分区中各个子分区的名字、大小、升级后的数据的校验值(如哈希值)以及升级数据(差分或者全量镜像的数据)在操作系统升级安装包里的位置。动态分区信息包括动态分区中各个子分区的名字、大小、升级后的数据的校验值(如哈希值)以及升级数据(差分或者全量镜像的数据)在操作系统升级安装包里的位置。In the operating system upgrade installation package, the mainfest records the partition information of the static partition (referred to as the static partition information) and the partition information of the dynamic partition (referred to as the dynamic partition information) in the data storage structure of the updated operating system (such as version 1.2). . Among them, the static partition information includes the name and size of each sub-partition in the static partition, the check value (such as hash value) of the upgraded data, and the upgrade data (difference or full mirror data) in the operating system upgrade installation package. Location. The dynamic partition information includes the name and size of each sub-partition in the dynamic partition, the check value (such as hash value) of the upgraded data, and the location of the upgraded data (differential or full mirrored data) in the operating system upgrade installation package.
示例性的,更新后的操作系统的动态分区包括如下6个子分区:system、system_ext、vendor、product、cust以及odm。相应的,manifest中包括如下动态分区信息:Exemplarily, the dynamic partition of the updated operating system includes the following six subpartitions: system, system_ext, vendor, product, cust and odm. Correspondingly, the manifest includes the following dynamic partition information:
system分区的名字、大小、升级后的数据的校验值(如哈希值)以及升级数据在操作系统升级安装包里的位置;The name and size of the system partition, the verification value (such as hash value) of the upgraded data, and the location of the upgraded data in the operating system upgrade installation package;
system_ext分区的名字、大小、升级后的数据的校验值(如哈希值)以及升级数据在操作系统升级安装包里的位置;The name and size of the system_ext partition, the check value (such as hash value) of the upgraded data, and the location of the upgraded data in the operating system upgrade installation package;
vendor分区的名字、大小、升级后的数据的校验值(如哈希值)以及升级数据在操作系统升级安装包里的位置;The name and size of the vendor partition, the check value (such as hash value) of the upgraded data, and the location of the upgraded data in the operating system upgrade installation package;
product分区的名字、大小、升级后的数据的校验值(如哈希值)以及升级数据在操作系统升级安装包里的位置;The name and size of the product partition, the verification value (such as hash value) of the upgraded data, and the location of the upgraded data in the operating system upgrade installation package;
cust分区的名字、大小、升级后的数据的校验值(如哈希值)以及升级数据在操作系统升级安装包里的位置;The name and size of the cust partition, the check value (such as hash value) of the upgraded data, and the location of the upgraded data in the operating system upgrade installation package;
odm分区的名字、大小、升级后的数据的校验值(如哈希值)以及升级数据在操作系统升级安装包里的位置。The name and size of the odm partition, the check value (such as the hash value) of the upgraded data, and the location of the upgraded data in the operating system upgrade installation package.
进一步的,若相较于当前的操作系统,更新后的操作系统的数据存储结构中动态分区包括的子分区减少了,则manifest中的动态分区信息涉及的子分区不会包括当前的操作系统中动态分区里的所有子分区。Further, if the number of sub-partitions included in the dynamic partition in the data storage structure of the updated operating system is reduced compared with the current operating system, the sub-partitions involved in the dynamic partition information in the manifest will not be included in the current operating system. All subpartitions in the dynamic partition.
示例性的,当前的操作系统的数据存储结构中,动态分区(Super)包括system、system_ext、vendor、product、cust、odm共6个子分区,而升级后的操作系统的数据存储结构中,动态分区(Super)包括system、product、cust、odm共4个子分区。相应的,manifest中包括如下动态分区信息:Exemplarily, in the data storage structure of the current operating system, the dynamic partition (Super) includes 6 sub-partitions of system, system_ext, vendor, product, cust, and odm, and in the data storage structure of the upgraded operating system, the dynamic partition (Super) includes 4 sub-partitions including system, product, cust, and odm. Correspondingly, the manifest includes the following dynamic partition information:
system分区的名字、大小、升级后的数据的校验值(如哈希值)以及升级数据在操作系统升级安装包里的位置;The name and size of the system partition, the verification value (such as hash value) of the upgraded data, and the location of the upgraded data in the operating system upgrade installation package;
product分区的名字、大小、升级后的数据的校验值(如哈希值)以及升级数据在操作系统升级安装包里的位置;The name and size of the product partition, the verification value (such as hash value) of the upgraded data, and the location of the upgraded data in the operating system upgrade installation package;
cust分区的名字、大小、升级后的数据的校验值(如哈希值)以及升级数据在操作系统升级安装包里的位置;The name and size of the cust partition, the check value (such as hash value) of the upgraded data, and the location of the upgraded data in the operating system upgrade installation package;
odm分区的名字、大小、升级后的数据的校验值(如哈希值)以及升级数据在操作系统升级安装包里的位置。The name and size of the odm partition, the check value (such as the hash value) of the upgraded data, and the location of the upgraded data in the operating system upgrade installation package.
很显然,manifest包括的动态分区信息不涉及system_ext和vendor分区。Obviously, the dynamic partition information included in the manifest does not involve the system_ext and vendor partitions.
S520、设备根据manifest中的动态分区信息,调整动态分区(Super)里slot1的子分区描述组,得到调整后的slot1。其中,调整后的slot1中子分区描述组涉及的子分区与manifest中动态分区信息涉及的子分区一一对应。S520. The device adjusts the sub-partition description group of slot1 in the dynamic partition (Super) according to the dynamic partition information in the manifest, and obtains the adjusted slot1. Wherein, the sub-partitions involved in the sub-partition description group in the adjusted slot1 are in one-to-one correspondence with the sub-partitions involved in the dynamic partition information in the manifest.
具体的,设备根据子分区的名字和大小调整slot1中相应子分区的地址(Extents)项,使调整后的slot1中各个子分区的地址(Extents)项与相应子分区大小相匹配。以及,设备从slot1中删除manifest的动态分区信息不涉及的子分区的子分区描述组。即,更新后的slot1的子分区描述组涉及的子分区,与manifest中动态分区信息涉及的子分区一一对应。Specifically, the device adjusts the address (Extents) item of the corresponding subpartition in slot1 according to the name and size of the subpartition, so that the adjusted address (Extents) item of each subpartition in slot1 matches the size of the corresponding subpartition. And, the device deletes the subpartition description group of the subpartition not involved in the dynamic partition information of the manifest from slot1. That is, the sub-partitions involved in the updated sub-partition description group of slot1 are in one-to-one correspondence with the sub-partitions involved in the dynamic partition information in the manifest.
以各个子分区的分区大小均未发生改变,并且,调整前的slot1是图5B中的(a) 所示初始的slot1为例,初始的slot1中包括system、system_ext、product、vendoer、cust、odm共6个子分区的子分区描述组,并且每个子分区包括两个子分区描述组,一个子分区描述组对应静态分区(A),一个子分区描述组对应静态分区(B)。此次从操作系统升级包中解析出的manifest中,包括system、product、cust、odm共4个子分区的动态分区信息,则经过调整后可得到如图5B中的(b)所示的slot1。相较于调整前的slot1,调整后的slot1中删除了system_ext和vendor分区的子分区描述组,而仅包括system、product、cust、odm共4个子分区的子分区描述组。Take the partition size of each sub-partition not changed, and the slot1 before adjustment is the initial slot1 shown in (a) in Figure 5B as an example, the initial slot1 includes system, system_ext, product, vendor, cust, odm There are 6 sub-partition description groups in total, and each sub-partition includes two sub-partition description groups, one sub-partition description group corresponds to the static partition (A), and one sub-partition description group corresponds to the static partition (B). The manifest parsed from the operating system upgrade package this time includes the dynamic partition information of 4 subpartitions including system, product, cust and odm. After adjustment, slot1 as shown in (b) in Figure 5B can be obtained. Compared with the slot1 before adjustment, the sub-partition description groups of system_ext and vendor partitions are deleted in slot1 after adjustment, and only the sub-partition description groups of four sub-partitions including system, product, cust, and odm are included.
进一步的,若调整前的slot1为初始的slot1(如图5B中的(a)所示),则相较于调整前的slot1,调整后的slot1仅保留与静态分区(B)对应的子分区描述组,即后缀为_b的子分区描述组,而删除了与静态分区(A)对应的子分区描述组,即后缀为_a的子分区描述组。Further, if the slot1 before the adjustment is the initial slot1 (as shown in (a) in Figure 5B), compared with the slot1 before the adjustment, the adjusted slot1 only retains the sub-partition corresponding to the static partition (B) The description group, that is, the sub-partition description group with the suffix _b, and the sub-partition description group corresponding to the static partition (A), that is, the sub-partition description group with the suffix _a is deleted.
S530、设备根据调整后的slot1在基础分区(Common)中记录cow文件的索引。S530. The device records the index of the cow file in the basic partition (Common) according to the adjusted slot1.
其中,cow文件的索引可指示设备从用户数据分区(Userdata)中查找相应的cow文件,以完成动态分区(Super)的加载。Wherein, the index of the cow file can instruct the device to search the corresponding cow file from the user data partition (Userdata) to complete the loading of the dynamic partition (Super).
设备将更新后的slot1中的子分区描述组复制一份到基础分区(Common)下,如基础分区(Common)的元数据(/metadate)下/gsi/ota/lp_metadata文件中,则得到cow文件的索引。The device copies the updated sub-partition description group in slot1 to the basic partition (Common), such as the /gsi/ota/lp_metadata file under the metadata (/metadate) of the basic partition (Common), and the cow file is obtained index of.
示例性的,仍以图5B中的(b)所示调整后的slot1为例,将该调整后的slot1中的子分区描述组复制一份到基础分区(Common)下/metadate/gsi/ota/lp_metadata文件中,则/metadate/gsi/ota/lp_metadata文件中可记录包括system、product、cust、odm共4个子分区对应的cow文件的索引。例如,/metadate/gsi/ota/lp_metadata中cow文件的索引如下所示:Exemplarily, still taking the adjusted slot1 shown in (b) in Figure 5B as an example, copy the sub-partition description group in the adjusted slot1 to /metadate/gsi/ota under the basic partition (Common) In the /lp_metadata file, the /metadate/gsi/ota/lp_metadata file can record the index of the cow file corresponding to the four subpartitions including system, product, cust, and odm. For example, the index of the cow file in /metadate/gsi/ota/lp_metadata looks like this:
Name:system_bName: system_b
Group:ry_dynamic_partitions_bGroup: ry_dynamic_partitions_b
Attributes:readonlyAttributes: readonly
Extents:Extents:
0…6995967 linear super 20480…6995967 linear super 2048
------------------------------------------------
Name:product_bName: product_b
Group:ry_dynamic_partitions_bGroup: ry_dynamic_partitions_b
Attributes:readonlyAttributes: readonly
Extents:Extents:
0…65535 linear super 69980160…65535 linear super 6998016
------------------------------------------------
Name:odm_bName: odm_b
Group:ry_dynamic_partitions_bGroup: ry_dynamic_partitions_b
Attributes:readonlyAttributes: readonly
Extents:Extents:
0…1949695 linear super 94310400…1949695 linear super 9431040
------------------------------------------------
Name:cust_bName: cust_b
Group:ry_dynamic_partitions_bGroup: ry_dynamic_partitions_b
Attributes:readonlyAttributes: readonly
Extents:Extents:
0…180223 linear super 16263168。0…180223 linear super 16263168.
S220、设备根据操作系统升级安装包针对静态分区(B)进行数据写入操作以升级静态分区(B)。S220. The device performs a data writing operation on the static partition (B) according to the operating system upgrade installation package to upgrade the static partition (B).
S540、设备根据操作系统升级安装包在用户数据分区(Userdata)创建虚拟动态分区,在虚拟动态分区中,采用cow文件保存动态分区(Super)的升级数据。S540. The device creates a virtual dynamic partition in the user data partition (Userdata) according to the operating system upgrade installation package. In the virtual dynamic partition, a cow file is used to store the upgrade data of the dynamic partition (Super).
在虚拟动态分区中,一个cow文件存放一个子分区的升级数据。例如,system_b_cow_img.img.000文件存放system分区的升级数据,cust_b_cow_img.img.000文件存放cust分区的升级数据。In a virtual dynamic partition, a cow file stores the upgrade data of a sub-partition. For example, the system_b_cow_img.img.000 file stores the upgrade data of the system partition, and the cust_b_cow_img.img.000 file stores the upgrade data of the cust partition.
S231、将设备的启动顺序由从静态分区(A)启动变更为从静态分区(B)启动。S231. Change the boot sequence of the device from booting from the static partition (A) to booting from the static partition (B).
S232、设备重启。S232. The device restarts.
S240、设备依次加载基础分区(Common)、静态分区(B),从静态分区(B)启动。S240. The device sequentially loads the basic partition (Common) and the static partition (B), and starts from the static partition (B).
S550、设备根据调整后的slot1和cow文件的索引,加载动态分区(Super)以及用户数据分区(Userdata)的虚拟动态分区中的cow文件。S550. The device loads the cow file in the dynamic partition (Super) and the virtual dynamic partition of the user data partition (Userdata) according to the adjusted slot1 and the index of the cow file.
设备在加载动态分区(Super)时,可以从调整后的slot1中读取子分区描述组,以及读取cow文件的索引和落盘状态信息。其中,设备读取子分区描述组,可以获取各个子分区的地址(Extents)项,即各个子分区在动态分区中的偏移地址。设备读取落盘状态信息,可以确定是否需要从用户数据分区(Userdata)中检索各个子分区对应的cow文件。具体的,读取到落盘状态信息的整体标识为“已落盘”时,则确定无需从用户数据分区(Userdata)中检索所有子分区对应的cow文件。读取到落盘状态信息的整体标识为“未落盘”时,则可以进一步读取落盘状态信息中针对各个子分区的子分区标识。若子分区标识为“已落盘”,则确定无需从用户数据分区(Userdata)中检索相应子分区对应的cow文件。若子分区标识为“未落盘”,则确定需要从用户数据分区(Userdata)中检索相应子分区对应的cow文件。设备读取cow文件的索引,可以根据cow文件的索引指示的文件名,从用户数据分区(Userdata)中检索相应的cow文件。When the device loads a dynamic partition (Super), it can read the sub-partition description group from the adjusted slot1, and read the index and storage status information of the cow file. Wherein, the device reads the sub-partition description group, and can obtain the address (Extents) item of each sub-partition, that is, the offset address of each sub-partition in the dynamic partition. The device reads the storage state information, and can determine whether to retrieve the cow files corresponding to each sub-partition from the user data partition (Userdata). Specifically, when it is read that the overall flag of the disk placement status information is "displaced", it is determined that there is no need to retrieve the cow files corresponding to all sub-partitions from the user data partition (Userdata). When it is read that the overall identifier of the disk placement status information is "unloaded disk", then the sub-partition identifiers for each sub-partition in the disk placement status information can be further read. If the sub-partition is identified as "placed", it is determined that there is no need to retrieve the cow file corresponding to the corresponding sub-partition from the user data partition (Userdata). If the sub-partition is identified as "not placed on the disk", it is determined that the cow file corresponding to the corresponding sub-partition needs to be retrieved from the user data partition (Userdata). The device reads the index of the cow file, and can retrieve the corresponding cow file from the user data partition (Userdata) according to the file name indicated by the index of the cow file.
示例性的,设备读取落盘状态信息,确定需要检索system子分区对应的cow文件。然后,设备读取包括如下内容的cow文件的索引:Exemplarily, the device reads the storage state information, and determines that the cow file corresponding to the system subpartition needs to be retrieved. The device then reads the index of the cow file which contains the following:
Name:system_b,Name: system_b,
Group:ry_dynamic_partitions_b,Group: ry_dynamic_partitions_b,
Attributes:readonly,Attributes: readonly,
Extents:0…6995967 linear super 2048,Extents: 0...6995967 linear super 2048,
可以读取到与system子分区对应的名称项“system_b”。然后,设备根据cow文件的命名规则,可以确定名称项“system_b”对应的cow文件的文件名为 system_b_cow_img。设备可以从用户数据分区(Userdata)中检索文件名为system_b_cow_img的cow文件。从而检索到system分区对应的cow文件。The name item "system_b" corresponding to the system sub-partition can be read. Then, according to the naming rule of the cow file, the device can determine that the file name of the cow file corresponding to the name item "system_b" is system_b_cow_img. The device can retrieve the cow file named system_b_cow_img from the user data partition (Userdata). Thus, the cow file corresponding to the system partition is retrieved.
之后,设备采用snapshot可合并加载动态分区(Super)以及cow文件。Afterwards, the device can merge and load dynamic partition (Super) and cow files by using snapshot.
关于S550中未详细说明的部分,例如,采用snapshot可合并加载动态分区(Super)以及cow文件的内容,可参见图2所示的实施例中S241的相关说明,此处不再赘述。Regarding the parts not described in detail in S550, for example, the contents of the dynamic partition (Super) and the cow file can be merged and loaded by using the snapshot, refer to the related description of S241 in the embodiment shown in FIG. 2 , which will not be repeated here.
S250、设备成功启动,进入用户交互界面。S250. The device is successfully started and enters the user interaction interface.
S251、设备将虚拟动态分区的数据落盘到动态分区(Super)。S251. The device puts the data of the virtual dynamic partition into the dynamic partition (Super).
需要在此说明的是,关于图5A中未详细说明的步骤,可参见图2所示实施例中相关步骤的说明,图5A所示的实施例中不再赘述。例如,采用S550中采用snapshot合并加载动态分区(Super)以及cow文件的内容,可参见图2所示的实施例中S241的相关说明。It should be noted here that, for steps not described in detail in FIG. 5A , reference may be made to the description of relevant steps in the embodiment shown in FIG. 2 , and details will not be repeated in the embodiment shown in FIG. 5A . For example, in S550, the contents of the dynamic partition (Super) and the cow file are merged and loaded using the snapshot, and reference may be made to the related description of S241 in the embodiment shown in FIG. 2 .
采用上述图5A所示的升级方案,设备在获取到操作系统升级安装包后,可以调整动态分区(Super)的slot1和创建cow文件的索引。然后,设备使用调整后的slot1和cow文件的索引,可以加载得到启动动态分区(Super)所需的数据,从而成功启动动态分区(Super)。Using the upgrade scheme shown in FIG. 5A above, after the device obtains the operating system upgrade installation package, it can adjust the slot1 of the dynamic partition (Super) and create the index of the cow file. Then, the device uses the adjusted slot1 and the index of the cow file to load and obtain the data required for starting the dynamic partition (Super), thereby successfully starting the dynamic partition (Super).
然而,在实际场景中,极有可能只需对整个操作系统中的部分分区升级,在这种升级场景中,采用图5A所示的升级方案则会存在一定不足。下面将以定制操作系统为例,来说明部分分区升级的需求,以及面对这种需求,采用图5A所示的升级方案的不足。However, in an actual scenario, it is very likely that only some partitions in the entire operating system need to be upgraded. In this upgrade scenario, the upgrade solution shown in FIG. 5A will have certain shortcomings. The customized operating system will be used as an example below to illustrate the requirement for upgrading some partitions, and the disadvantages of using the upgrade solution shown in FIG. 5A in the face of this requirement.
基础操作系统(如图1和图3所示的数据存储结构对应的系统)仅包含最基础的功能,其并不能完全满足用户的应用需求。因此,为了提升用户体验,设备供应商会根据客户需求、应用场景的不同,对基础操作系统进行优化,在基础操作系统的基础上增加定制内容,构建定制操作系统。在设备上安装定制操作系统,以使得设备可以提供优化的系统功能。The basic operating system (the system corresponding to the data storage structure shown in FIG. 1 and FIG. 3 ) only includes the most basic functions, which cannot fully meet the application requirements of users. Therefore, in order to improve user experience, equipment suppliers will optimize the basic operating system according to different customer needs and application scenarios, add customized content on the basis of the basic operating system, and build a customized operating system. Install a customized operating system on the device so that the device can provide optimized system functions.
图6所示为根据本申请一实施例的数据存储结构示意图。如图6所示,安卓系统数据存储区包含基础分区(Common)、静态分区(A)、静态分区(B)、定制动态分区(Super)、用户数据分区(Userdata)。静态分区(A)、静态分区(B)所包含的具体子分区可以参照前文实施例的相关描述。定制动态分区(Super)不仅包含图1和图3所示的基础操作系统数据存储结构中动态分区(Super)的所有子分区。除此以外,定制数据以动态分区的子分区的形式被添加在定制动态分区(Super)中,如图6所示,定制动态分区(Super)还包含定制(version)分区、货架(preload)分区。Version分区、preload分区用于保存定制数据。FIG. 6 is a schematic diagram of a data storage structure according to an embodiment of the present application. As shown in Figure 6, the Android system data storage area includes a basic partition (Common), a static partition (A), a static partition (B), a customized dynamic partition (Super), and a user data partition (Userdata). For the specific sub-partitions included in the static partition (A) and the static partition (B), reference may be made to the relevant descriptions of the foregoing embodiments. The customized dynamic partition (Super) not only includes all the subpartitions of the dynamic partition (Super) in the basic operating system data storage structure shown in FIG. 1 and FIG. 3 . In addition, custom data is added to the custom dynamic partition (Super) in the form of a sub-partition of the dynamic partition. As shown in Figure 6, the custom dynamic partition (Super) also includes custom (version) partitions, shelf (preload) partitions . Version partition and preload partition are used to save customized data.
例如,version分区可以用于存放运营商(如移动、联通)相关的定制化数据。preload分区可以用于存放设备出厂时预装的三方应用的相关数据。这里需要说明的是,在图6所示的实施例中,定制数据保存在version分区以及preload分区中。在本申请其他实施例中,也可以采用其他分区结构保存定制数据。例如,仅保留version分区或仅保留preload分区。又例如,再额外增加一个服务分区。For example, the version partition can be used to store customized data related to operators (such as China Mobile and China Unicom). The preload partition can be used to store data related to third-party applications pre-installed on the device when it leaves the factory. It should be noted here that, in the embodiment shown in FIG. 6 , customized data is stored in the version partition and the preload partition. In other embodiments of the present application, other partition structures may also be used to store customized data. For example, keep only the version partition or only the preload partition. Another example is to add an additional service partition.
在上述定制操作系统中,为了满足用户日益增加的定制化需求,可能需要频繁对定制数据进行升级。与此同时,为了方便对定制操作系统管理,可以将定制操作系统 的数据存储结构划分为多个组件。图7为本申请一实施例的数据存储结构示意图。如图7所示,可以将定制动态分区中的version分区和静态分区中用于存储version分区的校验内容的分区(如vbmeta_version分区)合称为定制(version)组件,将定制动态分区中的preload分区和静态分区中用于存储preload分区的校验内容的分区(如vbmeta_preload分区)合称为货架化(preload)组件,以及将定制动态分区中基础操作系统数据存储结构中动态分区的所有子分区,如system、system_ext、product、vendor等分区,和静态分区中的剩余部分合称为基础(base)组件。这里需要说明的是,图7所示的实施例中,组件的划分仅为示例性的。实际实施时,可根据各个分区的关联性灵活进行划分。例如,可以将定制动态分区中的每个分区和静态分区中用于校验该分区的空间划分为一个组件。下文中,将主要以如图7所示划分的base组件、version组件和preload组件为例,来说明本申请方案。In the above-mentioned customized operating system, in order to meet the increasing customization requirements of users, it may be necessary to frequently upgrade the customized data. At the same time, in order to facilitate the management of the customized operating system, the data storage structure of the customized operating system can be divided into multiple components. FIG. 7 is a schematic diagram of a data storage structure according to an embodiment of the present application. As shown in Figure 7, the version partition in the customized dynamic partition and the partition (such as the vbmeta_version partition) used to store the verification content of the version partition in the static partition can be collectively referred to as a custom (version) component, and the custom (version) component in the dynamic partition can be customized The preload partition and the partition used to store the verification content of the preload partition (such as the vbmeta_preload partition) in the static partition are collectively called the shelf (preload) component, and all sub-partitions in the dynamic partition in the basic operating system data storage structure in the customized dynamic partition Partitions, such as system, system_ext, product, vendor, etc., and the rest of the static partition are collectively called the base component. It should be noted here that, in the embodiment shown in FIG. 7 , the division of components is only exemplary. In actual implementation, it can be flexibly divided according to the relevance of each partition. For example, each partition in the custom dynamic partition and the space used to verify the partition in the static partition can be divided into a component. Hereinafter, the solution of this application will be described mainly by taking the base component, the version component and the preload component divided as shown in FIG. 7 as examples.
通过划分组件,可以将关联性强的分区,例如,存储的数据的作用相似的分区,划分为同一组件。并且,当任一组件的数据有更新时,则会产生升级需求。尤其是preload组件,其升级需求极大。By dividing components, partitions with strong associations, for example, partitions with similar functions of stored data, can be divided into the same component. Moreover, when the data of any component is updated, there will be an upgrade requirement. Especially the preload component has a huge demand for upgrades.
由于version分区、preload分区是定制动态分区(Super)的子分区。因此,整个定制操作系统(基础数据+定制数据)也可以采用图5A所示的升级方案进行升级。如图8中的(a)所示,当有至少两个组件(如version组件和preload组件)有升级需求时,可以将需要升级的组件(如version组件和preload组件)的新版本和不需要升级的组件(如base组件)的当前版本组合为一个新版本后发布,即发布组合升级包。然后,设备在获取到该组合升级包后,可以使用图5A所示的升级流程来完成升级。这种升级方式,当任意数量的组件需要升级时,都需要组合得到一个大版本的系统升级包,然后才能升级。如此,随着各个组件的升级需求越来越大,则会得到大量大版本的升级包,不利于灵活管理。Because the version partition and preload partition are sub-partitions of the custom dynamic partition (Super). Therefore, the entire customized operating system (basic data + customized data) can also be upgraded using the upgrade solution shown in FIG. 5A. As shown in (a) in Figure 8, when there are at least two components (such as the version component and the preload component) that need to be upgraded, the new version of the component that needs to be upgraded (such as the version component and the preload component) can be combined with the new version that does not need The current version of the upgraded components (such as the base component) is combined into a new version and released, that is, the combined upgrade package is released. Then, after the device obtains the combined upgrade package, it can use the upgrade process shown in FIG. 5A to complete the upgrade. In this upgrade method, when any number of components need to be upgraded, they need to be combined to obtain a system upgrade package of a large version before upgrading. In this way, as the upgrade requirements of each component increase, a large number of large-version upgrade packages will be obtained, which is not conducive to flexible management.
若不采用上述发布组合升级包升级的方式,如图8中的(b)所示,当base组件需要升级时,则可以发布base组件的升级安装包(也可称为base安装包);当version组件需要升级,则可以发布version组件的升级安装包(也可称为version升级包);preload组件需要升级,则可以发布preload组件的升级安装包(也可称为preload升级包)。也就是说,每个组件的版本可以独立演进。当有多个组件需要升级时,可以发布该多个组件对应的升级安装包。之后,若采用图5A所示的升级流程来完成升级,则设备只会针对其中一个升级安装包解析出的manifest来调整slot1和创建cow文件的索引。这样,会导致对slot1的调整不完全,创建的cow文件的索引也不准确,最终影响定制动态分区(Super)的加载。If do not adopt the above-mentioned method of publishing combined upgrade package upgrade, as shown in (b) in Figure 8, when the base component needs to be upgraded, then the upgrade installation package (also referred to as base installation package) of the base component can be released; If the version component needs to be upgraded, an upgrade installation package of the version component (also called a version upgrade package) can be released; if the preload component needs to be upgraded, an upgrade installation package of the preload component can be released (also called a preload upgrade package). That is, the version of each component can evolve independently. When multiple components need to be upgraded, the upgrade installation packages corresponding to the multiple components may be published. Afterwards, if the upgrade process shown in Figure 5A is used to complete the upgrade, the device will only adjust slot 1 and create an index of the cow file for the manifest parsed out of one of the upgrade installation packages. In this way, the adjustment to slot1 will be incomplete, and the index of the created cow file will be inaccurate, which will eventually affect the loading of the customized dynamic partition (Super).
基于上述问题,本申请提供一种操作系统中多个组件组合升级的方法,采用该方法,可以对操作系统(基础操作系统或者定制操作系统)中至少两个组件组合进行升级更新,从而可以灵活适配各种升级需求。例如,base组件和version组件组合升级的需求,version组件和preload组件组合升级的需求等。具体的,当设备当前是从静态分区(A)启动时,设备按照图9所示的流程实现多个组件的组合升级。Based on the above problems, the present application provides a method for upgrading a combination of multiple components in an operating system. With this method, at least two combinations of components in the operating system (basic operating system or customized operating system) can be upgraded and updated, so that it can be flexibly Adapt to various upgrade needs. For example, the combination upgrade requirements of base component and version component, the combination upgrade requirement of version component and preload component, etc. Specifically, when the device is currently started from the static partition (A), the device implements combined upgrade of multiple components according to the process shown in FIG. 9 .
S900、设备依次加载基础分区(Common)、静态分区(A)以及动态分区(Super),从静态分区(A)启动。S900, the device loads the basic partition (Common), the static partition (A) and the dynamic partition (Super) in sequence, and starts from the static partition (A).
从静态分区(A)启动时,读取Slot0中的多个子分区描述组,以加载动态分区的数据。此时,运行的是升级前的操作系统,也可以称为第一操作系统。When booting from the static partition (A), read multiple sub-partition description groups in Slot0 to load the data of the dynamic partition. At this point, the operating system before the upgrade is running, which may also be called the first operating system.
应理解,在将图9的实施例应用于基础操作系统的升级时,则动态分区(Super)是指基础操作系统中的动态分区(Super)。在将图9的实施例应用于定制操作系统的升级时,则动态分区(Super)是指定制操作系统中的定制动态分区(Super)。下文中也是如此,将不再一一赘述。It should be understood that when the embodiment of FIG. 9 is applied to the upgrade of the basic operating system, the dynamic partition (Super) refers to the dynamic partition (Super) in the basic operating system. When the embodiment of FIG. 9 is applied to the upgrade of the customized operating system, the dynamic partition (Super) refers to the customized dynamic partition (Super) in the customized operating system. The same is true in the following, and details will not be repeated one by one.
S901、设备获取多个组件的多个升级包。S901. The device acquires multiple upgrade packages of multiple components.
本申请实施例中,多个升级包包括base升级包和version升级包的组合,base升级包和preload升级包的组合,version升级包和preload升级包的组合,base升级包、version升级包和preload升级包的组合中的一种。当多个组件有升级需求时,设备可一次下载得到多个组件的多个升级包。然后,针对该多个升级包统一对多个组件升级。In the embodiment of the present application, the plurality of upgrade packages includes a combination of a base upgrade package and a version upgrade package, a combination of a base upgrade package and a preload upgrade package, a combination of a version upgrade package and a preload upgrade package, a base upgrade package, a version upgrade package and a preload One of the combinations of upgrade packages. When multiple components need to be upgraded, the device can download multiple upgrade packages for multiple components at one time. Then, the multiple components are uniformly upgraded for the multiple upgrade packages.
并且,各个升级包可用于升级相应组件涉及的动态子分区(即动态分区的子分区)和/或静态子分区(即静态分区的子分区)。应理解,每个组件涉及的动态子分区可以为一个或多个,涉及的静态子分区也可以为一个或多个。例如,多个组件包括version组件。version组件涉及的动态子分区为version分区,涉及的静态子分区为vbmeta_version分区,则version升级包可用于升级version分区和用于升级vbmeta_version分区。Moreover, each upgrade package can be used to upgrade the dynamic sub-partition (ie, the sub-partition of the dynamic partition) and/or the static sub-partition (ie, the sub-partition of the static partition) involved in the corresponding component. It should be understood that each component may involve one or more dynamic subpartitions, and may also involve one or more static subpartitions. For example, multiple components include a version component. The dynamic sub-partition involved in the version component is the version partition, and the static sub-partition involved is the vbmeta_version partition. The version upgrade package can be used to upgrade the version partition and the vbmeta_version partition.
为了方便说明,可以将一个组件的升级包称为一个升级安装包,有多个组件的多个升级包时,则可以用前缀第一、第二……来区别。以base升级包和version升级包的组合为例,可以将base升级包称为第一升级安装包,将version升级包称为第二升级安装包。以及,为了方便说明,可以将第一升级安装包用于升级的动态子分区称为第一子分区,将第二升级安装包用于升级的动态子分区称为第二子分区,将除多个升级包用于升级的动态子分区之外的子分区称为第三子分区。可以将第一升级安装包用于升级的静态子分区称为第五子分区,将第二升级安装包用于升级的动态子分区称为第六子分区,将除多个升级包用于升级的静态子分区之外的子分区称为第七子分区。应理解,实际实施时,根据数据存储结构中组件的划分,还可以有第三升级安装包、第四升级安装包等等,对应这些升级安装包,则可以升级另一些动态子分区和静态子分区,例如,第三升级包可以用于升级动态分区的第四子分区。本申请实施例对此不作具体限定。For the convenience of explanation, the upgrade package of one component can be called an upgrade installation package. When there are multiple upgrade packages of multiple components, they can be distinguished by the prefixes first, second.... Taking the combination of the base upgrade package and the version upgrade package as an example, the base upgrade package may be called the first upgrade installation package, and the version upgrade package may be called the second upgrade installation package. And, for the convenience of description, the dynamic subpartition used for upgrading by the first upgrade installation package may be called the first subpartition, and the dynamic subpartition used for upgrading by the second upgrade installation package may be called the second subpartition. The subpartition other than the dynamic subpartition used for upgrading by the first upgrade package is called the third subpartition. The static sub-partition used for upgrading by the first upgrade installation package can be called the fifth sub-partition, and the dynamic sub-partition used for upgrading by the second upgrade installation package can be called the sixth sub-partition. Subpartitions other than the static subpartition of , are called seventh subpartitions. It should be understood that in actual implementation, according to the division of components in the data storage structure, there may also be a third upgrade installation package, a fourth upgrade installation package, etc., and corresponding to these upgrade installation packages, other dynamic sub-partitions and static sub-partitions may be upgraded. Partitions, for example, the third upgrade package can be used to upgrade the fourth sub-partition of the dynamic partition. This embodiment of the present application does not specifically limit it.
在一种可行的实现方案中,设备定期向搜包服务器发起搜包请求,搜包请求包含设备当前运行的操作系统中各个组件的版本号;搜包服务器根据搜包请求中各个组件的版本号,检索当前是否存在更新版本号的各个组件的升级包。示例性的,设备当前运行的操作系统中base组件、version组件和preload组件的版本号均为版本1.1,若搜包服务器检索到base组件的最新版本号还是版本1.1,但是version组件和preload组件的最新版本号为1.2,则表明存在更新版本号的version组件和preload组件的升级包。当多个组件存在更新版本的升级包时,搜包服务器向设备反馈该多个组件的升级包的下载地址。设备根据下载地址即可下载相应组件的升级包。In a feasible implementation scheme, the device periodically initiates a packet search request to the packet search server, and the packet search request includes the version number of each component in the operating system currently running on the device; the packet search server , to retrieve whether there is currently an upgrade package for each component with a newer version number. Exemplarily, the version numbers of the base component, version component, and preload component in the operating system currently running on the device are all version 1.1. If the latest version number of the base component retrieved by the package search server is still version 1.1, but the If the latest version number is 1.2, it indicates that there is an upgrade package for the version component and the preload component with a newer version number. When there are upgrade packages of newer versions for multiple components, the package search server feeds back the download addresses of the upgrade packages for the multiple components to the device. The device can download the upgrade package of the corresponding component according to the download address.
设备在下载多个组件的升级包后,响应于升级系统的事件,例如,用户输入升级的操作、达到预定的升级时间等,设备中的在线升级服务(online update client,OUC) 可将升级包在设备中的位置发送给设备的更新引擎(update engine)。之后,由该更新引擎来执行具体的升级操作,如后续的升级包解析、数据写入等操作,以完成升级。After the device downloads the upgrade packages of multiple components, in response to the events of the upgrade system, such as the user inputting the upgrade operation, reaching the scheduled upgrade time, etc., the online update client (OUC) in the device can update the upgrade package to The location in the device is sent to the device's update engine. Afterwards, the update engine performs specific upgrade operations, such as subsequent upgrade package parsing, data writing, and other operations, to complete the upgrade.
S902、设备解析每个升级包,获得多个升级包对应的多个应用清单数据(manifest)。S902. The device parses each upgrade package to obtain multiple application manifest data (manifest) corresponding to the multiple upgrade packages.
从每个升级包的元数据(/metadata)中,设备可读取到payload.bin的头数据在升级包中的偏移位置和大小。然后,设备根据该payload.bin的头数据在升级包中的偏移位置和大小则可以从升级包中获取到manifest。From the metadata (/metadata) of each upgrade package, the device can read the offset position and size of the header data of payload.bin in the upgrade package. Then, the device can obtain the manifest from the upgrade package according to the offset position and size of the header data of the payload.bin in the upgrade package.
示例性的,升级包的元数据(/metadata)中记录的部分内容如下所示:Exemplarily, part of the content recorded in the metadata (/metadata) of the upgrade package is as follows:
files=payload_metadata.bin:720:1346,payload.bin:720:285881,payload_properties.txt:286653:150,VERSION.mbn:286929:106,SOFTWARE_VER.mbn:286849:21,metadata:63:616。files=payload_metadata.bin:720:1346, payload.bin:720:285881, payload_properties.txt:286653:150, VERSION.mbn:286929:106, SOFTWARE_VER.mbn:286849:21, metadata:63:616.
上述内容中,payload_metadata.bin:720:1346的含义为:payload.bin的头数据(即manifest)在升级包的偏移位置(如720,单位字节)和大小(如1346,单位字节)。然后,设备根据该偏移位置和大小则可获得manifest的原始裸数据(即升级包里记录的原始数据),再调用对该原始裸数据解码可获得manifest的具体内容。In the above content, the meaning of payload_metadata.bin:720:1346 is: the offset position (such as 720, unit byte) and size (such as 1346, unit byte) of the header data (ie manifest) of payload.bin in the upgrade package . Then, according to the offset position and size, the device can obtain the original raw data of the manifest (that is, the original data recorded in the upgrade package), and then call the decoding of the original raw data to obtain the specific content of the manifest.
本申请实施例中,从每个升级包中解析出的manifest中包括的静态分区信息仅涉及该多个组件包括的静态分区的子分区,动态分区信息仅涉及该多个组件包括的动态分区的子分区,而不涉及其他组件。其他组件是指该多个组件之外的组件。其中,静态分区信息或者动态分区信息(可简称为分区信息)都包括子分区的名字(也可以理解为分区标识)、大小、升级后的数据的校验值(如哈希值)以及升级数据在升级包里的位置。为了方便说明,可以将从多个升级包中解析出的多个应用清单数据称为第一数据、第二数据……,例如,将从第一升级安装包中解析出的应用清单数据称为第一数据,将从第二升级安装包中解析出的应用清单数据称为第二数据……。In this embodiment of the application, the static partition information contained in the manifest parsed from each upgrade package only involves the subpartitions of the static partitions included in the multiple components, and the dynamic partition information only involves the sub-partitions of the dynamic partitions included in the multiple components. Subpartitions without involving other components. Other components refer to components other than the plurality of components. Among them, the static partition information or dynamic partition information (which can be referred to as partition information for short) includes the name of the sub-partition (also can be understood as a partition identifier), size, check value (such as hash value) of the upgraded data, and the upgraded data The position in the upgrade package. For the convenience of description, multiple application list data parsed from multiple upgrade packages may be referred to as first data, second data..., for example, the application list data parsed from the first upgrade installation package is called For the first data, the application list data parsed from the second upgrade installation package is referred to as the second data . . . .
示例性的,多个组件包括version组件。由于version组件包括静态分区中的vbmeta_version分区和动态分区中的version分区,相应的,解析出的manifest中可以包括如下分区信息:Exemplarily, the multiple components include a version component. Since the version component includes the vbmeta_version partition in the static partition and the version partition in the dynamic partition, correspondingly, the parsed manifest can include the following partition information:
vbmeta_version分区的名字、大小、升级后的数据的校验值(如哈希值)信息、升级数据在version升级包里的位置;The name and size of the vbmeta_version partition, the check value (such as hash value) information of the upgraded data, and the location of the upgraded data in the version upgrade package;
version分区的名字、大小、升级后的数据的校验值(如哈希值)信息、升级数据在version升级包里的位置。The name and size of the version partition, the check value (such as hash value) information of the upgraded data, and the location of the upgraded data in the version upgrade package.
又示例性的,多个组件包括preload组件。由于preload组件包括静态分区中的vbmeta_preload分区和动态分区中的preload分区,相应的,解析出的manifest中可以包括如下分区信息:Also exemplary, the multiple components include a preload component. Since the preload component includes the vbmeta_preload partition in the static partition and the preload partition in the dynamic partition, correspondingly, the parsed manifest can include the following partition information:
vbmeta_preload分区的名字、大小、升级后的数据的校验值(如哈希值)信息、升级数据在preload升级包里的位置;The name and size of the vbmeta_preload partition, the check value (such as hash value) information of the upgraded data, and the location of the upgraded data in the preload upgrade package;
preload分区的名字、大小、升级后的数据的校验值(如哈希值)信息、升级数据在preload升级包里的位置。The name and size of the preload partition, the check value (such as hash value) information of the upgraded data, and the location of the upgraded data in the preload upgrade package.
再示例性的,多个组件包括base组件。由于base组件包括静态分区中除vbmeta_version和vbmeta_preload之外的分区,例如boot、recovery等分区,和基础操作系统中动态分区包括的子分区,例如,system、product等分区,相应的,解析出的 manifest中可以包括如下分区信息:In another example, the multiple components include a base component. Since the base component includes partitions other than vbmeta_version and vbmeta_preload in the static partition, such as partitions such as boot and recovery, and subpartitions included in dynamic partitions in the basic operating system, such as partitions such as system and product, the parsed manifest is corresponding can include the following partition information:
boot分区的名字、大小、升级后的数据的校验值(如哈希值)信息、升级数据在操作系统升级包里的位置;The name and size of the boot partition, the check value (such as hash value) information of the upgraded data, and the location of the upgraded data in the operating system upgrade package;
recovery分区的名字、大小、升级后的数据的校验值(如哈希值)信息、升级数据在操作系统升级包里的位置;The name and size of the recovery partition, the check value (such as hash value) information of the upgraded data, and the location of the upgraded data in the operating system upgrade package;
……(其他静态分区的子分区的分区信息)... (partition information of subpartitions of other static partitions)
system分区的名字、大小、升级后的数据的校验值(如哈希值)信息、升级数据在操作系统升级包里的位置;The name and size of the system partition, the check value (such as hash value) information of the upgraded data, and the location of the upgraded data in the operating system upgrade package;
system_ext分区的名字、大小、升级后的数据的校验值(如哈希值)信息、升级数据在操作系统升级包里的位置;The name and size of the system_ext partition, the check value (such as hash value) information of the upgraded data, and the location of the upgraded data in the operating system upgrade package;
vendor分区的名字、大小、升级后的数据的校验值(如哈希值)信息、升级数据在操作系统升级包里的位置;The name and size of the vendor partition, the check value (such as hash value) information of the upgraded data, and the location of the upgraded data in the operating system upgrade package;
……(其他动态分区的子分区的分区信息)。...(partition information of subpartitions of other dynamic partitions).
S903、设备将多个manifest合并,得到合并后的manifest。S903. The device merges multiple manifests to obtain a merged manifest.
为了方便说明,可以将合并后的manifest称为第三数据。For convenience of description, the combined manifest may be called third data.
在合并处理时,设备可以将多个manifest按照第一预设顺序首尾拼接。示例性的,第一预设顺序从前至后依次为从base升级包解析出的manifest,从version升级包解析出的manifest和从preload升级包解析出的manifest。或者,设备也可以将多个manifest中的静态分区信息和动态分区信息分别按照第一预设顺序拼接。示例性的,参见图10,以多个升级包包括base升级包、version升级包和preload升级包为例,设备在将从该三个升级包中解析出的三个manifest合并时,可以依次将从base升级包中解析出的manifest、从version升级包中解析出的manifest和从preload升级包中解析出的manifest中的静态分区信息拼接,以及依次将从base升级包中解析出的manifest、从version升级包中解析出的manifest和从preload升级包中解析出的manifest中的动态分区信息拼接,得到拼接后的manifest。During merging processing, the device can splice multiple manifests end to end according to a first preset order. Exemplarily, the first preset order from front to back is the manifest parsed from the base upgrade package, the manifest parsed from the version upgrade package, and the manifest parsed from the preload upgrade package. Alternatively, the device may also splice the static partition information and dynamic partition information in multiple manifests according to a first preset order. Exemplarily, referring to FIG. 10 , taking multiple upgrade packages including a base upgrade package, a version upgrade package, and a preload upgrade package as an example, when the device merges the three manifests parsed from the three upgrade packages, it may sequentially The manifest parsed from the base upgrade package, the manifest parsed from the version upgrade package, and the static partition information in the manifest parsed from the preload upgrade package are stitched together, and the manifest parsed from the base upgrade package, from The manifest parsed from the version upgrade package is spliced with the dynamic partition information in the manifest parsed from the preload upgrade package to obtain the spliced manifest.
经过S903,设备可以得到合并后的manifest,并且可以将合并后的manifest放入新创建的对象,如mergedmanifest中。后续设备则可以仅根据mergedmanifest的值来完成相应的处理即可,如调整slot1,创建cow文件的索引等。After S903, the device can obtain the merged manifest, and can put the merged manifest into a newly created object, such as mergedmanifest. Subsequent devices can complete the corresponding processing only according to the value of the mergedmanifest, such as adjusting slot1, creating an index of the cow file, and so on.
S904、设备根据合并后的manifest中的动态分区信息,调整动态分区(Super)里slot1中的子分区描述组,得到调整后的slot1。其中,调整子分区描述组的过程中,设备不从slot1中删除其他组件包括的子分区的子分区描述组,其他组件是除多个组件之外的组件。S904. The device adjusts the sub-partition description group in slot1 in the dynamic partition (Super) according to the dynamic partition information in the merged manifest, and obtains the adjusted slot1. Wherein, during the process of adjusting the sub-partition description group, the device does not delete the sub-partition description group of the sub-partitions included in other components from slot1, and the other components are components other than the plurality of components.
其中,合并后的manifest包括:动态分区中多个组件包括的子分区的动态分区信息,动态分区信息中包括子分区的名字和大小。设备在根据合并后的manifest调整slot1的过程中,设备根据动态分区信息中子分区的名字和大小调整slot1中相应子分区描述组中的地址(Extents)项。若子分区的大小未发生变化,则slot1中相应子分区描述组中的地址(Extents)项不改变。若子分区的大小发生变化,则调整slot1中相应子分区描述组中的地址(Extents)项。从而使调整后的slot1中各个子分区描述组的地址(Extents)项与相应子分区的大小相匹配。下文实施例中,将主要以子分区的大小未 发生改变来说明本申请方案。Wherein, the merged manifest includes: dynamic partition information of sub-partitions included in multiple components in the dynamic partition, and the dynamic partition information includes the name and size of the sub-partitions. When the device adjusts slot1 according to the merged manifest, the device adjusts the address (Extents) item in the corresponding subpartition description group in slot1 according to the name and size of the subpartition in the dynamic partition information. If the size of the sub-partition does not change, the address (Extents) item in the corresponding sub-partition description group in slot1 does not change. If the size of the sub-partition changes, adjust the address (Extents) item in the corresponding sub-partition description group in slot1. Therefore, the adjusted address (Extents) item of each sub-partition description group in slot1 matches the size of the corresponding sub-partition. In the following embodiments, the solution of the present application will be described mainly with the fact that the size of the sub-partition does not change.
以及,若多个组件仅为base组件、versio组件和preload组件中的两个,则表明不是所有的组件需要升级。本申请实施例中,设备在根据合并后的manifest调整slot1的过程中,不会从slot1中删除其他组件包括的子分区的子分区描述组,即删除不需要升级的组件包括的子分区的子分区描述组。为了方便说明,可以将调整后的slot1中包括的多个子分区描述组称为多个第三描述组。And, if the multiple components are only two of the base component, versio component and preload component, it indicates that not all components need to be upgraded. In the embodiment of this application, during the process of adjusting slot1 according to the merged manifest, the device will not delete the subpartition description groups of subpartitions included in other components from slot1, that is, delete the subpartition description groups of subpartitions included in components that do not need to be upgraded. Partition description group. For convenience of description, the multiple sub-partition description groups included in the adjusted slot1 may be referred to as multiple third description groups.
示例性的,多个组件为version组件和preload组件,即仅有version组件和preload组件需要升级,而base组件无需升级。其中,version组件包括的子分区为version分区,preload组件包括的子分区为preload分区,那么合并后的manifest中包括version分区和preload分区的动态分区信息。假设升级前后动态分区的各个子分区的大小未发生变化,且调整前的slot1中包括如图11中的(a)所示的子分区描述组,即:调整前的slot1中包括system、system_ext、product、vendor、cust、odm、version和preload共8个子分区的子分组描述组。设备根据manifest调整slot1后,得到调整后的slot1中包括如图11中的(b)所示的子分区描述组。相较于调整前的slot1,调整后的slot1中并未删除version分区和preload分区之外的子分区描述组。例如,调整前的slot1中包括system、system_ext、product等分区(属于base组件包括的子分区)的子分区描述组,调整后的slot1中也同样包括system、system_ext、product等分区(属于base组件包括的子分区)的子分区描述组(如图11中的(b)中的虚线框所示)。上述举例中,以各个子分区的大小未发生变化为前提,则相较于调整前的slot1中的每个子分区描述组,调整后的slot1中对应的子分区描述组都是相同的。但是实际中,若多个组件中至少一个子分区(如version分区)升级前的大小和升级后的大小不同,则slot1中该至少一个子分区的子分区描述组中地址(Extents)项可能会相应发生变化。Exemplarily, the multiple components are a version component and a preload component, that is, only the version component and the preload component need to be upgraded, but the base component does not need to be upgraded. Wherein, the subpartition included in the version component is the version partition, and the subpartition included in the preload component is the preload partition, then the merged manifest includes the dynamic partition information of the version partition and the preload partition. Assume that the size of each sub-partition of the dynamic partition has not changed before and after the upgrade, and the slot1 before adjustment includes the sub-partition description group shown in (a) in Figure 11, that is, the slot1 before adjustment includes system, system_ext, A subgroup description group of 8 subpartitions including product, vendor, cust, odm, version, and preload. After the device adjusts the slot1 according to the manifest, the adjusted slot1 includes the sub-partition description group shown in (b) in FIG. 11 . Compared with the slot1 before the adjustment, the sub-partition description groups other than the version partition and the preload partition are not deleted in the adjusted slot1. For example, before adjustment, slot1 includes sub-partition description groups of partitions such as system, system_ext, and product (belonging to the sub-partitions included in the base component), and after adjustment, slot1 also includes partitions such as system, system_ext, and product (belonging to the sub-partitions included in the base component) The sub-partitions of ) describe groups (as shown by the dotted box in (b) in Figure 11). In the above example, on the premise that the size of each sub-partition does not change, compared with each sub-partition description group in slot1 before adjustment, the corresponding sub-partition description group in slot1 after adjustment is the same. However, in practice, if the size of at least one sub-partition (such as the version partition) in multiple components is different before and after the upgrade, the address (Extents) item in the sub-partition description group of the at least one sub-partition in slot1 may be different Change accordingly.
也就是说,在调整slot1的过程中,不会删除合并后的manifest中动态分区信息不涉及的子分区(如第三子分区)的描述组。That is to say, in the process of adjusting slot1, the description group of sub-partitions (such as the third sub-partition) not involved in the dynamic partition information in the merged manifest will not be deleted.
需要说明的是,若调整前的slot1是初始的slot1,那么在根据manifest调整slot1的过程中,设备会删除与静态分区(A)对应的子分区描述组,即后缀为_a的子分区描述组,而仅保留与静态分区(B)对应的子分区描述组,即后缀为_b的子分区描述组。It should be noted that if the slot1 before adjustment is the initial slot1, then during the process of adjusting slot1 according to the manifest, the device will delete the sub-partition description group corresponding to the static partition (A), that is, the sub-partition description with the suffix _a group, and only retain the sub-partition description group corresponding to the static partition (B), that is, the sub-partition description group with the suffix _b.
S905、设备根据合并后的manifest中的动态分区信息,在基础分区(Common)中记录cow文件的索引。其中,该索引与manifest中动态分区信息涉及的子分区一致。S905. The device records the index of the cow file in the basic partition (Common) according to the dynamic partition information in the merged manifest. Wherein, the index is consistent with the sub-partition involved in the dynamic partition information in the manifest.
为了方便说明,可以将S905及其后续步骤中cow文件的索引称为第一索引。For convenience of description, the index of the cow file in S905 and its subsequent steps may be referred to as the first index.
若多个组件仅为base组件、versio组件和preload组件中的两个,则表明不是所有的组件需要升级。该情况下,调整后的slot1不仅包括多个组件(即需要升级的组件)对应的子分区描述组,而且还保留有其他组件(即不需要升级的组件)对应的子分区描述组。设备若直接复制调整后的slot1来得到cow文件的索引,则在后续加载动态分区(Super)时,该索引不仅会指示设备从用户数据分区(userdata)中读取多个组件(即需要升级的组件)包括的子分区对应的cow文件,还会指示设备从用户数据分区(userdata)中读取其他组件(即不需要升级的组件)包括的子分区对应的cow文件。然而,此次并不需要升级其他组件,设备也不会在用户数据分区(userdata)中写入其 他组件包括的子分区对应的cow文件,因此,指示设备从用户数据分区(userdata)中读取其他组件包括的子分区对应的cow文件显然是不合理的。If multiple components are only two of the base component, versio component and preload component, it indicates that not all components need to be upgraded. In this case, the adjusted slot1 not only includes sub-partition description groups corresponding to multiple components (ie, components that need to be upgraded), but also retains sub-partition description groups corresponding to other components (ie, components that do not need to be upgraded). If the device directly copies the adjusted slot1 to obtain the index of the cow file, then when the dynamic partition (Super) is subsequently loaded, the index will not only instruct the device to read multiple components from the user data partition (userdata) component) contains the cow file corresponding to the sub-partition, and also instructs the device to read the cow file corresponding to the sub-partition included in other components (that is, components that do not need to be upgraded) from the user data partition (userdata). However, there is no need to upgrade other components this time, and the device will not write cow files corresponding to subpartitions included in other components in the user data partition (userdata). Therefore, instruct the device to read from the user data partition (userdata) The cow files corresponding to subpartitions included in other components are obviously unreasonable.
基于此,在本申请实施例中,设备根据合并的manifest中的动态分区信息,在基础分区(Common)下记录cow文件的索引。其中,该索引与合并后的manifest中动态分区信息涉及的子分区一致。如此,索引可仅指示设备从用户数据分区(userdata)中读取需要升级的组件包括的子分区对应的cow文件。Based on this, in the embodiment of the present application, the device records the index of the cow file under the basic partition (Common) according to the dynamic partition information in the merged manifest. Wherein, the index is consistent with the sub-partition involved in the dynamic partition information in the merged manifest. In this way, the index may only instruct the device to read the cow file corresponding to the sub-partition included in the component to be upgraded from the user data partition (userdata).
仍以多个组件是version组件和preload组件为例,则合并后的manifest中包括version分区和preload分区的动态分区信息。相应的,设备可在基础分区(Common)中仅记录version分区的cow文件的索引和preload分区的cow文件的索引,以指示设备从用户数据分区(userdata)中读取version分区和preload分区对应的cow文件。Still taking the example that multiple components are version components and preload components, the merged manifest includes the dynamic partition information of the version partition and the preload partition. Correspondingly, the device can only record the index of the cow file of the version partition and the index of the cow file of the preload partition in the basic partition (Common), so as to instruct the device to read the version partition and the index corresponding to the preload partition from the user data partition (userdata). cow file.
在一些实施例中,设备可以在获取到多个升级包后,在基础分区(Common)的元数据(/metadate)下创建/gsi/ota/lp_metadata文件,并在该/gsi/ota/lp_metadata文件中记录cow文件的索引。从而可以方便设备从固定的位置获取到cow文件的索引。In some embodiments, after obtaining multiple upgrade packages, the device can create a /gsi/ota/lp_metadata file under the metadata (/metadate) of the basic partition (Common), and create the /gsi/ota/lp_metadata file in the /gsi/ota/lp_metadata file The index of the cow file is recorded in . Therefore, it is convenient for the device to obtain the index of the cow file from a fixed location.
在一些实施例中,cow文件的索引包括cow文件的名字。示例性的,设备可以根据合并后的manifest中包括动态分区信息涉及的子分区(如第一子分区、第二子分区),和cow文件的命名规则,来生成动态分区信息涉及的子分区的cow文件的名字,并将该名字作为索引。例如,动态分区信息涉及的子分区为version分区和preload分区,并且设备当前从静态分区(A)启动,则可生成version分区的cow文件的名字可以为:version_b_cow_img,生成preload分区的cow文件的名字可以为:preload_b_cow_img。其中,后缀_b对应静态分区(B),则可以在从静态分区(B)重启时读取以加载动态分区。设备可将该名字version_b_cow_img写入基础分区(Common),作为version分区的cow文件的索引;将设备可将该名字preload_b_cow_img写入基础分区(Common),作为preload分区的cow文件的索引。如此,可以通过名字准确指示需要查找的cow文件。为了方便说明,可以将第一子分区的cow文件的名字称为第一文件名,将第二子分区的cow文件的名字称为第二文件名。In some embodiments, the index of the cow file includes the name of the cow file. Exemplarily, the device can generate the subpartitions involved in the dynamic partition information according to the merged manifest including the subpartitions involved in the dynamic partition information (such as the first subpartition and the second subpartition) and the naming rules of the cow file. The name of the cow file and use that name as an index. For example, if the subpartitions involved in the dynamic partition information are the version partition and the preload partition, and the device is currently booted from the static partition (A), the name of the cow file that can generate the version partition can be: version_b_cow_img, the name of the cow file that generates the preload partition Can be: preload_b_cow_img. Among them, the suffix _b corresponds to the static partition (B), and can be read to load the dynamic partition when restarting from the static partition (B). The device can write the name version_b_cow_img into the basic partition (Common) as the index of the cow file in the version partition; the device can write the name preload_b_cow_img into the basic partition (Common) as the index of the cow file in the preload partition. In this way, the cow file that needs to be found can be accurately indicated by the name. For convenience of explanation, the name of the cow file of the first sub-partition may be referred to as the first file name, and the name of the cow file of the second sub-partition may be referred to as the second file name.
在一些实施例中,cow文件的索引还包括cow文件的存储位置。示例性的,存储位置可以是用户数据分区(userdata)。又示例性的,存储位置可以是用户数据分区(userdata)的目标目录(例如,/data/gsi/ota目录),用户数据分区(userdata)的目标目录用于存储升级数据,若升级数据以cow文件存储,则cow文件也存储在该目标目录下。如此,可以通过存储位置准确指示查找cow文件的位置。In some embodiments, the index of the cow file also includes the storage location of the cow file. Exemplarily, the storage location may be a user data partition (userdata). Also exemplary, the storage location may be the target directory of the user data partition (userdata) (for example, the /data/gsi/ota directory), and the target directory of the user data partition (userdata) is used to store the upgrade data, if the upgrade data is in cow file storage, the cow file is also stored in the target directory. In this way, the storage location can be used to indicate exactly where to find the cow file.
仍以多个组件是version组件和preload组件为例,则得到的cow文件的索引可以包括下述信息:Still taking the multiple components as version component and preload component as an example, the index of the obtained cow file can include the following information:
内容:version_b_cow_img、preload_b_cow_imgContent: version_b_cow_img, preload_b_cow_img
位置:userdata。Location: userdata.
上述索引表示在用户数据分区(userdata)中有名为version_b_cow_img和名为preload_b_cow_img的cow文件。The above index indicates that there are cow files named version_b_cow_img and named preload_b_cow_img in the user data partition (userdata).
应理解,前述S904和S905并没有严格的先后顺序。实际实施时,S905也可以在S904之前,或者S904和S905可以同时执行,本申请实施例对此不作具体限定。It should be understood that the aforementioned S904 and S905 are not in a strict sequence. In actual implementation, S905 may also be performed before S904, or S904 and S905 may be performed simultaneously, which is not specifically limited in this embodiment of the present application.
在本申请实施例中,在得到合并后的manifest之后,一方面经过上述S904,设备 可以根据合并后的manifest调整slot1,调整后的slot1中依然保留此次未升级的组件包括的子分区的子分区描述组。另一方面经过S905,设备可以根据合并或manifest创建cow文件的索引,使cow文件的索引仅指示设备从用户数据分区(userdata)中读取此次需要升级的组件包括的子分区对应的cow文件。In the embodiment of this application, after obtaining the merged manifest, on the one hand, after the above S904, the device can adjust slot1 according to the merged manifest, and the adjusted slot1 still retains the subpartitions of the subpartitions included in the components that have not been upgraded this time. Partition description group. On the other hand, through S905, the device can create the index of the cow file according to the merge or manifest, so that the index of the cow file only instructs the device to read the cow file corresponding to the sub-partition included in the component that needs to be upgraded this time from the user data partition (userdata) .
S906、设备根据多个升级包在用户数据分区(Userdata)创建虚拟动态分区,并依次根据多个升级包针对静态分区(B)进行数据写入操作以升级静态分区,以及在虚拟动态分区中写入动态分区(Super)的升级数据。在虚拟动态分区中,采用cow文件保存动态分区(Super)的升级数据。S906. The device creates a virtual dynamic partition in the user data partition (Userdata) according to multiple upgrade packages, and sequentially performs data writing operations on the static partition (B) according to the multiple upgrade packages to upgrade the static partition, and write data in the virtual dynamic partition. Import the upgrade data of the dynamic partition (Super). In the virtual dynamic partition, the cow file is used to save the upgrade data of the dynamic partition (Super).
其中,每个升级包中包括用于升级动态子分区的升级数据和用于升级静态子分区的升级数据。为了方便说明,可以将第一升级安装包用于升级动态子分区(如第一子分区)的升级数据称为第一升级数据,将第二升级安装包用于升级动态子分区(如第二子分区)的升级数据称为第二升级数据。以及,可以将第一升级安装包用于升级静态子分区(如第五子分区)的升级数据称为第三升级数据,将第二升级安装包用于升级静态子分区(如第六子分区)的升级数据称为第四升级数据。Wherein, each upgrade package includes upgrade data for upgrading the dynamic sub-partition and upgrade data for upgrading the static sub-partition. For the convenience of description, the upgrade data used by the first upgrade installation package to upgrade the dynamic sub-partition (such as the first sub-partition) can be called the first upgrade data, and the second upgrade installation package can be used to upgrade the dynamic sub-partition (such as the second sub-partition). The upgrade data of sub-partitions) is called the second upgrade data. And, the upgrade data that the first upgrade installation package is used to upgrade the static sub-partition (such as the fifth sub-partition) can be called the third upgrade data, and the second upgrade installation package is used to upgrade the static sub-partition (such as the sixth sub-partition). ) is called the fourth upgrade data.
本申请实施例中,设备将多个升级包中用于升级静态子分区的数据写入静态分区(B)的相应子分区(如第五子分区、第六子分区),以及将多个升级包中用于升级动态子分区的数据写入虚拟动态分区中。In the embodiment of the present application, the device writes the data used to upgrade the static sub-partitions in the multiple upgrade packages into the corresponding sub-partitions (such as the fifth sub-partition and the sixth sub-partition) of the static partition (B), and writes the multiple upgrade packages The data in the package used to upgrade the dynamic sub-partition is written into the virtual dynamic partition.
示例性的,以多个组件是version组件和preload组件为例。version组件包括vbmeta_version分区(属于静态分区的子分区)和version分区(属于动态分区的子分区),preload组件包括vbmeta_preload分区(属于静态分区的子分区)和preload分区(属于动态分区的子分区)。相应的,设备在数据更新时,将version升级包中vbmeta_version分区的数据和preload升级包中vbmeta_preload分区的数据写入静态分区(B)的相应分区中。例如,将vbmeta_version分区的数据写入/dev/block/by-name/vbmeta_version_b目录下,将vbmeta_preload分区的数据写入/dev/block/by-name/vbmeta_preload_b目录下,其中,目录中的后缀_b对应静态分区(B)。以及,将version升级包中version分区的数据和preload升级包中preload分区的数据以cow文件写入虚拟动态分区中。例如,将version分区的数据写入到虚拟动态分区中名为version_b_cow_img的cow文件中,将preload分区的数据写入到虚拟动态分区中名为preload_b_cow_img的cow文件中,同样的,文件名中的后缀_b对应静态分区(B)。Exemplarily, the multiple components are a version component and a preload component as an example. The version component includes a vbmeta_version partition (a sub-partition belonging to a static partition) and a version partition (a sub-partition belonging to a dynamic partition), and the preload component includes a vbmeta_preload partition (a sub-partition belonging to a static partition) and a preload partition (a sub-partition belonging to a dynamic partition). Correspondingly, when the data is updated, the device writes the data of the vbmeta_version partition in the version upgrade package and the data of the vbmeta_preload partition in the preload upgrade package into corresponding partitions of the static partition (B). For example, write the data of the vbmeta_version partition into the /dev/block/by-name/vbmeta_version_b directory, and write the data of the vbmeta_preload partition into the /dev/block/by-name/vbmeta_preload_b directory, where the suffix _b in the directory Corresponds to the static partition (B). And, write the data of the version partition in the version upgrade package and the data of the preload partition in the preload upgrade package to the virtual dynamic partition as a cow file. For example, write the data of the version partition to the cow file named version_b_cow_img in the virtual dynamic partition, and write the data of the preload partition to the cow file named preload_b_cow_img in the virtual dynamic partition. Similarly, the suffix in the file name _b corresponds to the static partition (B).
进一步的,由于涉及多个组件的升级,设备在数据更新时,则可以依次将每个升级包中用于升级静态子分区的数据和用于升级动态子分区的数据写入到相应的位置。而不能如图5A所示的升级方案中(S220和S540)仅根据将一个升级包的数据进行写入操作即完成数据更新。Further, since the upgrade of multiple components is involved, when the data is updated, the device may sequentially write the data for upgrading the static sub-partition and the data for upgrading the dynamic sub-partition in each upgrade package to corresponding locations. However, in the upgrade scheme (S220 and S540) shown in FIG. 5A, the data update cannot be completed only by writing the data of one upgrade package.
具体的,设备在向静态分区(B)以及虚拟动态分区写入数据时,可以按照第二预设顺序依次遍历多个升级包,例如,第二预设顺序从前到后依次为base升级包、version升级包和preload升级包。并在遍历到每个升级包时,则从该升级包中获取升级数据写入到相应的位置,完成数据更新。其中,若为静态分区的升级数据,则写入到静态分区(B)中,若为动态分区的升级数据,则以cow文件的形式写入到用户数 据分区(Userdata)下。每完成一个升级包对应的数据写入后,则判断是否还有升级包需要更新,若有,则继续遍历。若没有,则结束S906。Specifically, when the device writes data to the static partition (B) and the virtual dynamic partition, it can sequentially traverse multiple upgrade packages according to the second preset order, for example, the second preset order is the base upgrade package, version upgrade package and preload upgrade package. And when each upgrade package is traversed, the upgrade data is obtained from the upgrade package and written to the corresponding position to complete the data update. Wherein, if it is the upgrade data of the static partition, it is written into the static partition (B), and if it is the upgrade data of the dynamic partition, it is written into the user data partition (Userdata) in the form of a cow file. After completing the writing of the data corresponding to an upgrade package, it is judged whether there are any upgrade packages to be updated, and if so, the traversal is continued. If not, end S906.
在一种具体的实现方式中,设备在获取到多个升级包后,可以将多个升级包按照第二预设顺序放入目标数组中,其中每个升级包为目标数组的一个元素。在S906中,设备可以从数组中依次取元素,在取到一个元素后,则完成相应升级包的数据写入。并且,每完成一个升级包的数据写入后,设备可继续从目标数组中取元素,若能取到元素,则判定还有升级包需要更新,则继续数据写入。反之,若不能取到元素,则判定所有升级包的数据已完成更新,则结束S906。In a specific implementation manner, after acquiring multiple upgrade packages, the device may put the multiple upgrade packages into the target array in a second preset order, where each upgrade package is an element of the target array. In S906, the device can sequentially fetch elements from the array, and after fetching an element, write the data of the corresponding upgrade package. Moreover, after completing the data writing of an upgrade package, the device can continue to fetch elements from the target array. If the elements can be fetched, it is determined that there are upgrade packages that need to be updated, and the data writing continues. On the contrary, if the element cannot be obtained, it is determined that the data of all upgrade packages have been updated, and S906 ends.
以多个组件是version组件和preload组件,第二预设顺序从前到后依次为base升级包、version升级包和preload升级包为例,由于多个组件中不包括base组件,设备则可以仅依次将version升级包和preload升级包放入目标数组中。在S906中,设备第一次可以从目标数组中取出version升级包,将version升级包中vbmeta_version分区的数据写入静态分区(B)的vbmeta_version分区中,将version升级包中version分区的数据以cow文件写入虚拟动态分区中,从而完成针对version升级包的数据更新。然后,设备第二次可以从目标数组中取出preload升级包,并将preload升级包中vbmeta_preload分区的数据写入静态分区(B)的vbmeta_preload分区中,将preload升级包中preload分区的数据以cow文件写入虚拟动态分区中,从而完成针对preload升级包的数据更新。至此,目标数组中的升级包已全部被取出,设备从目标数组中已经取不到升级包了,则可以判定所有升级包均已完成更新,则结束S906。Taking the multiple components as version component and preload component, the second preset order from front to back is base upgrade package, version upgrade package and preload upgrade package as an example. Since the base component is not included in the multiple components, the device can only Put the version upgrade package and preload upgrade package into the target array. In S906, the device can take out the version upgrade package from the target array for the first time, write the data of the vbmeta_version partition in the version upgrade package into the vbmeta_version partition of the static partition (B), and write the data of the version partition in the version upgrade package as cow The file is written into the virtual dynamic partition to complete the data update for the version upgrade package. Then, the device can take out the preload upgrade package from the target array for the second time, write the data of the vbmeta_preload partition in the preload upgrade package into the vbmeta_preload partition of the static partition (B), and write the data of the preload partition in the preload upgrade package to the cow file Write to the virtual dynamic partition to complete the data update for the preload upgrade package. So far, all the upgrade packages in the target array have been taken out, and the device can no longer obtain the upgrade packages from the target array, it can be determined that all upgrade packages have been updated, and S906 ends.
进一步的,在S906中完成数据更新之后,设备对各个子分区更新后的数据进行校验。在本申请实施例中,设备可以根据合并后的manifest来完成校验。Further, after the data update is completed in S906, the device checks the updated data of each sub-partition. In the embodiment of this application, the device can complete the verification according to the merged manifest.
针对静态分区中的各个子分区,设备可以计算操作系统中该子分区升级后的数据的校验值(如哈希值),然后将该校验值与合并后的manifest中相应子分区的目标校验值(如哈希值)比较,如果两者相同,则校验成功。以vbmeta_version分区为例,设备在对vbmeta_version分区完成数据写入后,可以计算/dev/block/by-name/vbmeta_version_b目录下的数据的sha256值,并将该sha256值与合并后的manifest中vbmeta_version分区的sha256值比较,两者相同则校验成功。For each sub-partition in the static partition, the device can calculate the check value (such as hash value) of the upgraded data of the sub-partition in the operating system, and then compare the check value with the target of the corresponding sub-partition in the merged manifest. The verification value (such as the hash value) is compared, and if the two are the same, the verification is successful. Taking the vbmeta_version partition as an example, after the device finishes writing data to the vbmeta_version partition, it can calculate the sha256 value of the data in the /dev/block/by-name/vbmeta_version_b directory, and combine the sha256 value with the vbmeta_version partition in the merged manifest Compare the sha256 values of , if the two are the same, the verification is successful.
针对动态分区中的各个子分区,设备可以计算该子分区的数据和虚拟动态分区中该子分区的cow文件中数据的合成结果的校验值(如哈希值),然后将该哈希值与合并后的manifest中相应子分区的目标校验值(如哈希值)比较,如果两者相同,则校验成功。以version分区为例,设备在向虚拟动态分区中名为version_b_cow_img的cow文件中写入version分区的升级数据后,可以计算动态分区中version分区的数据和虚拟动态分区中名为version_b_cow_img的cow文件中数据的合成结果的sha256值,并将该sha256值与合并后的manifest中version分区的sha256值比较,两者相同则校验成功。For each sub-partition in the dynamic partition, the device can calculate the check value (such as hash value) of the result of combining the data of the sub-partition and the data in the cow file of the sub-partition in the virtual dynamic partition, and then the hash value Compared with the target verification value (such as hash value) of the corresponding sub-partition in the merged manifest, if the two are the same, the verification is successful. Taking the version partition as an example, after the device writes the upgrade data of the version partition to the cow file named version_b_cow_img in the virtual dynamic partition, it can calculate the data of the version partition in the dynamic partition and the cow file named version_b_cow_img in the virtual dynamic partition. The sha256 value of the synthesis result of the data, and compare the sha256 value with the sha256 value of the version partition in the merged manifest. If the two are the same, the verification is successful.
S907、将设备的启动顺序由从静态分区(A)启动变更为从静态分区(B)启动。S907. Change the boot sequence of the device from booting from the static partition (A) to booting from the static partition (B).
S908、设备重启。S908. The device restarts.
S909、设备依次加载基础分区(Common)、静态分区(B),从静态分区(B)启动。S909. The device sequentially loads the basic partition (Common) and the static partition (B), and starts from the static partition (B).
此时从静态分区(B)启动升级后的操作系统,也可以称为第二操作系统。At this time, the upgraded operating system is started from the static partition (B), which may also be called the second operating system.
S910、设备根据调整后的slot1和cow文件的索引,加载动态分区(Super)以及用户数据分区(Userdata)中虚拟动态分区的cow文件。S910. The device loads the dynamic partition (Super) and the cow file of the virtual dynamic partition in the user data partition (Userdata) according to the adjusted slot1 and the index of the cow file.
本申请实施例中,调整后的slot1中包括base组件、version组件和preload组件对应的子分区描述组。因此,设备读取该调整后的slot1中的子分区描述组时,可以获取到动态分区中所有子分区的地址(Extents)项。以及,cow文件的索引中仅包括多个组件(即此次需要升级的组件)包括的子分区对应的cow文件的索引。因此,设备读取该cow文件的索引,可以仅获取到动态分区中升级的所有子分区对应的cow文件,即第一升级数据和第二升级数据。In the embodiment of the present application, the adjusted slot1 includes sub-partition description groups corresponding to the base component, the version component, and the preload component. Therefore, when the device reads the sub-partition description group in the adjusted slot1, it can obtain address (Extents) items of all sub-partitions in the dynamic partition. And, the index of the cow file only includes the index of the cow file corresponding to the subpartitions included in multiple components (that is, the components that need to be upgraded this time). Therefore, the device reads the index of the cow file, and can only obtain the cow files corresponding to all the upgraded sub-partitions in the dynamic partition, that is, the first upgrade data and the second upgrade data.
S911、设备成功启动,进入用户交互界面。S911. The device is successfully started and enters a user interaction interface.
S912、设备将虚拟动态分区的数据落盘到动态分区(Super)。S912. The device puts the data of the virtual dynamic partition into the dynamic partition (Super).
另外,图9所示实施例中未详细说明的部分,可参见前文图5A所示实施例的说明,此处将不再赘述。In addition, for parts not described in detail in the embodiment shown in FIG. 9 , reference may be made to the description of the embodiment shown in FIG. 5A above, and details will not be repeated here.
采用图9所示实施例的方案,设备在获取到多个组件的升级包后,可以针对多个升级包进行处理,完成对多个组件的升级。如此,可以灵活满足至少两个组件需要升级的需求。Using the solution of the embodiment shown in FIG. 9 , after obtaining the upgrade packages of multiple components, the device can process the multiple upgrade packages to complete the upgrade of the multiple components. In this way, the requirement that at least two components need to be upgraded can be flexibly met.
进一步的,设备可以将调整前的slot1中的子分区描述组作为调整slot1和创建cow文件的索引的基础数据,然后通过增删改查等修改操作,来得到调整后的slot1和cow文件的索引。具体的,参见图12,在图9所示的流程中S904和S905之前,还包括S1200:Further, the device can use the pre-adjusted subpartition description group in slot1 as the basic data for adjusting slot1 and creating the index of the cow file, and then obtain the adjusted slot1 and the index of the cow file through modification operations such as addition, deletion, modification, and query. Specifically, referring to FIG. 12, before S904 and S905 in the process shown in FIG. 9, S1200 is also included:
S1200、设备将静态分区(B)对应的slot1中的子分区描述组分别存到第一临时对象和第一文件中。S1200. The device stores the subpartition description group in slot1 corresponding to the static partition (B) into the first temporary object and the first file, respectively.
其中,第一临时对象(如target_metadata)是update engine进程创建的临时对象,用于调整slot1。第一文件(如lp_metadata)是update engine在基础分区(common)的元数据(metadata)下创建的文件,用于创建cow文件的索引。为了方便说明,也可以将第一文件称为目标文件。Wherein, the first temporary object (such as target_metadata) is a temporary object created by the update engine process, and is used to adjust slot1. The first file (such as lp_metadata) is a file created by the update engine under the metadata (metadata) of the basic partition (common), and is used to create the index of the cow file. For convenience of description, the first file may also be referred to as a target file.
具体的,设备可以将静态分区(B)对应的slot1(此时为调整前的slot1)中的子分区描述组复制到第一临时对象和第一文件中,以分别作为调整slot1的基础数据和创建cow文件的索引的基础数据。Specifically, the device may copy the sub-partition description group in the slot1 corresponding to the static partition (B) (slot1 before adjustment at this time) to the first temporary object and the first file, as the basic data and the first file for adjusting slot1, respectively. The basic data for creating the index of the cow file.
继续参见图12,图9中的S904进一步包括S1201和S1202:Continuing to refer to FIG. 12, S904 in FIG. 9 further includes S1201 and S1202:
S1201、设备根据合并后的manifest中的动态分区信息,调整第一临时对象中的数据。其中,在调整第一临时对象中的数据的过程中,设备不删除其他组件包括的子分区的子分区描述组,其他组件是除多个组件之外的组件。S1201. The device adjusts data in the first temporary object according to the dynamic partition information in the merged manifest. Wherein, during the process of adjusting the data in the first temporary object, the device does not delete the subpartition description group of the subpartitions included in other components, and the other components are components other than the plurality of components.
关于S1201调整第一临时对象中的数据的具体实现,可参见前文S904中调整slot1的说明,此处不再赘述。For the specific implementation of adjusting the data in the first temporary object in S1201, refer to the description of adjusting slot1 in S904 above, which will not be repeated here.
S1202、设备将调整后第一临时对象中的数据更新到slot1中,得到调整后的slot1。S1202. The device updates the adjusted data in the first temporary object to slot1 to obtain the adjusted slot1.
具体的,设备可以将调整后第一临时对象中的数据写入到slot1中,覆盖slot1中的原始数据,从而得到调整后的slot1。并且,在将调整后第一临时对象中的数据写入到slot1中,则释放该第一临时对象。Specifically, the device may write the adjusted data in the first temporary object into slot1 to overwrite the original data in slot1, so as to obtain the adjusted slot1. And, after the adjusted data in the first temporary object is written into slot1, the first temporary object is released.
经过上述S1201和S1202,设备在第一临时对象中完成对slot1的调整,而不直接对slot1进行调整。如此,调整的过程并不直接针对slot1,从而可以避免调整过程影响操作系统的运行。After the above S1201 and S1202, the device completes the adjustment of the slot1 in the first temporary object, instead of directly adjusting the slot1. In this way, the adjustment process does not directly target slot1, thereby preventing the adjustment process from affecting the operation of the operating system.
继续参见图12,图9中的S905进一步包括S1203和S1204:Continuing to refer to FIG. 12, S905 in FIG. 9 further includes S1203 and S1204:
S1203、设备根据合并后的manifest中的动态分区信息,调整第一文件中的数据。其中,在调整第一文件中的数据的过程中,设备会删除其他组件包括的子分区的子分区描述组,其他组件是除多个组件之外的组件。S1203. The device adjusts the data in the first file according to the dynamic partition information in the merged manifest. Wherein, during the process of adjusting the data in the first file, the device deletes the subpartition description group of the subpartitions included in other components, and the other components are components other than the multiple components.
仍以多个组件是version组件和preload组件为例,则合并后的manifest中的动态分区信息涉及的子分区为version分区和preload分区,其他组件为base组件。若第一文件的基础数据如图13中的(a)所示,则设备在调整第一文件中的数据时,会将base组件包括的子分区(例如,system、product等)的子分区描述组删除。在删除后,剩下的数据则如图13中的(b)所示,仅剩下version分区和preload分区的子分区描述组。Still taking the multiple components as the version component and the preload component as an example, the sub-partitions involved in the dynamic partition information in the merged manifest are the version partition and the preload partition, and the other components are the base components. If the basic data of the first file is shown in (a) in Figure 13, when the device adjusts the data in the first file, it will describe the sub-partitions of the sub-partitions (such as system, product, etc.) included in the base component Group deletion. After deletion, the remaining data is as shown in (b) in Figure 13, only the sub-partition description groups of the version partition and the preload partition remain.
S1204、设备根据调整后第一文件中的数据生成cow文件的索引。S1204. The device generates an index of the cow file according to the adjusted data in the first file.
设备可以根据第一文件中剩余的描述组中名称项的值,以及cow文件的命名规则来生成cow文件的文件名,作为cow文件的索引,具体可参见前文S904中的说明。为了方便说明,可以将生成cow文件的文件名称为第一文件名,该第一文件名与多个组件涉及的动态分区的子分区对应。The device can generate the file name of the cow file according to the value of the name item in the remaining description group in the first file and the naming rule of the cow file, and use it as an index of the cow file. For details, refer to the description in S904 above. For the convenience of description, the file name of the generated cow file may be called the first file name, and the first file name corresponds to the sub-partition of the dynamic partition involved by multiple components.
经过上述S1203和S1204,设备以调整前slot1中的数据作为创建cow文件的索引的基础数据,则可以通过简单的增删改查来完成索引的创建。After the above S1203 and S1204, the device uses the data in slot1 before adjustment as the basic data for creating the index of the cow file, and then the creation of the index can be completed through simple addition, deletion, modification and query.
进一步的,在创建得到cow文件的索引后,设备可以进一步根据该索引在用户数据分区(userdata)下创建空的cow文件(也可以称为初始cow文件),以用于存储升级数据。其中,创建空的cow文件,可以理解为前文中的创建虚拟动态分区。具体的,如图14所示,图9中的S906进一步包括S1400和S1401:Further, after the index of the cow file is created, the device may further create an empty cow file (also called an initial cow file) under the user data partition (userdata) according to the index to store the upgrade data. Among them, creating an empty cow file can be understood as creating a virtual dynamic partition in the previous article. Specifically, as shown in Figure 14, S906 in Figure 9 further includes S1400 and S1401:
S1400、设备根据cow文件的索引在用户数据分区(userdata)下创建空的cow文件。S1400. The device creates an empty cow file under the user data partition (userdata) according to the index of the cow file.
cow文件的索引中,记录有动态分区中需要升级的各个子分区的相关信息,如子分区的名字、子分区对应的cow文件的名字等。设备根据该相关信息,可以生成与动态分区中需要升级的各个子分区对应的空的cow文件。示例性的,cow文件的索引中记录有分区名字“version”,设备根据cow文件的命名规则,则可以生成version分区对应的cow文件的名字为:version_b_cow_img。其中,后缀_b对应静态分区(B),则可以在从静态分区(B)重启时读取以加载动态分区。然后,设备在用户数据分区(userdata)下创建名为version_b_cow_img的空的cow文件,并根据version分区的大小设置cow文件占用的空间大小,以为存储升级数据留足空间。其中,设备可以根据manifest中version分区大小而获取到version分区的大小。The index of the cow file records the relevant information of each sub-partition that needs to be upgraded in the dynamic partition, such as the name of the sub-partition and the name of the cow file corresponding to the sub-partition. According to the relevant information, the device can generate an empty cow file corresponding to each sub-partition to be upgraded in the dynamic partition. Exemplarily, the partition name "version" is recorded in the index of the cow file, and the device can generate the name of the cow file corresponding to the version partition as: version_b_cow_img according to the naming rules of the cow file. Among them, the suffix _b corresponds to the static partition (B), and can be read to load the dynamic partition when restarting from the static partition (B). Then, the device creates an empty cow file named version_b_cow_img under the user data partition (userdata), and sets the space occupied by the cow file according to the size of the version partition to leave enough space for storing the upgrade data. Wherein, the device can obtain the size of the version partition according to the size of the version partition in the manifest.
在一些实施例中,cow文件的索引中包括cow文件的名字,具体可参见前文S905中的说明。在本实施例中,设备可直接在用户数据分区(userdata)下创建以名字命名的cow文件,并根据分区的大小设置cow文件占用的空间大小。为了方便说明,可以将根据第一文件名生成的初始cow文件称为第一初始cow文件,将根据第二文件名生 成的初始cow文件称为第二初始cow文件。应明确,若第一子分区为多个,则第一文件名为多个,相应的,第一初始cow文件也为多个。同理,若第二子分区为多个,则第二文件名为多个,相应的,第二初始cow文件也为多个。In some embodiments, the index of the cow file includes the name of the cow file. For details, refer to the description in S905 above. In this embodiment, the device can directly create a named cow file under the user data partition (userdata), and set the space occupied by the cow file according to the size of the partition. For convenience of description, the initial cow file generated according to the first file name can be called the first initial cow file, and the initial cow file generated according to the second file name can be called the second initial cow file. It should be clear that if there are multiple first sub-partitions, then there are multiple first file names, and correspondingly, there are also multiple first initial cow files. Similarly, if there are multiple second sub-partitions, then there are multiple second file names, and correspondingly, there are also multiple second initial cow files.
需要在此说明的是,S1400中创建空的cow文件的时机并不以图14所示的顺序为限。实际实施时,可以在创建得到cow文件的索引后,随时创建空的cow文件。并且,设备在获取到升级包后,直至重启的过程中,都是在正常运行的,则一直有运行数据在占用用户数据分区(userdata)的空间。因此,越早创建空的cow文件,则可以越早占用存储升级数据的空间。如此,可以避免因设备运行占用用户数据分区(userdata)的空间过多,而导致用于存储升级数据的空间不足。It should be noted here that the timing of creating an empty cow file in S1400 is not limited to the sequence shown in FIG. 14 . In actual implementation, an empty cow file can be created at any time after the index of the cow file is created. Moreover, after the device obtains the upgrade package, it is running normally until it is restarted, and there is always running data occupying the space of the user data partition (userdata). Therefore, the sooner an empty cow file is created, the sooner it can occupy space for storing upgrade data. In this way, too much space occupied by the user data partition (userdata) due to device operation can be avoided, resulting in insufficient space for storing upgrade data.
S1401、设备依次根据多个升级包针对静态分区(B)进行数据写入操作以升级静态分区,以及在空的cow文件中写入动态分区(Super)的升级数据。其中,一个空的cow文件中写入动态分区(Super)中一个子分区的升级数据。S1401. The device sequentially performs data writing operations on the static partition (B) according to multiple upgrade packages to upgrade the static partition, and writes the upgrade data of the dynamic partition (Super) in an empty cow file. Among them, the upgrade data of a sub-partition in the dynamic partition (Super) is written in an empty cow file.
例如,在第一初始cow文件中写入第一升级数据,在第二初始cow文件中写入第二升级数据。For example, the first upgrade data is written in the first initial cow file, and the second upgrade data is written in the second initial cow file.
采用本实施例,设备根据cow文件的索引来创建空的cow文件,以占用存储升级数据的空间,避免设备运行而导致没有足够的空间存储升级数据。With this embodiment, the device creates an empty cow file according to the index of the cow file, so as to occupy the space for storing the upgrade data, so as to avoid insufficient space to store the upgrade data due to the operation of the device.
如图15所示,在一种场景中,在设备出厂后,静态分区(A)和静态分区(B)中初始的数据是相同的,vbmeta_version分区的初始数据都是X1,vbmeta_preload分区的初始数据都是Y1,其他子分区的初始数据都是Z1。若设备当前从静态分区(A)启动,且当前需要升级version组件和preload组件,则设备在对静态分区进行数据更新时(如S906中),会更新静态分区(B)中的vbmeta_version分区的数据,得到更新的数据X2,以及更新静态分区(B)中的vbmeta_preload分区的数据,得到更新的数据Y2。此时,静态分区(A)和静态分区(B)中vbmeta_version分区的数据则不相同了。此后,当设备当前从静态分区(B)启动,且当前需要升级preload组件和base组件,则设备在对静态分区进行数据更新时(如S906中),会更新静态分区(B)中的vbmeta_preload分区的数据,得到更新的数据Y3,以及更新静态分区(B)中的system、system_ext分区(base组件包括的子分区)的数据,得到更新的数据Z2。此时,虽然完成了preload组件和base组件包括的子分区的数据更新,但是当前不需要升级的version组件包括的vbmeta_version分区的数据还是初始的数据X1,而不是此前更新后的X2。如此,则会导致静态分区(B)中的数据不是对应最新版本的数据。As shown in Figure 15, in one scenario, after the device leaves the factory, the initial data in the static partition (A) and the static partition (B) are the same, the initial data of the vbmeta_version partition is X1, and the initial data of the vbmeta_preload partition All are Y1, and the initial data of other sub-partitions are all Z1. If the device is currently started from the static partition (A), and the version component and preload component need to be upgraded, the device will update the data of the vbmeta_version partition in the static partition (B) when updating the data of the static partition (such as in S906) , get the updated data X2, and update the data of the vbmeta_preload partition in the static partition (B), and get the updated data Y2. At this time, the data of the vbmeta_version partition in the static partition (A) and the static partition (B) are different. Afterwards, when the device is currently started from the static partition (B), and the preload component and the base component need to be upgraded, the device will update the vbmeta_preload partition in the static partition (B) when performing data update on the static partition (such as in S906) The updated data Y3 is obtained, and the data of the system and system_ext partitions (subpartitions included in the base component) are updated in the static partition (B), and the updated data Z2 is obtained. At this time, although the data update of the sub-partitions included in the preload component and the base component has been completed, the data of the vbmeta_version partition included in the version component that does not need to be upgraded is still the initial data X1, not the previously updated X2. In this way, the data in the static partition (B) will not correspond to the latest version of the data.
针对该场景,在一些实施例中,若多个组件是base组件、version组件和preload组件中的两个,且设备当前从静态分区(A)启动,则设备在获取到多个升级包后,可以将静态分区(A)中其他组件(即当前无需升级的组件)包括的子分区的最新数据同步给静态分区(B)。或者,设备当前从静态分区(B)启动,则设备在获取到多个升级包后,可以将静态分区(B)中其他组件(即当前无需升级的组件)包括的子分区的最新数据同步给静态分区(A)。从而使无需升级的组件包括的子分区的最新数据,在静态分区(A)和静态分区(B)之间保持同步。具体的,在设备当前从静态分区(A)启动时,如图16所示,在图9中S902之后、S906之前,还包括S1600和S1601:For this scenario, in some embodiments, if the multiple components are two of the base component, the version component and the preload component, and the device is currently started from the static partition (A), after the device obtains multiple upgrade packages, The latest data of sub-partitions included in other components in the static partition (A) (that is, components that do not need to be upgraded currently) can be synchronized to the static partition (B). Or, if the device is currently booted from the static partition (B), after the device obtains multiple upgrade packages, it can synchronize the latest data of sub-partitions included in other components in the static partition (B) (that is, components that do not need to be upgraded currently) to Static partition (A). Therefore, the latest data of the sub-partitions included in the components that do not need to be upgraded are kept synchronized between the static partition (A) and the static partition (B). Specifically, when the device is currently started from the static partition (A), as shown in Figure 16, after S902 and before S906 in Figure 9, S1600 and S1601 are also included:
S1600、设备检测多个组件是否包括基础(base)组件、定制(version)组件和货架化(preload)组件。若是,则执行S906;若否,则执行S1601或者S1602。S1600. The device detects whether the multiple components include a base (base) component, a custom (version) component, and a shelf (preload) component. If yes, execute S906; if not, execute S1601 or S1602.
若多个组件包括base组件、version组件和preload组件,则表明所有组件均需要升级。相应的,所有组件包括的子分区都需要更新。所有组件当然就涉及静态分区(B)的所有子分区,即静态分区(B)的所有子分区都需要更新,而不存在无需更新的子分区(如第七子分区)。该情况下,设备无需先在静态分区(A)和静态分区(B)之间同步最新的数据,而可以直接遍历多个升级包,进行数据更新。If multiple components include base component, version component and preload component, it indicates that all components need to be upgraded. Correspondingly, all component subpartitions need to be updated. Of course, all the components involve all sub-partitions of the static partition (B), that is, all sub-partitions of the static partition (B) need to be updated, and there are no sub-partitions (such as the seventh sub-partition) that do not need to be updated. In this case, the device does not need to synchronize the latest data between the static partition (A) and the static partition (B), but can directly traverse multiple upgrade packages to update data.
若多个组件不包括base组件、version组件和preload组件的全部,则表明只有部分组件需要升级。即静态分区(B)中只有部分子分区需要更新。换言之,静态分区(B)中还有部分子分区(如第七子分区)无需更新。该情况下,设备则需要在静态分区(A)和静态分区(B)之间同步最新的数据。If multiple components do not include all of the base component, version component, and preload component, it indicates that only some components need to be upgraded. That is, only some sub-partitions in the static partition (B) need to be updated. In other words, some sub-partitions (such as the seventh sub-partition) in the static partition (B) do not need to be updated. In this case, the device needs to synchronize the latest data between the static partition (A) and the static partition (B).
S1601、若多个组件包括基础(base)组件,设备将静态分区(A)中其他组件包括的子分区的数据同步至静态分区(B)中的相应子分区。其中,其他组件是多个组件之外的组件。S1601. If multiple components include a base (base) component, the device synchronizes data of sub-partitions included in other components in the static partition (A) to corresponding sub-partitions in the static partition (B). Wherein, other components are components other than the plurality of components.
其中,多个组件包括base组件的情况有如下两种:多个组件是base组件和version组件,或者base组件和preload组件。相应的,除该多个组件之外的其他组件则不包括base组件。There are two cases where multiple components include the base component: the multiple components are the base component and the version component, or the base component and the preload component. Correspondingly, other components except the plurality of components do not include the base component.
通常情况下,在静态分区的所有数据中,base组件包括的数据占据大部分,而version组件和preload组件包括的数据仅仅是一小部分。因此,在多个组件包括base组件时,设备可以将静态分区(A)中其他组件包括的子分区(第七子分区)的数据同步至静态分区(B)中的相应子分区内。示例性的,多个组件是base组件和preload组件,则其他组件是version组件,设备可以将静态分区(A)的vbmeta_version分区(即vbmeta_version_a)中的数据同步到静态分区(B)的vbmeta_version分区(即vbmeta_version_b)。如此,设备可以通过小部分数据的同步而实现静态分区中当前无需升级的子分区数据的同步。Usually, among all the data in the static partition, the data included in the base component occupies most of the data, while the data included in the version component and the preload component is only a small part. Therefore, when multiple components include the base component, the device can synchronize the data of the sub-partition (seventh sub-partition) included in other components in the static partition (A) to the corresponding sub-partition in the static partition (B). Exemplarily, multiple components are base components and preload components, and other components are version components, and the device can synchronize data in the vbmeta_version partition (ie vbmeta_version_a) of the static partition (A) to the vbmeta_version partition ( That is vbmeta_version_b). In this way, the device can synchronize the data of sub-partitions that do not need to be upgraded currently in the static partition through the synchronization of a small part of data.
为了方便说明,可以将静态分区(B)中涉及的数据量较大的子分区,例如,静态分区(B)中基础(base)组件涉及的子分区,称为预设子分区。For convenience of description, a sub-partition involving a large amount of data in the static partition (B), for example, a sub-partition related to a base component in the static partition (B), may be called a preset sub-partition.
S1602、若多个组件不包括基础(base)组件,设备将静态分区(A)中所有子分区的数据同步至静态分区(B)中的相应子分区。S1602. If the multiple components do not include a base (base) component, the device synchronizes data of all sub-partitions in the static partition (A) to corresponding sub-partitions in the static partition (B).
多个组件是version组件和preload组件,则多个组件不包括base组件。相应的,其他组件则是base组件。即,静态分区中的大部分数据都无需升级。因此,在多个组件不包括base组件时,设备可以直接将静态分区(A)中所有子分区的数据同步到静态分区(B)的相应子分区中。如此,在大部分数据无需升级时,设备无需从静态分区(A)去剔除不需要同步的数据,而可以通过全部同步来简化同步的步骤。Multiple components are version components and preload components, and multiple components do not include base components. Correspondingly, other components are base components. That is, most data in static partitions does not need to be upgraded. Therefore, when multiple components do not include the base component, the device can directly synchronize the data of all sub-partitions in the static partition (A) to the corresponding sub-partitions of the static partition (B). In this way, when most of the data does not need to be updated, the device does not need to remove data that does not need to be synchronized from the static partition (A), but can simplify the steps of synchronization by synchronizing all.
需要在此说明的是,S1600-S1602的执行时机并不以图16所示为限。实际实施时,设备可以在S902-S906之间的任意时刻执行上述S1600-S1602,本申请实施例对此不作具体限定。It should be noted here that the execution timings of S1600-S1602 are not limited to those shown in FIG. 16 . During actual implementation, the device may execute the foregoing S1600-S1602 at any time between S902-S906, which is not specifically limited in this embodiment of the present application.
采用本实施例,设备可以将静态分区(A)中当前无需升级的子分区的最新数据同步到静态分区(B)中,然后对静态分区(B)进行数据更新。如此,可以保证静态 分区(B)中各个子分区的数据都是最新的。Using this embodiment, the device can synchronize the latest data of sub-partitions that do not need to be upgraded in the static partition (A) to the static partition (B), and then update the data of the static partition (B). In this way, it can be guaranteed that the data of each sub-partition in the static partition (B) is up-to-date.
进一步的,在数据更新的过程中(如图9中的S906中),设备可以显示数据更新的更新进度,例如,50%、80%等。当更新进度达到100%,则表示多个组件的数据更新完成。如图17所示,在设备执行图9中的S906的过程中,还包括S1700和S1701:Further, during the data updating process (as in S906 in FIG. 9 ), the device may display the updating progress of the data updating, for example, 50%, 80% and so on. When the update progress reaches 100%, it means that the data update of multiple components is completed. As shown in Figure 17, during the process of the device executing S906 in Figure 9, S1700 and S1701 are also included:
S1700、设备记录数据更新当前针对的组件的写入进度,以及记录数据更新当前针对的组件的排序数。S1700. The device records the writing progress of the component currently targeted for data update, and records the sequence number of the component currently targeted for data update.
其中,写入进度可以反映当前针对的组件已完成写入的数据量,也可以称为保存进度。排序数可反映当前针对的组件在多个组件中更新时的排序位数。在一种具体的实现方式中,设备可以在用户数据分区(Userdata)中/data/misc/update_log/perfs目录下记录上述写入进度和排序数(即payload_id,也可以称为遍历序数)。Wherein, the writing progress may reflect the amount of data written by the currently targeted component, and may also be referred to as saving progress. The sort number reflects the number of sort bits when the currently targeted component is updated in multiple components. In a specific implementation manner, the device may record the above-mentioned writing progress and sorting number (that is, payload_id, which may also be called the traversal sequence number) in the directory /data/misc/update_log/perfs in the user data partition (Userdata).
以多个升级包是version升级包和preload升级包,且第二预设顺序从前到后依次为base升级包、version升级包和preload升级包为例,则设备首先针对version组件进行数据更新,此时数据更新当前针对的组件为version组件,version组件为此次数据更新的第一个组件,则排序数为1。并且,随着设备不断写入数据,设备可实时更新针对version组件已完成写入的数据量,即针对version组件的写入进度。在针对version组件已完成写入的数据量达到version组件需要写入的数据总量后,设备开始针对preload组件进行数据更新,此时数据更新当前针对的组件为preload组件,preload组件为此次数据更新的第二个组件,则排序数更新为2。同样的,随着设备不断写入数据,设备可实时更新针对preload组件已完成写入的数据量,即针对preload组件的写入进度。Taking the multiple upgrade packages as version upgrade package and preload upgrade package, and the second preset order from front to back is base upgrade package, version upgrade package and preload upgrade package as an example, then the device first performs data update for the version component. The component currently targeted by the current data update is the version component, and the version component is the first component of this data update, so the sort number is 1. Moreover, as the device continues to write data, the device can update in real time the amount of data written to the version component, that is, the writing progress of the version component. After the amount of data written for the version component reaches the total amount of data that the version component needs to write, the device starts to update the data for the preload component. At this time, the current data update is for the preload component, and the preload component is the The second component of the update, the sort count is updated to 2. Similarly, as the device continues to write data, the device can update in real time the amount of data written to the preload component, that is, the writing progress of the preload component.
S1701、设备根据写入进度和排序数计算更新进度,显示该更新进度。S1701. The device calculates the update progress according to the write progress and the sort number, and displays the update progress.
其中,更新进度是指针对多个组件已完成写入的数据量,占多个组件需要写入的数据总量的百分比。将写入进度对应的已完成写入的数据量记为p,排序数记为n,则更新进度q可通过如下公式计算得到:q=[SUM(前n-1个组件需要写入的数据量)+p]/SUM(多个组件需要写入的数据量)。Wherein, the update progress refers to the amount of data that has been written for multiple components, as a percentage of the total amount of data that needs to be written by multiple components. Record the amount of written data corresponding to the writing progress as p, and the sorting number as n, then the update progress q can be calculated by the following formula: q=[SUM(the data that needs to be written in the first n-1 components Amount)+p]/SUM (amount of data to be written by multiple components).
仍以S1700中的举例来说,假设写入进度为70条数据,排序数为2,version组件需要写入的数据量为200条数据,preload组件需要写入的数据量为100条数据,那么更新进度q=(200+70)/(200+100)=90%。Still taking the example in S1700, assuming that the writing progress is 70 pieces of data, the sorting number is 2, the amount of data to be written by the version component is 200 pieces of data, and the amount of data to be written by the preload component is 100 pieces of data, then Update progress q=(200+70)/(200+100)=90%.
在一种具体的实现方式中,设备可以根据合并后的manifest中获取每个组件需要写入的数据总量。具体的,合并后的manifest中,每条分区信息中包括升级数据在相应升级安装包中的位置,该位置包括起始位置的偏移量、结束位置的偏移量以及数据量的大小。其中,数据量的大小即为相应子分区的数据量。之后,设备将同一组件包括的多个子分区的数据量求和,则可得到相应组件的数据总量。In a specific implementation manner, the device can obtain the total amount of data to be written by each component according to the merged manifest. Specifically, in the merged manifest, each piece of partition information includes the location of the upgrade data in the corresponding upgrade installation package, and the location includes the offset of the start location, the offset of the end location, and the size of the data volume. Wherein, the size of the data volume is the data volume of the corresponding sub-partition. Afterwards, the device sums the data volumes of multiple sub-partitions included in the same component to obtain the total data volume of the corresponding component.
采用本实施例,设备可以在多个组件数据更新的过程中,准确的显示更新进度。With this embodiment, the device can accurately display the update progress during the update process of multiple component data.
更进一步的,如图18中的(a)所示,在一些场景中,设备按照base组件、version组件、preload组件的顺序更新数据,并且在更新version组件的过程中,设备掉电。在设备重启后,若再次从base组件开始更新数据,则可能导致数据重复写入,影响升级。并且,还会影响延长升级时长。Furthermore, as shown in (a) in Figure 18, in some scenarios, the device updates data in the order of the base component, version component, and preload component, and the device is powered off during the update of the version component. After the device is restarted, if the data is updated from the base component again, data may be written repeatedly, affecting the upgrade. In addition, it will also affect the extension of the upgrade time.
基于该问题,在一些实施例中,设备可以根据前述图17所示实施例中记录的写入 进度和排序数,从掉电时对应的更新进度继续开始更新。具体的,当设备重启后,设备可以确定是否为在更新数据的过程中掉电后重启的情况,若是,则确定需要继续执行(resume)数据更新。设备则可以根据排序数定位到掉电时正在更新的组件,也可以理解为定位到正在写入的目标升级包。如图18中的(b)所示,根据排序数2定位到version组件,即正在进行version升级包的数据写入。然后根据写入进度定位到掉电时正在更新的组件中正在更新的数据(目标数据)。如图18中的(c)所示,根据写入进度80条数据定位到掉电时已完成version组件中已写入80条数据的位置。最后,设备可以从定位的位置继续更新。如此,可以提高异常掉电处理的灵活性。Based on this problem, in some embodiments, the device can continue to update from the corresponding update progress at the time of power failure according to the write progress and sorting number recorded in the embodiment shown in the foregoing Figure 17. Specifically, after the device is restarted, the device may determine whether it is a case of restarting after a power failure during the process of updating data, and if so, determine that data update needs to be continued (resume). The device can locate the component being updated when the power is off according to the sort number, and it can also be understood as locating the target upgrade package being written. As shown in (b) in Figure 18, the version component is located according to the sort number 2, that is, the data writing of the version upgrade package is in progress. Then locate the data (target data) being updated in the component being updated when the power is off according to the writing progress. As shown in (c) in FIG. 18 , according to the write progress of 80 pieces of data, locate the position where 80 pieces of data have been written in the version component when the power is turned off. Finally, the device can continue updating from where it was located. In this way, the flexibility of abnormal power-down processing can be improved.
进一步的,在落盘(如图9中的S912)完成后,设备可以将cow文件的索引删除。具体的,如图19所示,在图9中的S912之后,还包括S1900:Further, the device may delete the index of the cow file after the disk transfer (eg, S912 in FIG. 9 ) is completed. Specifically, as shown in FIG. 19, after S912 in FIG. 9, S1900 is also included:
S1900、在虚拟动态分区中的所有数据落盘完成后,设备将cow文件的索引删除。S1900. After all the data in the virtual dynamic partition is placed to the disk, the device deletes the index of the cow file.
在存在至少一个子分区的数据未落盘完成的情况下,设备掉电,则在设备再次重启后,需要再次根据cow文件的索引来加载动态分区。因此,在本实施例中,当基础分区(Common)的元数据(/metadata)中所有子分区的落盘状态信息均由“未落盘(wait for merge)”改为“已落盘(merged)”后,则表明所有数据均已落盘完成,此时则将cow文件的索引删除。如此,设备可以在落盘过程中异常掉电重启的情况下,继续使用cow文件的索引来加载动态分区。When the data of at least one sub-partition has not been transferred to the disk, and the device is powered off, after the device is restarted, the dynamic partition needs to be loaded again according to the index of the cow file. Therefore, in this embodiment, when the transfer status information of all sub-partitions in the metadata (/metadata) of the basic partition (Common) is changed from "wait for merge" to "merged )", it indicates that all the data has been transferred to the disk, and at this time, the index of the cow file will be deleted. In this way, the device can continue to use the index of the cow file to load the dynamic partition in the case of an abnormal power failure and restart during the disk transfer process.
本申请实施例提供了一种电子设备,该电子设备可以包括:存储器和一个或多个处理器。该存储器和处理器耦合。该存储器用于存储计算机程序代码,该计算机程序代码包括计算机指令。当处理器执行计算机指令时,电子设备可执行上述方法实施例中设备执行的各个功能或者步骤。An embodiment of the present application provides an electronic device, and the electronic device may include: a memory and one or more processors. The memory is coupled to the processor. The memory is used to store computer program code comprising computer instructions. When the processor executes the computer instructions, the electronic device can execute various functions or steps performed by the device in the foregoing method embodiments.
本申请实施例还提供一种芯片系统,如图20所示,该芯片系统2000包括至少一个处理器2001和至少一个接口电路2002。处理器2001和接口电路2002可通过线路互联。例如,接口电路2002可用于从其它装置(例如电子设备的存储器)接收信号。又例如,接口电路2002可用于向其它装置(例如处理器2001)发送信号。示例性的,接口电路2002可读取存储器中存储的指令,并将该指令发送给处理器2001。当所述指令被处理器2001执行时,可使得电子设备执行上述实施例中的各个步骤。当然,该芯片系统还可以包含其他分立器件,本申请实施例对此不作具体限定。The embodiment of the present application further provides a chip system, as shown in FIG. 20 , the chip system 2000 includes at least one processor 2001 and at least one interface circuit 2002 . The processor 2001 and the interface circuit 2002 can be interconnected through lines. For example, interface circuit 2002 may be used to receive signals from other devices, such as memory of an electronic device. As another example, the interface circuit 2002 may be used to send signals to other devices (such as the processor 2001). Exemplarily, the interface circuit 2002 can read instructions stored in the memory, and send the instructions to the processor 2001 . When the instructions are executed by the processor 2001, the electronic device may be made to execute various steps in the foregoing embodiments. Of course, the chip system may also include other discrete devices, which is not specifically limited in this embodiment of the present application.
本申请实施例还提供一种计算机存储介质,该计算机存储介质包括计算机指令,当该计算机指令在电子设备上运行时,使得该电子设备执行上述方法实施例中设备执行的各个功能或者步骤。The embodiment of the present application also provides a computer storage medium, the computer storage medium includes computer instructions, and when the computer instructions are run on the electronic device, the electronic device is made to perform various functions or steps performed by the device in the above method embodiments.
本申请实施例还提供一种计算机程序产品,当该计算机程序产品在计算机上运行时,使得该计算机执行上述方法实施例中设备执行的各个功能或者步骤。The embodiments of the present application also provide a computer program product, which, when running on a computer, causes the computer to execute the various functions or steps performed by the device in the above method embodiments.
通过以上实施方式的描述,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。Through the description of the above embodiments, those skilled in the art can clearly understand that for the convenience and brevity of the description, only the division of the above-mentioned functional modules is used as an example for illustration. In practical applications, the above-mentioned functions can be assigned by Completion of different functional modules means that the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,该模块或 单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个装置,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed devices and methods may be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined Or it can be integrated into another device, or some features can be omitted, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
该作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是一个物理单元或多个物理单元,即可以位于一个地方,或者也可以分布到多个不同地方。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The unit described as a separate component may or may not be physically separated, and a component displayed as a unit may be one physical unit or multiple physical units, that is, it may be located in one place, or may be distributed to multiple different places. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
该集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该软件产品存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例该方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated unit is realized in the form of a software function 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, and the software product is stored in a storage medium Among them, several instructions are included to make a device (which may be a single-chip microcomputer, a chip, etc.) or a processor (processor) execute all or part of the steps of the method in various embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes such as U disk, mobile hard disk, read only memory (ROM), random access memory (random access memory, RAM), magnetic disk or optical disk.
以上内容,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以该权利要求的保护范围为准。The above content is only the specific implementation of the application, but the protection scope of the application is not limited thereto, and any changes or replacements within the technical scope disclosed in the application shall be covered within the protection scope of the application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims (17)

  1. 一种操作系统升级方法,其特征在于,应用于电子设备,所述电子设备包括处理器以及存储器,所述存储器包括基础分区、第一静态分区、第二静态分区、动态分区以及用户数据分区,所述动态分区包括第一插槽数据和第二插槽数据,所述动态分区包括多个子分区,所述第一插槽数据包括与所述多个子分区对应的多个第一描述组,所述第二插槽数据包括与所述多个子分区对应的多个第二描述组;A method for upgrading an operating system, characterized in that it is applied to an electronic device, the electronic device includes a processor and a memory, and the memory includes a basic partition, a first static partition, a second static partition, a dynamic partition, and a user data partition, The dynamic partition includes first slot data and second slot data, the dynamic partition includes a plurality of sub-partitions, the first slot data includes a plurality of first description groups corresponding to the plurality of sub-partitions, the The second slot data includes a plurality of second description groups corresponding to the plurality of sub-partitions;
    加载所述基础分区、所述第一静态分区和所述动态分区的数据,以运行第一操作系统,在加载所述动态分区的数据的过程中,读取所述多个第一描述组,基于所述多个第一描述组中地址项的值加载所述动态分区的数据;loading the data of the basic partition, the first static partition, and the dynamic partition to run a first operating system, and during the process of loading the data of the dynamic partition, reading the plurality of first description groups, loading data of the dynamic partition based on values of address items in the plurality of first description groups;
    获取第一升级安装包和第二升级安装包,所述第一升级安装包用于升级第一子分区,所述第二升级安装包用于升级第二子分区,所述第一子分区和所述第二子分区是所述动态分区的子分区,所述第一升级安装包包括第一数据,所述第一数据包括所述第一子分区的分区信息,所述第二升级安装包包括第二数据,所述第二数据包括所述第二子分区的分区信息;Obtain a first upgrade installation package and a second upgrade installation package, the first upgrade installation package is used to upgrade the first sub-partition, the second upgrade installation package is used to upgrade the second sub-partition, the first sub-partition and The second sub-partition is a sub-partition of the dynamic partition, the first upgrade installation package includes first data, the first data includes partition information of the first sub-partition, and the second upgrade installation package including second data, the second data including partition information of the second sub-partition;
    根据第三数据和所述多个第二描述组得到多个第三描述组,所述第三数据中包括所述第一子分区的分区信息和所述第二子分区的分区信息,所述多个第三描述组中包括与所述第一子分区对应的描述组,与第二子分区对应的描述组,和与第三子分区对应的描述组,所述第三子分区是所述动态分区中除所述第一子分区和所述第二子分区之外的子分区;A plurality of third description groups are obtained according to the third data and the plurality of second description groups, the third data includes the partition information of the first sub-partition and the partition information of the second sub-partition, the The multiple third description groups include a description group corresponding to the first sub-division, a description group corresponding to the second sub-division, and a description group corresponding to the third sub-division, the third sub-division being the a sub-partition other than the first sub-partition and the second sub-partition in the dynamic partition;
    重启所述电子设备,加载所述基础分区、所述第二静态分区和所述动态分区的数据,以运行第二操作系统,在加载所述动态分区的数据的过程中,读取所述多个第三描述组中地址项的值,基于所述多个第三描述组中地址项的值加载所述动态分区的数据。Restarting the electronic device, loading the data of the basic partition, the second static partition, and the dynamic partition to run the second operating system, and during the process of loading the data of the dynamic partition, reading the multiple The value of the address item in the third description group, and the data of the dynamic partition is loaded based on the value of the address item in the plurality of third description groups.
  2. 根据权利要求1所述的方法,其特征在于,在所述获取第一升级安装包和第二升级安装包之后,所述方法还包括:The method according to claim 1, characterized in that, after said obtaining the first upgrade installation package and the second upgrade installation package, said method further comprises:
    将所述多个第二描述组写入目标文件中,在所述目标文件中删除与所述第三子分区对应的描述组,生成第一索引。Writing the plurality of second description groups into a target file, deleting the description group corresponding to the third sub-partition in the target file, and generating a first index.
  3. 根据权利要求1或2所述的方法,其特征在于,在所述加载所述基础分区、所述第一静态分区和所述动态分区的数据之后,所述方法还包括:The method according to claim 1 or 2, wherein after loading the data of the basic partition, the first static partition and the dynamic partition, the method further comprises:
    获取第三升级安装包,所述第三升级安装包用于升级第四子分区,所述第四子分区是所述动态分区的子分区,所述第三升级安装包包括第三数据,所述第三数据包括所述第四子分区的分区信息;Obtain a third upgrade installation package, the third upgrade installation package is used to upgrade the fourth sub-partition, the fourth sub-partition is a sub-partition of the dynamic partition, the third upgrade installation package includes third data, the The third data includes partition information of the fourth sub-partition;
    根据所述第三数据和所述多个第二描述组得到所述多个第三描述组,所述第三数据中还包括所述第四子分区的分区信息,所述第三子分区是所述动态分区中除所述第一子分区、所述第二子分区和所述第四子分区之外的子分区。The plurality of third description groups are obtained according to the third data and the plurality of second description groups, the third data further includes partition information of the fourth sub-partition, and the third sub-partition is Subpartitions in the dynamic partition other than the first subpartition, the second subpartition and the fourth subpartition.
  4. 根据权利要求2或3所述的方法,其特征在于,所述第一升级安装包包括第一升级数据,所述第一升级数据用于升级所述第一子分区,所述第二升级安装包包括第二升级数据,所述第二升级数据用于升级所述第二子分区;The method according to claim 2 or 3, wherein the first upgrade installation package includes first upgrade data, the first upgrade data is used to upgrade the first sub-partition, and the second upgrade installation The package includes second upgrade data, and the second upgrade data is used to upgrade the second sub-partition;
    所述方法还包括:The method also includes:
    在所述用户数据分区中保存所述第一升级数据和所述第二升级数据;saving the first upgrade data and the second upgrade data in the user data partition;
    在加载所述动态分区的数据的过程中,读取所述目标文件,基于所述目标文件中的所述第一索引加载所述用户数据分区中的所述第一升级数据和所述第二升级数据。In the process of loading the data of the dynamic partition, read the target file, load the first upgrade data and the second update data in the user data partition based on the first index in the target file Upgrade data.
  5. 根据权利要求4所述的方法,其特征在于,所述在所述目标文件中删除与所述第二子分区对应的描述组,生成第一索引,包括:The method according to claim 4, wherein the deleting the description group corresponding to the second sub-partition in the target file to generate the first index comprises:
    在所述目标文件中删除与所述第三子分区对应的描述组,得到与所述第一子分区对应的描述组和与所述第二子分区对应的描述组,所述与所述第一分区对应的描述组中包括所述第一子分区的名称,所述与所述第二子分区对应的描述组中包括所述第二子分区的名称;Deleting the description group corresponding to the third subdivision in the target file, obtaining the description group corresponding to the first subdivision and the description group corresponding to the second subdivision, and the description group corresponding to the second subdivision. The description group corresponding to a partition includes the name of the first sub-partition, and the description group corresponding to the second sub-partition includes the name of the second sub-partition;
    基于所述第一子分区的名称生成与所述第一子分区对应的第一文件名,基于所述第二子分区的名称生成与所述第二子分区对应的第二文件名,所述第一索引包括所述第一文件名和所述第二文件名。generating a first file name corresponding to the first sub-partition based on the name of the first sub-partition, generating a second file name corresponding to the second sub-partition based on the name of the second sub-partition, the The first index includes the first filename and the second filename.
  6. 根据权利要求5所述的方法,其特征在于,在所述基于所述第一子分区的名称生成与所述第一子分区对应的第一文件名,基于所述第二子分区的名称生成与所述第二子分区对应的第二文件名之后,所述方法还包括:The method according to claim 5, wherein the first file name corresponding to the first sub-partition is generated based on the name of the first sub-partition, and the name of the second sub-partition is generated based on the name of the second sub-partition. After the second file name corresponding to the second sub-partition, the method also includes:
    在所述用户数据分区中创建文件名为所述第一文件名的第一初始cow文件,以及创建文件名为所述第二文件名的第二初始cow文件,所述第一初始cow文件和所述第二初始cow文件中未存储升级数据;Create a first initial cow file with a file name of the first file name in the user data partition, and create a second initial cow file with a file name of the second file name, the first initial cow file and No upgrade data is stored in the second initial cow file;
    所述在所述用户数据分区中保存所述所述第一升级数据和所述第二升级数据,包括:The saving the first upgrade data and the second upgrade data in the user data partition includes:
    在所述第一初始cow文件中保存所述第一升级数据,在所述第二初始cow文件中保存所述第二升级数据。The first upgrade data is saved in the first initial cow file, and the second upgrade data is saved in the second initial cow file.
  7. 根据权利要求1-6中任一项所述的方法,其特征在于,所述第一子分区包括一个或多个子分区,所述第二子分区包括一个或多个子分区,所述第三子分区包括一个或多个子分区。The method according to any one of claims 1-6, wherein the first sub-partition includes one or more sub-partitions, the second sub-partition includes one or more sub-partitions, and the third sub-partition A partition consists of one or more subpartitions.
  8. 根据权利要求4-7中任一项所述的方法,其特征在于,所述第二静态分区包括多个子分区,所述第一升级安装包还包括第三升级数据,所述第三升级数据用于升级第五子分区,所述第二升级安装包还包括第四升级数据,所述第四升级数据用于升级第六子分区,所述第五子分区和所述第六子分区是所述第二静态分区的子分区;The method according to any one of claims 4-7, wherein the second static partition includes a plurality of sub-partitions, the first upgrade installation package further includes third upgrade data, and the third upgrade data For upgrading the fifth sub-partition, the second upgrade installation package further includes fourth upgrade data, the fourth upgrade data is used for upgrading the sixth sub-partition, the fifth sub-partition and the sixth sub-partition are subpartitions of the second static partition;
    在所述获取第一升级安装包和所述第二升级安装包后,所述方法还包括:After the acquisition of the first upgrade installation package and the second upgrade installation package, the method further includes:
    将所述第三升级数据写入所述第五子分区,将所述第四升级数据写入所述第六子分区。Writing the third upgrade data into the fifth sub-partition, and writing the fourth upgrade data into the sixth sub-partition.
  9. 根据权利要求8所述的方法,其特征在于,所述第一静态分区包括多个子分区,所述第一静态分区的所述多个子分区与所述第二静态分区的所述多个子分区一一对应;The method according to claim 8, wherein the first static partition comprises a plurality of sub-partitions, and the plurality of sub-partitions of the first static partition are the same as the plurality of sub-partitions of the second static partition one-to-one correspondence;
    在将所述第三升级数据写入所述第五子分区,将所述第四升级数据写入所述第六子分区之前,所述方法还包括:Before writing the third upgrade data into the fifth sub-partition and writing the fourth upgrade data into the sixth sub-partition, the method further includes:
    若所述第二静态分区包括第七子分区,检测所述第五子分区和所述第六子分区中是否包括预设子分区,所述第七子分区是所述第二静态分区中除所述第五子分区和所述第六子分区之外的子分区;If the second static partition includes a seventh sub-partition, it is detected whether a preset sub-partition is included in the fifth sub-partition and the sixth sub-partition, and the seventh sub-partition is the second static sub-partition except Subpartitions other than the fifth subpartition and the sixth subpartition;
    若所述第五子分区和所述第六子分区中包括所述预设子分区,将所述第一静态分区的所述第七子分区的数据同步至所述第二静态分区的所述第七子分区中;If the fifth sub-partition and the sixth sub-partition include the preset sub-partition, synchronizing the data of the seventh sub-partition of the first static partition to the data of the second static partition In the seventh subdivision;
    若所述第五子分区和所述第六子分区中不包括所述预设子分区,将所述第一静态分区中所有子分区的数据同步至所述第二静态分区的对应子分区中。If the fifth sub-partition and the sixth sub-partition do not include the preset sub-partition, synchronizing the data of all sub-partitions in the first static partition to the corresponding sub-partitions of the second static partition .
  10. 根据权利要求9所述的方法,其特征在于,所述将所述第三升级数据写入所述第五子分区,将所述第四升级数据写入所述第六子分区,包括:The method according to claim 9, wherein writing the third upgrade data into the fifth sub-partition and writing the fourth upgrade data into the sixth sub-partition comprises:
    若所述第二静态分区不包括所述第七子分区,将所述第三升级数据写入所述第五子分区,将所述第四升级数据写入所述第六子分区。If the second static partition does not include the seventh sub-partition, write the third upgrade data into the fifth sub-partition, and write the fourth upgrade data into the sixth sub-partition.
  11. 根据权利要求4-10中任一项所述的方法,其特征在于,在所述用户数据分区中保存所述第一升级数据和所述第二升级数据,包括:The method according to any one of claims 4-10, wherein storing the first upgrade data and the second upgrade data in the user data partition comprises:
    遍历所述第一升级安装包和所述第二升级安装包,遍历到所述第一升级安装包时,在所述用户数据分区中保存所述第一升级数据,遍历到所述第二升级安装包时,在所述用户数据分区中保存所述第二升级数据;Traversing the first upgrade installation package and the second upgrade installation package, when traversing to the first upgrade installation package, saving the first upgrade data in the user data partition, traversing to the second upgrade installation package When installing the package, saving the second upgrade data in the user data partition;
    所述方法还包括:The method also includes:
    记录当前遍历到的升级安装包包括的升级数据的保存进度,以及记录当前遍历的升级安装包的遍历序数;Record the progress of saving the upgrade data included in the currently traversed upgrade installation package, and record the traversal sequence number of the currently traversed upgrade installation package;
    计算所述保存进度和所述遍历序数对应的更新进度,显示所述更新进度。Calculate the saving progress and the update progress corresponding to the traversal sequence number, and display the update progress.
  12. 根据权利要求11所述的方法,其特征在于,在所述用户数据分区中保存所述第一升级数据和所述第二升级数据的过程中,所述方法还包括:The method according to claim 11, wherein during the process of saving the first upgrade data and the second upgrade data in the user data partition, the method further comprises:
    若所述电子设备掉电重启,在所述第一升级安装包和所述第二升级安装包中定位所述遍历序数对应的目标升级安装包,以及在所述目标升级安装包的升级数据中定位所述写入进度对应的目标数据;If the electronic device is powered off and restarted, locate the target upgrade installation package corresponding to the traversal sequence number in the first upgrade installation package and the second upgrade installation package, and in the upgrade data of the target upgrade installation package Locating target data corresponding to the writing progress;
    从所述目标升级安装包的所述目标数据开始,在所述用户数据分区中继续保存所述第一升级数据和所述第二升级数据。Starting from the target data of the target upgrade installation package, the first upgrade data and the second upgrade data are continuously stored in the user data partition.
  13. 根据权利要求1-12中任一项所述的方法,其特征在于,在所述根据第三数据和所述多个第二描述组得到多个第三描述组之前,所述方法还包括:The method according to any one of claims 1-12, wherein, before obtaining a plurality of third description groups according to the third data and the plurality of second description groups, the method further comprises:
    合并所述第一数据和所述第二数据,得到所述第三数据。combining the first data and the second data to obtain the third data.
  14. 根据权利要求4-13中任一项所述的方法,其特征在于,在所述加载所述基础分区、所述第二静态分区和所述动态分区的数据之后,所述方法还包括:The method according to any one of claims 4-13, wherein after loading the data of the basic partition, the second static partition and the dynamic partition, the method further comprises:
    将所述用户数据分区中的所述多个第一升级数据和所述第二升级数据落盘到所述动态分区的对应子分区中。Putting the plurality of first upgrade data and the second upgrade data in the user data partition into corresponding sub-partitions of the dynamic partition.
  15. 一种电子设备,其特征在于,所述电子设备包括处理器以及存储器,所述存储器包括基础分区、第一静态分区、第二静态分区、动态分区以及用户数据分区,所述动态分区包括多个子分区,所述处理器用于执行所述存储器上存储的软件代码,以使得所述电子设备启动后加载所述基础分区、所述第一静态分区以及所述动态分区的数据以运行第一操作系统;An electronic device, characterized in that the electronic device includes a processor and a memory, the memory includes a basic partition, a first static partition, a second static partition, a dynamic partition and a user data partition, and the dynamic partition includes a plurality of sub-partitions a partition, the processor is used to execute the software code stored on the memory, so that after the electronic device is started, the data of the basic partition, the first static partition and the dynamic partition are loaded to run the first operating system ;
    并且,在所述第一操作系统运行之后,使得所述电子设备执行如权利要求1-14中任一项所述的方法。And, after the first operating system runs, the electronic device is made to execute the method according to any one of claims 1-14.
  16. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有计 算机程序,当其在电子设备上运行时,使得所述电子设备执行如权利要求1-14中任一项所述的方法。A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, and when it runs on an electronic device, the electronic device executes any one of claims 1-14. the method described.
  17. 一种芯片系统,其特征在于,所述芯片系统应用于包括处理器和存储器的电子设备,所述芯片系统包括一个或多个接口电路和一个或多个处理器,所述接口电路和所述处理器通过线路互联,所述接口电路用于从所述电子设备的存储器接收信号,并向所述处理器发送所述信号,所述信号包括所述存储器中存储的计算机指令,当所述处理器执行所述计算机指令时,使得所述电子设备执行如权利要求1-14中任一项所述的方法。A chip system, characterized in that the chip system is applied to an electronic device including a processor and a memory, the chip system includes one or more interface circuits and one or more processors, the interface circuit and the The processors are interconnected by wires, and the interface circuit is used to receive signals from the memory of the electronic device and send the signals to the processor, the signals include computer instructions stored in the memory, when the processing When the computer executes the computer instructions, the electronic device is made to execute the method according to any one of claims 1-14.
PCT/CN2022/140016 2022-01-10 2022-12-19 Operating system upgrade method, electronic device, storage medium, and chip system WO2023130946A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
EP22899609.6A EP4242835A1 (en) 2022-01-10 2022-12-19 Operating system upgrade method, electronic device, storage medium, and chip system

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN202210023196 2022-01-10
CN202210023196.0 2022-01-10
CN202210135613.0 2022-02-14
CN202210135613.0A CN116450169A (en) 2022-01-10 2022-02-14 Operating system upgrading method, electronic device, storage medium and chip system

Publications (1)

Publication Number Publication Date
WO2023130946A1 true WO2023130946A1 (en) 2023-07-13

Family

ID=87073070

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/140016 WO2023130946A1 (en) 2022-01-10 2022-12-19 Operating system upgrade method, electronic device, storage medium, and chip system

Country Status (2)

Country Link
EP (1) EP4242835A1 (en)
WO (1) WO2023130946A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116701318A (en) * 2023-08-09 2023-09-05 荣耀终端有限公司 System upgrade information acquisition method, electronic equipment and storage medium
CN117707566A (en) * 2023-08-23 2024-03-15 荣耀终端有限公司 Operating system upgrading method and electronic equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090307477A1 (en) * 2008-06-06 2009-12-10 Apple Computer, Inc. Installation of software onto a computer
CN113805956A (en) * 2021-06-15 2021-12-17 荣耀终端有限公司 Operating system configuration method, operating system configuration device, operating system storage medium, and program product
CN113805914A (en) * 2021-06-15 2021-12-17 荣耀终端有限公司 Operating system upgrade method, apparatus, storage medium, and computer program product
CN113821233A (en) * 2021-06-15 2021-12-21 荣耀终端有限公司 Operating system upgrade method, apparatus, storage medium, and computer program product

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090307477A1 (en) * 2008-06-06 2009-12-10 Apple Computer, Inc. Installation of software onto a computer
CN113805956A (en) * 2021-06-15 2021-12-17 荣耀终端有限公司 Operating system configuration method, operating system configuration device, operating system storage medium, and program product
CN113805914A (en) * 2021-06-15 2021-12-17 荣耀终端有限公司 Operating system upgrade method, apparatus, storage medium, and computer program product
CN113821233A (en) * 2021-06-15 2021-12-21 荣耀终端有限公司 Operating system upgrade method, apparatus, storage medium, and computer program product

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116701318A (en) * 2023-08-09 2023-09-05 荣耀终端有限公司 System upgrade information acquisition method, electronic equipment and storage medium
CN116701318B (en) * 2023-08-09 2023-12-15 荣耀终端有限公司 System upgrade information acquisition method, electronic equipment and storage medium
CN117707566A (en) * 2023-08-23 2024-03-15 荣耀终端有限公司 Operating system upgrading method and electronic equipment

Also Published As

Publication number Publication date
EP4242835A1 (en) 2023-09-13

Similar Documents

Publication Publication Date Title
WO2023130946A1 (en) Operating system upgrade method, electronic device, storage medium, and chip system
WO2022262744A1 (en) Upgrade method for operating system, and device, storage medium and computer program product
WO2022262754A1 (en) Operating system data updating method and device, storage medium, and program product
EP4202649A1 (en) Method for upgrading operating system, device, storage medium, and computer program product
US9449021B2 (en) Use of long file names in data storage systems
KR101452725B1 (en) Mobile terminal and method for synchronizing data thereof
WO2022262751A1 (en) Operating system upgrading method, and device, storage medium and computer program product
CN101882132A (en) Creating and reading method and device for virtual FAT file system
CN113821221B (en) Method, apparatus and storage medium for installing operating system
US20120221609A1 (en) Data Storage System and Method
WO2022262753A1 (en) Operating system starting method, device, storage medium, and computer program product
WO2023169035A1 (en) Operating system upgrade method, electronic device, and storage medium
WO2022262748A1 (en) Management method for operating system, device, storage medium, and computer program product
CN114461257B (en) Operating system data configuration method, operating system data configuration device, storage medium and program product
CN113805956B (en) Configuration method and device of operating system and storage medium
CN113868156B (en) System upgrade power-down protection method, electronic device and storage medium
CN113900673B (en) System installation package management method, device, storage medium and program product
CN115562695B (en) Operating system upgrading method, electronic device, storage medium and chip system
CN116450169A (en) Operating system upgrading method, electronic device, storage medium and chip system
WO2024114029A1 (en) Operating system upgrade method and electronic device
US20240220226A1 (en) Operating system data update method, device, storage medium, and program product
WO2024119895A1 (en) Operating system upgrade method, device, and storage medium
US20240231789A1 (en) Operating System Management Method, Device, Storage Medium, and Computer Program Product
US20240220225A1 (en) Operating system upgrade method, device, storage medium, and computer program product
CN117707566A (en) Operating system upgrading method and electronic equipment

Legal Events

Date Code Title Description
ENP Entry into the national phase

Ref document number: 2022899609

Country of ref document: EP

Effective date: 20230607

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22899609

Country of ref document: EP

Kind code of ref document: A1