Open SiuKiri opened 2 days ago
参考手册
具体步骤
VIVADO
工程在 VIVADO
工程中完成项目创建,获得 XSA
文件
Petalinux
工程 Version:2022.1创建工程
petalinux-create --type project --template zynq --name zynq7020-dpu
进入项目目录,将 XSA
文拷贝至该目录并进行基本配置
petalinux-config --get-hw-description=./
完成之后会生成基本项目文件,下一步进行定制化配置
拷贝 Vitis-AI
github项目中的 recipes-vitis-ai
至 zynq7020-dpu
中的 meta-user
cp <vitis-ai>/setup/petalinux/recipes-vitis-ai <petalinux project>/project-spec/meta-user/
编辑 <petalinux project>/project-spec/meta-user/conf/user-rootfsconfig
文件,附加内容
CONFIG_vitis-ai-library
CONFIG_vitis-ai-library-dev
CONFIG_vitis-ai-library-dbg
配置 rootfs
Select user packages --->
Select [*] vitis-ai-library
执行构建
注意:构建前需保证磁盘可用存储大于40GB
petalinux-build
完成构建
$ petalinux-build
[INFO] Sourcing buildtools
[INFO] Building project
[INFO] Sourcing build environment
[INFO] Generating workspace directory
INFO: bitbake petalinux-image-minimal
NOTE: Started PRServer with DBfile: /home/pynq/Desktop/pynqz-dpu/build/cache/prserv.sqlite3, Address: 127.0.0.1:40323, PID: 81113
Loading cache: 100% |###############################################################################################################################################| Time: 0:00:00
Loaded 5397 entries from dependency cache.
Parsing recipes: 100% |#############################################################################################################################################| Time: 0:00:00
Parsing of 3597 .bb files complete (3595 cached, 2 parsed). 5399 targets, 554 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
Initialising tasks: 100% |##########################################################################################################################################| Time: 0:00:02
Checking sstate mirror object availability: 100% |##################################################################################################################| Time: 0:01:20
Sstate summary: Wanted 675 Local 13 Network 425 Missed 237 Current 1638 (64% match, 89% complete)
NOTE: Executing Tasks
Currently 2 running tasks (2313 of 2313/6032 of 6051) 99% |####################################################################################################NOTE: Tasks Summary: Attempted 6051 tasks of which 6026 didn't need to be rerun and all succeeded.
INFO: Failed to copy built images to tftp dir: /tftpboot
[INFO] Successfully built project
FAQ
vart
编译 test
出现错误/Vitis-AI-Runtime/VART/vart/xrt-device-handle/test/test_ecmd.cpp:200:24: error: unsigned conversion from 'long long int' to 'long unsigned int' changes value from '824633724928' to '4096' [-Werror=overflow]
| 200 | unsigned long addr = 0xc000001000;
| | ^~~~~~~~~~~~
问题原因:由于该开发板是 ARM32
构架,这里出现数据溢出问题
解决方案:修改数据类型即可解决问题
<petalinux project>/build/tmp/work/cortexa9t2hf-neon-xilinx-linux-gnueabi/vart/2.5-r0/git/src/Vitis-AI-Runtime/VART/vart/xrt-device-handle/test/test_ecmd.cpp
| 200 | unsigned long long addr = 0xc000001000;
Vitis-AI-Library
中图像处理相关错误<petalinux project>/build/tmp/work/cortexa9t2hf-neon-xilinx-linux-gnueabi/vitis-ai-library/2.5-r0/git/src/Vitis-AI-Library/math/src/image_util.cpp
| 4403 | return (uint8x16_t)__builtin_neon_vshru_nv16qi ((int8x16_t) __a, __b);
问题原因:由于 ARM NEON 指令集的限制 引起的
解决方案:针对该开发板处理器架构重新编写代码
<petalinux project>/build/tmp/work/cortexa9t2hf-neon-xilinx-linux-gnueabi/vitis-ai-library/2.5-r0/git/src/Vitis-AI-Library/math/src/image_util.cpp:void transform_mean_scale()
auto calc_float_mean = [](const uint8x16_t& in_u8, int scale,
const uint8x16_t& high_mean,
const uint8x16_t& low_mean) -> int8x16_t {
else if (scale < 0) {
// scale < 0
/*
return vreinterpretq_s8_u8( vsubq_u8(vshrq_n_u8(vqsubq_u8(in_u8, high_mean), -scale),
vshrq_n_u8(vqsubq_u8(low_mean, in_u8), -scale)));
*/
return vreinterpretq_s8_u8(
vsubq_u8(
vshlq_u8(vqsubq_u8(in_u8, high_mean), vdupq_n_s8(-scale)),
vshlq_u8(vqsubq_u8(low_mean, in_u8), vdupq_n_s8(-scale))
)
);
}
};
auto calc_int_mean = [](const uint8x16_t& in_u8, int scale,
const uint8x16_t& mean) -> int8x16_t {
else if (scale < 0) {
// scale < 0
return vreinterpretq_s8_u8(
vsubq_u8(
vshlq_u8(vqsubq_u8(in_u8, mean), vdupq_n_s8(-scale)),
vshlq_u8(vqsubq_u8(mean, in_u8), vdupq_n_s8(-scale))
)
);
}
};
这里仅展示修改部分的代码,主要目的是将代码匹配对应的处理器架构
Vitis-AI-Library/math/test/
中也有相似的一处错误,根据 src
中的修改思路修改代码即可
记录Vitis-AI开发过程