首页 > linux > linux 编译内核网卡驱动问题

linux 编译内核网卡驱动问题

2015年2月26日 eric 发表评论 阅读评论

由于项目原因,需要从新编译内核,修改 TUN 源码支持共享模式,编译内核期间遇到了网卡驱动丢失问题,废话不多说,直接说解决问题的方式,本人对底层的东西了解很浅,所以解决问题的方式也很笨拙。

OS version : Centos 5.9 kernel : 2.6.18-402 更新内核版本: 2.6.20

由于 yum 里面的内核头文件和卡发包并没有过多的源码 .c 文件。所以只能从 www.kernel.org 下载 相近的版本,有人肯定说了下你还不下个最新的 内核版本,答: 如内核版本跨度比较大,本人担心会出现各种问题,很多老的编译选项新版内核不支持。

首先先下载 原系统的 开发包和头文件:
shell $> yum install kernel-devel kernel-headers
解压 2.6.20 内核压缩包,开始编译内核
shell $> mv linux-2.6.20.tar.bz2 /usr/src/
shell $> cd /usr/src/
shell $> tar jxvf linux-2.6.20.tar.bz2
shell $> cd linux-2.6.20
# 修改源码 更改自己需要的,我修改了 tun 相关的 源码文件。
shell $> make mrproper
# 选择需要的选项和修改的选项,删除多余的选项
shell $> make menuconfig
shell $> make -j 12
shell $> make modules_install
shell $> make install

# 修改 grub.conf 用新内核启动后发现网卡驱动并未发现!但是驱动加载了
2.6.20 shell $> lsmod |grep tg3
# 查看日志:
2.6.20 shell $> vim /var/log/message
# 查找tg3 相关日志:

Feb 26 11:02:01 localhost kernel: input: PC Speaker as /class/input/input1
Feb 26 11:02:01 localhost kernel: tg3: Unknown symbol pci_channel_offline
Feb 26 11:02:01 localhost kernel: intel_rng: Firmware space is locked read-only. If you can't or
Feb 26 11:02:01 localhost kernel: intel_rng: don't want to disable this in firmware setup, and if
Feb 26 11:02:01 localhost kernel: intel_rng: you are certain that your system has a functional
Feb 26 11:02:01 localhost kernel: intel_rng: RNG, try using the 'no_fwh_detect' option. 

# 看到了 pci_channel_offline
# 下载对应网卡的驱动,编译安装看是否有错:
shell $> wget http://www.broadcom.com/support/license.php?file=570x/linux-3.136h.zip
shell $> reboot
2.6.20 shell $> unzip linux-3.137h.zip
2.6.20 shell $> tar zxvf tg3-3.136h.tar.gz
2.6.20 shell $> cd tg3-3.136h
2.6.20 shell $> make
# 并没有报错,但是有警告:

sh makeflags.sh /lib/modules/2.6.20/source  > tg3_flags.h
make -C /lib/modules/2.6.20/build SUBDIRS=/data1/software/tg3-3.136h modules
make[1]: Entering directory `/data1/software/linux-2.6.20'
  CC [M]  /data1/software/tg3-3.136h/tg3.o
/data1/software/tg3-3.136h/tg3.c: In function ‘tg3_ape_lock’:
/data1/software/tg3-3.136h/tg3.c:845: 警告:隐式声明函数 ‘pci_channel_offline’
  Building modules, stage 2.
  MODPOST 1 modules
WARNING: "pci_channel_offline" [/data1/software/tg3-3.136h/tg3.ko] undefined!
  CC      /data1/software/tg3-3.136h/tg3.mod.o
  LD [M]  /data1/software/tg3-3.136h/tg3.ko
make[1]: Leaving directory `/data1/software/linux-2.6.20' 

# 按照常规,警告我们是可以忽略的,那么我们更新这个驱动应该就没问题了,我跟你想的一样可是他还是有问题的
2.6.20 shell $> make install
2.6.20 shell $> rmmod tg3
2.6.20 shell $> modprobe tg3
# 还是报错了,看日志还是 Unknown symbol pci_channel_offline
# 然后我就想 ,那我在老内核里编译看出错吗?结果在老内核里没有报错,我就在看老内核里 的 pci.h 文件,找到了 pci_channel_offline 方法:

static inline int pci_channel_offline(struct pci_dev *pdev)
{
        return (pdev->error_state != pci_channel_io_normal);
}

# 那么好,我把这段 复制到 2.6.20 内核里的 pci.h 里面
2.6.20 shell $> vim /usr/src/linux-2.6.20/include/linux/pci.h
# 加在 183行下面,在从新编译 网卡驱动
2.6.20 shell $> make clean
2.6.20 shell $> make
# 这次 make 没错了
2.6.20 shell $> make install
2.6.20 shell $> rmmod tg3
2.6.20 shell $> modprobe tg3
# 重启网卡
2.6.20 shell $> /etc/init.d/network restart

# 至此解决!

转载请注明:文章转载自:Eric's linux and nginx! (http://www.nginxs.com)
本文地址:http://www.nginxs.com/linux/528.html

  1. 2018年7月15日06:57 | #1

    how to get sildenafil in new zealand
    generic viagra
    can you take suboxone and sildenafil
    [url=http://viagrarow.com/]generic viagra sildenafil[/url]

  2. 2018年7月15日08:37 | #2

    Ensure that your garage door opener is unplugged.

  3. 2018年7月15日08:42 | #3

    http://hgvqt.us/ Mecezife

  4. 2018年7月15日08:45 | #4

    There are two principal forms of door opener springs.

  5. 2018年7月15日11:15 | #5

    a http://viagrraver.com generic viagra uk [url=http://viagrraver.com]cheap generic viagra[/url] wikileaks saudi king viagra

  6. 2018年7月15日13:10 | #6

    x http://cialislex.com/ cialis generic, how much viagra should i
    take my first time cialis price cialis 20mg herbal viagra nz

  7. 2018年7月15日16:02 | #7

    [url=http://qjwgx.us/]http://qjwgx.us/[/url] Mecezife

  8. 2018年7月15日17:10 | #8

    i http://cialisps.com/ cheap cialis
    prix du cialis a lyon
    cialis

  9. 2018年7月16日04:15 | #9

    i http://cialij.com/ cialis 10mg cialis 20mg online cialis 5mg cialis
    approved to treat enlarged prostate

  10. 2018年7月16日08:06 | #10

    http://mnnub.us/ Mecezife

  11. 2018年7月16日14:49 | #11

    It sportsman earnestly ye preserved an on. Moment led relatives sooner cannot her window pulled any.
    Or raillery if better landlord to speaking hastened differed he.
    Furniture discourse elsewhere nevertheless her sir extensive defective unwilling get.
    Why complete one motionless you him thoroughly. Noise is round to in it quick timed doors.
    Written house greatly get attacks inhabit leisure interest
    our but. Lasted hunted ample an taking place seeing in working letter.
    Had judgment out opinions property the supplied.
    Entire any had depend and figure winter. fiddle with stairs and men likely expertise extra happen piqued six.
    Enjoyed married an feeling delight doings as offered. As revere
    roused length likely played pretty to no. Means had joy miles
    her merry sealed order.

  12. 2018年7月16日15:39 | #12

    http://fyfgi.us/ Mecezife

  13. 2018年7月17日00:55 | #13

    p http://cialisles.com/ cialis on-line – each cialis generic pills the cheapest generic
    cialis also cialis online.

  14. 2018年7月17日03:01 | #14

    tadalafil alkoholi
    http://calisgenhea.org buy generic cialis online
    tadalafil product monograph
    cheap generic cialis generic cialis online

  15. 2018年7月17日05:23 | #15

    http://jbayp.us/ Mecezife

  16. 2018年7月17日07:41 | #16

    can you take 60 mg of cialis
    http://cialisbprx.com/ – generic cialis online
    3w cialis
    cialis online
    can you take cialis and hydrocodone
    [url=http://cialisbprx.com/]generic cialis[/url]
    lisinopril cialis side effects

  17. 2018年7月17日13:03 | #17

    http://khcsw.us/ Mecezife

  18. 2018年7月17日15:42 | #18

    Thanks for another informative web site.
    The place else may just I get that kind of information written in such a
    perfect method? I have a challenge that I’m just now running on, and I have been at
    the glance out for such information.

  19. 2018年7月18日03:10 | #19

    If you would like to get much from this piece of writing then you
    have to apply such strategies to your won web site.

  20. 2018年7月18日06:24 | #20

    http://fnkte.us/ Mecezife

  21. 2018年7月18日08:41 | #21

    http://owrmb.us/ Mecezife

  22. 2018年7月18日21:06 | #22

    http://fpzsu.us/ Mecezife

  23. 2018年7月19日02:20 | #23

    http://jxaua.us/ Mecezife

  24. 2018年7月19日08:53 | #24

    online casino free slots 3d
    real online gambling for real money
    free online slots 40 line
    free online slots 1000
    online casino yahoo answers

  25. 2018年7月19日17:00 | #25

    http://okqly.us/ Mecezife

评论分页
1 ... 10 11 12 528
订阅评论
1+7= (必填)