標籤:linux x86 嵌入式 核心
有的時候,開發時需要用到裝置的pci ID,如用dpdk來綁定某個網卡,需要用網卡的pci ID。下面有一些方法是可以擷取pci ID的。
1.使用lspci命令。
如
02:00.0 USB controller: Intel Corporation 82371AB/EB/MB PIIX4 USB02:01.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)02:02.0 Multimedia audio controller: Ensoniq ES1371 / Creative Labs CT2518 [AudioPCI-97] (rev 02)02:03.0 USB controller: VMware USB2 EHCI Controller
第一列就是PCI ID,後面就是裝置名稱和供應商名稱。可以看到乙太網路卡的PCI ID是02:01.0
但有時候在一些嵌入式的系統裡,lspci命令並不是由pciutils提供,而是由其它軟體包提供,或者是修改過,輸出結果可能如下:
上面結果和centos是同一個虛擬機器,只是用一個嵌入式核心+ramfs啟動的, 命令是lspci -vmm
遇到這種情況,只能上http://www.pcidatabase.com/ 尋找相應的Vendor和Device,再一一比對。
如02:01.0的是8086和100f
| 0x100F |
Intel(R) PRO/1000 MT Network Connection |
0x8086 |
Intel Corporation |
2.用dmesg命令。
如
e1000 0000:02:01.0: PCI INT A -> GSI 19 (level, low) -> IRQ 19e1000 0000:02:01.0: setting latency timer to 64e1000 0000:02:01.0: eth0: (PCI:66MHz:32-bit) 00:0c:29:62:d0:69e1000 0000:02:01.0: eth0: Intel(R) PRO/1000 Network Connection
也可以看到乙太網路卡的PCI ID是02:01.0
這種方法無論是在通用的發行版或是定製的嵌入式系統,都適用。
Linux下擷取裝置pci ID的方法