linux如何编译Intel网卡驱动源码,并进行安装

linux平台:中标麒麟桌面操作系统

GCC:gcc (GCC) 4.9.3 20150626 (NeoKylin 4.9.3-3)

买回来一款Intel的网卡,型号I210

如果想要安装这个网卡的驱动,需要去找此网卡的驱动源码。

当然,Intel已经帮我们把驱动源码写好了,我们要做的

只需要交叉编译这个驱动源码。

进入Intel驱动官网

https://downloadcenter.intel.com/zh-cn/download/13663

igb-5.3.5.36

英特尔®适用于 82575/6、82580、I350 和 I210/211 基于 Linux 的千兆位网络连接的网络适配器驱动程序

解压之后,查看README文件

Building and Installation
-------------------------
To build a binary RPM* package of this driver, run 'rpmbuild -tb
igb-<x.x.x>.tar.gz', where <x.x.x> is the version number for the driver tar
file.

Note: For the build to work properly, the currently running kernel MUST match
the version and configuration of the installed kernel sources. If you have just
recompiled the kernel reboot the system before building.

- To compile the driver on some kernel/arch combinations, a package with the
development version of libelf (e.g. libelf-dev, libelf-devel,
elfutilsl-libelf-devel) may need to be installed.

Note: RPM functionality has only been tested in Red Hat distributions.


1. Move the base driver tar file to the directory of your choice. For
   example, use '/home/username/igb' or '/usr/local/src/igb'.

2. Untar/unzip the archive, where <x.x.x> is the version number for the
   driver tar file:
   tar zxf igb-<x.x.x>.tar.gz

3. Change to the driver src directory, where <x.x.x> is the version number
   for the driver tar:
   cd igb-<x.x.x>/src/

4. Compile the driver module:
   # make install
   The binary will be installed as:
   /lib/modules/<KERNEL VERSION>/updates/drivers/net/ethernet/intel/igb/igb.ko

   The install location listed above is the default location. This may differ
   for various Linux distributions.

5. Load the module using the modprobe command:
   modprobe <igb> [parameter=port1_value,port2_value]

   Make sure that any older igb drivers are removed from the kernel before
   loading the new module:
   rmmod igb; modprobe igb

6. Assign an IP address to the interface by entering the following,
   where ethX is the interface name that was shown in dmesg after modprobe:
  
   ip address add <IP_address>/<netmask bits> dev ethX

7. Verify that the interface works. Enter the following, where IP_address
   is the IP address for another machine on the same subnet as the interface
   that is being tested:
   ping <IP_address>

To build igb driver with DCA
----------------------------
If your kernel supports DCA, the driver will build by default with DCA enabled.

Note: For certain distributions like (but not limited to) RedHat Enterprise
Linux 7 and Ubuntu, once the driver is installed the initrd/initramfs file may
need to be updated to prevent the OS loading old versions of the igb driver.
The dracut utility may be used on RedHat distributions:
	# dracut --force
   For Ubuntu:
	# update-initramfs -u

查看完building and Insallation之后

具体步骤

[root@localhost igb-5.3.5.36]# ls
COPYING  igb.7  igb.spec  pci.updates  README  scripts  src  SUMS
[root@localhost igb-5.3.5.36]# cd src
[root@localhost src]# ls
common.mk        e1000_manage.h  igb_ethtool.c  igb_ptp.o
e1000_82575.c    e1000_manage.o  igb_ethtool.o  igb_regtest.h
e1000_82575.h    e1000_mbx.c     igb.h          igb_vmdq.c
e1000_82575.o    e1000_mbx.h     igb_hwmon.c    igb_vmdq.h
e1000_api.c      e1000_mbx.o     igb_hwmon.o    igb_vmdq.o
e1000_api.h      e1000_nvm.c     igb.ko         kcompat.c
e1000_api.o      e1000_nvm.h     igb_main.c     kcompat_ethtool.c
e1000_defines.h  e1000_nvm.o     igb_main.o     kcompat.h
e1000_hw.h       e1000_osdep.h   igb.mod.c      kcompat.o
e1000_i210.c     e1000_phy.c     igb.mod.o      kcompat_overflow.h
e1000_i210.h     e1000_phy.h     igb.o          Makefile
e1000_i210.o     e1000_phy.o     igb_param.c    modules.order
e1000_mac.c      e1000_regs.h    igb_param.o    Module.supported
e1000_mac.h      igb.7.gz        igb_procfs.c   Module.symvers
e1000_mac.o      igb_debugfs.c   igb_procfs.o
e1000_manage.c   igb_debugfs.o   igb_ptp.c
[root@localhost src]# make clean
make[1]: Entering directory '/usr/src/kernels/3.10.0-2.nd7.33.mips64el'
  CLEAN   /home/100trust/igb-5.3.5.36/src/.tmp_versions
  CLEAN   /home/100trust/igb-5.3.5.36/src/Module.symvers
make[1]: Leaving directory '/usr/src/kernels/3.10.0-2.nd7.33.mips64el'
[root@localhost src]# make install
make[1]: Entering directory '/usr/src/kernels/3.10.0-2.nd7.33.mips64el'
  CC [M]  /home/100trust/igb-5.3.5.36/src/igb_main.o
  CC [M]  /home/100trust/igb-5.3.5.36/src/e1000_api.o
  CC [M]  /home/100trust/igb-5.3.5.36/src/igb_ethtool.o
  CC [M]  /home/100trust/igb-5.3.5.36/src/igb_hwmon.o
  CC [M]  /home/100trust/igb-5.3.5.36/src/e1000_mbx.o
  CC [M]  /home/100trust/igb-5.3.5.36/src/e1000_mac.o
  CC [M]  /home/100trust/igb-5.3.5.36/src/e1000_manage.o
  CC [M]  /home/100trust/igb-5.3.5.36/src/e1000_nvm.o
  CC [M]  /home/100trust/igb-5.3.5.36/src/igb_param.o
  CC [M]  /home/100trust/igb-5.3.5.36/src/e1000_phy.o
  CC [M]  /home/100trust/igb-5.3.5.36/src/igb_procfs.o
  CC [M]  /home/100trust/igb-5.3.5.36/src/igb_vmdq.o
  CC [M]  /home/100trust/igb-5.3.5.36/src/e1000_82575.o
  CC [M]  /home/100trust/igb-5.3.5.36/src/e1000_i210.o
  CC [M]  /home/100trust/igb-5.3.5.36/src/igb_debugfs.o
  CC [M]  /home/100trust/igb-5.3.5.36/src/igb_ptp.o
  CC [M]  /home/100trust/igb-5.3.5.36/src/kcompat.o
  LD [M]  /home/100trust/igb-5.3.5.36/src/igb.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/100trust/igb-5.3.5.36/src/igb.mod.o
  LD [M]  /home/100trust/igb-5.3.5.36/src/igb.ko
make[1]: Leaving directory '/usr/src/kernels/3.10.0-2.nd7.33.mips64el'
Copying manpages...
Installing modules...
make[1]: Entering directory '/usr/src/kernels/3.10.0-2.nd7.33.mips64el'
  INSTALL /home/100trust/igb-5.3.5.36/src/igb.ko
  DEPMOD  3.10.0-2.nd7.33.mips64el
make[1]: Leaving directory '/usr/src/kernels/3.10.0-2.nd7.33.mips64el'
Running depmod...
[root@localhost src]# ls
common.mk        e1000_manage.h  igb_ethtool.c  igb_ptp.o
e1000_82575.c    e1000_manage.o  igb_ethtool.o  igb_regtest.h
e1000_82575.h    e1000_mbx.c     igb.h          igb_vmdq.c
e1000_82575.o    e1000_mbx.h     igb_hwmon.c    igb_vmdq.h
e1000_api.c      e1000_mbx.o     igb_hwmon.o    igb_vmdq.o
e1000_api.h      e1000_nvm.c     igb.ko         kcompat.c
e1000_api.o      e1000_nvm.h     igb_main.c     kcompat_ethtool.c
e1000_defines.h  e1000_nvm.o     igb_main.o     kcompat.h
e1000_hw.h       e1000_osdep.h   igb.mod.c      kcompat.o
e1000_i210.c     e1000_phy.c     igb.mod.o      kcompat_overflow.h
e1000_i210.h     e1000_phy.h     igb.o          Makefile
e1000_i210.o     e1000_phy.o     igb_param.c    modules.order
e1000_mac.c      e1000_regs.h    igb_param.o    Module.supported
e1000_mac.h      igb.7.gz        igb_procfs.c   Module.symvers
e1000_mac.o      igb_debugfs.c   igb_procfs.o
e1000_manage.c   igb_debugfs.o   igb_ptp.c
[root@localhost src]# modprobe igb
[root@localhost src]# dmesg | grep igb
[    3.414062] igb: Intel(R) Gigabit Ethernet Network Driver - version 5.4.0-k
[    3.414062] igb: Copyright (c) 2007-2014 Intel Corporation.
[root@localhost src]# lsmod
Module                  Size  Used by
nls_cp936             130566  0
vfat                   11334  0
fat                    61117  1 vfat
usb_storage            58814  0
fuse                   88700  3
snd_hda_codec_hdmi     42111  0
snd_hda_intel          24076  2
r8169                  80994  0
shpchp                 29282  0
ip_tables              18188  0
x_tables               28893  1 ip_tables
ipv6                  431873  50
autofs4                28486  2

 

  • 0
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Linux常见驱动源码分析(kernel hacker修炼之道)--李万鹏 李万鹏 IBM Linux Technology Center kernel team 驱动资料清单内容如下: Linux设备模型(中)之上层容器.pdf Linux设备模型(上)之底层模型.pdf Linux驱动修炼之道-驱动中一些常见的宏.pdf Linux驱动修炼之道-内存映射.pdf Linux驱动修炼之道-看门狗框架源码分析.pdf Linux驱动修炼之道-触摸屏驱动之s3c2410_ts源码分析.pdf Linux驱动修炼之道-SPI驱动框架源码分析(中).pdf Linux驱动修炼之道-SPI驱动框架源码分析(下).pdf Linux驱动修炼之道-SPI驱动框架源码分析(上).pdf Linux驱动修炼之道-RTC子系统框架与源码分析.pdf Linux驱动修炼之道-platform.pdf Linux驱动修炼之道-LCD背光与gpio控制.pdf Linux驱动修炼之道-INPUT子系统(下).pdf Linux驱动修炼之道-INPUT子系统(上).pdf Linux驱动修炼之道-framebuffer(中).pdf Linux驱动修炼之道-framebuffer(下).pdf Linux驱动修炼之道-framebuffer(上).pdf Linux驱动修炼之道-DMA框架源码分析(下).pdf Linux驱动修炼之道-DMA框架源码分析(上).pdf Linux驱动修炼之道-DM9000A网卡驱动框架源码分析(中).pdf Linux驱动修炼之道-DM9000A网卡驱动框架源码分析(下).pdf Linux驱动修炼之道-DM9000A网卡驱动框架源码分析(上).pdf Linux驱动修炼之道-clock框架.pdf Linux驱动修炼之道-ADC驱动.pdf Linux内核访问外设I O资源的方式.pdf LINUX内核USB子系统学习笔记之初识USB.pdf kernel hacker修炼之道之驱动-流水灯.pdf kernel hacker修炼之道之驱动-混杂设备.pdf kernel hacker修炼之道之驱动-按键.pdf kernel hacker修炼之道之PCI subsystem(五).pdf kernel hacker修炼之道之PCI subsystem(四).pdf kernel hacker修炼之道之PCI subsystem(三).pdf kernel hacker修炼之道之PCI subsystem(六).pdf kernel hacker修炼之道之PCI subsystem(二).pdf
### 回答1: 在 Linux 系统中安装网卡驱动的方法可能会有所不同,具体取决于您使用的操作系统版本和网卡型号。但是,通常来说,安装网卡驱动的步骤大致如下: 1. 首先,您需要下载适用于您的网卡的驱动程序。您可以在网卡的制造商的网站上下载驱动程序,或者在 Linux 发行版的软件仓库中搜索。 2. 解压下载的驱动程序文件,并进入驱动程序所在的目录。 3. 在该目录中,运行以下命令来编译安装驱动程序: ``` ./configure make sudo make install ``` 4. 安装完成后,重新启动您的计算机,使驱动程序生效。 在某些情况下,您可能需要使用特殊的命令或工具来安装网卡驱动程序,具体取决于您使用的 Linux 发行版。如果您在安装过程中遇到困难,建议您查看驱动程序的文档或者在线搜索,以获取更多的帮助。 ### 回答2: 在Linux安装网卡驱动一般可以通过以下步骤进行: 1. 确认网卡型号:首先,我们需要确定安装网卡驱动所需的网卡型号。可以通过使用命令“lspci -v”或“lsusb”来列出系统的PCI或USB设备信息,从中找到网卡型号。 2. 下载驱动程序:在确认了网卡型号之后,我们需要到网卡制造商的官方网站或者Linux社区的驱动程序库中,下载适用于该网卡型号的驱动程序。 3. 解压驱动程序:将下载的驱动程序解压缩到一个目录中,并打开终端进入该目录。 4. 编译安装驱动程序:使用终端中的命令来编译安装驱动程序。常见的命令包括“make”用于编译驱动程序,“make install”用于安装驱动程序。 5. 加载驱动程序:安装完驱动程序后,我们需要加载该驱动程序。使用命令“modprobe”来加载驱动程序,例如“sudo modprobe <driver_module_name>”。 6. 验证网卡驱动安装和加载驱动程序后,可以使用命令“ifconfig”或“ip addr”来检查网卡是否成功安装和运行。 7. 永久加载驱动程序:为了在系统启动时自动加载驱动程序,我们需要编辑相关配置文件。可以使用命令“sudo nano /etc/modules”来打开一个文本编辑器,并添加驱动程序的名称,保存并退出编辑器。 以上是通用的方法,不同的Linux发行版可能会有细微差异,而且对于一些较新的网卡型号,可能需要安装额外的固件或者更新内核来支持。因此,在具体操作时请参考对应的文档或者社区支持。 ### 回答3: 在Linux系统中安装网卡驱动主要有两种方法:通过内核模块安装和通过硬件供应商提供的驱动程序安装。 一种常见的方法是通过内核模块安装Linux操作系统已经集成了许多常见的网卡驱动。首先,我们需要检查当前系统中是否已存在所需网卡驱动的内核模块。通过命令`lsmod | grep <驱动名称>`可以查看当前已加载的内核模块。如果该模块不存在,我们可以使用命令`modprobe <驱动名称>`来加载所需的网卡驱动。为了避免每次开机都手动加载驱动,我们可以在`/etc/modules`文件中添加驱动名称,让系统在启动时自动加载。 另一种方法是通过硬件供应商提供的驱动程序安装。我们需要从供应商的官方网站下载正确版本的驱动程序,并将其解压缩到合适的位置。然后,我们需要打开终端,切换到解压后的驱动目录,并运行`make`命令编译驱动程序。编译完成后,使用`make install`命令安装驱动程序。根据驱动程序不同,可能还需要运行其他命令或进行其他配置。 无论使用哪种方法安装网卡驱动,最后都需要重启系统以使驱动生效。重启后,可以使用`ifconfig`命令来查看网卡是否正常工作。如果一切正常,我们可以通过编辑`/etc/network/interfaces`文件来配置网络连接,或使用网络管理工具来设置IP地址、网关等网络参数。 总之,安装网卡驱动程序可能因具体硬件和Linux发行版而有所不同。但无论使用哪种方法,建议先查找官方文档或搜索相关教程,以获得确切的指导和注意事项。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

GLL_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值