Is there any way to install a Linux device driver without connecting the device?
I have complete access to the driver code. I’m using Linux Kernel 2.6.35.
I have tried insmod and modprobe to no avail. I am working on a custom driver (I didn’t write it) but there isn’t any documentation.
A properly written device driver should not install when no instances of the device exist in the system (hot-pluggable device might be an exception). In some versions of Unix the probe() function of the driver checks if the device is present. In Linux the probe functionality is often incorporated into the _init() routine. When no hardware is detected, the driver should not register itself, and return status that would cause it to be unloaded if it is a module.
If you insist on having the driver code in memory, then don’t build it as a loadable module, but rather select the Linux driver to be part of the memory-resident kernel. Building a driver as a loadable module is selected by typing an “M” in the
menuconfigprogram. To have the driver built into the kernel, use the space bar to select the driver. The selection will be marked with an asterisk*rather than anMto indicate this difference.(The text for this
menuconfigdialog comes fromKconfigfiles. The product of this configuration dialog is the.configfile, which has configuration symbols that are used inMakefiles to control the compilation of object files. The previous assumes that this driver has been incorporated into the Linux kernel source code tree. If all you have is the source code file, then you’ll have to decide where in the source tree this driver fits. You then might be able to manually edit aMakefileto unconditionally compile the driver in that appropriate sub-directory. Or customize theKconfigandMakefilefiles with a configuration variable for this driver.)To keep all of the driver’s code resident, you will have to make some minor code changes. Normally the initialization code and data are placed in text and data sections separate from “ordinary” text and data, and this memory section is freed once the kernel has finished booting. To prevent any driver code and data from being freed, remove the
__initand__exitsection specifiers in declarations.Of course you will have to build a new kernel binary in order to incorporate this device driver. You should try to use the previous build’s
.configfile before adding the driver.