An operating system upgrade method and electronic device
By using system upgrade packages for virtual A/B upgrades in electronic devices, the issue of system compatibility when converting demo units to commercial units is resolved, improving flashing efficiency and storage space utilization.
Patent Information
- Application Number
- CN202310500090.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2022-01-10
- Filing Date
- 2022-02-16
- Publication Date
- 2026-11-10
- Estimated Expiration
- 2042-02-16
AI Technical Summary
In existing technologies, when converting a demo unit to a commercial unit, there are problems such as low flashing efficiency and low storage space utilization due to differences in system standards.
By using system upgrade packages to perform virtual A/B upgrades in electronic devices, the system standard information is modified, data is migrated during the upgrade process, and the operating system partition is adjusted to achieve system standard change and improve flashing efficiency, while optimizing storage space utilization.
It enables system changes without requiring the device to be sent back to the factory for re-flashing, improving the re-flashing efficiency of electronic devices and increasing the utilization rate of storage space.
Smart Images

Figure CN116610339B_ABST
Abstract
Description
[0001] This application claims priority to Chinese Patent Application No. 202210023826.4, filed on January 10, 2022, entitled "An Operating System Upgrade Method and Electronic Device", the entire contents of which are incorporated herein by reference.
[0002] This application is a divisional application. The original application has the application number 202210143150.2 and the original application date is February 16, 2022. The entire contents of the original application are incorporated herein by reference. Technical Field
[0003] This application relates to the field of terminal devices, and more particularly to an operating system upgrade method and an electronic device. Background Technology
[0004] In existing technology applications, user terminals need to have an operating system installed before they can be used by users. For example, mobile phones need to have a mobile operating system (such as iOS or Android) installed before they can be used by users.
[0005] However, operating systems use different standards, and system partitions differ between these standards. For example, the demo unit uses the demo cn standard, while the commercial unit uses the all cn standard. The customized (version) subpartition of the demo unit is much larger than that of the commercial unit, with a difference of up to 8GB. After the phone is discontinued, the demo unit also needs to be sold to consumers, making the transition from demo unit to commercial unit crucial. Summary of the Invention
[0006] This application provides an operating system upgrade method and an electronic device to improve the efficiency of flashing the firmware when changing the device's operating system.
[0007] In a first aspect, the present application provides an operating system upgrade method applied to an electronic device. The electronic device includes a memory, which includes a base partition, a first static partition, a second static partition, a dynamic partition, and a user data partition. The dynamic partition includes a first subpartition, which stores a first partition table. The first partition table includes a first address, which indicates the starting physical address of the first subpartition in the memory. The base partition stores a first format file, which includes first format information. The electronic device is configured with a boot order identifier. The electronic device includes a first operating system and a second operating system. When the boot order identifier indicates booting from the first static partition, after the electronic device runs, it loads data from the base partition, the first static partition, and the dynamic partition to start the first operating system. After the first operating system starts, the method includes: obtaining a system upgrade package, which is used to upgrade the operating system; The system upgrade package includes first upgrade data, second upgrade data, a second partition table, and a second standard file. The second standard file includes second standard information, which is different from the first standard information. The second partition table includes a second address, which indicates the starting physical address of the first subpartition in memory after the upgrade is completed. The system data in the second static partition is updated to the first upgrade data. The boot order identifier of the electronic device is modified, wherein the modified boot order identifier indicates booting from the second static partition. After the electronic device completes its first restart, the system data in the dynamic partition is updated to the second upgrade data. The first standard information is modified to the second standard information. After the electronic device restarts for the second time, it enters recovery mode. In recovery mode, the starting physical address of the first data is moved from the first address to the second address. The first data includes the data stored in the first subpartition. The first partition table is modified to the second partition table.
[0008] In addition, electronic devices include two operating systems that back each other up, namely, a first operating system and a second operating system. Electronic devices achieve the operation of different operating systems by loading different static partitions.
[0009] In the above embodiments, taking the scenario of an electronic device running a first operating system as an example, if the received system upgrade package includes a second format file and the second format file is different from the first format file, the electronic device can use the system upgrade package to change the format type of the electronic device during the upgrade process. This type of upgrade can be called a system modification upgrade.
[0010] For example, the aforementioned first sub-partition can refer to a system sub-partition whose starting physical address changes after modification. Taking the modification of an electronic device into a commercial version as an example, the first sub-partition can be a pre-installed sub-partition, which is located after the customized sub-partition. Understandably, the customized sub-partition of the demo unit is different in size from that of the commercial unit. Thus, the location of the pre-installed sub-partition of the demo unit is also different from that of the customized sub-partition of the commercial unit.
[0011] During the virtual A / B upgrade process of electronic devices based on system upgrade packages, the first system standard information can be replaced with the second system standard information. Furthermore, during the merge process—that is, after updating the dynamic partition using the second upgrade data—the electronic device migrates the first data to the storage location. This first data includes the data in the first sub-region after the merge. After the storage location of the first data is migrated, the starting physical address of the first data is the same as the second address in the second partition table. This second address is the starting physical address of the first sub-partition in a commercially available electronic device. Then, the partition table indicating the starting physical address of the first sub-partition is changed; that is, the first partition table is modified to the second partition table. In this way, system standard changes can be completed during automatic upgrades without requiring factory re-flashing, improving the human-machine efficiency of system standard changes for electronic devices.
[0012] In some possible embodiments, the first data also includes second data in the dynamic partition, which is stored after the first sub-partition. The base partition stores a third partition table, which includes a third address indicating the end physical address of the current dynamic partition in memory. Moving the starting physical address of the first data from the first address to the second address includes: reading the first data between the first address and the third address; writing the read first data into a blank storage area of the user data partition; and after writing, writing the first data from the user data partition into the dynamic partition, starting from the second address.
[0013] In the above embodiments, during the migration of the first data, the security of the system data is ensured to avoid accidents that could damage the system data.
[0014] In some possible embodiments, the second address is located after the first address.
[0015] In some possible embodiments, a third partition table is stored in the base partition, the third partition table including a fourth address, the fourth address being used to indicate the starting physical address of the user data partition in memory; the system upgrade package also includes a fourth partition table, the fourth partition table also including a fifth address, the fifth address being used to indicate the starting physical address of the user data partition in memory after the upgrade is completed, the fifth address being located before the fourth address; after migrating the starting physical address of the first data from the first address to the second address, the method further includes: updating the third partition table using the fourth partition table.
[0016] In the above embodiments, the size of the user data partition can be increased to improve the storage space utilization of the electronic device.
[0017] In some possible embodiments, after updating the first partition table using the second partition table, the method further includes: determining that the second format information is already included in the first format file; and formatting the user data partition.
[0018] In some possible embodiments, after updating the first partition table using the second partition table, the method further includes: determining that the first standard file does not contain the second standard information; reading the second standard information again and writing it into the first standard file to replace the first standard information in the first standard file.
[0019] In the above embodiments, the success rate of modification can be improved by detecting standard information.
[0020] In some possible embodiments, before the electronic device restarts for the first time, the method further includes: after parsing the system upgrade package, determining that the system upgrade package contains a modified small package; wherein the second partition table is compressed within the modified small package; storing the second format file as a temporary file in the base partition; decompressing the modified small package in a first storage area; wherein the first storage area is a storage area accessible to the electronic device in recovery mode; before migrating the starting physical address of the first data from the first address to the second address, the method further includes: obtaining the second address from the second partition table in the first storage area.
[0021] In some possible embodiments, after entering recovery mode, the method further includes: if the modified small packet is stored in the first storage area, writing first indication information in the second storage area; migrating the starting physical address of the first data from the first address to the second address, including: after detecting the first indication information, migrating the starting physical address of the first data from the first address to the second address.
[0022] In some possible embodiments, after updating the system data in the second static partition to the first upgrade data, the method further includes: creating a virtual partition in the user data partition; writing the second upgrade data into the virtual partition; and updating the system data in the dynamic partition to the second upgrade data, including: merging the second upgrade data in the virtual partition into the dynamic partition.
[0023] In some possible embodiments, after modifying the boot sequence identifier of the electronic device, the method further includes: during the first reboot, loading data from the base partition, the second static partition, the dynamic partition, and the virtual partition; and after the first reboot is completed, mirroring the data from the second static partition to the first static partition.
[0024] Secondly, an electronic device is provided in the embodiments of this application. The electronic device includes one or more processors and a memory. The memory is coupled to the processor and is used to store computer program code, which includes computer instructions. When one or more processors execute the computer instructions, the one or more processors are used to: obtain a system upgrade package, which is used to upgrade the operating system; the system upgrade package includes first upgrade data, second upgrade data, a second partition table, and a second standard file, the second standard file including second standard information, which is different from the first standard information; the second partition table includes a second address, which indicates the starting physical address of the first subpartition in the memory after the upgrade is completed; update the system data in the second static partition to the first upgrade data; modify the boot order identifier of the electronic device, wherein the modified boot order identifier indicates booting from the second static partition; after the electronic device completes its first restart, update the system data in the dynamic partition to the second upgrade data; modify the first standard information to the second standard information; after the electronic device restarts for the second time, enter a recovery mode; in the recovery mode, migrate the starting physical address of the first data from the first address to the second address; wherein the first data includes data stored in the first subpartition; and modify the first partition table to the second partition table.
[0025] In some possible embodiments, the first data also includes second data in the dynamic partition, which is stored after the first sub-partition. The base partition stores a third partition table, which includes a third address indicating the end physical address of the current dynamic partition in memory. One or more processors are further configured to: read the first data from between the first address and the third address; write the read first data into a blank storage area of the user data partition; and after writing is completed, write the first data in the user data partition into the dynamic partition, starting from the second address.
[0026] In some possible embodiments, the second address is located after the first address.
[0027] In some possible embodiments, the base partition stores a third partition table, which includes a fourth address indicating the starting physical address of the user data partition in memory; the system upgrade package also includes a fourth partition table, which includes a fifth address indicating the starting physical address of the user data partition in memory after the upgrade is completed, and the fifth address is located before the fourth address; after migrating the starting physical address of the first data from the first address to the second address, one or more processors are further configured to: update the third partition table using the fourth partition table.
[0028] In some possible embodiments, after updating the first partition table using the second partition table, one or more processors are further configured to: determine that the second standard information has been included in the first standard file; and format the user data partition.
[0029] In some possible embodiments, after updating the first partition table using the second partition table, one or more processors are further configured to: determine that the first standard file does not include the second standard information; read the second standard information again and write it into the first standard file to replace the first standard information in the first standard file.
[0030] In some possible embodiments, prior to the first reboot of the electronic device, one or more processors are further configured to: determine, after parsing the system upgrade package, that the system upgrade package contains a modified small package; wherein the second partition table is compressed within the modified small package; store the second format file as a temporary file in the base partition; decompress the modified small package in a first storage area; wherein the first storage area is a storage area accessible to the electronic device in recovery mode; and obtain a second address from the second partition table in the first storage area.
[0031] In some possible embodiments, after entering recovery mode, one or more processors are further configured to: write first indication information in a second storage area if the modified small packet is stored in a first storage area; and migrate the starting physical address of the first data from the first address to the second address, including: migrating the starting physical address of the first data from the first address to the second address after detecting the first indication information.
[0032] In some possible embodiments, after updating the system data in the second static partition to the first upgrade data, one or more processors are further configured to: create a virtual partition in the user data partition; write the second upgrade data into the virtual partition; and merge the second upgrade data in the virtual partition into the dynamic partition.
[0033] In some possible embodiments, after modifying the boot sequence identifier of the electronic device, one or more processors are further configured to: during the first reboot, load data from the base partition, the second static partition, the dynamic partition, and the virtual partition; and after the first reboot is completed, mirror the data from the second static partition to the first static partition.
[0034] Thirdly, embodiments of this application provide a computer storage medium including computer instructions that, when executed on an electronic device, cause the electronic device to perform the methods described in the first aspect and its possible embodiments.
[0035] Fourthly, this application provides a computer program product that, when run on the aforementioned electronic device, causes the electronic device to perform the methods described in the first aspect and its possible embodiments.
[0036] Understandably, the electronic devices, computer-readable storage media, and computer program products provided in the above aspects are all applied to the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here. Attached Figure Description
[0037] Figure 1 One of the example diagrams of the data storage structure of the operating system in the electronic device provided in the embodiments of this application;
[0038] Figure 2 Example diagrams of system partitions for the demonstration prototype and commercial machine provided in this application embodiment;
[0039] Figure 3A Example structural diagrams of the electronic device provided in the embodiments of this application;
[0040] Figure 3B One of the flowcharts for an operating system upgrade method provided in this application embodiment;
[0041] Figure 4 A flowchart illustrating the process of performing a virtual A / B upgrade as provided in an embodiment of this application;
[0042] Figure 5 A flowchart illustrating the process of performing a merge as provided in this application embodiment;
[0043] Figure 6 This is the second example diagram of the data storage structure of the operating system provided in the embodiments of this application;
[0044] Figure 7 Example diagrams of data migration provided in embodiments of this application;
[0045] Figure 8 A flowchart of data migration provided for embodiments of this application;
[0046] Figure 9 Example diagram of changing user data partition (Userdata) provided in the embodiments of this application;
[0047] Figure 10 This is the third example diagram of the data storage structure of the operating system provided in the embodiments of this application;
[0048] Figure 11 A second flowchart illustrating an operating system upgrade method provided in this application embodiment;
[0049] Figure 12 This is a schematic diagram of the composition of a chip system provided in an embodiment of this application. Detailed Implementation
[0050] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this embodiment, unless otherwise stated, "a plurality of" means two or more.
[0051] The implementation of this embodiment will now be described in detail with reference to the accompanying drawings.
[0052] This application provides an operating system upgrade method, which can be applied to electronic devices. It is understood that electronic devices require an operating system to be installed before they can be used by users. For example, mobile phones require a mobile operating system (e.g., iOS, Android) to be used by users.
[0053] For example, the aforementioned electronic devices include, but are not limited to, smartphones, smart headphones, tablets, smart refrigerators, smart speakers, etc., that can install an operating system. Exemplary embodiments of the operating system include, but are not limited to, those... Or other operating systems.
[0054] Taking the Android system, which uses a virtual A / B operating system, as an example, the data storage structure of the operating system in an electronic device is as follows: Figure 1 As shown, the data storage structure of this operating system includes a Common partition, a system partition, and a User data partition.
[0055] The Common partition is the base partition, which stores system data that does not participate in operating system upgrades. In some embodiments, the Common partition may include at least one subpartition, such as an oeminfo subpartition or an nv subpartition. The oeminfo subpartition can be used to store the operating system's standard (vendor_country, VC) information, such as Allcn, democn, cmcccn, etc. Allcn indicates a configuration with the general Chinese standard, cmcccn indicates a China Mobile standard, and democn indicates a demo standard.
[0056] Understandably, electronic devices need to be configured with corresponding Visual C++ (VC) information in their operating systems depending on their location and the network operator they connect to. For example, they might be configured with "all cn" or "cmcc cn". Furthermore, electronic devices can be configured with different VC information in their operating systems based on their intended use. For instance, a demo unit placed in a retail store might be configured with "demo cn", while an electronic device intended for sale to consumers might be configured with "All cn".
[0057] Thus, during the operation of an electronic device, the operating system needs to be booted. During the boot process, the electronic device reads and loads the VC information from the Common partition, and the VC information can be written into the custom information (Custom.bin file) in the Userdata partition so that it can be called during the operation of the operating system.
[0058] The aforementioned Userdata partition is used to store users' personal data, such as apps installed by the user, photos, documents, and videos saved by the user.
[0059] The aforementioned system partitions are used to store operating system data. For example, the system partitions are further divided into static partitions and dynamic partitions (Super). The static partitions include static partition (A) and static partition (B). Static partition (A) and static partition (B) are backups of each other; that is, the structures of static partition (A) and static partition (B) correspond to each other, and their subpartition names are distinguished by the suffixes _a and _b, respectively, and can also be called the first static partition and the second static partition. For example, static partition (A) includes bootloader_a, boot_a, vendor_boot_a, dtbo_a, and vbmeta_a; static partition (B) includes bootloader_b, boot_b, vendor_boot_b, dtbo_b, and vbmeta_b.
[0060] With two static partitions, the electronic device can virtualize two operating systems, such as Operating System A and Operating System B. Upon startup, the electronic device must run on either operating system. For example, if the electronic device needs to run on Operating System A, it boots from the static partition (A): loading the base partition (Common), the static partition (A), and the dynamic partition (Super) in sequence. Similarly, if the electronic device needs to run on Operating System B, it boots from the static partition (B): loading the base partition (Common), the static partition (B), and the dynamic partition (Super) in sequence.
[0061] Take Universal Flash Storage (UFS) using the Master Boot Record (MBR) format as an example. The UFS MBR (Master Boot Record, the first sector of the UFS, i.e., sector 1, head 0, cylinder 0 at C / H / S address) stores a description of the electronic device's boot order, such as booting from static partition (A) (boot order flag A) or booting from static partition (B) (boot order flag A). After booting, the electronic device first reads its boot order from the UFS MBR. Then, based on the read boot order, the electronic device can load data from the system partitions, such as loading the basic partition (Common), static partition (A), and dynamic partition (Super) sequentially, as described in the previous example, or loading the basic partition (Common), static partition (B), and dynamic partition (Super) sequentially.
[0062] In addition, a dynamic partition (Super) can also contain multiple subpartitions, such as preas, preavs, System, system_ext, vendor, product, Cust, Odm, version, and preload.
[0063] It's worth noting that while the sub-partitions within the dynamic partition (Super) of the same electronic device may be of the same type, the size of each sub-partition within the dynamic partition (Super) can differ depending on the device's operating system. For example, for a demo unit (device with VC information "demo cn"), the "version" sub-partition, also known as the customized "version" sub-partition, is needed to store a large number of operational demo samples. However, this is not necessary for a commercial device (device with VC information "All cn" or "cmcc cn"). Thus, the "version" and "preload" sub-partitions differ between demo units and commercial devices. For example... Figure 2As shown, the demo unit and the commercial unit have different sizes for the version subpartition and different starting addresses for the preload subpartition. This preload subpartition is also called the first subpartition. Furthermore, the starting address can also be referred to as the starting physical address in memory.
[0064] Typically, after a new generation of electronic devices is launched, demo units of the previous generation also need to be sold to users. Due to differences in dynamic partitioning structures, even after being sold to users, demo units still require system upgrade packages. Thus, after the upgrade, demo samples still exist in the version sub-partition of the demo unit. However, the sold demo units no longer actually need to store operation demo samples, yet the corresponding version sub-area still occupies a large amount of space. This unreasonable storage area division obviously affects storage space utilization.
[0065] To address the aforementioned issues, this application provides an operating system upgrade method. For demo units intended for sale, an operating system upgrade changes the device's standard configuration and adjusts the operating system partitions, ensuring that the upgraded demo unit is indistinguishable from a commercial unit. This improves the device's storage space utilization and increases the efficiency of the operating system upgrade.
[0066] In subsequent embodiments, the demo units to be sold can be collectively referred to as electronic devices. Within the Common partition of the electronic device, the oeminfo subpartition includes VC information indicating the first standard (demo cn).
[0067] Please refer to Figure 3A This is a schematic diagram of the structure of an electronic device 100 provided in an embodiment of this application. Figure 3A As shown, the electronic device 100 may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.
[0068] The aforementioned sensor module 180 may include sensors such as pressure sensors, gyroscope sensors, barometric pressure sensors, magnetic sensors, accelerometers, distance sensors, proximity sensors, fingerprint sensors, temperature sensors, touch sensors, ambient light sensors, and bone conduction sensors.
[0069] It is understood that the structure illustrated in this embodiment does not constitute a specific limitation on the electronic device 100. In other embodiments, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0070] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0071] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to the instruction opcode and timing signals to complete the control of fetching and executing instructions.
[0072] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0073] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0074] It is understood that the interface connection relationships between the modules illustrated in this embodiment are merely illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments, the electronic device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
[0075] The wireless communication function of an electronic device can be implemented through antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, modem processor, and baseband processor. In some embodiments, antenna 1 of the electronic device is coupled to mobile communication module 250, and antenna 2 is coupled to wireless communication module 260, enabling the electronic device to communicate with networks and other devices, such as wearable devices, through wireless communication technology.
[0076] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device can be used to cover one or more communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with a tuning switch.
[0077] The mobile communication module 250 can provide solutions for wireless communication applications in electronic devices, including 2G / 3G / 4G / 5G. The mobile communication module 250 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 250 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation.
[0078] The mobile communication module 250 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via the antenna 1. In some embodiments, at least some functional modules of the mobile communication module 250 can be housed in the processor 210. In some embodiments, at least some functional modules of the mobile communication module 250 and at least some modules of the processor 210 can be housed in the same device.
[0079] The wireless communication module 260 can provide solutions for wireless communication applications in electronic devices, including WLAN (such as wireless fidelity, Wi-Fi) networks, Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR) technology, and other wireless communication technologies.
[0080] GNSS can include the BeiDou Navigation Satellite System (BDS), the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the Quasi-Zenith Satellite System (QZSS), and / or satellite-based augmentation systems (SBAS).
[0081] The wireless communication module 260 can be one or more devices integrating at least one communication processing module. The wireless communication module 260 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signal, and sends the processed signal to processor 210. The wireless communication module 260 can also receive signals to be transmitted from processor 210, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.
[0082] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0083] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a Mini LED, a MicroLED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc.
[0084] An NPU (Neural Processing Unit) is a computational processor for neural networks (NNs). By borrowing the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it can rapidly process input information and continuously learn on its own. NPUs enable intelligent cognitive applications in electronic devices, such as image recognition, facial recognition, speech recognition, and text understanding.
[0085] The audio module 170 is used to convert digital audio information into analog audio signals for output, and also to convert analog audio input into digital audio signals. The audio module 170 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 170 may be located in the processor 110, or some functional modules of the audio module 170 may be located in the processor 110. The speaker 170A, also called a "loudspeaker," is used to convert audio electrical signals into sound signals. Thus, the electronic device 100 can play audio data, such as video music.
[0086] A pressure sensor is used to sense pressure signals and convert them into electrical signals. In some embodiments, the pressure sensor can be located on the display screen 194. A gyroscope sensor can be used to determine the motion posture of the electronic device 100. When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of the electronic device 100, applied to applications such as landscape / portrait screen switching. A touch sensor, also known as a "touch panel," can be located on the display screen 194. The touch sensor 180K and the display screen 194 together form a touch screen, also known as a "touch screen." The touch sensor is used to detect touch operations applied to or near it. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event.
[0087] The following description, with reference to the accompanying drawings, continues to use the example of an electronic device employing a virtual A / B operating system to illustrate the operating system upgrade method provided in this application.
[0088] In some embodiments, the aforementioned operating system upgrade can be performed by an operating system updater installed on the electronic device. For example, the online update client APK (OUC APK) and the update engine are two modules within the operating system updater. The online update client APK is used to obtain the operating system upgrade installation package, and the update engine is used to drive and execute the operating system upgrade.
[0089] Figure 3B The following is for Figure 1 The flowchart illustrates the operating system upgrade process using the data storage structure of the operating system shown. In a scenario where the electronic device boots from a static partition (A), i.e., running on operating system A, the electronic device follows the steps described above. Figure 3B The process shown enables operating system upgrades.
[0090] S101, upgrade server releases system upgrade package.
[0091] In some embodiments, the system upgrade package described above is data used to indicate upgrading the operating system to a target version. The target version is different from the system version currently running on the electronic device. In some embodiments, the system upgrade package is a full upgrade package, and it also indicates data to upgrade to a node version.
[0092] Additionally, the system upgrade package includes a modification package. This modification package instructs the electronic device's operating system to be updated from the first standard to the second standard (all cn or cmcc cn). This modification package is used when the electronic device enters Recovery mode.
[0093] For example, the data structure of the system upgrade package is as follows:
[0094] demochange.tag;
[0095] META-INF;
[0096] payload.bin;
[0097] payload_properties.txt;
[0098] SOFTWARE_VER.mbn;
[0099] update_base_demochange.zip;
[0100] vendor_country.mbn;
[0101] VERSION.mbn;
[0102] The above-mentioned `demochange.tag` is a modification tag, used to indicate that the system upgrade package can be used to modify a demo unit into a commercial unit. The above-mentioned `META-INF` is signature information used for signature verification of the system upgrade package. The above-mentioned `payload.bin` contains data that can upgrade the operating system to the target version. The above-mentioned `payload_properties.txt` is a file carrying parameters such as `FILE_HASH`, `FILE_SIZE`, and `METADATA_HASH`. The above-mentioned `SOFTWARE_VER.mbn` is the software version file. The target version's VC information (e.g., all cn) is stored in the root directory of the system upgrade package as a `vendor_country.mbn` file. The above-mentioned `update_base_demochange.zip` is the modification package.
[0103] For example, the data structure of this modification package, namely update_base_demochange.zip, is as follows:
[0104] Ptable;
[0105] Image;
[0106] super_metadata.img;
[0107] META-INF;
[0108] OTA_update.tag;
[0109] PTABLE_SUPER.mbn;
[0110] skipauth_pkg.tag;
[0111] vendor_country.mbn;
[0112] The Ptable is the overall partition table for the target version, used to describe the partition deployment of the storage device (ROM) after upgrading to the target version. It defines the start address and size of each partition. For example, the Ptable includes the start and end addresses of the Common partition, system partition, and Userdata partition in the storage space. See Table 1 below for example:
[0113] Table 1
[0114]
[0115] Additionally, the Image includes `super_metadata.img`, which is the super sub-partition table corresponding to the target version. This table describes the start and end addresses of each sub-partition in `super` after upgrading to the target version. The modified package also includes `META-INF`, which can also be used for signature verification. The target version's VC information (e.g., all cn) can also be stored in the root directory of the modified package as a `vendor_country.mbn` file.
[0116] In addition, the modified package may also include empty images such as userdata.img and metadata.img.
[0117] In some embodiments, the electronic device sequentially loads the base partition (Common), the static partition (A), and the dynamic partition (Super), and boots from the static partition (A). S101 can be executed after the electronic device boots or before the electronic device boots. When the electronic device is booted from the static partition (A), the online update client apk executes S102.
[0118] S102, online update client apk obtains system upgrade package, which includes modified small package and VC information of target version.
[0119] For example, in one feasible implementation, an electronic device periodically sends a packet search request to an upgrade server. The packet search request includes the version number of the operating system currently running on the electronic device (e.g., version 1.1). Based on the operating system version number in the packet search request, the upgrade server searches for the existence of a system upgrade package with an updated version number (e.g., version 1.2). When an updated system upgrade package exists, the upgrade server provides the electronic device with the download address of the system upgrade package (e.g., the full system upgrade package for version 1.2). The electronic device downloads the system upgrade package based on the download address.
[0120] As another example, in another feasible implementation, the upgrade server can also proactively push the new version of the system upgrade file to the electronic device after receiving it.
[0121] In this embodiment of the application, the system upgrade package obtained by the online update client apk can instruct the electronic device to be modified from the demo version to the commercial version. That is, the system upgrade package includes the modification package and the VC information of the target version (e.g., all cn).
[0122] In some embodiments, after S102, the online update client APK can download and save the system upgrade package to the user data partition. For example, the online update client APK periodically sends a package search request to the upgrade server. The package search request includes information such as the device's current operating system version number (e.g., version 1.1), device serial number, product model, and network standard (e.g., version 1.1). Based on the operating system version number in the package search request, the upgrade server searches the installation package server to see if there is a system upgrade package with an updated version number (e.g., version 1.2). When an updated version of the system upgrade package exists, the upgrade server sends the download address (e.g., URL address) of the system upgrade package (e.g., a system upgrade package from version 1.1 to version 1.2) and the filelist file corresponding to the system upgrade installation package to the online update client APK. The online update client APK downloads the system upgrade package from the installation package server based on the download address of the system upgrade package.
[0123] Once the online update client APK obtains the system upgrade package, it starts the update engine, which then upgrades the operating system based on the system upgrade package.
[0124] In other words, when the online update client apk executes S103, it triggers the update engine to enter the upgrade process.
[0125] As an example, after the online update client APK obtains the system upgrade package, it sets the startup attribute of the upgrade engine to true. The service manager, which resides in the operating system background, monitors the startup attribute of the upgrade engine. When the service manager detects that the startup attribute of the upgrade engine is true, it starts the upgrade engine.
[0126] The online update client APK obtains the status of the update engine through binder communication. When the online update client APK confirms that the update engine has started successfully, it passes the update parameters to the update engine (e.g., whether the current update operation is a file update operation or a file write operation), triggering the update engine to enter the update process.
[0127] During the upgrade process, the update engine executes S104 to verify the operating system upgrade package.
[0128] For example, this could involve verifying the validity of the META-INF (i.e., digital signature) in the system upgrade package to confirm whether the system upgrade package is legitimate. Specific implementation details can be found in relevant technologies and will not be elaborated upon here.
[0129] If the verification is successful, the update engine executes S105, and if system A is running, it initiates an upgrade for system B based on the system upgrade package.
[0130] In some embodiments, upgrading the electronic device's System B (also known as the second operating system) is part of a virtual A / B upgrade process. In other words, if the electronic device is running System A (also known as the first operating system), the above-described S105 can also be used to initiate and execute the virtual A / B upgrade process.
[0131] For example, the process of performing a virtual A / B upgrade is as follows: Figure 4As shown. Figure 4 As shown, it includes the following steps:
[0132] S401, the electronic device reads the saved system upgrade package from the user data partition (Userdata), and performs a data write operation on the static partition (B) according to the system upgrade package to upgrade the static partition.
[0133] For example, if the system upgrade package contains data from the static partition of version 1.2, also known as the first upgrade data, the update engine will overwrite the data from the static partition of version 1.2 into the static partition (B).
[0134] S402, the electronic device creates a virtual dynamic partition in the user data partition (Userdata) according to the system upgrade package, and writes the upgrade data of the dynamic partition (Super) into the virtual dynamic partition.
[0135] For example, the system upgrade package may include data from the version 1.2 dynamic partition, also known as the second upgrade data. The device writes the version 1.2 dynamic partition (Super) data into the virtual dynamic partition. In other possible embodiments, in the virtual A / B upgrade scheme, an incremental upgrade method is used for the dynamic partition (Super). During the upgrade process, the virtual dynamic partition of the user data partition (Userdata) does not store all the files of the new version of the dynamic partition (Super) after the upgrade, but rather the upgrade result of the data that needs to be upgraded in the old version of the dynamic partition (Super). That is, the virtual dynamic partition of the user data partition (Userdata) stores the updated data of the dynamic partition.
[0136] Taking the system sub-partition as an example, suppose that in version 1.1, the data in the system sub-partition can be divided into two parts: system1 and system2. From version 1.1 to version 1.2, the data system2 remains unchanged, but the data system1 is upgraded to system3. Therefore, in S402, the device creates a virtual dynamic partition in the user data partition and writes the data system3 into the virtual dynamic partition.
[0137] For example, the system incremental upgrade package for upgrading from version 1.1 to version 1.2 contains dynamic partition (Super) update data for upgrading from version 1.1 to version 1.2, which includes the data system3.
[0138] Furthermore, in the virtual A / B upgrade scheme, incremental upgrades of the dynamic partition (Super) are implemented based on snapshot technology. Specifically, in the virtual dynamic partition of the user data partition, a copy-on-write (COW) file is used to store the upgrade data of the dynamic partition (Super).
[0139] Specifically, the upgrade data of the Super dynamic partition stored in the Userdata partition contains multiple COW files. Each COW file corresponds to a subpartition of the Super dynamic partition, and the name of the COW file corresponds to the subpartition of the Super dynamic partition it targets.
[0140] In the system upgrade package, the COW files for the upgrade data of the Super partition are compressed and stored in binary code form. Each COW file in the system upgrade package is named according to the Super subpartition it targets. For example, the COW file for the system subpartition is named system-cow-img.img.0000.
[0141] In S402, the electronic device unpacks the system upgrade package to obtain all COW files and appends A / B partition markers to each COW file. Specifically, when the electronic device is currently booting from the static partition (A), it can be understood that the dynamic partition (Super) loaded by the operating system currently running on the electronic device is the dynamic partition (A). During the operating system upgrade, the virtual dynamic partition created in the user data partition (Userdata) is for the dynamic partition (B). Therefore, the name marker _b corresponding to the dynamic partition (B) is appended to the COW file. For example, appending _b to system-cow-img.img.0000 generates system_b-cow-img.img.0000.
[0142] Furthermore, in S402, an Update folder is created in the Userdata partition, and the renamed COW file is saved in the Update folder. For example, in one application scenario, after writing a COW file to the Userdata partition, the Update folder of the Userdata partition contains the following files:
[0143] system_b-cow-img.img.0000;
[0144] system_ext_b-cow-img.img.0000;
[0145] vendor_b-cow-img.img.0000;
[0146] product_b-cow-img.img.0000;
[0147] cust_b-cow-img.img.0000;
[0148] odm_b-cow-img.img.0000.
[0149] Specifically, the COW file contains its own COW file map (snapshot map) and upgrade data.
[0150] The COW file map (snapshot) corresponds to the file map of the subpartitions of the dynamic partition (Super) that the COW file targets. The file map of the subpartitions of the dynamic partition (Super) describes all files in the subpartitions of the dynamic partition (Super) in the current version of the operating system (the version prior to this upgrade, for example, version 1.1) and the storage location of each file.
[0151] The upgrade data in the COW file represents the updated files in the new version of the subpartition data compared to the current version; the COW file map itself describes the correspondence between the updated files and the files in the current version of the subpartition, as well as the storage location of the updated files.
[0152] Based on the file maps of the subpartitions of the dynamic partition (Super) and the COW file maps within the COW file, the upgrade data in the COW file can be used to replace the corresponding files in the subpartitions of the dynamic partition (Super), thereby achieving the upgrade of the dynamic partition (Super) data. Specifically, when it is necessary to obtain the file map of the subpartitions of the dynamic partition (Super), a snapshot operation can be performed on the data of the subpartitions of the dynamic partition (Super) to generate the file map of the subpartitions of the dynamic partition (Super). Alternatively, when creating the system upgrade package, the file map of the subpartitions of the dynamic partition (Super) can be pre-generated and added to the COW file.
[0153] Taking the system subpartition as an example, assume that the data in the system subpartition is stored in the following paths:
[0154] / system / app / A0.XXX;
[0155] / system / app / A1.XXX;
[0156] / system / app / A2.XXX;
[0157] / system / B0.XXX;
[0158] / system / B1.XXX;
[0159] / system / user / C0.XXX;
[0160] / system / user / C1.XXX;
[0161] / system / user / C2.XXX;
[0162] / system / user / C3.XXX.
[0163] The file map of the system subpartition can be:
[0164] / system / app / A0.XXX: 024010~024013;
[0165] / system / app / A1.XXX: 024014~024017;
[0166] / system / app / A2.XXX: 024018~024020;
[0167] / system / B0.XXX: 024021~024026;
[0168] / system / B1.XXX: 024027~024028;
[0169] / system / user / C0.XXX: 024029~024032;
[0170] / system / user / C1.XXX: 024033~024035;
[0171] / system / user / C2.XXX: 024036~024040;
[0172] / system / user / C3.XXX: 024041~024044.
[0173] The value following the filename (e.g., 024010~024013 in “ / system / app / A0.XXX:024010~024013”) is the physical storage address (block address) of the file in the system subpartition of the dynamic partition (Super).
[0174] Suppose that the current operating system upgrade requires updating the data / system / app / A2.XXX and / system / user / C2.XXX.
[0175] It can be considered as:
[0176] / system / app / A2.XXX and / system / user / C2.XXX are the system1 part of the system sub-partition data;
[0177] / system / app / A0.XXX, / system / app / A1.XXX, / system / B0.XXX, / system / B1.XXX, / system / user / C0.XXX, / system / user / C1.XXX, and / system / user / C3.XXX are the system2 part of the system sub-partition data.
[0178] Therefore, the COW file (system_b-cow-img.img.0000) for the system subpartition contains the latest versions of / system / app / A2.XXX and / system / user / C2.XXX.
[0179] The latest versions of / system / app / A2.XXX and / system / user / C2.XXX can be considered as system3. The upgrade goal is to use system3 to update system1.
[0180] When the size of the updated data in the COW file is the same as the size of the original data to be updated, and the location where the updated data in the COW file is saved in the subpartition after the data update is the same as the location where the original data to be updated is saved in the subpartition, the COW file map of the COW file (system_b-cow-img.img.0000) itself can be:
[0181] / system / app / A2.XXX:
[0182] Map1 (address of data to be updated in the original super partition): starting address: 024018 (offset relative to the system starting address); offset size: 2 (i.e., data in the address range 024018 to 024020).
[0183] Map2 (the address of the updated data stored in the cow file): starting address: 045033 (offset relative to the starting address of the cow file); offset size: 2 (i.e., the data in the address range of 045033 to 045035);
[0184] / system / user / C2.XXX:
[0185] Map1 (address of data to be updated in the original super partition): starting address: 024036 (offset relative to the system starting address); offset size: 4 (data in the address range 024036 to 024040).
[0186] Map2 (the address of the updated data stored in the cow file): starting address: 045036 (offset relative to the starting address of the cow file); offset size: 4 (i.e., the data in the address range of 045036 to 045040).
[0187] When the size of the updated data in the COW file is inconsistent with the size of the original data to be updated, the COW file map of the COW file (system_b-cow-img.img.0000) itself can be:
[0188] / system / app / A2.XXX:
[0189] Map1.1 (address of data to be updated in the original super partition): starting address: 024018 (offset relative to the system starting address); offset size: 2 (i.e., data in the address range 024018 to 024020).
[0190] Map2.1 (the address of the updated data that needs to overwrite the address of Map1.1 stored in the cow file): starting address: 045033 (offset relative to the starting address stored in the cow file); offset size: 2 (i.e., the data in the address range of 045033 to 045035);
[0191] Map1.2 (the address in the original super partition where the updated data in the cow file exceeds the size of the data to be updated): Starting address: 025018 (offset relative to the system starting address); Offset size: 1 (i.e., the data in the address range 025018 to 025020).
[0192] Map2.2 (the address of the updated data that needs to overwrite the address of Map1.2 stored in the cow file): starting address: 046033 (offset relative to the starting address stored in the cow file); offset size: 2 (i.e., data in the address range of 046033 to 046035).
[0193] In the following description, for ease of explanation, we will only use the following application scenario as an example: the size of the updated data in the COW file is the same as the size of the original data to be updated, and the location of the updated data in the COW file after the data update in the subpartition is the same as the location of the original data to be updated in the subpartition.
[0194] In the example above, the address ranges (045033~045035 and 045036~045040) are the physical storage addresses (block addresses) of the latest versions of / system / app / A2.XXX and / system / user / C2.XXX in the user data partition (Userdata), respectively.
[0195] Thus, if A2.XXX at addresses 045033-045035 is used to replace A2.XXX at addresses 024018-024020, and C2.XXX at addresses 045036-045040 is used to replace C2.XXX at addresses 045036-045040, the data upgrade of the system subpartition in the dynamic partition (Super) can be completed.
[0196] Furthermore, in S402, after writing the COW file to the user data partition, it is also necessary to perform an overall verification of the dynamic partition (Super) + COW file to verify the validity of the dynamic partition (Super) + COW file and to verify whether the combined result of the current version of the dynamic partition (Super) data + COW file is the new version of the dynamic partition (Super) data.
[0197] In some examples, taking the upgrade from version 1.1 to version 1.2 as an example, the hash value of the combined result of the data in the dynamic partition (Super) that does not need to be upgraded (data that has not changed from version 1.1 to version 1.2) and the upgrade data in the COW file (data that needs to be upgraded from version 1.1 to version 1.2) is calculated. It is then determined whether this hash value is consistent with the hash value of the complete data in the dynamic partition (Super) in version 1.2. If they are consistent, the COW file is valid; if they are inconsistent, the COW file is invalid, the upgrade fails, the corresponding update engine process is interrupted, and an error is reported. The hash value of the complete data in the dynamic partition (Super) in version 1.2 is stored in the system upgrade package.
[0198] Specifically, during the verification process, the dynamic partition (Super) and COW file are merged based on the snapshot. In the implementation of the snapshot, the merging of the dynamic partition (Super) and COW file is not a physical merger, but rather a merging of the overall file map of the subpartition in the COW file with the COW file's own COW file map, generating a new version of the subpartition data's file map.
[0199] For example, a file map of the system subpartition:
[0200] / system / app / A0.XXX: 024010~024013;
[0201] / system / app / A1.XXX: 024014~024017;
[0202] / system / app / A2.XXX: 024018~024020;
[0203] / system / B0.XXX: 024021~024026;
[0204] / system / B1.XXX: 024027~024028;
[0205] / system / user / C0.XXX: 024029~024032;
[0206] / system / user / C1.XXX: 024033~024035;
[0207] / system / user / C2.XXX: 024036~024040;
[0208] / system / user / C3.XXX: 024041~024044.
[0209] Map with COW file:
[0210] / system / app / A2.XXX:
[0211] Map1: Address start: 024018; Size: 2 (i.e., data in the address range 024018 to 024020)
[0212] Map2: address start: 045033; size: 2 (i.e., data in the address range 045033 to 045035);
[0213] / system / user / C2.XXX:
[0214] Map1: address start: 024036; size: 4 (i.e., data in the address range 024036 to 024040)
[0215] Map2: address start: 045036; size: 4 (i.e., data in the address range 045036 to 045040).
[0216] Merge. This will give you a new version of the file map for the system subpartition:
[0217] / system / app / A0.XXX: 024010~024013;
[0218] (Points to A0.XXX under / system / app in the dynamic partition (Super))
[0219] / system / app / A1.XXX: 024014~024017;
[0220] (Points to A1.XXX under / system / app in the dynamic partition (Super))
[0221] / system / app / A2.XXX: 045033~045035;
[0222] (Points to A2.XXX in / Update / system_b-cow-img.img.0000 within the Userdata partition)
[0223] / system / B0.XXX: 024021~024026;
[0224] (Points to B0.XXX under / system in the dynamic partition (Super))
[0225] / system / B1.XXX: 024027~024028;
[0226] (Points to B1.XXX under / system in the dynamic partition (Super))
[0227] / system / user / C0.XXX: 024029~024032;
[0228] (Points to C0.XXX under / system / user in the dynamic partition (Super))
[0229] / system / user / C1.XXX: 024033~024035;
[0230] (Points to C1.XXX under / system / user in the dynamic partition (Super))
[0231] / system / user / C2.XXX: 045036~045040;
[0232] (Points to C2.XXX in / Update / system_b-cow-img.img.0000 within the Userdata partition)
[0233] / system / user / C3.XXX: 024041~024044.
[0234] (Points to C3.XXX under / system / user in the dynamic partition (Super))
[0235] In the new version of the file map for the system subpartition, the storage address of / system / app / A2.XXX does not point to / system / app / A2.XXX on the dynamic partition (Super) on storage, but rather to A2.XXX in system_b-cow-img.img.0000 within the user data partition (Userdata) on storage; similarly, the storage address of / system / user / C2.XXX does not point to / system / user / C2.XXX on the dynamic partition (Super) on storage, but rather to C2.XXX in system_b-cow-img.img.0000 within the user data partition (Userdata) on storage.
[0236] During the verification process, following the above synthesis method, new versions of file maps for all sub-partitions of the dynamic partition (Super) are obtained (if a corresponding COW file for a sub-partition is not written in the user data partition (Userdata), then the file map of that sub-partition is directly used as the new version of the file map). The new versions of the file maps for all sub-partitions are combined to generate a new version of the file system for the dynamic partition (Super).
[0237] Data is read from the new version of the file system based on dynamic partitions (Super), and all files contained in the new version of the file system based on dynamic partitions (Super) are read and their hash values are calculated.
[0238] When the COW file is valid, the disk write status information in the metadata partition ( / metadata) of the base partition (Common) is changed from "merged" to "wait for merge". The disk write status information indicates whether a COW file needs to be written to the dynamic partition (Super). Specifically, the disk write status information includes an overall identifier for the dynamic partition (Super) and subpartition identifiers for each subpartition. When the overall identifier is "merged", it means that none of the subpartitions of the dynamic partition (Super) need to be written to disk; when the overall identifier is "wait for merge", it means that one or more subpartitions of the dynamic partition (Super) need to be written to disk; when a subpartition identifier is "merged", it means that the subpartition does not need to be written to disk; when a subpartition identifier is "wait for merge", it means that the subpartition needs to be written to disk.
[0239] In some embodiments, after S402 described above, the electronic device can perform a card slot switch. This card slot switch operation does not immediately change the currently running operating system; that is, the electronic device does not immediately switch from running system A to system B. When the electronic device is started next time, the system data corresponding to system B is loaded, and thus, it runs on system B.
[0240] For example, the Common partition of an electronic device includes an MBR, which is configured with a boot order identifier. When the electronic device boots the operating system, it can read the boot order identifier from the MBR and determine the static partition (static partition A or static partition B) to be loaded based on the boot order identifier, that is, whether to boot system A or system B. The aforementioned card slot switching can be achieved by the electronic device rewriting the boot order identifier of the MBR, for example, changing the boot order identifier from A to B. In this way, after the electronic device restarts, it can load the data of static partition (B) and switch to running system B. In addition, in other possible embodiments, the MBR can also be stored in other partitions, for example, both static partition (A) and static partition (B) are configured with MBRs, and the boot order identifiers configured in the MBRs of the two static partitions are the same.
[0241] S403, Electronic device restarts.
[0242] In some embodiments, exit the current operating system, disconnect the device power, and then turn the device power back on.
[0243] S404, the electronic device loads the basic partition (Common) and the static partition (B) in sequence.
[0244] In some embodiments, during the reboot process, if the electronic device recognizes the boot sequence identifier as B, then the boot sequence of the electronic device is changed from booting from the static partition (A) to booting from the static partition (B).
[0245] For example, before restarting an electronic device, the boot order identifier in the Master Boot Record (MBR) is rewritten from A to B. After the electronic device is powered on, if it reads the boot order identifier as A, it boots from the static partition (A) and loads the static partition (A) during the boot process; if it reads the boot order identifier as B, it boots from the static partition (B) and loads the static partition (B) during the boot process.
[0246] For example, the electronic device first loads the common partition. During the loading of the common partition, the electronic device reads the boot flag in the common partition; when the boot flag in the common partition is (A), the electronic device loads the static partition (A) after loading the common partition, and thus boots from the static partition (A); when the boot flag in the common partition is (B), the electronic device loads the static partition (B) after loading the common partition, and thus boots from the static partition (B).
[0247] In S404, the electronic device reads the boot flag in the basic partition (Common). The boot flag in the basic partition (Common) is (B). After loading the basic partition (Common), the electronic device loads the static partition (B) and boots from the static partition (B).
[0248] S405, the electronic device loads a virtual dynamic partition of dynamic partition (Super) and user data partition (Userdata).
[0249] Specifically, the electronic device reads the disk write status information from the metadata ( / metadata), determines whether it needs to retrieve the COW file from the specified path of the user data partition (Userdata) based on the disk write status information, and uses a snapshot to merge and load the dynamic partition (Super) and the COW file.
[0250] Furthermore, in S405, the electronic device does not load all COW files from the dynamic partition (Super) and the user data partition (Userdata). Instead, it loads the corresponding files based on the operating system's requirements. Specifically, in S405, the electronic device determines the files to be loaded based on the operating system's requirements and extracts the corresponding files from the COW files in the dynamic partition (Super) or the virtual dynamic partition based on a snapshot for loading.
[0251] Specifically, in S405, when a corresponding COW file exists in a subpartition of the dynamic partition (Super), a new version of the file map for each subpartition of the dynamic partition (Super) is first generated based on the snapshot. The process of generating the new version of the file map can be referred to in S402. The electronic device determines the files to be loaded according to the operating system's requirements and loads the files based on the new version of the file map of the dynamic partition (Super) subpartitions.
[0252] For example, the operating system requires loading all data in the user directory ( / system / user) under the system subpartition. The electronic device reads the disk persistence status information from the metadata ( / metadata). In this information, the subpartition of the system subpartition is marked as "wait for merge." Therefore, the electronic device searches for COW files under / Update in the user data partition. After finding the COW file system_b-cow-img.img.0000 under Update, it generates a new version of the file map for the system subpartition based on the snapshot and the file map of the COW file in system_b-cow-img.img.0000. Data is then loaded according to the storage addresses of all files under / system / user in the new version of the file map for the system subpartition. For example, based on the new version of the file map for the system subpartition:
[0253] / system / user / C0.XXX: 024029~024032;
[0254] / system / user / C1.XXX: 024033~024035;
[0255] / system / user / C2.XXX: 045036~045040;
[0256] / system / user / C3.XXX: 024041~024044.
[0257] Load C0.XXX at addresses 024029-024032, C1.XXX at addresses 024033-024035, C2.XXX at addresses 045036-045040, and C3.XXX at addresses 024041-024044.
[0258] In some examples, when loading all data in the user directory ( / system / user) under the system subpartition, if the subpartition of the system subpartition is marked as "merged" in the disk status information, the electronic device will not search for COW files under / Update in the user data partition (Userdata), but will directly load all data in the user directory ( / system / user) under the system subpartition.
[0259] In other examples, when loading all data in the user directory ( / system / user) under the system subpartition, if the subpartition of the system subpartition is marked as "wait for merge" in the disk status information, and the electronic device does not find the corresponding COW file of the system subpartition in the user data partition ( / Update), it indicates that there was a data writing error during the upgrade process (COW file writing error or disk status information writing error). At this time, the electronic device rolls back the system and reports an error.
[0260] Furthermore, in S405, the electronic device needs to verify the file before loading it. Unlike S402, S405 does not perform overall verification of the dynamic partition (Super) + COW file, but only verifies the file to be loaded. For example, verification is based on dmverity (dm-verity is a target of dm (device mapper), a virtual block device specifically used for file system verification). If the verification is successful, the file is loaded; if the verification fails, the device is restarted, the system is rolled back, or the file is tried to be loaded again.
[0261] The above S401 to S405 are part of the A / B upgrade scheme. During the A / B upgrade process, the electronic device can also execute S106 to S109.
[0262] For example, after the electronic device executes S402, the process proceeds to S106. Then, after the electronic device completes S107 to S109, the process proceeds to S403 (i.e., S110) for a restart. After a successful restart, the electronic device executes S404 and S405, and then the process proceeds to S111, triggering the merge process, which is another part of the A / B upgrade scheme.
[0263] For example, when the electronic device executes S401, it can asynchronously execute S106 to S109. Of course, S109 needs to be completed before S403 (that is, S110). In this way, after the electronic device restarts, it executes S404 and S405, and then the process enters S111, triggering the merge process.
[0264] For example, after the electronic device executes S402 and then switches the card slot, it can execute S106. After S109 is executed, the electronic device can be triggered to restart, that is, to execute S403 (or S110).
[0265] S106, Update Engine detected a modified small package in the system upgrade package.
[0266] In some embodiments, the update engine detects the package name of the modified package in the system upgrade package, such as update_base_demochange.zip, to determine that a modified package has been detected. In other embodiments, the update engine detects a modification tag in the system upgrade package, such as demochange.tag, to determine that a modified package exists in the system upgrade package.
[0267] S107, the update engine reads the target version's VC information from the system upgrade package.
[0268] In some embodiments, the system upgrade package includes a file containing VC information, such as the vendor_country.mbn file, also known as a second-format file. In this scenario, after parsing the system upgrade package, the VC information of the target version, also known as second-format information, can be obtained from the vendor_country.mbn file.
[0269] S108, the update engine writes the read VC information to oeminfo_vc_tmp.
[0270] In some embodiments, the aforementioned `oeminfo_vc_tmp` is a temporary file within the `oeminfo` subpartition, occupying temporary storage space within that subpartition. `oeminfo_vc_tmp` is different from the `oeminfo_vc` file within the `oeminfo` subpartition. The `oeminfo_vc` file includes VC information from before the system upgrade (e.g., VC information from version 1.1). It is understandable that `oeminfo_vc_tmp` and `oeminfo_vc` actually occupy different physical addresses within the `oeminfo` subpartition. Furthermore, the storage address corresponding to the `oeminfo_vc` file is the address where the electronic device loads the VC information. Therefore, when the electronic device loads system data, it will load the `oeminfo_vc` file instead of `oeminfo_vc_tmp`.
[0271] Furthermore, it is understood that the above-described S108 is merely an example of temporarily storing the VC information of the target version in the system upgrade package. Other implementations are also possible, such as writing the VC information of the target version to other readable temporary storage areas. This application does not limit this approach.
[0272] In S109, the update engine unpacks the modified package to the cache / update directory. This modified package includes ptable and super_metadata.img.
[0273] In some embodiments, the aforementioned cache / update directory is a directory under a cache subpartition, also known as the first storage area, which belongs to the Common partition. Furthermore, this cache subpartition is a storage partition accessible in Recovery mode. After decompressing the modified package to the cache / update directory, the cache / update directory includes ptable and super_metadata.img.
[0274] S110, update engine triggers electronic device restart.
[0275] In some embodiments, the current operating system is exited, the device power is cut off, and the device power is turned on again. This step S110 is the same as the aforementioned S403, also known as the first restart. If the restart is successful, the electronic device executes S404 and S405. After executing S405, if it is determined that the current state is not disk-written, the process then proceeds to S111.
[0276] S111, the update engine triggers the merge process.
[0277] In some embodiments, the merge process is initiated when the new system takes effect after a reboot; that is, when the updated System B takes effect. Figure 5 As shown, the merge process includes:
[0278] S501, the electronic device has successfully started up and entered the user interface.
[0279] S502, the electronic device merges the data of the virtual dynamic partition into the dynamic partition (Super) in the background.
[0280] In other words, the electronic device writes the data of the virtual dynamic partition to the dynamic partition (Super) in the background. In this embodiment, the write-to-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 dynamic partition (Super) during the operating system upgrade process. This allows the files in the dynamic partition (Super) to complete the data upgrade, so that the electronic device does not need to load the dynamic partition (Super) and the virtual dynamic partition on the next boot. It only needs to load the dynamic partition (Super) to complete the boot process.
[0281] In some examples, the electronic device broadcasts a boot message after a successful boot, which then starts the updateengine process. The updateengine process reads the disk merge status information from the metadata ( / metadata) of the base partition (Common). If the disk merge status information is "merged", the device enters normal operating mode.
[0282] If the disk write status is "wait for merge", the update engine process will write the COW file in the user data partition to the dynamic partition (Super).
[0283] In some embodiments, the process corresponding to the update engine writes the upgrade data from the COW file in the Userdata partition to the corresponding address in the Super partition, so that all the data in the Super partition is the upgraded new version of the data.
[0284] For example, based on the file map of the system subpartition / system / app / A2.XXX:024018~024020 and the COW file map / system / app / A2.XXX:045033~045035, data at addresses 045033~045035 is written to addresses 024014~024017; based on the file map of the system subpartition / system / user / C2.XXX:024036~024040 and the COW file map / system / user / C2.XXX:045036~045040, data at addresses 045036~045040 is written to addresses 024036~024040.
[0285] After this, the process corresponding to the update engine deletes the COW files in the user data partition (Userdata), returns the storage space to the user data partition (Userdata), and changes the disk status information in the metadata ( / metadata) of the base partition (Common) from "wait for merge" to "merged".
[0286] In S401, the data operation for static partition upgrade targets the operating system data in the static partition (B) and does not affect the operating system data in the currently booted static partition (A). Furthermore, in S402, the data operation for dynamic partition upgrade is performed on the virtual dynamic partition created within the user data partition (Userdata), and it does not affect the currently mounted dynamic partition (Super). Therefore, the user can use the device normally throughout the entire operating system upgrade process. Moreover, after S402 is completed, the device does not need to be restarted immediately; the user can choose when to restart. Thus, the operating system upgrade process does not affect the user's normal phone operation, greatly improving the user experience. In this way, for the dynamic partition (Super), the virtual dynamic partition is only created on the user data partition (Userdata) when an upgrade is needed, effectively improving data storage space utilization.
[0287] In some embodiments, after the merge process is complete, the space occupied by data in the version-customized subpartition of the super partition decreases, while the location of the preload subpartition remains unchanged. At this point, free space (unusable storage space) is created between the version and preload subpartitions. The merge process ends, and the operating system's data structure is as follows: Figure 6 As shown, the starting address of the version sub-partition remains unchanged, while the ending address decreases, thus reducing the physical storage space occupied by the version sub-partition. The starting and ending addresses of the preload sub-partition remain unchanged, resulting in an unused physical storage area (i.e., free space) between the version and preload sub-partitions.
[0288] S112, the update engine copies the static partition of system B to the static partition of system A.
[0289] In some embodiments, S112 is only an example of a way to update the static partition (A). In this application embodiment, there may be other possible implementations. For example, the update engine can use a system upgrade package to update the data in the static partition (A). This application embodiment does not specifically limit this.
[0290] S113, the update engine writes the VC information in oeminfo_vc_tmp to the oeminfo_vc file in the oeminfo subpartition.
[0291] In some embodiments, the VC information stored in oeminfo_vc_tmp is the target version VC information (e.g., all cn) read from the system upgrade package. This VC information differs from the original VC information in the electronic device (i.e., demo cn, also known as the first standard information). In other words, the VC information in oeminfo_vc_tmp is different from the VC information recorded in the oeminfo_vc file. This oeminfo_vc file can be called the first standard file. Thus, after writing the target version VC information (e.g., all cn) into the oeminfo_vc file, the original VC information (i.e., democn) in the oeminfo_vc file can be overwritten, thereby changing the standard information. This process is also referred to as modifying the first standard information to the second standard information.
[0292] Furthermore, the aforementioned oeminfo subpartition is a Common partition. During the operating system startup process, it needs to read VC information from the oeminfo_vc file within the oeminfo subpartition. Therefore, by changing the VC information in the oeminfo_vc file, the electronic device's system standard can be changed.
[0293] After electronic devices have undergone a standard change, it is still necessary to further improve the problem of low storage space utilization.
[0294] In the embodiments of this application, such as Figure 3B As shown, it also includes:
[0295] S114, if the update engine detects that a modification package is included in the cache / update directory, it writes data indicating a modification upgrade to the cache / recovery / command file.
[0296] For example, the data indicating the modification and upgrade can be information indicating the storage path of the modification package. For instance, if the modification package is stored in the cache / update directory, the information indicating the storage path could be "update_package= / cache / update / update_base_demochange.zip". In this way, after the electronic device enters Recovery mode, it can find the modification package based on this storage path.
[0297] In other embodiments, the modified small package can be obtained after entering Recovery mode in other ways. For example, if the modified small package is detected in the cache / update directory, the data indicating the modification upgrade can also be the modified small package itself. That is, after the modified small package is detected in the cache / update directory, the modified small package is moved to the cache / recovery directory.
[0298] S115, update engine triggered a reboot and indicated entry into Recovery mode.
[0299] In some embodiments, the above-mentioned reboot is also referred to as the second reboot. In addition, after indicating to enter Recovery mode, the Recovery process is enabled and the process enters S116.
[0300] S116, the Recovery process verifies the integrity of the system upgrade package.
[0301] In some embodiments, the above-described S116 may refer to the implementation of verifying the integrity of the upgrade package in related technologies, and will not be repeated here.
[0302] S117, when the Recovery process determines that the current scenario is a modification and upgrade based on the cache / recovery / command file, it configures the global variable vcdemo.
[0303] In some embodiments, the Recovery process can parse the command file in the cache / recovery / directory to obtain a storage path. The Recovery process then accesses the corresponding storage space based on this path. If a data packet exists in this storage space, and the packet name matches a predefined modification packet name, the current scenario is determined to be a modification / upgrade. Alternatively, if the data packet contains an identifier indicating modification, the current scenario can also be determined to be a modification / upgrade.
[0304] In some embodiments, when it is determined that the current scenario is a modification and upgrade, the Recovery process writes the global variable vcdemo (also known as the first indication information) to a specified storage location (e.g., in a cache accessible to the Recovery process, such as the second storage area).
[0305] Understandably, configuring the global variable `vcdemo` to indicate that this upgrade is a modification upgrade is only one implementation method. In other embodiments, the Recovery process can be prompted to perform subsequent processes of modification upgrade in other ways, such as the electronic device actively querying the `cache / update` directory for modification packages.
[0306] S118, upon recognizing the variable vcdemo, the Recovery process executes preload data migration.
[0307] In some embodiments, the preload data mentioned above is the data stored in the preload sub-partition after the merge process is completed. The principle of the above preload data migration is as follows: Figure 7 As shown: The electronic device first copies the data in the preload subpartition and the last data in the super partition to the end of the userdata partition. The last data in the super partition refers to the data stored after the preload subpartition, for example... Figure 7 The 3M tail data is marked in the code. Then, the data in the preload sub-partition of the userdata partition and the tail data of the super partition are written back to the super partition. For example, you can first obtain super_metadata.img, also known as the second partition table, from the modified small package. Then, obtain the starting address (also known as the second address) of the preload sub-partition indicated in super_metadata.img. It can be understood that the starting address of the preload sub-partition in super_metadata.img is the same as the starting address of the free space, that is, it is adjacent to the ending address of the version-customized sub-partition after the merge. In this way, the free space in the super partition can be utilized.
[0308] As one implementation method, the process of performing preload data migration is as follows: Figure 8 As shown, it includes:
[0309] S801, the Recovery process reads the super header information from the super partition.
[0310] In some embodiments, the super header information described above may be stored in the top 1MB of storage space of the super partition. The super header information includes data describing the starting address and size of each subpartition in the current super partition. In other words, the super header information includes a first partition table, which includes a first address indicating the starting physical address of the first subpartition in the memory. For example, before merging, the super header information indicates the starting address and size of the version subpartition and the preload subpartition, as shown below:
[0311] Super: 17295360..34072576: version_b(16777216sectors);
[0312] Super: 34072576..37152768: preload_b(3080192sectors);
[0313] In other words, before merging, the starting address of the version sub-partition was "physical address 17295360" and the ending address was "physical address 34072576". The size of the version sub-partition was 16,777,216 sectors, which means it occupied approximately 8-9 GB of storage space. The starting address of the preload sub-partition was "physical address 34072576" and the ending address was "physical address 37152768". The size of the version sub-partition was 3,080,192 sectors.
[0314] Additionally, after merging, the super header information indicates the starting address and size of the version subpartition and the preload subpartition, as shown below:
[0315] Super: 17295360..17360896: version_b(65536sectors);
[0316] Super: 34072576..37152768: preload_b(3080192sectors);
[0317] As can be seen, after merging, the starting address of the version sub-partition is "physical address 17295360", the ending address is "physical address 17360896", and the size of the version sub-partition is 65536 sectors. The starting address of the preload sub-partition is "physical address 34072576", the ending address is "physical address 37152768", and the size of the version sub-partition is 3080192 sectors.
[0318] Clearly, there is free space between the version subpartition and the preload subpartition, that is, the storage space between physical address 17360896 and physical address 34072576. This free space cannot be actually used.
[0319] S802, the Recovery process parses the size of the preload data and the current position attribute (currentpos) from the super header information.
[0320] Continuing with the previous example, the size of the preload data could be 3080192 sectors, and the current position attribute (currentpos) could be the physical address 34072576. That is, the preload data starts from physical address 34072576 and reads data of size 3080192 sectors.
[0321] S803: The Recovery process reads preload data from the super partition based on the size of the preload data and the current position.
[0322] For example, starting from the physical address indicated by currentpos (e.g., physical address 34072576), a specified size (e.g., 3080192 sectors) of data is read from the super partition as preload data.
[0323] S804, the Recovery process writes preload data to an empty area in the userdata partition.
[0324] In some embodiments, preload data may be written to the storage space at the end of the userdata partition.
[0325] S805, the Recovery process reads the target location (dstpos) from the modified packet's super_metadata.img.
[0326] In some examples, the target location (dstpos) mentioned above is the starting address of the preload partition corresponding to the target version. Understandably, the super_metadata.img file contains information such as the starting address and size of each partition after the version change.
[0327] For example, the starting addresses and sizes of the version and preload sub-partitions in super_metadata.img are shown below:
[0328] Super: 17295360..17360896: version(65536sectors);
[0329] Super: 17360896..20441088: preload(3080192sectors);
[0330] Thus, the target location (dstpos) read from super_metadata.img can be the physical address 17360896.
[0331] S806, the Recovery process rewrites the preload data in the userdata partition to the super partition based on the target location (dstpos).
[0332] In some embodiments, the preload data is written back to the super partition by overwriting the storage address indicated by the target location (dstpos). For example, the preload data is written back to the super partition by starting at physical address 17360896.
[0333] In addition to needing to migrate the preload data, such as Figure 7As shown, the tail data of the super partition (referred to as the second data) also needs to be migrated synchronously. It can be understood that the tail data of the super partition mentioned above is the data stored in the super partition after the preload data. For ease of description, the preload data and the tail data of the super partition can be referred to as data 1 or the first data. For example, when the Recovery process determines that the tail space in the super partition after the preload subpartition still includes 3MB of data, after reading the preload data, it continues to read 3MB of data starting from the end address of the preload subpartition, thus reading data 1. Then, the read data 1 is first written to an empty area in the userdata partition, and then, starting from the aforementioned target address (dstpos), data 1 in the userdata partition is written back to the super partition.
[0334] Alternatively, after resolving the location attribute (currentpos) of the preload subpartition, such as address a or the first address, the end address (also known as the end physical address), such as address b or the third address, of the super partition is resolved from the partition table (also known as the third partition table) of the Common partition. Then, all data written between address a and address b is read as data 1. Next, the read data 1 is first written to an empty area in the userdata partition, and then, starting from the aforementioned target location (dstpos), data 1 in the userdata partition is written back to the super partition. In S119, the Recovery process updates the partition table in the Common partition using the ptable in the modified packet.
[0335] In some embodiments, the ptable mentioned above includes the start and end addresses of the Common partition, system partition, and user data partition (Userdata) in the storage space under the target version. This ptable is also called the fourth partition table. The fourth partition table also includes a fifth address, which is used to indicate the starting physical address of the user data partition in the memory after the upgrade is completed.
[0336] Of course, the Common partition originally included a partition table, such as partition table a or the third partition table. This partition table a can be used to indicate the starting address (also known as the fourth address) and ending address of the Common partition, system partition, and user data partition in the storage space after the merge. Among them, the ptable mentioned above indicates a smaller system partition than partition table a, that is, the fifth address comes before the fourth address.
[0337] Understandably, after S111 above, that is, after the electronic device is merged, free space will appear between the version subpartition and the preload subpartition. After migrating the preload data and the tail data of the super partition, there will be idle space at the tail of the super partition. At this point, using ptable to replace the partition table 'a' in Common, the idle space at the tail of the super partition can be allocated to the user data partition (Userdata), such as... Figure 9 As shown. Prior to this, the storage location of preload data was moved forward. Electronic devices can load system data normally according to the updated partition table in Common. In other words, without affecting system data, the user data partition available to the user increases, improving the user experience.
[0338] S120, the Recovery process updates the super_metadata.img in the modified small packet to the super header information.
[0339] In some embodiments, the header storage area of the super partition ( Figure 9 The 1MB storage space indicated in the image (also known as the super_metadata partition) stores header information, also called the super header information. This super header information includes a sub-partition table. This sub-partition table records the starting address and size of each sub-partition of the original super partition of the electronic device. In this embodiment, the actual location of the preload data has been moved forward, and the upward movement is referenced to super_metadata.img. This means that after upgrading to the target version, the version-customized sub-partition needs to be shrunk, and the starting position of the preload partition also moves upward. It can be understood that the version-customized sub-partition size recorded in super_metadata.img is the shrunk size, and the starting position of the preload partition is also the moved address. Thus, after the electronic device writes super_metadata.img into the super header information, replacing the atomic partition table, the electronic device can normally load the data in the preload partition after starting the operating system.
[0340] Following the previous example, before the super header information is updated in super_metadata.img, the super header information records: the starting address of the version sub-partition is "physical address 17295360" and the ending address is "physical address 17360896"; the starting address of the preload sub-partition is "physical address 34072576" and the ending address is "physical address 37152768".
[0341] After the super header information is updated in super_metadata.img, the super header information records: the starting address of the version subpartition is "physical address 17295360" and the ending address is "physical address 17360896"; the starting address of the preload subpartition is "physical address 17360896" and the ending address is "physical address 20441088". In this way, after the preload data is moved forward, the electronic device can accurately read the data.
[0342] As an example, such as Figure 10 As shown, in Android systems employing the virtual A / B upgrade method, only static partitions use the A / B scheme, while dynamic partitions use a scheme where virtual dynamic partitions are constructed during the upgrade. Therefore, to ensure matching between static and dynamic partitions, the metadata ( / supermetadata) in the super header information, also known as the header of the dynamic partition (Super), includes Slot0 (slot one data) for the corresponding static partition (A) and Slot1 (slot two data) for the static partition (B). Slot0 and Slot1 are used to store the partition table of the Super partition.
[0343] For example, in the UFS MBR, the device boot sequence description specifies that Slot0 corresponds to booting from static partition (A), and Slot1 corresponds to booting from static partition (B). During device boot, depending on the static partition being booted, the device selects either Slot0 or Slot1 to retrieve the Super partition's partition information. For instance, when the device boots from static partition A, it first reads Slot0 to obtain the Super partition's sub-partition addresses when loading the Super partition; similarly, when the device boots from static partition B, it first reads Slot1 to obtain the Super partition's sub-partition addresses.
[0344] Specifically, Slot0 and Slot1 contain multiple subpartition description groups, each corresponding to a subpartition of the Super partition. Each subpartition description group contains:
[0345] The Name field contains the name of the sub-partition.
[0346] The Group item has a value indicating the sub-partition type.
[0347] The Attributes item has values for partition read / write attributes, such as the read-only attribute.
[0348] The Address (Extents) field contains the address of the sub-partition (e.g., partition size, offset).
[0349] In the Name and Group fields, if the value ends in _a, it corresponds to a static partition (A); if the value ends in _b, it corresponds to a static partition (B).
[0350] When booting from static partition A and loading the Super partition, Slot0 is read first. When reading Slot0, since the suffix _a corresponds to static partition (A), the device reads the value of the Extends item in the partition description group with the suffix _a in the Name and / or Group items of Slot0 to obtain the address of the sub-partition of the Super partition.
[0351] When booting from static partition B and loading the Super partition, Slot1 is read first. While reading Slot1, since the suffix _b corresponds to static partition (B), the device reads the value of the Extensions item in the partition description group with the suffix _b in Slot0, which is the Name item and / or Group item, to obtain the address of the sub-partition of the Super partition.
[0352] The modified package contains the partition information of the target version's dynamic partition (Super), namely, super_metadata.img. Electronic devices can use super_metadata.img to refresh the partition information in Slot 1 corresponding to the static partition (B). For example, refer to S120.
[0353] Taking the preload subpartition as an example, Slot 1 of / supermetadata in the dynamic partition (Super) contains the following:
[0354] Metadata version: 10.2;
[0355] Metadata size: 1300 bytes;
[0356] Metadata max size:65536bytes;
[0357] Metadata slot count: 3;
[0358] Header flags:virtual_abdevice;
[0359] Partition table:------------------------;
[0360] Name: preload_b;
[0361] Group:ry_dynamic_partitions_b;
[0362] Attributes:readonly,updated;
[0363] Extents:34072576..37152768; The super_metadata.img file in the modified package contains the following content:
[0364] Name: preload;
[0365] Group:ry_dynamic_partitions;
[0366] Extents:17360896..20441088; The device locates Slot 1 of / supermetadata in the dynamic partition (Super) of the static partition (B) that needs to be upgraded, and refreshes the contents of Slot 1 using super_metadata.img. Slot 1 of / supermetadata in the dynamic partition (Super) contains the following:
[0367] Metadata version: 10.2;
[0368] Metadata size: 1300 bytes;
[0369] Metadata max size:65536bytes;
[0370] Metadata slot count: 3;
[0371] Header flags:virtual_ab_device;
[0372] Partition table:------------------------;
[0373] Name: preload_b;
[0374] Group:ry_dynamic_partitions_b;
[0375] Attributes:readonly,updated;
[0376] Extents:17360896..20441088;
[0377] S121, The Recovery process determines that the VC information in the oeminfo subpartition has been changed.
[0378] In some embodiments, the Recovery process checks whether the VC information in the oeminfo subpartition has changed, i.e., it is no longer demo cn. If it is determined that it has changed, the process proceeds to S122. If it is determined that it has not changed, the VC information change process is executed again. For example, the vendor_country.mbn file in the modified package is written to the oeminfo_vc file in the oeminfo subpartition, replacing the original VC information.
[0379] S122, format the Userdata partition and restart.
[0380] In some embodiments, the userdata partition needs to be reset, and the metadata partition and data partition need to be formatted.
[0381] In this way, electronic devices can support remote HOTA upgrades, enabling the transition from demonstration to commercial use, avoiding the need for prototype recycling and delivery, and saving on the manpower costs of flashing firmware.
[0382] As one implementation method, taking the operating system upgrade of an electronic device running on system A as an example, the implementation process of the above operating system upgrade method is as follows: Figure 11 As shown:
[0383] A1, upgrade the server and release the system upgrade package.
[0384] In some embodiments, the implementation details of A1 above can be found in S101, and will not be repeated here.
[0385] A2, ouc apk obtains the system upgrade package, which includes a modified small package and VC information for the target version.
[0386] In some embodiments, the implementation details of A2 described above can be found in S102, and will not be repeated here.
[0387] A3, ouc apk triggers update engine to enter the upgrade process.
[0388] In some embodiments, the implementation details of A3 described above can be found in S103, and will not be repeated here.
[0389] A4, Update Engine verification system upgrade package.
[0390] In some embodiments, the implementation details of A4 above can be found in S104, and will not be repeated here.
[0391] A5, the update engine, performs data writing operations on the static partition of system B based on the system upgrade package when system A is running.
[0392] In some embodiments, the implementation details of A4 described above can be found in S401, and will not be repeated here. Similarly, in the scenario of upgrading the operating system of an electronic device running on system B, the update engine performs data writing operations on the static partition of system B based on the system upgrade package.
[0393] A6, the update engine creates virtual dynamic partitions in the user partition.
[0394] In A7, the update engine writes the data from the system upgrade package used to upgrade the dynamic partition to the virtual dynamic partition.
[0395] In some embodiments, the implementation details of A6 and A7 described above can be found in S402, and will not be repeated here.
[0396] In A8, the update engine will change the identifier that indicates booting from the static partition of system A to indicate booting from the static partition of system B.
[0397] In some embodiments, the update engine can rewrite the boot order identifier of the Master Boot Record (MBR), for example, changing the boot order identifier from A to B. In this way, after the electronic device restarts, it can load the data of the static partition (B) and thus switch to running system B.
[0398] A9, Update Engine has determined that the system upgrade package includes a modification package.
[0399] In some embodiments, the implementation details of A9 described above can be found in S106, and will not be repeated here.
[0400] A10, the update engine reads the target version's VC information from the system upgrade package.
[0401] In some embodiments, the implementation details of A10 described above can be found in S107, and will not be repeated here.
[0402] A11, the update engine writes the read VC information to oeminfo_vc_tmp.
[0403] In some embodiments, the implementation details of A11 described above can be found in S108, and will not be repeated here.
[0404] In A12, the update engine extracts the modified package to the cache / update directory. This modified package includes ptable and super_metadata.img.
[0405] In some embodiments, the implementation details of A12 described above can be found in S109, and will not be repeated here.
[0406] A13, the update engine triggers an electronic device restart.
[0407] In some embodiments, the implementation details of A13 described above can be found in S110, and will not be repeated here. Additionally, upon successful reboot, the electronic device can load the static partition of system B, and the process proceeds to A14.
[0408] A14, the update engine triggers the merge process.
[0409] In some embodiments, the implementation details of A14 described above can be found in S111, and will not be repeated here.
[0410] A15, the update engine copies the static partition of system B to the static partition of system A.
[0411] In some embodiments, the implementation details of A15 described above can be found in S112, and will not be repeated here.
[0412] A16, the update engine writes the VC information in oeminfo_vc_tmp to the oeminfo_vc file in the oeminfo subpartition.
[0413] In some embodiments, the implementation details of A16 described above can be found in S113, and will not be repeated here.
[0414] A17: If the update engine detects that a modified package is included in the cache / update directory, it writes the storage address of the modified package into the cache / recovery / command file.
[0415] In some embodiments, the implementation details of A17 described above can be found in S114, and will not be repeated here.
[0416] A18, update engine triggered a reboot and indicated entry into Recovery mode.
[0417] In some embodiments, the implementation details of A18 described above can be found in S115, and will not be repeated here. Alternatively, the electronic device can initiate the Recovery process based on the information instructing it to enter Recovery mode, thus proceeding to A19.
[0418] A19, the Recovery process verifies the integrity of the system upgrade package.
[0419] In some embodiments, the implementation details of A19 described above can be found in S116, and will not be repeated here.
[0420] A20: When the Recovery process finds the modified small package based on the cache / recovery / command file, it configures the global variable vcdemo.
[0421] In some embodiments, the implementation details of A20 described above can be found in S117, and will not be repeated here.
[0422] A21. Upon recognizing the variable vcdemo, the Recovery process migrates the preload data based on super_metadata.img.
[0423] In some embodiments, the implementation details of A21 described above can be found in S801 to S806, and will not be repeated here.
[0424] A22, the Recovery process updates the ptable in the modified package to the partition table in Common.
[0425] In some embodiments, the implementation details of A22 described above can be found in S119, and will not be repeated here.
[0426] A23, the Recovery process will update the super_metadata.img in the modified small package to the super header information.
[0427] In some embodiments, the implementation details of A23 described above can be found in S120, and will not be repeated here.
[0428] A24, The Recovery process has determined that the VC information in the oeminfo subpartition has been changed.
[0429] In some embodiments, the implementation details of A24 described above can be found in S121, and will not be repeated here.
[0430] A25, the Recovery process formats the Userdata partition and reboots.
[0431] In some embodiments, the implementation details of A25 described above can be found in S122, and will not be repeated here.
[0432] This application also provides an electronic device that may include a memory and one or more processors. The memory and processors are coupled. The memory stores computer program code, which includes computer instructions. When the processor executes the computer instructions, it causes the electronic device to perform the steps described in the above embodiments. Of course, the electronic device may include, but is not limited to, the memory and one or more processors described above, for example... Figure 3A As shown.
[0433] This application also provides a chip system that can be applied to the electronic devices described in the foregoing embodiments. For example... Figure 12 As shown, the chip system includes at least one processor 2201 and at least one interface circuit 2202. The processor 2201 may be a processor in the aforementioned electronic device. The processor 2201 and the interface circuit 2202 are interconnected via a circuit. The processor 2201 can receive and execute computer instructions from the memory of the aforementioned electronic device through the interface circuit 2202. When the computer instructions are executed by the processor 2201, the electronic device can perform the various steps in the above embodiments. Of course, the chip system may also include other discrete components, and this application embodiment does not specifically limit this.
[0434] In some embodiments, as described above, those skilled in the art will clearly understand that, for the sake of convenience and brevity, the division of the functional modules described above is merely an example. In practical applications, the functions described above can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device, and unit described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0435] In the embodiments of this application, the functional units can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0436] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, essentially, or the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as flash memory, portable hard disk, read-only memory, random access memory, magnetic disk, or optical disk.
[0437] The above description is merely a specific implementation of the embodiments of this application, but the protection scope of the embodiments of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the embodiments of this application should be covered within the protection scope of the embodiments of this application. Therefore, the protection scope of the embodiments of this application should be determined by the protection scope of the claims.
Claims
1. An operating system upgrade method, characterized in that, The invention is applied to an electronic device, which includes a memory, comprising a base partition, a dynamic partition, and a user data partition; the dynamic partition includes a first sub-partition, wherein the first sub-partition is adjacent to and follows a custom sub-partition in the dynamic partition, and the dynamic partition stores a first partition table, the first partition table including a first address, the first address indicating the starting physical address of the first sub-partition in the memory; The basic partition stores first standard information, and the method includes: Obtain a system upgrade package, which is used to upgrade the operating system; the system upgrade package includes second upgrade data, a second partition table, and second system standard information, the second system standard information being different from the first system standard information; the second partition table includes a second address, the second address indicating the starting physical address of the first subpartition in the memory after the upgrade is completed, the second address being located before the first address, and the second upgrade data being data used to update the dynamic partition; Decompress the second upgrade data in the system upgrade package to the user data partition; After the electronic device completes its first reboot, the second upgrade data in the user data partition is written to the dynamic partition; Modify the first system information in the basic partition to the second system information; After the electronic device restarts for the second time, it enters recovery mode; In recovery mode, the starting physical address of the first data is moved from the first address to the second address; wherein, the first data includes the data stored in the first sub-partition and the data stored in the dynamic partition whose storage location is after the first sub-partition; Modify the first partition table to the second partition table.
2. The method according to claim 1, characterized in that, The memory also includes a user data partition for storing user personal data. The base partition stores a third partition table, which includes a third address to indicate the end physical address of the current dynamic partition in the memory. The step of migrating the starting physical address of the first data from the first address to the second address includes: Read the first data from between the first address and the third address; Write the first data read into the blank storage area of the user data partition; After the write operation is completed, the first data in the user data partition is written to the dynamic partition, starting from the second address as the physical address.
3. The method according to claim 1, characterized in that, The second address is located after the first address.
4. The method according to claim 3, characterized in that, The memory also includes a user data partition. The base partition stores a third partition table, which includes a fourth address indicating the starting physical address of the user data partition in the memory. The system upgrade package also includes a fourth partition table, which includes a fifth address indicating the starting physical address of the user data partition in the memory after the upgrade is completed. The fifth address is located before the fourth address. After migrating the starting physical address of the first data from the first address to the second address, the method further includes: Update the third partition table using the fourth partition table.
5. The method according to any one of claims 1-4, characterized in that, The memory also includes a user data partition. After modifying the first partition table to the second partition table, the method further includes: It has been confirmed that the system information has been modified to the second system information; Format the user data partition.
6. The method according to any one of claims 1-4, characterized in that, After modifying the first partition table to the second partition table, the method further includes: It is determined that the format information in the basic partition is still the first format information; The second standard information is read again and written to the base partition again to replace the first standard information.
7. The method according to any one of claims 1-4, characterized in that, Before the electronic device is restarted for the first time, the method further includes: After parsing the system upgrade package, it is determined that the system upgrade package contains a modified small package; wherein, the second partition table is compressed into the modified small package; The second standard information is stored in the base partition as a temporary file; The modified package is decompressed into a first storage area; wherein, the first storage area is a storage area accessible to the electronic device in the recovery mode; Before migrating the starting physical address of the first data from the first address to the second address, the method further includes: Obtain the second address from the second partition table in the first storage area.
8. The method according to claim 7, characterized in that, After entering recovery mode, the method further includes: In the case of storing the modified small packet in the first storage area, first instruction information is written in the second storage area, wherein the second storage area comes from a cache accessible to the Recovery process; The step of migrating the starting physical address of the first data from the first address to the second address includes: after detecting the first indication information, migrating the starting physical address of the first data from the first address to the second address.
9. The method according to any one of claims 1-4, characterized in that, The memory also includes a user data partition, and before writing the second upgrade data in the user data partition to the dynamic partition, the method further includes: Create a virtual partition in the user data partition; write the second upgrade data into the virtual partition.
10. The method according to any one of claims 1-4, characterized in that, The memory further includes a first static partition and a second static partition. The electronic device is configured with a boot order identifier. The electronic device includes a first operating system and a second operating system. When the boot order identifier indicates booting from the first static partition, after the electronic device runs, it loads data from the base partition, the first static partition, and the dynamic partition to start the first operating system. Before obtaining the system upgrade package, the method further includes: booting from the first static partition and running the first operating system; Before the electronic device restarts for the first time, the method further includes: updating the system data in the second static partition with first upgrade data, wherein the first upgrade data is data used to update the static partition; Modify the boot order identifier in the base partition, wherein the modified boot order identifier indicates booting from the second static partition.
11. The method according to claim 10, characterized in that, After modifying the boot sequence identifier of the electronic device, the method further includes: During the first reboot, data from the base partition, the second static partition, the dynamic partition, and the virtual partition are loaded to run the second operating system; After the first reboot is completed, the data in the second static partition is mirrored to the first static partition.
12. An electronic device, characterized in that, An electronic device includes one or more processors and a memory; the memory is coupled to the processor and is used to store computer program code, the computer program code including computer instructions, wherein when the one or more processors execute the computer instructions, the one or more processors are used to perform the method as described in any one of claims 1-11.
13. A computer storage medium, characterized in that, Includes computer instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any one of claims 1-11.
Citation Information
Patent Citations
Method and equipment for configuring system of operating system and storage medium
CN114489813A
