| 论坛注册| 加入收藏 | 设为首页| RSS
Google
您当前的位置:首页 > Linux频道 > Linux入门与提高 > 安装与配置

linux网卡驱动程序的编译与安装

时间:2006-08-25 10:20:29  来源:Linux联盟收集  作者:
一般来说,目前新版的 Linux 预设可以支持的网络卡芯片组数量已经很完备了,很多网络卡芯片都已经被支持, JbKLinux联盟
JbKLinux联盟
  例如RLT 8139 芯片 ( RealTek 8139 ) 的网络卡所以使用者可以很轻易的设定好他们的网络卡。 JbKLinux联盟
JbKLinux联盟
  不过,如果万一不幸核心没有支持该网络卡的话,那么可以透过重新编译核心或者编译网络卡驱动模块 ( Modules ), JbKLinux联盟
JbKLinux联盟
  并且加载该模块,今天就是这么巧,碰到一个D-Link 的DFE-530TX,没法,只有手动安装网络卡驱动程序了. JbKLinux联盟
JbKLinux联盟
  可以用命令# dmesg | grep eth JbKLinux联盟
JbKLinux联盟
  来查看系统启动信息,显示出 eth0 或者 eth1 的信息,如果eth1没找到正确的信息,那就表示 Linux 无法找到该硬件, JbKLinux联盟
JbKLinux联盟
  eth0是8139的,已经显示正常,例如: JbKLinux联盟
JbKLinux联盟
[root@kindgeorge root]# dmesg | grep eth JbKLinux联盟
JbKLinux联盟
eth0: RealTek RTL8139 Fast Ethernet at 0xf0160000, 00:0a:a6:30:0d:0e, IRQ 11 JbKLinux联盟
JbKLinux联盟
eth0: Identified 8139 chip type 'RTL-8139C' JbKLinux联盟
JbKLinux联盟
eth0: Setting 10mbps full-duplex based on auto-negotiated partner ability 4061. JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
一. 查看自己系统的内核版本. JbKLinux联盟
JbKLinux联盟
[root@kindgeorge root]# uname -r JbKLinux联盟
JbKLinux联盟
2.4.18-3  JbKLinux联盟
JbKLinux联盟
我这里是redhat7.3的,内核2.4.18-3 JbKLinux联盟
JbKLinux联盟
一般来说,这个内核驱动程序的模块会放在 /lib/modules/2.4.18-3/kernel/drivers/net JbKLinux联盟
JbKLinux联盟
二.确定系统是否已经安装下面包 JbKLinux联盟
JbKLinux联盟
1.由于编译需要用到内核的源代码包和编译程序gcc.所以如果没有的话,要先装. JbKLinux联盟
JbKLinux联盟
查看: JbKLinux联盟
JbKLinux联盟
[root@kindgeorge root]# rpm -qa|grep kernel JbKLinux联盟
JbKLinux联盟
kernel-2.4.18-3 JbKLinux联盟
JbKLinux联盟
kernel-source-2.4.18-3 JbKLinux联盟
JbKLinux联盟
[root@kindgeorge root]# rpm -qa|grep gcc (gcc是编译用) JbKLinux联盟
JbKLinux联盟
gcc-2.96-110 JbKLinux联盟
JbKLinux联盟
gcc-g77-2.96-110 JbKLinux联盟
JbKLinux联盟
gcc-c++-2.96-110 JbKLinux联盟
JbKLinux联盟
一般装了内核源包的话,都会在出现/usr/src/linux-2.4,同路径下会有linux-2.4.18-3的文件实际目录. JbKLinux联盟
JbKLinux联盟
2.如果没有的话,就用原来安装盘上的文件安装,会去下载个相同内核源包安装吧 JbKLinux联盟
JbKLinux联盟
rpm -ivh kernel-source-2.4.18-3.i386.rpm JbKLinux联盟
JbKLinux联盟
...... JbKLinux联盟
JbKLinux联盟
三. 取得驱动程序和编译 JbKLinux联盟
JbKLinux联盟
1. 可以重厂家提供的光盘提供,把光盘上的linux目录下的dlkfet-4.24.tar.gz 拷贝过来用. JbKLinux联盟
JbKLinux联盟
2. 从网上下载网络卡驱动程序,一般厂家的网站都提供下载程序的. JbKLinux联盟
JbKLinux联盟
例如: http://www.d-link.com.cn 上有下载. JbKLinux联盟
JbKLinux联盟
[root@kindgeorge root]# cp dlkfet-4.24.tar.gz /usr/src JbKLinux联盟
JbKLinux联盟
[root@kindgeorge root]# cd /usr/src/ JbKLinux联盟
JbKLinux联盟
[root@kindgeorge src]# tar -zxvf dlkfet-4.24.tar.gz JbKLinux联盟
JbKLinux联盟
dlkfet-4.24/ JbKLinux联盟
JbKLinux联盟
dlkfet-4.24/rhine_main.c JbKLinux联盟
JbKLinux联盟
dlkfet-4.24/Makefile JbKLinux联盟
JbKLinux联盟
dlkfet-4.24/vmns_drv.h JbKLinux联盟
JbKLinux联盟
dlkfet-4.24/rhine.h JbKLinux联盟
JbKLinux联盟
dlkfet-4.24/.depend.mak JbKLinux联盟
JbKLinux联盟
dlkfet-4.24/rhine_vmns.c JbKLinux联盟
JbKLinux联盟
dlkfet-4.24/rhine_proc.h JbKLinux联盟
JbKLinux联盟
dlkfet-4.24/rhine_proc.c JbKLinux联盟
JbKLinux联盟
dlkfet-4.24/rhine_vmns.h JbKLinux联盟
JbKLinux联盟
dlkfet-4.24/kcompat.h JbKLinux联盟
JbKLinux联盟
dlkfet-4.24/rhine_cfg.h JbKLinux联盟
JbKLinux联盟
dlkfet-4.24/.depend JbKLinux联盟
JbKLinux联盟
dlkfet-4.24/rhine_wol.c JbKLinux联盟
JbKLinux联盟
dlkfet-4.24/rhine_wol.h JbKLinux联盟
JbKLinux联盟
dlkfet-4.24/linux.txt JbKLinux联盟
JbKLinux联盟
3.请留意一开始是没有.o文件的. 我们编译前可以看看目录的linux.txt,是一个包含介绍安装说明.在进入目录后,执行make进行编译. JbKLinux联盟
JbKLinux联盟
[root@kindgeorge src]# cd dlkfet-4.24 JbKLinux联盟
JbKLinux联盟
[root@kindgeorge dlkfet-4.24]# make JbKLinux联盟
JbKLinux联盟
[root@kindgeorge dlkfet-4.24]# ll (编译后查看一下) JbKLinux联盟
JbKLinux联盟
total 320 JbKLinux联盟
JbKLinux联盟
-rw-r--r-- 1 root root 7473 Jan 15 2003 kcompat.h JbKLinux联盟
JbKLinux联盟
-rw-r--r-- 1 root root 11491 Jan 20 2003 linux.txt JbKLinux联盟
JbKLinux联盟
-rw-r--r-- 1 root root 5219 Dec 10 2002 Makefile JbKLinux联盟
JbKLinux联盟
-rw-r--r-- 1 root root 1818 Jan 16 2003 rhine_cfg.h JbKLinux联盟
JbKLinux联盟
-rw-r--r-- 1 root root 48715 May 24 18:31 rhinefet.o JbKLinux联盟
JbKLinux联盟
-rw-r--r-- 1 root root 42044 Jan 15 2003 rhine.h JbKLinux联盟
JbKLinux联盟
-rw-r--r-- 1 root root 78996 Jan 16 2003 rhine_main.c JbKLinux联盟
JbKLinux联盟
-rw-r--r-- 1 root root 32760 May 24 18:31 rhine_main.o JbKLinux联盟
JbKLinux联盟
-rw-r--r-- 1 root root 14980 Jan 15 2003 rhine_proc.c JbKLinux联盟
JbKLinux联盟
-rw-r--r-- 1 root root 1672 Jan 15 2003 rhine_proc.h JbKLinux联盟
JbKLinux联盟
-rw-r--r-- 1 root root 12336 May 24 18:31 rhine_proc.o JbKLinux联盟
JbKLinux联盟
-rw-r--r-- 1 root root 9172 Jan 15 2003 rhine_vmns.c JbKLinux联盟
JbKLinux联盟
-rw-r--r-- 1 root root 1106 Jan 15 2003 rhine_vmns.h JbKLinux联盟
JbKLinux联盟
-rw-r--r-- 1 root root 3792 May 24 18:31 rhine_vmns.o JbKLinux联盟
JbKLinux联盟
-rw-r--r-- 1 root root 7536 Jan 15 2003 rhine_wol.c JbKLinux联盟
JbKLinux联盟
-rw-r--r-- 1 root root 1529 Jan 15 2003 rhine_wol.h JbKLinux联盟
JbKLinux联盟
-rw-r--r-- 1 root root 3488 May 24 18:31 rhine_wol.o JbKLinux联盟
JbKLinux联盟
-rw-r--r-- 1 root root 6824 Jan 15 2003 vmns_drv.h JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
4.经过编译后,会编译出一个rhinefet.o 文件,这个就是驱动模块,我们把它拷贝到相应地方: JbKLinux联盟
JbKLinux联盟
[root@kindgeorge dlkfet-4.24]#cp rhinefet.o /lib/modules/2.4.18-3/kernel/drivers/net JbKLinux联盟
JbKLinux联盟
[root@kindgeorge dlkfet-4.24]# depmod -a JbKLinux联盟
JbKLinux联盟
5.测试 JbKLinux联盟
JbKLinux联盟
(1)可以用命令modprobe rhinefet 或 insmod rhinefet.o 加载.如果没出错信息说明ok. JbKLinux联盟
JbKLinux联盟
(2) 用命令lsmod 可以看看是否已经加载了. JbKLinux联盟
JbKLinux联盟
[root@kindgeorge dlkfet-4.24]# lsmod JbKLinux联盟
JbKLinux联盟
Module Size Used by Not tainted JbKLinux联盟
JbKLinux联盟
rhinefet 38752 1 JbKLinux联盟
JbKLinux联盟
8139too 16448 1 JbKLinux联盟
JbKLinux联盟
mii 2408 0 [8139too] JbKLinux联盟
JbKLinux联盟
这样,看到rhinefet模块已经加载了,基本上,这样就证明已经编译成功. JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
6. 让它开机时加载 JbKLinux联盟
JbKLinux联盟
[root@kindgeorge dlkfet-4.24]# vi /etc/modules.conf JbKLinux联盟
JbKLinux联盟
在后面加上一行: alias eth1 rhinefet JbKLinux联盟
JbKLinux联盟
7. 配置一下网络 JbKLinux联盟
JbKLinux联盟
[root@kindgeorge dlkfet-4.24]# vi /etc/sysconfig/network-scripts/ifcfg-eth1 JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
DEVICE=eth1 JbKLinux联盟
JbKLinux联盟
BOOTPROTO=static JbKLinux联盟
JbKLinux联盟
IPADDR=192.168.4.202 JbKLinux联盟
JbKLinux联盟
NETMASK=255.255.255.0 JbKLinux联盟
JbKLinux联盟
NETWORK=192.168.4.0 JbKLinux联盟
JbKLinux联盟
GATEWAY=192.168.4.250 JbKLinux联盟
JbKLinux联盟
BROADCAST=192.168.4.255 JbKLinux联盟
JbKLinux联盟
ONBOOT=yes JbKLinux联盟
JbKLinux联盟
8.启动网卡,然后用ifconfig查看, JbKLinux联盟
JbKLinux联盟
ifup eth1 JbKLinux联盟
JbKLinux联盟
[root@kindgeorge dlkfet-4.24]# ifconfig JbKLinux联盟
JbKLinux联盟
eth0 Link encap:Ethernet HWaddr 00:0A:E6:30:0D:0E JbKLinux联盟
JbKLinux联盟
inet addr:211.239.218.153 Bcast:211.239.218.255 Mask:255.255.255.0 JbKLinux联盟
JbKLinux联盟
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 JbKLinux联盟
JbKLinux联盟
RX packets:3780479 errors:0 dropped:0 overruns:0 frame:0 JbKLinux联盟
JbKLinux联盟
TX packets:3833860 errors:0 dropped:0 overruns:0 carrier:0 JbKLinux联盟
JbKLinux联盟
collisions:0 txqueuelen:100 JbKLinux联盟
JbKLinux联盟
RX bytes:1118112324 (1066.3 Mb) TX bytes:1111887387 (1060.3 Mb) JbKLinux联盟
JbKLinux联盟
Interrupt:11 JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
eth1 Link encap:Ethernet HWaddr 00:0F:3D:82:EC:1D JbKLinux联盟
JbKLinux联盟
inet addr:192.168.4.202 Bcast:192.168.4.255 Mask:255.255.255.0 JbKLinux联盟
JbKLinux联盟
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 JbKLinux联盟
JbKLinux联盟
RX packets:749312 errors:0 dropped:0 overruns:0 frame:0 JbKLinux联盟
JbKLinux联盟
TX packets:976174 errors:0 dropped:0 overruns:0 carrier:0 JbKLinux联盟
JbKLinux联盟
collisions:0 txqueuelen:100 JbKLinux联盟
JbKLinux联盟
RX bytes:43695059 (41.6 Mb) TX bytes:1472142037 (1403.9 Mb) JbKLinux联盟
JbKLinux联盟
Interrupt:5 Base address:0xe000 JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
9.重新启动机器,可以自动加载和使用了.大功告成. JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
五. 按照安装说明的方法自动编译安装. JbKLinux联盟
JbKLinux联盟
在 "三.3" 中我们用make 编译,然后进行手动的拷贝. 实际上在linux.txt中的安装说明提到用make install . JbKLinux联盟
JbKLinux联盟
那我们来看看这种方法系统都做了什么吧. JbKLinux联盟
JbKLinux联盟
[root@firewall1 dlkfet-4.24]# make install JbKLinux联盟
JbKLinux联盟
gcc -Wall -DLINUX -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -D__NO_VERSION__ -O2 -pipe -I/lib/modules/2.4.18-3/build/include -I. -Wstrict-prototypes -fomit-frame-pointer -DMODVERSIONS -include /lib/modules/2.4.18-3/build/include/linux/modversions.h -DVMNS -c -o rhine_main.o rhine_main.c JbKLinux联盟
JbKLinux联盟
gcc -Wall -DLINUX -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -D__NO_VERSION__ -O2 -pipe -I/lib/modules/2.4.18-3/build/include -I. -Wstrict-prototypes -fomit-frame-pointer -DMODVERSIONS -include /lib/modules/2.4.18-3/build/include/linux/modversions.h -DVMNS -c -o rhine_proc.o rhine_proc.c JbKLinux联盟
JbKLinux联盟
gcc -Wall -DLINUX -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -D__NO_VERSION__ -O2 -pipe -I/lib/modules/2.4.18-3/build/include -I. -Wstrict-prototypes -fomit-frame-pointer -DMODVERSIONS -include /lib/modules/2.4.18-3/build/include/linux/modversions.h -DVMNS -c -o rhine_wol.o rhine_wol.c JbKLinux联盟
JbKLinux联盟
gcc -Wall -DLINUX -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -D__NO_VERSION__ -O2 -pipe -I/lib/modules/2.4.18-3/build/include -I. -Wstrict-prototypes -fomit-frame-pointer -DMODVERSIONS -include /lib/modules/2.4.18-3/build/include/linux/modversions.h -DVMNS -c -o rhine_vmns.o rhine_vmns.c JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
************************************************** JbKLinux联盟
JbKLinux联盟
Build options: JbKLinux联盟
JbKLinux联盟
VERSION 2.4.18-3 JbKLinux联盟
JbKLinux联盟
SMP Disabled JbKLinux联盟
JbKLinux联盟
VMNS Enabled JbKLinux联盟
JbKLinux联盟
*************************************************** JbKLinux联盟
JbKLinux联盟
mkdir -p /lib/modules/2.4.18-3/kernel/drivers/net JbKLinux联盟
JbKLinux联盟
install -m 644 -o root rhinefet.o /lib/modules/2.4.18-3/kernel/drivers/net JbKLinux联盟
JbKLinux联盟
***** Move official driver via-rhine.o to via-rhine.o.backup JbKLinux联盟
JbKLinux联盟
mv /lib/modules/2.4.18-3/kernel/drivers/net/via-rhine.o /lib/modules/2.4.18-3/kernel/drivers/net/via-rhine.o.backup JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
/sbin/depmod -a || true JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
JbKLinux联盟
按照上面的结果显示是这样的一个过程: JbKLinux联盟
JbKLinux联盟
(1)系统把.c等文件编译成相应的.o文件. JbKLinux联盟
JbKLinux联盟
(2)然后显示系统是否支持SMP和VMNS,然后把相应的.o模块文件拷贝到系统应该的地方. JbKLinux联盟
JbKLinux联盟
(3)并且把相同芯片的程序过时的via-rhine.o改为备份文件.让系统用新的rhinefet.o JbKLinux联盟
JbKLinux联盟
(4)最后执行/sbin/depmod -a 更新模块库配置. 看来这个也是个智能的安装方法. JbKLinux联盟
JbKLinux联盟
六. 用其他方法驱动. JbKLinux联盟
JbKLinux联盟
由于市面上很多的各种各样的板卡,有名牌有杂牌,多不胜数.当我们拿到一块卡,但一下子没找到它本身提供的源程序,不能编译,怎么办呢? JbKLinux联盟
JbKLinux联盟
所以当你有一块网卡不能用,在找linux的driver之前一定搞清楚这个网卡用的什么芯片,跟谁兼容,比如3c509,ne2000,etherexpress等等. JbKLinux联盟
JbKLinux联盟
这样的型号一般都在网卡上最大的一快芯片上印着.如果芯片型号相同,那么它们其中一些是可以通用的.我们可以尝试一下系统上已经安装了的驱动是否可行了.进入驱动目录/lib/modules/(内核版本)/kernel/drivers/net 即可发现已经有很多模块了, 用命令insmod 相应芯片模块名字 , 如果不成功会报错,如果正确则不显示错误信息,然后再进行上面的"三.5-9"步骤进行测试.如果不行,再老老实实的找源程序吧.
来顶一下
近回首页
返回首页
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
相关文章
    无相关信息
栏目更新
栏目热门