Equipment tree loading method and device, electronic equipment and storage medium

By parsing the mirror tree file and adopting a multi-level priority matching mechanism, the problems of insufficient flexibility and accuracy in existing device tree loading methods are solved, and efficient and flexible loading of device trees and accurate identification of hardware resources are achieved.

CN121635992APending Publication Date: 2026-03-10SHENZHEN GRANDSTREAM NETWORKS TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-12
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

Existing device tree loading methods rely on the firmware configuration of hardware circuits, which is difficult to modify flexibly. This results in low device tree loading efficiency, inaccurate matching of device tree files, leading to hardware resource identification errors and abnormal system startup.

Method used

By parsing the image tree file through the bootloader, configuration description information and device tree file are obtained. Based on the multi-level priority matching mechanism of device attributes, the target device tree file is determined, thereby achieving automatic and accurate loading of the device tree.

Benefits of technology

It improves the flexibility and efficiency of device tree loading, facilitates subsequent adjustments to device adaptation, ensures accurate identification of hardware resources, and reduces production and maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121635992A_ABST
    Figure CN121635992A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses an equipment tree loading method and device, electronic equipment and a storage medium. In the starting process of a target device, a mirror image tree file of the target device is analyzed through a boot loader, multiple pieces of configuration description information, a device tree file and updatable configuration content are obtained, and the configuration content is used for indicating the corresponding relation between at least one device attribute and the configuration description information; determining matched target configuration description information of the target equipment in the starting process based on the configuration content and at least one equipment attribute of the target equipment; determining a target device tree file matched with the target device in the device tree file based on device tree indication information configured in the target configuration description information; and loading the target device tree file to identify hardware resources of the target device. Therefore, the target device tree file matched with the target device in the starting process can be accurately and flexibly loaded, and the device tree loading efficiency is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and specifically to a device tree loading method, apparatus, electronic device, and storage medium. Background Technology

[0002] In the boot process of embedded systems and operating system kernels, the device tree, as a key description file for hardware abstraction, is widely used in the Linux kernel to enable the operating system to identify and manage different hardware resources. Some device tree loading methods typically rely on peripheral hardware circuitry to distinguish device models or versions, thereby selecting the appropriate device tree file.

[0003] However, this device tree loading method relies on the firmware configuration of the hardware circuit, making it difficult to modify the adapted device tree later. As a result, it cannot accurately and flexibly load the device tree file matched by the device, leading to low device tree loading efficiency. Summary of the Invention

[0004] This application provides a device tree loading method, apparatus, electronic device, and storage medium, which can accurately and flexibly determine and load the target device tree file that matches the target device during the current startup process, facilitating the adjustment of the device tree file for device adaptation in the later stage and effectively improving the device tree loading efficiency.

[0005] This application provides a device tree loading method, including: During the startup process of the target device, the image tree file of the target device is parsed by the bootloader to obtain multiple configuration description information, device tree file and updatable configuration content. The configuration content is used to indicate the correspondence between at least one device attribute and the configuration description information. Based on the configuration content and at least one device attribute of the target device, determine the target configuration description information matched by the target device during this startup process; Based on the device tree indication information configured in the target configuration description information, a target device tree file matching the target device is determined in the device tree file; The target device tree file is loaded to identify the hardware resources of the target device.

[0006] Accordingly, embodiments of this application also provide a device tree loading apparatus, including: The parsing unit is used to parse the image tree file of the target device through the bootloader during the startup process of the target device to obtain multiple configuration description information, device tree file and updatable configuration content, wherein the configuration content is used to indicate the correspondence between at least one device attribute and the configuration description information; The first determining unit is configured to determine, based on the configuration content and at least one device attribute of the target device, the target configuration description information matched by the target device during this startup process. The second determining unit is configured to determine, based on the device tree indication information configured in the target configuration description information, a target device tree file that matches the target device in the device tree file; The loading unit is used to load the target device tree file to identify the hardware resources of the target device.

[0007] In one embodiment, each of the device attributes is configured with a corresponding priority, and the first determining unit is configured to: According to the priority of the device attributes from high to low, the device attributes of the target device are matched with the configuration description information corresponding to the device attributes indicated in the configuration content. If the device attribute of the current priority matches the corresponding configuration description information, then the configuration description information is determined as the target configuration description information matched by the target device during this startup process; If the current priority device attribute does not match the corresponding configuration description information, the matching continues based on the next priority device attribute until the target configuration description information is matched.

[0008] In one embodiment, the device attributes include at least one of device serial number, product model, and hardware identification parameters, wherein the priority corresponding to the device serial number is greater than the priority corresponding to the product model, and the priority corresponding to the product model is greater than the priority corresponding to the hardware identification parameters.

[0009] In one embodiment, the device attributes include a device serial number and other device attributes, wherein the device serial number has a higher priority than the other device attributes, the configuration content includes a mapping relationship between the device serial number and the corresponding configuration description information, the configuration description information includes device attribute indication information, the device attribute indication information is used to indicate other device attributes that match the configuration description information, and the other device attributes include at least one of product model and hardware identification parameters; The above-mentioned matching of the device attributes of the target device with the configuration description information corresponding to the device attributes indicated in the configuration content, in descending order of priority, is specifically used for: According to the priority of the device attributes from high to low, based on the mapping relationship between the device serial number and the corresponding configuration description information, the target device serial number of the target device is matched with the configuration description information corresponding to the device serial number indicated by the mapping relationship; If the current priority device attribute does not match the corresponding configuration description information, the matching continues based on the next priority device attribute until the target configuration description information is matched. Specifically, this is used for: If the target device serial number does not match the corresponding configuration description information, the next priority target device attribute is determined from the other device attributes. Based on the target device attribute corresponding to the target device and the device attribute indication information of the configuration description information, the target configuration description information that matches the target device is determined from the configuration description information.

[0010] In one embodiment, the device attributes include a device serial number, which has the highest priority. The configuration content includes at least one preset mapping relationship between a device serial number range and corresponding configuration description information. Each configuration description information is configured with a corresponding priority. The above-mentioned matching of the device attributes of the target device with the configuration description information corresponding to the device attributes indicated in the configuration content is specifically used for: The highest priority configuration description information is determined from the configuration description information. Based on the mapping relationship, a target serial number range that matches the first configuration description information is determined in the preset device serial number range; If the target device serial number corresponding to the target device is found in the target serial number range, the first configuration description information is determined to be the configuration description information corresponding to the target device serial number.

[0011] In one embodiment, the configuration content includes a mapping relationship between device serial numbers and corresponding configuration description information. The configuration description information includes priority information and device attribute indication information. The device attribute indication information is used to indicate device attributes that match the configuration description information. The device attributes include at least one of device serial number, product model, and hardware identification parameters. A first determining unit is configured to: Based on multiple device attributes of the target device, the device attribute indication information, and the mapping relationship, at least one candidate configuration description information is matched from the configuration description information; Based on the priority information corresponding to the configuration description information, the configuration description information with the highest priority is selected from the candidate configuration description information to obtain the target configuration description information matched by the target device.

[0012] In one embodiment, the configuration content is stored in an updatable area of ​​the mirror tree file, and the device tree loading device is further configured to: In response to an update event for the configuration content, the configuration content in the updatable area is updated to obtain the updated configuration content, and based on the updated configuration content, the latest correspondence between device attributes and the configuration description information is obtained.

[0013] Furthermore, embodiments of this application also provide an electronic device, including a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of any of the device tree loading methods provided in embodiments of this application.

[0014] Furthermore, embodiments of this application also provide a computer-readable storage medium including a computer program, which, when run on an electronic device, causes the electronic device to perform the steps of any of the device tree loading methods provided in embodiments of this application.

[0015] Furthermore, embodiments of this application also provide a computer program product, including a computer program stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, causing the electronic device to perform the steps of any of the device tree loading methods provided in embodiments of this application.

[0016] This embodiment of the application, during the startup process of the target device, parses the image tree file of the target device through a bootloader to obtain multiple configuration description information, a device tree file, and updatable configuration content. The configuration content indicates the correspondence between at least one device attribute and the configuration description information. Based on the configuration content and at least one device attribute of the target device, the target configuration description information matching the target device during this startup process is determined. Based on the device tree indication information configured in the target configuration description information, the target device tree file matching the target device is determined in the device tree file. The target device tree file is loaded to identify the hardware resources of the target device. Therefore, by setting updatable configuration content in the image tree file to indicate the correspondence between device attributes and configuration description information, the target device tree file matching the target device during this startup process can be accurately and flexibly determined and loaded based on the updatable configuration content and at least one device attribute of the target device. This also facilitates adjustments to the device tree file for device adaptation in later stages, effectively improving device tree loading efficiency. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 This is a schematic diagram illustrating an implementation scenario of a device tree loading method provided in this application embodiment; Figure 2 This is a flowchart illustrating a device tree loading method provided in an embodiment of this application; Figure 3a This is a schematic diagram of a mirror tree file representing a device tree loading method provided in an embodiment of this application; Figure 3b This is a schematic diagram illustrating the specific process of a device tree loading method provided in this application embodiment; Figure 3c This is another specific flowchart illustrating a device tree loading method provided in this application embodiment; Figure 4 This is a schematic diagram of the device tree loading device provided in the embodiments of this application; Figure 5 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0019] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0020] Furthermore, in the description of the embodiments of this application, the terms "first," "second," etc., are used only for distinguishing descriptions and should not be construed as indicating or implying relative importance. Therefore, a feature specified as "first" or "second" may explicitly or implicitly include one or more features. In the description of the embodiments of this application, "multiple" means two or more, unless otherwise explicitly specified.

[0021] With the diversification of embedded device functions, multiple models and hardware configurations of the same product line often emerge. However, the existing device tree loading mechanism has the following drawbacks: 1. Lack of priority hierarchy design in matching rules: In the existing technology, there is no clear priority distinction in the correspondence between each configuration file and the device tree file. The matching process relies on a single dimension of information (such as only associating with the product serial number) for unordered matching. It is impossible to select the most suitable device tree in an orderly manner based on the accuracy of device characteristics (such as the uniqueness of individual devices, model subdivision, hardware identification, etc.). 2. Low matching accuracy: Due to the lack of priority-oriented matching logic, when there are multiple models and configuration differences of devices, the device characteristics are prone to mismatch with the device tree, which can lead to hardware resource identification errors, abnormal system startup and other adaptation failures. 3. High production and maintenance costs: To avoid the risk of mismatch, existing technologies still require the creation of multiple independent system firmware for different devices. During production, different firmware needs to be burned separately, and during maintenance, multiple firmware versions need to be managed, which significantly increases the complexity of production control and maintenance costs.

[0022] To address this, this application proposes a device tree loading method that combines updatable configuration rules and a multi-level priority matching mechanism. This method allows the same main firmware of a device to be compatible with all device versions, eliminating the need to create separate firmware for each version. Ultimately, it achieves automatic and accurate loading of the device tree, ensuring that the device correctly identifies its own hardware resources. At the same time, it facilitates the adjustment of the device tree file adapted to the device in the later stages, thereby effectively improving the device tree loading efficiency.

[0023] This application provides a device tree loading method, apparatus, electronic device, and storage medium. The device tree loading apparatus can be integrated into an electronic device, which may be a server, a terminal, or other similar device.

[0024] The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery network (CDN) acceleration services, and big data and artificial intelligence platforms. The terminal can include, but is not limited to, smart screen projection devices, mobile phones, computers, smart voice interaction devices, smart home appliances, vehicle terminals, and aircraft. The terminal and server can be directly or indirectly connected via wired or wireless communication, and this application does not impose any restrictions on this connection.

[0025] Please see Figure 1 Taking the integration of a device tree loading device into an electronic device as an example, Figure 1This is a schematic diagram illustrating an implementation scenario of the device tree loading method provided in this application. The electronic device can be a terminal. During the startup process of the target device, the electronic device can parse the target device's mirror tree file through a bootloader to obtain multiple configuration descriptions, a device tree file, and updatable configuration content. The configuration content indicates the correspondence between at least one device attribute and the configuration description information. Based on the configuration content and at least one device attribute of the target device, the target configuration description information matched by the target device during this startup process is determined. Based on the device tree indication information configured in the target configuration description information, a target device tree file matching the target device is determined in the device tree file. The target device tree file is loaded to identify the hardware resources of the target device.

[0026] It should be noted that, Figure 1 The illustrated scenario of the device tree loading method is merely an example. The implementation environment of the device tree loading method described in this application is intended to more clearly illustrate the technical solutions of this application and does not constitute a limitation on the technical solutions provided in this application. Those skilled in the art will recognize that, with the evolution of data processing and the emergence of new business scenarios, the technical solutions provided in this application are also applicable to similar technical problems.

[0027] The solutions provided in this application are specifically illustrated through the following embodiments. It should be noted that the order of description of the following embodiments is not intended to limit the preferred order of the embodiments.

[0028] This embodiment will be described from the perspective of a device tree loading device, which can be integrated into an electronic device, which can be a terminal, and this application does not limit it.

[0029] Please see Figure 2 , Figure 2 This is a flowchart illustrating the device tree loading method provided in an embodiment of this application. The device tree loading method includes: In step 101, during the startup process of the target device, the image tree file of the target device is parsed by the bootloader to obtain multiple configuration description information, device tree file and updatable configuration content.

[0030] This configuration content can be used to indicate the correspondence between at least one device attribute and configuration description information.

[0031] The target device can be the currently booting device, and the bootloader can be the program that runs first during the startup of an embedded system or operating system. It is responsible for initializing the hardware, loading the operating system kernel, and starting the system. For example, the bootloader can include a bootloader for embedded systems and some operating systems (U-Boot). The image tree file can be a file packaged in image format, which can include components such as the kernel, device tree, and configuration nodes (conf). Optionally, the image tree file can be an image packaged in a Flattened Image Tree (FIT) format (FIT Image). FIT can be a standardized firmware image format that can be used to package multiple boot components such as the kernel and device tree blob (DTB) into a single image package. The configuration description information can be metadata in a configuration node of the image tree file, located under configuration items, and is used to define the firmware and device tree that should be loaded during system startup. The device tree file can be a device tree used to describe hardware resources. This configuration content can be stored in an updatable area set in the mirror tree file, and can be used to indicate the correspondence between at least one device attribute and configuration description information. The device attribute can be a device property, such as the device serial number, main product model, sub-product model, hardware identification parameters, etc.

[0032] The hardware identification parameter can be information used to identify the hardware resources of the device during the boot loader's startup phase. For example, it can be the target voltage value (ADC value) of a specific hardware interface of the device. The ADC value can be an integer value after the analog-to-digital converter (ADC) converts the analog voltage signal into a digital quantity.

[0033] Optionally, the configuration content may store a mapping relationship between device serial numbers and corresponding configuration description information. For example, the configuration content may store multiple device serial numbers and configuration identifiers of configuration description information corresponding to each device serial number. The configuration identifier can be used to uniquely identify a configuration description information. For example, the configuration identifier can be an identifier such as conf0, conf1, conf2, etc., which can be used to indicate configuration description information 1, configuration description information 2, and configuration description information 3, etc., respectively.

[0034] For example, assuming there is a mapping relationship between device serial number 'a' and configuration description information 'b', and a mapping relationship between device serial number 'c' and configuration description information 'd', based on the mapping relationships in the configuration content, it can be determined that the device with serial number 'a' matches configuration description information 'b', and the device with serial number 'c' matches configuration description information 'd'. Thus, based on the updatable mapping relationships in the configuration content, the mapping relationship between device serial numbers and corresponding configuration description information can be updated according to business needs. This allows for accurate and convenient determination of the configuration description information matched by the target device, enabling accurate and flexible loading of the matching device tree for the target device and improving device tree loading efficiency.

[0035] Optionally, since each device corresponds to a unique device serial number, the number of device serial numbers is relatively large. In order to reduce the storage space occupied, at least one preset device serial number range and the corresponding configuration description information can be stored in the configuration content.

[0036] In one embodiment, the preset device serial number range can be a pre-defined device serial number range, which can be a range consisting of multiple consecutive device serial numbers. For example, it can be a device serial number range such as (202000, 202100], (202101, 202200], (202201, 202300], etc., where 202000 to 202300 are device serial numbers.

[0037] Optionally, the configuration content can be stored in an updatable area of ​​the mirror tree file, so that in response to an update event for the configuration content, the configuration content in the updatable area can be updated to obtain the updated configuration content, and based on the updated configuration content, the latest correspondence between device attributes and configuration description information can be obtained.

[0038] The update event can be an event that updates the configuration content.

[0039] Optionally, Over-The-Air (OTA) technology can be used to update the configuration content in the updatable area. This allows for real-time updates of the device tree file adapted to the target device based on business needs, correcting hardware differences between different batches of devices, and achieving compatibility with hardware differences between different devices. This enables differentiated adjustments to device tree resources for devices even after the product has been sold, and allows for precise adjustments down to the specific device level, achieving more accurate device tree matching and thus improving device tree loading efficiency.

[0040] In one embodiment, the configuration content can be updated along with the device's firmware version, reducing the resource costs required for updating the configuration content and improving the efficiency of the configuration content update.

[0041] In one embodiment, please refer to Figure 3a , Figure 3a This is a schematic diagram of a device tree loading method provided in this application embodiment. The image tree file may include a kernel, updatable configuration content, configuration description information, and device tree files. The image tree file may include multiple configuration description information, for example, they may be represented as conf0, conf1, conf2, and conf3 respectively. Correspondingly, the image tree file may include multiple device tree files, for example, they may be represented as dtb_a, dtb_b, dtb_c, and dtb_d respectively.

[0042] In step 102, based on the configuration content and at least one device attribute of the target device, the target configuration description information matched by the target device during this startup process is determined.

[0043] The target configuration description information can be the configuration description information that matches the target device during this startup process.

[0044] There are several ways to determine the target configuration description information to be matched by the target device during this startup process, based on the configuration content and at least one device attribute of the target device. For example, each device attribute can be configured with a corresponding priority. The device attributes of the target device can be matched with the configuration description information corresponding to the device attributes indicated in the configuration content in descending order of priority. If the device attribute of the current priority matches the corresponding configuration description information, then the configuration description information is determined as the target configuration description information to be matched by the target device during this startup process. If the device attribute of the current priority does not match the corresponding configuration description information, then the matching continues based on the device attribute of the next lower priority until the target configuration description information is matched.

[0045] Optionally, the priority of each device attribute can be flexibly configured based on the configuration content. For example, the priority of each device attribute can be determined according to actual business needs, and then the priority of each device attribute can be updated in the configuration content, so that the target device can determine the priority of each device attribute based on the configuration content.

[0046] In one embodiment, the device attributes may include at least one of the following: device serial number, product model, and hardware identification parameters. The priority of the device serial number may be greater than the priority of the product model, and the priority of the product model may be greater than the priority of the hardware identification parameters.

[0047] Optionally, the priorities corresponding to the device serial number, product model, and hardware identification parameters can be set according to the actual situation, and this embodiment of the application does not limit them.

[0048] Optionally, there are several ways to match the device attributes of the target device with the configuration description information corresponding to the device attributes indicated in the configuration content, according to the priority of the device attributes from high to low. For example, device attributes may include device serial number and other device attributes, with the device serial number having a higher priority than other device attributes. The configuration content may include a mapping relationship between the device serial number and the corresponding configuration description information. The configuration description information may include device attribute indication information, which can be used to indicate other device attributes that match the configuration description information. These other device attributes may include at least one of product model and hardware identification parameters. The target device serial number of the target device may be matched with the configuration description information corresponding to the device serial number indicated by the mapping relationship, according to the priority of the device attributes from high to low.

[0049] Correspondingly, if the current priority device attribute does not match the corresponding configuration description information, the matching continues based on the next priority device attribute until the target configuration description information is matched. This step may include: if the target device serial number does not match the corresponding configuration description information, the next priority target device attribute is determined from other device attributes, and the target configuration description information that matches the target device is determined from the configuration description information based on the target device attribute corresponding to the target device and the device attribute indication information of the configuration description information.

[0050] The target device serial number can be the device serial number of the target device, and the product model can include the main product model and the sub-product model. The priority of the main product model is lower than that of the sub-product model, and the priority of the hardware identification parameters is lower than that of the main product model.

[0051] There are several ways to match the target device serial number with the configuration description information corresponding to the device serial number indicated by the mapping relationship between the device serial number and the target device serial number, according to the priority of device attributes from high to low. For example, the matching can be performed first based on the device serial number with the highest priority, according to the priority of device attributes from high to low. Specifically, the mapping relationship stored in the configuration content can be searched for a device serial number that is the same as the target device serial number. If a device serial number that is the same as the target device serial number is found, the configuration description information corresponding to the found device serial number can be determined as the target configuration description information matched by the target device in this startup process. If a device serial number that is the same as the target device serial number is not found, then no corresponding configuration description information is matched, that is, the target configuration description information matched by the target device in this startup process is not determined in the configuration description information.

[0052] If no matching target configuration description information is found for the target device during this startup process based on the highest priority device serial number, the next lower priority product model and hardware identification parameters can be used to determine the matching target configuration description information for the target device during this startup process.

[0053] For example, the step of determining the target configuration description information that matches the target device in the configuration description information based on the target device attributes and configuration description information corresponding to the target device with the next priority can include: determining the target configuration description information that matches the target device in the configuration description information based on the target product model corresponding to the target device and the device attribute indication information in the configuration description information; if the target product model corresponding to the target device and the product model indicated in the device attribute indication information do not match, determining the target configuration description information that matches the target device in the configuration description information based on the hardware identification parameters corresponding to the target device and the device attribute indication information in the configuration description information.

[0054] The target product model can be the product model of the target device, which may include a main product model and a sub-product model. A mismatch between the target product model corresponding to the target device and the product model indicated in the device attribute information can mean that the product model indicated in the device attribute information of the configuration description is different from the target product model of the target device.

[0055] In one embodiment, if the hardware identifier parameter indicated in the device attribute indication information of the configuration description information does not match the hardware identifier parameter of the target device, the default configuration description information can be determined as the target configuration description information that matches the target device.

[0056] Since each device serial number corresponds uniquely to a device, the mapping between serial numbers and configuration descriptions allows for accurate and fine-grained identification of the target configuration description information that matches the target device. Consequently, the serial number has the highest priority. Devices belonging to the same product model share the same model number. Therefore, matching configuration descriptions based on product model will result in multiple devices of the same product model having identical configuration descriptions. Similarly, matching configuration descriptions based on hardware identifier parameters will lead to multiple devices with the same hardware identifier parameters having identical configuration descriptions. Therefore, the accuracy of device tree matching based on product model and hardware identifier parameters is lower than that based on device serial numbers, and the accuracy of device tree matching based on hardware identifier parameters is lower than that based on product model. Thus, the product model has a higher priority than the hardware identifier parameter.

[0057] Therefore, configuration description information can be matched first based on the target device's serial number. If no match is found, the configuration description information can then be matched based on the target device's product model. If no match is found based on the product model, the configuration description information can then be matched based on the target device's hardware identifier parameters. In this way, through multi-dimensional and multi-level matching rules, the target configuration description information can be matched flexibly and accurately. Based on the matched target configuration description information, the device tree file matching the target device can be quickly selected, thereby improving device tree loading efficiency.

[0058] Optionally, there are multiple ways to determine the target configuration description information that matches the target device in the configuration description information based on the target product model and the device attribute indication information of the configuration description information corresponding to the target device. For example, the product model may include a main product model and a sub-product model. The target configuration description information that matches the target device can be determined in the configuration description information based on the target product sub-model and the device attribute indication information of the configuration description information. If the target product sub-model and the product sub-model indicated in the device attribute indication information do not match, the target configuration description information that matches the target device can be determined in the configuration description information based on the target product main model and the device attribute indication information of the configuration description information corresponding to the target device.

[0059] Since the number of devices for the same product sub-model is less than the number of devices for the same product main model, the product sub-model has a higher priority than the product main model.

[0060] Optionally, based on the mapping relationship between the device serial number and the corresponding configuration description information, there are multiple ways to match the target device serial number of the target device with the configuration description information corresponding to the device serial number indicated by the mapping relationship. For example, the configuration content may include at least one preset device serial number range and corresponding configuration description information mapping relationship. Each configuration description information is configured with corresponding priority information. The first configuration description information with the highest priority can be determined. Based on the mapping relationship, the target serial number range that matches the first configuration description information is determined in the preset device serial number range. If the target device serial number corresponding to the target device is found in the target serial number range, the first configuration description information is determined as the target configuration description information corresponding to the target device.

[0061] The preset device serial number range can be a pre-defined device serial number range. The priority information can be information indicating the priority of each configuration description information. The priority of each configuration description information can be set by relevant technical personnel according to business needs or the specific hardware configuration requirements of the device; this embodiment does not limit this. The first configuration description information can be the configuration description information with the highest priority among the configuration description information. The target serial number range can be the preset device serial number range corresponding to the first configuration description information.

[0062] Optionally, if the target device serial number corresponding to the target device is not found in the target serial number range, the target configuration description information that matches the target device can continue to be searched based on the product model and hardware identification parameters of the target device in turn, so as to improve the matching flexibility and loading efficiency of the device tree.

[0063] In one embodiment, there are multiple ways to match the device attributes of the target device with the configuration description information corresponding to the device attributes indicated in the configuration content. For example, the device attributes may include a device serial number, which has the highest priority. The configuration content includes at least one preset device serial number range and a mapping relationship between the corresponding configuration description information. Each configuration description information is configured with a corresponding priority. In this way, the first configuration description information with the highest priority can be determined. Based on the mapping relationship, a target serial number range that matches the first configuration description information is determined in the preset device serial number range. If the target device serial number corresponding to the target device is found in the target serial number range, the first configuration description information is determined to be the configuration description information corresponding to the target device serial number.

[0064] Therefore, the configuration description messages can be matched first based on the highest priority first configuration description message and the highest priority device serial number. The target device serial number corresponding to the target device can be found in the target serial number range. When the target device serial number corresponding to the target device is found, the first configuration description information can be determined as the target configuration description information that matches the target device, thereby realizing fast matching of the configuration description information corresponding to the target device.

[0065] Optionally, based on the configuration content and at least one device attribute of the target device, there are several other ways to determine the target configuration description information matched by the target device during this startup process. For example, the configuration content may include a mapping relationship between the device serial number and the corresponding configuration description information. The configuration description information may be configured with priority information and device attribute indication information. The device attribute indication information can be used to indicate the device attribute that matches the configuration description information. The device attribute may include at least one of the device serial number, product model, and hardware identification parameters. In this way, based on multiple device attributes of the target device, device attribute indication information, and mapping relationships, at least one candidate configuration description information can be matched in the configuration description information. Based on the priority information corresponding to the configuration description information, the configuration description information with the highest priority can be filtered from the candidate configuration description information to obtain the target configuration description information matched by the target device.

[0066] The candidate configuration description information can be configuration description information obtained by matching multiple device attributes of the target device.

[0067] There are several ways to match at least one candidate configuration description information in the configuration description information based on multiple device attributes, device attribute indication information, and mapping relationships of the target device. For example, the candidate configuration description information matching the target device serial number can be determined in the configuration description information based on the target device serial number and mapping relationship; the candidate configuration description information matching the target device product model can be determined in the configuration description information based on the target device product model and device attribute indication information of each configuration description information; and the candidate configuration description information matching the target device hardware identification parameters can be determined in the configuration description information based on the target device hardware identification parameters and device attribute indication information of each configuration description information. Thus, at least one candidate configuration description information can be obtained.

[0068] Therefore, by using multi-dimensional and multi-level configuration description information matching rules, the target configuration description information can be matched flexibly and accurately. Based on the matched target configuration description information, the device tree file matching the target device can be selected quickly, thereby improving the device tree loading efficiency.

[0069] In step 103, based on the device tree indication information configured in the target configuration description information, a target device tree file matching the target device is determined in the device tree file.

[0070] The device tree indication information can be the device tree information corresponding to the configuration description information. The target device tree file can be the device tree file that matches the target device. A device tree is a data structure that describes hardware topology and configuration. It can be used to pass information such as register addresses, interrupt numbers, clocks, and pin multiplexing of the central processing unit (CPU), memory, and peripherals (such as UART, I2C, GPIO, etc.) to the operating system kernel in a tree format, so that the kernel can adapt to different board types without hardcoding.

[0071] There are several ways to determine the target device tree file that matches the target device based on the device tree indication information configured in the target configuration description information. For example, the device tree file corresponding to the target configuration description information can be determined based on the device tree indication information configured in the target configuration description information, and the device tree file corresponding to the target configuration description information can be determined as the target device tree file that matches the target device.

[0072] In one embodiment, please refer to Figure 3b , Figure 3b This is a schematic diagram of a specific process of a device tree loading method provided in an embodiment of this application. It is assumed that multiple configuration description information and multiple device tree files are obtained by parsing the image tree file. The multiple configuration description information can be represented as conf0, conf1, conf2, conf3, conf4, conf5, and conf6, respectively, and the multiple device tree files can be represented as dtb_a, dtb_b, dtb_c, dtb_d, dtb_e, dtb_f, and dtb_g, respectively.

[0073] Conf0 includes device attribute indication information, priority information, and device tree indication information. The device attribute indication information includes the serial number indication information "match series_no", which indicates that a serial number matching rule is configured, meaning that a mapping relationship exists between the configuration description information conf0 and the configuration content. The priority information "prior=4" indicates that conf0 has a priority of 4; the higher the value, the higher the priority. The device tree indication information "dtb_c" indicates that the device tree file corresponding to conf0 is dtb_c. Conf1 also includes device attribute indication information, priority information, and device tree indication information. The device attribute indication information includes the product sub-model indication information "match dev_sub_type=type_a1", which indicates that the product sub-model matched by the configuration description information conf1 is "type_a1". The priority information "prior=3" indicates that conf1 has a priority of 3. The device tree indication information "dtb_b" indicates that the device tree file corresponding to conf1 is dtb_b.

[0074] Conf2 includes device attribute indication information, priority information, and device tree indication information. The device attribute indication information includes the product sub-model indication information "match dev_sub_type=type_a2", which indicates that the product sub-model matched by configuration description information conf2 is "type_a1". The priority information "prior=3" indicates that the priority of conf2 is 3. The device tree indication information "dtb_e" indicates that the device tree file corresponding to conf2 is dtb_e. Conf3 includes device attribute indication information, priority information, and device tree indication information. The device attribute indication information includes the product main model indication information "match dev_main_type=product_a", which indicates that the product main model matched by configuration description information conf3 is "product_a". The priority information "prior=2" indicates that the priority of conf3 is 2. The device tree indication information "dtb_a" indicates that the device tree file corresponding to conf3 is dtb_a. Conf4 includes device attribute indication information, priority information, and device tree indication information. The device attribute indication information includes the product main model indication information "match dev_main_type=product_b", which can be used to indicate that the product main model matched by the configuration description information conf4 is "product_b". The priority information "prior=2" indicates that the priority of conf4 is 2. The device tree indication information "dtb_g" can be used to indicate that the device tree file corresponding to conf4 is dtb_g.

[0075] Conf5 includes device attribute indication information, priority information, and device tree indication information. The device attribute indication information includes the hardware identifier indication information "match hw_adc=100", which indicates that the ADC value matched by the configuration description information conf5 is "100". The priority information "prior=1" indicates that the priority of conf5 is 1. The device tree indication information "dtb_d" indicates that the device tree file corresponding to conf5 is dtb_d. Conf6 includes device attribute indication information, priority information, and device tree indication information. The device attribute indication information includes the hardware identifier indication information "match hw_adc=200", which indicates that the ADC value matched by the configuration description information conf6 is "200". The priority information "prior=1" indicates that the priority of conf6 is 1. The device tree indication information "dtb_f" indicates that the device tree file corresponding to conf6 is dtb_f.

[0076] In one embodiment, it can be first determined whether a highest priority matching rule exists. For example, if a rule for series_no is defined in conf0 and conf0 has the highest priority, conf0 can be determined as the first configuration description information. Then, based on the mapping relationship in the configuration content and conf0, the corresponding target serial number range can be matched. Then, it can be searched in the target serial number range to see if the target device serial number of the target device can be matched. If a device serial number with the same target device serial number as the target device is matched, conf0 can be selected first as the target configuration description information matched with the target device. If the target configuration description information cannot be matched by the highest priority matching rule, the next level of rules can be checked, and the product main model, product sub-model, etc. can be matched in sequence. If no matching target configuration description information is found based on the product main model or product sub-model, the lowest priority matching method can be used to match the target configuration description information. For example, when the ADC value of the target device is detected to be 100, conf5 can be determined as the target configuration description information, and the dtb_d corresponding to conf5 can be selected as the device tree loading target, thereby loading the matching target device tree file for the target device. Therefore, through the multi-level and multi-rule matching mechanism described above, the embodiments of this application can achieve flexible and refined control of device tree loading, and can simultaneously meet the needs of different batches and different configurations of devices for differentiated startup configurations, effectively improving device tree loading efficiency.

[0077] In step 104, the target device tree file is loaded to identify the hardware resources of the target device.

[0078] Therefore, based on the multiple configuration descriptions in the image tree file and multiple device tree files, as well as the mapping relationships stored in the updatable configuration content, it is possible to adapt the device tree loading requirements of multiple devices to a single image tree file, thereby improving the device tree loading efficiency.

[0079] In one embodiment, please refer to Figure 3c , Figure 3c This is another specific flowchart illustrating a device tree loading method provided in this application embodiment. During the boot process of the target device, the bootloader (U-boot) parses the target device's image tree file (FIT Image), thereby extracting multiple configuration description information files, conf0-conf7, from the parsed image tree file. Assuming that conf0-conf7 are arranged in descending order of priority, conf0 is first matched according to the priority information corresponding to the configuration description information, device attribute indication information, and the mapping relationship of the configuration content. When conf0 matches the target device, the device tree file corresponding to conf0 can be determined as the target device tree file based on the device tree indication information corresponding to conf0, and the device tree file and kernel are loaded. If conf0 does not match the target device, the matching of the next priority configuration description information conf1 can continue until a configuration description information matching the target device is found. If no matching target configuration description information is found in conf0-conf7, the default configuration description information can be used as the target configuration description information. Then, based on the device tree indication information corresponding to the default configuration description information, the target device tree file is determined, and the device tree file and kernel are loaded. This allows the operating system to identify and manage the hardware resources of the target device, enabling the target device to run correctly and efficiently.

[0080] In some device tree loading methods, the loading and selection of the device tree are typically based on hardware circuit characteristics or preset software configuration strategies. For example, different device models or versions are distinguished by peripheral circuits (such as ADC voltage, GPIO status, DIP switches, etc.), thereby selecting the corresponding device tree file. Alternatively, the product model is read by software, and the required device tree is determined during the startup phase. However, device tree loading methods that rely on peripheral hardware circuit identification lack flexibility. Once the device is manufactured, it cannot be modified. When the differences between device batches and hardware versions are small, hardware resources are limited and expansion is not conducive, making it unable to cope with the differences between different batches that are subsequently exposed. On the other hand, device tree loading methods that read the software model lack convenience, and the software configuration has low security and is easily tampered with. When the software model is mismatched, it can easily cause hardware problems. In addition, these methods usually distinguish device trees on the basis of the overall device model, lacking a fine-grained matching mechanism, and cannot perform more refined device tree matching for individual differences within the same device (such as hardware differences between different batches that require later hardware correction).

[0081] To address this, this application's embodiments utilize a multi-dimensional, multi-priority, multi-rule matching approach to achieve flexible selection and efficient loading of device trees. This dynamically adapts to batch differences after production, with matching granularity traceable to specific batches and devices, thus meeting the differentiated configuration needs of complex hardware systems. Specifically, devices can establish different priorities based on rules such as hardware ADC values, product main model, product sub-model, and device serial number. Through multi-dimensional matching, the optimal device tree file is flexibly selected. Even after a product is sold, OTA upgrades can still be used to differentiate device tree resources, with matching granularity precise to specific devices. Simultaneously, this effectively reduces the number of device trees, lowering storage space overhead associated with multiple device trees. Furthermore, OTA upgrades enable compatibility across different devices when urgent differences need to be corrected after product sale, facilitating continuous optimization of the device products.

[0082] As described above, this embodiment of the application, during the startup process of the target device, parses the image tree file of the target device through a bootloader to obtain multiple configuration description information, a device tree file, and updatable configuration content. The configuration content indicates the correspondence between at least one device attribute and the configuration description information. Based on the configuration content and at least one device attribute of the target device, the target configuration description information matched by the target device during this startup process is determined. Based on the device tree indication information configured in the target configuration description information, the target device tree file matching the target device is determined in the device tree file. The target device tree file is loaded to identify the hardware resources of the target device. Therefore, by setting updatable configuration content in the image tree file to indicate the correspondence between device attributes and configuration description information, the target device tree file matching the target device during this startup process can be accurately and flexibly determined and loaded based on the updatable configuration content and at least one device attribute of the target device. This also facilitates adjustments to the device tree file for device adaptation in later stages, effectively improving device tree loading efficiency.

[0083] To better implement the above methods, embodiments of the present invention also provide a device tree loading device, which can be integrated into an electronic device, which can be a terminal.

[0084] For example, such as Figure 4 The diagram shown is a structural schematic of the device tree loading device provided in an embodiment of this application. The device tree loading device may include a parsing unit 201, a first determining unit 202, a second determining unit 203, and a loading unit 204, as follows: The parsing unit 201 is used to parse the image tree file of the target device through the bootloader during the startup process of the target device to obtain multiple configuration description information, device tree file and updatable configuration content. The configuration content is used to indicate the correspondence between at least one device attribute and the configuration description information. The first determining unit 202 is used to determine the target configuration description information matched by the target device during this startup process based on the configuration content and at least one device attribute of the target device. The second determining unit 203 is used to determine, based on the device tree indication information configured in the target configuration description information, a target device tree file that matches the target device in the device tree file. Loading unit 204 is used to load the target device tree file to identify the hardware resources of the target device.

[0085] In one embodiment, each device attribute is configured with a corresponding priority, and the first determining unit 202 is used to: According to the priority of device attributes from high to low, the device attributes of the target device are matched with the configuration description information corresponding to the device attributes indicated in the configuration content. If the device attribute of the current priority matches the corresponding configuration description information, then the configuration description information will be determined as the target configuration description information matched by the target device during this startup process; If the current priority device attribute does not match the corresponding configuration description information, the matching will continue based on the next lower priority device attribute until the target configuration description information is matched.

[0086] In one embodiment, the device attributes include at least one of the following: device serial number, product model, and hardware identification parameters, wherein the priority of the device serial number is greater than the priority of the product model, and the priority of the product model is greater than the priority of the hardware identification parameters.

[0087] In one embodiment, the device attributes include a device serial number and other device attributes, with the device serial number having a higher priority than the other device attributes. The configuration content includes a mapping relationship between the device serial number and the corresponding configuration description information. The configuration description information includes device attribute indication information, which is used to indicate other device attributes that match the configuration description information. The other device attributes include at least one of product model and hardware identification parameters. The above process, following the order of priority of device attributes from highest to lowest, matches the device attributes of the target device with the configuration description information corresponding to the device attributes indicated in the configuration content. Specifically, this is used for: Based on the priority of device attributes from high to low, and the mapping relationship between device serial numbers and corresponding configuration description information, the target device serial number of the target device is matched with the configuration description information corresponding to the device serial number indicated by the mapping relationship. If the current priority device attribute does not match the corresponding configuration description information, the matching continues based on the next lower priority device attribute until the target configuration description information is matched. Specifically, this is used for: If the target device serial number does not match the corresponding configuration description information, the next priority target device attribute is determined from other device attributes. Based on the target device attribute corresponding to the target device and the device attribute indication information of the configuration description information, the target configuration description information that matches the target device is determined from the configuration description information.

[0088] In one embodiment, the device attributes include a device serial number, which has the highest priority. The configuration content includes at least one preset mapping relationship between a device serial number range and the corresponding configuration description information. Each configuration description information is configured with corresponding priority information. The above-mentioned matching of the device attributes of the target device with the configuration description information corresponding to the device attributes indicated in the configuration content is specifically used for: Determine the highest priority configuration description information among the configuration description information; Based on the mapping relationship, a target serial number range that matches the first configuration description information is determined from the preset device serial number range; If the target device serial number corresponding to the target device is found in the target serial number range, the first configuration description information is determined to be the configuration description information corresponding to the target device serial number.

[0089] In one embodiment, the configuration content includes a mapping relationship between device serial numbers and corresponding configuration description information. The configuration description information includes priority information and device attribute indication information. The device attribute indication information is used to indicate device attributes that match the configuration description information. The device attributes include at least one of device serial number, product model, and hardware identification parameters. The first determining unit 202 is used to: Based on multiple device attributes, device attribute indication information and mapping relationships of the target device, at least one candidate configuration description information is matched from the configuration description information; Based on the priority information corresponding to the configuration description information, the configuration description information with the highest priority is selected from the candidate configuration description information to obtain the target configuration description information that matches the target device.

[0090] In one embodiment, the configuration content is stored in an updatable area of ​​the mirror tree file, and the device tree loading device is further configured to: In response to an update event for configuration content, the configuration content in the updatable area is updated to obtain the updated configuration content. Based on the updated configuration content, the latest correspondence between device attributes and configuration description information is obtained.

[0091] As described above, in this embodiment, the parsing unit 201 parses the target device's image tree file during the target device's startup process using a bootloader to obtain multiple configuration description information, a device tree file, and updatable configuration content. The configuration content indicates the correspondence between at least one device attribute and the configuration description information. The first determining unit 202, based on the configuration content and at least one device attribute of the target device, determines the target configuration description information matched by the target device during this startup process. The second determining unit 203, based on the device tree indication information configured in the target configuration description information, determines the target device tree file matching the target device within the device tree file. The loading unit 204 loads the target device tree file to identify the target device's hardware resources. Therefore, by setting updatable configuration content in the image tree file to indicate the correspondence between device attributes and configuration description information, the target device tree file matching the target device during this startup process can be accurately and flexibly determined and loaded based on the updatable configuration content and at least one device attribute of the target device. This also facilitates adjustments to the device tree file for device adaptation in later stages, effectively improving device tree loading efficiency.

[0092] Accordingly, this application also provides an electronic device, which can be a terminal, such as a smartphone, tablet computer, laptop computer, touch screen, game console, personal computer (PC), personal digital assistant (PDA), or other terminal device. Alternatively, the electronic device can be a server.

[0093] like Figure 5 As shown, Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device 300 includes a processor 301 with one or more processing cores, a memory 302 with one or more computer-readable storage media, and a computer program stored in the memory 302 and executable on the processor. The processor 301 and the memory 302 are electrically connected. Those skilled in the art will understand that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0094] The processor 301 is the control center of the electronic device 300. It connects various parts of the electronic device 300 through various interfaces and lines. By running or loading software programs and / or units stored in the memory 302, and calling data stored in the memory 302, it executes various functions of the electronic device 300 and processes data. The processor 301 may be a CPU, GPU, network processor (NP), etc., and can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application.

[0095] In this embodiment, the processor 301 in the electronic device 300 loads the instructions corresponding to the processes of one or more applications into the memory 302 according to the following steps, and the processor 301 runs the applications stored in the memory 302 to realize various functions, such as: During the startup process of the target device, the bootloader parses the target device's image tree file to obtain multiple configuration description information, a device tree file, and updatable configuration content. The configuration content indicates the correspondence between at least one device attribute and the configuration description information. Based on the configuration content and at least one device attribute of the target device, the target configuration description information matched by the target device during this startup process is determined. Based on the device tree indication information configured in the target configuration description information, the target device tree file matching the target device is determined in the device tree file. The target device tree file is loaded to identify the hardware resources of the target device.

[0096] This solution parses the target device's image tree file during the target device's startup process using a bootloader. This yields multiple configuration descriptions, a device tree file, and updatable configuration content. The configuration content indicates the correspondence between at least one device attribute and the configuration description. Based on this configuration content and at least one device attribute of the target device, the solution determines the target configuration description information that matches the target device during this startup process. Based on the device tree indication information configured in the target configuration description, the solution identifies the target device tree file matching the target device within the device tree file. Finally, the solution loads the target device tree file to identify the target device's hardware resources. By setting updatable configuration content in the image tree file to indicate the correspondence between device attributes and configuration descriptions, the solution can accurately and flexibly determine and load the target device tree file matching the target device during this startup process, based on the updatable configuration content and at least one device attribute of the target device. This also facilitates adjustments to the device tree file for device adaptation in later stages, effectively improving device tree loading efficiency.

[0097] Furthermore, the various functions implemented by running the application stored in memory 302 can also be found in the description of the foregoing embodiments, and will not be repeated here.

[0098] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0099] Optional, such as Figure 5 As shown, the electronic device 300 also includes: a touch display screen 303, a radio frequency circuit 304, an audio circuit 305, an input unit 306, and a power supply 307. The processor 301 is electrically connected to the touch display screen 303, the radio frequency circuit 304, the audio circuit 305, the input unit 306, and the power supply 307. Those skilled in the art will understand that... Figure 5 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0100] The touch display screen 303 can be used to display a graphical user interface (GUI) and receive operation commands generated by the user interacting with the GUI. The touch display screen 303 may include a display panel and a touch panel. The display panel can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces of the electronic device. These graphical user interfaces can be composed of graphics, text, icons, video, and any combination thereof. Optionally, the display panel can be configured using a liquid crystal display (LCD), organic light-emitting diode (OLED), or other similar technologies. The touch panel can be used to collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near the touch panel), generate corresponding operation commands, and execute the corresponding program according to the operation commands. Optionally, the touch panel may include two parts: a touch detection device and a touch controller. The touch detection device detects the user's touch location and the signal generated by the touch operation, transmitting the signal to the touch controller. The touch controller receives touch information from the touch detection device, converts it into touch point coordinates, and sends it to the processor 301. It can also receive and execute commands from the processor 301. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it transmits the information to the processor 301 to determine the type of touch event. Subsequently, the processor 301 provides corresponding visual output on the display panel based on the type of touch event. In this embodiment, the touch panel and the display panel can be integrated into the touch display screen 303 to achieve input and output functions. However, in some embodiments, the touch panel and the touch display screen 303 can be implemented as two independent components to achieve input and output functions. That is, the touch display screen 303 can also be used as part of the input unit 306 to achieve input functions.

[0101] The radio frequency circuit 304 can be used to transmit and receive radio frequency signals to establish wireless communication with network devices or other electronic devices, and to transmit and receive signals with network devices or other electronic devices.

[0102] Audio circuitry 305 can be used to provide an audio interface between a user and an electronic device via a speaker and a microphone. Audio circuitry 305 converts received audio data into electrical signals, transmits them to the speaker, and the speaker converts them into sound signals for output. Conversely, the microphone converts collected sound signals into electrical signals, which are then received by audio circuitry 305, converted back into audio data, and then processed by processor 301 before being transmitted via radio frequency circuitry 304 to, for example, another electronic device, or output to memory 302 for further processing. Audio circuitry 305 may also include an earphone jack to facilitate communication between peripheral headphones and electronic devices.

[0103] The input unit 306 can be used to receive input target video and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.

[0104] Power supply 307 is used to supply power to various components of electronic device 300. Optionally, power supply 307 can be logically connected to processor 301 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. Power supply 307 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0105] although Figure 5 As not shown in the diagram, the electronic device 300 may also include a camera, sensor, wireless fidelity module, Bluetooth module, etc., which will not be described in detail here.

[0106] In the above embodiments, the descriptions of each embodiment have different focuses. Parts not described in detail in a particular embodiment can be found in the relevant descriptions of other embodiments. It should be noted that the electronic device provided in this application embodiment and the device tree loading method described in the above embodiments belong to the same concept, and its specific implementation process is detailed in the above method embodiments, and will not be repeated here.

[0107] As can be seen from the above, the electronic device provided in this application embodiment can, during the startup process of the target device, parse the image tree file of the target device through a bootloader to obtain multiple configuration description information, a device tree file, and updatable configuration content. The configuration content is used to indicate the correspondence between at least one device attribute and the configuration description information. Based on the configuration content and at least one device attribute of the target device, the target configuration description information matched by the target device during this startup process is determined. Based on the device tree indication information configured in the target configuration description information, the target device tree file matching the target device is determined in the device tree file. The target device tree file is loaded to identify the hardware resources of the target device. Thus, by setting updatable configuration content in the image tree file to indicate the correspondence between device attributes and configuration description information, the target device tree file matching the target device during this startup process can be accurately and flexibly determined and loaded based on the updatable configuration content and at least one device attribute of the target device. This also facilitates adjustments to the device tree file for device adaptation in later stages, effectively improving device tree loading efficiency.

[0108] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.

[0109] Therefore, embodiments of this application provide a computer-readable storage medium, including a computer program that, when run on an electronic device, causes the electronic device to execute any of the device tree loading methods provided in embodiments of this application. For example, the computer program can execute the steps of the following device tree loading method: During the startup process of the target device, the bootloader parses the target device's image tree file to obtain multiple configuration description information, a device tree file, and updatable configuration content. The configuration content indicates the correspondence between at least one device attribute and the configuration description information. Based on the configuration content and at least one device attribute of the target device, the target configuration description information matched by the target device during this startup process is determined. Based on the device tree indication information configured in the target configuration description information, the target device tree file matching the target device is determined in the device tree file. The target device tree file is loaded to identify the hardware resources of the target device.

[0110] This solution parses the target device's image tree file during the target device's startup process using a bootloader. This yields multiple configuration descriptions, a device tree file, and updatable configuration content. The configuration content indicates the correspondence between at least one device attribute and the configuration description. Based on this configuration content and at least one device attribute of the target device, the solution determines the target configuration description information that matches the target device during this startup process. Based on the device tree indication information configured in the target configuration description, the solution identifies the target device tree file matching the target device within the device tree file. Finally, the solution loads the target device tree file to identify the target device's hardware resources. By setting updatable configuration content in the image tree file to indicate the correspondence between device attributes and configuration descriptions, the solution can accurately and flexibly determine and load the target device tree file matching the target device during this startup process, based on the updatable configuration content and at least one device attribute of the target device. This also facilitates adjustments to the device tree file for device adaptation in later stages, effectively improving device tree loading efficiency.

[0111] Furthermore, the detailed steps of the above method can be found in the description of the foregoing embodiments, and will not be repeated here.

[0112] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0113] The computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0114] Since the computer program stored in the computer-readable storage medium can execute any of the device tree loading methods provided in the embodiments of this application, the beneficial effects that any of the device tree loading methods provided in the embodiments of this application can achieve can be realized. For details, please refer to the previous embodiments, which will not be repeated here.

[0115] According to one aspect of this application, a computer program product is also provided, comprising a computer program stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, causing the electronic device to perform the methods provided in various optional implementations of the above embodiments.

[0116] In the above embodiments of the device tree loading device, computer-readable storage medium, electronic device, and computer program product, the descriptions of each embodiment have different focuses. Parts not described in detail in a particular embodiment can be referred to in the relevant descriptions of other embodiments. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process and beneficial effects of the device tree loading device, computer-readable storage medium, computer program product, electronic device, and their corresponding units described above can be referred to the description of the device tree loading method in the above embodiments, and will not be repeated here.

[0117] The foregoing has provided a detailed description of a device tree loading method, apparatus, electronic device, computer-readable storage medium, and computer program product provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A device tree loading method, characterized by, The application relates to a booting method for a target device. In a booting process of a target device, a mirror tree file of the target device is parsed by a boot loader to obtain a plurality of configuration description information, a device tree file and updatable configuration content, the configuration content being used for indicating a correspondence between at least one device attribute and the configuration description information; Based on the configuration content and at least one device attribute of the target device, target configuration description information matched by the target device in the current booting process is determined; Based on device tree indication information configured in the target configuration description information, target device tree file matched by the target device is determined in the device tree file; The target device tree file is loaded to identify hardware resources of the target device. 2.The device tree loading method of claim 1, wherein, Each device attribute is configured with a corresponding priority, and the target configuration description information matched by the target device in the current booting process is determined based on the configuration content and at least one device attribute of the target device, comprising: In a descending order of the priorities of the device attributes, the device attributes of the target device are sequentially matched with the configuration description information corresponding to the device attributes indicated in the configuration content; If the device attribute of the current priority is matched with the corresponding configuration description information, the configuration description information is determined as the target configuration description information matched by the target device in the current booting process; If the device attribute of the current priority is not matched with the corresponding configuration description information, the matching is continued based on the device attribute of the next priority until the target configuration description information is matched. 3.The device tree loading method of claim 2, wherein, The device attributes include at least one of a device serial number, a product model and a hardware identification parameter, wherein the priority corresponding to the device serial number is higher than the priority corresponding to the product model, and the priority corresponding to the product model is higher than the priority corresponding to the hardware identification parameter. 4.The device tree loading method of claim 2, wherein, The device attributes include a device serial number and other device attributes, the priority of the device serial number is higher than the priority of the other device attributes, the configuration content includes a mapping relationship between the device serial number and the corresponding configuration description information, the configuration description information includes device attribute indication information, the device attribute indication information is used for indicating the other device attributes matched with the configuration description information, and the other device attributes include at least one of a product model and a hardware identification parameter. In a descending order of the priorities of the device attributes, the target device serial number of the target device is matched with the configuration description information corresponding to the device serial number indicated by the mapping relationship based on the mapping relationship between the device serial number and the corresponding configuration description information; If the device attribute of the current priority is not matched with the corresponding configuration description information, the matching is continued based on the device attribute of the next priority until the target configuration description information is matched. ​ If the target device serial number does not match the corresponding configuration description information, a next priority target device attribute is determined from the other device attributes, and based on the target device attribute corresponding to the target device and the device attribute indication information of the configuration description information, target configuration description information matching the target device is determined in the configuration description information. 5.The device tree loading method of claim 2, wherein, The device attribute includes a device serial number, the device serial number has the highest priority, the configuration content includes a mapping relationship between at least one preset device serial number interval and corresponding configuration description information, each configuration description information is configured with a corresponding priority, and the device attribute of the target device is matched with the configuration description information corresponding to the device attribute indicated in the configuration content, including: determining a first configuration description information with the highest priority in the configuration description information; based on the mapping relationship, determining a target serial number interval matching the first configuration description information in the preset device serial number interval; if the target device serial number corresponding to the target device is found in the target serial number interval, the first configuration description information is determined as the configuration description information corresponding to the target device serial number. 6.The device tree loading method of claim 1, wherein, The configuration content includes a mapping relationship between a device serial number and corresponding configuration description information, the configuration description information is configured with priority information and device attribute indication information, the device attribute indication information is used to indicate a device attribute matching the configuration description information, the device attribute includes at least one of a device serial number, a product model and a hardware identification parameter, and the target configuration description information matched by the target device in the current startup process is determined based on the configuration content and at least one device attribute of the target device, including: based on the multiple device attributes of the target device, the device attribute indication information and the mapping relationship, at least one candidate configuration description information is matched in the configuration description information; based on the priority information corresponding to the configuration description information, a configuration description information with the highest priority is screened out from the candidate configuration description information, and the target configuration description information matched by the target device is obtained.

7. The device tree loading method according to any one of claims 1 to 6, wherein, The configuration content is stored in an updatable area in the image tree file, and the method further includes: in response to an update event for the configuration content, updating the configuration content in the updatable area to obtain updated configuration content, and obtaining the latest correspondence between device attributes and the configuration description information based on the updated configuration content.

8. A device tree loading apparatus, comprising: including: an analysis unit, configured to analyze, in a startup process of a target device, an image tree file of the target device through a bootloader to obtain multiple configuration description information, a device tree file and updatable configuration content, the configuration content being used to indicate a correspondence between at least one device attribute and the configuration description information; a first determination unit, configured to determine, based on the configuration content and at least one device attribute of the target device, target configuration description information matched by the target device in the current startup process; A second determining unit, configured to determine a target device tree file matched with the target device in the device tree file based on device tree indication information configured in the target configuration description information; A loading unit, configured to load the target device tree file to identify hardware resources of the target device.

9. An electronic device, comprising: An electronic device, comprising a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the computer program causes the processor to perform the steps of the device tree loading method in any one of claims 1 to 7.

10. A storage medium, characterized by An electronic device, comprising a computer program, and when the computer program is executed on the electronic device, the computer program is used to cause the electronic device to perform the steps of the device tree loading method in any one of claims 1 to 7.