Notes: Kernel Modules
Get the source:
#: sudo apt-get source linux
Get the headers with Module.symvers:
Unpackage source and modify files:
After you build the kernel modifications, or copy the symvers from header. Note, this is not a necessary step.
Copy the config (if it has the module included):
Else if the module is not available (in the Module.symvers file or config), then you must create a config that will build the module.
And build:
To install:
If you want to unload the module either use rmmod or modprobe -r $module-name
Other Notes:
depmod will traverse the dependencies in /lib/modules/`uname -r`/kernel
this is so you can use modinfo $module-name to reference it
otherwise, insmod will also install the module but it will ignore dependencies... if you do not build the module with Module.symver ...then, you will not have any version info with the compiled module.
#: sudo apt-get linux-image-$(uname -r)
Unpackage source and modify files:
#: cd ~/
#: sudo tar -xvf linux*.tar.gz
#: sudo tar -xvf linux*.tar.gz
After you build the kernel modifications, or copy the symvers from header. Note, this is not a necessary step.
#: cd /usr/src
#: sudo cp -p linux-headers-*/Module.symvers ~/linux-x.x
#: sudo cp -p linux-headers-*/Module.symvers ~/linux-x.x
Copy the config (if it has the module included):
#: cd ~/linux-x.x
#: sudo cp -p linux-headers-*/.config .
Else if the module is not available (in the Module.symvers file or config), then you must create a config that will build the module.
#: cd ~/linux-x.x
#: make menuconfig
Example I needed ov534:
Device Drivers -> Multimedia Support -> Media USB Adapters -> GSPCA base Webcams -> OV534 OV772x (should have M for module)
Save file: .config
#: make menuconfig
Example I needed ov534:
Device Drivers -> Multimedia Support -> Media USB Adapters -> GSPCA base Webcams -> OV534 OV772x (should have M for module)
Save file: .config
And build:
#: cd ~/linux-x.x
#: make prepare
#: make modules_prepare
#: make SUBDIRS=drivers/media/usb/gspca modules
#: make prepare
#: make modules_prepare
#: make SUBDIRS=drivers/media/usb/gspca modules
To install:
#: cd ~/linux-x.x
#: sudo cp -p drivers/media/usb/gspca/gspca_ov534.ko /lib/modules/`uname -r`/kernel/drivers/media/usb/gspca/gspca_ov534.ko
#: sudo depmod
#: sudo modprobe gspca-ov534
#: sudo cp -p drivers/media/usb/gspca/gspca_ov534.ko /lib/modules/`uname -r`/kernel/drivers/media/usb/gspca/gspca_ov534.ko
#: sudo depmod
#: sudo modprobe gspca-ov534
Other Notes:
depmod will traverse the dependencies in /lib/modules/`uname -r`/kernel
this is so you can use modinfo $module-name to reference it
otherwise, insmod will also install the module but it will ignore dependencies... if you do not build the module with Module.symver ...then, you will not have any version info with the compiled module.
No comments:
Post a Comment