首页 > 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年6月2日22:46 | #1

    Cialis Bordeaux Kamagra Bijwerkingen Cephalexin And Kariva generic cialis overnight delivery Viagra E Dipendenza Cialis No Prescription Montreal

  2. 2018年6月3日04:13 | #2

    can you get in trouble for ordering zoloft online
    http://zolftgenhuf.com zoloft, where to buy zoloft online from canada
    sertraline sertraline high how old do you have to be to buy zoloft

  3. 2018年6月3日09:21 | #3

    L’ugola di gola gonfia e dolorante primo soccorso per una vittima di ictus

  4. 2018年6月3日14:46 | #4

    Hi would you mind sharing which blog platform you’re working with?
    I’m looking to start my own blog in the near future
    but I’m having a hard time making a decision between BlogEngine/Wordpress/B2evolution and Drupal.

    The reason I ask is because your design seems different then most blogs and I’m
    looking for something completely unique. P.S Sorry for
    being off-topic but I had to ask!

  5. 2018年6月3日17:32 | #5
  6. 2018年6月3日19:26 | #6

    I have learn some good stuff here. Certainly price bookmarking for revisiting.

    I surprise how so much attempt you set to create any such great informative web site.

  7. 2018年6月4日00:03 | #7
  8. 2018年6月4日02:15 | #8
  9. 2018年6月4日06:00 | #9

    pills for sale http://viagrauga.com/ viagra 25mg
    online difference between sildenafil and manforce viagra 50mg
    sale

  10. 2018年6月4日08:10 | #10

    Hey! This is my first comment here so I just wanted to give a quick shout
    out and say I genuinely enjoy reading through your posts.
    Can you suggest any other blogs/websites/forums that
    go over the same topics? Thanks!

  11. 2018年6月4日08:12 | #11

    generic brand for cialis 5mg canada
    buy generic cialis
    cialis coupon cvs
    [url=http://cialisfee.com/]buy generic cialis online[/url]
    generic cialis release date

  12. 2018年6月4日09:43 | #12

    Inquire particularly aggregation ended Crataegus oxycantha son formula.
    Extremely avidness precept respectable have was serviceman. Workforce received far his
    dashwood subjects unexampled. My sufficient surrounded an companions dispatched in on.
    New beamish friends and her some other. Foliage she does none be intimate
    in high spirits one of these days.

  13. 2018年6月4日11:33 | #13

    dwvnnqkg cialis [url=http://cialissom.com/]cialissom.com[/url] generic cialis online buy
    cialis beneficios de tadalafil 5 mg

  14. 2018年6月4日11:52 | #14

    where to get viagra in durban
    [url=http://www.hqviagrauro.com/]buy cheap viagra online next day delivery[/url]
    getting viagra from tesco
    viagra generic

  15. 2018年6月4日12:04 | #15

    can you take two 5mg cialis in one day
    [url=http://www.cialislet.com/]cialis online[/url]
    resultados de cialis 5 mg
    buy cialis online

  16. 2018年6月4日13:46 | #16

    where can you buy sildenafil at walgreens
    generic sildenafil citrate
    sildenafil grapefruit warning
    [url=http://viaqraonlinegen.com/]cheap generic viagra[/url]

  17. 2018年6月4日19:49 | #17

    c http://cialisles.com cialis generic, regularly cialis funziona yahoo cialis online also cialis online

  18. 2018年6月4日23:18 | #18

    http://ancc.us/ Mecezife

  19. 2018年6月5日21:45 | #19
  20. 2018年6月6日01:25 | #20

    Very good post! We will be linking to this particularly great
    post on our site. Keep up the good writing.

  21. 2018年6月6日06:11 | #21
  22. 2018年6月6日17:26 | #22

    Folks usually make the mistake of skimping on crops.

  23. 2018年6月6日20:20 | #23

    http://larbo.us/ Mecezife

  24. 2018年6月7日04:30 | #24

    Some could have even used their services a time or two.

  25. 2018年6月7日09:10 | #25

    [url=http://educationpoints.eu/]http://educationpoints.eu/[/url] Mecezife

  26. 2018年6月7日09:27 | #26

    It suggests the purchase of high quality mum plants.

  27. 2018年6月7日11:10 | #27

    sample viagra buy viagra buy female viagra [url=http://bestbuymaleenhancement.com/#]viagra for sale[/url]

  28. 2018年6月7日13:04 | #28

    order viagra purchase viagra viagra natural [url=http://vigrageneic.com/#]over the counter viagra[/url]

  29. 2018年6月7日13:04 | #29

    help me write my essay essay help essay german [url=https://essayhelp.us.org]buy essays[/url]

  30. 2018年6月7日13:18 | #30

    soft viagra 100mg tablets
    buy generic viagra online
    price of viagra and cialis
    [url=http://viagrapipls.com/]buy generic viagra online[/url]
    proper dosage for viagra

  31. 2018年6月7日16:08 | #31

    viagra generic viagra how it works canada viagra [url=http://onlineviaqer.com/#]viagra for sale[/url]

  32. 2018年6月7日16:37 | #32

    These drivers will also change tires on autos.

  33. 2018年6月7日18:07 | #33

    loans for people with bad credit loans with bad credit loans with bad credit [url=https://loanswithbadcredit.us.org]loans with bad credit[/url]

  34. 2018年6月7日18:07 | #34

    viagra alternative viagra wholesale viagra [url=http://sexviagen.com/#]name brand viagra[/url]

  35. 2018年6月7日19:45 | #35

    On the lookout for a storage door restore as we speak?

  36. 2018年6月7日21:59 | #36

    what happens if a girl takes viagra viagra alternative how to get viagra [url=http://genericonlineviaqra.com/#]buy viagra online[/url]

  37. 2018年6月7日22:36 | #37

    [url=http://eduface.eu/]http://eduface.eu/[/url] Mecezife

  38. 2018年6月8日04:02 | #38

    canadian pharmacy viagra viagra samples generic viagra [url=http://erectiledysfunctionmedicinesus.com/#]female viagra pills[/url]

  39. 2018年6月8日07:18 | #39

    bad credit quick loans smart loan payday loans massachusetts [url=https://onlinepaydayloan.us.com]payday loans online[/url]

  40. 2018年6月8日08:17 | #40

    young driver car insurance car insurance policy compare auto insurance rates [url=https://carinsurancerates.us.org]compare auto insurance rates[/url]

  41. 2018年6月8日10:21 | #41

    buy viagra cheap purchase viagra sublingual viagra [url=http://viagracefo.com/#]viagra[/url]

  42. 2018年6月8日11:07 | #42

    viagra sildenafil viagra cheap generic viagra [url=http://menedkkr.com/#]viagra generic[/url]

  43. 2018年6月8日15:07 | #43

    [url=http://enavody.eu/]http://enavody.eu/[/url] zolpidem Mecezife

  44. 2018年6月8日20:21 | #44

    loan online online loan debt consolidation loans [url=https://loanonline.us.com]bankruptcy loans[/url]

  45. 2018年6月8日20:35 | #45

    viagra soft tablets discount generic viagra cheap viagra [url=http://viagrapbna.com/]viagra brands[/url]

  46. 2018年6月8日21:56 | #46

    purchase viagra viagra without prescription buy cheap purchase uk viagra [url=http://viagrapfhze.com/#]buy cheap viagra[/url]

  47. 2018年6月8日22:23 | #47

    cheapest cialis cialis pill tadalafil tablets 20 mg [url=http://cialpharmedi.com/]cialis 5mg[/url]

  48. 2018年6月9日01:28 | #48

    tadalafil citrate do you need a prescription for cialis buy tadalafil [url=http://cialisotjs.com/]generic cialis[/url]

  49. 2018年6月9日05:27 | #49

    bad credit catalogues
    [url=http://personalloansx1.com/#]online personal loans[/url]
    first advance cash
    personal online loans

  50. 2018年6月9日07:03 | #50

    no prescription cialis generic cialis cialis pills [url=http://drcialonlinedkb.com/]cialis sale[/url]

评论分页
1 ... 6 7 8 9 10 ... 16 528
订阅评论
3+4= (必填)