Device identification starting method, device and system based on multi-device tree file
By storing multiple device tree files and hardware device ID information in Flash memory, and judging device type using EEPROM, the problem that traditional hardware devices can only store one device tree file is solved, and the system startup speed and flexibility is improved, and the system is implemented. Multi-device support.
Patent Information
- Application Number
- CN202411236566.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-04
- Publication Date
- 2024-12-27
AI Technical Summary
The EEPROM of traditional hardware devices can only store one device tree file, which makes it difficult to adapt to multiple hardware devices when the system starts, which leads to failure to start and slow speed.
By pre-write the model support list and multiple device tree files in the Flash memory, use the ID information on the EEPROM to determine the hardware device type, and load the corresponding device tree file for system startup.
It supports the loading of multiple device tree files, improves the system startup speed and flexibility, and ensures that the hardware devices can be recognized and started normally.
Smart Images

Figure CN119203112A_ABST
Abstract
Description
[Technical field]
[0001] The present invention relates to the technical field of hardware startup, and in particular to a device identification startup method, device and system based on multiple device tree files. [Background technology]
[0002] The EEPROM of a traditional hardware device usually only stores a unique identification code (ID) and the corresponding device tree file, and cannot store multiple device tree files. In addition, when a hardware device is powered on, the system will try to load the device tree file from the hardware device to configure the environment. Then, when the system cannot adapt to a certain hardware device, the system attempts to load the corresponding device tree file, which can easily lead to a startup failure, thereby slowing down the system startup.
[0003] In view of this, it is necessary to provide a device identification and startup method, apparatus and system based on multiple device tree files to overcome the above-mentioned defects. [Summary of the invention]
[0004] The purpose of the present invention is to provide a device identification startup method, device and system based on multiple device tree files, aiming to solve the problem that the existing system can only place one device tree file and the startup speed of hardware devices is slow.
[0005] In order to achieve the above object, the first aspect of the present invention provides a device identification and startup method based on multiple device tree files, comprising:
[0006] Step S10: Obtain a model support list pre-written into the boot, and a Flash memory storing a device tree file of the hardware device to be supported; wherein the model support list includes ID information of all hardware devices to be supported, and each ID information is set in one-to-one correspondence with the device tree file;
[0007] Step S20: start the system boot;
[0008] Step S30: The target hardware device is powered on, and the EEPROM of the target hardware device is read to obtain the ID information of the target hardware device connected to the system;
[0009] Step S40: determining whether the ID of the target hardware device is one of the IDs stored in the model support list; if so, proceeding to step S50; if not, exiting this startup or not starting the hardware device;
[0010] Step S50: setting environment variables, retrieving from the Flash memory and loading into the system a device tree file corresponding to the ID of the target hardware device;
[0011] Step S60: Start the kernel and complete the system startup.
[0012] In a preferred embodiment, the step S10 includes:
[0013] Get the ID information in the EEPROM of each preset hardware device and store it in the model support list;
[0014] Compile the device tree source file for each hardware device into a device tree binary file;
[0015] Use the burning tool or command line tool to burn the compiled device tree binary file to the predetermined location of the Flash memory.
[0016] In a preferred embodiment, the step S20 includes:
[0017] Start the boot program: BIOS / UEFI loads the boot loader from the boot device according to the configuration;
[0018] Boot loader execution: provides an interface for selecting an operating system;
[0019] Loading the kernel: The boot loader loads the kernel of the operating system into memory.
[0020] In a preferred embodiment, the step S50 includes:
[0021] Restart the device and enter the U-Boot command line;
[0022] Specify the address where the device tree binary will be loaded into memory;
[0023] Specify the name and path of the device tree file;
[0024] Save the environment variables.
[0025] In a preferred embodiment, the step S60 includes:
[0026] The boot loader is responsible for loading the kernel image and the device tree binary file into memory;
[0027] The bootloader passes the address of the device tree binary to the kernel;
[0028] Parse the device tree binary file and configure the hardware according to the information in the file;
[0029] The kernel uses the information in the device tree to initialize each device in the system, including setting registers, mapping memory, and allocating interrupts;
[0030] When all the hardware devices corresponding to the IDs pre-written into the model support list are initialized, the kernel startup process is completed and the system enters a fully operational state.
[0031] A second aspect of the present invention provides a device identification and startup device based on multiple device tree files, comprising:
[0032] A preprocessing module, used for obtaining a model support list pre-written into the boot, and a Flash memory storing a device tree file of the hardware device to be supported; wherein the model support list includes ID information of all the hardware devices to be supported, and each ID information is set in one-to-one correspondence with the device tree file;
[0033] The first startup module is used to start the system boot;
[0034] The ID reading module is used to read the EEPROM of the target hardware device when the target hardware device is powered on to obtain the ID information of the target hardware device connected to the system;
[0035] The ID matching module is used to determine whether the ID of the target hardware device is one of the IDs stored in the model support list. If the result is yes, the process proceeds to step S50; if the result is no, the process exits the current startup or does not start the hardware device.
[0036] A file loading module, used for setting environment variables, retrieving from the Flash memory and loading in the system a device tree file corresponding to the ID of the target hardware device;
[0037] The second startup module is used to start the kernel and complete the system startup.
[0038] A third aspect of the present invention provides a system, which includes a memory, a processor, and a computer program stored in the memory. When the computer program is executed by the processor, it implements the various steps of the device identification and startup method based on a multi-device tree file as described in any one of the above implementation modes.
[0039] A fourth aspect of the present invention provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the various steps of the device identification and startup method based on multiple device tree files as described in any one of the above implementation modes.
[0040] A fifth aspect of the present invention provides a computer program product, including a computer program or instructions, which, when processed and executed, implement the various steps of the device identification and startup method based on multiple device tree files as described in any one of the above implementation modes.
[0041] The device identification startup method, device and system based on multiple device tree files provided by the present invention write the ID information of multiple hardware devices into the model support list, and store the corresponding multiple device tree files in the Flash memory. When the system is started to power on the hardware device, it is only necessary to first detect whether the ID of the powered-on hardware device is one of the preset IDs in the model support list, so as to know whether the hardware device meets the requirements. Only when it is judged to be one of the preset devices, the corresponding device tree file will be loaded from the Flash memory, so that multiple device tree files can be placed and the system startup speed can be improved.
Brief Description of the Drawings
[0042] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0043] Figure 1 A flowchart of a device identification and startup method based on multiple device tree files provided by the present invention;
[0044] Figure 2 A framework diagram of a device identification and startup apparatus based on multiple device tree files provided by the present invention. [Specific implementation method]
[0045] In order to make the purpose, technical solution and beneficial technical effect of the present invention clearer, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. It should be understood that the specific implementation methods described in this specification are only for explaining the present invention, not for limiting the present invention.
[0046] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0047] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0048] Embodiment 1
[0049] In an embodiment of the present invention, a device identification and startup method based on multiple device tree files is provided, which is used to configure corresponding device tree files when starting hardware devices to achieve normal operation of hardware devices (such as audio devices).
[0050] like Figure 1 The device identification and startup method based on multiple device tree files includes steps S10-S60.
[0051] Step S10: Obtain the model support list pre-written into the boot, and the Flash memory storing the device tree file of the hardware device to be supported; wherein the model support list includes the ID information of all the hardware devices to be supported, and each ID information is set in a one-to-one correspondence with the device tree file.
[0052] The ID (Identification) information of the hardware device can be set at the factory or encoded when written. Each hardware device has a unique ID. EEPROM (Electrically Erasable Programmable Read-Only Memory) is used to store the unique serial number or identification code of the hardware device. This information is programmed during the production process and remains unchanged throughout the life cycle of the hardware device. The Device Tree Blob (DTB) is a data structure that provides the system's hardware configuration information and is very important for the operating system to correctly initialize the hardware at startup.
[0053] Specifically, step S10 includes: obtaining the ID information in the EEPROM of all preset hardware devices to be supported, storing it in the model support list, and writing it into the uboot code; then compiling the device tree source file (.dts) of each hardware device into a device tree binary file (.dtb); burning the compiled device tree binary file to a predetermined location of the Flash memory through a burning tool or a command line tool (such as the dd command).
[0054] Step S20: Start the system boot.
[0055] Specifically, step S20 includes:
[0056] Start the boot program: BIOS / UEFI loads the boot loader (such as GRUB, LILO, Windows Boot Manager, etc.) from the boot device (such as hard disk, CD / DVD, USB, etc.) according to the configuration;
[0057] Boot loader execution: provides an interface for selecting an operating system;
[0058] Loading the kernel: The boot loader loads the kernel of the operating system into memory.
[0059] Step S30: The target hardware device is powered on, and the EEPROM of the target hardware device is read to obtain the ID information of the target hardware device connected to the system.
[0060] When the system starts to start, the hardware device is powered on, and the ID information stored in the EEPROM of the hardware device can be read.
[0061] Step S40: Determine whether the ID of the connected hardware device is one of the IDs stored in the model support list. If the result is yes, execute step S50; if the result is no, exit this startup or do not start the hardware device.
[0062] Step S50: setting environment variables, retrieving from the Flash memory and loading into the system the device tree file corresponding to the ID of the target hardware device.
[0063] Specifically, step S50 includes:
[0064] Reboot the device and enter the U-Boot command line; specify the address where the device tree binary will be loaded into memory; specify the name and path of the device tree file; save the environment variables.
[0065] Among them, after the device is powered on, the boot loader is loaded from its storage location (i.e., Flash memory) into the memory and starts to execute. The boot loader will initialize a default set of environment variables. These variables are usually hard-coded in the source code of the boot loader, or defined in the configuration file of the boot loader. The boot loader here supports non-volatile storage (such as EEPROM or Flash) and will try to read the previously saved environment variables from the storage. It should be noted that after the configuration is completed, the boot loader will check whether the loaded environment variables are valid, including whether their values are reasonable and whether they meet the conditions of the startup process.
[0066] Step S60: Start the kernel and complete the system startup.
[0067] Specifically, step S60 includes:
[0068] The boot loader is responsible for loading the kernel image and device tree binary file into the memory; the boot loader passes the address of the device tree binary file to the kernel; parses the device tree binary file and configures the hardware according to the information in the file; the kernel uses the information in the device tree to initialize each device in the system, including setting registers, mapping memory, and allocating interrupts; when all the hardware corresponding to the ID in the pre-written model support list is initialized, the kernel startup process is completed and the system enters a fully operational state.
[0069] Embodiment 2
[0070] The present invention provides a device identification startup device 100 based on multiple device tree files, which is used to configure the corresponding device tree file when starting the hardware device to achieve the normal operation of the hardware device. It should be noted that the implementation principle and specific implementation method of the device identification startup device 100 based on multiple device tree files can refer to the above-mentioned device identification startup method based on multiple device tree files, so it will not be repeated below.
[0071] like Figure 2 As shown, the device identification and starting device 100 based on multiple device tree files includes:
[0072] The preprocessing module 10 is used to obtain a model support list pre-written in the boot, and a Flash memory storing a device tree file of the hardware device to be supported; wherein the model support list includes ID information of all the hardware devices to be supported, and each ID information is set in a one-to-one correspondence with the device tree file;
[0073] The first boot module 20 is used to boot the system;
[0074] The ID reading module 30 is used to read the EEPROM of the target hardware device when the target hardware device is powered on to obtain the ID information of the target hardware device connected to the system;
[0075] The ID matching module 40 is used to determine whether the ID of the target hardware device is one of the IDs stored in the model support list. If the result is yes, the process proceeds to step S50; if the result is no, the process exits the current startup or does not start the hardware device.
[0076] A file loading module 50, used to set environment variables, retrieve from the Flash memory and load in the system a device tree file corresponding to the ID of the target hardware device;
[0077] The second startup module 60 is used to start the kernel and complete the system startup.
[0078] Embodiment 3
[0079] The present invention provides a system, which includes a memory, a processor, and a computer program stored in the memory. When the computer program is executed by the processor, the computer program implements the various steps of the device identification and startup method based on multiple device tree files as described in any one of the above implementation modes.
[0080] Embodiment 4
[0081] The present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the computer program implements the various steps of the device identification and startup method based on multiple device tree files as described in any one of the above implementation modes.
[0082] Embodiment 5
[0083] The present invention provides a computer program product, including a computer program or instructions, which, when processed and executed, implements the various steps of the device identification and startup method based on multiple device tree files as described in any one of the above implementation modes.
[0084] To summarize, the device identification startup method, apparatus and system based on multiple device tree files provided by the present invention write the ID information of multiple hardware devices into the model support list, and store the corresponding multiple device tree files in the Flash memory. When the system is started to power on the hardware device, it is only necessary to first detect whether the ID of the powered-on hardware device is one of the preset IDs in the model support list, so as to know whether the hardware device meets the requirements. Only when it is judged to be one of the preset devices, the corresponding device tree file will be loaded from the Flash memory, thereby placing multiple device tree files and improving the system startup speed.
[0085] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the system can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0086] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0087] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0088] In the embodiments provided by the present invention, it should be understood that the disclosed systems or devices / terminal equipment and methods can be implemented in other ways. For example, the system or device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the system or unit can be electrical, mechanical or other forms.
[0089] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0090] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0091] The present invention is not limited to what is described in the specification and implementation modes, and therefore additional advantages and modifications can be easily realized by those skilled in the art. Therefore, without departing from the spirit and scope of the general concept defined by the claims and their equivalents, the present invention is not limited to the specific details, representative devices, and illustrative examples shown and described herein.
Claims
1. A device identification and startup method based on multiple device tree files, characterized in that: include: Step S10: Obtain a model support list pre-written into the boot, and a Flash memory storing a device tree file of the hardware device to be supported; wherein the model support list includes ID information of all the hardware devices to be supported, and each ID information is set in one-to-one correspondence with the device tree file; Step S20: start the system boot; Step S30: The target hardware device is powered on, and the EEPROM of the target hardware device is read to obtain the ID information of the target hardware device connected to the system; Step S40: determining whether the ID of the target hardware device is one of the IDs stored in the model support list; if so, proceeding to step S50; if not, exiting this startup or not starting the hardware device; Step S50: setting environment variables, retrieving from the Flash memory and loading into the system a device tree file corresponding to the ID of the target hardware device; Step S60: Start the kernel and complete the system startup.
2. The device identification and startup method based on multiple device tree files according to claim 1, characterized in that: The step S10 comprises: Get the ID information in the EEPROM of each preset hardware device and store it in the model support list; Compile the device tree source file for each hardware device into a device tree binary file; Use the burning tool or command line tool to burn the compiled device tree binary file to the predetermined location of the Flash memory.
3. The device identification and startup method based on multiple device tree files according to claim 1, characterized in that: The step S20 comprises: Start the boot program: BIOS / UEFI loads the boot loader from the boot device according to the configuration; Boot loader execution: provides an interface for selecting an operating system; Loading the kernel: The boot loader loads the kernel of the operating system into memory.
4. The device identification and startup method based on multiple device tree files according to claim 2, characterized in that: The step S50 comprises: Restart the device and enter the U-Boot command line; Specify the address where the device tree binary will be loaded into memory; Specify the name and path of the device tree file; Save the environment variables.
5. The device identification and startup method based on multiple device tree files according to claim 3, characterized in that: The step S60 comprises: The boot loader is responsible for loading the kernel image and the device tree binary file into memory; The bootloader passes the address of the device tree binary to the kernel; Parse the device tree binary file and configure the hardware according to the information in the file; The kernel uses the information in the device tree to initialize each device in the system, including setting registers, mapping memory, and allocating interrupts; When all the hardware devices corresponding to the IDs pre-written into the model support list are initialized, the kernel startup process is completed and the system enters a fully operational state.
6. A device identification and startup device based on multiple device tree files, characterized in that: include: A preprocessing module, used for obtaining a model support list pre-written into the boot, and a Flash memory storing a device tree file of the hardware device to be supported; wherein the model support list includes ID information of all the hardware devices to be supported, and each ID information is set in one-to-one correspondence with the device tree file; The first startup module is used to start the system boot; The ID reading module is used to read the EEPROM of the target hardware device when the target hardware device is powered on to obtain the ID information of the target hardware device connected to the system; An ID matching module is used to determine whether the ID of the target hardware device is one of the IDs stored in the model support list. If the result is yes, the process proceeds to step S50; if the result is no, the process exits the current startup or does not start the hardware device. A file loading module, used for setting environment variables, retrieving from the Flash memory and loading in the system a device tree file corresponding to the ID of the target hardware device; The second startup module is used to start the kernel and complete the system startup.
7. A system, characterized in that: The system includes a memory, a processor, and a computer program stored in the memory. When the computer program is executed by the processor, each step of the device identification and startup method based on multiple device tree files as described in any one of claims 1 to 5 is implemented.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the device identification and startup method based on multiple device tree files as described in any one of claims 1 to 5 are implemented.
Citation Information
Cited By
PLC equipment self-adaption method based on SPI equipment tree
CN120803981A
