CN116628670B - Authority setting method and electronic equipment - Google Patents

Authority setting method and electronic equipment Download PDF

Info

Publication number
CN116628670B
CN116628670B CN202310566350.3A CN202310566350A CN116628670B CN 116628670 B CN116628670 B CN 116628670B CN 202310566350 A CN202310566350 A CN 202310566350A CN 116628670 B CN116628670 B CN 116628670B
Authority
CN
China
Prior art keywords
partition
electronic device
interface
dynamic
super
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202310566350.3A
Other languages
Chinese (zh)
Other versions
CN116628670A (en
Inventor
王冠森
赵文振
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Honor Device Co Ltd
Original Assignee
Honor Device Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Honor Device Co Ltd filed Critical Honor Device Co Ltd
Priority to CN202310566350.3A priority Critical patent/CN116628670B/en
Publication of CN116628670A publication Critical patent/CN116628670A/en
Application granted granted Critical
Publication of CN116628670B publication Critical patent/CN116628670B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/30Authentication, i.e. establishing the identity or authorisation of security principals
    • G06F21/44Program or device authentication
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • G06F8/63Image based installation; Cloning; Build to order

Landscapes

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

Abstract

The embodiment of the application provides a permission setting method and electronic equipment. In the method, all the images carrying the root rights are respectively brushed (written) into the target partition corresponding to each image. And restarting the system to enable the electronic equipment to acquire the root permission. The related operations of brushing the image 1 carrying the root authority into the target static partition and brushing the image 2 carrying the root authority into the target dynamic partition are performed in the fastboot mode. It will also be appreciated that the operations associated with swiping image 1 into the target static partition and swiping image 2 into the target dynamic partition are all done at the level of the fastboot mode.

Description

Authority setting method and electronic equipment
Technical Field
The application relates to the technical field of terminals, in particular to a permission setting method and electronic equipment.
Background
The root authority of the electronic equipment is a system authority similar to an administtra in a windows system, and the root is a super administrator user account in a linux system, an unix system and the like, and the account has the highest authority of the whole system. Under the condition that the electronic equipment acquires the root authority, the content in the system can be conveniently operated, such as deleting operation or changing operation. In general, in the stage of developing and testing an electronic device, the electronic device is particularly required to acquire root rights to operate content in a system. For example, in the research and development stage, after the electronic device obtains the root authority, the system file defined by the chip manufacturer may be deleted.
How to make the rights settings makes it worthwhile to get the root rights by the electronic device.
Disclosure of Invention
The application provides a permission setting method and electronic equipment, which can enable the electronic equipment to brush a mirror image carrying root permission into a dynamic partition in a fastboot mode, and acquire the root permission after restarting a system. When the root rights are acquired, whether the electronic equipment is in a research and development state or not does not need to be considered.
In a first aspect, the present application provides a rights setting method, including: restarting the system by the electronic equipment to enter a startup loading fastboot mode, wherein the mirror image of the system is stored in a static partition and a super dynamic partition of a flash memory; the starting addresses of all static partitions on the flash and the starting addresses of the super dynamic partitions are recorded in a partition table; the super dynamic partition comprises super metadata, and the super metadata records the offset of each dynamic partition under the super dynamic partition; the offset of one dynamic partition describes the offset of the one dynamic partition relative to the starting address of the super dynamic partition; the electronic equipment brushes the mirror image of a first partition into the first partition in the fastboot mode; the first partition includes at least one dynamic partition; the mirror image of the first partition carries root rights;
The electronic device restarting the system; the electronic device has root rights after restarting the system.
In the above embodiment, the first dynamic partition may be understood as a target partition corresponding to all the images carrying root rights in the following embodiment. The mirroring of the first partition may be understood as the mirroring to be written to the target partition as referred to in the following embodiments. For example, where the first partition is a target dynamic partition, the image of the first partition may be referred to as the image of the target dynamic partition (e.g., image 2 referred to in the embodiments described below.
And setting the capability of analyzing the super dynamic partition in the fastboot mode, and acquiring the super metadata in the super dynamic partition. An offset for the first partition is determined based on the super metadata. And obtaining the initial address of the first partition in the flash based on the offset, and further finishing the operation of brushing the mirror image carrying the root authority into the first partition. Dynamic partition flushing is not required to restart the system into the fastboot mode, and flushing the first partition in the fastboot mode does not need to be concerned about whether the electronic device is in the developer mode (development state in the embodiment). Meaning that whether the electronic device is in developer mode or not, the images all carrying the root rights can be brushed into the corresponding partition in fastboot mode. And then restarting the system, and the electronic equipment can acquire the root permission. In some possible scenes, the electronic device can finish the operation of brushing the mirror image carrying the root permission into the corresponding partition in the fastboot mode, the root permission can be provided after the system is restarted again, the system does not need to be restarted to enter the fastboot, and the number of restarting the system once is reduced.
With reference to the first aspect, in some embodiments, before the electronic device brushes the image of the first partition into the first partition in the fastboot mode, the method further includes: the electronic equipment acquires a starting address of the first partition on the flash in the fastboot mode; the initial address of the first partition on the flash is obtained based on the offset of the first partition and the initial address of the super dynamic partition; the offset of the first partition is obtained by the electronic device through starting an offset obtaining interface of a loading bootloader layer in the fastboot mode.
In the above embodiment, the fastboot mode is implemented in a bootloader layer of the electronic device, where the bootloader layer includes an offset acquisition interface. The offset acquisition interface may be utilized to determine an offset for the first partition based on the super metadata.
With reference to the first aspect, in some embodiments, the offset obtaining interface includes a first interface, a second interface, a third interface, a fourth interface, a fifth interface, and a sixth interface, where the first interface is configured to obtain super metadata from the super dynamic partition; the second interface is used for checking the validity of the super metadata; the third interface is used for determining the numbers corresponding to all dynamic partitions in the super dynamic partition from the super metadata; the fourth interface is used for determining the number corresponding to the first partition from the numbers corresponding to all the dynamic partitions; the fifth interface is used for determining an offset sequence number corresponding to the first partition based on the number corresponding to the first partition; the sixth interface is configured to determine, based on an offset number corresponding to the first partition, an offset corresponding to the offset number as an offset of the first partition.
With reference to the first aspect, in some embodiments, the electronic device restarting system enters a fastboot mode, specifically including:
the electronic device determines that the electronic device does not support a developer mode, and the electronic device restarts the system to enter a fastboot mode.
In the above embodiment, when the electronic device does not support the developer mode, the images all carrying the root rights may be brushed into the corresponding partition in the fastboot mode. And then restarting the system, and the electronic equipment can acquire the root permission.
With reference to the first aspect, in some embodiments, the method further includes: under the condition that the electronic equipment determines that the electronic equipment supports the developer mode, the electronic equipment restarting system enters a fast start daemon fastbootd mode; the electronic device determines the starting address and the size of the first partition from a device mapping table in the fastbootd mode; the equipment mapping table records the starting address and the size of all dynamic partitions; the electronic device mounts a storage space from a start address to an end address of the first partition as a block device; the storage area between the end address and the start address of the first partition is equal to the size of the first partition; the electronic device allocates a file descriptor for the block device; the electronic device finds the first partition based on the file descriptor and brushes a mirror image of the first partition into the first partition.
In the above embodiment, the case where the electronic device supports the developer mode may be understood as the case where the electronic device is in a development state in the embodiment. In such a case, the electronic device may write the image carrying the root right to the first partition in the fastbootd mode.
With reference to the first aspect, in some embodiments, the first partition further includes at least one static partition, and for a static partition in the first partition, before the electronic device brushes the mirror image of the first partition into the first partition in the fastboot mode, the method further includes: the electronic device determines a starting address of the first partition through the partition table.
In the above embodiment, the first partition may be not only a dynamic partition but also a static partition, and when the first partition indicates a static partition, the mirror image of the first partition may be regarded as the mirror image 1 referred to in the embodiment.
With reference to the first aspect, in some embodiments, before brushing the mirror image of the first partition into the flash, the method further includes: the electronic device determines that the storage space occupied by the mirror image of the first partition is smaller than or equal to the storage space of the first partition on the flash.
In the above embodiment, the first partition is only written when it is determined that the storage space occupied by the mirror image of the first partition is smaller than or equal to the storage space of the first partition on the flash. The situation that the content of the next partition of the first partition is covered during the writing process because the mirror image of the first partition is too large is avoided.
With reference to the first aspect, in some embodiments, the method further includes: and under the condition that the storage space occupied by the mirror image of the first partition is larger than the storage space of the first partition on the flash, the electronic equipment displays prompt information to prompt the failure of the writing.
In the above embodiment, the first partition is only refreshed when it is determined that the storage space occupied by the mirror image of the first partition is greater than the storage space of the first partition on the flash. The situation that the content of the next partition of the first partition is covered during the writing process because the mirror image of the first partition is too large is avoided. And simultaneously displaying prompt information to inform the failure of the writing.
With reference to the first aspect, in some embodiments, the electronic device is connected to a brushing device, and before the electronic device brushes the image of the first partition into the first partition in the fastboot mode, the method further includes: and the electronic equipment receives a brushing instruction sent by the brushing equipment.
With reference to the first aspect, in some embodiments, before the electronic device restart system enters the boot loader fastboot mode, the method further includes: the electronic device receives an instruction for entering the fastboot mode, which is sent by the brushing device.
In a second aspect, embodiments of the present application provide an electronic device, including: one or more processors and memory; the memory is coupled to the one or more processors, the memory for storing computer program code comprising computer instructions that the one or more processors call to cause the electronic device to perform the method as implemented in the first aspect.
In the above embodiment, the capability of analyzing the super dynamic partition is set in the fastboot mode, so that the super metadata in the super dynamic partition can be obtained. An offset for the first partition is determined based on the super metadata. And obtaining the initial address of the first partition in the flash based on the offset, and further finishing the operation of brushing the mirror image carrying the root authority into the first partition. Dynamic partition flushing is not required to restart the system into the fastboot mode, and flushing the first partition in the fastboot mode does not need to be concerned about whether the electronic device is in the developer mode (development state in the embodiment). Meaning that whether the electronic device is in developer mode or not, the images all carrying the root rights can be brushed into the corresponding partition in fastboot mode. And then restarting the system, and the electronic equipment can acquire the root permission. In some possible scenes, the electronic device can finish the operation of brushing the mirror image carrying the root permission into the corresponding partition in the fastboot mode, the root permission can be provided after the system is restarted again, the system does not need to be restarted to enter the fastboot, and the number of restarting the system once is reduced.
In a third aspect, embodiments of the present application provide a computer-readable storage medium comprising instructions that, when executed on an electronic device, cause the electronic device to perform a method as implemented in the first aspect.
In the above embodiment, the capability of analyzing the super dynamic partition is set in the fastboot mode, so that the super metadata in the super dynamic partition can be obtained. An offset for the first partition is determined based on the super metadata. And obtaining the initial address of the first partition in the flash based on the offset, and further finishing the operation of brushing the mirror image carrying the root authority into the first partition. Dynamic partition flushing is not required to restart the system into the fastboot mode, and flushing the first partition in the fastboot mode does not need to be concerned about whether the electronic device is in the developer mode (development state in the embodiment). Meaning that whether the electronic device is in developer mode or not, the images all carrying the root rights can be brushed into the corresponding partition in fastboot mode. And then restarting the system, and the electronic equipment can acquire the root permission. In some possible scenes, the electronic device can finish the operation of brushing the mirror image carrying the root permission into the corresponding partition in the fastboot mode, the root permission can be provided after the system is restarted again, the system does not need to be restarted to enter the fastboot, and the number of restarting the system once is reduced.
In a fourth aspect, embodiments of the present application provide a chip system for application to an electronic device, the chip system comprising one or more processors for invoking computer instructions to cause the electronic device to perform a method as implemented in the first aspect.
In the above embodiment, the capability of analyzing the super dynamic partition is set in the fastboot mode, so that the super metadata in the super dynamic partition can be obtained. An offset for the first partition is determined based on the super metadata. And obtaining the initial address of the first partition in the flash based on the offset, and further finishing the operation of brushing the mirror image carrying the root authority into the first partition. Dynamic partition flushing is not required to restart the system into the fastboot mode, and flushing the first partition in the fastboot mode does not need to be concerned about whether the electronic device is in the developer mode (development state in the embodiment). Meaning that whether the electronic device is in developer mode or not, the images all carrying the root rights can be brushed into the corresponding partition in fastboot mode. And then restarting the system, and the electronic equipment can acquire the root permission. In some possible scenes, the electronic device can finish the operation of brushing the mirror image carrying the root permission into the corresponding partition in the fastboot mode, the root permission can be provided after the system is restarted again, the system does not need to be restarted to enter the fastboot, and the number of restarting the system once is reduced.
In a fifth aspect, embodiments of the present application provide a computer program product comprising instructions which, when run on an electronic device, cause the electronic device to perform the method as implemented in the first aspect.
In the above embodiment, the capability of analyzing the super dynamic partition is set in the fastboot mode, so that the super metadata in the super dynamic partition can be obtained. An offset for the first partition is determined based on the super metadata. And obtaining the initial address of the first partition in the flash based on the offset, and further finishing the operation of brushing the mirror image carrying the root authority into the first partition. Dynamic partition flushing is not required to restart the system into the fastboot mode, and flushing the first partition in the fastboot mode does not need to be concerned about whether the electronic device is in the developer mode (development state in the embodiment). Meaning that whether the electronic device is in developer mode or not, the images all carrying the root rights can be brushed into the corresponding partition in fastboot mode. And then restarting the system, and the electronic equipment can acquire the root permission. In some possible scenes, the electronic device can finish the operation of brushing the mirror image carrying the root permission into the corresponding partition in the fastboot mode, the root permission can be provided after the system is restarted again, the system does not need to be restarted to enter the fastboot, and the number of restarting the system once is reduced.
It will be appreciated that the electronic device provided in the second aspect, the computer storage medium provided in the third aspect, the chip system provided in the fourth aspect and the computer program product provided in the fifth aspect are all configured to perform the method provided by the embodiments of the present application. Therefore, other advantages achieved by the method can be referred to as advantages of the corresponding method, and will not be described herein.
Drawings
Fig. 1A and 1B are schematic diagrams showing that a control electronic device obtains root rights through a brushing device;
FIG. 2 shows a schematic diagram of all partitions of a storage system and their associated information;
FIG. 3 illustrates an exemplary system hierarchy involved in determining dynamic partitions and static partitions;
FIG. 4 illustrates an example diagram of swiping an image carrying root rights in a target static partition;
FIG. 5 illustrates an example diagram of swiping images in a target static partition and a target dynamic partition;
FIG. 6 illustrates the reason why the electronic device cannot write the development status;
FIG. 7 illustrates software interfaces involved in an electronic device swiping an image in a target dynamic partition;
FIG. 8 illustrates an interface interaction diagram involved in an electronic device swiping mirror 2 in a target dynamic partition;
FIG. 9 is a flowchart of a fastbootd interface sending a mount target dynamic partition request to a device mapper interface;
FIG. 10 illustrates software interfaces involved in brushing images in a target static partition and a target dynamic partition in another approach;
FIG. 11 illustrates an interface interaction diagram involved in an electronic device brushing images in a target static partition and a target dynamic partition;
FIG. 12 illustrates exemplary presentation code involved in an electronic device brushing a target dynamic partition;
FIG. 13 illustrates an exemplary flow chart for an electronic device brushing an image in a target partition in fastboot mode;
fig. 14 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The terminology used in the following embodiments of the application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the specification and the appended claims, the singular forms "a," "an," "the," and "the" are intended to include the plural forms as well, unless the context clearly indicates to the contrary. It should also be understood that the term "and/or" as used in this application refers to and encompasses any or all possible combinations of one or more of the listed items.
The terms "first," "second," and the like, are used below for descriptive purposes only and are not to be construed as implying or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include one or more such feature, and in the description of embodiments of the present application, unless otherwise indicated, the meaning of "a plurality" is two or more.
In some aspects, the manner in which the electronic device obtains the root rights includes: the images carrying the root rights are respectively brushed (written) into the target partition (which can also be called as a first partition) corresponding to each image. And restarting the system to enable the electronic equipment to acquire the root permission. The partition includes an area in a memory (e.g., flash) of the electronic device for storing the system. The image carrying the root authority in the writing target partition may also be referred to as an image of the target partition.
Illustratively, in the case where the electronic device is a television (e.g., a smart screen). The electronic equipment is connected with the electronic equipment through the brushing equipment when the operability of the input instruction of the electronic equipment is low, and the electronic equipment is triggered to brush (write) all the mirror images carrying the root rights into the target partitions corresponding to the mirror images after the brushing instruction is input to the electronic equipment through the brushing equipment.
Fig. 1A and 1B are schematic diagrams showing that a control electronic device obtains root rights through a brushing device.
As shown in fig. 1A, the electronic device is a television and the user interface 10 is one exemplary interface that the electronic device may involve when entering the host system. The electronic device is connected with the brushing device. The electronic device may only brush the image in the target partition (including the target static partition or the target dynamic partition) after the swiping device sends an instruction to the electronic device to exit the host system and enter other switchable modes. Other writable modes referred to herein are modes of a stand-alone host system. In different cases, the fastboot mode or fastboot mode referred to hereinafter may be. Here, the fastboot mode is described as an example.
The host system may also be referred to simply as a system, where possible.
The fastboot mode may also be referred to as a fast start mode, where possible. fastbootd mode may also be referred to as a fast launch daemon mode.
The brushing device sends an instruction for entering the fastboot mode to the electronic device, and the instruction can be: "adb reboot bootloader". The subsequent electronic device may enter fastboot mode. As shown in fig. 1B, the user interface 11 is one exemplary interface that is involved when the electronic device enters fastboot mode. After the electronic device receives a brushing instruction sent by the brushing device, a mirror image carrying root rights can be brushed in a target partition (comprising a static partition or a dynamic partition).
And restarting the system to return to the main system until the electronic equipment brushes (writes) all the images carrying the root rights into the target partitions corresponding to the images respectively, wherein the electronic equipment has the root rights.
It should be understood that fig. 1A and 1B are exemplary interaction diagrams of a brushing device and an electronic device when brushing a mirror image, and should not be construed as limiting embodiments of the present application.
It should be noted here that different parts of the mirror image of the system are stored in different partitions of the memory (e.g. flash), and typically include a static partition and a super partition. The content in the different partitions may be enabled to be used normally after being run. Common systems may include Android systems and the like.
Of all the partitions of the storage system, some or all of the partitions may be target partitions. In some possible cases, the electronic device may acquire the root rights after brushing all target partitions into the image carrying the root rights. The image carrying the root authority can be regarded as a part of the system, and after the image carrying the root authority and other parts of the system are operated, the electronic device can enter the system and have the root authority.
Wherein information of all partitions of the image of the storage system may be recorded in the partition table. For example, the partition table records information such as the name, start address, and size of each static partition and super partition. The electronic device may find the real address space of the static partition based on the name, start address, and size of the static partition, and then brush a mirror image carrying the root rights in the real address space.
In some possible cases, the super partition may also be referred to as a super dynamic partition (super dynamic partition).
It should be noted here that all partitions of the storage system may include static partitions, or may also include dynamic partitions. The static partition refers to a partition in which part or all of information such as a name, a starting address, a size and the like can be queried in a partition table. All dynamic partitions are integrated into one partition (super partition), and the dynamic partition refers to a partition in a partition table, in which information such as a name, a starting address, a size and the like cannot be queried. The partition table can inquire partial or all information in the name, the starting address, the size and the like of the super partition. Information (e.g., information including names, numbers, etc.) of each dynamic partition in the super partition is stored in super metadata (super metadata). The super metadata is stored in a dynamic partition of the super partition.
In some possible cases, information (e.g., including names, numbers, etc.) for each dynamic partition may be stored in primary metadata (primary metadata) of the super metadata. The primary metadata may also record one or more of the offset information and the size of each dynamic partition, for example, the offset information, or the offset information and the size. The offset information and the size of any dynamic partition correspond to the number of the dynamic partition. The offset information of any dynamic partition includes an offset sequence number. The offset sequence number corresponding to any dynamic partition corresponds to the offset of the dynamic partition. Wherein the offset describes the offset of a dynamic partition relative to the starting address of the dynamic partition. Thus, the electronic device can determine the offset information and the size corresponding to the number based on the number of the dynamic partition. The offset information comprises an offset serial number corresponding to the dynamic partition, and the offset corresponding to the offset serial number is used as the offset of the dynamic partition relative to the starting position of the super partition. The electronic device can find the actual address space of the dynamic partition by combining the starting address of the super partition and the offset, and then brush the mirror image carrying the root authority in the actual address space.
FIG. 2 shows a schematic diagram of all partitions of a storage system and their associated information.
As shown in fig. 2 (1), all partitions of the storage system include at least one static partition and one super partition. The super partition includes at least one dynamic partition. Among them, the static partition may include boot partition (including boot_a and boot_b partition), ramdisk partition (including ramdisk_a and ramdisk_b partition), and the like. Dynamic partitions in the super partition may include system partitions, vendor partitions, and the like.
It should be understood herein that any partition (including dynamic, static, and super) corresponds to a real address space, which is a contiguous storage area (memory space) in memory.
The aforementioned partition table referred to may be, in some possible cases, a boot partition table (GUIDpartition table, GPT), which may be stored in a memory area starting from a starting position in the flash.
As shown in Table 1, the partition table may include information for each static partition as well as the super partition. For example, some or all of the information including name, start address, and size. The electronic device can perform indexing, positioning and other operations through the information in the partition table, and find all static partitions and super partitions in the memory.
The partition table shown in table 1 may also include partition numbers for each static partition and super partition. The partition number is used to define which partition is the memory.
TABLE 1
It should be noted that table 1 shows an exemplary partition table, which is for the purpose of facilitating understanding of the partition table. In practice, the partition table may be different from table 1, and should not be construed as limiting the embodiments of the present application.
The above-mentioned super metadata may be stored in a super partition. Illustratively, it may be stored in the first 1M space of the super partition.
Alternatively, as shown in fig. 2 (2), super metadata is typically stored starting from the start address in the super partition. The electronic device may record information (including names, numbers, etc.) of each dynamic partition in primary metadata of super metadata.
Based on the foregoing description, it can be appreciated that because the electronic device cannot obtain the information of the dynamic partition from the partition table, the process involved in determining the start address of a dynamic partition is more complex than the process involved in determining the start address of a static partition.
Thus, in some possible cases, the system level involved in determining the starting address of a dynamic partition and determining the starting address of a static partition is different, and the mode in which the electronic device needs to be turned on is different. Typically, the system level involved in determining the starting address of a dynamic partition is at the frame layer, requiring the electronic device to turn on the fastbootd mode implementation. And determining that a system level related to the static partition is in a bootloader layer, and starting a fastboot mode by the electronic equipment.
FIG. 3 illustrates an exemplary system hierarchy involved in determining dynamic partitions and static partitions.
As shown in fig. 3, after the electronic device enters the fastbootd mode, the frame layer may parse the super metadata in the super partition to obtain the start address of the dynamic partition, and the link kernel layer (abbreviated as kernel layer) may brush a mirror image into the dynamic partition based on the start address of the dynamic partition. After the electronic device enters the fastboot mode, the bootloader layer can analyze the partition table to obtain the starting address of the static partition, and the mirror image is brushed into the dynamic partition based on the starting address of the static partition.
It should be noted here that, in the fastboot mode, since a higher system level is involved than in the fastboot mode, a stricter condition needs to be satisfied when brushing an image into a dynamic partition. With reference to fig. 4 to 6, details relating to how the mirror image is specifically brushed are described in detail.
It should be understood herein that the target partition that needs to be flushed with the image (carrying the root rights) may include one or more of a static partition or a dynamic partition. Generally speaking, the specific situation of the target partition may be determined according to the system version of the electronic device, and should not be construed as limiting the embodiments of the present application. Wherein the static partition that needs to be flushed with the image (carrying the root rights) may be referred to as the target static partition. The dynamic partition that needs to be flushed with the image (carrying the root rights) may be referred to as the target dynamic partition.
FIG. 4 illustrates an example diagram of swiping an image carrying root rights in a target static partition.
As shown in fig. 4, the detailed description of this process may refer to the following descriptions of step S101 to step S104.
S101, restarting the system by the electronic equipment to enter a fastboot mode.
The main system is typically accessed after the electronic device is powered on. However, the host system is not available when the target static partition is flushed, so a fastboot mode independent of the host system can be entered, in which the target static partition is flushed.
For example, when the electronic device receives an instruction to enter the fastboot mode, the electronic device may restart the system to enter the fastboot mode. The instruction for entering the fastboot mode may be: "adbrebootbootloader".
S102, brushing the mirror image 1 carrying the root authority into the target static partition.
The electronic device is illustratively connected to other swiping devices, which may input a swiping instruction 1 to the electronic device. After the electronic equipment receives the brushing instruction 1, brushing the mirror image 1 carrying the root authority in the target static partition.
In some possible cases, the electronic device first determines the start address (denoted as start address 1) of the target static partition in the partition table.
The real address space corresponding to the start address 1 (denoted as real address space 1) is found and the electronic device then swipes mirror 1 in the real address space 1.
In other possible cases, the electronic device first determines the starting address and size of the target static partition in the partition table.
When it is determined that the storage space occupied by the mirror image 1 to be flushed is smaller than or equal to the size of the target static partition, the electronic device finds the actual address space 1 corresponding to the start address 1, and then the electronic device flushes the mirror image 1 in the actual address space 1.
It should be understood here that, when it is determined that the storage space occupied by the image 1 to be flushed is larger than the size of the target static partition, the electronic device may not perform the operation of flushing the image 1 in the real address space 1, and display a prompt message to prompt that flushing fails.
S103, restarting the system to enter the main system.
After all the target static partitions are respectively brushed into the mirror images of the root authorities, the electronic equipment restarting system enters the main system and can have the root authorities.
S104, the electronic equipment executes related operations based on the root authorities.
Under the condition that the electronic equipment acquires the root authority, the content in the system can be conveniently operated, such as deleting operation or changing operation. For example, in the research and development stage, after the electronic device obtains the root authority, the system file and the system application defined by the chip manufacturer can be deleted.
It should be understood that, in some possible cases, in addition to the image carrying the root rights needs to be brushed into the target static partition, other images carrying the root rights need to be brushed into the target dynamic partition, so that the electronic device can acquire the root rights. For example, after the system version is updated, the target partition that needs to be flushed with the image (carrying the root authority) when the electronic device acquires the root authority may be changed from including the target static partition to including both the target static partition and the target dynamic partition.
However, in general, when the image is brushed into the target dynamic partition, it is necessary to enter the fastbootd mode. Under the condition that the electronic equipment has strict control over the dynamic partition of the brushing, once the electronic equipment enters the fastbootd mode, the mirror image is only allowed to be brushed in the dynamic partition when the electronic equipment is in a research and development state. This requires that the electronic device be determined to be in a development state before the image is flushed into the dynamic partition, and the electronic device can flush the image into the dynamic partition. The following description of step S204 to step S205 may be referred to for the relevant description of the process.
It will be appreciated that in some cases, a development effort might also be referred to as a development effort or a developer effort.
FIG. 5 illustrates an example diagram of swiping images in a target static partition as well as a target dynamic partition.
As shown in fig. 5, the detailed description of this process may refer to the following descriptions of step S201 to step S208.
S201, restarting the system by the electronic equipment to enter a fastboot mode.
The step S201 is the same as the step S101, and the description of the step S201 may refer to the description of the step S101, which is not repeated here.
S202, brushing the mirror image 1 carrying the root authority into the target static partition.
The step S202 is the same as the step S102, and the description of the step S202 may refer to the description of the step S102, which is not repeated here.
S203, the electronic equipment restarts the system again to enter a fastbootid mode.
The host system is not available when the target dynamic partition is flushed, and therefore a fastbootd mode independent of the host system can be entered in which the target dynamic partition is flushed.
For example, when the electronic device receives an instruction to enter the fastbootd mode, the electronic device may restart the system to enter the fastbootd mode. The instruction for entering the fastbootd mode may be: "adbrebootfastboot".
S204, determining whether the electronic equipment is in a research and development state.
The research and development state is a safety mode set when the electronic equipment is researched and developed or tested when the electronic equipment is not shipped, and can be used for controlling the writing of the dynamic partition after entering the fastbootd mode.
In the case where it is determined that the fastbootd mode is entered and the electronic apparatus is in the development state, the following step S205 may be performed.
In the case where it is determined that the fastbootd mode is entered and the electronic apparatus is not in the development state, the following step S208 may be performed to indicate a brush failure.
It should be understood here that, in the case where the electronic device determines to enter the fastbootd mode and is not in the development state, the reason for the electronic device brush failure is that: when the electronic equipment is not in the research and development state and does not have the root right, the electronic equipment cannot write in the research and development state, and the electronic equipment is required to have the root right when the research and development state is written in, so that the electronic equipment falls into a 'dead loop'.
Fig. 6 shows the reason why the electronic device cannot write the development status.
As shown in fig. 6, the electronic device needs to acquire root rights in the stages of development, testing, and the like. To obtain the root rights, the mirror image 2 carrying the root rights needs to be brushed into the target dynamic partition. The target dynamic partition is flushed in fastbootd mode. However, swiping any dynamic partition in fastbootd mode requires the electronic device to be in a research and development state. Under the condition that the electronic equipment is not in a research and development state, the electronic equipment is required to be configured with the attribute related to the research and development state under the main system for writing the research and development state into the electronic equipment, and the attribute comprises an IP address, a port and the like, so that other equipment can be connected with the electronic equipment through the IP address, the port and the like to write a research and development mode. For example, the other device may be a device that has installed a development mode write application, which may be a "dongle" application. However, configuring the attributes involved in writing the development state requires root rights. In order to obtain the root authority, the mirror image 2 carrying the root authority needs to be brushed into the target dynamic partition. Thus forming a "dead cycle".
S205, brushing the mirror image 2 carrying the root authority into the target dynamic partition.
The electronic device is connected to other swiping devices which can input a swiping instruction 2 to the electronic device. After the electronic equipment receives the brushing instruction 2, the mirror image 2 carrying the root authority is brushed in the target dynamic partition.
In some possible cases, the electronic device may determine the starting address of the super partition where the target dynamic partition is located in the partition table. Then, the offset of the target dynamic partition relative to the super partition start address is obtained from the super metadata. This offset is added to the start address of the super partition as the start address of the target dynamic partition (denoted as start address 2). For details of determining the start address 2 by the electronic device, reference may be made to the following descriptions of fig. 7-9 and related contents, which are not repeated here.
The real address space corresponding to the start address 2 (denoted as real address space 2) is found and the electronic device then swipes mirror 2 in the real address space 2.
In other possible cases, the electronic device may also determine the starting address and size of the target dynamic partition.
The method for determining the start address of the target dynamic partition may refer to the foregoing description, and will not be described herein. The size of the target dynamic partition is determined by taking the super metadata.
When it is determined that the storage space occupied by the mirror image 2 to be flushed is smaller than or equal to the size of the target dynamic partition, the electronic device finds the actual address space 2 corresponding to the start address 2, and then the electronic device flushes the mirror image 2 in the actual address space 2.
It should be understood herein that upon determining that the memory space occupied by the image 2 to be flushed is greater than the size of the target dynamic partition, the electronic device may not perform flushing the image 2 in the actual address space and display a hint message indicating a flush failure.
S206, restarting the system to enter the main system.
After all the target dynamic partitions and all the target static partitions are respectively brushed into the mirror images of the root authorities, the electronic equipment restarting system can have the root authorities when entering the main system.
S207, the electronic equipment executes related operations based on the root authorities.
Under the condition that the electronic equipment acquires the root authority, the content in the system can be conveniently operated, such as deleting operation or changing operation. For example, in the research and development stage, after the electronic device obtains the root authority, the system file and the system application defined by the chip manufacturer can be deleted.
S208, no dynamic partition is allowed to be flushed, including the target dynamic partition.
In the case where the electronic device is not in a development state, the electronic device does not allow any dynamic partition to be written, including the target dynamic partition, even if the fastboot mode is entered. At this point, the electronic device may display a hint indicating a failure in the swipe.
It should be understood here that there is no precedence relationship between the foregoing S201 and step S203. The electronic device may first perform step S201 to enter fastboot mode to flush the target static partition. Step S203 may also be performed first to enter the fastbootd mode to brush the target dynamic partition. In addition, there is no relation between the step S203 and the step S204, or the step S204 may be executed to determine whether the development state is in the development state after the step S203 is entered into the fastbootd mode. The electronic device may first perform step S204 to determine whether the electronic device is in a development state, and then perform step S203 to enter the fastbootd mode. In some possible cases, after the electronic device first performs step S204 to determine that the electronic device is not in the development state, step S208 may be directly performed without performing step S204.
FIG. 7 illustrates software interfaces involved in an electronic device swiping an image in a target dynamic partition.
As shown in fig. 7, when the electronic device brushes the mirror image carrying the root authority into the target dynamic partition, the related software interface mainly includes: the frame work layer includes a fastbootd interface, a device mapper interface of the kernel layer, and a brush writing and reading interface of the bootloader layer.
The framework layer may also be referred to as a framework layer, which is a layer where the fastbootd mode is located. The frame layer may include a fastbootd interface, which may provide the capability of analyzing super metadata for the electronic device, to obtain information such as a start address of the target dynamic partition.
The kernel (kernel) layer, which may also be referred to as a kernel layer, may include a device mapper interface. The device mapper interface may provide the electronic device with the ability to mount the actual address space where the target dynamic partition is located as a block device.
bootloader layers are custom levels for the chip vendor, which bootloader can be understood to initiate loading. The bootloader layer may also be referred to as a boot loader layer. The bootloader layer may include a brush and read interface. The flush and remove interface may be invoked by the device mapper interface referred to above to perform the flushing of the mirror in the real address space corresponding to the target dynamic partition.
It should be appreciated that the bootloader layer supports developers to preset some new interfaces at the bootloader layer through the electronic device to meet the requirements.
It should be understood here that the actual address space corresponding to the target dynamic partition exists in the memory (flash). The flash is located in a hardware layer.
FIG. 8 illustrates an interface interaction diagram that the electronic device involves when swiping mirror 2 in a target dynamic partition.
The process by which the electronic device brushes image 2 in the target dynamic partition is described in detail below in conjunction with fig. 7 and 8. For the description of this process, reference may be made to the following descriptions of step S10 to step S19. Step S10-step S19 correspond to 10-19 in the white circles of FIG. 7, respectively.
And S10, the fastbootd interface receives a brushing instruction 2.
Illustratively, after the electronic device is connected to the swiping device, the fastbootd interface of the electronic device may receive a swiping instruction 2 sent by the swiping device.
S11, the fastbootd interface sends a request for mounting the target dynamic partition to the device mapper interface.
The request to mount the target dynamic partition is to mount the target dynamic partition as a block device. The purpose of mounting the target dynamic partition as a block device is to: the block device corresponds to the actual address space of the target dynamic partition. The subsequent fastbootd interface may call the device mapper interface to assign a file descriptor to the block device. The refreshing and reading interface can determine the actual address space corresponding to the target dynamic partition based on the file descriptor, and then the mirror image 2 is refreshed into the actual address space of the target dynamic partition. For details of this procedure, reference is made to the following descriptions of steps S12-S17, which are not repeated here.
The request for mounting the target dynamic partition carries the starting address and the size of the target dynamic partition. The mounting target dynamic partition comprises: and determining the actual address space corresponding to the target dynamic partition based on the starting address and the size of the target dynamic partition. And mounting the actual address space corresponding to the target dynamic partition as block equipment.
FIG. 9 shows a detailed flow of the fastbootd interface issuing a request to mount a target dynamic partition to the device mapper interface.
As shown in fig. 9, the fastbootd interface obtains the starting address and size of the target dynamic partition based on the dm device table. And generating a request for mounting the target dynamic partition based on the starting address and the size of the target dynamic partition, and sending the request for mounting the target dynamic partition to a device mapper interface. Wherein, dm equipment table is fully called: "device mapper table" may also be referred to as a device map. Illustratively, the dm equipment table is stored in random access memory (random access memory, RAM) of the electronic equipment. For example, may be stored in the DM stack of RAM.
For a detailed description of this process, reference may be made to the following description of step S20 to step S24.
The fastbootd interface determines if a dm device table exists.
The dm equipment table records the starting address and the size of each dynamic partition.
The fastbootd interface first determines whether a dm device table exists.
In the presence of the dm equipment table, the following step S23 is performed to acquire the start address and size of the target dynamic partition from the dm equipment table.
In the case where the dm equipment table does not exist, the following steps S21 and S22 are executed, and the dm equipment table is generated based on the super metadata.
S21, opening block equipment corresponding to the super partition by the fastbootd interface, and obtaining super metadata in the super partition.
The block device corresponding to the super partition corresponds to the real address space of the super partition. And opening the block equipment corresponding to the super partition, and obtaining the data recorded in the actual address space of the super partition. For example, super metadata in a super partition may be obtained.
The fastbootd interface determines the dm device table generated by the starting address and the size of all dynamic partitions based on the super metadata.
The fastbootd interface may obtain primary metadata from super metadata. The primary metadata records the offset information and the size of each dynamic partition. The offset of each dynamic partition relative to the super partition start address may be determined based on the offset information of each dynamic partition. And adding the offset corresponding to each dynamic partition with the starting address of the super partition to obtain the starting address corresponding to each dynamic partition.
A dm equipment table generated based on the size and starting address of all dynamic partitions.
S23, the fastbootd interface acquires the starting address and the size of the target dynamic partition from the dm equipment table.
S24, the fastbootd interface sends a request for mounting the target dynamic partition to the device mapper interface, wherein the request carries the starting address and the size of the target dynamic partition.
The fastbootd interface generates a request for mounting the target dynamic partition based on the starting address and the size of the target dynamic partition, and sends the request for mounting the target dynamic partition to the device mapper interface.
S12, the device mapper interface mounts the target dynamic partition as a block device.
The device mapper interface obtains the starting address and size of the target dynamic partition from the request to mount the target dynamic partition. Then, a real address space corresponding to the target dynamic partition is determined based on the starting address and the size of the target dynamic partition. And mounting the actual address space corresponding to the target dynamic partition as block equipment.
S13, calling a device mapper interface by the fastbootd interface to configure a file descriptor corresponding to the block device.
The file descriptor corresponding to the block device may be used to determine the actual address space of the target dynamic partition corresponding to the block device.
S14, configuring a file descriptor corresponding to the block device by the device map interface, and sending the file descriptor corresponding to the block device to the fastbootd interface.
S15, the fastbootd interface sends a request for brushing the target dynamic partition to the device mapper interface.
In some possible cases, the request for flushing the target dynamic partition carries the file descriptor corresponding to the block device.
S16, determining a real address space corresponding to the block device by the device mapper interface based on the file descriptor.
The actual address space corresponding to the block device is the actual address space of the target dynamic partition corresponding to the block device.
S17, calling the brushing and reading interface by the device mapper interface to brush the mirror image 2 carrying the root authority into the actual address space corresponding to the block device.
S18, executing the brushing operation by the brushing and reading interface.
The swiping and reading interface mirror 2 swipes into the real address space corresponding to the block device. The actual address space corresponding to the block device is the actual address space of the target dynamic partition corresponding to the block device.
S19, the brushing and reading interface returns a notification of successful brushing to the fastbootd interface through the device mapper interface.
The flush and read interface sends a notification to the device mapper interface that the flush was successful. The device mapper interface then returns a notification to the fastbootd interface that the flush was successful.
It should be understood here that the device mapper interface referred to in step S15-step S17 is illustrative, and the fastbootd interface may send a request to flush the target dynamic partition to other interfaces through which the target dynamic partition is flushed. The embodiments of the present application are not limited in this regard.
Aiming at the situation that the electronic equipment does not have a research and development state when acquiring the root permission, namely is in a non-research and development state, but a scene that the mirror image can be brushed into the dynamic partition in the fastbootd mode only in the research and development state is set. In order to break the foregoing "dead loop", the embodiment of the present application further provides another authority setting method.
In the authority setting method, related operations of brushing the image 1 carrying the root authority into the target static partition and brushing the image 2 carrying the root authority into the target dynamic partition are performed in a fastboot mode. It will also be appreciated that the operations associated with swiping image 1 into the target static partition and swiping image 2 into the target dynamic partition are all done at the level of the fastboot mode. Illustratively, it may be at bootloader layer.
FIG. 10 illustrates software interfaces involved in brushing images in a target static partition as well as a target dynamic partition in another approach.
Illustratively, as shown in FIG. 10, the process performed at the bootloader layer to brush image 1 into the target static partition includes: and the partition table is obtained based on a brushing and reading interface of the bootloader layer. And then determining the starting address 1 of the target static partition based on the partition table, and brushing the mirror image 1 into the actual address space 1 corresponding to the starting address 1.
Illustratively, as shown in fig. 10, the content of the mirror 2 to be brushed into the target dynamic partition at the bootloader layer includes: the functional interface of the electronic device for obtaining the start address of the target dynamic partition can be integrated into the bootloader layer. For example, the electronic device may encapsulate the function of determining the target dynamic partition offset based on the super metadata into one preset interface (offset acquisition interface in the following). And the preset interface is set to the level where the fastboot mode is started, and the bootloader layer can be exemplified. The flush and read interface may determine the starting address of the super partition based on the partition table. The flush and read interface may then take the offset plus the start address of the super partition as the start address 2 of the target dynamic partition. Subsequently, the brushing and reading interface brushes the mirror image 2 into the actual address space 2 corresponding to the initial address 2.
FIG. 11 illustrates an interface interaction diagram that the electronic device involves when brushing images in a target static partition as well as a target dynamic partition.
The interface interactions referred to in steps S30-S33 in fig. 11 correspond to the interface interactions referred to in the white circles 30-33 in fig. 10, respectively. Step S34 a-step S34d in fig. 11 correspond to the white circle 34 in fig. 10. The interface interactions referred to in steps S35-S37 in fig. 11 correspond to the interface interactions of 35-37 in the white circles in fig. 10, respectively. For a detailed description of the above procedure, reference may be made to the following description of step S30 to step S37.
S30, the brushing and reading interface receives a brushing instruction A1, acquires a starting address 1 of the target static partition from the partition table, and brushes the mirror image 1 carrying the root authority into the target static partition based on the starting address 1.
The electronic device is illustratively connected to other swiping devices, which may input a swiping instruction A1 to the electronic device. After receiving the swiping instruction A1, the electronic device may perform the operation of swiping mirror 1 in the target static partition.
Wherein the process of swiping mirror 1 in the target static partition includes: the brushing and reading interface obtains the initial address 1 of the target static partition from the area table recorded in the flash. Mirror 1 is then flushed from the memory area in flash starting at this starting address 1.
In some possible cases, the electronic device may also check whether image 1 can be flushed in the target static partition before flushing the target static partition into image 1. The flush and read interface may also determine the size of the target static partition from the partition table before mirror 1 is flushed to the target static partition. And determining the actual address space 1 corresponding to the target static partition based on the starting address 1 and the size of the target static partition. When it is determined that the storage space occupied by the image 1 to be flushed is smaller than or equal to the size of the target static partition, the electronic device flushes the image 1 in the actual address space 1. When it is determined that the storage space occupied by the image 1 to be flushed is larger than the size of the target static partition, the electronic device does not execute the operation of flushing the image 1 in the actual address space 1, and displays a prompt message to indicate that flushing fails.
The real address space 1 is a continuous storage area from the start address 1 to the end address 1 in the flash. The size of the storage area before the end address 1 and the start address 1 is equal to the size of the target static partition.
S31, the brushing and reading interface receives a brushing instruction A2.
The electronic device is illustratively connected to other swiping devices, which may input a swiping instruction A2 to the electronic device. After receiving the swiping instruction A2, the electronic device may perform the operation of swiping mirror 2 in the target dynamic partition. Reference may be made to the following description of step S32-step S37 regarding the process of swiping the mirror image 2 in the target dynamic partition.
S32, the brushing and reading interface acquires super metadata from the super partition.
The brushing and reading interface determines the starting address of the super partition in the flash from the partition table. And then reading from the starting address corresponding to the super partition to acquire super metadata.
S33, the brushing and reading interface calls an offset obtaining interface to obtain the offset of the target dynamic partition based on the super metadata.
The process of the flush and read interface calling the offset obtaining interface to obtain the offset of the target dynamic partition based on the super metadata may refer to the following descriptions of step S34 a-step S34 d.
S34a, analyzing numbers corresponding to all dynamic partitions based on super metadata by an offset acquisition interface.
For example, the numbers corresponding to the all dynamic partitions may be recorded in primary metadata in super metadata. The primary metadata may further record offset information and size of each dynamic partition, where the offset information and size of any dynamic partition are corresponding to the number of the dynamic partition. The offset information includes an offset number. The offset sequence number corresponding to any dynamic partition corresponds to the offset of the dynamic partition.
S34b, obtaining the number corresponding to the target dynamic partition from the numbers corresponding to all the dynamic partitions by the offset obtaining interface.
S34c, determining an offset serial number corresponding to the target dynamic partition by the offset acquisition interface.
And the offset acquisition interface determines an offset serial number corresponding to the number based on the number corresponding to the target dynamic partition as the offset serial number corresponding to the target dynamic partition. The offset number corresponding to the number is recorded in the offset information corresponding to the number.
S34d, determining the offset corresponding to the target dynamic partition by the offset acquisition interface based on the offset serial number corresponding to the target dynamic partition.
The offset obtaining interface takes the offset corresponding to the offset serial number as the offset corresponding to the target dynamic partition.
S35, the offset obtaining interface returns the offset corresponding to the target dynamic partition to the brushing and reading interface.
S36, the brushing and reading interface takes the offset plus the starting address of the super partition as the starting address 2 of the target dynamic partition.
The brushing and reading interface acquires the starting address of the super partition from the partition table, and adds the offset corresponding to the target dynamic partition and the starting address of the super partition as the starting address 2 of the target dynamic partition.
S37, the brushing and reading interface brushes the mirror image 2 carrying the root authority into the target dynamic partition based on the starting address 2.
Illustratively, the process of swiping mirror 2 in the target dynamic partition includes: the flush and read interface flushes mirror 2 from the memory area in flash starting at this starting address 2.
Subsequently, the electronic device can restart the system to enter a main system, and the electronic device executes operation on the system file based on the root authority in the main system, wherein the operation cannot be executed when the electronic device does not have the root authority. For example, the operations may include: and deleting the system files and the system applications defined by the chip manufacturer.
In some possible cases, the electronic device may also check whether image 2 can be flushed in the target dynamic partition before flushing the target dynamic partition into image 2. The flush and read interface may also determine the size of the target dynamic partition from the super metadata before the mirror 2 is flushed into the target dynamic partition. And determining the actual address space 2 corresponding to the target dynamic partition based on the starting address 2 and the size of the target dynamic partition. When it is determined that the memory space occupied by the image 2 to be flushed is smaller than or equal to the size of the target dynamic partition, the electronic device flushes the image 2 in the real address space 2. When it is determined that the storage space occupied by the image 2 to be flushed is larger than the size of the target dynamic partition, the electronic device does not execute the operation of flushing the image 2 in the actual address space 2, and displays a prompt message to indicate that flushing fails.
The real address space 2 is a continuous storage area from the start address 2 to the end address 2 in the flash. The size of the storage area before the end address 2 and the start address 2 is equal to the size of the target dynamic partition.
In some possible cases, the fastboot mode of the electronic device may be referred to as a first mode in a scheme in which both dynamic and static partitions may be written in the fastboot mode. The first mode is independent of the main system, is used for brushing static partition and dynamic partition, and the electronic device can be in a non-research and development state or in a research and development state when brushing dynamic partition. At this time, the fastbootd mode of the electronic device may be referred to as a second mode. The second mode is another mode independent of the host system; the electronic device needs to satisfy the condition in the research and development state when brushing data into any dynamic partition in the second mode. And under the condition that the electronic equipment is in the first mode, the electronic equipment enters the second mode after restarting the system.
In some possible cases, the electronic device may first perform step S30 to flush the target static partition after the execution sequence of step S30 and step S31 is not consecutive. Then, step S31 is performed to start flushing the target dynamic partition.
It should be appreciated here that the methods illustrated in fig. 10 and 11 described above may also be used in scenarios where it is not necessary to determine whether a dynamic partition is being written in a development state. The method shown in fig. 10 and 11 is described by taking the example that the target partition includes a target static partition and a target dynamic partition. In actual situations, the target partition may include only the target static partition or only the target dynamic partition.
As can be seen from the foregoing description of fig. 10 and 11, in the foregoing embodiment, all instructions related to obtaining the offset of the target dynamic partition are encapsulated into the offset obtaining interface. In practical situations, all instructions related to obtaining the offset of the target dynamic partition may be encapsulated into two or more interfaces, for example, one instruction may correspond to one interface, which is not limited in the embodiment of the present application.
It should also be appreciated that the reason why the kernel layer and the frame layer are drawn with dashed lines in fig. 10 is that: in another authority setting method, the target dynamic partition and the target static partition are both performed in the fastboot mode, and the method can be realized through an interface of a bootloader layer where the fastboot mode is located. The interfaces of the kernel layer and the frame layer are not involved.
The target dynamic partition referred to in the foregoing may be a render partition, as some cases may be.
FIG. 12 illustrates exemplary presentation code involved in an electronic device brushing a target dynamic partition.
As shown in fig. 12, the electronic device obtains the start address of the super partition based on the super address interface query partition table. The supermetadata is obtained from the superpartition based on the readfrom interface. Optionally, the electronic device may also check the validity of the supermetadata based on the Cchecklegal interface. Under the condition that the supermetadata is determined to be effective, the numbers corresponding to all the dynamic partitions are analyzed from the supermetadata based on the GetParationinterface. And determining the number corresponding to the target dynamic partition from the numbers corresponding to all the dynamic partitions based on the GetOrder interface. And determining the offset serial number corresponding to the target dynamic partition based on the serial number corresponding to the target dynamic partition by using the GetExtend interface. And further determining the offset of the target dynamic partition based on the offset sequence number by using the GetOffest interface. The offset is then added to the start address of the super partition as the start address 2 of the target dynamic carriage. Finally, mirror image 2 is flushed into the target dynamic partition based on start address 2.
In some possible cases, the offset acquisition interface of the foregoing device may include (may also be referred to as a first interface), a checkagal interface (may also be referred to as a second interface), a getcomponents interface (may also be referred to as a third interface), a GetOrder interface (may also be referred to as a fourth interface), a getextension interface (may also be referred to as a fifth interface), and a getoffset interface (sixth interface).
The permission setting method in the embodiment of the application is to set and analyze the function of the super partition in a bootloader layer. In addition to being applicable to the scene of root authority setting, the method can also be applied to other scenes, including but not limited to the following two scenes.
Scene 1: when the electronic device is in a server archiving version, the electronic device needs to archive images in a super partition for servers of different operators (mobile, communication, telecom, etc.) separately. The reason for this is that there are differences in the partial dynamic partition between servers corresponding to different operators, and the partial dynamic partition may be a preload partition or a render partition. But cannot brush the preload partition, the render partition, to fit the differences in fastboot mode. However, by using the function of analyzing the super partition at the bootloader layer, which is related to the foregoing, the electronic device can independently brush the preload partition and the vendor partition in the fastboot mode, and the mirror images in the preload partition and the vendor partition are brushed to meet the server archiving versions of different operators so as to adapt to the difference.
Scene 2: once the follow-up electronic device has the scene that the dynamic partition cannot be written in the fastbootd mode, the function of analyzing the super partition in the bootloader layer can be used for writing the dynamic partition in the fastbootd mode.
FIG. 13 illustrates an exemplary flow chart for an electronic device brushing an image in a target partition in fastboot mode.
In some embodiments, reference may be made to the following description of step S301-step S303 regarding the process of the electronic device brushing an image in a target partition in fastboot mode.
S301, restarting the system by the electronic equipment to enter a fastboot mode.
In connection with the foregoing, it should be understood herein that the mirror image of the system is stored in the static partition and the super dynamic partition of the flash. Based on the description of the foregoing, the static partition includes a partition table, where the partition table records the starting addresses of all static partitions on the flash and the starting addresses of the super dynamic partitions; the super dynamic partition comprises super metadata (super metadata), and the super metadata records the offset of each dynamic partition under the super dynamic partition; the offset of one dynamic partition describes the offset of the one dynamic partition relative to the starting address of the super dynamic partition.
S302, brushing the mirror image of the target partition into the target partition in the fastboot mode, wherein the target partition at least comprises one dynamic partition.
In some possible cases, the target partition may include at least one dynamic partition therein, such as the target dynamic partition referred to previously.
When the target partition indicates a dynamic partition, the electronic device analyzes the super metadata to determine a start address of the target partition before brushing the mirror image of the target partition into the target partition, and the process includes: the electronic equipment acquires the starting address of the target partition on the flash in the fastboot mode; the initial address of the target partition on the flash is obtained based on the offset of the target partition and the initial address of the super dynamic partition; the offset of the target partition is obtained by the electronic device through starting an offset obtaining interface of a loading bootloader layer in the fastboot mode. The details of this process may be referred to the previous descriptions of steps S32-S35, and will not be repeated here. The description of the offset obtaining interface may also refer to the related content and will not be repeated herein. Where the target partition is a dynamic partition, the image of the target partition may be understood as image 2 referred to above.
In other possible cases, in addition to dynamic partitioning, static partitioning may be included in the target partition, such as the target static partition referred to previously.
When the target partition indicates a static partition, the electronic device may determine a starting address of the target partition from the partition table before brushing the image of the target partition into the target partition. Where the target partition is a static partition, the image of the target partition may be understood as image 1 referred to previously.
S303, restarting the system by the electronic equipment.
The electronic equipment restarts the system, and has root authority after restarting the system.
In some possible implementations, in order to make the image of the target partition not cover the data of the next partition of the target partition when the image of the target partition is written, before the electronic device brushes the image of the target partition into the flash, it may further be determined that a storage space occupied by the image of the target partition is less than or equal to a storage space of the target partition on the flash. It is also understood that determining that the mirror image of the target partition is smaller or larger than the size of the target partition.
And under the condition that the storage space occupied by the mirror image of the target partition is larger than the storage space of the target partition on the flash, the electronic equipment displays prompt information to prompt the failure of the writing. It may also be understood that the electronic device displays a hint message to indicate a failure in the flush if the mirror image of the target partition is larger than the size of the target partition.
It should be understood here that in the process of performing the above steps S301-S303 and the related operations to write the image of the target partition to the target partition, it may not be concerned whether the electronic device is in a development state. In some possible cases, the electronic device also has the ability to flush the target partition in fastbootd mode when the target partition is a dynamic partition. At this time, the process of the electronic device brushing the target partition in the fastbootd mode includes: under the condition that the electronic equipment determines that the electronic equipment supports the developer mode, the electronic equipment restarting system enters a fast start daemon fastbootd mode; the electronic device determines the starting address and the size of the first partition from a device mapping table in the fastbootd mode; the equipment mapping table records the starting address and the size of all dynamic partitions; the electronic device mounts a storage space from a start address to an end address of the first partition as a block device; the storage area between the end address and the start address of the first partition is equal to the size of the first partition; the electronic device allocates a file descriptor for the block device; the electronic device finds the first partition based on the file descriptor and brushes a mirror image of the first partition into the first partition.
In other possible cases, the electronic device may determine whether the electronic device is in a development state before performing the aforementioned step S301. The electronic device executes step S301 only if it is determined that the electronic device is in the development state: the electronic device restarts the system to enter a fastboot mode. In the case that it is determined that the electronic device is not in the development state, the electronic device may write the target partition in the fastbootd mode, and the related description of the process may refer to the foregoing related content, which is not described herein.
Exemplary electronic devices provided by embodiments of the present application are described below.
Fig. 14 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
The electronic device may be a television (e.g., a smart screen) that may be connected to the handwriting device, and the specific type of the electronic device and the handwriting device is not particularly limited in the embodiments of the present application.
It should be understood that the electronic device may have more or fewer components than shown in fig. 14, may combine two or more components, or may have a different configuration of components. The various components shown in fig. 14 may be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and/or application specific integrated circuits.
The electronic device may include: processor 122, memory 123, wireless communication processing module 124, power switch 125, wired LAN communication processing module 126, USB communication processing module 127, and display screen 128. Wherein:
processor 122 may be used to read and execute computer readable instructions. In particular implementations, processor 122 may include primarily controllers, operators, and registers. The controller is mainly responsible for instruction decoding and sending out control signals for operations corresponding to the instructions. The arithmetic unit is mainly responsible for performing fixed-point or floating-point arithmetic operations, shift operations, logic operations, and the like, and may also perform address operations and conversions. The register is mainly responsible for storing register operands, intermediate operation results and the like temporarily stored in the instruction execution process. In a specific implementation, the hardware architecture of the processor 122 may be an Application Specific Integrated Circuit (ASIC) architecture, a MIPS architecture, an ARM architecture, an NP architecture, or the like.
In some embodiments, the processor 122 may be configured to parse signals received by the wireless communication processing module 124 and/or the wired LAN communication processing module 126. Such as parsing a command sent by the brushing device to restart into fastboot mode, a brushing command, etc.
Memory 123 is coupled to processor 122 for storing various software programs and/or sets of instructions. In particular implementations, memory 123 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic disk storage devices, flash memory devices, or other non-volatile solid-state storage devices. The memory 123 may store an operating system, such as an Android system. The memory 123 may also store therein partition files such as super metadata, partition tables, images written to root rights, and the like.
The wireless communication processing module 124 may include one or more of a Bluetooth (BT) communication processing module 124A, WLAN communication processing module 124B or an NFC communication processing module 124C for device (e.g., a swipe device) discovery and data transfer when establishing a connection, etc.
The wireless communication processing module 124 may be used for device discovery, data transmission, etc. when establishing a connection. For example, the electronic device may return the device ID of the electronic device to the refresh device upon receiving the information of the device scan sent by the refresh device, so that the refresh device may be connected to the electronic device.
The power switch 125 may be used to control the power supplied by the power source to the electronic device.
The wired LAN communication processing module 126 may be used to communicate with other electronic devices in the same LAN via a wired LAN, and may also be used to connect to a WAN via a wired LAN, and may communicate with devices in the WAN.
The USB communication processing module 127 may be used to communicate with other devices through a USB interface (not shown).
The display screen 128 may be used to display video, images, and the like. The display 128 may be a liquid crystal display (liquid crystal display, LCD), an organic light-emitting diode (OLED) display, or the like.
In the embodiment of the present application, the processor 122 may invoke computer instructions stored in the internal memory 123, so that the electronic device executes the rights setting method in the embodiment of the present application.
The application also provides an electronic device, which may include: memory and a processor. Wherein the memory is operable to store a computer program; the processor may be operative to invoke a computer program in said memory to cause the electronic device to perform the method of any of the embodiments described above.
The present application also provides a chip system including at least one processor for implementing the functions involved in the method performed by the electronic device in any of the above embodiments.
In one possible design, the system on a chip further includes a memory to hold program instructions and data, the memory being located either within the processor or external to the processor. The chip system may be formed of a chip or may include a chip and other discrete devices. Alternatively, the processor in the system-on-chip may be one or more. The processor may be implemented in hardware or in software. When implemented in hardware, the processor may be a logic circuit, an integrated circuit, or the like. When implemented in software, the processor may be a general purpose processor, implemented by reading software code stored in a memory. Alternatively, the memory in the system-on-chip may be one or more. The memory may be integrated with the processor or may be separate from the processor, and embodiments of the present application are not limited. For example, the memory may be a non-transitory processor, such as a ROM, which may be integrated on the same chip as the processor, or may be separately disposed on different chips, and the type of memory and the manner of disposing the memory and the processor in the embodiments of the present application are not specifically limited. Illustratively, the system-on-chip may be a field programmable gate array (field programmable gate array, FPGA), an application specific integrated chip (application specific integrated circuit, ASIC), a system on chip (SoC), a central processing unit (central processor unit, CPU), a network processor (network processor, NP), a digital signal processing circuit (digital signal processor, DSP), a microcontroller (micro controller unit, MCU), a programmable controller (programmable logic device, PLD) or other integrated chip.
The present application also provides a computer program product comprising: a computer program (which may also be referred to as code, or instructions), which when executed, causes a computer to perform the method performed by the electronic device in any of the embodiments described above.
The present application also provides a computer-readable storage medium storing a computer program (which may also be referred to as code, or instructions). The computer program, when executed, causes a computer to perform the method performed by the electronic device in any of the embodiments described above.
The above embodiments are merely for illustrating the technical solution of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.
As used in the above embodiments, the term "when …" may be interpreted to mean "if …" or "after …" or "in response to determination …" or "in response to detection …" depending on the context. Similarly, the phrase "at the time of determination …" or "if detected (a stated condition or event)" may be interpreted to mean "if determined …" or "in response to determination …" or "at the time of detection (a stated condition or event)" or "in response to detection (a stated condition or event)" depending on the context.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may 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 loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present application, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may 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 may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by a wired (e.g., coaxial cable, fiber optic, digital subscriber line), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk), etc.
Those of ordinary skill in the art will appreciate that implementing all or part of the above-described method embodiments may be accomplished by a computer program to instruct related hardware, the program may be stored in a computer readable storage medium, and the program may include the above-described method embodiments when executed. And the aforementioned storage medium includes: ROM or random access memory RAM, magnetic or optical disk, etc.

Claims (10)

1. A rights setting method, characterized in that the method comprises:
restarting a system by the electronic equipment to enter a startup loading fastboot mode, wherein a mirror image of the system is stored in a static partition and a super dynamic partition of a flash memory; the starting addresses of all static partitions on the flash and the starting addresses of the super dynamic partitions are recorded in a partition table; the super dynamic partition comprises super metadata, and the super metadata records the offset of each dynamic partition under the super dynamic partition; the offset of one dynamic partition describes the offset of the one dynamic partition relative to the starting address of the super dynamic partition;
the electronic equipment brushes the mirror image of a first partition into the first partition based on the starting address of the first partition on the flash in the fastboot mode; the first partition includes at least one dynamic partition; the mirror image of the first partition carries root rights; the initial address of the first partition on the flash is obtained by the electronic equipment in the fastboot mode based on the offset recorded by the first partition in the super metadata and the initial address of the super dynamic partition;
The offset of the first partition is obtained by the electronic device through starting an offset obtaining interface for loading a bootloader layer in the fastboot mode; the offset obtaining interface comprises a first interface, a second interface, a third interface, a fourth interface, a fifth interface and a sixth interface, wherein the first interface is used for obtaining super metadata from the super dynamic partition; the second interface is used for checking the validity of the super metadata; the third interface is used for determining the numbers corresponding to all dynamic partitions in the super dynamic partition from the super metadata; the fourth interface is used for determining the number corresponding to the first partition from the numbers corresponding to all the dynamic partitions; the fifth interface is configured to determine an offset sequence number corresponding to the first partition based on a number corresponding to the first partition; the sixth interface is configured to determine, based on an offset sequence number corresponding to the first partition, an offset corresponding to the offset sequence number as an offset of the first partition;
the electronic device restarting the system; the electronic equipment has root authority after restarting the system.
2. The method according to claim 1, wherein the electronic device restarting system enters a fastboot mode, specifically comprising:
And the electronic equipment determines that the electronic equipment does not support a developer mode, and the electronic equipment restarting system enters a fastboot mode.
3. The method according to claim 2, wherein the method further comprises:
the electronic equipment restarting system enters a fast start daemon fastbootid mode under the condition that the electronic equipment determines that the electronic equipment supports the developer mode;
the electronic equipment determines the starting address and the size of the first partition from an equipment mapping table in the fastbootd mode; the equipment mapping table records the starting addresses and the sizes of all dynamic partitions;
the electronic equipment mounts a storage space from the starting address to the ending address of the first partition as block equipment; a storage area between the end address and a start address of the first partition is equal to a size of the first partition;
the electronic device allocates a file descriptor for the block device;
the electronic device finds the first partition based on the file descriptor and brushes a mirror image of the first partition into the first partition.
4. The method of any of claims 1-3, wherein the first partition further comprises at least one static partition, wherein for a static partition in the first partition, the electronic device brushes a mirror of a first partition into the first partition in the fastboot mode, the method further comprising:
The electronic device determines a starting address of the first partition through the partition table.
5. A method according to any one of claims 1-3, wherein before brushing the mirror of the first partition into the flash, the method further comprises:
and the electronic equipment determines that the storage space occupied by the mirror image of the first partition is smaller than or equal to the storage space of the first partition on the flash.
6. The method of claim 5, wherein the method further comprises:
and under the condition that the storage space occupied by the mirror image of the first partition is larger than the storage space of the first partition on the flash, the electronic equipment displays prompt information to prompt the failure of the brushing.
7. The method of claim 6, wherein the electronic device is coupled to a brushing device, the electronic device further comprising, prior to brushing the mirror of the first partition into the first partition in the fastboot mode:
and the electronic equipment receives a refreshing instruction sent by the refreshing equipment.
8. The method of claim 7, wherein before the electronic device restart system enters a boot loader fastboot mode, the method further comprises:
And the electronic equipment receives an instruction for entering the fastboot mode, which is sent by the brushing equipment.
9. An electronic device, comprising: one or more processors and memory; the memory is coupled with the one or more processors, the memory for storing computer program code comprising computer instructions that the one or more processors invoke to cause the electronic device to perform the method of any of claims 1-8.
10. A computer readable storage medium comprising instructions which, when run on an electronic device, cause the electronic device to perform the method of any one of claims 1 to 8.
CN202310566350.3A 2023-05-18 2023-05-18 Authority setting method and electronic equipment Active CN116628670B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310566350.3A CN116628670B (en) 2023-05-18 2023-05-18 Authority setting method and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310566350.3A CN116628670B (en) 2023-05-18 2023-05-18 Authority setting method and electronic equipment

Publications (2)

Publication Number Publication Date
CN116628670A CN116628670A (en) 2023-08-22
CN116628670B true CN116628670B (en) 2024-03-22

Family

ID=87641121

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310566350.3A Active CN116628670B (en) 2023-05-18 2023-05-18 Authority setting method and electronic equipment

Country Status (1)

Country Link
CN (1) CN116628670B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114116023A (en) * 2021-06-15 2022-03-01 荣耀终端有限公司 Operating system starting method, operating system starting device, storage medium and computer program product
CN114265616A (en) * 2022-03-02 2022-04-01 荣耀终端有限公司 Upgrading method of operating system, electronic equipment and storage medium
CN115113799A (en) * 2021-03-18 2022-09-27 慧荣科技股份有限公司 Host command execution method and device
CN115543368A (en) * 2022-01-10 2022-12-30 荣耀终端有限公司 Operating system upgrading method and electronic equipment

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016181464A1 (en) * 2015-05-11 2016-11-17 株式会社日立製作所 Storage system and storage control method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115113799A (en) * 2021-03-18 2022-09-27 慧荣科技股份有限公司 Host command execution method and device
CN114116023A (en) * 2021-06-15 2022-03-01 荣耀终端有限公司 Operating system starting method, operating system starting device, storage medium and computer program product
WO2022262753A1 (en) * 2021-06-15 2022-12-22 荣耀终端有限公司 Operating system starting method, device, storage medium, and computer program product
CN115543368A (en) * 2022-01-10 2022-12-30 荣耀终端有限公司 Operating system upgrading method and electronic equipment
CN114265616A (en) * 2022-03-02 2022-04-01 荣耀终端有限公司 Upgrading method of operating system, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN116628670A (en) 2023-08-22

Similar Documents

Publication Publication Date Title
CN108763099B (en) System starting method and device, electronic equipment and storage medium
US8448187B2 (en) Conflict resolution apparatus
RU2630171C2 (en) Method of initialization of computer system with plurality of central processors
US9678767B2 (en) Unified extensible firmware interface (UEFI) driver and protocol
US20030110369A1 (en) Firmware extensions
CN109710317B (en) System starting method and device, electronic equipment and storage medium
JP6182160B2 (en) Dynamic code insertion into a running process
US20100169629A1 (en) Method for configuring computer by bios, server, computer, system startup method and computer system
CN105335178B (en) Starting control method and device
CN114020621A (en) Debugging method, electronic device and storage medium
CN113407247A (en) Dual-system starting method based on multi-core processor
CN116028455A (en) Data processing method and device, storage medium and electronic equipment
CN113448643B (en) Configuration data management system and method
CN116628670B (en) Authority setting method and electronic equipment
US11200203B1 (en) Accessing files stored in a firmware volume from a pre-boot application
CN116400938B (en) Operating system upgrading method, device and storage medium
KR20100050098A (en) Image processing apparatus and control method thereof
US8321606B2 (en) Systems and methods for managing memory using multi-state buffer representations
CN112130900A (en) User information management method, system, equipment and medium for BMC
CN107220101B (en) Container creation method and device
CN111314493A (en) Data processing method of heterogeneous cloud storage system and readable medium and system thereof
CN115827080B (en) Embedded equipment adaptation method and device based on serial port communication and computer equipment
US12013774B2 (en) Verification of core file debugging resources
JP3832933B2 (en) Information processing apparatus and method, operating system, and storage medium
CN117032818A (en) BIOS (basic input output system) option configuration method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant