Sunday, September 9, 2012

Building a single kernel module on Debian.

I was trying to build snd-seq-oss.ko so I could run the old playmidi that requires OSS /dev/sequencer, but when I did the insmod I got a -1 "Invalid module format" and dmesg showed "snd_seq_oss: no symbol version for module_layout".

I found out the problem was that since I am building just the module not the kernel, I need the Module.symvers from the distro's kernel.  So the solution in this case was to install linux-headers-2.6.32-5-686 and copy the Module.symvers from there.

There's probably other ways to do it but that is what worked for me.  See steps below for future reference.

sudo -i
apt-get install linux-headers-2.6.32-5-686 linux-source-2.6.32
cd /usr/src
tar -jvxf linux-source-2.6.32.tar.bz2
ln -s linux-source-2.6.32 linux
cd linux
cp ../linux-headers-2.6.32-5-686/Module.symvers .
cp /boot/config-2.6.32-5-686 .config
   (modify .config as desired)
make oldconfig
make prepare
make modules_prepare
make SUBDIRS=scripts/mod
make SUBDIRS=path/to/module modules