首页 > 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. 2017年5月13日09:22 | #1

    Hello my family member! I wish to say that this post is amazing, nice written and come with approximately all vital
    infos. I’d like to peer extra posts like this.

  2. 2017年5月19日18:50 | #2

    What’s up, its pleasant paragraph on the topic of media print, we all understand media is a impressive source of
    facts.

  3. 2017年5月20日08:51 | #3

    Hey! Do you use Twitter? I’d like to follow you if that would be okay.
    I’m absolutely enjoying your blog and look forward to new posts.

  4. 2017年5月28日15:36 | #4

    Thank you for the good writeup. It in fact was
    a amusement account it. Look advanced to far added agreeable from you!
    By the way, how could we communicate?

  5. DorisTiems
    2017年7月15日07:02 | #5

    Absolutely NEW update of SEO/SMM software “XRumer 16.0 + XEvil”:
    captchas recognition of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex,
    and more than 8400 another subtypes of captcha,
    with highest precision (80..100%) and highest speed (100 img per second).
    You can connect XEvil 3.0 to all most popular SEO/SMM programms: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other programms.

    Interested? You can find a lot of introducing videos about XEvil in YouTube.
    See you later!

    XRumer201707

  6. 2017年7月16日03:51 | #6

    Hi! This is my first visit to your blog! We are a group
    of volunteers and starting a new project in a community in the same niche.
    Your blog provided us beneficial information to work on. You have done a outstanding job!

  7. DorisTiems
    2017年7月17日17:04 | #7

    Revolutional update of SEO/SMM package “XRumer 16.0 + XEvil 3.0″:
    captchas solving of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex,
    and more than 8400 another types of captchas,
    with highest precision (80..100%) and highest speed (100 img per second).
    You can connect XEvil 3.0 to all most popular SEO/SMM software: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other software.

    Interested? There are a lot of introducing videos about XEvil in YouTube.
    Good luck ;)

    XRumer201707

  8. DorothyRuirm
    2017年7月18日04:14 | #8

    Absolutely NEW update of SEO/SMM package “XRumer 16.0 + XEvil”:
    captchas solving of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex,
    and more than 8400 another categories of captcha,
    with highest precision (80..100%) and highest speed (100 img per second).
    You can connect XEvil 3.0 to all most popular SEO/SMM programms: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other programms.

    Interested? You can find a lot of impessive videos about XEvil in YouTube.
    See you later!

    XRumer20170717

  9. DorothyRuirm
    2017年7月19日08:14 | #9

    Revolutional update of SEO/SMM package “XRumer 16.0 + XEvil”:
    captchas regignizing of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex,
    and more than 8400 another size-types of captchas,
    with highest precision (80..100%) and highest speed (100 img per second).
    You can connect XEvil 3.0 to all most popular SEO/SMM software: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other software.

    Interested? There are a lot of impessive videos about XEvil in YouTube.
    Good luck ;)

    XRumer20170718

  10. ArleneBix
    2017年7月22日07:40 | #10

    Absolutely NEW update of SEO/SMM software “XRumer 16.0 + XEvil 3.0″:
    captcha regignizing of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex,
    and more than 8400 another size-types of captcha,
    with highest precision (80..100%) and highest speed (100 img per second).
    You can connect XEvil 3.0 to all most popular SEO/SMM software: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other software.

    Interested? There are a lot of impessive videos about XEvil in YouTube.
    Good luck ;)

    XRumer20170721

  11. ArleneBix
    2017年7月22日17:03 | #11

    Absolutely NEW update of SEO/SMM software “XRumer 16.0 + XEvil 3.0″:
    captchas solving of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex,
    and more than 8400 another subtypes of captchas,
    with highest precision (80..100%) and highest speed (100 img per second).
    You can connect XEvil 3.0 to all most popular SEO/SMM software: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other programms.

    Interested? There are a lot of demo videos about XEvil in YouTube.
    See you later!

    XRumer20170721

  12. ArleneBix
    2017年7月22日22:27 | #12

    Revolutional update of SEO/SMM package “XRumer 16.0 + XEvil 3.0″:
    captcha breaking of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex,
    and more than 8400 another size-types of captchas,
    with highest precision (80..100%) and highest speed (100 img per second).
    You can connect XEvil 3.0 to all most popular SEO/SMM software: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other software.

    Interested? There are a lot of introducing videos about XEvil in YouTube.
    See you later!

    XRumer20170721

  13. ArleneBix
    2017年7月23日03:37 | #13

    Revolutional update of SEO/SMM package “XRumer 16.0 + XEvil”:
    captchas solving of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex,
    and more than 8400 another categories of captchas,
    with highest precision (80..100%) and highest speed (100 img per second).
    You can connect XEvil 3.0 to all most popular SEO/SMM software: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other programms.

    Interested? There are a lot of impessive videos about XEvil in YouTube.
    See you later!

    XRumer20170721

  14. 2017年7月25日17:52 | #14

    Write My Essay – EssayErudite.com

    Fed up of typing “who can write my essay” in the search bar?
    Would you like to have a reliable helper always by your side?
    Our website will come as an excellent solution to write my essay

  15. 2017年7月25日19:27 | #15

    Dissertation Writing Service – EssayErudite.com

    Our https://essayerudite.com/dissertation-writing-service/ provides a full-scale writing assistance accessible online 24/7.
    Apart from many other writing companies, we are rather picky when forming a professional staff of experts.
    Moreover, we try to make our every customer feel safe and pleased with the service.

  16. 2017年7月25日19:38 | #16

    Write My Paper – EssayErudite.com

    Looking for an expert to write my paper for you? You are at the right place.
    Providing superior writing service appears to be our main specialization and passion.
    Our website is the best destination for every English-speaking student who calls for assistance when handling his or her daily academic tasks.

  17. 2017年7月26日16:57 | #17

    EssayErudite.com is the web’s leading provider of quality and professional academic writing.
    When it comes to essay writing, an in-depth research is a big deal. Our experienced writers are professional in many fields of knowledge so that they can assist you with virtually any academic task. We deliver papers of different types: essays, theses, book reviews, case studies, etc.
    We have thousands of satisfied customers who have already recommended us to their friends. Why not follow their example and place your order today?

  18. 2017年8月1日02:15 | #18

    http://www.copic-sketch.ru – городской скетчинг

  19. 2017年8月1日05:59 | #19

    Day ago i read some cool info about Omega 3 foods and now i very wanna get it. But i want a quality, some premium omega 3 fish oil. I’ve got this carlson omega 3 . What do you think about this Carlson brand?

  20. 2017年8月1日11:00 | #20

    I’m amazed, I have to admit. Seldom do I encounter a blog that’s equally educative
    and engaging, and without a doubt, you’ve hit the nail on the
    head. The problem is something that not enough folks are speaking intelligently about.

    Now i’m very happy I came across this in my search for something regarding this.

  21. 2017年8月1日18:42 | #21

    I think the admin of this web site is truly working hard in favor of his site, as here every data is quality based
    data.

  22. 2017年8月1日22:35 | #22

    Yesterday i got some shocking info about Omega 3 foods and now i very wanna buy it. But i’m not 100% sure which pluses will i have. I’ve got this omega 3 info , and currently i want to get it with lowest price. Any idea?

  23. 2017年8月1日22:52 | #23

    Thanks for your personal marvelous posting!
    I really enjoyed reading it, you are a great author.I will be sure to bookmark your blog and will eventually come back down the road.
    I want to encourage continue your great work, have a nice afternoon!

  24. 2017年8月2日00:00 | #24

    Have you ever considered creating an ebook or guest authoring on other
    sites? I have a blog based upon on the same ideas you discuss
    and would love to have you share some stories/information. I know my
    visitors would appreciate your work. If you are even remotely interested, feel free
    to shoot me an e-mail.

  25. 2017年8月2日03:19 | #25

    You can definitely see your expertise in the work
    you write. The sector hopes for even more passionate writers like you who are not afraid to
    mention how they believe. At all times follow your heart.

  26. 2017年8月2日03:55 | #26

    Why viewers still make use of to read news papers when in this technological world
    the whole thing is presented on net?

  27. 2017年8月2日08:07 | #27

    Touche. Great arguments. Keep up the amazing work.

  28. 2017年8月2日08:26 | #28

    Excellent blog here! Also your website loads up very fast!

    What host are you using? Can I get your affiliate link to your
    host? I wish my website loaded up as fast
    as yours lol

  29. 2017年8月2日13:44 | #29

    Yesterday i got some shocking info about Omega 3 foods and now i really wanna get it. But i’m not 100% sure which benefits will i have. I’ve got this omega 3 info , and currently i want to get it with good price. Any idea?

  30. 2017年8月3日01:42 | #30

    Thanks for finally writing about >Eric's linux and nginx!

    > linux 编译内核网卡驱动问题 <Loved it!

  31. 2017年8月3日03:43 | #31

    I loved as much as you’ll receive carried out right here.
    The sketch is tasteful, your authored subject matter stylish.
    nonetheless, you command get bought an nervousness over that
    you wish be delivering the following. unwell unquestionably come further formerly again since exactly the same nearly a lot often inside case you shield this hike.

  32. 2017年8月3日03:57 | #32

    Day ago i got some cool info about Omega 3 stuff and now i very wanna buy it. But i’m not absolutely sure which benefits will i have. I’ve got this omega 3 info , and currently i want to buy it with best price. Any idea?

  33. 2017年8月3日04:02 | #33

    What’s Happening i’m new to this, I stumbled upon this I have found It absolutely helpful and it has helped me out loads.
    I hope to contribute & assist different customers like its helped me.

    Great job.

  34. 2017年8月3日06:02 | #34

    Greetings I am so delighted I found your blog, I really found you by accident, while I was searching
    on Aol for something else, Anyways I am here now and would just like to say
    kudos for a tremendous post and a all round thrilling blog (I also love the theme/design),
    I don’t have time to go through it all at the minute but
    I have book-marked it and also added your RSS feeds, so when I have time I
    will be back to read a great deal more, Please do keep up the great jo.

  35. 2017年8月3日10:54 | #35

    Howdy would you mind letting me know which hosting company you’re working
    with? I’ve loaded your blog in 3 different internet browsers and I must say this blog
    loads a lot quicker then most. Can you suggest a good hosting provider at a reasonable price?
    Many thanks, I appreciate it!

  36. 2017年8月3日11:05 | #36

    What’s up to all, the contents present at
    this website are truly amazing for people knowledge, well, keep
    up the nice work fellows.

  37. 2017年8月3日16:47 | #37

    Thanks for every other informative site. The place else could I am getting
    that type of info written in such an ideal approach? I’ve a undertaking that I am simply now working on, and I’ve been at
    the glance out for such information.

  38. 2017年8月3日18:45 | #38

    Yesterday i read some shocking info about Omega 3 stuff and now i very wanna get it. But i’m not really sure which benefits will i have. I’ve got this omega 3 info , and now i want to get it with best price. Any idea?

  39. 2017年8月3日21:33 | #39

    I loved as much as you will receive carried out right here.

    The sketch is tasteful, your authored subject matter stylish.
    nonetheless, you command get got an shakiness over that you wish be delivering
    the following. unwell unquestionably come further formerly again since exactly the same nearly very often inside case you
    shield this hike.

  40. 2017年8月4日08:28 | #40

    Day ago i read some cool info about Omega 3 stuff and now i really wanna buy it. But i’m not absolutely sure which pluses will i have. I’ve got this omega 3 info , and now i wanna purchase it with best price. Any idea?

  41. 2017年8月4日14:18 | #41

    Fastidious respond in return of this matter with
    real arguments and describing all on the topic of that.

  42. 2017年8月4日22:13 | #42

    Yesterday i read some amazing info about Omega 3 foods and now i really wanna buy it. But i’m not 100% sure which pluses will i have. I’ve got this omega 3 info , and now i wanna buy it with best price. Any idea?

  43. 2017年8月4日22:25 | #43

    Do you have any video of that? I’d love to find out more details.

  44. 2017年8月4日22:38 | #44

    Hello very nice blog!! Man .. Beautiful .. Superb ..
    I’ll bookmark your blog and take the feeds also?
    I’m happy to search out a lot of helpful info right here in the post,
    we’d like work out more techniques in this regard,
    thanks for sharing. . . . . .

  45. Carolynmal
    2017年8月5日01:24 | #45

    Revolutional update of SEO/SMM package “XRumer 16.0 + XEvil 3.0″:
    captchas regignizing of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex,
    and more than 8400 another types of captchas,
    with highest precision (80..100%) and highest speed (100 img per second).
    You can connect XEvil 3.0 to all most popular SEO/SMM programms: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other programms.

    Interested? You can find a lot of introducing videos about XEvil in YouTube.
    You read it – then IT WORKS!
    See you later!

    XRumer201708

  46. Carolynmal
    2017年8月5日06:31 | #46

    Revolutional update of SEO/SMM package “XRumer 16.0 + XEvil 3.0″:
    captcha breaking of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex,
    and more than 8400 another size-types of captchas,
    with highest precision (80..100%) and highest speed (100 img per second).
    You can connect XEvil 3.0 to all most popular SEO/SMM programms: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other programms.

    Interested? There are a lot of demo videos about XEvil in YouTube.
    You read it – then IT WORKS!
    Good luck ;)

    XRumer201708

  47. 2017年8月5日07:57 | #47

    I simply couldn’t depart your web site before suggesting that I really enjoyed the
    standard information a person provide for your guests?
    Is gonna be again often in order to investigate cross-check new
    posts

  48. 2017年8月5日12:54 | #48

    Hello every one, here every one is sharing these kinds of know-how, therefore it’s nice to read this website, and I used
    to go to see this weblog every day.

  49. 2017年8月5日13:12 | #49

    Yesterday i read some interesting info about Omega 3 stuff and now i really wanna buy it. But i’m not really sure which benefits will i have. I’ve got this [url=https://buy-omega-3.com] omega 3 info [/url] , and currently i wanna purchase it with best price. Any idea?

  50. 2017年8月5日15:00 | #50

    Hi would you mind sharing which blog platform you’re working with?

    I’m going to start my own blog soon 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 Apologies
    for being off-topic but I had to ask!

评论分页
1 2 3 ... 10 528
订阅评论
5+6= (必填)