一、下載VITIS-AI的倉庫
單獨git clone很慢,因此先將其導入到gitee平台,再執行clone
1. Import VITIS-AI github repo into gitee repo
2. Git clone repo from gitee
二、安裝Docker
參考:https://docs.docker.com/engine/install/ubuntu/,並執行:
1. “Install using the repository”的全部步驟
2. “Install Docker Engine”的 sudo apt-get install docker-ce docker-ce-cli containerd.io
三、修改docker的配置文件
使用國內鏡像(阿里雲、網易雲
....
)。
sudo gedit /etc/docker/daemon.json
{
"registry-mirrors": [
"https://kfwkfulq.mirror.aliyuncs.com",
"https://2lqq34jg.mirror.aliyuncs.com",
"https://pee6w651.mirror.aliyuncs.com",
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com"
]
}
參考:
https://blog.oioweb.cn/index.php/archives/1347.html
四、加載重啟docker
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
五、從docker中下載文件
sudo docker pull xilinx/vitis-ai:latest
六、Run docker
打開從gitee下載的Vitis-AI文件路徑
cd Vitis-AI
sudo ./docker_run.sh xilinx/vitis-ai:latest
按照提示操作知道出現logo“VITIS—AI”表示安裝成功,輸入exit退出。
七、下載VITIS-AI tutorial
該倉庫的master分支只有一個Readme.md文件。其他的例子在其他份分支上:
如果想切換到其他分支(比如Vitis-AI-Custom-Platform),則執行git checkout Vitis-AI-Custom-Platform。
VitisAI(Ultra96v2)平台教程(GitHub開源 https://github.com/Xilinx/Vitis-AI-Tutorials/tree/Vitis-AI-Custom-Platform)
一、閱讀Vitis-AI-Tutorial文件中
/files/tutorials/1-Building-a-Vitis-Ultra96V2-and-MIPI-platform.md
1、 首先在Vivado中創建MIPI項目,安裝Petalinux工具。其次在ultra96上啟動硬件和軟件鏡像來觀察MIPI視頻。
1.1、將Vitis-AI-Tutorial文件夾中 reference-files/vivado/sources的sources文件復制到 build/vivado 路徑下。
1.2、打開Vivado2019.2(后綜合發現vivado2019.2版本不支持mipi IP核,vivado2020.1版本方可支持)
1.3、在build/vivado創建一個新的項目,將其命名為‘ultra96v2_mipi’-----選擇RTL項目-----do not specify sources-----Boards-----Ultra96v2-----Finish。
1.4、在Tcl控制台窗口打開sources路徑。
1.5、Use the Tcl Console to call `source ./sources/u96v2_mipi.tcl`.
1.6、在Sources標簽中右鍵`u96v2_mipi.bd`然后‘Create HDL Wrapper’。
1.7、添加xdc文件,從 `build/vivado/sources` 復制`cnst.xdc`文件到項目約束文件中。
2、為使用Vitis開發工具設計做准備
打開Vivado工程修改硬件設計為軟件加速做准備。
3、配置平台接口
3.1、添加ZYNQUltraSCALE IP核,打開“Window”目錄選擇“Platform Interfaces”,
使能下列三個PS從接口,和一個master主接口(如果不做使能配置,直接在ZYNQ GUI界面勾選應該是可以的)
* S_AXI_HP0_FPD
* S_AXI_HP1_FPD
* S_AXI_HP2_FPD
* HPM0_FPD
Platform Interfaces**Options**選項中將三個slave接口的“stpg”值依次設置為: `HP0`, `HP1`, and `HP2`
4、指定平台時鍾
4.1. Double-click the **clk_wiz_0 IP**, and make the following changes in the Output Clocks tab:`[clk_out3=150MHz], [clk_out4=300MHz], [Matched routing selected on clk_out3/4], [Reset Type = Active Low]`
4.2. Right-click the block design, select **Add IP**, and add a processor system reset IP for each of the new clocks.
4.3 Name the new clocks, `proc_sys_reset_dynamic_1` and `proc_sys_reset_dynamic_2`.
4.4 Connect the `clk_out3` and `clk_out4` outputs of `clk_wiz_0` block to `proc_sys_reset_dynamic_1` and `proc_sys_reset_dynamic_2` `slowest_sync_clk` inputs, respectively.
4.5 Connect the `ext_reset_in`(proc_sys_rest IP的接口) to `pl_resetn0` on the MPSoC block.
4.6 Connect the "locked" output of the Clock Wizard to the `dcm_locked` port of the processor reset blocks.
4.7 確保每個‘proc_sys_reset` 模塊的`ext_reset_in` 與`pl_resetn0` 連接。
4.8 In the Platform Interfaces tab, enable `clk_out3` and `clk_out4` of the `clk_wiz_0` instance.
4.9 Set the slower clock (in this case, `clk_out3`) as the default. `clk_out3` should have its id set to 0, and `clk_out4` should have its id set to 1.
4.10 Make sure the `proc_sys_reset` block listed in each window is set to the instance that is connected to that clock. Check the properties/options window when each clock is selected in platform interfaces, and verify the proc_sys_reset parameter matches.
5、使能中斷
5.1、添加IP核AXI Interrupt Controller命名為“axi_intc_0“。雙擊IP核進行配置,修改為”Edge or Level”和”Single”,點選OK。
5.2、添加IP核Concat命名為”xlconcat_interrup_0”,配置IP端口數為8.
5.3、添加IP核Constant,配置值為’0’,連接到interrupt controller,命名為”xlconstant_gnd”。
5.4、”Run Connection Automation”,自動連接將AXI Interrupt Controller的從接口連接到PS的”HPM0_LPD”主接口上。將”clk_out1(200MHz)”選擇為所有模塊的時鍾資源。
5.5、將”interrupt controller”的輸入與”concat”模塊輸出連接。
5.6、將”constant”模塊的輸出與”concat”模塊的第一個輸入連接。then each subsequent concat input to this net。
5.7、將”interrupt comtroller”模塊的輸出與PS模塊的”pl_ps_irq0”連接。
6、生成XSA文件
綜合、布局布線、生成bit流,導出自定制硬件平台設計;可通過TCL指令或者點選界面執行。
source ./sources/xsa.tcl
注意:Vivado工程路徑不要太長,此時如果將sources文件夾放在路徑 ~build/vivado下並且執行sources下的xsa腳本,生成的.xsa文件會存放在與~build/hw_platform文件夾下面。
創建軟件平台
The software platform requires several changes to the default Petalinux template. Begin by configuring the project to include a meta-layer, which builds in all necessary support for the MIPI mezzanine card and pipeline. Then, finish by adding the necessary Xilinx Runtime (XRT) components into the design.
7、安裝petalinux工具在ubuntu上
# 安裝步驟
7.1 運行 `bash pre_install.sh`
7.2 運行 `bash tftp.sh`
7.3 運行
```bash
mkdir /tools/Xilinx/
sudo chown 你的用戶名 /tools/Xilinx
```
7.4 運行 `./petalinux-v2020.1-final-installer.run -d /tools/Xilinx`
7.5 zyp使用:source /tools/Xilinx/settings.sh 注:每次使用petalinux工具時都要執行settings.sh;
8、定制Petalinux項目(createàconfigàbuildàboot)
8.1、在’build/’路徑下打開備用的petalinux工程。
8.2、創建新的帶有zynqMP模板的petalinux工程
‘petalinux-create -n petalinux --template zynqMP -t project’
8.3、從`reference-files/ petalinux’下復制文件夾`meta-ultra96v2mipi`,粘貼到’build/ petalinux/ components’路徑下。
8.4、更新Petalinux工程(xsa文件)並且打開初始化配置菜單。
‘petalinux-config --get-hw-description=../hw_platform`
注意:hw_platform文件夾路徑問題。
若出現報錯:將ultra96 路徑下的layer.conf文件中 thud 改成 zeus.
8.5、主菜單中選擇”Subsystem AUTO settings”和目錄下的”Serial Settings”。修改’psu_uart_1’作為primary(原默認psu_uart_0)。
8.6、主菜單中選擇”DTG Settings”並且設置命名為’avnet-ultra96-rev1’(原來默認template)。
8.7、主菜單中選擇”Yocto Settings” à”User Layers”並且添加
${PROOT}/components/meta-ultra96v2mipi 作為用戶第一層,然后退出初始化配置菜單。
8.8、添加平台XRT驅動,添加recipes通過拷貝`reference-files/ petalinux`路徑下的`recipes-xrt`文件到`build/ petalinux/ project-spec/ meta-user`路徑下。
8.9、添加recipes”自動運行”的腳本,保證在root后可自動運行recipes,拷貝路徑’reference-files/petalinux/autostart’ autostart目錄到’build/ petalinux/ project-spec/ meta-user/ recipes-apps’路徑下。
8.10、將上述recipes添加到petalinux鏡像配置中,在[build/ petalinux/ project-spec/ meta-user/ conf/ user-rootfsconfig]文件中內容添加 [reference-files/ petalinux/ plnxrfscfg.txt]文件內容。
8.11、打開Petalinux的根文件系統配置界面去使能上述的recipes
`petalinux-config -c rootfs`然后添加在"User Packages" and "Apps" 的子目錄下的`user-rootfsconfig`文件。
8.12、在rootfs配置下,under the Petalinux Packge Groups,使能如下選項:
gstreamer、matchbox、opencv、v4lutils、x11。
8.13、退出rootfs配置菜單。
9、修改Linux設備樹
9.1、打開文件`build/ petalinux/ project-spec/ meta-user/ recipes-bsp/ device-tree/ files/ system-user.dtsi`。用`reference-files/ petalinux/ dtfrag.txt`內容替換打開的內容。
離線編譯petalinux:官網下載aarch64 sstate-cache和downloads文件並解壓,存放路徑不要出現空格字符,否則后期編譯會出現錯誤。
配置sstate
在petalinux工程路徑下輸入petalinux-config命令進入配置界面
1.運行petalinux-config報錯:
將下面兩個文件中的thud修改為zeus
2.petalinux-build編譯報錯
解決:aarch64 sstate-cache和downloads文件存放的路徑有空格字符,修改路徑信息,編譯通過。
配置本地downloads
打開文件 project-spec/meta-user/conf/petalinuxbsp.conf進行如下配置,文件末尾添加6行,注意替換自己的實際目錄
petalinux編譯: $petalinux-build
petalinux-build編譯報錯
注:查詢資料這些錯誤是因為Ubuntu磁盤空間不足導致,重做Ubuntu系統磁盤空間留300G
重新運行petalinux工具 source /tools/Xilinx/settings.sh
petalinux-build編譯報錯:
個人能力無法解決,未知原因,該是設備樹配置問題,迫切歡迎有該方面調試經驗者交流學習;