[realtek] Re: kernel-module mismatch with RTL8139 - It works!

Umair Yousufi Umair Yousufi" <Umair.Yousufi@UTSouthwestern.edu
Sat Jun 8 21:04:01 2002


I solved the kernel-module mismatch problem and everything works ok now.  It
gives the same error message on startup, but it works nonetheless.  I
ended up invoking the insmod '-f' option which forces an install despite
kernel-module mismatches.  Actually, I used modprobe but added an insmod_opt
line in /etc/module.conf.

What I'd like to know is what to do after "ifconig eth0 up."  I needed to
use
SuSE's graphical LAN setup to start/stop the network, etc, but I'd like to
know what files it alters and what commands it issues.

Anyway, below I've typed up how I did it from start to end, as much for
myself as
for anyone else.  Maybe it will help people searching the archive.  I've
also
typed a short version, sent seperately.

The only disclaimer is that my methods may not be the best solution.  I
wouldn't be surprised if some of my problems couldn't have been fixed with
command line options or a newer linux version, etc.  It all worked however.
A
lot of the info below was borrowed shamelessly from the proper installation
instructions (http://www.scyld.com/network/updates.html), the Linux Ethernet
How-To, and these archives.

If anyone has changes, please feel free to post them.

--
Umair Yousufi

BEGIN INSTALLATION INSTRUCTIONS

----------INFO-----------------------:

1.  Ethernet Card:  D-Link DFE-530Tx+. (revD1), a 10/100Mbps PCI card.

The exact version of the card is important.  Even the "+" in the model
number
means you may end up using a different driver than the one I used.  To
verify
what model you have check the PCI Vendor ID (0x1186) and PCI device ID
(0x1300).  Do this by typing "cat /proc/pci/" and looking for the lines
referring to the ethernet controller.  Here's the relevant excerpt from my
machine:

  Bus  2, device   9, function  0:
    Ethernet controller: Unknown vendor Unknown device (rev 16).
      Vendor id=1186. Device id=1300.
      Medium devsel.  Fast back-to-back capable.  IRQ 9.  Master Capable.
Latency=32.  Min Gnt=32.Max Lat=64.
      I/O at 0xb800 [0xb801].
      Non-prefetchable 32 bit memory at 0xee800000 [0xee800000].


2.  OS version:   2.4.0-4GB

Linux was installed using SuSE 7.1  You can find your OS version using
'uname
-r.'  Having an updated version seems to be critical, as I had a lot of
problems using 2.2.1.8.


--------------STEPS----------------------


3.  Download the source RPMS from

ftp://ftp.scyld.com/pub/network/netdrivers-3.1-1.src.rpm

The most current version as of this writing (June 7, 2002) are the
netdrivers-3.1-1.  The RPM can go in any directory.

4.  The installation instructions are at
http://www.scyld.com/network/updates.html.  However, I needed to make some
modifications to get them to work, so I 'll go over them here. Remember the
disclaimers about my solutions (better ways exist, etc).

4.  change to the directory where the source rpm was downloaded

5.  Install the source RPMS:

rpm -ihv netdrivers-3.1-1.src.rpm

Explanation of rpm options:
-i - install
-h - show hash marks for progress
-v - verbose feedback

If the previous command is successful it should install two files,
netdrivers.tgz and netdrivers.spec.  netdrivers.tgz is the tarred/gzipped
file
holding the network driver files.  netdrivers.spec is a script that invokes
a
makefile and does some directoy setup, etc.   netdrivers.tgz is installed in
/usr/src/packages/SOURCE.  netdrivers.spec. in installed in
/usr/src/packages/SPECS


6.  switch to the following directory:

cd /usr/src/packages/

Your directory may be different if you're using something other than SuSE.
The original installation instructions suggests checking any of following
directories:  /usr/src/{redhat,TurboLinux,packages}/


7.  Build the binary packages of network drivers and pci-scan.

rpm -bb SPECS/netdriver*.spec

On my machine this will fail.  The source files will be unzipped into
/usr/src/pakages/BUILD/netdrivers-3.1, but on compilation gcc (version
2.95.2)
complains about an error regarding a variable called MODULE_LICENSE in
multiple files.  Tracing this error didn't get me far.  You can check the
netdrivers-3.1 for the files kern_compat.h, pci-skeleton.c, pci-scan.c
regarding the variable LINUX_VERSION_CODE , which itself is defined in the
main linux source tree (/usr/src/linux/include/linux/version.h), if you are
inclined.  However, you could just do the following:

8.  Comment out all lines in source code using the MODULE_LICENSE variable.

In the usr/src/pakages/BUILD/netdrivers-3.1 directory, find all the files
with
the MODULE_LICENSE variable in it (mainly the individual dirver files), and
comment them.  The line in the code will look like this:

MODULE_LICENSE("GPL");

To comment it out, just put a double slash in front of it:

//MODULE_LICENSE("GPL");

Do this for all the files (except kern_compat.h).

9.  Tar the modified files.

If you were o run the netdriver.spec file again, it would unzip the original
file and overwrite the changes.  To get around this tar and zip the modified
files.

In the usr/src/pakages/BUILD/netdrivers-3.1 directory, type

tar -cf netdrivers.tar *

10.  Zip the tarred files

In the same directory, type

gzip netdrivers.tar

This should leave you with a file called netdrivers.tar.gz.

11.  Move the new file to the correct location

Again, in the same directory, type

mv netdrivers.tar.gz /usr/src/packages/SOURCES/netdrivers.tgz

This will overwrite the original netdrivers.tgz file, but this can always be
restored from the original source RPM if needed.

12.  cd /usr/src/packages

13.  Rerun the compilation script

rpm -bb SPECS/netdriver*.spec

This will create the modules (as object files) in the BUILD/netdrivers-3.1
directory and an additional rpm file including them.

14.Install the drivers in the correct location

In the /usr/src/packages directory type:

rpm -i --force RPMS/i386/netdrivers-3.0-1.i386.rpm

This installs the modules into /lib/modules/'uname -r'/net directory.  The
--force option is needed because the new drivers may conflict with the
existing drivers installed by the kernel package.


15.  switch to the module directory

cd /lib/modules/2.4.0-4GB/net

16.  attempt to install the modules

At this point, thoeretically, you should be able to used modprobe to install
the modules.  This would look like:

depmod -a
modprobe rtl8139

It might work, so it's worth trying, but on my machine this fails with a
kernel-module mismatch on pci-scan.o.  A quick explanation of the commands:
Depmod -a creates a module dependency list for modprobe to use.
modprobe rtl8139 installs the driver file for the card, but also any other
modules rtl8139 is dependent on (namely pci-scan).  It's basically a shell
for
the command insmod.  insmod has an option, -f, just for such an occasion
which
forces an installation of a modules despite a kernel-module mismatch.
However, short of adding this option to the modprobe configuration file, I
couldn't find a way to get modprobe to pass this option to insmod.  YOu
could
just go ahead and use insmod -f on both pci-scan and rtl8139, but since the
modprobe config file needs to be edited evenually anyway (for a different
reason), I went the config file route

17.  Modify /etc/modules.conf

add the following lines at the end of the /etc/modules.conf file:

alias eth0 rtl8139
insmod_opt=-f

The alias command lets the os know that eth0 refers to your ethernet driver.
The insmod_opt command is sort of a hack to get modprobe to pass the -f
option
to insmod.  After you've sucessfully got your ethernet working, you should
probably go back and remove or comment out the insmod_opt line (but leave
the
alias line!)

18.  switch to the module directory

cd /lib/modules/2.4.0-4GB/net


19.  re-attempt to install the modules

depmod -a
modprobe rtl8139

The 'depmod -a' line needed to repeated since you've modified the
modules.conf
file. This should install the pci-scan and rtl8139 modules

20.  Verify module installation

Type lsmod.  The relvant lines should look something like this:

Module                  Size  Used by
rtl8139                12400   1
pci-scan                3680   1  [rtl8139]

21.  start the eth0 service

ifconfig eth0 up


This starts up eth0.  Check it's up by running ifconfig

22.  To establish the connection, I needed to run SuSE's YAST2 (a graphical
setup tool).  I wish I knew what files it modified, but I don't.  If someone
knows, please post here.  If you have a different linux version try using
it's
config program.  My machine automatically gets its IP information from a
DHCP
server, so that's the option I chose.  It saved the files and stopped and
restarted the network.  And then everything worked!


--------------NOTES------------------

I have some other notes, culled mostly from the archives:

*You may see people suggesting that you disable plug-n-play, and manually
configure IRQ, etc.  This, however, is only necessary on ISA boards, not PCI

*insmod sometimes complains about a "device or resource busy".  In my case
this was fixed by using the 2.4 linux version, and the updated netdrivers.
Never mind the rest of the insmod error message which reads "insmod errors
can
be caused by incorrect module parameters, including invalid IO or IRQ
parameters".  Again that advice only applies to ISA devices

*if you get the modprobe error "can't locate module rtl8139.o", you should
exclude the .o suffix :)


-------------COMMANDS-------------------
These are commands I found useful

modprobe /lib/modules/2.2.1.8/net rtl8139
modprobe -c
dmesg
cat /proc/interrupts
cat /proc/pci
insmod rtl8139
lsmod
rmmod
ifconfig
ifconfig eth0 up
depmod -a
lspci -vv

-------------FILES/LOCATIONS----------------
some file locations

/usr/src/packages/
/usr/src/packages/SOURCES - tgz files
/usr/src/pakcages/BUILD - source files
/etc/modules.conf - modprobe configuration files
/lib/modules/2.4.0-4GB/net - location of installed modules



>
> Message: 8
> Date: Wed, 05 Jun 2002 07:09:43 -0500
> From: "Umair Yousufi" <Umair.Yousufi@UTSouthwestern.edu>
> To: <realtek@scyld.com>
> Subject: [realtek] kernel-module mismatch with RTL8139 (resend)
>
> (this is a resend due to bad formatting)
>
> I'm trying to get a D-Link DFE-530Tx+ (revD1) ethernet
> card running on a SuSE Linux 7.1 machine.  PCI Vendor
> ID is 1186 and PCI Device ID is 1300 on the card.
>
> I've installed the updated network driver files
> (netdrivers-3.1-1), and then do 'depmod -a'.  In
> the /lib/modules/'uname -r'/net/ directory,
> running 'modprobe rtl8139' I get the following error
> (paraphrased):
>
> pci-scan.o:  kernel-module mismatch
>   pci-scan.o was compiled for kernel version 2.4.0
>   while this kernel is version 2.4.0-4GB
>
> ...then the standard insmod errors show up.
>
> IMHO, it seems like it should work, but that there is
> some problem related to reporting of which linux
> versions are acceptable.  I've tried previously using
> 2.2.1.8 with both the netdriver3.0 and netdriver3.1
> files.  With the 3.1 files, I ran 'rpm -bb
> SPECS/netdriver*.spec' and also got errors which were
> related to kernel version.  I traced those errors, to
> a kern_compat.h file, which excluded the definition of
> MODULE_LICENSE based on LINUX_VERSION_CODE
> MODULE_LICENSE shows up in the driver and pci-scan
> files).  I'm not exactly sure how to interpret this.
>
> Any ideas?  I've tried a long time myself, searched
> the archive, etc. and am at wit's end.  I've added
> exerpts from some output from a few commands, if it
> helps.  As a last resort, I may try compiling the
> version that came on the floppy w/ the ethernet card
> (as someone in the archive suggested).
>
> much thanks
>
> --
> Umair Yousufi
>
> -----------cat proc/pci--------------------
>
>   Bus  2, device   9, function  0:
>     Ethernet controller: Unknown vendor Unknown device (rev 16).
>       Vendor id=1186. Device id=1300.
>       Medium devsel.  Fast back-to-back capable.  IRQ 9.
>       Master Capable.  Latency=32.  Min Gnt=32.Max Lat=64.
>       I/O at 0xb800 [0xb801].
>       Non-prefetchable 32 bit memory at 0xee800000 [0xee800000].
>
>
> ----------------------lsmod---------------------------
>
> Module                  Size  Used by
> mousedev                3856   0  (unused)
> hid                    11680   0  (unused)
> input                   2880   0  [mousedev hid]
> usb-uhci               19056   0  (unused)
> usbcore                45104   1  [hid usb-uhci]