首页 > 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年8月5日16:54 | #1

    Hurrah, that’s what I was looking for, what a information! present here at this blog, thanks admin of this
    web site.

  2. 2017年8月5日19:00 | #2

    If some one wishes expert view about blogging and site-building afterward
    i propose him/her to visit this web site, Keep up the pleasant work.

  3. 2017年8月6日00:05 | #3

    Just want to say your article is as astounding. The clearness on your
    put up is just spectacular and that i can suppose you are a professional on this subject.
    Well along with your permission let me to seize your RSS feed to stay updated with
    impending post. Thanks 1,000,000 and please continue the gratifying work.

  4. 2017年8月6日05:56 | #4

    I have been exploring for a little bit for any high quality articles or weblog posts on this kind of house .
    Exploring in Yahoo I finally stumbled upon this website.
    Studying this info So i am happy to convey that
    I’ve an incredibly just right uncanny feeling I found out exactly what I needed.

    I most definitely will make certain to do not put out of your mind this site and provides it
    a glance on a continuing basis.

  5. 2017年8月6日06:16 | #5

    I feel this is among the such a lot vital info for me.

    And i’m satisfied reading your article. However should statement on some basic things, The web site taste is wonderful, the articles
    is actually great : D. Excellent job, cheers

  6. 2017年8月6日20:58 | #6

    It’s actually very complex in this active life to listen news
    on Television, so I only use the web for that reason, and obtain the newest information.

  7. 2017年8月6日21:17 | #7

    What’s up to every one, the contents existing at this site
    are actually awesome for people experience, well, keep up the nice work fellows.

  8. 2017年8月6日23:00 | #8

    Yesterday i got some interesting info about Omega 3 stuff and now i really wanna buy it. But i’m not 100% sure which benefits will i have. I’ve found this omega 3 info , and currently i wanna buy it with lowest price. Any idea?

  9. 2017年8月7日05:40 | #9

    Appreciate the recommendation. Let me try it out.

  10. 2017年8月7日15:54 | #10

    Yesterday i read some amazing info about Omega 3 stuff and now i really wanna get it. But i’m not absolutely sure which pluses will i have. I’ve found this omega 3 info , and currently i wanna get it with good price. Any idea?

  11. 2017年8月7日23:32 | #11

    Amazing! This blog looks just like my old one! It’s on a completely different subject but it
    has pretty much the same layout and design.
    Superb choice of colors!

  12. 2017年8月8日11:20 | #12

    Whoa! This blog looks exactly like my old one!

    It’s on a completely different subject but it has pretty much the same page layout and design. Superb choice of colors!

  13. 2017年8月8日23:56 | #13

    Yesterday i read some cool 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 currently i wanna get it with good price. Any idea?

  14. 2017年8月9日07:16 | #14

    Undeniably consider that which you said. Your favorite justification seemed to be at
    the internet the easiest factor to consider of. I say to you, I certainly get annoyed at the
    same time as other people think about concerns that they just do not recognise about.
    You managed to hit the nail upon the highest
    as well as defined out the entire thing with no need side-effects ,
    other folks could take a signal. Will probably be back to get more.
    Thanks

  15. 2017年8月9日13:23 | #15

    Way cool! Some very valid points! I appreciate you writing this article and the rest of
    the site is extremely good.

  16. 2017年8月9日15:28 | #16

    It is appropriate time to make some plans for the future and it is time to be happy.
    I’ve read this post and if I could I desire to suggest you
    some interesting things or tips. Maybe you could write next articles referring to this article.
    I wish to read even more things about it!

  17. 2017年8月9日17:02 | #17

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

  18. 2017年8月10日01:15 | #18

    I couldn’t refrain from commenting. Well written!

  19. 2017年8月10日09:20 | #19

    A motivating discussion is worth comment. I think that you
    ought to publish more about this subject, it might not be a taboo
    matter but generally folks don’t talk about these issues. To the next!

    Many thanks!!

  20. 2017年8月10日09:48 | #20

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

  21. 2017年8月10日10:31 | #21

    Hello, I think your site might be having browser compatibility issues.

    When I look at your blog in Safari, it looks fine but when opening in Internet Explorer,
    it has some overlapping. I just wanted to give you a quick heads up!
    Other then that, amazing blog!

  22. 2017年8月10日16:41 | #22

    Peculiar article, totally what I needed.

  23. 2017年8月11日01:35 | #23

    Day ago 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 wanna purchase it with best price. Any idea?

  24. 2017年8月11日16:32 | #24

    This is the right site for everyone who wants to find out
    about this topic. You know so much its almost hard to argue with
    you (not that I really would want to…HaHa). You definitely put a new spin on a topic
    that has been discussed for ages. Wonderful stuff, just great!

  25. 2017年8月11日17:47 | #25

    Yesterday i read some cool info about Omega 3 stuff and now i very wanna get it. But i’m not absolutely sure which pluses will i have. I’ve got this [url=https://buy-omega-3.com] omega 3 info [/url] , and now i wanna buy it with lowest price. Any idea?

  26. 2017年8月12日06:31 | #26

    Hi there, I enjoy reading through your post.
    I wanted to write a little comment to support you.

  27. 2017年8月12日10:51 | #27

    Yesterday i read some cool 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 found this omega 3 info , and currently i wanna buy it with lowest price. Any idea?

  28. 2017年8月12日12:42 | #28

    ВНИМАНИЕ!!! Ядекс и отношение к клиентам смотреть всем!!!
    Посмотрел и был в ШОКЕ….
    Вот ссылка на Ютуб
    https://www.youtube.com/watch?v=IdYDpLcuVnA

  29. 2017年8月13日11:13 | #29

    WOW just what I was searching for. Came here by searching for ii code scanner

  30. 2017年8月13日20:00 | #30

    Yesterday i read some shocking 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 found this omega 3 info , and currently i want to buy it with lowest price. Any idea?

  31. 2017年8月14日13:50 | #31

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

  32. 2017年8月15日18:01 | #32

    Hmm it seems like your website ate my first comment (it was super
    long) so I guess I’ll just sum it up what I submitted and say, I’m thoroughly enjoying your
    blog. I too am an aspiring blog writer but I’m still new to everything.

    Do you have any points for first-time blog writers?
    I’d really appreciate it.

  33. 2017年8月15日21:33 | #33

    Hey! I know this is sort of off-topic but I had to ask. Does operating a well-established blog
    such as yours take a large amount of work?
    I’m brand new to blogging but I do write in my diary on a daily basis.
    I’d like to start a blog so I will be able to share
    my experience and thoughts online. Please let me know if you have any kind of recommendations or tips for
    new aspiring bloggers. Thankyou!

  34. 2017年8月15日22:23 | #34

    Fastidious answers in return of this question with genuine arguments and telling the whole thing about that.

  35. Avito777Max
    2017年8月16日04:02 | #35

    Пополение баланса Авито (Avito) за 50% | Телеграмм @a1garant

    Здравствуйте, дорогие друзья!

    Рады предоставить Всем вам сервис по пополнению баланса на действующие активные аккаунты Avito (а также, абсолютно новые). Если Вам нужны определенные балансы – пишите, будем решать. Потратить можно на турбо продажи, любые платные услуги Авито (Avito).

    Аккаунты не Брут. Живут долго.

    Процент пополнения в нашу сторону и стоимость готовых аккаунтов: 50% от баланса на аккаунте.
    Если необходим залив на ваш аккаунт, в этом случае требуются логин и пароль Вашего акка для доступа к форме оплаты, пополнения баланса.
    Для постоянных клиентов гибкая система бонусов и скидок!
    Гарантия:

    И, конечно же ничто не укрепляет доверие, как – Постоплата!!! Вперед денег не просим… А также, гасим Штрафы ГИБДД за 65% …

    Оплата:
    ЯндексДеньги, Webmoney (профессиональные счета)
    Рады сотрудничеству!

    канал Телеграмм @t.me/avito50
    ________

    авито дома
    авито пакет +для новорожденных
    вещи пакетом +на девочку +на авито
    купить вещи пакетом +в авито
    турбо продажа +на авито со скидкой

  36. 2017年8月17日01:24 | #36

    Some time ago i learned new shocking info about Omega 3 foods and now i very want to purchase it. But i want a quality, only premium omega 3 fish oil. I’ve got this premium omega 3 fish oil url. What do you think about Carlson brand?

评论分页
1 2 528
订阅评论
3+9= (必填)