Ubuntu – How to build a single in-tree kernel module

kernelmodules

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)

Best Answer

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
Related Question