System upgrading method, medium and electronic equipment
By synchronizing super_metadata_A and super_metadata_B in electronic devices, the problem of cold patch upgrades being performed after the OTA is upgraded, resulting in the electronic devices being unable to read dynamic partition data normally, and the effect of electronic devices being able to read dynamic partition data normally after the cold patch is upgraded.
Patent Information
- Application Number
- CN202311071743.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-23
- Publication Date
- 2025-03-04
AI Technical Summary
After the electronic device is upgraded for OTA and then cold patches are upgraded, the electronic device cannot correctly determine the physical address of the data in the dynamic partition, and thus cannot read the data in the dynamic partition normally.
By synchronizing super_metadata_A and super_metadata_B in the electronic device, the super_metadata in the slot corresponds to the dynamic partition when the electronic device switches to another slot after the cold patch of the static partition is upgraded, so that the electronic device can read the data of the dynamic partition normally.
Ensure that electronic devices can read dynamic partition data normally after upgrading cold patches for static partitions, solving the data reading problems after OTA upgrades and cold patch upgrades.
Smart Images

Figure CN119556948A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a system upgrade method, medium and electronic device. Background Art
[0002] With the development of over the air technology (OTA), remote upgrading of electronic devices through the wireless network interface of electronic devices (such as mobile phones) is becoming more and more popular. In order to reduce the waiting time of users during system upgrades, electronic devices can currently be upgraded in virtual A / B mode, that is, the data storage area of the electronic device contains two copies of system data (slotA and slotB). Each copy of system data includes static partition data and dynamic partition metadata (super_metadata).
[0003] However, if the electronic device first modifies the partition structure of the dynamic partition in the OTA upgrade, and then upgrades the static partition data of the electronic device through a cold patch, after the cold patch upgrade, the super_metadata selected by the electronic device to run will not correspond to the structure of the current dynamic partition, making it impossible for the electronic device to correctly determine the physical address of the data in the dynamic partition. Summary of the invention
[0004] In view of this, the present application provides a system upgrade method, medium and electronic device, which can synchronize super_metadata_A and super_metadata_B, so that after the electronic device performs a cold patch upgrade of the static partition, the electronic device switches to another slot, and the super_metadata and dynamic partition in the slot also correspond, so that the electronic device can read the data of the dynamic partition normally.
[0005] In a first aspect, a system upgrade method is provided, which is applied to an electronic device, wherein the memory of the electronic device includes a first static partition, a second static partition and a dynamic partition, the dynamic partition includes first metadata and second metadata, the first metadata corresponds to the first static partition, and the second metadata corresponds to the second static partition, the method comprising: when the electronic device runs based on the first static partition and the first metadata, obtaining a first upgrade package; upgrading the partition structure of the second static partition, the dynamic partition and the second metadata according to the first upgrade package; restarting the electronic device; after restarting the electronic device, running the electronic device based on the upgraded second static partition and the upgraded second metadata; updating the first metadata according to the upgraded second metadata; obtaining a cold patch upgrade file; and upgrading the data of the first static partition in the electronic device based on the cold patch upgrade file.
[0006] In the above scheme, the electronic device can be a mobile phone, a computer or other device, and the electronic device adopts a virtual A / B mode, that is, there are two copies of operating system data in the memory, including a first static partition and a first metadata, and a second static partition and a second metadata. After upgrading the second metadata, the electronic device can also update the first metadata so that the first metadata and the second metadata are consistent. In this way, even if the electronic device is upgraded with a cold patch again, when the electronic device switches to running based on the first metadata, the structure of the first metadata and the dynamic partition is corresponding, so that the electronic device can read the data of the dynamic partition normally.
[0007] In combination with the first aspect, in some implementations, the first upgrade package is an over-the-air (OTA) upgrade package.
[0008] In the above scheme, the first upgrade package can be an OTA upgrade package, and the OTA upgrade package and the cold patch upgrade file can be sent by the server to the electronic device. Specifically, the server may first send an OTA upgrade request or a cold patch upgrade request to the electronic device, and after the electronic device receives the user's consent to the OTA upgrade request or the cold patch upgrade, the electronic device will receive the OTA upgrade package or the cold patch upgrade file sent from the server. Furthermore, after the electronic device performs an OTA upgrade, the first metadata may be updated so that the first metadata and the second metadata are consistent. In this way, even if the electronic device performs a cold patch upgrade again, when the electronic device switches to loading the first metadata, the structure of the first metadata and the dynamic partition corresponds, so that the electronic device can read the data of the dynamic partition normally.
[0009] In combination with the first aspect, in some implementations, in response to the restart being completed, the first metadata is updated according to the upgraded second metadata.
[0010] In the above scheme, based on the electronic device completing the OTA upgrade, the electronic device can restart by itself, or it can prompt the user that the loading of the OTA upgrade package has been completed, and the user can choose whether to restart. The user can choose to restart the electronic device after receiving the restart prompt of the electronic device, or the user can restart the electronic device by the power button after a certain period of time. The electronic device can determine that the OTA upgrade has been completed by successfully restarting, and then update the first metadata so that the first metadata and the second metadata are consistent. In this way, even if the electronic device performs a cold patch upgrade again, when the electronic device switches to loading the first metadata, the structure of the first metadata and the dynamic partition corresponds, so that the electronic device can read the data of the dynamic partition normally.
[0011] In combination with the first aspect, in some implementations, after upgrading the data of the first static partition in the electronic device, it also includes: restarting the electronic device; after restarting the electronic device, running the electronic device based on the first static partition upgraded with the cold patch and the updated first metadata.
[0012] In the above scheme, after the electronic device updates the first metadata so that the first metadata and the second metadata are consistent, the electronic device can also perform a cold patch upgrade, and the cold patch upgrade can only modify the data of the static partition. In addition, since the electronic device runs through the second static partition and the second metadata, the cold patch upgrade file will be written to the first static partition. Since the first metadata has been synchronized with the second metadata, after the cold patch upgrade is completed, when the electronic device switches to loading the first metadata, the structure of the first metadata and the dynamic partition also corresponds, so that the electronic device can read the data of the dynamic partition normally.
[0013] In combination with the first aspect, in some implementations, before updating the first metadata according to the upgraded second metadata, the method further includes: obtaining the name and address of at least one subpartition in the first metadata and the upgraded second metadata, wherein the name of at least one subpartition in the first metadata includes a first identifier, and the name of at least one subpartition in the upgraded second metadata includes a second identifier; determining whether the first metadata and the upgraded second metadata are consistent according to the name and address of at least one subpartition in the first metadata and the upgraded second metadata; and updating the first metadata according to the upgraded second metadata if it is determined that the first metadata and the upgraded second metadata are inconsistent.
[0014] In the above solution, the electronic device will also determine whether the first metadata and the second metadata are consistent. If they are inconsistent, the first metadata will be updated to make the first metadata consistent with the second metadata. In this way, even if the electronic device is upgraded with a cold patch, when the electronic device switches to loading the first metadata, the structure of the first metadata and the dynamic partition are corresponding, so that the electronic device can read the data of the dynamic partition normally.
[0015] In combination with the first aspect, in some implementations, the second identifier in the name item and group item of at least one subpartition in the upgraded second metadata is replaced with the first identifier to obtain the name item and group item in the updated first metadata; and, based on the name item and group item in the updated first metadata, the address of at least one subpartition in the upgraded second metadata is synchronized to the corresponding subpartition in the first metadata in sequence.
[0016] In the above scheme, updating the first metadata includes modifying the suffixes of the name item and the group item of the second metadata to the corresponding suffixes of the first metadata, for example, modifying "_b" to "_a". Then the addresses of each partition in the second metadata are synchronized into the first metadata in turn. In this way, the first metadata and the second metadata can be made consistent. Even if the electronic device is upgraded with a cold patch again, when the electronic device switches to loading the first metadata, the structure of the first metadata and the dynamic partition is corresponding, so that the electronic device can read the data of the dynamic partition normally.
[0017] In combination with the first aspect, in some implementations, the subpartition includes at least one physical block, and the address of at least one subpartition includes the starting position, offset, size of the subpartition and the starting position, offset, size of at least one physical block contained in the subpartition.
[0018] In the above scheme, the addresses of each partition in the second metadata are synchronized into the first metadata in sequence, including the starting position, offset, and size of each sub-partition and each physical block in each partition. In this way, the structures of the dynamic partitions represented by the first metadata and the second metadata are consistent, and the electronic device can read the data of the dynamic partition normally through any metadata.
[0019] In combination with the first aspect, in some implementations, the electronic device also includes a basic partition, which includes startup identifiers of a first static partition and a second static partition. The method also includes: determining that the startup identifier of the first static partition is bootable; and running the electronic device based on the first static partition and the first metadata.
[0020] In the above scheme, the electronic device determines the currently executable system data through the startup identifier of the static partition, and the electronic device can also determine whether the electronic device has completed the OTA upgrade through the startup status symbol of the static partition. For example, if the electronic device receives an OTA upgrade package, and the startup identifier of the static partition is inconsistent before and after the restart, it can be considered that the electronic device has been OTA upgraded, and the electronic device will update the first metadata so that the first metadata and the second metadata are consistent. In this way, the electronic device can read the data of the dynamic partition normally through any metadata.
[0021] In a second aspect, the present application provides an electronic device, including a processor and a memory, wherein the memory is used to store instructions and the processor is used to execute instructions. When the processor executes the instructions, the method described in the first aspect is performed.
[0022] In a third aspect, the present application provides a computer-readable storage medium, in which instructions are stored. When the instructions are executed on an electronic device, the method described in the first aspect is executed.
[0023] In a fourth aspect, the present application provides a computer program product, which includes computer instructions. When the computer program product is executed by a computing device, the computing device performs the method described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for describing the embodiments are briefly introduced below.
[0025] Figure 1 It is a schematic diagram of a storage structure of an electronic device in a virtual A / B mode provided by an embodiment of the present application;
[0026] Figure 2A This is a schematic diagram of a scenario in which an OTA upgrade is performed first and then a cold patch upgrade is performed, provided in an embodiment of the present application;
[0027] Figure 2B This is a schematic diagram of a memory structure change in which an OTA upgrade is first performed and then a cold patch upgrade is performed, provided in an embodiment of the present application;
[0028] Figure 3 It is a schematic diagram of synchronizing metadata after an OTA upgrade provided by an embodiment of the present application;
[0029] Figure 4 It is a flowchart of a system upgrade method provided in an embodiment of the present application;
[0030] Figure 5 This is a schematic diagram of a data structure of a dynamic partition provided in an embodiment of the present application;
[0031] Figure 6 It is a code schematic diagram of a header file in a dynamic partition provided by an embodiment of the present application;
[0032] Figure 7 This is a schematic diagram of a code for defining various data item information in a header file in a dynamic partition provided by an embodiment of the present application;
[0033] Figure 8 It is a code schematic diagram for defining partition information included in metadata in a dynamic partition provided in an embodiment of the present application;
[0034] Fig. 9 It is a schematic diagram of a code for defining a physical block of each partition included in metadata of a dynamic partition provided by an embodiment of the present application;
[0035] Fig.10 It is a structural schematic diagram of a system upgrade device provided in an embodiment of the present application;
[0036] Fig.11 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0037] The illustrative embodiments of the present application include, but are not limited to, system upgrade methods, media, and electronic devices.
[0038] The memory of the electronic device includes a program storage area and a data storage area. The program storage area can store an operating system and at least one application required for a function (such as a sound playback function, an image playback function), etc. The data storage area can store data created during the use of the electronic device (such as audio data, a phone book), etc.
[0039] Exemplarily, regarding the storage program area, specifically in the technical solution provided in the embodiment of the present application, it can be a basic partition (common), a static partition and a dynamic partition (super). Regarding the storage data area, specifically in the technical solution provided in the embodiment of the present application, it can be a user data partition (userdata).
[0040] Electronic devices usually store the data in the program storage area and data storage area in a read only memory (ROM), and the partition deployment information in the ROM can be described by the partition table shown in Table 1. Among them, data such as bootloader, boot and patch belong to the above static partition.
[0041] Table 1
[0042]
[0043] Next, combine Figure 1 The partition structure of the virtual A / B mode involved in this application is introduced. Among them, the partition structure of the virtual A / B divides the static partition that occupies a small storage space into static partition A and static partition B. In addition, the dynamic partition that occupies a large storage space adopts a single partition. Figure 1 As shown, the storage area of the electronic device includes a basic partition (common), static partition A and static partition B, a dynamic partition (super) and a user data partition (userdata).
[0044] The data stored in the basic partition is data that does not participate in the operating system upgrade, including the status marks of static partition A and static partition B. For example, when the electronic device runs in static partition A, the status mark of static partition A is bootable, and the status mark of static partition B is unbootable. When slotB completes the upgrade, the electronic device will change the status mark of static partition B to bootable, and the status mark of static partition A to unbootable. In addition, the basic partition can also include standard information of the wireless communication method of the electronic device, such as the universal Chinese standard (allcn).
[0045] Static partition A specifically includes bootloader_a and boot_a. It may also include patch_a, vendor_boot_a, dtbo_a, vbmeta_a and other data. Correspondingly, static partition B specifically includes bootloader_b and boot_b. It may also include patch_b, vendor_boot_b, dtbo_b, vbmeta_b and other data.
[0046] The dynamic partition also includes multiple subpartitions, such as the system subpartition, system_ext subpartition, product subpartition, vendor subpartition, cust subpartition, odm subpartition, etc. The system subpartition includes common components of the operating system. The vendor subpartition includes binary files of the operating system open source project, such as the binary files of the Android operating system open source project (AOSP). The system_ext subpartition includes the location of non-AOSP components in the system subpartition. The product subpartition includes configurations and applications for specific products. The cust subpartition includes user-customized files, such as boot animations. The odm subpartition is an extension of the vendor subpartition and can include additional programs for the system on chip (SoC).
[0047] The dynamic partition also includes super_metadata_A and super_metadata_B. Super_metadata_A and super_metadata_B are used to describe the partition information of each sub-partition of the dynamic partition, that is, it contains multiple sub-partition description groups, each of which corresponds to a sub-partition of the dynamic partition. Each sub-partition description group contains:
[0048] The name item, whose value is the name of the subpartition;
[0049] The group item, whose value is the sub-partition type;
[0050] Attributes item, whose value is the partition read-write attribute, for example, read-only attribute;
[0051] The address (extents) item, whose value is the address of each physical block in the sub-partition, for example, the size (size), starting position (index), offset (offset) of the physical block. The data of the sub-partition can be stored in multiple physical blocks, and the multiple physical blocks can be distributed continuously or discretely.
[0052] In the name item and the group item, the specific attribute value includes an identifier, for example, the corresponding slot can be indicated by the suffix of the value. For example, if the suffix of the value of the name item and the group item is _a, it means that the data of super_metadata_A corresponds to static partition A and belongs to slot A. Similarly, if the suffix of the value of the name item and the group item is _b, it means that the data of super_metadata_B corresponds to static partition B and belongs to slot B.
[0053] The user data partition is used to store the user's personal data, such as applications installed by the user, pictures, documents, videos and other personal data saved by the user. The user data partition also includes the upgrade file of the dynamic partition. Among them, since the dynamic partition with a large amount of data is designed as a single partition in the virtual A / B mode, when upgrading the data of the dynamic partition, the data of the upgraded dynamic partition is written to the user data partition as a copy on write (COW) file, and when the electronic device is restarted, the upgrade file is read from the user data partition and then dropped into the sub-partition corresponding to the dynamic partition.
[0054] Next, combine Figure 1 This section describes the process of starting and upgrading electronic devices using virtual A / B mode.
[0055] When the electronic device starts, it will first load and parse the basic file. When the electronic device parses the basic file and finds that the status of static partition A is marked as bootable and the status of static partition B is marked as unbootable, the electronic device will load slotA, that is, load static partition A and super_metadata_A in the dynamic partition, and then load each sub-partition of the dynamic partition.
[0056] When the electronic device is undergoing an OTA upgrade, if the status of the current static partition A of the electronic device is marked as bootable, the slotB corresponding to the static partition B marked as unbootable will be upgraded. Among them, the OTA upgrade can modify the data of the static partition as well as the dynamic partition, including modifying the partition structure of the sub-partition in the dynamic partition, such as adjusting the storage range of the sub-partition or adjusting the sub-partition to a discrete distribution. When upgrading the data of the dynamic partition, the data of the upgraded dynamic partition is written to the user data partition as a COW file, and is not dropped to the dynamic partition until it is restarted. If the upgrade of the dynamic partition involves the modification of the partition information, super_metadata will also be modified, and, as shown above, super_metadata also corresponds to static partition A and static partition B, and is backed up as super_metadata_A and super_metadata_B. Static partition A and super_metadata_A constitute slotA, and static partition B and super_metadata_B constitute slotB. When modifying the partition information of the dynamic partition, super_metadata_B in slotB that is not currently running is also modified.
[0057] After the OTA upgrade is completed, the status mark of static partition B becomes bootable, and the status mark of static partition A becomes unbootable. Then, after loading the basic file, the electronic device will load the static partition B marked as bootable, and correspondingly load the super_metadata_B in the dynamic partition, and then load each sub-partition of the dynamic partition.
[0058] In addition to OTA upgrades, electronic devices can also be upgraded using patches, which include hot patches and cold patches. Among them, hot patches refer to patches that can directly rewrite the operating system program and directly run the updated operating system without restarting the electronic device. Cold patch upgrades refer to patches that involve replacing global variables, code segments, etc. in the memory, and require the electronic device to be restarted to take effect.
[0059] Similarly, in order to shorten the waiting time of users during the upgrade process, when the electronic device in virtual A / B mode performs a cold patch upgrade, if the current electronic device is running in slotA, the cold patch will be written to slotB. After restarting, slotB will be selected to run, thereby completing the cold patch upgrade.
[0060] A cold patch upgrade will only upgrade and modify the currently written sub-partition. For example, when upgrading the data in the static partition of an electronic device through a cold patch, the data in the dynamic partition will not be modified synchronously.
[0061] However, if the partition structure of the dynamic partition is modified during the upgrade of the electronic device, and then the static partition data needs to be upgraded through a cold patch, after the cold patch upgrade, the super_metadata selected by the electronic device to run will not correspond to the structure of the current dynamic partition, making it impossible for the electronic device to correctly determine the physical address of the data in the dynamic partition.
[0062] For example, Figure 2A As shown, taking mobile phone 20 as an example, mobile phone 20 initially runs in slot B. When mobile phone 20 initially runs in slot B, the structure of the memory can refer to Figure 2B In (A), at this time, the two system data slotA and slotB of the mobile phone 20 are both version 1.0, including static partition A and static partition B are 1.0 and super_metadata_A and super_metadata_B are also version 1.0.
[0063] If the mobile phone 20 initially runs in slot B and receives an OTA upgrade package from the server 10, the mobile phone 20 will load the OTA upgrade package into slot A. Specifically, the server 10 first sends an OTA upgrade request to the mobile phone 20, and the electronic device 10 receives the OTA upgrade package from the server 20 after the user agrees to the OTA upgrade request. When the mobile phone 20 updates slot A according to the OTA upgrade package, in addition to modifying the data of the static partition, it also includes adjusting the partition structure of the dynamic partition, such as adjusting the range of the odm sub-partition.
[0064] After the mobile phone 20 is restarted, the mobile phone 20 will run through the slotA after the OTA upgrade. Figure 2B As shown in (B), after the OTA upgrade, the static partition A and super_metadata_A in slotA are both updated to 2.0, where super_metadata_A (2.0) corresponds to the structure of the dynamic partition of the mobile phone 20 at this time.
[0065] After the OTA upgrade is completed on the mobile phone 20, when the mobile phone 20 is running in slotA after the OTA upgrade, if the cold patch file sent by the server 10 is received, the cold patch file is specifically used to upgrade the data of the static partition. Since the mobile phone 20 is running in slotA after the OTA upgrade, the mobile phone 20 will load the cold patch file into the static partition in slotB. After the cold patch is loaded on the mobile phone 20, the mobile phone 20 can run in slotB after the cold patch upgrade by restarting. Figure 2B As shown in (C), after the cold patch upgrade, the static partition B is upgraded to version 3.0.
[0066] However, when a cold patch upgrades static partition data, it does not modify dynamic partition data, such as Figure 2B As shown in (C), super_metadata_B in slot B is still version 1.0. At this time, the structure of the dynamic partition does not correspond to super_metadata_B (1.0), so when the mobile phone 20 switches to slot B, it cannot correctly determine the physical address of the data in the dynamic partition, so that the mobile phone 20 cannot operate normally.
[0067] In order to solve the problem that the electronic device cannot read the data in the dynamic partition normally due to the cold patch upgrade after the OTA upgrade, the present application provides a system upgrade method, which is applied to the electronic device 100, and the electronic device 100 adopts the virtual A / B mode. After the OTA upgrade and / or before the cold patch upgrade, the electronic device 100 will check whether super_metadata_A and super_metadata_B are the same, including whether the number of each physical block in super_metadata_A and super_metadata_B, the starting address, etc. are the same. When the check shows that super_metadata_A and super_metadata_B are inconsistent, it means that the OTA upgrade has modified the dynamic partition, and the electronic device will synchronize the super_metadata in the currently running slot (that is, the super_metadata corresponding to the updated dynamic partition structure) to another super_metadata. Furthermore, the super_metadata in another slot can also correspond to the structure of the dynamic partition.
[0068] In this way, even if the electronic device 100 performs a cold patch upgrade of the static partition, after the electronic device 100 switches to another slot, the super_metadata and the dynamic partition in the slot are corresponding, so that the electronic device 100 can read the data of the dynamic partition normally.
[0069] The electronic device 100 may be any device with an operating system installed, such as a device with an Android operating system. Specifically, it may be the aforementioned mobile phone 20, tablet computer, wearable device, vehicle-mounted device, AR / virtual reality (VR) device, notebook computer, ultra-mobile personal computer (UMPC), netbook, personal digital assistant (PDA) or a dedicated camera (such as a SLR camera, a card camera), etc. It should be understood that the present application does not impose any restrictions on the specific type of the electronic device 100.
[0070] For example, Figure 2A Taking the illustrated situation as an example, after the mobile phone 20 is OTA upgraded, the mobile phone 20 runs the operating system through the slotA after the OTA upgrade. Figure 3 As shown in (A), static partition A and super_metadata_A are both updated to 2.0, and super_metadata_A (2.0) corresponds to the structure of the dynamic partition of mobile phone 20 at this time. When mobile phone 20 detects the restart and the loading of slotA is completed, since super_metadata_A and super_metadata_B are inconsistent, mobile phone 20 will synchronize super_metadata_A and super_metadata_B. Figure 3 As shown in (B), super_metadata_B can also be synchronized to version 2.0. After synchronizing super_metadata_A and super_metadata_B, if a cold patch upgrade is performed again and the mobile phone 20 switches to slotB for operation, super_metadata_B also corresponds to the structure of the dynamic partition.
[0071] The system upgrade method provided by the present application is described in detail below. The method is applied to the above electronic device 100. The structure of the program storage area in the electronic device 100 can refer to the following. Figure 1 As shown, slotA and slotB may also be referred to as the first partition and the second partition, super_metadata_A and super_metadata_B may also be referred to as the first metadata and the second metadata, and static partition A and static partition B may also be referred to as the first static partition and the second static partition. Figure 4 As shown, the electronic device 100 can synchronize metadata for super_metadata_A and super_metadata_B, and, Figure 4 For example, the electronic device 100 initially runs in slot B and runs in slot A after OTA upgrade. The method specifically includes:
[0072] S401: It is obtained that the electronic device 100 has been OTA upgraded, or is about to be cold patch upgraded.
[0073] The electronic device 100 initially runs in slot B. When the electronic device 100 receives the OTA upgrade package and loads the OTA upgrade package into slot A, the electronic device 100 can implement the OTA upgrade by restarting and selecting to load slot A. After the electronic device 100 detects that the restart is complete, metadata synchronization can be performed, that is, subsequent steps S402 to S405 are performed.
[0074] Among them, the electronic device 100 can restart itself after loading the OTA upgrade package. The electronic device 100 can also prompt the user that the loading of the OTA upgrade package has been completed, and the user can choose whether to restart. The user can choose to restart the electronic device 100 after receiving the prompt from the electronic device 100, or the user can restart the electronic device 100 by the power button after a certain period of time. It should be understood that this application does not specifically limit the triggering conditions for restarting the electronic device 100.
[0075] In some embodiments, the electronic device 100 may perform metadata synchronization at any time before an OTA upgrade or a cold patch upgrade is about to be performed, that is, execute subsequent steps S402 to S405. The triggering conditions for the electronic device 100 to perform metadata synchronization may include: obtaining that the electronic device 100 has been OTA upgraded, obtaining that the electronic device 100 is about to be cold patch upgraded, obtaining a metadata synchronization request sent by the user at a preset time after the OTA upgrade, and detecting that metadata will be loaded when the electronic device 100 is restarted after the cold patch modifies the corresponding data. One or more of the triggering conditions. It should be understood that the present application does not specifically limit the triggering conditions for the electronic device 100 to perform metadata synchronization.
[0076] In some embodiments, the electronic device 100 can determine whether the electronic device 100 has been OTA upgraded by whether it has received an OTA upgrade request or an OTA upgrade package. If the electronic device 100 receives an OTA upgrade request or an OTA upgrade package, and after the electronic device 100 is restarted, it can be determined that the electronic device 100 has completed the OTA upgrade. The OTA upgrade request can be as follows: Figure 2A Sent by the server 10 shown.
[0077] In other embodiments, the electronic device 100 may determine whether the electronic device 100 is to perform a cold patch upgrade by whether it receives a cold patch upgrade request or a cold patch file. If the electronic device 100 receives a cold patch upgrade request or a cold patch file, it may be considered that the electronic device 100 is to perform a cold patch upgrade. The cold patch upgrade request may be as follows: Figure 2A Sent by the server 10 shown.
[0078] In other embodiments, the electronic device 100 can also determine whether the electronic device 100 has completed the OTA upgrade by the status mark of the static partition in the basic partition. For example, if the status mark of the static partition A of the electronic device 100 is bootable, and the status mark of the static partition B is unbootable, that is, the electronic device 100 runs in slot A. After receiving the OTA upgrade request and when the electronic device 100 is restarted, it is obtained that the status mark of the static partition A becomes unbootable and the status mark of the static partition B becomes bootable, then it can be considered that the electronic device 100 has been upgraded by OTA.
[0079] In other embodiments, the electronic device 100 may prompt the user whether metadata synchronization is required after an OTA upgrade or before a cold patch upgrade. For example, a prompt message indicating whether metadata synchronization is required is displayed on the display screen of the electronic device 100. The electronic device 100 determines to perform the metadata synchronization operation based on obtaining the user's consent to perform the metadata synchronization operation.
[0080] In other embodiments, the electronic device 100 may also automatically perform a metadata synchronization operation at a preset time T1 after obtaining completion of the OTA upgrade, where T1 is a positive number.
[0081] In other embodiments, the electronic device 100 may also perform metadata synchronization first when it is detected that the electronic device 100 will restart after the corresponding data modification is completed through the cold patch. Alternatively, the electronic device 100 may perform metadata synchronization first when it is detected that the electronic device 100 needs to read metadata during the restart process after the corresponding data modification is completed through the cold patch, that is, before loading the dynamic partition metadata.
[0082] S402: The electronic device 100 reads super_metadata_A and super_metadata_B in the memory.
[0083] Before detecting that an OTA upgrade and / or a cold patch upgrade has been performed, the electronic device 100 determines whether there is a change in the structure of the dynamic partition, that is, verifies whether super_metadata_A and super_metadata_B correspond to each other.
[0084] Among them, Figure 1As shown, super_metadata_A and super_metadata_B are stored in the dynamic partition. The electronic device 100 can read super_metadata_A and super_metadata_B from the corresponding addresses in the dynamic partition. The read data includes the name item, the group item and the extents item, specifically the name, starting address, offset, number of partitions of each sub-partition and the name, starting position, offset and size of the physical blocks in each sub-partition.
[0085] S403: Determine whether super_metadata_A and super_metadata_B are consistent.
[0086] The electronic device 100 will further determine whether the read super_metadata_A and super_metadata_B correspond to each other, if yes, execute step S405, if no, execute step S404.
[0087] Specifically, the electronic device 100 traverses the name item, group item and extents item in super_metadata_A and super_metadata_B in turn. Optionally, the electronic device 100 can also compare the attributes item together. If the comparison result is that there are differences except for the identifier, it means that super_metadata_A and super_metadata_B are inconsistent, that is, the electronic device 100 has upgraded and adjusted the dynamic partition structure, so data synchronization will be performed. If the comparison result is consistent except for the identifier, it means that the electronic device 100 has not upgraded and updated the structure of the dynamic partition, super_metadata_A and super_metadata_B can correspond to the structure of the current dynamic partition, and the electronic device 100 maintains the current operating state.
[0088] When comparing the name item, group item, and extents item in super_metadata_A and super_metadata_B, you can first compare whether the name, start address, offset, and other information of each partition are the same. If the name, start address, and offset of each partition are consistent, then further compare whether the offset position, start position, and number of sectors of each physical block in the same partition in super_metadata_A and super_metadata_B are the same.
[0089] In some embodiments, the electronic device 100 may not perform step S403. That is, after obtaining the triggering condition for metadata synchronization and reading super_metadata_A and super_metadata_B, the metadata synchronization is performed directly. In other words, whether super_metadata_A and super_metadata_B are consistent, both will be synchronized to the latest version of metadata.
[0090] S404: Synchronize super_metadata_A of slotA to super_metadata_B of slotB.
[0091] When the electronic device 100 determines that super_metadata_A and super_metadata_B are inconsistent, it means that the electronic device 100 has updated the partition structure of the dynamic partition. Therefore, the electronic device 100 will perform a synchronization operation to synchronize super_metadata_A in the currently running slotA to super_metadata_B.
[0092] Specifically, since the electronic device 100 is currently running in slotA, and super_metadata_A and super_metadata_B are inconsistent, it means that the electronic device 100 also modified the partition structure of the dynamic partition when upgrading slotA. Therefore, the electronic device 100 will also synchronize super_metadata_A to super_metadata_B, including: changing the suffix "_a" in each name item and group item to "_b" as the new super_metadata_B name item and group item. Then write the extents item and / or attributes item in super_metadata_A to the corresponding position of super_metadata_B, so that super_metadata_B corresponds to super_metadata_A.
[0093] S405: Keep running in slot A.
[0094] When super_metadata_A and super_metadata_B in the electronic device 100 correspond to each other, or the two correspond to each other after synchronization, the electronic device 100 continues to operate in slotA.
[0095] It should be understood that the electronic device 100 may also receive a cold patch upgrade request. In the case where the cold patch only upgrades the static partition data, the electronic device 100 will restart and switch slots after the cold patch upgrade. Since super_metadata_A and super_metadata_B correspond to the same, they are consistent with the current dynamic partition of the electronic device 100. Therefore, according to the super_metadata in the slot running after switching the slot, the data of the dynamic partition can also be correctly read.
[0096] The following is an example of a dynamic partition data structure to illustrate the above system upgrade method.
[0097] like Figure 5 As shown, Figure 5 An exemplary dynamic partition storage data structure is shown, which includes a 4 kilobyte (KB) reserved area, a geometry area, and a metadata area. The data in the geometry area and the metadata area are replicated in a master-slave manner, and each includes a primary version and a backup version.
[0098] After the 4KB reserved area is the geometry area, which also includes the primary geometry area (primary geometry) and the backup geometry area (backup geometry geometry). The actual data volume of the master and slave versions is usually 52 bytes, but it will be padded to 4KB. The master and slave versions each include geometric structure data for storing metadata, such as LpMetadataGeometry. LpMetadataGeometry can include the metadata data size (metadata_max_size) corresponding to each slot and the number of metadata data contained in a single set of metadata data (metadata_slot_count). Among them. And because metadata data is usually also backed up by the master and slave, metadata_slot_count is 2.
[0099] The metadata area includes the master and slave versions of super_metadata_A and super_metadata_B, and also includes the master and slave versions of the spare reserved metadata super_metadata_C. Each super_metadata may include the following data: metadata header file (LpMetadataHeader), metadata partition structure (LpMetadataPartition), metadata physical block structure (LpMetadataExtent), metadata group information (LpMetadataGroup), and device attribute information (LpMetadataBlockDevice).
[0100] Among them, LpMetadataHeader can be specifically Figure 6 The program code is shown in the figure. Among them, LpMetadataHeader defines the version information of metadata, the size of the header structure, and also defines the subsequent partition, extent, group, block device and other data information. For details, please refer to Figure 7 The code shown in the figure shows the partition, extent, group, block device and other data information defined by LpMetadataHeader, including the offset position, quantity and size of a single data.
[0101] LpMetadataPartition can be specified through Figure 8 The program code shown is defined. Among them, LpMetadataPartition includes partition information inside the dynamic partition, such as the name of each sub-partition, attribute items, the starting position of the first physical block (first_extent_index), the number of physical blocks included (num_extents), etc.
[0102] LpMetadataExtent can be specified through Fig. 9 LpMetadataExtent defines the physical block information of each sub-partition, such as the number of sectors (num_sectors) contained in each partition, the type of mapped virtual device (target_type), the offset position (target_data), etc.
[0103] The LpMetadataGroup structure contains the group information within the dynamic partition, including the group name (name), maximum length (maximum_size) and identification (flags) information.
[0104] The LpMetadataBlockDevice structure records the device information in the dynamic partition, such as the starting position (first_logical_sector) of the physical block corresponding to the image file (image).
[0105] Therefore, according to Figures 5 to 9 The dynamic partition structure shown above Figure 4 In step S402, the electronic device 100 may read super_metadata_A and super_metadata_B from 0x3000 to 0x23000 in the dynamic partition.
[0106] Above Figure 4 In step S403, comparing super_metadata_A and super_metadata_B may include comparing whether the name and first_extent_index of each partition correspond to the same. In the case that the name and first_extent_index of each partition correspond to the same, it is also possible to further compare whether the target_data and num_sectors of the same partition in super_metadata_A and super_metadata_B correspond to the same.
[0107] Above Figure 4 In step S404, taking the electronic device currently running in slotA as an example, synchronizing super_metadata_A and super_metadata_B can specifically include changing the suffix "_a" in the name of each sub-partition and the name of the group in super_metadata_A to "_b", and storing it in targetMetadata. Traverse targetMetadata and generate new LpMetadata based on the partition information, which can also be recorded as exportedTarget. Then write the new LpMetadata to the location where super_metadata_B is stored in slotB.
[0108] In this way, super_metadata_A and super_metadata_B can be made consistent. Even if the electronic device 100 performs a cold patch upgrade of the static partition, after the electronic device 100 switches to another slot, the super_metadata in the slot and the dynamic partition are also corresponding, so that the electronic device 100 can read the data of the dynamic partition normally.
[0109] The system upgrade device 1000 provided by the present application is described in detail below. The system upgrade device 1000 can be applied to the electronic device 100. Fig.10 As shown, the system upgrade device 1000 includes an acquisition unit 1010 , an upgrade unit 1020 , a determination unit 1030 and an update unit 1040 .
[0110] The acquisition unit 1010 is used to acquire a first upgrade package when the electronic device 100 runs based on the first static partition and the first metadata. The upgrade unit 1020 is used to upgrade the partition structure of the second static partition, the dynamic partition, and the second metadata according to the first upgrade package. The determination unit 1030 is used to determine to restart the electronic device 100, and after restarting the electronic device 100, determine to run the electronic device 100 based on the upgraded second static partition and the upgraded second metadata. The update unit 1040 is used to update the first metadata according to the upgraded second metadata. The acquisition unit 1010 is also used to acquire a cold patch upgrade file. The upgrade unit 1020 is also used to upgrade the data of the first static partition in the electronic device 100 based on the cold patch upgrade file.
[0111] In some embodiments, the first upgrade package is an over-the-air (OTA) upgrade package.
[0112] In some other embodiments, the updating unit 1040 is further configured to update the first metadata according to the upgraded second metadata in response to completion of the restart.
[0113] In some other embodiments, the determination unit 1030 is further used to restart the electronic device 100; the determination unit 1030 is further used to run the electronic device 100 based on the first static partition after the cold patch upgrade and the updated first metadata after the electronic device 100 is restarted.
[0114] In some other embodiments, the acquisition unit 1010 is further used to acquire the name and address of at least one sub-partition in the first metadata and the upgraded second metadata, wherein the name of at least one sub-partition in the first metadata includes the first identifier, and the name of at least one sub-partition in the upgraded second metadata includes the second identifier. The determination unit 1030 is further used to determine whether the first metadata and the upgraded second metadata are consistent based on the name and address of at least one sub-partition in the first metadata and the upgraded second metadata. The update unit 1040 is further used to update the first metadata based on the upgraded second metadata when it is determined that the first metadata and the upgraded second metadata are inconsistent.
[0115] In some other embodiments, the updating unit 1040 is further used to replace the second identifier in the name item and the group item of at least one sub-partition in the upgraded second metadata with the first identifier to obtain the name item and the group item in the updated first metadata. The updating unit 1040 is further used to synchronize the address of at least one sub-partition in the upgraded second metadata to the corresponding sub-partition in the first metadata in sequence according to the name item and the group item in the updated first metadata.
[0116] In other embodiments, the subpartition includes at least one physical block, and the address of at least one subpartition includes the starting position, offset, and size of the subpartition and the starting position, offset, and size of at least one physical block contained in the subpartition.
[0117] In some other embodiments, the electronic device 100 further includes a basic partition, and the basic partition includes a boot identifier of the first static partition and the second static partition. The determination unit 1030 is further configured to determine that the boot identifier of the first static partition is bootable, and to operate the electronic device based on the first static partition and the first metadata.
[0118] In summary, after the electronic device upgrades the second metadata, it can also update the first metadata, so that the first metadata and the second metadata are consistent. In this way, even if the electronic device is upgraded with a cold patch, when the electronic device switches to loading the first metadata, the structure of the first metadata and the dynamic partition are also corresponding, so that the electronic device can read the data of the dynamic partition normally.
[0119] The method of the embodiment of the present application is described in detail above. In order to facilitate better implementation of the above scheme of the embodiment of the present application, correspondingly, related equipment for cooperating in implementing the above scheme is also provided below.
[0120] Fig.11 is a structural diagram of an electronic device 100 provided in this application, such as Fig.11As shown, the electronic device 100 includes: a processor 110, a communication interface 120 and a memory 130. Among them, the processor 110, the communication interface 120 and the memory 130 can be connected to each other through an internal bus 140, and can also communicate through other means such as wireless transmission. In the embodiment of the present application, the connection through the bus 140 is taken as an example. The bus 140 can be a peripheral component interconnect express (PCIe) bus, or an extended industry standard architecture (EISA) bus, a unified bus (Ubus or UB), a computer express link (CXL), a cache coherent interconnect for accelerators (CCIX), etc. The bus 140 can be divided into an address bus, a data bus, a control bus, etc. In addition to the data bus, the bus 140 can also include a power bus, a control bus, and a status signal bus. However, for the sake of clarity, various buses are marked as bus 140 in the figure.
[0121] The processor 110 may be composed of at least one general-purpose processor, such as a central processing unit (CPU), or a combination of a CPU and a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof. The processor 110 executes various types of digital storage instructions, such as software or firmware programs stored in the memory 130, which enables the electronic device 100 to provide a variety of services.
[0122] The memory 130 is used to store program codes and is controlled by the processor 110 to execute the processing steps of the visual positioning method in the above embodiment. The program code may include one or more software modules, which may be Fig.10 The memory 130 can also be used for the following: Figure 1 The program storage area and data storage area are shown.
[0123] It should be noted that this embodiment can be implemented by a general physical server, for example, an ARM server or an X86 server, or it can be implemented by a virtual machine based on a general physical server combined with NFV technology. A virtual machine refers to a complete computer system with complete hardware system functions simulated by software and running in a completely isolated environment. This application does not make any specific limitations.
[0124] The memory 130 may include a volatile memory, such as a random access memory (RAM); the memory 130 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); the memory 130 may also include a combination of the above types. The memory 130 may store program codes, specifically executing Figure 4 Steps S401 to S405 and their optional steps in the embodiment will not be described in detail here.
[0125] The communication interface 120 may be a wired interface (e.g., an Ethernet interface), an internal interface (e.g., a high-speed serial computer expansion bus), a wired interface (e.g., an Ethernet interface), or a wireless interface (e.g., a cellular network interface or a wireless local area network interface), and is used to communicate with other devices or modules. For example, it is used to obtain a patch file or upgrade package sent by a server.
[0126] Need to explain, Fig.11 This is only a possible implementation of the embodiment of the present application. In practical applications, the electronic device 100 may also include more or fewer components, which is not limited here. For contents not shown or described in the embodiment of the present application, please refer to the aforementioned Figure 4 The relevant explanations in the embodiments will not be repeated here.
[0127] It should be understood that Fig.11 The electronic device shown may also be a computer cluster consisting of at least one server, which is not specifically limited in this application.
[0128] The present application also provides a computer-readable storage medium, in which instructions are stored. When the instructions are executed on a processor, Figure 4 The method flow shown is realized.
[0129] The present application also provides a computer program product. When the computer program product is run on a processor, Figure 4 The method flow shown is realized.
[0130] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that contains one or more available media integration. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc.
[0131] A person skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by a computer program to instruct the relevant hardware, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above-mentioned method embodiments. The aforementioned storage medium includes: a read-only memory (ROM) or a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
Claims
1. A system upgrade method, characterized in that: Applied to an electronic device, the memory of the electronic device includes a first static partition, a second static partition and a dynamic partition, the dynamic partition includes first metadata and second metadata, the first metadata corresponds to the first static partition, and the second metadata corresponds to the second static partition, the method includes: When the electronic device runs based on the first static partition and the first metadata, obtaining a first upgrade package; Upgrading the second static partition, the partition structure of the dynamic partition, and the second metadata according to the first upgrade package; restarting the electronic device; After restarting the electronic device, operating the electronic device based on the upgraded second static partition and the upgraded second metadata; updating the first metadata according to the upgraded second metadata; Get the cold patch upgrade file; Based on the cold patch upgrade file, data of the first static partition in the electronic device is upgraded.
2. The method according to claim 1, characterized in that: The first upgrade package is an over-the-air (OTA) upgrade package.
3. The method according to claim 1, characterized in that The updating of the first metadata according to the upgraded second metadata includes: In response to the restart being completed, the first metadata is updated according to the upgraded second metadata.
4. The method according to claim 1, characterized in that After upgrading the data of the first static partition in the electronic device, the method further includes: restarting the electronic device; After the electronic device is restarted, the electronic device is operated based on the first static partition upgraded with the cold patch and the updated first metadata.
5. The method according to claim 1, characterized in that: Before updating the first metadata according to the upgraded second metadata, the method further includes: Acquire a name and an address of at least one subpartition in the first metadata and the upgraded second metadata, wherein the name of at least one subpartition in the first metadata includes a first identifier, and the name of at least one subpartition in the upgraded second metadata includes a second identifier; determining, according to a name and an address of at least one sub-partition in the first metadata and the upgraded second metadata, whether the first metadata and the upgraded second metadata correspond to each other; The updating of the first metadata according to the upgraded second metadata includes: When it is determined that the first metadata and the upgraded second metadata are inconsistent, the first metadata is updated according to the upgraded second metadata.
6. The method according to claim 5, characterized in that The updating of the first metadata according to the upgraded second metadata includes: replacing the second identifier in the name item and the group item of at least one sub-partition in the upgraded second metadata with the first identifier to obtain the name item and the group item in the updated first metadata; and According to the name item and the group item in the updated first metadata, the address of at least one sub-partition in the upgraded second metadata is synchronized to the corresponding sub-partition in the first metadata in sequence.
7. The method according to claim 6, characterized in that The sub-partition includes at least one physical block, and the address of the at least one sub-partition includes the starting position, offset, and size of the sub-partition and the starting position, offset, and size of at least one physical block contained in the sub-partition.
8. The method according to claim 1, characterized in that: The electronic device further includes a basic partition, the basic partition includes startup identifiers of the first static partition and the second static partition, and the method further includes: Determining that the boot identifier of the first static partition is bootable; The electronic device is operated based on the first static partition and the first metadata.
9. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory is used to store instructions, and the processor is used to execute the instructions. When the processor executes the instructions, the method according to any one of claims 1 to 8 is executed.
10. A computer-readable storage medium, characterized in that: The method comprises instructions, which, when executed on an electronic device, cause the electronic device to execute the method as claimed in any one of claims 1 to 8.
Citation Information
Cited By
Equipment upgrading method, second equipment and system
CN121441752A