0%

Xilinx

教程系列

Ubuntu环境安装

双向文件传输 共享文件夹 复制拖拽 增强工具安装
增强工具第一次安装不上可以弹出iso重新安装
可设置ubuntu熄屏时间

petalinux安装(需要和vivado版本对应)

设置安装路径 /opt/pkg/petalinux
petalinux-v2017.4-final-installer.run /文件夹

linux vivado安装(需要和petalinux版本对应)

vivado安装或者安装gcc-linaro-arm-linux-gnueabihf

petalinux使用

开启编译环境:source /opt/Xilinx/Vivado/2017.4/settings64.sh
开启系统环境:source /opt/pkg/petalinux/settings.sh
创建Block Design并添加ZYNQ Processing System并配置系统
拷贝.sdk文件夹到linux系统中(不要放在共享文件夹中)
~ /peta_pro
petalinux-create
petalinux-config 进行配置
petalinux-config -c kernel
petalinux-config -c rootfs
petalinux-build

移植Vivado生成的硬件程序到petalinux

在linux工作空间中创建工作目录
复制生成的.sdk文件夹到linux工作目录(可以在同一个工程下面选择同的sdk文件进行内核配置,这样可能节省内核配置时间)
执行创建工程petalinux-create –type project –template zynq –name Radar_peta
petalinux-config –get-hw-description ../Bram5.sdk
petalinux-config -c kernel
petalinux-config -c rootfs
自定义设备树
sudo gedit project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi
petalinux-build
petalinux-package –boot –fsbl ./images/linux/zynq_fsbl.elf –fpga –uboot –force
复制images/linux文件夹下面的UBOOT.bin和image.ub,system.dts文件到SD卡
ifconfig eth0 192.168.0.2 netmask 255.255.255.0 up

内核移植

内核移植编译

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distclean
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- xilinx_zynq_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- all -j16

petalinux应用程序编译

配置ip使用scp进行文件传输
设备树自动生成注意查看其地址 pl.dtsi在创建的工程中
控制led
https://blog.csdn.net/leon_zeng0/article/details/84172584
https://blog.csdn.net/u013029731/article/details/85042431
/dev/mem/
https://www.cnblogs.com/cxchanpin/p/7230743.html

petalinux中断使用(相应设备驱动需要在相应的内核底下编译)

工程文件:/home/allen/peta_pro/peta_pro

ls /proc/device-tree/amba_pl/
先生成硬件文件,直接修改设备树,编写设备驱动,
https://blog.csdn.net/seavensky_curry/article/details/82978475
编译驱动https://blog.csdn.net/weixin_43873379/article/details/102625054
modprobe和insmod加载设备驱动
创建设备节点
解压内核到ubuntu中并编译内核,要不驱动没法编译,将例程中的linux移植到ubuntu中
在petalinux-config
将内核添加到petalinux工程中
使用petalinux-create -t modules –name keyirq创建modules(将驱动编译进内核)
修改文件夹下面的文件
petalinux-config -c rootfs 选择modules->irqkey
petalinux-build
驱动生成位置
build/tmp/sysroots/plnx_arm/lib/modules/4.9.0-xilinx/extra/
自定义设备树位置
sudo gedit project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi
petalinux-package –boot –fsbl ./images/linux/zynq_fsbl.elf –fpga ./images/linux/design_1_wrapper.bit –u-boot –force
petalinux-config -c kernel

1
2
3
4
->Device Drivers
->Userspace I/O drivers
->Userspace I/O platform driver with generic IRQ handling
->Userspace platform driver with generic irq and dynamic memo

最终参考版本
https://blog.csdn.net/qq_30307853/article/details/100513971
https://blog.csdn.net/seavensky_curry/article/details/82978475
http://derekmolloy.ie/kernel-gpio-programming-buttons-and-leds/
led设备驱动
https://blog.csdn.net/h244259402/article/details/83990698

驱动编写

https://blog.csdn.net/zjy900507/article/details/78667899?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~all~first_rank_v2~rank_v25-3-78667899.nonecase&utm_term=gpio%E6%8C%89%E9%94%AE%E4%B8%AD%E6%96%AD%20linux

PL和PS通过bram进行双向通信

创建AXI Bram Controller 使用自动连接
PS双向数据传送
文件位置Bram5双向PSBram
https://blog.csdn.net/luhao806/article/details/77909158
https://blog.csdn.net/rzjmpb/article/details/50365915#
PL自定义AXI总线内核
ARM分别往AXI四个寄存器写数字(PL_BRAM_CTRL_mWriteReg(PL_RAM_BASE, 每个寄存器的偏移地址 , 数据))
ARM往Bram寄存器写入数据(XBram_WriteReg(XPAR_BRAM_0_BASEADDR, 寄存器偏移地址 , 数据))
https://www.amobbs.com/thread-5737330-1-1.html
https://blog.csdn.net/botao_li/article/details/86301995

FPGA和PS联合编程

FPGA使用PS时钟input wire, output wire clk,
.v文件作为上层文件调用封装好的版图
https://blog.csdn.net/taowei1314520/article/details/77939396
.v作为模块在工程中
工程文件位置Project/Software/RadarBoard/test/Bram4
注意修改xdc引脚分配文件
https://www.cnblogs.com/pangshian/p/13357433.html
https://bbs.elecfans.com/jishu_485735_1_1.html

petalinux中断最终版

PL硬件设计编写SDK测试文件确定

内核层可通过kill_fasync异步发送,kill_fasync发送方法网上资料很多,借用即可。
用户层通过signal(MYSIG, sig_handler)绑定信号和回调函数
共一下几个步骤:
signal(MYSIG, sig_handler);
fcntl(fd, F_SETOWN, getpid());
f_flags = fcntl(fd, F_GETFL);
fcntl(fd, F_SETFL, f_flags | O_NONBLOCK | FASYNC);
fcntl(fd, F_SETSIG, MYSIG);//如果要发送实时信号(MYSIG可自行定义),则需要通过fcntl设置
参考资料

PL和PS数据交互方式及其优缺点

常用的PL和PS数据交互方式根据交互数据量的大小有以下几种方式:
1、bit或Byte级别的交互,常用于设备状态交互
使用ram,AXI,RAM操作复杂,AXI操作简单,速度更快
2、100MB以下的数据交互
使用RAM,目前本人可以达到90MB
3、200MB以下的数据交互
使用AXIDMA进行数据交互,ZYNQ最快可以达到400M,本人使用US+,目前只能达到220M,如果PS端在DMA后端使用乒乓接受,应该速率更快,没有看到官方文档里面标注US+的AXIDMA最高速率
4、500M以上的数交互
使用HP总线,单个通道可以达到1GB。

Petalinux,PL通信

工程文件:F:/test/FPGA/

BOA

1.download boa文件
2.修改 #define TIMEZONE_OFFSET(foo) foo##->tm_gmtoff 避免编译器无法识别
=> #define TIMEZONE_OFFSET(foo) (foo)->tm_gmtoff
3.在系统的etc文件夹下面,创建/etc/boa用来存放boa.conf
创建目录
3.修改生成的Makefile中的编译器
加载css mime.type text.plain改为text/css
二。GCI

安装arm-linux-gcc
export PATH=/root/ZYNQ_gcc/gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux/bin:$PATH
arm-arago-linux-gnueabi-gcc
https://blog.csdn.net/kunkliu/article/details/79813121

boa及CGI移植到FPGA
https://blog.csdn.net/weixin_41922484/article/details/103343012
https://blog.csdn.net/a642960662/article/details/66473794
参考文章
http://www.360doc.com/content/14/0408/22/16459198_367364176.shtml

用到的参考链接

vivado加速编译

1
2
# set_param general.maxThreads 8 
# get_param general.maxThreads

https://www.pianshen.com/article/9500180462/
AXI PS PL数据通信
bram和ram 以及DDR的优缺点
https://blog.csdn.net/qq_31806049/article/details/99428777
linux读写bram数据
不用修改设备树直接调用open /dev/mem
https://blog.csdn.net/yohe12/article/details/105264853
https://blog.csdn.net/STR618/article/details/84728869
PL端读写bram
https://blog.csdn.net/weixin_43941525/article/details/90408941
xilinx github:https://github.com/Xilinx
PL读写DDR:
https://blog.csdn.net/weixin_36474809/article/details/85111550
Linux下运行PL程序
https://forums.xilinx.com/t5/嵌入式-工具-软件开发/petalinux-2018-3在PS中配置PL导致PS无响应/td-p/1046828
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18841847/Solution+ZynqMP+PL+Programming#SolutionZynqMPPLProgramming-BitstreamFormatsBitstream
https://www.xilinx.com/support/documentation/ip_documentation/axi_ref_guide/latest/ug1037-vivado-axi-reference-guide.pdf
PS PL双向通信
https://blog.csdn.net/botao_li/article/details/86301995
创建AXI总线
https://www.cnblogs.com/limanjihe/p/9885014.html

Radar工程

Vivado工程文件位置 F:/test/FPGA/radar1
https://blog.csdn.net/yohe12/article/details/105264853

DDR数据对齐方式

https://zhuanlan.zhihu.com/p/143524408?utm_source=wechat_session

调试错误汇总

插入SD卡不能建立ila核
生成U-Boot出现错误Default bitsream is not found, please specify a bitstream file path with –f
petalinux-package –boot –fsbl zynqmp_fsbl.elf –u-boot
petalinux-package –boot –fsbl zynqmp_fsbl.elf –u-boot –fpga system.bit
Xilinx FPGA 中“Done did not go high”

EMIO linux驱动

https://blog.csdn.net/Chi_Hong/article/details/84581017
https://blog.csdn.net/Claudedy/article/details/99426447(最终参考)

AD9628调试教程

接口

信号:
LVDS: ±CLK, ±DCO, ±DATA[11:0], ±OR(超量程标志)
SPI: OEB, SCLK, SDIO, CSB
ADC配置引脚: PDWN

UDP调试

lsof检测文件是否被打开

云端linux下载PL程序

https://www.cnblogs.com/luego/p/11777104.html

ZYNQ自启动应用程序

https://blog.csdn.net/leon_zeng0/article/details/95497335
https://blog.csdn.net/m0_37765662/article/details/100156137
ug1144_60页
https://blog.csdn.net/yishuicanhong/article/details/83020016

DONE Pin is not high on target fpga
解决方案:在Run Configuration中,勾选Reset entire System和Program FPGA

Genetate Block Design的时候出现有地址没有配置
解决方案:打开Address Editor选择Auto Assign Address

[IP_Flow 19-3153] Bus Interface ‘clk’: ASSOCIATED_BUSIF bus parameter is missing.
Ports and Interfaces->BRAM_PORT右击->Auto Infer Interface Chooser

Your display is too small to run Menuconfig!It must be at least 19 lines by 80 columns.
Your display is too small to run Menuconfig!
It must be at least 19 lines by 80 columns.

ERROR: fsbl-2017.4+gitAUTOINC+77448ae629-r0 do_compile: Function failed: do_compile (log file is located at /home/allen/peta_pro/ax_irqkey/build/tmp/work/plnx_arm-xilinx-linux-gnueabi/fsbl/2017.4+gitAUTOINC+77448ae629-r0/temp/log.do_compile.8420)
打开irq时 修改中断树

ERROR: Function failed: do_compile (log file is located at /home/allen/peta_pro/radar/build/tmp/work/plnx_arm-xilinx-linux-gnueabi/fsbl/2017.4+gitAUTOINC+77448ae629-r0/temp/log.do_compile.3841)
解决方法:继续编译一次

使用Diagram编程时,必须要导出hardware–>Launch SDK才能够运行时钟

././include/linux/kconfig.h:4:32: fatal error: generated/autoconf.h: 没有那个文件或目录
解决方案:编译内核

ERROR [INFO] sourcing bitbake
ERROR: Failed to source bitbake
ERROR: Failed to config project.
ERROR: Get hw description Failed!.
解决方案查看./build/config.log

Radar最终版移植步骤

硬件信息文件位置F:\Project\11Software\RadarBoard\test\PSTest
实现PL端每隔1s写第一块Bram然后发送一个trig给PS
写另外一块Bram写完之后发送EMIO信号给PL PL检测改信号上升沿并将数据写入第一块Bram

1
2
3
4
5
6
7
8
9
10
11
12
# cd ~/
# mkdir RadarFinish
# source /opt/Xilinx/Vivado/2017.4/settings64.sh
# source /opt/pkg/petalinux/settings.sh
# petalinux-create --type project --template zynq --name Radar_pro
# petalinux-config --get-hw-description /mnt/share/bram_test.sdk
# //配置内核源码位置
# petalinux-config -c kernel
# //修改增加设备树
# petalinux-config -c rootfs
# petalinux-build
# petalinux-package --boot --fsbl ./images/linux/zynq_fsbl.elf --fpga ./images/linux/RADARTest.bit --u-boot --force

配置 ifconfig eth0 192.168.0.2 netmask 255.255.255.0 up
编译中断驱动模块 文件位置:/home/allen/RadarFinish/kernel/linux-xlnx-xilinx-v2017.4
使用Makefile指定内核位置进行编译 编译之前需要进行内核编译

1
2
3
4
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distclean 
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- xilinx_zynq_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- all -j16

make
scp irq_drv.ko root@192.168.0.2:/home/root/
arm-linux-gnueabihf-gcc keyirqAPP.c -o keyirqAPP

创建自启动程序
petalinux-create -t apps –template install –name autorunapp –enable

#!/bin/sh

echo “Hello PetaLinux World”
mkdir /home/allen
mount -t vfat /dev/mmcblk0p1 /home/allen
mkdir /etc/boa

cp /home/allen/Radar/boa/bin/boa.conf /etc/boa/
cp /home/allen/Radar/boa/bin/boa /bin/
mkdir /var/log/boa
cp -rf /home/allen/Radar/boa/var/www /var/
cp /home/allen/Radar/boa/mime.types /etc/
/bin/boa

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# //文件位置project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi
# //注意不要将compatible中的字母写错了 否则设备树安装不上 会导致内核崩溃
# /include/ "system-conf.dtsi"
# / {
# model = "Zynq ALINX AX7350 Development Board";
# compatible = "alnx,zynq-ax7350","xlnx,zynq-7000";
#
# };
# &amba_pl{
# zynq_irq:radar_irq{
# compatible = "xlnx,zynq_irq";
# interrupt-parent = <&intc>;
# interrupts = <0 29 1>; //1为上升沿触发,4为高电平触发
# };
# };

硬件部分调试

LVDS差分时钟

坚持原创技术分享,您的支持将鼓励我继续创作!