下载VP源码
# sudo apt-get install git //先安装git
$ git clone https://github.com/nvdla/vp.git
$ cd vp
$ git submodule update --init --recursive //更新子模块文件
安装依赖
$ sudo apt-get update $ sudo apt-get install g++ cmake libboost-dev python-dev libglib2.0-dev libpixman-1-dev liblua5.2-dev swig libcap-dev libattr1-d
安装systemC
注意:需要指定systemc2.3.0版本,更高版本存在不兼容
$ wget -O systemc-2.3.0a.tar.gz https://www.accellera.org/images/downloads/standards/systemc/systemc-2.3.0a.tar.gz
//使用https链接,http无法访问 $ tar -xzvf systemc-2.3.0a.tar.gz $ cd systemc-2.3.0a $ sudo mkdir -p /usr/local/systemc-2.3.0/ $ mkdir objdir $ cd objdir $ ../configure --prefix=/usr/local/systemc-2.3.0 $ make $ sudo make install
安装perl package (YML 与 Tee)
$ wget -O YAML-1.24.tar.gz https://search.cpan.org/CPAN/authors/id/T/TI/TINITA/YAML-1.24.tar.gz
$ tar -xzvf YAML-1.24.tar.gz $ cd YAML-1.24 $ perl Makefile.PL
$ make
$ sudo make install
$ wget -O IO-Tee-0.65.tar.gz https://search.cpan.org/CPAN/authors/id/N/NE/NEILB/IO-Tee-0.65.tar.gz
$ tar -xzvf IO-Tee-0.65.tar.gz $ cd IO-Tee-0.65
$ perl Makefile.PL
$ make
$ sudo make install
构建NVDLA CMOD
$ git clone https://github.com/nvdla/hw.git
$ cd hw
$ make
make时候初出现如下提示,需要指定构造环境的路径
依赖的环境如下
- Java - jdk1.7
- Perl - perl-5.10
-
- XML::Simple
- Capture::Tiny
- CPP - gcc-4.9.3
- Python - python2.6
- SystemC - systemc-2.3.0
- (for Verilator builds) Verilator - Verilator 3.912
- (for Verilator builds) clang - clang 3.4
可以在make之前修改MakeFile文件中的default路径,cpp等路径可以用 whereis cpp查找,一般路径为/ust/bin/cpp
$ tools/bin/tmake -build cmod_top
构造成功如下
生成的文件的在目录 hw/outdir/<project>/cmod/release. 下
构建和安装仿真器
# cd vp //切换到vp仓库
$ cmake -DCMAKE_INSTALL_PREFIX=build -DSYSTEMC_PREFIX=/usr/local/systemc-2.3.0/ -DNVDLA_HW_PREFIX=/home/sunqiliang/VP/hw -DNVDLA_HW_PROJECT=sun_test
//DCMAKE_INSTALL_PREFIX仿真器的安装路径 systemc prefix 是已安装systemc的路径 nvdla_hw prefix是NVDLA HW仓库路径 nvdla_hw project是HW工程名字,上个步骤中project名称为sun_test
运行成功如下
# sudo apt-get install flex //make时候会用到
# sudo apt-get install bison //make时候会用到
$ make
$ make install
将子目录下CMakeList.txt中的 CMAKE_CXX_FLAGS语句中的-Werror删除( 只打印warn 不进行错误处理)
vp/CMakeLists.txt
vp/models/nvdla/CMakeLists.txt
vp/fpga/aws-fpga/fpga_sc_wrapper/CMakeLists.txt
vp/aws-fpga/cosim_sc_wrapper/CMakeLists.txt
参考 Ubuntu16.04 NVDLA环境搭建 https://www.codetd.com/article/2925855
运行成功如下
交叉编译一个linux内核
wget https://buildroot.org/downloads/buildroot-2017.11.tar.gz
tar -zxvf buildroot-2017.11.tar.gz
cd buildroot-2017.11/
sudo apt-get install libncurses5-dev // make menuconfig时会用到
$ make qemu_aarch64_virt_defconfig
$ make menuconfig
* Target Options -> Target Architecture -> AArch64 (little endian) * Target Options -> Target Architecture Variant -> cortex-A57 * Toolchain -> Custom kernel headers series -> 4.13.x * Toolchain -> Toolchain type -> External toolchain * Toolchain -> Toolchain -> Linaro AArch64 2017.08 * Toolchain -> Toolchain origin -> Toolchain to be downloaded and installed * Kernel -> () Kernel version -> 4.13.3 * Kernel -> Kernel configuration -> Use the architecture default configuration * System configuration -> Enable root login with password -> Y * System configuration -> Root password -> nvdla * Target Packages -> Show packages that are also provided by busybox -> Y * Target Packages -> Networking applications -> openssh -> Y
$ make -j4// 编译时间较长,建议先做其他事情
运行完成如下
运行虚拟机
$ export SC_SIGNAL_WRITE_CHECK=DISABLE
# vim conf/aarch64_nvdla.lua
//dirver file修改为上面生成的kenel路径 /home/sunqiliang/VP/buildroot-2017.11/output/images/rootfs.ext4
//-kenerl 路径修改为/home/sunqiliang/VP/buildroot-2017.11/output/images/Images
$ ./build/bin/aarch64_toplevel -c conf/aarch64_nvdla.lua
运行成功如下
输入之前make menuconfig设置的登录密码
运行test
# mount -t 9p -o trans=virtio r /mnt # cd /mnt/tests/hello # ./aarch64_hello
运行成功如下
退出命令虚拟机 ‘ctrl+a x’