A configuration-driven device tree automatic generation and image building tool
By adopting a configuration-driven approach, employing a web-based visual interface and a dynamic placeholder replacement algorithm, the device tree is automatically generated and the image is compiled. This solves the problems of complex device tree operations and poor portability in ARM architecture embedded development, and achieves efficient and reliable automatic compilation and image generation of device trees.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HENAN THINKER TRACK TRAFFIC TECH RES INST
- Filing Date
- 2026-02-03
- Publication Date
- 2026-05-29
AI Technical Summary
In ARM architecture embedded development, existing technologies require manual editing of device tree files, which is complex, error-prone, and the device tree structure varies greatly between different development boards, resulting in poor portability and reusability, low development efficiency, lack of graphical configuration capabilities and flexible scalability, and fragmented image building, making it impossible to form an integrated automated build loop.
The system adopts a configuration-driven approach, allowing users to select hardware platforms and components through a web-based visual interface. It utilizes device tree template files, node definition files, and component definition files, combined with a placeholder dynamic replacement algorithm, to automatically generate device trees and compile images. The system includes a web-based visual configuration module, a board-level data management module, a compilation and image generation module, and a custom extension module, supporting graphical configuration and automated building.
It lowers the development threshold, improves development efficiency and reliability, supports integrated automatic compilation and image generation of device trees, enhances reusability and scalability, reduces human error, and enables concurrent use by multiple users.
Smart Images

Figure CN122111454A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer technology, specifically relating to a method and system for automatic generation and image construction of a configuration-driven device tree. Background Technology
[0002] In ARM architecture embedded development, developers need to modify the operating system's Device Tree (DTS) file and regenerate the image based on different hardware platforms, chip models, and peripheral combinations.
[0003] In the traditional approach, device tree files need to be edited manually. Each modification requires manually locating nodes, updating attributes, and recompiling, which is complex, error-prone, and the device tree structure varies greatly between different development boards, resulting in poor portability and reusability and low development efficiency.
[0004] Existing publicly available solutions are mostly implemented using command-line scripts or template files, such as using Makefile + DTS template combined with sed / awk to replace placeholders; or using Python scripts to parse XML / JSON configurations to generate DTS. However, these solutions all require developers to understand device tree syntax and compilation logic, lack graphical configuration capabilities, and cannot flexibly extend configurations for different board levels and components, resulting in the following drawbacks: 1. Complex operation and high threshold: It requires manual editing or command line configuration of DTS files, which is not user-friendly for non-kernel developers; 2. Prone to errors and difficult to debug: The node hierarchy is complex, placeholder replacement is not intuitive, and error location is difficult; 3. Lack of scalability: Differences between different boards make it difficult to reuse templates, and scripts or templates need to be rewritten for each new hardware platform; 4. Dispersed image building: Device tree modification and image packaging processes are independent, making it impossible to form an integrated automated build loop. Summary of the Invention
[0005] To address the aforementioned technical problems, this invention provides a method and system for automatic generation of device trees and image construction based on configuration-driven approaches.
[0006] The specific plan is as follows: The method for automatic generation of device trees and image building based on configuration-driven approach includes the following steps: S1): User selects target board level: The target hardware platform is configured and selected through a web-based visual interface. The configuration selection includes the board level platform and at least one hardware component. S2): Read the board-level configuration file selected by the user: Based on the selected board-level platform, obtain the corresponding board-level configuration file from the board-level data management module. The board-level configuration file includes a device tree template file, a node definition file, and a component definition file. S3): Create a new baseboard device tree and parse nodes: Create a new baseboard device tree using the device tree template file as a template. The node definition file defines the structural hierarchy and placeholder identifiers of the device tree. The node definition file determines the mounting position of the hardware components selected by the user in the device tree. S4): Parse the component definition file to obtain the component definition and configurable nodes: Obtain the device tree code snippet corresponding to the hardware component selected by the user based on the component definition file; S5): Configure the component: Execute the placeholder dynamic replacement algorithm to replace the placeholders in the device tree template file with the corresponding device tree code snippets, and generate a complete device tree source file; S6): Compile device tree source file: Call the compiler to compile the device tree source file into a device tree binary file, and package the device tree binary file into the system image file; S7): Image file download: Provide the generated system image file to the user for download.
[0007] The device tree template file is a base template containing placeholders for all configurable nodes, and the device tree template file is in DTS format. The node definition file defines the node hierarchy, the number of components that can be added, and the corresponding placeholders; the node definition file is in JSON or YAML format. The component definition file includes the component name, component description, DTS replacement text, and supported nodes, defining the mapping relationship between hardware components and device tree code snippets. The component definition file adopts XML or YAML format.
[0008] Placeholder dynamic replacement algorithms include: Traverse the device tree template file to identify all placeholder identifiers; Based on the node definition file, determine the node location and allowed component types for each placeholder identifier; Based on the hardware components selected by the user, the corresponding device tree code snippet is obtained from the component definition file; Replace the placeholders with the corresponding device tree code snippets to generate a complete device tree source file.
[0009] The method also includes generating a build log, which is used to record configuration parameters, compilation process, and result status.
[0010] The image file is packaged in IMG format and contains a device tree binary file, a kernel image, and a root file system.
[0011] The image packaging method also includes a container-based CI / CD automation process.
[0012] A system for automatic generation and image building of configuration-driven device trees, the system comprising, The Web-based visual configuration module provides a graphical interface for users to select configuration options for the target hardware platform. The board-level data management module is used to store and manage board-level configuration files, which include device tree template files, node definition files, and component definition files. The compilation and image generation module is used to execute the placeholder dynamic replacement algorithm to generate device tree source files, and call the compiler to compile and package the device tree source files into system image files; Custom extension modules are used to support users in adding new board-level platforms or hardware components.
[0013] The Web visualization configuration module includes, Board-level platform selection: Supported hardware platforms are displayed in a list or card format; Hardware component selection: Displays available hardware components in the form of a category tree or checkboxes, and supports drag-and-drop configuration of components; Create a new device tree: Display the newly created device tree as a node tree; Configuration Preview: Real-time preview of the generated device tree structure; Configuration debugging: Supports debugging of configuration schemes to obtain the optimal solution.
[0014] The compilation and image generation module also includes a download module and a log management module. The download module generates corresponding target files according to different platforms, and the log management module is used to record system operation logs and build logs.
[0015] The system is deployed on a server and accessed via a web browser, supporting concurrent use by multiple users.
[0016] This invention discloses a method and system for automatic generation of device trees and image building based on configuration-driven architecture. It transforms kernel development into graphical configuration through a web-based visual interface, lowering the development threshold by employing graphical operations. No manual editing of the DTS is required; users can complete configuration, debugging, and compilation through the browser interface. It adopts a three-layer configuration-driven mechanism, consisting of the device tree template file (template.dts), the node definition file (node.json), and the component definition file (component.xml), combined with a placeholder dynamic replacement algorithm to automatically verify the matching relationship between nodes and components. The device tree is automatically compiled and image generated, offering advantages such as high reliability and automated construction. Board-level data is entirely described by configuration files. Adding a new hardware platform only requires adding a folder and description file, without modifying the program logic. The template file and component definition are independent of each other and support dynamic combination, improving reusability. Attached Figure Description
[0017] Figure 1 This is a flowchart of the present invention. Detailed Implementation
[0018] The technical solutions in the embodiments of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the implementation of the present invention, and not all of it. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0019] Embedded system development based on the ARM architecture. For example, smartphones, routers, IoT devices, industrial controllers, and other products based on ARM chips require writing or modifying a file called a Device Tree (DTS) for specific hardware configurations. This file informs the operating system (such as Linux) about the available hardware, such as CPU model, memory size, and peripheral interfaces. Developers must manually write or modify the DTS file, which is complex in syntax and prone to errors.
[0020] This invention proposes a configuration-driven method and system for automated generation of device trees and image building, realizing an integrated and visual development process from board-level configuration and component selection to image packaging.
[0021] like Figure 1 As shown, the method for automatic generation of device trees and image building based on configuration-driven architecture includes the following steps: S1): User selects target board level: The target hardware platform is configured and selected through a web-based visual interface. The configuration selection includes the board level platform and at least one hardware component. S2): Read the board-level configuration file selected by the user: Based on the selected board-level platform, obtain the corresponding board-level configuration file from the board-level data management module. The board-level configuration file includes a device tree template file, a node definition file, and a component definition file. S3): Create a new baseboard device tree and parse nodes: Create a new baseboard device tree using the device tree template file as a template. The node definition file defines the structural hierarchy and placeholder identifiers of the device tree. The node definition file determines the mounting position of the hardware components selected by the user in the device tree. S4): Parse the component definition file to obtain the component definition and configurable nodes: Obtain the device tree code snippet corresponding to the hardware component selected by the user based on the component definition file; S5): Configure the component: Execute the placeholder dynamic replacement algorithm to replace the placeholders in the device tree template file with the corresponding device tree code snippets, and generate a complete device tree source file; S6): Compile device tree source file: Call the compiler to compile the device tree source file into a device tree binary file, and package the device tree binary file into the system image file; S7): Image file download: Provide the generated system image file to the user for download.
[0022] The device tree template file is a base template that contains placeholders for all configurable nodes. The placeholder identifiers correspond to the node positions defined in the node definition file. The device tree template file is in DTS format, that is, the device tree template file is template.dts. The device tree template file contains all the positions that may need to be configured, but these positions are replaced with placeholders.
[0023] The node definition file defines the node hierarchy, the number of components that can be added, and the corresponding placeholders. The node definition file is in JSON or YAML format; in this embodiment, the node definition file is in JSON format, i.e., the node definition file is named node.json. The node definition file defines the structural hierarchy of the device tree, indicating which child nodes can be added under which parent node, and what the placeholder for each position is. The node definition file includes the following fields: Node name: Defines the name of the node in the device tree; Parent node: Defines the path of the parent node of this node; Placeholder identifier: Defines the placeholder identifier corresponding to the position of this node; Allowed component types: Defines the types of hardware components that can be mounted at this node location.
[0024] The component definition file includes a component name, component description, DTS replacement text, and supported nodes. It defines the mapping relationship between hardware components and device tree code snippets. The component definition file adopts XML or YAML format. In this embodiment, the component definition file adopts XML format, that is, the component definition file is component.xml. The component definition file defines a specific hardware component, such as a specific I2C touch screen, and describes what the actual DTS code snippet corresponding to this component is. The component definition file includes the following fields: Component name: A unique identifier for a hardware component; Component Type: Classification of hardware component types; Device tree code snippet: The device tree code corresponding to this hardware component.
[0025] Placeholder dynamic replacement algorithms include: Traverse the device tree template file template.dts and identify all placeholder identifiers; Based on the node definition file node.json, determine the corresponding node position and the allowed component types for each placeholder identifier; Based on the hardware components selected by the user, the corresponding device tree code snippet is obtained from the component definition file component.xml; Replace the placeholders with the corresponding device tree code snippets to generate a complete device tree source file.
[0026] The method also includes generating a build log, which is used to record configuration parameters, compilation process, and result status.
[0027] The image file is packaged in IMG format and contains a device tree binary file, a kernel image, and a root file system.
[0028] The image packaging method also includes a container-based CI / CD automated process. CI stands for Continuous Integration. The main CI process involves developers uploading code to GitHub. Continuous Integration tools (GitHub Actions, Jenkins) detect new code commits, triggering a build process to generate an application image, which is then pushed to an image repository (Docker Hub, JFroger). CD stands for Continuous Deployment. When a new image is detected, it is started, generating a container. The container-based CI / CD automated process avoids basic errors from manual operations and simplifies project development and deployment.
[0029] A system for automatic generation and image building of configuration-driven device trees, the system comprising, The Web-based visual configuration module provides a graphical interface for users to select configuration options for the target hardware platform. The Web-based visual configuration module can also be replaced by a web-based command-line tool, but the Web-based visual configuration module is preferred.
[0030] The Web visualization configuration module includes, Board-level platform selection: Supported hardware platforms are displayed in a list or card format; Hardware component selection: Displays available hardware components in the form of a category tree or checkboxes, and supports drag-and-drop configuration of components; Create a new device tree: Display the newly created device tree as a node tree; Configuration Preview: Real-time preview of the generated device tree structure; Configuration debugging: Supports debugging of configuration schemes to obtain the optimal solution.
[0031] The web-based visual configuration module provides a web interface where users can select hardware and configuration parameters by clicking, dragging, and other methods, without writing code. It can be accessed via a browser on an Ubuntu server (default port 5544); supports board-level selection, creating new device trees, component configuration, previewing, and debugging; and supports node tree display and drag-and-drop component configuration.
[0032] The board-level data management module stores and manages board-level configuration files, which include a device tree template file (template.dts), a node definition file (node.json), and a component definition file (component.xml). Board-level data is located at / opt / tools / tool-extender / board / . Each board level contains three core configuration files—template.dts, node.json, and component.xml—forming a three-layer configuration-driven mechanism. A unified template combined with a configuration-driven model describes the correspondence between nodes, components, and placeholders. The separation of the device tree template file, node definition file, and component definition file allows components to be reused across different board levels, and board-level configurations can be easily derived. Adding a new hardware platform or component only requires adding the corresponding configuration file, without modifying the core tool's program code—a fundamental difference from traditional script-based methods.
[0033] The board-level data management module stores the configurations of different hardware platforms, such as development boards with RK3568 chips and development boards with E2000Q chips. Each hardware platform has a corresponding configuration file.
[0034] The compilation and image generation module automatically compiles the DTS file into binary format based on user configuration and packages it into the final system image file. This module generates device tree source files by executing a placeholder dynamic replacement algorithm and then calls a compiler to compile and package these source files into a system image file. The compilation and image generation module also includes a download module and a log management module. The download module generates corresponding target files for different platforms, and the log management module records system operation logs and build logs.
[0035] Supports automatic compilation of Device Tree Source Files (DTS) into Device Tree Binary Files (DTB); generates target files for different platforms, such as boot.img for RK3568 and dtb for E2000Q; provides failure log query and image download functions; A custom extension module is provided to support users in adding new board-level platforms or hardware components. It supports custom extensions, allowing users to add new board-level platforms or hardware components by uploading configuration files. These configuration files include a device tree template file (template.dts), a node definition file (node.json), and a component definition file (component.xml). Users can define custom components (XML), nodes (JSON), and templates (DTS). The system automatically parses the relationships between these three elements, enabling dynamic loading and extension. The system is deployed on a server and accessed via a web browser, supporting concurrent use by multiple users.
[0036] Taking the RK3568 development board and touch screen assembly as examples, the workflow of this invention is explained in detail: On the front-end webpage, the user selects "RK3568 development board" and "a specific touchscreen model." The system backend then reads the RK3568 board-level folder, copies the device tree template file template.dts as a base, and, based on the node definition file node.json, determines that the touchscreen should be mounted under the I2C-1 node, with the placeholder being {i2c1_node}. Based on the component definition file component.xml, it finds the corresponding DTS code snippet for the touchscreen, executes the "placeholder dynamic replacement algorithm," replaces the placeholder {i2c1_node} in the template with the corresponding DTS code snippet for the touchscreen, automatically calls the compiler to compile the generated standard DTS file into a DTB, and finally packages it into a boot.img image for the user to download.
[0037] The aforementioned method and system for automatic device tree generation and image building based on configuration-driven architecture is a web-based visual device tree configuration and debugging method. It features a board-level scalable and component-reusable system architecture design, and adopts a three-layer configuration-driven mechanism consisting of a device tree template file (template.dts), a node definition file (node.json), and a component definition file (component.xml). Through dynamic replacement of placeholders and a node component binding algorithm, placeholders are replaced with corresponding code snippets of the components, and the compiler is automatically invoked, resulting in an integrated process of automatic device tree compilation and image generation.
[0038] It has the following advantages, 1. Graphical operation significantly lowers the development threshold. No need to manually edit DTS; users can complete configuration, debugging, and compilation in the browser interface. 2. High reliability and automated build: The system automatically verifies the matching relationship between nodes and components, and supports one-click compilation to generate image files; 3. The configuration driver has an extensible architecture. Board-level data is entirely described by configuration files. When adding new hardware platforms, only the folder and description file need to be added, without modifying the program logic. 4. Components and nodes are decoupled, template files and component definitions are independent of each other, supporting dynamic composition and improving reusability; 5. Debugging and log visualization, supporting compilation log viewing, error location, and image result preview.
[0039] The technical means disclosed in this invention are not limited to those disclosed in the above embodiments, but also include technical solutions composed of any combination of the above technical features. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of this invention, and these improvements and modifications are also considered within the scope of protection of this invention.
Claims
1. A method for automatic generation of device trees and image construction based on configuration-driven approaches, characterized in that: Includes the following steps: S1): User selects target board level: The target hardware platform is configured and selected through a web-based visual interface. The configuration selection includes the board level platform and at least one hardware component. S2): Read the board-level configuration file selected by the user: Based on the selected board-level platform, obtain the corresponding board-level configuration file from the board-level data management module. The board-level configuration file includes a device tree template file, a node definition file, and a component definition file. S3): Create a new baseboard device tree and parse nodes: Create a new baseboard device tree using the device tree template file as a template. The node definition file defines the structural hierarchy and placeholder identifiers of the device tree. The node definition file determines the mounting position of the hardware components selected by the user in the device tree. S4): Parse the component definition file to obtain the component definition and configurable nodes: Obtain the device tree code snippet corresponding to the hardware component selected by the user based on the component definition file; S5): Configure the component: Execute the placeholder dynamic replacement algorithm to replace the placeholders in the device tree template file with the corresponding device tree code snippets and generate a complete device tree source file; S6): Compile device tree source file: Call the compiler to compile the device tree source file into a device tree binary file, and package the device tree binary file into the system image file; S7): Image file download: Provide the generated system image file to the user for download.
2. The method for automatic generation of device trees and image construction based on configuration-driven approach according to claim 1, characterized in that: The device tree template file is a base template containing placeholders for all configurable nodes, and the device tree template file is in DTS format. The node definition file defines the node hierarchy, the number of components that can be added, and the corresponding placeholders; the node definition file is in JSON or YAML format. The component definition file includes the component name, component description, DTS replacement text, and supported nodes, defining the mapping relationship between hardware components and device tree code snippets. The component definition file adopts XML or YAML format.
3. The method for automatic generation of device trees and image construction based on configuration-driven approach according to claim 1, characterized in that: Placeholder dynamic replacement algorithms include: Traverse the device tree template file to identify all placeholder identifiers; Based on the node definition file, determine the node location and allowed component types for each placeholder identifier; Based on the hardware components selected by the user, the corresponding device tree code snippet is obtained from the component definition file; Replace the placeholders with the corresponding device tree code snippets to generate a complete device tree source file.
4. The method for automatic generation of device trees and image construction based on configuration-driven approach according to claim 1, characterized in that: The method also includes generating a build log, which is used to record configuration parameters, compilation process, and result status.
5. The method for automatic generation of device trees and image construction based on configuration-driven approach according to claim 1, characterized in that: The image file is packaged in IMG format and contains a device tree binary file, a kernel image, and a root file system.
6. The method for automatic generation of device trees and image construction based on configuration-driven approach according to claim 1, characterized in that: The image packaging method also includes a container-based CI / CD automation process.
7. A system for automatic generation and image building of device trees based on configuration-driven methods, the system operating as described in any one of claims 1 to 5, characterized in that: The system includes, The Web-based visual configuration module provides a graphical interface for users to select configuration options for the target hardware platform. The board-level data management module is used to store and manage board-level configuration files, which include device tree template files, node definition files, and component definition files. The compilation and image generation module is used to execute the placeholder dynamic replacement algorithm to generate device tree source files, and call the compiler to compile and package the device tree source files into system image files; Custom extension modules are used to support users in adding new board-level platforms or hardware components.
8. The system for automatic generation and image building of device trees based on configuration-driven architecture according to claim 7, characterized in that: The Web visualization configuration module includes, Board-level platform selection: Supported hardware platforms are displayed in a list or card format; Hardware component selection: Displays available hardware components in the form of a category tree or checkboxes, and supports drag-and-drop configuration of components; Create a new device tree: Display the newly created device tree as a node tree; Configuration Preview: Real-time preview of the generated device tree structure; Configuration debugging: Supports debugging of configuration schemes to obtain the optimal solution.
9. The system for automatic generation and image building of device trees based on configuration-driven architecture according to claim 7, characterized in that: The compilation and image generation module also includes a download module and a log management module. The download module generates corresponding target files for different platforms, and the log management module is used to record system operation logs and build logs.
10. The system for automatic generation and image building of device trees based on configuration-driven architecture according to claim 7, characterized in that: The system is deployed on a server and accessed via a web browser, supporting concurrent use by multiple users.