NetFPGA-1G-CML從零開始環境配置
前言
偶得一塊NetFPGA-1G-CML,跟着github對NetFPGA-1G-CML的入門指南,一步步把配置環境終於搭建起來,下面重新復現一下此過程。期間感謝開發板的技術人員支持與幫助,得以成功配置環境。
https://github.com/NetFPGA/NetFPGA-public/wiki/NetFPGA-1G-CML-Getting-Started-Guide
實驗工具
- NetFPGA-1G-CML開發板
- 一台有PCIe口的主機
下為工具照片:
1、操作系統的選擇
官方推薦Fedora 20,於是我也選擇了該操作系統。
-
鏡像選擇
鏡像為清華大學鏡像源的鏡像(國內其他鏡像源中沒有找到Fedora 20 64bit的版本)下載鏈接
-
系統盤制作
- 一個8G U盤
- 系統盤制作工具 PowerISO。(切記不要用軟碟通UltraISO(軟碟通),原因軟碟通不適合做linux的系統盤,筆者第一次也是采用軟碟通進行系統盤制作,結果出現了一些問題,后來用PowerISO一切正常)
可參照這篇文章:制作Linux(Fedora、Ubuntu、CentOS)優盤啟動
2、Xilinx開發工具的下載
這個是整個環境安裝中最耗費時間的一個地方,建議在windows下用迅雷下載,然后轉到fedora下,因為文件相當龐大。之前筆者也下了下列兩個工具的最新的版本,可中途也出了莫名其妙的問題,最終成功的環境還是以以下兩個工具為基礎。
-
ISE Design Suite 14.6(筆者選擇的是鏈接中基於Linux的完整安裝程序5.88G,之前安裝過ISE Design Suite 14.7的,可其中缺少EDK變量,后來重新換成了這個。安裝教程:見Reference Operating System鏈接里Installing Xilinx ISE Design Suite on Fedora 14部分,有一點不一樣,連接中版本較老,但鏈接的提示中,選項該去掉依然參照它)
tip:ISE工具需要license,否則無法build。如果您已經擁有license,則可導入,否則還有一種辦法:百度一下即可發現驚喜。
-
Vivado Desgin Suite 15.2 (筆者選擇的是鏈接中,2015.02的版本, Vivado 2015.2: Full Installer For Linux Single File Download Image Including SDK (TAR/GZIP - 4.58 GB) ,安裝過程遇ISE類似)
3、獲得NetFPGA-1G-CML對應github倉庫的權限
在次NetFPGA官網的鏈接中填入你的相關信息,則工作人員會把拉到對應倉庫下,然后可以clone下來到本地。
以下步驟皆基於本倉庫。
4、Fedora 20操作系統環境所需配置的安裝
下面簡單羅列命令,至於每個命令所需安裝的內容是為何物,請查看Getting Started Guide的Operating System Setup以及Reference Operating System的Additional Required Installation Packages。
sudo yum install '*stdc*'
sudo yum install libsigc++ libsigc++.i686 qt.i686 qt
sudo yum groups mark convert
sudo yum group install "Fedora Eclipse"
sudo yum install qgit wireshark wireshark-gnome
sudo yum install python
sudo yum install scapy
sudo yum install fxload
sudo yum install bison byacc flex
sudo yum install glibc.i686
sudo yum install kernel-devel
sudo yum install libusb-devel
sudo yum install libpcap-devel
sudo yum install libnet-devel
其后四個命令,由於筆者在安裝過程中采用是按tab鍵得到,相關名稱可能會有點差異,具體看操作系統級別(32bit or 64bit)選擇安裝。
5、環境配置,以及跑一個demo
Step1、獲得git倉庫權限后,把倉庫clone到本地
tip:切記此時你已經獲得了該倉庫的權限(有時候郵件沒收到,可能在垃圾箱里面)
git clone https://github.com/NetFPGA/NetFPGA-1G-CML-live.git
Step2、建立編譯環境路徑變量
- 取得賽靈思工具的路徑
source /opt/Xilinx/14.6/ISE_DS/settings64.sh
source /opt/Xilinx/Vivado/2015.2/settings64.sh
- 取得clone后倉庫的路徑
路徑的信息保存於該倉庫的文件bashrc_addon_NetFPGA_10G
中,記得根據實際路徑進行修改,比如筆者的倉庫位於/home/netfpga/Program/NetFPGA-1G-CML-live
,所以筆者該文件的信息修改如下:
export NF_ROOT=${HOME}/Program/NetFPGA-1G-CML-live
export NF_DESIGN_DIR=${NF_ROOT}/projects/reference_nic_nf1_cml
export NF_WORK_DIR=/tmp/${USER}
export PYTHONPATH=${NF_ROOT}/lib/python:${NF_DESIGN_DIR}/lib/Python:${NF_ROOT}/tools/scripts:
export LD_LIBRARY_PATH=${NF_ROOT}/lib/java/NetFPGAFrontEnd/bin:${LD_LIBRARY_PATH
然后執行命令
source bashrc_addon_NetFPGA_10G
為了更好確認上部是否寫對,可以執行一下命令看看輸出
echo $NF_ROOT
此時如果輸出為倉庫的所在的絕對路徑,就證明正確了。
Step3、 Build the Libraries and IP
此處由於筆者還不了解大概這些庫的功能,中文無法直接翻譯。
tip:這個步驟的過程一定要基於ISE已經導入license
To build the hardware test libraries for the hardware and simulation tests:
cd $NF_ROOT
make hwtestlib
To build the IP cores used by the NF1-CML projects:
make cml_cores
上述兩個步驟,若無出現make ...錯誤都表示步驟已經成功進行。
Step4、編譯一個工程
本次 $NF_DESIGN_DIR
所選擇的工程為 reference_nic_nf1_cml
一個簡單的網卡(若想編譯其他工程,記得去bashrc_addon_NetFPGA_10G
修改對應的$NF_DESIGN_DIR
路徑)
cd $NF_DESIGN_DIR
make
此時你會等待相當長的一段時間,最后如果成功后最后兩行會顯示如下:
mkdir -p bitfiles
cp hw/implementation/download.bit bitfiles/reference_nic_nf1_cml.bit
Step5、連接FPGA到主機
筆者是用J12的usb jtag引腳作為連接主機的口,這里主要介紹一下相關驅動的安裝,以及一些坑。
如圖所示
首先下載usb驅動,驅動:rmdir.de/~michael/xilinx/
驅動安裝步驟
tar -xvf usb-driver-HEAD-xxxxxxx.tar.gz
cd usb-driver-HEAD-xxxxxxx
source /opt/Xilinx/13.4/ISE_DS/settings64.sh 這里要相應改變
make
./setup_pcusb
cp libusb-driver.so /usr/local/lib/libusb-jtag-driver.so
export LD_PRELOAD=/usr/local/lib/libusb-jtag-driver.so
之后用命令lsusb
可以看到
[netfpga@localhost bin]$ lsusb
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 1443:0007 Digilent Development board JTAG //這個就是我們的設備
Bus 002 Device 003: ID 1c4f:0002 SiGma Micro Keyboard TRACER Gamma Ivory
Bus 002 Device 004: ID 192f:0916 Avago Technologies, Pte.
可是通過impact &
打開ISE impact又有提示如下圖所示問題,需重新裝驅動
后來在技術人員幫助下,有了一個解決答案,具體的下載文件請移步另外一篇博客:Digilent Xilinx USB Jtag cable。
根據上述做完,即可從impact &
看到我們的FPGA芯片。
Step6、燒寫程序到FPGA中
進入到項目文件夾下,執行以下命令
make download
然后燒寫成功后,會有如下輸出
INFO:iMPACT - '1': Checking done pin....done.
'1: Programmed successfully.
Elapsed time = 62 sec.
rm -f bitfiles/download.bit
Step7、安裝NetFPGA-1G-CML作為系統設備
首先確保已經把NetFPGA-1G-CML開發板插到PCIe口上,如圖所示
然后執行以下命令,並可看到該設備
lspci | grep Xilinx
01:00.0 Ethernet controller: Xilinx Corporation Device 4244
安裝NetFPGA-1G-CML驅動,在這之前,請在執行一次
cd $NF_ROOT
source bashrc_addon_NetFPGA_10G
make hwtestlib
安裝必要組件
sudo yum install kernel-devel-3.11.10-301.fc20.x86_64
編譯驅動
cd $NF_DESIGN_DIR/sw/host/driver
make
安裝驅動
sudo insmod nf10.ko
初始化NetFPGA-1G-CML的四個以太網接口
sudo ifconfig nf0 up
sudo ifconfig nf1 up
sudo ifconfig nf2 up
sudo ifconfig nf3 up
執行一下ifconfig
,可以看到四個以太網卡出現了
[netfpga@localhost bin]$ ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 10 bytes 940 (940.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 10 bytes 940 (940.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
nf0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.200.1 netmask 255.255.255.0 broadcast 192.168.200.255
inet6 fe80::24e:46ff:fe31:3000 prefixlen 64 scopeid 0x20<link>
ether 00:4e:46:31:30:00 txqueuelen 1000 (Ethernet)
RX packets 377 bytes 528796 (516.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 377 bytes 534074 (521.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 30
nf1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.201.1 netmask 255.255.255.0 broadcast 192.168.201.255
inet6 fe80::24e:46ff:fe31:3001 prefixlen 64 scopeid 0x20<link>
ether 00:4e:46:31:30:01 txqueuelen 1000 (Ethernet)
RX packets 377 bytes 528796 (516.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 377 bytes 534074 (521.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 30
nf2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.202.1 netmask 255.255.255.0 broadcast 192.168.202.255
inet6 fe80::24e:46ff:fe31:3002 prefixlen 64 scopeid 0x20<link>
ether 00:4e:46:31:30:02 txqueuelen 1000 (Ethernet)
RX packets 371 bytes 528372 (515.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 377 bytes 534074 (521.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 30
nf3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.203.1 netmask 255.255.255.0 broadcast 192.168.203.255
inet6 fe80::24e:46ff:fe31:3003 prefixlen 64 scopeid 0x20<link>
ether 00:4e:46:31:30:03 txqueuelen 1000 (Ethernet)
RX packets 370 bytes 528316 (515.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 377 bytes 534074 (521.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 30
p4p1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.105 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 fe80::922b:34ff:feba:728b prefixlen 64 scopeid 0x20<link>
ether 90:2b:34:ba:72:8b txqueuelen 1000 (Ethernet)
RX packets 3421 bytes 2595675 (2.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 5648 bytes 583390 (569.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Step8、Making Registers
對於這個步驟,筆者較為陌生,編譯寄存器的相關映射,再次只做操作步驟,原理還需細究
$ cd $NF_DESIGN_DIR/hw
$ make regs
在此處步驟,筆者遇到一個莫名其妙的問題,編譯不通過,然后出去吃個飯,重啟了一下,重新打開makefile
保存了一下,竟莫名其妙的解決了.(已解決)
解決方案,重新打開一個終端,執行命令
source /opt/Xilinx/14.6/ISE_DS/settings64.sh
source bashrc_addon_NetFPGA_10G
然后在去執行上述步驟
Step9、Verify the Design in Hardware with the Test Infrastructure
最終步驟驗證實驗,並把四個以太網口按如圖所示接上,NF0---NF3,NF1---NF2
cd $NF_ROOT/tools/bin
su -c "./nf_test.py hw --major loopback --minor maxsize"
然后如果測試成功會有如下顯示:
Running global setup... PASS
Running test both_loopback_maxsize... PASS
Running global teardown... PASS
然后在執行一遍ifconfig
,可以發現NF0-3各個網卡的收發包較上次執行ifconfig
有了上漲
[netfpga@localhost bin]$ ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 10 bytes 940 (940.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 10 bytes 940 (940.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
nf0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.200.1 netmask 255.255.255.0 broadcast 192.168.200.255
inet6 fe80::24e:46ff:fe31:3000 prefixlen 64 scopeid 0x20<link>
ether 00:4e:46:31:30:00 txqueuelen 1000 (Ethernet)
RX packets 427 bytes 603796 (589.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 427 bytes 609774 (595.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 30
nf1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.201.1 netmask 255.255.255.0 broadcast 192.168.201.255
inet6 fe80::24e:46ff:fe31:3001 prefixlen 64 scopeid 0x20<link>
ether 00:4e:46:31:30:01 txqueuelen 1000 (Ethernet)
RX packets 427 bytes 603796 (589.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 427 bytes 609774 (595.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 30
nf2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.202.1 netmask 255.255.255.0 broadcast 192.168.202.255
inet6 fe80::24e:46ff:fe31:3002 prefixlen 64 scopeid 0x20<link>
ether 00:4e:46:31:30:02 txqueuelen 1000 (Ethernet)
RX packets 421 bytes 603372 (589.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 427 bytes 609774 (595.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 30
nf3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.203.1 netmask 255.255.255.0 broadcast 192.168.203.255
inet6 fe80::24e:46ff:fe31:3003 prefixlen 64 scopeid 0x20<link>
ether 00:4e:46:31:30:03 txqueuelen 1000 (Ethernet)
RX packets 420 bytes 603316 (589.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 427 bytes 609774 (595.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 30
p4p1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.105 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 fe80::922b:34ff:feba:728b prefixlen 64 scopeid 0x20<link>
ether 90:2b:34:ba:72:8b txqueuelen 1000 (Ethernet)
RX packets 3441 bytes 2598545 (2.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 5697 bytes 590789 (576.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
至此,安裝環境測試完畢
結語
本篇博客只是把NetFPGA-1G-CML的步驟走了一遍,描述了遇到的問題以及相關解決方案,並沒有詳細描述每一個步驟的目的,建議讀者閱讀原github上的Getting-Started-Guide,並以本文作為輔助。
圖片較為模糊,很抱歉,也較大。