How do I build a single in-tree kernel module?
The linux-source-... has a module which is disabled in the config /boot/config-3.4-trunk-686-pae so that it is not part of linux-image-... (This is on Debian, but the solution should be the same for Ubuntu, or?), e.g.
# CONFIG_CAN_PEAK_USB is not set
How would one compile just that kernel module, so that it can be used with the distributed kernel?
The respective linux-source-... package is already installed, uncompressed and linked to /usr/src/linux. /boot/config-3.4-trunk-686-pae is copied to /usr/src/linux/.config and modified with
CONFIG_CAN_PEAK_USB=m
With
make
make modules
it is possible to compile the kernel and all modules. But how would one compile only that specific single module?
(Note: also the kernel needs to be compiled before, otherwise you get the following error: no symbol version for module_layout
)
I had the same problem. I assume that you need not only to copy .config but also Module.symvers
my steps to compile module ft1000 (running Debian Wheeze 7.1.0; kernel 3.2.0-4-686-pae):
aptitude install linux-headers-3.2.0-4-686-pae
aptitude install linux-source-3.2
cd /usr/src/
tar xjf linux-source-3.2.tar.bz2
cd /usr/src/linux-source-3.2
cp ../linux-headers-3.2.0-4-686-pae/Module.symvers .
make oldconfig # it copies .config to ./
vi .config # enable ft1000 module: CONFIG_FT1000=m
make prepare # setup FT1000 as module
make modules_prepare
make SUBDIRS=scripts/mod
make SUBDIRS=drivers/staging/ft1000/ft1000-usb modules
cp drivers/staging/ft1000/ft1000-usb/ft1000.ko /lib/modules/3.2.0-4-686-pae/kernel
/drivers/staging/
depmod
modprobe ft1000
From within the top-level source directory, simply give make the path to the module name or module directory, e.g.:
make drivers/net/can/usb/peak_usb/
or for a simpler example (Intel e1000 Ethernet driver):
make drivers/net/ethernet/intel/e1000/e1000.ko
As simple as : (this example illustrate ft1000 driver, this should take just few minutes if not instants)
cd /usr/src/kernel-sources
make SUBDIRS=drivers/staging/ft1000/ft1000-usb modules
# Enable the ft1000 module: CONFIG_FT1000=m on the config with
make xconfig # or "make menuconfig" then save
make prepare
make modules_prepare
make SUBDIRS=scripts/mod
make SUBDIRS=drivers/staging/ft1000/ft1000-usb modules
make SUBDIRS=drivers/staging/ft1000/ft1000-usb modules_install
You can then load the module with modprobe
after depmod
Note : depending on the module dependency you may need to rebuild the kernel entirely