Linux内核编译,配置本机驱动

1.前言                                                 

编译Linux内核失败的原因很多时候就是驱动选错,适合自己本机的驱动没编译进去。面对特殊平台(或者有些洁癖者,我就是^_^),要编译精简内核,只要本机驱动,其他都不需要。面对内核里面这么多驱动,不懂硬件的我们,看到都头大。本人第一次安装gentoo的时候,内核编译了5次,前4次主要失败原因是以太网卡驱动、无线网卡驱动、显卡驱动、声卡驱动都没一次性配置正确。虽然gentoo提供了genkernel命令,可以自动帮你编译内核,但还是想自己手工尝试下。

2.获取本机驱动信息                             

既然跟内核挂钩,我们获取本机内核驱动信息最直接的办法就是使用lspci命令,这个命令可以输出本机驱动信息,配合-k选项可以看到此驱动在内核的位子。

一般编译内核的场景:更新旧内核,安装定制版linux发行版(gentoo,arch等),嵌入式平台,其他特殊平台等等...

大部分场景在下都可以使用lspci命令,安装gentoo的livecd版都提供了该工具,如果其他系统没有就安装该工具

debian系列安装

1 $:sudo apt-get install pciutils

或者源码编译安装,下载地址https://www.kernel.org/pub/software/utils/pciutils/

然后我们获取本机环境现存的驱动信息,下面是我的机器上面的信息:

1 $:lspci -k 2 00:00.0 Host bridge: Intel Corporation 2nd Generation Core Processor Family DRAM Controller (rev 09) 3 Subsystem: Lenovo Device 21e2 4 00:01.0 PCI bridge: Intel Corporation Xeon E3-1200/2nd Generation Core Processor Family PCI Express Root Port (rev 09) 5 Kernel driver in use: pcieport 6 00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09) 7 Subsystem: Lenovo Device 21e3 8 Kernel driver in use: i915 9 00:16.0 Communication controller: Intel Corporation 6 Series/C200 Series Chipset Family MEI Controller #1 (rev 04) 10 Subsystem: Lenovo Device 21e2 11 Kernel driver in use: mei_me 12 00:1a.0 USB controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #2 (rev 04) 13 Subsystem: Lenovo Device 21e2 14 Kernel driver in use: ehci-pci 15 00:1b.0 Audio device: Intel Corporation 6 Series/C200 Series Chipset Family High Definition Audio Controller (rev 04) 16 Subsystem: Lenovo Device 21e2 17 Kernel driver in use: snd_hda_intel 18 00:1c.0 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 1 (rev b4) 19 Kernel driver in use: pcieport 20 00:1c.1 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 2 (rev b4) 21 Kernel driver in use: pcieport 22 00:1c.2 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 3 (rev b4) 23 Kernel driver in use: pcieport 24 00:1c.3 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 4 (rev b4) 25 Kernel driver in use: pcieport 26 00:1c.7 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 8 (rev b4) 27 Kernel driver in use: pcieport 28 00:1d.0 USB controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #1 (rev 04) 29 Subsystem: Lenovo Device 21e2 30 Kernel driver in use: ehci-pci 31 00:1f.0 ISA bridge: Intel Corporation HM65 Express Chipset Family LPC Controller (rev 04) 32 Subsystem: Lenovo Device 21e2 33 Kernel driver in use: lpc_ich 34 00:1f.2 SATA controller: Intel Corporation 6 Series/C200 Series Chipset Family 6 port SATA AHCI Controller (rev 04) 35 Subsystem: Lenovo Device 21e2 36 Kernel driver in use: ahci 37 00:1f.3 SMBus: Intel Corporation 6 Series/C200 Series Chipset Family SMBus Controller (rev 04) 38 Subsystem: Lenovo Device 21e2 39 01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Seymour [Radeon HD 6400M/7400M Series] (rev ff) 40 Kernel driver in use: radeon 41 03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 06) 42 Subsystem: Lenovo Device 21e2 43 Kernel driver in use: r8169 44 04:00.0 System peripheral: Ricoh Co Ltd PCIe SDXC/MMC Host Controller (rev 07) 45 Subsystem: Lenovo Device 21e2 46 Kernel driver in use: sdhci-pci 47 09:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8188CE 802.11b/g/n WiFi Adapter (rev 01) 48 Subsystem: Realtek Semiconductor Co., Ltd. Device 8195 49 Kernel driver in use: rtl8192ce

我们可以看到每个驱动后面都有Kernel driver in use:,代表驱动在内核中的链接位子。

3.配置内核驱动                             

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/e12d1f6eccf71198c87296c8f13e1fba.html