How to compile a kernel module?

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
PappyPuppy
Posts: 409
Joined: Sat 01 Oct 2016, 00:27

How to compile a kernel module?

#1 Post 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.
:)

PappyPuppy
Posts: 409
Joined: Sat 01 Oct 2016, 00:27

I'm starting to understand

#2 Post 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.

PappyPuppy
Posts: 409
Joined: Sat 01 Oct 2016, 00:27

I am geting some info from the make help command

#3 Post 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/....

PappyPuppy
Posts: 409
Joined: Sat 01 Oct 2016, 00:27

It doesn't work

#4 Post 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.

PappyPuppy
Posts: 409
Joined: Sat 01 Oct 2016, 00:27

Someone posted Hans Reenickec's rpm file

#5 Post by PappyPuppy »

Let's hope

User avatar
Keef
Posts: 987
Joined: Thu 20 Dec 2007, 22:12
Location: Staffordshire

#6 Post 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.

PappyPuppy
Posts: 409
Joined: Sat 01 Oct 2016, 00:27

I have the rpm files installed now

#7 Post 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.

PappyPuppy
Posts: 409
Joined: Sat 01 Oct 2016, 00:27

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

#8 Post by PappyPuppy »

So I can delay any driver work now that my machine has detected the tape drive.

Sailor Enceladus
Posts: 1543
Joined: Mon 22 Feb 2016, 19:43

#9 Post 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

Post Reply