Disclosure of Invention
Aiming at the defects of the prior art, the invention provides the equipment drive configuration method and the equipment drive configuration device under the embedded system, which can reduce the thresholds of drive development and debugging update and simplify the drive configuration process of the embedded system when equipment or equipment drive needs to be updated.
In order to solve the above technical problem, the present invention adopts a device driver configuration method under an embedded system, the method is used for configuring driver parameters for a device in the embedded system, and the driver configuration method includes the following steps: step S1, before the device is powered on, configuring a custom type driver packet at a configuration end, where the driver packet includes a data set composed of at least one set of device name, driver name, and parameter data of the device; a step S2 of configuring a boot system-side boot loader at the configuration side, where the boot loader boots the system side boot and responds to the drive packet; step S3, configuring a data processing module for the boot loader, where the data processing module responds to the driving data packet and performs parsing processing on the driving data packet to obtain driving parameters of the device, and stores the driving parameters according to a parameter address given by the system; step S4, configuring a driving parsing module at the system end, where the driving parsing module addresses the storage area of the embedded system according to a parameter address given by the system and extracts the driving parameter; step S5, after the device is powered on, executing the boot loader, and sending and storing the drive data packet to a memory of the embedded system; and step S6, executing a system image including a drive at the system end, executing the drive analysis module, and extracting the drive parameter, where the system image configures the device according to the device name, the drive name, and the parameter data included in the drive parameter.
As a preferable aspect of the present invention, the drive configuration method further includes: when the device and/or the driving parameters of the device need to be updated, the data set in the driving data packet is modified at the configuration end, and then the device is configured according to the sequence from step S5 to step S6.
Further preferably, in step S1, the data set of the driving data packet includes a start identifier and an end identifier, wherein the device name, the driving name and the parameter data are separated by using a first separator.
As a further preferable mode of the present invention, in step S3, before the step of performing parsing processing on the driving packet by the data processing module, the step of: configuring an entry function through a debugging serial port tool, wherein the data processing module in the first starting guider is triggered through the entry function; and after triggering, the data processing module analyzes the driving data packet to obtain the driving parameters of the equipment and then stores the driving parameters to the parameter address.
Still further preferably, in step S5, the boot loader sends and stores the driving data packet to an offset address in an embedded system memory;
and executing the data processing module, analyzing the driving data packet to obtain the driving parameters, and storing the driving parameters into an offset address of a nonvolatile memory bank under the embedded system.
As still further preferable in this solution, the step of parsing the driver package by the data processing module specifically includes: and extracting the drive data packet from the offset address of the memory of the embedded system, judging the starting identifier and the ending identifier of the drive data packet, analyzing at least one group of the equipment name, the drive name and the parameter data through the separator, and storing the equipment name, the drive name and the parameter data into the offset address of the nonvolatile memory bank.
Still more preferably, in step S5, the step of sending the driving data packet by the boot loader is specifically: and the first starting director sends a serial port type or network port type transmission command and sends the driving data packet to an offset address of a memory of the system end.
Still preferably, the present invention further includes: when the boot loader is started, if the data processing module is not matched with the driving data packet needing to be responded, the driving setting module adopts preset driving parameters.
In a second aspect of the present invention, a driver configuration apparatus under an embedded system is provided, where the configuration apparatus includes: the starting guide device is used for guiding the system end to start; the data processing module is used for responding to a driving data packet of a configuration end to obtain driving parameters in the driving data packet and storing the driving parameters into a parameter address; a drive resolution module that extracts the drive parameter from the parameter address; and the drive setting module configures the equipment according to the equipment name, the drive name and the parameter data contained in the drive parameters.
A third aspect of the present invention provides an electronic device, including: one or more processors; and a memory associated with the one or more processors for storing program instructions which, when read and executed by the one or more processors, perform the method of the first aspect of the invention.
Compared with the prior art, the invention has the following beneficial technical effects due to the adoption of the technical scheme:
in the preferred embodiment of the invention, the start-up guidance of the embedded system is configured, so that the start-up of the system end system mirror image is realized through the start-up guidance, and during the start-up guidance, a predefined driving data packet is obtained, and the driving data packet is analyzed to obtain at least one group of device names, driving names and parameter data contained in a data set of the driving data packet; and after the system mirror image is started, extracting a driving parameter formed by the equipment name, the driving name and the parameter data, and performing driving configuration on the equipment at the system end according to the driving parameter. Therefore, when the system side equipment or the drive parameters of the equipment are changed, or the equipment or the drive parameters of the equipment are required to be updated, the drive source codes do not need to be modified again under the same requirements of the prior art, then the system is compiled and burned, the predefined drive data packet only needs to be directly modified at the configuration end, then the system mirror image is enabled to obtain the modified drive data packet again by starting the boot, and the equipment is updated according to the updated drive parameters.
Detailed Description
Embodiments of a device driver configuration method and configuration apparatus under an embedded system according to the present invention will be described below with reference to the accompanying drawings. Those of ordinary skill in the art will recognize that the described embodiments can be modified in various different ways, without departing from the spirit and scope of the present invention. Accordingly, the drawings and description are illustrative in nature and not intended to limit the scope of the claims. Furthermore, in the present description, the drawings are not to scale and like reference numerals refer to like parts.
It should be noted that, in the embodiments of the present invention, the expressions "first" and "second" are used to distinguish two entities with the same name but different names or different parameters, and it is understood that "first" and "second" are merely for convenience of description and should not be construed as limitations of the embodiments of the present invention, and the descriptions thereof in the following embodiments are omitted.
In the prior art, when the device of the embedded system or the driver of the device changes, the driver source code of the embedded system needs to be modified, and then the embedded system can identify and drive the device in a recompilation and burning manner. Obviously, this approach makes the device driver configuration of the embedded system very inconvenient. The idea of solving the technical problem in the preferred embodiment of the present invention includes:
1) configuring a starting guide for the system mirror image, and guiding to start the embedded system through the starting guide;
2) on the basis of starting guidance, a bridge and a medium for bearing equipment driving parameters are configured between a configuration end and a system end, when an embedded system is guided to start, the bridge acquires and identifies the predefined medium, and the equipment is configured according to the driving parameters in the medium, so that when the equipment or the driving parameters of the equipment change, only the medium for bearing the equipment driving parameters needs to be modified at the configuration end, and then the system is restarted by starting guidance, and the modified driving parameters can be sent to the embedded system;
3) the drive analysis module of the embedded system is improved, so that when the system is preferentially selected to be started, a medium which is used for guiding and sending the bearing equipment drive parameters is started, and the equipment is driven and configured according to the drive parameters in the medium.
Based on the idea, the invention provides a device driver configuration method and a device under an embedded system. Referring to fig. 1, fig. 1 is a schematic diagram illustrating a framework structure of a device driver configuration method under an embedded system according to a preferred embodiment of the invention. As shown in FIG. 1, in the preferred embodiment, the configuration framework includes a custom file 100, a boot loader 200, and an embedded system 300. The start guide 200 is used to guide the start of the embedded system, and meanwhile, a file processing module 201 corresponding to the custom file 100 is configured in the start guide 200, and the file processing module 201 can respond to the custom file 100 and analyze the file content. The startup director 200 sends the custom file 100 to the memory of the embedded system in the process of booting the embedded system, and at the same time, executes the file processing module 201, and the file processing module 201 extracts the custom file from the memory of the embedded system according to the address given by the system, analyzes the custom file to obtain the driving parameters, then stores the driving parameters into the nonvolatile memory of the embedded system, reconfigures so that the analysis module in the embedded system extracts the driving parameters stored in the nonvolatile memory from the parameter area of the nonvolatile memory, and then implements the driving configuration of the device according to the analyzed file content.
It can be seen that in the preferred embodiment, the custom file 100 is also the medium of the aforementioned solution, and the bridge is a linear process from the custom file 100 to the file processing module and then to the parsing module based on boot.
In actual configuration, the custom file can be regarded as a drive data packet containing drive parameters. The driver data package contains at least one data set containing a set of driver parameters for at least one device of the embedded system. For example, in the preferred embodiment, the data set includes the device name, driver name, and parameter data for a single device. It should be understood that in other embodiments of the present invention, the driving parameters contained in the driving data packet should be adapted according to the type of the peripheral device, and multiple sets of driving parameters of a single device may be contained in one driving data packet, or multiple sets of device drivers may be configured in one driving data packet. The preferred embodiment of the present invention should not be limited by the type of custom file, and the number of device and/or drive parameters contained in the custom file.
The boot may be a boot configured at the configuration end, or a functional module with a boot function. For example, in a preferred embodiment of the present invention, a boot loader is configured to boot the embedded system, and when the embedded system is started, the boot loader sends the custom file to the memory of the embedded system through a serial port or a network interface command, and executes a data processing module included in the boot loader, that is, the file processing module may respond to the driver data packet, that is, the custom file, and analyze the data set in the custom file according to a composition manner or an encryption manner of the custom file, so as to obtain at least one set of device name, driver name, and parameter data of at least one device included in the data set. And then, the data processing module stores the device name, the drive name and the parameter data obtained by analysis into a nonvolatile memory bank at the system end along with the starting of the embedded system.
And the drive analysis module of the embedded system extracts analysis data from the nonvolatile memory bank at the system end, checks the validity of the analysis data and performs drive configuration on equipment according to the analysis data.
Based on this framework, the drive configuration process of the preferred embodiment of the present invention is specifically described. Fig. 2 is a flowchart illustrating a flow of a device driver configuration method under an embedded system according to a preferred embodiment of the present invention. In the preferred embodiment, the device driver configuration method under the embedded system includes the following steps: step S1, before the device is powered on, configuring a custom type driver packet at a configuration end, where the driver packet includes a data set composed of at least one set of device name, driver name, and parameter data of the device; a step S2 of configuring a boot system-side boot loader at the configuration side, where the boot loader boots the system side boot and responds to the drive packet; step S3, configuring a data processing module for the boot loader, where the data processing module responds to the driving data packet and performs parsing processing on the driving data packet to obtain driving parameters of the device, and stores the driving parameters according to a parameter address given by the system; step S4, configuring a driving parsing module at the system end, where the driving parsing module addresses the storage area of the embedded system according to a parameter address given by the system and extracts the driving parameter; step S5, after the device is powered on, executing the boot loader, and sending and storing the drive data packet to a memory of the embedded system; and step S6, executing a system image including a drive at the system end, executing the drive analysis module, and extracting the drive parameter, where the system image configures the device according to the device name, the drive name, and the parameter data included in the drive parameter.
Let us say the drive packet. For the configuration of the driving data packet, the following problems need to be solved:
1) how to include and distinguish individual data in the data set of the drive packet;
2) how to enable the data processing module to correctly identify the driving data packet and realize quick response to the driving data packet;
3) how the data processing module can extract the driving parameters contained in the driving data packet after identifying the driving data packet.
In view of the above problem, in the preferred embodiment, first, the data set in the driving data packet includes a start identifier and an end identifier for identification and response, when the start boot guides the embedded system to start, the data processing module in the start boot identifies the driving data packet according to the start identifier and implements response, and then determines the length of the driving data packet according to the end identifier. The plurality of driving parameters in the data set are separated by preset separators, or the plurality of driving parameters are combined according to a preset encryption mode. For example, in the preferred embodiment of the present invention, the start flag may be <0xf1f1f1f1>, and the end flag may be <0xf1f1f1f >, respectively, the external name of each device is included in "()", the driving name and the parameter value are separated by colon, and the parameter values are separated by semicolon. Correspondingly, the data processing module distinguishes the plurality of driving parameters according to the separators, or decrypts the encrypted driving parameters according to a preset key, so that the equipment name, the driving name and the specific driving parameters are analyzed from the driving data packet.
For convenience of description, the data obtained by the data processing module and including the device name, the driving name, and the parameter data are collectively referred to as driving parameters. And then, after the data processing module analyzes the obtained driving parameters, the driving parameters are stored in a nonvolatile memory bank of the embedded system along with the starting of the system mirror image of the embedded system and are stored according to the parameter address given by the system. Here, the parameter address given by the system may be any address location configured not to conflict with the storage address of other programs and data in the current platform, but usually, an offset address on the nonvolatile memory bank of the embedded system is selected as the parameter storage area.
The drive analysis module in the embedded system preferably addresses the parameter address given by the system according to the starting guide so as to extract the drive parameters stored in the system. And finally, a drive setting module of the embedded system sets the equipment according to the drive parameters.
Accordingly, another aspect of the present invention provides a configuration apparatus for executing the device driver configuration method under the embedded system, where the configuration apparatus includes: the starting guide device is used for guiding the system end to start; the data processing module is used for responding to a driving data packet of a configuration end to obtain driving parameters in the driving data packet and storing the driving parameters into a parameter address; a drive resolution module that extracts the drive parameter from the parameter address; and the drive setting module configures the equipment according to the equipment name, the drive name and the parameter data contained in the drive parameters. In particular, according to embodiments of the application, the processes described above with reference to the flow diagrams may be implemented as computer software programs. For example, embodiments of the present application include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means, or installed from the memory, or installed from the ROM. The computer program, when executed by a processor, performs the above-described functions defined in the methods of embodiments of the present application.
It should be noted that the computer readable medium of the embodiments of the present application may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In embodiments of the application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In embodiments of the present application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the foregoing.
Examples
In this embodiment of the present invention, a concrete implementation of the drive configuration method of the present invention is schematically described by way of example.
In this embodiment, Vxworks is used as an embedded system, and the boot loader is a BootLoader configured at the configuration end. Creating a custom file, containing the name, the driving parameters and the parameter values of the equipment, and writing the custom file into:
<0xf1f1f1f1> (device name) drive name: a parameter value of 1; a parameter value of 2; <0xf1f1f1f >.
And adding a data processing module in the BootLoader, wherein the module responds to the user-defined file according to a preset initial identifier and a preset termination identifier. Under Vxworks, an entry function is configured in a debugging serial port tool, such as tera term, and a data processing module is triggered by inputting the entry function.
In the sending process, if a command of a serial port class transmission file is adopted, a tera term supporting a Y modem protocol is adopted, a load command is adopted in a debugging serial port, and after an address is input, a user-defined file is selected to be sent after being displayed; if the command of the file is transmitted by using the internet access class, a tftpd32 transmission tool supporting protocols such as tftp is used. Inputting 'tftp DrvParam.Txt' and a parameter address given by a system, and transferring the file to the parameter address.
And then, calling an entry function to trigger the data processing module. And after triggering, the data processing module analyzes the user-defined file, reads a file header and file contents, searches and identifies the equipment name, and sends the parameters positioned behind the peripheral name and the numerical values corresponding to the parameters to the offset address of the nonvolatile memory of the embedded system.
Then, the boot loader is started to boot the system mirror image of the embedded system, the drive analysis module of the embedded system reads the name of the corresponding device from the offset address of the nonvolatile memory bank, and if the name of the corresponding device exists, the drive parameters are configured. And if the equipment does not exist, performing drive configuration according to a default value.
The above examples only show some embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.