How do I build a single in-tree kernel module?

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

Tags:

Kernel

Modules