LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-20-2008, 02:49 PM   #1
kscott121
Member
 
Registered: Jul 2003
Location: NC
Distribution: Fedora,Mepis,Debian
Posts: 84

Rep: Reputation: 15
How to recompile an existing module? ? ?


I am trying to use a USB-to-serial converter by prolific. The appropriate driver should be pl2303 which is in the 2.6 kernel I am using. The vend# (067b) IS in the driver but the prod# (0609) is NOT presently in the driver so it isn't recognized. I'd like to add the new prod # to the pl2303.h file and recompile but I cannot figure out how to go about this.
I made sure the kernel headers package is installed but when I go look at the pl2303.h file it is Zero (0) bytes as are many other present but empty header files (2.6.18 kernel MEPIS). Ditto for an ubuntu system (2.6.20 kernel).
Similarly when I try to look at the pl2303.h file on a FC6 (2.6.18 kernel) system , it is not present at all but there is a pl2303/module.h file located as below which contains a single line:
#cat \ /usr/src/linux-headers-2.6.15-27-desktop64-smp/include/config/usb/serial/pl2303/module.h
#define CONFIG_USB_SERIAL_PL2303_MODULE 1

So I am unsure about
1) how can I add the appropriate product codes to a pl2303.h file that I can't find?
2) if I do find them where do I put the pl2303.c file and the pl2303.h files, and
3) how to setup the supposedly easy and built-in kbuild system for building modules?

Thanks in advance for your help!!
Ken
 
Old 06-21-2008, 08:49 AM   #2
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
You need the full kernel source to recompile a module:

apt-cache search linux-source

linux-source-2.6.25
linux-tree-2.6.25
linux-patch-debian-2.6.25

So what does that all mean? Well, ignore the 'linux-patch' one - you want the 'source' and the 'tree'. The 'tree' helps you work out what patches to roll back to get the source corresponding to the kernel image you want to build for.
 
Old 06-21-2008, 12:55 PM   #3
kscott121
Member
 
Registered: Jul 2003
Location: NC
Distribution: Fedora,Mepis,Debian
Posts: 84

Original Poster
Rep: Reputation: 15
Penniped, Thanks.
Ok,
I put those in but the sources are still (even after installing them using the synaptic package manager) in a tar.bz2 file. Is that ok or dod I need to extract them somehow.

linux-source-2.6.25
linux-tree-2.6.25
linux-patch-debian-2.6.25

Next I 'll change the pl2303.c and pl2303.h files st include the necessary vend/prod #s.

Then the mystery. What are the necessary commands to recompile the actiual driver and where does the make file come from?

KScott
 
Old 06-21-2008, 07:06 PM   #4
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
Hmm... if the sources are in "tar.bz2" format then maybe you need the -patches one after all. I'm a bit confused at the moment since Debian has obviously changed things since I last compiled a kernel; maybe the official Debian docs will have a good explanation of the -source -tree -patches thing.

You do need to unpack the source code, but before you do, just find out if it will automatically create a sensible directory:

tar --list -j --file your_tar_bz2_file.tar.bz2 | less

You don't want to unpack a tarball to discover that it creates a thousand files in your current directory.

You will also want to install 'kernel-kbuild' (I have kernel-kbuild-2.6-3) ; you don't want to reconfigure and rebuild the entire kernel just for 1 module.

apt-cache search kernel-kbuild

Last edited by pinniped; 06-21-2008 at 07:14 PM.
 
Old 06-21-2008, 09:56 PM   #5
kscott121
Member
 
Registered: Jul 2003
Location: NC
Distribution: Fedora,Mepis,Debian
Posts: 84

Original Poster
Rep: Reputation: 15
Pinniped,
The system is a MEPIS actually (which is a confusing mix of debian and ubuntu )
kens@4[pl2303]$ cat /etc/issue
The Magic of MEPIS TM
kens@4[pl2303]$ uname -a
Linux mepis65 2.6.15-27-desktop64-smp #1 SMP PREEMPT Mon Mar 12 22:09:42 EDT 2007 x86_64 GNU/Linux

When I search for kbuild (in synaptic) I only get three uninstalled packages related to vdkbuilder2 but nothing installed or available for just kbuild?!
also,
kens@4[pl2303]$ dpkg -l | grep kernel | grep 2.4.27
ii kernel-patch-debian-2.4.27 2.4.27-12 Debian patches to Linux 2.4.27
ii kernel-source-2.4.27 2.4.27-12 Linux kernel source for version 2.4.27 with Debi
ii kernel-tree-2.4.27 2.4.27-12 Linux kernel source tree for building Debian ker

The command:
tar --list -j --file /usr/src/linux-source-2.6.15.tar.bz2 | less
Gives a huge list of files but no obvious info about where they should be put. I presume /usr/src)?

I modified the pl2303.c and .h files and built a makefile and this is what I got when I tried 'make':
(probably doesn't work because I haven't yet extracted all the sources???)

kens@4[pl2303]$ ls
Makefile Makefile~ pl2303.c pl2303.c0 pl2303.c.0 pl2303.c1 pl2303.h pl2303.h0 pl2303.h.0 pl2303.h1
kens@4[pl2303]$ cat Makefile
obj-m := pl2303.o
#FILES = pl2303.c pl2303.h
KDIR := /lib/modules/2.6.15-27-desktop64-smp
PWD := /home/kens/Desktop/pl2303
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
$(RM) .*.cmd *.mod.c *.o *.ko -r .tmp*
kens@4[pl2303]$ make
make -C /lib/modules/2.6.15-27-desktop64-smp SUBDIRS=/home/kens/Desktop/pl2303 modules
make[1]: Entering directory `/lib/modules/2.6.15-27-desktop64-smp'
make[1]: *** No rule to make target `modules'. Stop.
make[1]: Leaving directory `/lib/modules/2.6.15-27-desktop64-smp'
make: *** [default] Error 2
kens@4[pl2303]$
kens@4[pl2303]$ ls /usr/src
kernel-patches linux-headers-2.6.15-27 linux-source-2.6.15.tar.bz2
kernel-source-2.4.27.tar.bz2 linux-headers-2.6.15-27-desktop64-smp rpm
kens@4[pl2303]$ apt-cache search kernel-kbuild # returns nothing....
kens@4[pl2303]$

Any great (or not so great ideas) as to if I am on the right track?
Thanks in advance.
Ken
 
Old 06-22-2008, 12:01 AM   #6
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
"The command:
tar --list -j --file /usr/src/linux-source-2.6.15.tar.bz2 | less
Gives a huge list of files but no obvious info about where they should be put. I presume /usr/src)?"

You can unpack it anywhere you want. /usr/src/ is convenient, but managing the file permissions etc can be a nuisance. You might create a "kernels" directory in your home directory instead. You should only need root privileges to install the module (copy the module to the final place and run 'update-modules').

You're going about the 'make' the wrong way - the way you attempted requires you to configure and build the entire kernel. You don't want that because you'll struggle with the version information. See if synaptic can find 'kernel-kbuild' since it makes it easier for you to build a module with just the 'kernel-headers' and the module source. According to the Debian package:

"This package provides kbuild tools for Linux kernel 2.6. It is used together with the kernel-headers packages to build out-of-tree kernel modules."
 
Old 06-22-2008, 12:36 AM   #7
alan_ri
Senior Member
 
Registered: Dec 2007
Location: Croatia
Distribution: Debian GNU/Linux
Posts: 1,733
Blog Entries: 5

Rep: Reputation: 127Reputation: 127
Quote:
Originally Posted by kscott121 View Post
The vend# (067b) IS in the driver but the prod# (0609) is NOT presently in the driver so it isn't recognized. I'd like to add the new prod # to the pl2303.h file and recompile but I cannot figure out how to go about this.
Again I have to log out when I find something interesting.Quick answer;why don't you get source code of that driver/module and add what you want.Verify that the source code for your current kernel version is installed.If you don't have a /usr/include/linux/version.h file, do cd /usr/src/linux; make include/linux/version.h.Copy the driver source code to a source directory. Usually it's used /usr/src/modules/driver.c.Compile the file using the compile-command at the bottom of the driver source file. If a compile-command is not there use the following compile command:gcc -DMODULE -D__KERNEL__ -O6 -c driver.c.As 'root', test the module by doing "insmod driver.o". Install the driver module in the proper location for your distribution. This is usually /lib/modules/kernel-version/net/driver.o. for example.The command to do this is ; install -m 644 driver.o /lib/modules/`uname -r`/net/. If you get a "modversions.h not found" message when compiling the driver, delete '-DMODVERSIONS' from the command used to compile the driver module.As 'root', load the module using "insmod driver.o".
 
Old 06-23-2008, 04:32 PM   #8
kscott121
Member
 
Registered: Jul 2003
Location: NC
Distribution: Fedora,Mepis,Debian
Posts: 84

Original Poster
Rep: Reputation: 15
I can find no kbuild info (or packages ) on any of the three systems I'm testing on. What do you suggest I do about that?

I changed the pl2303.c and .h files as needed and tried the make command as follows:

kens@4[pl2303]$ gcc -DMODULE -D__KERNEL__ -O6 -c pl2303.c
In file included from pl2303.c:17:
/usr/include/linux/config.h:1:2: error: #error "Compilation aborted. Please read the FAQ for linux-libc-headers package."
/usr/include/linux/config.h:2:2: error: #error "(can be found at http://ep09.pld-linux.org/~mmazur/linux-libc-headers/doc/)"
pl2303.c:21:24: error: linux/slab.h: No such file or directory
pl2303.c:23:30: error: linux/tty_driver.h: No such file or directory
pl2303.c:24:28: error: linux/tty_flip.h: No such file or directory
In file included from /usr/include/linux/sched.h:16,
from /usr/include/linux/module.h:9,
from pl2303.c:26:
/usr/include/linux/signal.h:2:2: warning: #warning "You should include <signal.h>. This time I will do it for you."
In file included from /usr/include/linux/resource.h:4,
from /usr/include/linux/sched.h:79,
from /usr/include/linux/module.h:9,
from pl2303.c:26:
/usr/include/linux/time.h:9: error: redefinition of 'struct timespec'
/usr/include/linux/time.h:15: error: redefinition of 'struct timeval'
/usr/include/linux/time.h:20: error: redefinition of 'struct timezone'
/usr/include/linux/time.h:47: error: redefinition of 'struct itimerval'
In file included from pl2303.c:26:
/usr/include/linux/module.h:41: error: field 'attr' has incomplete type
/usr/include/linux/module.h:49: error: field 'kobj' has incomplete type
In file included from /usr/include/linux/spinlock.h:1,
from pl2303.c:28:
/usr/include/linux/err_kernel_only.h:1:2: error: #error Kernel only header included in userspace
pl2303.c:29:25: error: asm/uaccess.h: No such file or directory
pl2303.c:31:24: error: usb-serial.h: No such file or directory
pl2303.c:46: warning: parameter names (without types) in function declaration
pl2303.c:55: error: array type has incomplete element type
pl2303.c:86: error: variable 'pl2303_driver' has initializer but incomplete type
pl2303.c:87: error: unknown field 'owner' specified in initializer
pl2303.c:87: warning: excess elements in struct initializer
pl2303.c:87: warning: (near initialization for 'pl2303_driver')
pl2303.c:88: error: unknown field 'name' specified in initializer
pl2303.c:88: warning: excess elements in struct initializer
pl2303.c:88: warning: (near initialization for 'pl2303_driver')
pl2303.c:89: error: unknown field 'probe' specified in initializer
pl2303.c:89: error: 'usb_serial_probe' undeclared here (not in a function)
pl2303.c:89: warning: excess elements in struct initializer
pl2303.c:89: warning: (near initialization for 'pl2303_driver')
. . . . . .
(remainder of make output has many more errors - nearly one err per line.)
Ken
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
module problems after recompile slinky2004 Linux - General 3 10-25-2005 10:59 AM
Module issues after recompile Glock Shooter Linux - General 1 03-07-2005 05:48 PM
not recompile kernel, but 1 module -possible? deNiro Debian 4 01-31-2005 04:48 PM
Kernel / module recompile for 5.1 ? how ? Wynand1 Linux - Newbie 6 03-09-2004 02:33 AM
recompile module taoweijia Linux - Newbie 1 09-22-2003 12:55 PM

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

All times are GMT -5. The time now is 11:56 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration