Compile driver, get error!?!
margie crews
plug-devel@lists.PLUG.phoenix.az.us
Sat Oct 25 18:46:02 2003
Remove this email address from your list !!
-----Original Message-----
From: plug-devel-admin@lists.PLUG.phoenix.az.us
[mailto:plug-devel-admin@lists.PLUG.phoenix.az.us] On Behalf Of Bob
Cober
Sent: Saturday, October 25, 2003 2:30 AM
To: plug-devel@lists.plug.phoenix.az.us
Subject: Re: Compile driver, get error!?!
Alan Dayley wrote:
> On Thursday 23 October 2003 10:19 am, Alan Dayley wrote:
>
> I have compiled drivers before but this one is giving me a pain.
>
> - I recompiled the st.o (SCSI tape) driver by doing "make
> drivers/scsi/st.o" from the /usr/src/linux-2.4.18-3 directory.
> - I then did "make modules_install" to let make copy the driver to
> where it
> expects it.
> - I then "rmmod st" and attempted "modprobe st" This gave me the
error
> "couldn't find the kernel version the module was compiled for"
>
> Here is where I think the problem lies: I have two kernels available
on
> this box. They are named: " 2.4.18-3" and "2.4.18-3MultiLU" the later
> having been compiled for support of SCSI devices with multiple logical
> units.
>
> Note:
> - I am running the 2.4.18-3MultiLU kernel.
> - The EXTRAVERSION parameter of the Makefile is set to "= -3MultiLU"
> - The Makefile I am discussing is in the /usr/src/linux-2.4.18-3
> directory.
> - My new st.o file was copied to the
> /lib/modules/2.4.18-3MultiLU/kernel/drivers/scsi/ directory.
> - There is no /usr/src/linux-2.4.18-3MultiLU directory.
>
> So, if the driver "couldn't find the kernel version" it was compiled
for,
> how do I determine which version it was compiled for? How do I make
it
> compiled for the version I am runing, "-3MultiLU"?
>
> Alan
>
>
> All right, I am learning a bit here. These links seem to indicate a
> possible
> explanation:
>
> My kernel is probably configured to bind the st driver to the base
> kernel, not
> as a loadable module:
> http://www.faqs.org/docs/Linux-HOWTO/Module-HOWTO.html#AEN204
>
> This describes the objdump program that can display part of the st.o
> file. A
> way to see what kernel it was compiled for, among other things:
> http://www.faqs.org/docs/Linux-HOWTO/Module-HOWTO.html#MODINFO
>
> So, does that mean I can just put my st.o file in the correct place
and
> reboot? I wish I was still at work so I could try it out.
>
> Alan
Alan - This post was timely for me - I am reading Linux Device Drivers,
2nd Edition. It's definitely a good read if you are interested.
Anyway in Chapter 2 they clarify a few things, many of which are in the
faq you posted and I am sure you already know:
"Bear in mind that your module's code has to be recompiled for each
version of the kernel that is will be linked to. Ech module defines a
symbol called __module_kernel_version which insmod matches against the
version number of the current kernel. This symbol is placed in the
.modinfo of the ELF section.....
The compiler will define the symbol for you whenever you include
<linux/module.h>...
In case of a version mismatch, you can still try to load a module
against a different versin by specifying the -f switch....
If you want to compile your module for a particular kernel version, you
have to include the specific header files for that kernel...
When asked to load a module, insmod follows its own search path to look
for the object file, looking in version-dependent directories under
/lib/modules...
"
Based on your error, I am assuming that the __module_kernel_version the
module was compiled with is different than the kernel currently
running. Do you have multiple versions of the kernel on your disk?
Something similar has happened to me when I have multiple different
kernels in /usr/src and forget to switch the symbolic link
/usr/src/linux to the correct one when I build.
Hope this helps...Good luck and post what happens I am interested in
hearing.
_______________________________________________
PLUG-devel mailing list - PLUG-devel@lists.PLUG.phoenix.az.us
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-devel
_______________________________________________
PLUG-devel mailing list - PLUG-devel@lists.PLUG.phoenix.az.us
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-devel