petalinux+nvme, doesn't match header type 01
阿新 • • 發佈:2022-04-13
說明
petalinux + nvme, 在系統下對ssd盤識別並掛載讀寫
在邏輯工程師匯出對應的hdf檔案後,需要通過petalinux去做系統,系統做完之後, 系統能起來, PCI能起來,但是檢測裝置資訊錯誤如下:
[ 2.006434] nwl-pcie fd0e0000.pcie: Link is UP [ 2.010353] OF: PCI: host bridge /amba/pcie@fd0e0000 ranges: [ 2.015954] OF: PCI: MEM 0xe0000000..0xefffffff -> 0xe0000000 [ 2.021827] OF: PCI: MEM 0x600000000..0x7ffffffff -> 0x600000000 [ 2.028076] nwl-pcie fd0e0000.pcie: PCI host bridge to bus 0000:00 [ 2.034112] pci_bus 0000:00: root bus resource [bus 00-ff] [ 2.039558] pci_bus 0000:00: root bus resource [mem 0xe0000000-0xefffffff] [ 2.046391] pci_bus 0000:00: root bus resource [mem 0x600000000-0x7ffffffff pref] [ 2.053860] pci 0000:00:00.0: ignoring class 0x058000 (doesn't match header type 01) [ 2.061964] pci 0000:01:00.0: BAR 0: no space for [mem size 0x00004000 64bit] [ 2.068624] pci 0000:01:00.0: BAR 0: failed to assign [mem size 0x00004000 64bit] [ 2.076061] pci 0000:00:00.0: not setting up bridge for bus 0000:01
使用lspci檢視
root@mynvme01:~# lspci
00:00.0 Non-VGA unclassified device: Xilinx Corporation Device d011
01:00.0 Non-Volatile memory controller: Device 1bc0:1002 (rev 01)
解決方案
檢視 petalinux原始碼, pci啟動時候 報錯資訊對應程式碼如下 doesn't match header type 01
整體程式碼如下: 總共有三處 goto bad;分支
因為dev->hdr_type
為01
, 所以程式碼走PCI_HEADER_TYPE_BRIDGE
case PCI_HEADER_TYPE_BRIDGE: /* bridge header */ //PCI_HEADER_TYPE_BRIDGE 為 1
if (class != PCI_CLASS_BRIDGE_PCI) //PCI_CLASS_BRIDGE_PCI 為 0x0604
goto bad;
也就說是 dev->hdr_type
為 01
的時候, class
的值只能是 0x0604
, 系統核心才不會報錯
class 程式碼片段如下
1398: u32 class; // #define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8 revision */ 1425: pci_read_config_dword(dev, PCI_CLASS_REVISION, &class); 1427: dev->class = class >> 8; /* upper 3 bytes */ 1444: class = dev->class >> 8;
可以看出 class是32bit, 最後對比的是 前 16bit 的資料, class 前24bit代表等級
其中 pci_read_config_dword
讀取的應該是配置
檢視 dev->class
屬性
可以看出 class 前兩個位元組分別代表 base 和 sub, 開啟 vivado 工程, 點開pci裝置, 設定資訊如下, 0x0604
即可