Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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)

share|improve this question
    
please close as duplicate of 14627. answer of user 'Radu C' answers the question. –  mab Sep 3 '12 at 15:49

2 Answers 2

up vote 5 down vote accepted

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
share|improve this answer
    
I'm not sure if SUBDIRS is still correct. It was ignored for me. After reading kernel.org/doc/Documentation/kbuild/modules.txt I tried using make M=/path/to/module which seemed to work. –  harmic Sep 17 at 12:44

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
share|improve this answer
    
Just doing: make drivers/net/can/usb/peak_usb/pcan_usb.ko did only build pcan_usb.o. Doing make drivers/net/can/usb/peak_usb/ && make drivers/net/can/usb/peak_usb/pcan_usb.ko compiles it, but insmod complains Error: could not insert module drivers/net/can/usb/peak_usb/peak_usb.ko: Invalid module format. dmesg: peak_usb: no symbol version for module_layout –  mab Jul 29 '12 at 18:38
    
Are you running that specific kernel, and have you already compiled the kernel once? Please try with modprobe also. –  izx Aug 9 '12 at 23:44
    
I am running the packaged kernel. Compiling the complete kernel works. but I am trying to not compile the complete kernel, just the specific kernel module. Is there a make target that 'prepares' a single module compilation? modprobe shows the same error. –  mab Aug 13 '12 at 14:08
    
According to stackoverflow you can just use make modules SUBDIRS=drivers/net/can/usb/peak_usb or any other subdir. It works fine here. –  Treviño Jul 13 '13 at 17:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.