Update single kernel module / driver
One warning: There is no gurantee, that the new driver version is compatible with the old kernel. But it is worth a try.
-
Find the newer driver in the kernel. There are two options: You can use the original kernel driver from the kernel git, for example in https://github.com/torvalds/linux/tree/master/drivers. It is handy to select a tag to find the specific kernel version you need. Download the specific
thedriver.h
andthedriver.c
files and put them into a new directory.The second option is to fetch Ubuntu's new kernel from http://packages.ubuntu.com or via
apt-get source ...
Install the packages
build-essentials
and thelinux-kernel-headers
-
Now we create a makefile for this single module as shown on cyberciti.biz,
thedriver.o
has to be replaced by the driver name. In the folder which contains the driver code, create a fileMakefile
with the following content:obj-m += thedriver.o all: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules clean: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
Now, in this directory, type
make
to compile the driver.If everything works well, a
thedriver.ko
file should have been created that can be placed into the folder/lib/modules/$kernelversion/kernel/drivers
(do not forget to create a backup)
Related videos on Youtube
Alex
Updated on September 18, 2022Comments
-
Alex over 1 year
I needed a newer version of a Kernel module in an quite old kernel.
How can I replace a single kernel module of the mainstream linux kernel and compile only this module?