Page 1 of 1

How to compile a kernel module?

Posted: Mon 10 Jul 2017, 16:01
by PappyPuppy
I need to start somewhere on a fairly mysterious and complex topic.

#1. I just need to recompile a single kernel module for Linux.

#2. I have all the source files I need and there is a Makefile and KConfig files in the directory.

#3. If I go to that directory and type the command: make thefile.ko, I get an error:

make: *** No rule to make target 'thefile.ko'. Stop.

So then there is no real recipes in there to convert .c/.asm files into their .o or .ko counterparts. Firstly, why? And secondly, what needs to be done to get those rules in there?

If there is a document or readme that describes this, please point me to it. But numerous Linux distros have this style of make and the files are quite similar.

Any help appreciated.
:)

I'm starting to understand

Posted: Mon 10 Jul 2017, 16:51
by PappyPuppy
I have now found the build flags in the directory a few above my drivers, in the 3.10.0-327.el7.x86_64 direcdtory.

It starts with VERSION = 3
PATCHLEVE = 10, etc..

So perhaps I just need to navigate to that directory and run the make.

I am geting some info from the make help command

Posted: Mon 10 Jul 2017, 17:04
by PappyPuppy
I'll try to descend into the directory by specifying it.

If I run the command make help, it gives a recipe for how to navigate to a directory in the make, as in make dir/....

It doesn't work

Posted: Mon 10 Jul 2017, 17:13
by PappyPuppy
make /pathtomydrive/mydriver.ko, I get an error

make[1]: *** NO rule to make target /usr/src/kernels/3.10.0-327.el7.x86_64/arch/x86/syscalls/syscall_32.tbl', needed by etc..

It doesn't behave the way the help file makes it seem.

Someone posted Hans Reenickec's rpm file

Posted: Mon 10 Jul 2017, 17:44
by PappyPuppy
Let's hope

Posted: Mon 10 Jul 2017, 18:45
by Keef
You just need to type 'make' on its own. It will be (should be) in the right place to find the source files.

I have the rpm files installed now

Posted: Mon 10 Jul 2017, 20:16
by PappyPuppy
So far no matter what I type, it errors out on arch/x86 directory. I have only one direcxtory populated iwth source code, the aic7xxx. All others are empty, othe than having the source files. But for now, I'll use the driver someone found for me. It seems to be working. I just cannot find a way to get power to the tape drive. I can't find any cables that reach and I don't have connectors so I'm scrounging right now.
Keef wrote:You just need to type 'make' on its own. It will be (should be) in the right place to find the source files.

I scrounged up some power from an old PC/coffee table

Posted: Mon 10 Jul 2017, 23:46
by PappyPuppy
So I can delay any driver work now that my machine has detected the tape drive.

Posted: Tue 11 Jul 2017, 19:15
by Sailor Enceladus
Since this seems to be a general "how do you compile a kernel module" thread, here is how peebee compiled the broadcom_wl driver:
http://www.murga-linux.com/puppy/viewto ... 946#884946