Xilinx的开发工具SDK/Vitis都可以自动根据Vivado设计,创建软件工程,自动配置各个外部设备的驱动程序。为了兼容旧版本工程,SDK/Vitis里提供了多个IP版本的驱动程序。如果在SDK/Vitis的软件工程里查看代码,驱动程序都是正确的。
如果没有工程,也可以在安装目录下查看代码,比如目录Vitis\2020.2\data\embeddedsw\XilinxProcessorIPLib\drivers。这时候,需要自己选择对应的版本。
第三方源代码编辑器,比如Source Insight,可以创建自己的工程,查找所有符号表等。由于有多个IP版本的驱动程序,只能手动添加对应IP的驱动,到Source Insight工程。否则Source Insight能找到函数的多个实现,看起来有些麻烦。SDK/Vitis下大约有200个软件模块,全部手动添加的话,比较麻烦。
为了避免上述情况,可以把旧版本的驱动程序删除。手动删除旧版本,也比较繁琐,也容易出错。犹豫很久后,终于写了一个Linux脚本,自动删除SDK/Vitis下驱动程序的旧版本。当然,在删除之前,请做好备份。万一需要的情况下,需要恢复。如果是Linux环境,可以直接执行这个Linux脚本;如果是Windows环境,可以借助WSL执行。 SDK/Vitis在下列目录,有多个版本的驱动。 请在下列目录执行脚本。
Vitis/2020.2/data/embeddedsw/XilinxProcessorIPLib/drivers Vitis/2020.2/data/embeddedsw/ThirdParty/sw_services Vitis/2020.2/data/embeddedsw/ThirdParty/bsp Vitis/2020.2/data/embeddedsw/ThirdParty/sw_services Vitis/2020.2/data/embeddedsw/lib/sw_services Vitis/2020.2/data/embeddedsw/lib/bsp
脚本如下:
#!/bin/bash # Author: hankf@xilinx.com # 2021-07-28 # # Run this script in # Linux : # WSL on Windows: # /mnt/c/Xilinx/Vitis/2020.2/data/embeddedsw/XilinxProcessorIPLib/drivers # /mnt/c/Xilinx/Vitis/2020.2/data/embeddedsw/ThirdParty/sw_services # /mnt/c/Xilinx/Vitis/2020.2/data/embeddedsw/ThirdParty/bsp # /mnt/c/Xilinx/Vitis/2020.2/data/embeddedsw/ThirdParty/sw_services # /mnt/c/Xilinx/Vitis/2020.2/data/embeddedsw/lib/sw_services # /mnt/c/Xilinx/Vitis/2020.2/data/embeddedsw/lib/bsp function del_old_dir(){ echo "IP base name $1" for main_version in {1..10} do ip_dir_name_main="$1_v$main_version" # echo "Directory main version: $ip_dir_name_main" # IP directory example: zdma_v1_12 for sub_version in {0..20} do ip_dir_name_main_sub=$ip_dir_name_main\_$sub_version # echo "Check IP Directory main_sub version $ip_dir_name_main_sub" if test -d $ip_dir_name_main_sub then # echo "Directory $ip_dir_name_main_sub exists" # echo "IP Directory length: ${#ip_dir_name_main_sub} " if [ ${#ip_dir_name_main_sub} -gt 5 ]; then ip_dir_name_main_sub_latest=$ip_dir_name_main_sub echo "Update IP Directory: $ip_dir_name_main_sub_latest" fi fi done done echo "Latest IP Directory: $ip_dir_name_main_sub_latest" if [ "$ip_dir_name_main_sub_latest" = "" ]; then echo "Latest IP Directory is null." return 0 fi if [ -d $ip_dir_name_main_sub ]; then echo "Latest IP Directory: $ip_dir_name_main_sub_latest does not exist." return 0 fi for main_version in {1..10} do ip_dir_name_main="$1_v$main_version" # echo "Directory main version: $ip_dir_name_main" for sub_version in {0..20} do ip_dir_name_main_sub=$ip_dir_name_main\_$sub_version # echo "Check IP Directory main_sub version $ip_dir_name_main_sub" if test -d $ip_dir_name_main_sub then if [ "$ip_dir_name_main_sub" == "\\" ]; then # double check it is not root direcoty. echo "Error: IP Directory: $ip_dir_name_main_sub is root directory." exit fi # echo "IP Directory: $ip_dir_name_main_sub length: ${#ip_dir_name_main_sub}" if [ ${#ip_dir_name_main_sub} -lt 5 ]; then # double check it is correct echo "Error: IP Directory: $ip_dir_name_main_sub is too short: ${#ip_dir_name_main_sub}" exit fi if [ $ip_dir_name_main_sub != $ip_dir_name_main_sub_latest ]; then # Delete IP Directory: dangerous echo "Delete old IP Directory: $ip_dir_name_main_sub" rm -rf ./$ip_dir_name_main_sub/* rmdir ./$ip_dir_name_main_sub fi fi done done } function get_sub_dir(){ check_dir=$1 # echo "Check Directory: $check_dir" if test -d $check_dir then echo "Check Directory: $check_dir" ip_dir_base_name=${check_dir%%_v[0-9]_*} # echo "IP Directory Base name: $ip_dir_base_name" ip_dir_base_name_rmv_slash=${ip_dir_base_name:2} echo "IP Directory Base name without slash: $ip_dir_base_name_rmv_slash" if [ "$1" != "" ]; then del_old_dir $ip_dir_base_name_rmv_slash fi fi } function getdir(){ echo $1 current_dir_name=`pwd` echo "Current Directory: $current_dir_name" # Make sure it is not in wrong directory. # echo "Current Directory length: ${#current_dir_name} " if [ ${#current_dir_name} -lt 10 ]; then echo "Current Directory is too short: $current_dir_name" echo "Please enter into Xilinx Vitis directory." return 0; fi xilinx_result=$(echo $current_dir_name | grep Xilinx) if [ "$xilinx_result" == "" ]; then echo "Current Directory does not includes Xilinx." echo "Please enter into Xilinx Vitis directory." return 0; else echo "Current Directory includes Xilinx." fi vitis_result=$(echo $current_dir_name | grep Xilinx) if [ "$vitis_result" == "" ]; then echo "Current Directory does not includes Vitis." echo "Please enter into Xilinx Vitis directory." return 0; else echo "Current Directory includes Vitis." fi for sub_dir in $1/* do get_sub_dir $sub_dir done } getdir .