You are not logged in.

#1 2012-03-01 12:10:57

LunaVorax
Member
Registered: 2012-03-01
Posts: 18

How to compile a kernel module without recompiling the whole kernel?

Hi,

I'm pretty sure my question is a bit newbish, still I haven't been able to found any information/solution to my problem in 3days.
The kernel I use doesn't come with the module I need for my hardware and I would like to know if there's a way to compile it without having to make a new kernel myself (since compiling the kernel takes ages on my machine).

Even if your answer is a "Let me Google that for you", I'm so desperate that I'll be happy to see it.

Thank you all in advance for your answers!

Offline

#2 2012-03-01 12:21:11

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,441
Website

Re: How to compile a kernel module without recompiling the whole kernel?

I don't have a direct answer to the question - but what module is it?  Have you checked the AUR?  There are many different kernel compilations already available.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2012-03-01 12:27:54

Gusar
Member
Registered: 2009-08-25
Posts: 3,605

Re: How to compile a kernel module without recompiling the whole kernel?

In general, install the linux-headers package, that will allow you to compile external modules.

However I second Trilby's suggestion of checking AUR. If it's a common module, chances are you'll find it there.

Offline

#4 2012-03-01 12:46:12

LunaVorax
Member
Registered: 2012-03-01
Posts: 18

Re: How to compile a kernel module without recompiling the whole kernel?

Wow that was quick!

The module I'm looking for (among others) is the vt8623fb module.
I already checked the AUR and it doesn't contain the module I'm looking for.

I've also been told to instal the linux-headers... with no further information, so I don't know what does this package do and how to use it to compile modules.

Offline

#5 2012-03-01 13:00:11

ratcheer
Member
Registered: 2011-10-09
Posts: 912

Re: How to compile a kernel module without recompiling the whole kernel?

@LunaVorax, the instructions for compiling the module will vary somewhat from module to module. Each module should have a README file or something similar that tells you how to compile and install it. There may even be instructions to modify some of the module's configuration files based on your needs.

But, in general, you run "make", then "make install", then "modprobe <module_name>". If you are replacing another module that is part of the standard kernel, you may need to blacklist the kernel-supplied module.

But, please do not follow my general instructions. Make sure you find and follow the instructions for your specific module.

Tim

PS - linux-headers is just another package in the standard repository. Install it with pacman.

Last edited by ratcheer (2012-03-01 13:02:32)

Offline

#6 2012-03-01 16:14:20

Blµb
Member
Registered: 2008-02-10
Posts: 224

Re: How to compile a kernel module without recompiling the whole kernel?

Unfortunately this module is not in archlinux' stock kernel, you'll have to at least compile all the modules in drivers/video - which doesn't even take long (just a few seconds).
Archlinux' default kernel comes with every kernel option you need enabled (except svgalib, which is selected by that module and builds a module as well, so you're good)

This might work, but be careful:
1) Fetch the kernel build files (eg: yaourt -G linux)
2) go into the directory containing the PKGBUILD (ie. linux/)
3) type `makepkg -o` to have it fetch and unpack the kernel sources.
(Usually you'd want to apply the provided patches now, but I don't think any of them are required for that module.)
4) Copy the config.x86_64 (or config, if you're on 32 bit) file to src/linux-3.2/.config (NOTE: the dot in the filename)
5) go to src/linux-3.2/
6) Run `make menuconfig` and select the driver from: Device Drivers -> Graphics Support -> Support for frame buffer devices -> VIA VT8623 support
(Make sure you mark it as module (<M>) not as built-in (<*>))
7) Then run `make M=drivers/video`
This will build all the modules in drivers/video (which are only a dozen or so, but running just `make drivers/video/vt8623fb.ko` will give you loads of errors)

You should now have these 2 files you need: drivers/video/vt8623fb.ko and drivers/video/svgalib.ko
8) Copy both to /lib/modules/`uname -r`/kernel/drivers/video
9) Now: `depmod -a`

Now try `modprobe vt8623fb` to see if it loads

Last edited by Blµb (2012-03-01 16:23:13)


You know you're paranoid when you start thinking random letters while typing a password.
A good post about vim
Python has no multithreading.

Offline

#7 2012-03-01 19:05:58

LunaVorax
Member
Registered: 2012-03-01
Posts: 18

Re: How to compile a kernel module without recompiling the whole kernel?

'make M=drivers/video' fails and give me the following error.

WARNING: Symbol version dump /home/lunavorax/linux-libre/src/linux-3.2/Module.symvers
           is missing; modules will have no dependencies and modversions.

  CC      drivers/video/fb_notify.o
/bin/sh: scripts/genksyms/genksyms: Aucun fichier ou dossier de ce type
make[1]: *** [drivers/video/fb_notify.o] Erreur 1
make: *** [_module_drivers/video] Erreur 2

To be honnest I don't really understand what I'm supposed to do here.

Last edited by LunaVorax (2012-03-01 19:07:43)

Offline

#8 2012-03-01 19:27:12

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: How to compile a kernel module without recompiling the whole kernel?


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#9 2012-03-01 19:31:33

LunaVorax
Member
Registered: 2012-03-01
Posts: 18

Re: How to compile a kernel module without recompiling the whole kernel?

Thanks for the link, but this doesn't seems any different from Blµb's instructions. It gives me the same errors.

Offline

#10 2012-03-01 19:32:45

the.ridikulus.rat
Member
From: Indiana, USA
Registered: 2011-10-04
Posts: 765

Re: How to compile a kernel module without recompiling the whole kernel?

https://github.com/the-ridikulus-rat/My … iwlwifi.sh

Modify the src path, kernel ver, module subdir and module name accordingly.

Offline

#11 2012-03-01 19:36:54

LunaVorax
Member
Registered: 2012-03-01
Posts: 18

Re: How to compile a kernel module without recompiling the whole kernel?

Why in the world can't this be simple?

Offline

#12 2012-03-01 20:18:39

vwyodajl
Member
Registered: 2012-01-21
Posts: 183

Re: How to compile a kernel module without recompiling the whole kernel?

It is once you do it and have gone through the process a couple time wink

Offline

#13 2012-03-01 20:33:29

Blµb
Member
Registered: 2008-02-10
Posts: 224

Re: How to compile a kernel module without recompiling the whole kernel?

LunaVorax wrote:

Why in the world can't this be simple?

I actually tried what I posted before to make sure it works...
But I can't really read the errors you posted since I don't speak that language... typical user fail tongue

I didn't get the warning either though.

I'll test with the linux-libre thing.

EDIT:
Okay that the linux-libre kernel actually has this module selected...

I'm wondering though, why use linux-libre? if you use that, you must have the module alreay... if you use the stock kernel though, the modules you build from there might not even be loadable.

EDIT2:
Okay it's possible that the source I was building the modules in wasn't "clean"... the genksym error appears now as well.

EDIT3:
Nope, genksym error doesn't appear with the stock kernel sources, only in linux-libre.

EDIT4: [possible solution]
Do `make prepare` and `make M=scripts` first, then try `make M=drivers/video` again...
this did teh trick in linux-libre for me, also works for the stock sources, they seem to fail after compiling with 'modpost' not found otherwise.
This time I used a completely new checkout of the sources. So it has to work tongue

Last edited by Blµb (2012-03-01 20:55:11)


You know you're paranoid when you start thinking random letters while typing a password.
A good post about vim
Python has no multithreading.

Offline

#14 2012-03-01 22:25:06

LunaVorax
Member
Registered: 2012-03-01
Posts: 18

Re: How to compile a kernel module without recompiling the whole kernel?

Blµb wrote:

I actually tried what I posted before to make sure it works...

I'm sure you did

Blµb wrote:

But I can't really read the errors you posted since I don't speak that language... typical user fail tongue

I made the mistake not to translate the output. Still the only words in French here are "Error" and "No such file or directory". Even Google Translate can understand it so I don't see where the fail is but I'll assume you have no idea what French is supposed to look like.

Blµb wrote:

Do `make prepare` and `make M=scripts` first, then try `make M=drivers/video` again...

I already tried with "make prepare" first but not with "make M=scripts", this apparently fixed the problem, modules are compiling right now.

EDIT:
Too bad, that was too easy to be true.
Everything compiled correctly but when I try to "modprobe vt8623fb" I get the following error:

ERROR: could not insert 'vt8623fb': Exec format error

Last edited by LunaVorax (2012-03-01 22:39:15)

Offline

#15 2012-03-01 23:23:43

Avant-texte
Member
Registered: 2012-02-13
Posts: 136

Re: How to compile a kernel module without recompiling the whole kernel?

You might already be beyond this, but here are some intro links to compiling modules.

http://www.cyberciti.biz/tips/compiling … odule.html
http://www.cyberciti.biz/tips/build-lin … -tree.html

Offline

#16 2012-03-01 23:25:19

LunaVorax
Member
Registered: 2012-03-01
Posts: 18

Re: How to compile a kernel module without recompiling the whole kernel?

Thank you for theses links! That's always welcome!

Offline

#17 2012-03-02 09:14:45

Blµb
Member
Registered: 2008-02-10
Posts: 224

Re: How to compile a kernel module without recompiling the whole kernel?

So which kernel do you actually use? Like I said earlier, if you're not using linux-libre, the modules might not be loadable since the're using a different config.
Or are from a different version.
The point is, modules have to be compiled against your kernel / kernel headers. So in order for a native module to build, you have to make sure you use a copy of the sources of the very kernel you're using.
Which obviously isn't from the linux-libre package since if that was the case, you'd already have the module you need.

Last edited by Blµb (2012-03-02 09:16:19)


You know you're paranoid when you start thinking random letters while typing a password.
A good post about vim
Python has no multithreading.

Offline

#18 2012-03-02 10:58:39

LunaVorax
Member
Registered: 2012-03-01
Posts: 18

Re: How to compile a kernel module without recompiling the whole kernel?

Sorry I missed that. I am indeed using the Linux-Libre kernel (and having the Linux-Libre headers etc...).
I am doing everything correctly (at least it seems like).

Offline

#19 2012-03-02 13:25:25

Blµb
Member
Registered: 2008-02-10
Posts: 224

Re: How to compile a kernel module without recompiling the whole kernel?

But then you should have the module you mentioned already yikes
Or maybe the packages has been changed since you installed it.


You know you're paranoid when you start thinking random letters while typing a password.
A good post about vim
Python has no multithreading.

Offline

#20 2012-03-02 14:12:04

LunaVorax
Member
Registered: 2012-03-01
Posts: 18

Re: How to compile a kernel module without recompiling the whole kernel?

My bad, I didn't told you that I was using the linux-libre package from the Parabola repository. They removed this module from their kernel not so long ago and have no plans to put it back.

Offline

#21 2012-03-02 14:59:50

Blµb
Member
Registered: 2008-02-10
Posts: 224

Re: How to compile a kernel module without recompiling the whole kernel?

Do you have a /proc/config.gz that you could use? Otherwise I don't know. I mean, many modules should be compilable simply with the system-installed kernel headers, but not all native modules might follow that rule.
Unfortunatel most of what you find on the web talks about how to create new modules which can be compild against the installed kernel tree, not about how to compile one of the native kernel modules against it.

Actually, try what those links suggest.
Skip the configuration part, and just do:
make -C /lib/modules/`uname -r`/build M=$(PWD)/drivers/video modules

(maybe `make -C /lib/modules/`uname -r`/build M=$(PWD)/drivers/video clean` first tongue)

EDIT: Meh, that uses your config and won't build that driver... there must be some way though
EDIT2: Try:
make -C /lib/modules/`uname -r`/build M=$(PWD)/drivers/video modules CONFIG_FB_VT8623=m CONFIG_FB_SVGALIB=m

The problem though is, that they might have removed some of the dependencies of the module, so if it doesn't compile, you'll have to recompile the kernel.
Good thing is though, you can use their .config as base (found in /usr/src/linux-..../.config)
You can also check if your config "supports" your module by putting it into the kernel source tree, running `make menuconfig` and typing /8623 and pressing enter.
The last line in that screen should read:
Selects: <list of options>
As long as all of those options are either =y or =m, you're good. SVGALIB can be =n because it's part of drivers/video/ and you can compile it together with  your module.

Last edited by Blµb (2012-03-02 15:14:16)


You know you're paranoid when you start thinking random letters while typing a password.
A good post about vim
Python has no multithreading.

Offline

Board footer

Powered by FluxBB