DTS modification method, device and computer-readable storage medium
Through the management service interface, the binary format file dts.bin of DTS is parsed and synchronized, real-time modification of DTS is realized, solving the problems of high modification risks and high workload in the existing technology, simplifying the operation process and supporting the use scenarios of different devices. .
Patent Information
- Application Number
- CN202010796824.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-10
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2040-08-10
AI Technical Summary
The prior art is difficult to modify the device tree source file (DTS) in real time in all scenarios, especially when different hardware configurations and equipment replaces motherboard peripherals, resulting in high modification risks, high workload and unfavorable to the maintenance of native systems.
Get and parse DTS' binary format file dts.bin through the management service interface, realize real-time modification of DTS, supports different devices and various usage scenarios, and synchronizes the modified content to the dts.bin file to generate DTS that can be directly parsed by the kernel , avoid the impact on the native system.
Real-time modification of DTS is realized, the modification process is simplified, the system workload is reduced, different devices are supported, various usage scenarios are met, and the user experience is improved.
Smart Images

Figure CN112068896B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the embedded field, and more specifically, relates to a method, a device and a computer-readable storage medium for modifying a DTS (Device Tree Source). Background Art
[0002] In devices based on the Linux kernel system, the device tree is used to describe the hardware resources of the device, and DTS is used to describe the device tree architecture. DTS is a source file that is easy for humans to read and understand, but cannot be directly parsed by the Linux kernel.
[0003] In actual applications, the same device may have different hardware configurations, or the device may replace the mainboard and peripherals. In this case, the DTS or its parameters need to be modified accordingly. At present, the main solutions for modifying DTS and its parameters in the industry have defects:
[0004] (1) Modifications need to be made in specific scenarios, such as entering the uboot (universal boot loader) mode and using the fdt command to make modifications. However, in actual scenarios, DTS needs to be modified or parameters added in real time. For example, in the commercial display field, the same firmware needs to be applied to dozens or hundreds of display devices. This solution cannot meet the needs for real-time modification of DTS in all scenarios.
[0005] (2) Directly modify some DTS parameters at the application layer. These parameters interact with the upper layer through corresponding interfaces at the kernel driver layer. This solution not only leads to potential modification risks, but also brings a huge workload every time the driver is modified, and destroys the original system mode.
[0006] (3) Modify the firmware DTS through a PC or other tools, generate new firmware, and then update the target board. This method of first modifying the firmware DTS through a modification tool requires a huge amount of engineering for mass production and online use, and the firmware update cycle is long. Summary of the invention
[0007] The main purpose of the present invention is to provide a method, device and computer-readable storage medium for DTS modification, which can realize DTS modification through a management service interface, not only optimizing the maintenance and operation methods of the system, but also meeting the demand for real-time DTS modification on the target board.
[0008] According to a first aspect of the present invention, a method for modifying a DTS comprises the following steps:
[0009] Get the dts.bin file that saves the DTS data in binary format;
[0010] Load the modified content and parsing services of DTS;
[0011] Parse the modified content through the management service interface and synchronize the modified content to the dts.bin file;
[0012] Generate DTS based on the synchronized dts.bin file and write it into the DTS partition.
[0013] This embodiment parses DTS into a dts.bin file that can be directly parsed by the kernel, and uses the dts.bin file as an intermediate medium for modifying DTS. DTS modification is achieved by modifying the dts.bin file. This not only realizes real-time modification of DTS, supports different devices, and meets the needs of various usage scenarios, but also has a simple modification process, a small system workload, and will not affect the native system.
[0014] In a specific embodiment of the present invention, the step of obtaining a dts.bin file storing DTS data in binary format includes:
[0015] Determine whether the dts.bin file exists. If not, generate the dts.bin file. Ensure that the dts.bin file can be obtained and improve the reliability of DTS modification.
[0016] In a specific embodiment of the present invention, the step of obtaining a dts.bin file storing DTS data in binary format includes:
[0017] Start the boot loader and check whether the dts.bin file exists;
[0018] If it does not exist, generate the dts.bin file and then start the operating system;
[0019] If present, boot the operating system.
[0020] After the boot loader is started, the DTS needs to be passed to the kernel. Obtaining the binary format file dts.bin of the DTS data during the boot loader startup process can simplify the workflow.
[0021] In a specific embodiment of the present invention, the dts.bin file is generated by compiling DTS using a device tree compiler to obtain a binary dts.bin file, thereby making full use of the boot loader, reducing the addition of other programs, and simplifying the workflow.
[0022] In a specific embodiment of the present invention, the dts.bin file and DTS are stored in different partitions of the system storage space. The dts.bin file is a modified storage medium of DTS, and being stored separately can ensure that the normal operation of the current system is not affected, thereby reducing risks.
[0023] In a specific embodiment of the present invention, the method of loading the modified content of the DTS includes at least one of the following:
[0024] Loading the hardware configuration of the target device, and comparing the hardware configuration of the target device with the DTS to obtain the modified content; or
[0025] Get the modified content of the DTS entered by the user from the modification request; or
[0026] The modified content of the DTS input by the user is obtained from the modification request, and the modified content of the DTS input by the user is compared with the DTS to obtain the final modified content.
[0027] In a specific embodiment of the present invention, before parsing the modified content through the management service interface and synchronizing the modified content to the dts.bin file, it also includes determining whether to enter DTS modification;
[0028] If you enter DTS to make changes, parse the changes through the management service interface and synchronize the changes to the dts.bin file;
[0029] Otherwise, the operating system keeps functioning normally.
[0030] Since the DTS modification of the present invention can be performed at any time, a judgment prompt is performed before starting the DTS modification, which can avoid the DTS modification from affecting the programs running on the system and improve the user experience.
[0031] In another specific embodiment of the present invention, before parsing the modified content through the management service interface and synchronizing the modified content to the dts.bin file, it also includes determining whether to modify the dts.bin file;
[0032] If the dts.bin file is modified, the modified content is parsed through the management service interface and synchronized to the dts.bin file;
[0033] If the dts.bin file is not modified, determine whether to restart the operating system;
[0034] If the system is restarted, DTS is generated based on the synchronized dts.bin file and written to the DTS partition; otherwise, the operating system resumes normal operation.
[0035] This is a judgment prompt, which can prevent DTS modifications from affecting programs running on the system and improve user experience.
[0036] According to a third aspect of the present invention, there is provided a device for modifying DTS, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a method for modifying DTS is implemented as in any one of the embodiments of the third aspect of the present invention.
[0037] A third aspect of the present invention provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute a DTS modification method of any implementation of the third aspect of the present invention.
[0038] One of the above technical solutions of the present invention has at least one of the following advantages or beneficial effects: parsing DTS into a dts.bin file that can be directly parsed by the kernel, and using the dts.bin file as an intermediate medium for modifying DTS. By modifying the dts.bin file, DTS modification is achieved, which not only realizes real-time modification of DTS, supports different devices, and meets various usage scenario requirements, but also has a simple modification process, a small system workload, and will not affect the native system. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 is a flow chart of a DTS modification method provided by an embodiment of the present invention;
[0040] Figure 2 is a specific flow chart of step S100 in an embodiment of the present invention;
[0041] Figure 3 is a schematic diagram of system storage space partitioning in an embodiment of the present invention;
[0042] Figure 4 is a specific flow chart of step S300 in an embodiment of the present invention;
[0043] Figure 5 It is a structural block diagram of a DTS modification device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0044] The embodiments of the present invention are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals represent the same or similar elements or elements having the same or similar functions from beginning to end. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.
[0045] The following disclosure provides many different embodiments or examples for implementing different solutions of the present invention.
[0046] Reference Figure 1 As shown, a DTS modification method provided by an embodiment of the present invention includes the following steps:
[0047] Step S100: Obtain a dts.bin file storing DTS data in binary format (which can be directly parsed by the operating system kernel).
[0048] Step S200, loading the modified content and parsing service of DTS; in one embodiment of the present invention, step S200 is executed after the operating system is started.
[0049] In this embodiment, the method of loading the modified content of the DTS includes at least one of the following:
[0050] (1) Load the hardware configuration of the target device directly from the target device, and compare the hardware configuration of the target device with the DTS to obtain the modified content;
[0051] (2) After receiving the DTS modification request, the DTS modification content entered by the user is obtained from the modification request; in order to ensure the accuracy of the modification content and avoid unnecessary modifications, the DTS modification content entered by the user is compared with the DTS to obtain the final modification content.
[0052] Step S300: Parse the modified content through the management service interface and synchronize the modified content to the dts.bin file.
[0053] Step S400: Generate DTS according to the dts.bin file in step S300, write it into the DTS partition, and modify the DTS.
[0054] In the embodiment of the present invention, the operating system is restarted and step S400 is executed. Step S400 includes:
[0055] Compile and generate a new DTS based on the modified dts.bin file;
[0056] Call the management service interface to write the new DTS to the DTS partition.
[0057] This embodiment parses DTS into a dts.bin file that can be directly parsed by the kernel, and uses the dts.bin file as an intermediate medium for modifying DTS. DTS modification is achieved by modifying the dts.bin file. This not only realizes real-time modification of DTS, supports different devices, and meets the needs of various usage scenarios, but also has a simple modification process, a small system workload, and will not affect the native operating system.
[0058] In order to ensure that the dts.bin file can be obtained and improve the reliability of DTS modification, in one embodiment of the present invention, step S100 includes determining whether the dts.bin file exists. If the dts.bin file does not exist, DTC (Device Tree Compiler) is used to compile DTS and regenerate the dts.bin file.
[0059] Because after the boot loader is started, the DTS needs to be passed to the kernel, it is easier to obtain the binary format file dts.bin file of the DTS data, simplifying the workflow. Therefore, this embodiment obtains the dts.bin file in the boot loader, such as Figure 2 As shown, step S100 includes the following steps:
[0060] Step S101, power on the system;
[0061] Step S102, starting the boot loader (boot);
[0062] Step S103, determine whether there is a dts.bin file, if so, execute step S105, otherwise, execute step S104; wherein the dts.bin file stores the binary format of the DTS data;
[0063] Step S104: regenerate the dts.bin file. In this embodiment, regenerating the dts.bin file includes:
[0064] Read DTS data by adding an interface capable of reading DTS in boot;
[0065] Use DTC to compile the read data to obtain binary format data, and save the binary format data in a newly created dts.bin file.
[0066] Step S105: start the operating system.
[0067] In order to reduce the impact on DTS, the dts.bin file and DTS in the embodiment of the present invention are stored in different partitions of the system storage space, such as Figure 3 As shown, the system storage space includes: BOOT0 partition, UBOOT and DTS partitions, kernel partition, system partition, Bootloader partition and other partitions, among which the dts.bin file is saved in the Bootloader partition and DTS is saved in the DTS partition.
[0068] In this embodiment, if Figure 4 As shown, step S300 includes the following steps:
[0069] Step S301, calling the management service's parsing and reading interface dts_get to parse and read the modified content;
[0070] Step S302, calling the saving interface dts_set of the management service to save the read modified content;
[0071] Step S303, calling the synchronization interface dts_sync of the management service to synchronize the modified content to the dts.bin file, saving the modified dts.bin file, and exiting the dts.bin file modification program;
[0072] Step S304, determine whether to restart the operating system, if restarted, execute step S400; otherwise, the operating system keeps working normally.
[0073] In the embodiment of the present invention, the management service interface called is an additional interface for DTS modification. An independent management service is used to manage and operate the DTS storage intermediate file (dts.bin file), which can optimize the maintenance and operation process of the operating system.
[0074] Since the DTS modification in the embodiment of the present invention can be performed at any time, that is, step S200 can be performed at any time as needed, in order to avoid the DTS modification from affecting the programs running on the system and improve the user experience, in another embodiment of the present invention, after executing step S200 and before executing steps S301 to S303, it also includes a determination of whether to enter the DTS modification program, including the following steps:
[0075] Determine whether to enter DTS modification. If so, execute step S300; otherwise, the operating system keeps working normally, and after entering the operating system restart, execute step S400 again.
[0076] In another embodiment of the present invention, for the purpose of flexibility of use and suitability for various application scenarios, a procedure for determining whether to modify the dts.bin file is also included, including the following steps:
[0077] Determine whether to modify the dts.bin file. If so, execute step S300. Otherwise, determine whether to restart the operating system. If so, execute step S400. Otherwise, the operating system resumes normal operation. After the operating system restarts, execute step S400 again to complete the DTS modification.
[0078] In another embodiment of the present invention, the process includes both the determination of whether to enter the DTS modification program and the determination of whether to perform the dts.bin file modification program; the process includes the following steps:
[0079] Determine whether to enter DTS modification. If not, the operating system keeps normal operation. After the operating system is restarted, step S400 is executed again.
[0080] If DTS modification is entered, determine whether to modify the dts.bin file; if the dts.bin file is not modified, the operating system resumes normal operation, and after the operating system is restarted, step S400 is executed again to complete the DTS modification; if the dts.bin file is modified, step S300 is executed.
[0081] Reference Figure 5 As shown, a DTS modification device provided in an embodiment of the present invention may be any type of program module, such as an application program. The DTS modification device may be used to modify the DTS on a target device in real time.
[0082] Specifically, the DTS modification device includes: one or more processors 200 and a memory 100, Figure 5 A processor 200 and a memory 100 are taken as an example. The processor 200 and the memory 100 may be connected via a bus or other means. Figure 5 The example of connecting through bus is taken in the following.
[0083] The memory 100 is a non-transitory computer-readable storage medium that can be used to store non-transitory software programs and non-transitory computer executable programs, such as a DTS modification method in an embodiment of the present invention. The processor 200 implements a DTS modification method in the above embodiment of the present invention by running the non-transitory software programs and instructions stored in the memory 100.
[0084] The memory 100 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required by at least one function; the data storage area may store data required to execute a DTS modification method in the above embodiment, etc. In addition, the memory 100 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory may optionally include a memory 100 remotely disposed relative to the processor 200, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0085] The non-transient software program and instructions required to implement the above-mentioned DTS modification method are stored in the memory 100. When executed by one or more processors 200, the above-mentioned DTS modification method is executed, for example, the above-mentioned DTS modification method is executed. Figure 1Steps S100 to S400 of the method, Figure 2 Steps S101 to 105 of the method, Figure 4 The method comprises steps S301 to S304.
[0086] In addition, the present invention further provides a computer-readable storage medium, which stores computer-executable instructions. The computer-executable instructions are executed by one or more control processors, for example, by a processor, so that the one or more processors can execute a DTS modification method in the above embodiment, for example, execute the above described Figure 1 Steps S100 to S400 of the method, Figure 2 Steps S101 to 105 of the method, Figure 4 The method comprises steps S301 to S304.
[0087] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0088] It will be appreciated by those skilled in the art that all or some of the steps and systems in the disclosed method above may be implemented as software, firmware, hardware and appropriate combinations thereof. Some physical components or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, disk storage or other magnetic storage devices, or any other medium that may be used to store desired information and may be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically embodies computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0089] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.
Claims
1. A method for modifying DTS, characterized in that: The following steps are involved: Get the dts.bin file that saves the DTS data in binary format; Load the modified content and parsing services of DTS; Parse the modified content through the management service interface and synchronize the modified content to the dts.bin file; Generate DTS based on the synchronized dts.bin file and write it into the DTS partition; The step of obtaining the dts.bin file storing the DTS data in binary format includes: Start the boot loader and check whether the dts.bin file exists; If it does not exist, generate the dts.bin file and then start the operating system; If present, boot the operating system.
2. The method according to claim 1, characterized in that The generating of the dts.bin file is to compile the DTS using a device tree compiler to obtain a dts.bin file in a binary format.
3. The method according to claim 1, characterized in that The dts.bin file and DTS are stored in different partitions of the system storage space.
4. The method according to claim 1, characterized in that The method of loading the modified content of the DTS includes at least one of the following: Loading the hardware configuration of the target device, and comparing the hardware configuration of the target device with the DTS to obtain the modified content; or Get the modified content of the DTS entered by the user from the modification request; or The modified content of the DTS input by the user is obtained from the modification request, and the modified content of the DTS input by the user is compared with the DTS to obtain the final modified content.
5. The method according to claim 1, characterized in that Before parsing the modified content through the management service interface and synchronizing the modified content to the dts.bin file, it also includes determining whether to enter DTS modification; If you enter DTS to make changes, parse the changes through the management service interface and synchronize the changes to the dts.bin file; Otherwise, the operating system continues to function normally.
6. The method according to claim 1, characterized in that Before parsing the modified content through the management service interface and synchronizing the modified content to the dts.bin file, it also includes determining whether to modify the dts.bin file; If the dts.bin file is modified, the modified content is parsed through the management service interface and synchronized to the dts.bin file; If the dts.bin file is not modified, determine whether to restart the operating system; If the system is restarted, DTS is generated based on the synchronized dts.bin file and written to the DTS partition; otherwise, the operating system resumes normal operation.
7. A DTS modification device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a DTS modification method as described in any one of claims 1 to 6 is implemented.
8. A computer-readable storage medium storing computer-executable instructions, characterized in that: The computer executable instructions are used to execute the DTS modification method described in any one of claims 1 to 6.
Citation Information
Patent Citations
Memory device initialization method and electronic equipment
CN105159716A
Multi-dts (Device Tree Source)-file supporting method, compilation device and embedded device
CN107632828A
Method and device for disk management in ARM equipment and ARM equipment
CN108008914A
Disk Management Method and Apparatus in ARM Device and ARM Device
US20190220291A1
