CN113504918A - Equipment tree configuration optimization method and device, computer equipment and storage medium - Google Patents

Equipment tree configuration optimization method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN113504918A
CN113504918A CN202110535235.0A CN202110535235A CN113504918A CN 113504918 A CN113504918 A CN 113504918A CN 202110535235 A CN202110535235 A CN 202110535235A CN 113504918 A CN113504918 A CN 113504918A
Authority
CN
China
Prior art keywords
tree file
target
file
equipment
child node
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.)
Pending
Application number
CN202110535235.0A
Other languages
Chinese (zh)
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.)
Shenzhen Guangtong Yuanchi Technology Co ltd
Original Assignee
Shenzhen Guangtong Yuanchi Technology 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 Shenzhen Guangtong Yuanchi Technology Co ltd filed Critical Shenzhen Guangtong Yuanchi Technology Co ltd
Priority to CN202110535235.0A priority Critical patent/CN113504918A/en
Publication of CN113504918A publication Critical patent/CN113504918A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application relates to a device tree configuration optimization method, a device, computer equipment and a storage medium. The method comprises the following steps: reading an original equipment tree file from a system starting partition, and loading the original equipment tree into a running memory; reading a target device tree file from a target configuration partition, and loading the target device tree file into an operating memory, wherein the target configuration partition is obtained by partitioning a file system; modifying child node information of the original equipment tree file according to the target equipment tree file to obtain an updated equipment tree file; loading a kernel driver, and acquiring an updated equipment tree file from an operating memory; and according to the updated device tree file, realizing connection with the target hardware device. By adopting the method, the maintenance cost of the equipment tree file adaptation hardware can be reduced.

Description

Equipment tree configuration optimization method and device, computer equipment and storage medium
Technical Field
The present application relates to the technical field of ARM-LINUX systems, and in particular, to a method and an apparatus for optimizing a device tree configuration, a computer device, and a storage medium.
Background
With the development of the ARM-LINUX system technology, a device tree configuration technology has appeared in order to enable the ARM-LINUX system to be adapted to hardware devices.
In the conventional technology, in the current method of using the device tree in the ARM-LINUX system, one software version can only adapt to one hardware configuration, and if another hardware configuration is replaced, for example: the hardware configuration of the device A is to open the serial port, the hardware configuration of the device B is to close the serial port, and the device tree file needs to be modified and compiled to generate software version upgrading adaptation when software is adapted to the hardware of the device B after the hardware of the device A is adapted to the hardware of the device B.
However, the conventional method of adapting hardware by using the device tree file uses multiple versions of software, requires multiple compiling and releasing processes, and is high in maintenance cost.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a device tree configuration optimization method, apparatus, computer device, and storage medium capable of reducing maintenance cost of device tree file adaptation hardware.
A device tree configuration optimization method, wherein a cache partition comprises a system starting partition and a file system partition, and the method comprises the following steps:
reading an original equipment tree file from a system starting partition, and loading the original equipment tree into a running memory;
reading a target device tree file from a target configuration partition, and loading the target device tree file into an operating memory, wherein the target configuration partition is obtained by partitioning the file system partition;
modifying the child node information of the original equipment tree file according to the target equipment tree file to obtain an updated equipment tree file;
loading a kernel driver, and acquiring the updated equipment tree file from the running memory;
and realizing connection with the target hardware equipment according to the updated equipment tree file.
In one embodiment, the child node information includes attribute names and corresponding attribute values of the nodes; according to the target device tree file, modifying the child node information of the original device tree file to obtain an updated device tree file, including:
checking whether a first attribute name of a child node in the original equipment tree file is the same as a second attribute name of a child node in the target equipment tree file;
when the first attribute name is the same as the second attribute name, checking whether a first attribute value corresponding to the first attribute name is the same as a second attribute value corresponding to the second attribute name;
and when the first attribute value is different from the second attribute value, modifying the first attribute value of the child node in the original equipment tree file according to the second attribute value of the child node in the target equipment tree file to obtain the updated equipment tree file.
In one embodiment, when the first attribute name is different from the second attribute name, the second attribute name and the corresponding second attribute value in the target device tree file are added to the original device tree file to obtain an updated device tree file.
Before modifying the child node information corresponding to the original device tree file according to the target device tree file to obtain an updated device tree file, the method further includes:
checking whether the first child node name of the original equipment tree file is the same as the second child node name of the target equipment tree file;
and when the first child node name is the same as the second child node name, executing a step of modifying the child node information of the original equipment tree file according to the target equipment tree file.
In one embodiment, the method further comprises:
checking whether the size of the target equipment tree file is larger than the memory space of the configuration partition;
and when the size of the target equipment tree file is not larger than the memory space of the candidate configuration partition, determining that the target equipment tree file is valid, and storing the target equipment tree file into the target configuration partition.
In one embodiment, the method further comprises:
checking whether the size of the target equipment tree file is larger than the memory space of the configuration partition;
and when the size of the target equipment tree file is not larger than the memory space of the candidate configuration partition, determining that the target equipment tree file is valid, and storing the target equipment tree file into the target configuration partition.
An apparatus for device tree configuration optimization, the apparatus comprising:
the system comprises a starting partition, a primary device tree file reading module, a primary device tree file loading module and a running memory, wherein the starting partition is used for starting a system;
a target device tree file loading module, configured to read a target device tree file from a target configuration partition, and load the target device tree file into an operating memory, where the target configuration partition is obtained by partitioning the file system partition, and the target device tree file of the target device tree file is the same as the second file configuration of the target hardware device;
the updated equipment tree file acquisition module is used for modifying the child node information of the original equipment tree file according to the target equipment tree file to obtain an updated equipment tree file;
the updated equipment tree file loading module is used for loading the kernel driver and acquiring the updated equipment tree file from the running memory;
and the target hardware equipment connection module is used for realizing connection with the target hardware equipment according to the updated equipment tree file.
In one embodiment, the updated device tree file obtaining module includes:
the attribute name checking module is used for checking whether a first attribute name of a child node in the original equipment tree file is the same as a second attribute name of a child node in the target equipment tree file; when the first attribute name is the same as the second attribute name, checking whether a first attribute value corresponding to the first attribute name is the same as a second attribute value corresponding to the second attribute name; and when the first attribute value is different from the second attribute value, modifying the first attribute value of the child node in the original equipment tree file according to the second attribute value of the child node in the target equipment tree file to obtain an updated equipment tree file.
A computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:
reading an original equipment tree file from a system starting partition, and loading the original equipment tree into a running memory;
reading a target device tree file from a target configuration partition, and loading the target device tree file into an operating memory, wherein the target configuration partition is obtained by partitioning the file system partition;
modifying the child node information of the original equipment tree file according to the target equipment tree file to obtain an updated equipment tree file;
loading a kernel driver, and acquiring the updated equipment tree file from the running memory;
and realizing connection with the target hardware equipment according to the updated equipment tree file.
A computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:
reading an original equipment tree file from a system starting partition, and loading the original equipment tree into a running memory;
reading a target device tree file from a target configuration partition, and loading the target device tree file into an operating memory, wherein the target configuration partition is obtained by partitioning the file system partition;
modifying the child node information of the original equipment tree file according to the target equipment tree file to obtain an updated equipment tree file;
loading a kernel driver, and acquiring the updated equipment tree file from the running memory;
and realizing connection with the target hardware equipment according to the updated equipment tree file.
According to the equipment tree configuration optimization method, the equipment tree configuration optimization device, the computer equipment and the storage medium, the target equipment tree file contains files which are needed by an operating system and used for being connected with external hardware equipment. And reading the original equipment tree file from the system starting partition, and loading the original equipment tree file into the running memory. And storing the target equipment tree file into the target configuration partition, and loading the target equipment tree file into the operating memory, so that in the operating memory, the original equipment tree file can be modified according to the target equipment tree file to obtain an updated equipment tree file. And acquiring the updated equipment tree file from the running memory by loading the kernel driver. According to the updated device tree file, the system can be adapted to the external target hardware device. The method for adapting the hardware by using the equipment tree file does not need to use software of multiple versions, and does not need to compile and release for multiple times in the middle, so that the maintenance cost of the hardware adapted by using the equipment tree file can be reduced.
Drawings
FIG. 1 is a diagram of an application environment for a method for device tree configuration optimization according to an embodiment;
FIG. 2 is a flowchart illustrating a method for optimizing device tree configuration according to an embodiment;
FIG. 3 is a diagram illustrating an exemplary optimization of a device tree configuration;
FIG. 4 is a diagram of a device tree structure in one embodiment;
FIG. 5 is a flowchart illustrating a method for optimizing device tree configuration according to another embodiment;
FIG. 6 is a block diagram showing an exemplary apparatus for optimizing the configuration of a device tree;
FIG. 7 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The device tree configuration optimization method provided by the application can be applied to the application environment shown in fig. 1. The terminal 102 and the target hardware device 104 communicate with each other in a serial wired or wireless manner, and the terminal 102 specifically carries an ARM-Linux embedded system in the present application. The terminal 102 includes a flash cache partition, which includes a system start partition (boot partition), a kernel partition, and a file system partition, and reads an original device tree file from the system start partition, loads the original device tree into an operating memory, and loads a target device tree file matched with an external target hardware device 104 into the operating memory, so that the original device tree file is modified in the operating memory according to the target device tree file to obtain an updated device tree file, and the updated device tree file can be successfully connected with the target hardware device 104.
In an embodiment, as shown in fig. 2 and fig. 3, a method for optimizing a device tree configuration is provided, which is described by taking the method as an example applied to the terminal in fig. 1, and includes the following steps:
step S202, reading the original equipment tree file from the system starting partition, and loading the original equipment tree into the running memory.
The device tree file is stored behind the kernel block of the boot partition, and the device tree file is loaded through the boot partition by starting step by step. The target device tree file in the application is set according to the target hardware device, and the target device tree file is used for modifying the original device tree file, so that the original system only can be adapted to the hardware device A and can also be adapted to the target hardware device.
Specifically, in the process of updating the original device tree file according to the target device tree file, the original device tree file needs to be read from the system start partition and loaded into the operating memory; the running memory is a running environment for the system to perform data calculation.
Step S204, reading the target device tree file from the target configuration partition, and loading the target device tree file into the operating memory, wherein the target configuration partition is obtained by partitioning the file system partition.
The target configuration partition is a storage space obtained by newly dividing the file system partition by the system. As shown in fig. 3, the file system partition includes partition 1, partition 2, partition 3. When the original device tree file is read from the system starting partition and loaded into the operating memory, the system reads the target device tree file from the target configuration partition and loads the target device tree file into the operating memory, so that the target device tree file and the original device tree file are both located in the operating memory, and in the operating memory, the system can modify the original device tree file according to the target device tree file.
Step S206, according to the target device tree file, the child node information of the original device tree file is modified to obtain an updated device tree file.
The structure diagram of the original device tree is shown in fig. 4, the original device tree file includes a unique root node and a plurality of child nodes, in the device tree structure, the root node is located above each child node, and the root node and the child nodes both have a plurality of files with the suffix of dts or dtsi, for example, the root node includes root node files of models, compatibility, interrupts, central processing units, systems on chip, and the like. The system on chip of one of the root node files comprises child node files such as an interrupt controller, a timer and a serial port. It can be known that the file on the child node belongs to the file on the root node, and the file is the detailed configuration content of a certain file on the root node, and the detailed configuration content includes the relevant configuration information of the target hardware device. The child node information includes an attribute name and an attribute value of the node, the attribute value is specific configuration information of a file on the child node, and the attribute name is a name of the attribute value. The target device tree file may include a root node and several child nodes, for which case the original device tree file may be entirely "replaced". Firstly, whether the root node of the original equipment tree file is matched with the root node of the target equipment tree file is matched, and when the root node of the original equipment tree file is matched with the root node of the target equipment tree file, all the sub nodes corresponding to the original equipment tree file are sequentially replaced according to all the sub nodes of the target equipment tree file, so that an updated equipment tree file which is modified more comprehensively as a whole is obtained. Based on the updated device tree file, the system may adapt to a plurality of target hardware devices that were not previously adaptable. In another case, the target device tree file includes a child node, the child node corresponding to the original device tree file may be modified according to the target device tree file, and if the original device tree file does not have a child node corresponding to the target device tree file, the target device tree file may be directly added to the root node of the original device tree file to serve as a new child node. In fig. 4, for example, when the serial port configuration information is changed, the serial port configuration information in the child node file is modified according to the target device tree file, so that the serial port configuration information of the original device tree is updated and can be successfully adapted to the target hardware device, and the system can be successfully connected to the target hardware device.
Step S208, load the kernel driver, and obtain the updated device tree file from the operating memory.
After the original device tree file is compiled, a dtb file (namely, a binary original device tree file) is stored behind a kernel block in a kernel image file, after the system is started, according to a starting sequence, a bootstrap program is started (namely, boot starting) firstly, then the kernel is started, the process of starting the kernel can be regarded as a process of loading a kernel driver, and when the kernel driver is loaded, the system acquires an updated device tree file from a running memory and maps the updated device tree file into the kernel for taking effect.
And step S210, according to the updated device tree file, realizing connection with the target hardware device.
Since the updated device tree file includes the file information matching the target hardware device, the system can implement connection with the target hardware device according to the updated device tree file after the system maps the updated device tree file into the kernel.
In the above device tree configuration optimization method, the target device tree file contains a file required by the operating system and used for connecting with the external hardware device. And reading the original equipment tree file from the system starting partition, and loading the original equipment tree file into the running memory. And storing the target equipment tree file into the target configuration partition, and loading the target equipment tree file into the operating memory, so that in the operating memory, the original equipment tree file can be modified according to the target equipment tree file to obtain an updated equipment tree file. And acquiring the updated equipment tree file from the running memory by loading the kernel driver. According to the updated device tree file, the system can be adapted to the external target hardware device. The method for adapting the hardware by using the equipment tree file does not need to use software of multiple versions, and does not need to compile and release for multiple times in the middle, so that the maintenance cost of the hardware adapted by using the equipment tree file can be reduced.
In one embodiment, the child node information includes the attribute name and corresponding attribute value of the node; modifying the child node information of the original device tree file according to the target device tree file to obtain an updated device tree file, comprising:
verifying whether a first attribute name of a child node in the original equipment tree file is the same as a second attribute name of a child node in the target equipment tree file;
when the first attribute name is the same as the second attribute name, checking whether a first attribute value corresponding to the first attribute name is the same as a second attribute value corresponding to the second attribute name;
when the first attribute value is different from the second attribute value, modifying the first attribute value of the child node in the original equipment tree file according to the second attribute value of the child node in the target equipment tree file to obtain an updated equipment tree file;
and when the first attribute name is different from the second attribute name, adding the second attribute name and the corresponding second attribute value in the target equipment tree file into the original equipment tree file to obtain an updated equipment tree file.
The first attribute name refers to an attribute name of a child node in the source device tree file, for example, the attribute name is "state", and the code may be written as "status" or "disabled", that is, the attribute state of the child node is indicated as unavailable. The second attribute name is the attribute name of the child node in the target device tree file, and is similar to the first attribute name.
Specifically, in the process of modifying the original device tree file according to the target device tree file, it is necessary to determine whether a first attribute name of a child node in the original device tree file is the same as a second attribute name of a child node in the target device tree file. And when the first attribute value and the second attribute value are the same, further checking whether the first attribute value corresponding to the first attribute name and the second attribute value corresponding to the second attribute name are the same. And when the first attribute value is different from the second attribute value, modifying the first attribute value of the child node in the original equipment tree file according to the second attribute value of the child node in the target equipment tree file, thereby obtaining an updated equipment tree file. In addition, the updated device tree file is obtained, and when the first attribute name and the second attribute name are different, it indicates that the corresponding child node cannot be found in the original device tree file.
In actual programming, the code for modifying the child node information is as follows,
[product]
version is 1000/version number
Chinese character 'mdm 9607'/type
custom _ num x/number of hardware configurations in the configuration file
custom _ name ═ xxx "/name of hardware configuration currently to be used
[ xxx ]/hardware configuration Start
[/xx/xx/xx ]/corresponding device tree files, where the first slash represents the root node, "xx" is a child node, the second and third slashes are separators, "xx" is a child node below the child node, and so on
Attribute names and attribute values under xx/modified child nodes
[ end ]/end of hardware configuration
In this embodiment, by checking the first attribute name and the second attribute name, when the first attribute name and the second attribute name are different, the second attribute name and the second attribute value in the child node of the target device tree file are directly added to the original device tree, so as to obtain an updated device tree file. Or the first attribute name and the second attribute name are the same, but the first attribute value and the second attribute value are different, the first attribute value of the child node in the original device tree file can be modified according to the second attribute value in the target device tree file, and the updated device tree file is obtained. Therefore, the original equipment tree file can be adaptively modified according to the target equipment tree file, and the original equipment tree file is adapted to the target hardware equipment, so that the system and the target hardware equipment can be successfully connected.
In an embodiment, before modifying the child node information corresponding to the original device tree file according to the target device tree file to obtain an updated device tree file, the method further includes:
checking whether the first child node name of the original equipment tree file is the same as the second child node name of the target equipment tree file;
and when the first child node name is the same as the second child node name, executing a step of modifying the child node information of the original equipment tree file according to the target equipment tree file.
The first child node name of the original device tree file, for example, a serial port, may be UART1, UART2. In the case of consistent file content in both ARM-Linux system and target hardware equipment, the naming of the child nodes is fixed.
Specifically, before comparing the attribute name and the attribute value of the child node of the source device tree with the attribute name and the attribute value of the child node of the target device tree, it is further required to check whether the name of the first child node of the source device tree file is the same as the name of the second child node of the target device tree file, and the step of modifying the child node information of the source device tree file according to the target device tree file is performed only if the name of the first child node is the same as the name of the second child node.
In this embodiment, the step of modifying the child node information of the original device tree file according to the target device tree file is performed by checking whether the first child node name of the original device tree is the same as the second child node name of the target device tree in advance, which is beneficial to improving the accuracy of matching and modifying the original device tree file and the target device tree file.
In one embodiment, the method for optimizing the device tree configuration further includes: checking whether the size of the target equipment tree file is larger than the memory space of the target configuration partition;
and when the size of the target equipment tree file is not larger than the memory space of the target configuration partition, determining that the target equipment tree file is valid, and storing the target equipment tree file into the target configuration partition.
The size of the memory space of the newly divided target configuration partition is fixed, for example, 4K of memory space. If the size of the target device tree file exceeds the memory space of the target configuration partition, the target configuration partition cannot store the target device tree file, so that the target device tree file is not a valid file and cannot be stored in the target configuration partition.
In addition, the size of the target device tree file can be obtained by obtaining the address of the target configuration partition and calculating the address of the target configuration partition.
In this embodiment, whether the size of the target device tree file is larger than the memory space of the target configuration partition is checked to determine whether the target device tree file is an invalid file exceeding the pre-allocated space, so as to ensure that the target device tree file stored in the target configuration partition is a valid target device tree file.
In one embodiment, the method for optimizing the device tree configuration further includes:
checking whether the target equipment tree file is an empty file;
and when the target equipment tree file is not an empty file, modifying the child node information of the original equipment tree file according to the target equipment tree file.
The empty file refers to a file with no content or incomplete content.
Specifically, the target device tree file may also be an empty file if it is valid, and therefore, it is required to check whether the target device tree file is not an empty file, and when the target device tree file is not an empty file, the step of modifying the child node information of the original device tree according to the target device tree file is performed.
In this embodiment, by checking whether the target device tree file is an empty file, the step of modifying the child node information of the original device tree according to the target device tree file is executed under the condition that the target device tree file is not an empty file, so that the target device tree file can be ensured to be a normal file, and the original device tree file can be modified.
In one embodiment, as shown in fig. 5, a device tree configuration optimization method includes: steps S502 to S518, wherein:
step S502, reading the original device tree file from the system boot partition, and loading the original device tree into the operating memory.
Step S504, reading the target device tree file from the target configuration partition, and loading the target device tree file into the operating memory.
And the target configuration partition is obtained by partitioning the file system partition.
Step S506, checking whether the first child node name of the original device tree file is the same as the second child node name of the target device tree file. When the first child node name is the same as the second child node name, step S508 is executed to check whether the first attribute name of the child node in the source device tree file is the same as the second attribute name of the child node in the target device tree file. When the first attribute name and the second attribute name are the same, step S510 is executed to check whether the first attribute value corresponding to the first attribute name is the same as the second attribute value corresponding to the second attribute name.
And when the first attribute value is different from the second attribute value, executing step S512, and modifying the first attribute value of the child node in the original device tree file according to the second attribute value of the child node in the target device tree file to obtain an updated device tree file.
When the first attribute name is different from the second attribute name, step S514 is executed to add the second attribute name and the corresponding second attribute value in the target device tree file to the original device tree file, so as to obtain an updated device tree file.
After obtaining the updated device tree file, step S516 is executed to load the kernel driver, and obtain the updated device tree file from the operating memory.
And step S518, realizing connection with the target hardware equipment according to the updated equipment tree file.
In this embodiment, the original device tree file is loaded into the operating memory by reading the original device tree file from the system boot partition. And storing the target equipment tree file into the target configuration partition, and loading the target equipment tree file into the operating memory, so that in the operating memory, the original equipment tree file can be modified according to the target equipment tree file to obtain an updated equipment tree file. And acquiring the updated equipment tree file from the running memory by loading the kernel driver. According to the updated device tree file, the system can be adapted to the external target hardware device. The method for adapting the hardware by using the equipment tree file does not need to use software of multiple versions, and does not need to compile and release for multiple times in the middle, so that the maintenance cost of the hardware adapted by using the equipment tree file can be reduced.
It should be understood that, although the steps in the flowcharts related to the above embodiments are shown in sequence as indicated by the arrows, the steps are not necessarily executed in sequence as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a part of the steps in each flowchart related to the above embodiments may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of performing the steps or stages is not necessarily sequential, but may be performed alternately or alternately with other steps or at least a part of the steps or stages in other steps.
In one embodiment, as shown in fig. 6, there is provided an apparatus for optimizing a device tree configuration, including: an original device tree file reading module 601, a target device tree file loading module 602, an updated device tree file obtaining module 603, an updated device tree file loading module 604, and a target hardware device connecting module 605, wherein:
a source device tree file reading module 601, configured to read a source device tree file from a system boot partition, and load the source device tree into an operating memory;
a target device tree file loading module 602, configured to read a target device tree file from a target configuration partition, and load the target device tree file into an operating memory, where the target configuration partition is obtained by partitioning a file system partition, and the target device tree file of the target device tree file is the same as the second file configuration of the target hardware device;
an updated device tree file obtaining module 603, configured to modify child node information of the original device tree file according to the target device tree file to obtain an updated device tree file;
an updated device tree file loading module 604, configured to load a kernel driver and obtain an updated device tree file from an operating memory;
and the target hardware device connection module 605 is configured to implement connection with the target hardware device according to the updated device tree file.
In one embodiment, the updated device tree file acquisition module includes: the attribute name checking module is used for checking whether a first attribute name of a child node in the original equipment tree file is the same as a second attribute name of a child node in the target equipment tree file; when the first attribute name is the same as the second attribute name, checking whether a first attribute value corresponding to the first attribute name is the same as a second attribute value corresponding to the second attribute name; when the first attribute value is different from the second attribute value, modifying the first attribute value of the child node in the original equipment tree file according to the second attribute value of the child node in the target equipment tree file to obtain an updated equipment tree file; and when the first attribute name is different from the second attribute name, adding the second attribute name and the corresponding second attribute value in the target equipment tree file into the original equipment tree file to obtain an updated equipment tree file.
In one embodiment, the device tree configuration optimizing apparatus further includes: the child node name checking module is used for checking whether a first child node name of the original equipment tree file is the same as a second child node name of the target equipment tree file; and when the first child node name is the same as the second child node name, executing a step of modifying the child node information of the original equipment tree file according to the target equipment tree file.
In one embodiment, the device tree configuration optimizing apparatus further includes: the file size checking module is used for checking whether the size of the target equipment tree file is larger than the memory space of the target configuration partition or not; and when the size of the target equipment tree file is not larger than the memory space of the target configuration partition, determining that the target equipment tree file is valid, and storing the target equipment tree file into the target configuration partition.
In one embodiment, the device tree configuration optimizing apparatus further includes: the empty file checking module is used for checking whether the target equipment tree file is an empty file; and when the target equipment tree file is not an empty file, modifying the child node information of the original equipment tree file according to the target equipment tree file.
For specific limitations of the device tree configuration optimization apparatus, reference may be made to the above limitations of the device tree configuration optimization method, which are not described herein again. The respective modules in the above device tree configuration optimization apparatus may be wholly or partially implemented by software, hardware, and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 7. The computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless communication can be realized through WIFI, an operator network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a device tree configuration optimization method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
Those skilled in the art will appreciate that the architecture shown in fig. 7 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is further provided, which includes a memory and a processor, the memory stores a computer program, and the processor implements the steps of the above method embodiments when executing the computer program.
In an embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when being executed by a processor, carries out the steps of the above-mentioned method embodiments.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A device tree configuration optimization method is characterized in that a cache partition comprises a system starting partition and a file system partition, and the method comprises the following steps:
reading an original equipment tree file from a system starting partition, and loading the original equipment tree into a running memory;
reading a target device tree file from a target configuration partition, and loading the target device tree file into an operating memory, wherein the target configuration partition is obtained by partitioning the file system partition;
modifying the child node information of the original equipment tree file according to the target equipment tree file to obtain an updated equipment tree file;
loading a kernel driver, and acquiring the updated equipment tree file from the running memory;
and realizing connection with the target hardware equipment according to the updated equipment tree file.
2. The method of claim 1, wherein the child node information comprises an attribute name and a corresponding attribute value of the node; according to the target device tree file, modifying the child node information of the original device tree file to obtain an updated device tree file, including:
checking whether a first attribute name of a child node in the original equipment tree file is the same as a second attribute name of a child node in the target equipment tree file;
when the first attribute name is the same as the second attribute name, checking whether a first attribute value corresponding to the first attribute name is the same as a second attribute value corresponding to the second attribute name;
and when the first attribute value is different from the second attribute value, modifying the first attribute value of the child node in the original equipment tree file according to the second attribute value of the child node in the target equipment tree file to obtain the updated equipment tree file.
3. The method according to claim 2, wherein when the first attribute name and the second attribute name are different, the second attribute name and the corresponding second attribute value in the target device tree file are added to an original device tree file to obtain an updated device tree file.
4. The method of claim 1, wherein before modifying the child node information corresponding to the original device tree file according to the target device tree file to obtain an updated device tree file, the method further comprises:
checking whether the first child node name of the original equipment tree file is the same as the second child node name of the target equipment tree file;
and when the first child node name is the same as the second child node name, executing a step of modifying the child node information of the original equipment tree file according to the target equipment tree file.
5. The method of claim 1, further comprising:
checking whether the size of the target equipment tree file is larger than the memory space of the target configuration partition;
and when the size of the target equipment tree file is not larger than the memory space of the target configuration partition, determining that the target equipment tree file is valid, and storing the target equipment tree file into the target configuration partition.
6. The method of claim 1, further comprising:
checking whether the target equipment tree file is an empty file;
and when the target equipment tree file is not an empty file, modifying the child node information of the original equipment tree file according to the target equipment tree file.
7. An apparatus for optimizing a device tree configuration, the apparatus comprising:
the system comprises a starting partition, a primary device tree file reading module, a primary device tree file loading module and a running memory, wherein the starting partition is used for starting a system;
a target device tree file loading module, configured to read a target device tree file from a target configuration partition, and load the target device tree file into an operating memory, where the target configuration partition is obtained by partitioning the file system partition, and the target device tree file of the target device tree file is the same as the second file configuration of the target hardware device;
the updated equipment tree file acquisition module is used for modifying the child node information of the original equipment tree file according to the target equipment tree file to obtain an updated equipment tree file;
the updated equipment tree file loading module is used for loading the kernel driver and acquiring the updated equipment tree file from the running memory;
and the target hardware equipment connection module is used for realizing connection with the target hardware equipment according to the updated equipment tree file.
8. The apparatus of claim 7, wherein the updated device tree file obtaining module comprises:
the attribute name checking module is used for checking whether a first attribute name of a child node in the original equipment tree file is the same as a second attribute name of a child node in the target equipment tree file; when the first attribute name is the same as the second attribute name, checking whether a first attribute value corresponding to the first attribute name is the same as a second attribute value corresponding to the second attribute name; and when the first attribute value is different from the second attribute value, modifying the first attribute value of the child node in the original equipment tree file according to the second attribute value of the child node in the target equipment tree file to obtain an updated equipment tree file.
9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method of any of claims 1 to 6.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 6.
CN202110535235.0A 2021-05-17 2021-05-17 Equipment tree configuration optimization method and device, computer equipment and storage medium Pending CN113504918A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110535235.0A CN113504918A (en) 2021-05-17 2021-05-17 Equipment tree configuration optimization method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110535235.0A CN113504918A (en) 2021-05-17 2021-05-17 Equipment tree configuration optimization method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113504918A true CN113504918A (en) 2021-10-15

Family

ID=78008517

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110535235.0A Pending CN113504918A (en) 2021-05-17 2021-05-17 Equipment tree configuration optimization method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113504918A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114661330A (en) * 2022-05-25 2022-06-24 武汉海微科技有限公司 Vehicle hardware program updating method, device, equipment and storage medium
CN114691240A (en) * 2022-04-01 2022-07-01 武汉深之度科技有限公司 Drive hardware configuration information loading method, device and system and computing equipment
CN115328563A (en) * 2022-10-09 2022-11-11 荣耀终端有限公司 System starting method and electronic equipment

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114691240A (en) * 2022-04-01 2022-07-01 武汉深之度科技有限公司 Drive hardware configuration information loading method, device and system and computing equipment
CN114661330A (en) * 2022-05-25 2022-06-24 武汉海微科技有限公司 Vehicle hardware program updating method, device, equipment and storage medium
CN115328563A (en) * 2022-10-09 2022-11-11 荣耀终端有限公司 System starting method and electronic equipment
CN115328563B (en) * 2022-10-09 2023-04-14 荣耀终端有限公司 System starting method and electronic equipment

Similar Documents

Publication Publication Date Title
CN113504918A (en) Equipment tree configuration optimization method and device, computer equipment and storage medium
US20190087208A1 (en) Method and apparatus for loading elf file of linux system in windows system
JP7088897B2 (en) Data access methods, data access devices, equipment and storage media
CN108776587B (en) Data acquisition method and device, computer equipment and storage medium
CN112765023A (en) Test case generation method and device
CN111158715A (en) Gray scale release control method and system
CN108846129B (en) Storage data access method, device and storage medium
EP3698253A1 (en) System and method for managing program memory on a storage device
CN113010265A (en) Pod scheduling method, scheduler, memory plug-in and system
CN115344284A (en) Automatic driving software upgrading method and device, storage medium and computer equipment
CN109190367B (en) Method and device for running application program installation package by utilizing sandbox
CN110192178B (en) Program patching method and device, micro control unit and terminal equipment
CN106951288B (en) Development and application method and device of hot upgrade resource
CN115934354A (en) Online storage method and device
CN112269665B (en) Memory processing method and device, electronic equipment and storage medium
CN113590144B (en) Dependency processing method and device
CN115454403A (en) Page construction method and device and storage medium
CN115048082A (en) Micro front-end system construction method and device, server and readable storage medium
CN110333870B (en) Simulink model variable distribution processing method, device and equipment
CN112417020A (en) Method and device for realizing service expansion, computer equipment and storage medium
CN114756261A (en) Container cluster upgrading method and system, electronic equipment and medium
CN113961841A (en) Native application webpage loading method, system, storage medium and equipment
CN109840156B (en) Data caching method and equipment, storage medium and terminal thereof
CN112783866A (en) Data reading method and device, computer equipment and storage medium
CN111857662A (en) Programming method for describing object specific constitution based on MAP and interface

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