LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 08-04-2008, 02:42 PM   #1
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Rep: Reputation: 49
Compiling a module separately without compiling entire kernel


I just compiled a 2.6.26 kernel and installed on my Debian etch system.

Now I just realized that I need one more module in the kernel. I can get the module by copying a file called testlpp.c in the usr/src/linux/drivers/char/ directory and then compiling it. The module is called LPPTEST. Basically there is the PREEMPT_RT patch that gives this module.


How can I just compile this module and install it without compiling the entire kernel? I have copied the file testlpp.c in the drivers/char/ directory.

Thanks
 
Old 08-05-2008, 08:14 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Tried 'make M=drivers/char/'?
 
Old 08-05-2008, 02:31 PM   #3
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Original Poster
Rep: Reputation: 49
Quote:
Originally Posted by unSpawn View Post
Tried 'make M=drivers/char/'?
I tried what you suggested and I got loads of errors..I was not able to caputre the first error because the screen scrolled too fast and since there were so many errors the first error is not in the terminal's memory anymore i.e. even if I scroll up I cannot see the first error.

I have uploaded the file lpptest.c here.

Thanks.
 
Old 08-05-2008, 02:39 PM   #4
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
Put your driver source in a separate directory, including any .h files that go with it (usually you won't get away with just a .c file) and make it with this makefile (which you can copy into a file named Makefile).

Code:
obj-m := lpptest.o
KDIR    := /lib/modules/$(shell uname -r)/build
PWD    := $(shell pwd)

default:
        $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
This is the standard makefile structure for kernel modules.

After making it, just copy it into the directory you want it in, then you can insert it into the kernel.
 
Old 08-05-2008, 02:53 PM   #5
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Original Poster
Rep: Reputation: 49
Quote:
Originally Posted by jiml8 View Post
Put your driver source in a separate directory, including any .h files that go with it (usually you won't get away with just a .c file) and make it with this makefile (which you can copy into a file named Makefile).

Code:
obj-m := lpptest.o
KDIR    := /lib/modules/$(shell uname -r)/build
PWD    := $(shell pwd)

default:
        $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
This is the standard makefile structure for kernel modules.

After making it, just copy it into the directory you want it in, then you can insert it into the kernel.

Thanks for your input. Does the line
Code:
KDIR    := /lib/modules/$(shell uname -r)/build
means that I need to have kernel headers also installed?
 
Old 08-05-2008, 06:18 PM   #6
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
Of course.
 
Old 08-05-2008, 07:28 PM   #7
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Original Poster
Rep: Reputation: 49
Quote:
Originally Posted by jiml8 View Post
Of course.
I think I am very close to compile the module successfully. I got a warning message:
Code:
debian:/usr/src/lpptest# make
make -C /lib/modules/2.6.26-1-486/build SUBDIRS=/usr/src/lpptest modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.26-1-486'
  CC [M]  /usr/src/lpptest/lpptest.o
  Building modules, stage 2.
  MODPOST 1 modules
WARNING: "irq_desc" [/usr/src/lpptest/lpptest.ko] undefined!
  LD [M]  /usr/src/lpptest/lpptest.ko
make[1]: Leaving directory `/usr/src/linux-headers-2.6.26-1-486'
debian:/usr/src/lpptest#
I check for the "irq_desc" in the include files and it seems that #include <linux/irq.h> file has the definition of the structure irq_desc. Wonder why it is still saying that irq_desc is undefined.

I have uploaded the irq.h file here.
 
Old 08-06-2008, 01:29 AM   #8
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
Will the module load into the kernel? Try insmod.
 
Old 08-06-2008, 01:45 AM   #9
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Original Poster
Rep: Reputation: 49
Quote:
Originally Posted by jiml8 View Post
Will the module load into the kernel? Try insmod.
No, unfortunately, the module does not load because of that warning message.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help me in compiling kernel module swift_a2002 Programming 1 05-05-2007 02:28 PM
how to complie a kernel module separately jesonlay Linux - Software 1 05-04-2007 09:00 AM
Compiling modules separately Alex_jacobson Linux - General 2 03-11-2005 01:43 AM
Compiling a module/Kernel mismatch fbarre Linux - Newbie 2 09-04-2003 08:26 PM
Kernel compiling and module compiling tarballed Linux - General 1 12-22-2002 05:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 02:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration