petalinux_zynq7 C语言驱动DAC以及ADC模块之一:建立IPhttps://blog.csdn.net/qq_27158179/article/details/136234296在上一篇,建立了ADC和DAC两个IP。这里继续。本文在 petalinux默认配置的基础上,添加了python和qt。再编译出sdk可以给x86主机交叉编译。
0. 环境
- ubuntu18
- vivado 2018.3
- mizar z7010 + ada106模块
1. petalinux工程创建
1.1 创建工程
cd /home/dell/work/mizar
source /opt/pkg/petalinux/2018.3/settings.sh
petalinux-create -t project -n linux_sd_adda --template zynq
拷贝 hdf
把
/home/xxjianvm/work/mizar/linux_sd_hdmi/linux_sd_hdmi.sdk/hdmi_out_wrapper_hw_platform_0/system.hdf
拷贝到
/home/dell/work/mizar7/linux_sd_hdmi/hdf/system.hdf
1.2 用mizar开发板提供的linux内核
准备修改过的linux内核(添加了hdmi)
把
F:\开发板-FPGA资料、Mizar_Z7010_2018.3\03_Source\03_source.7z
拷贝到
/home/dell/work/mizar/03_source.7z
解压
7z x 03_source.7z
cd 03_source
mkdir -p ../petalinux_kernel/linux-4.14
tar -zvxf linux-4.14.0-v2018.3.tar.gz -C ../petalinux_kernel/linux-4.14
1.3 导入硬件描述配置
配置 Petalinux 工程的硬件信息,硬件信息目录里只能有一个 hdf 文件
cd linux_sd_hdmi导入硬件描述
petalinux-config --get-hw-description hdf/
导入硬件描述后会自动弹出 menuconfig页面。
检查串口
Subsystem AUTO Hardware Settings -> Serial Settings -> FSBL Serial stdin/stdout (ps7_uart_1)
Subsystem AUTO Hardware Settings -> Ethernet Settings -> Primary Ethernet (ps7_ethernet_0)
Subsystem AUTO Hardware Settings -> SD/SDIO Settings -> Primary SD/SDIO (ps7_sd_0)
配置SD卡
Image Packaging Configuration -> Root filesystem type -> SD card
Image Packaging Configuration -> Device node of SD device -> /dev/mmcblk0p2
启动
Subsystem AUTO Hardware Settings -> Advanced bootable images storage Settings -> boot image settings -> image storage media (primary sd)
Subsystem AUTO Hardware Settings -> Advanced bootable images storage Settings -> u-boot env partition settings -> image storage media (primary sd)
Subsystem AUTO Hardware Settings -> Advanced bootable images storage Settings -> kernel image settings -> image storage media (primary sd)
Subsystem AUTO Hardware Settings -> Advanced bootable images storage Settings -> jffs2 rootfs image settings -> image storage media (manual)
Subsystem AUTO Hardware Settings -> Advanced bootable images storage Settings -> dtb image settings -> image storage media (from boot image)
之后可以临时退出menuconfig页面了。
1.4 配置petalinux
第一次配置输入指令
petalinux-config
第二次如果没修改hdf以及相关配置,输入指令
petalinux-config
第二次配置如果修改了hdf
petalinux-build -x mrproper -f
petalinux-config
第二次配置如果修改了配置:
petalinux-build -x distclean
petalinux-build
内核源码
Linux Components Selection -> linux-kernel -> ext-local-src
Linux Components Selection -> linux-kernel -> External linux-kernel local source settings -> /home/dell/work/mizar/petalinux_kernel/linux-4.14
配置 sstate 高速缓存(不是必须的)
petalinux-config -> Yocto Settings -> Local sstate feeds settings -> local sstate feeds url ->-> file:///opt/pkg/petalinux/2018.3/sstate-rel-v2018.3/arm
petalinux-config -> Yocto Settings -> Add pre-mirror url ->-> file:///opt/pkg/petalinux/2018.3/sstate-rel-v2018.3/downloads
petalinux-config -> Yocto Settings -> 取消 Enable Network sstate feeds
petalinux-config -> Yocto Settings -> 取消 Enable BB NO NETWORK # python的一个库需要联网
此时保存配置退出。
1.5 配置内核
petalinux2018.3默认不支持远程中断配置内核,需要修改:
gedit project-spec/meta-user/conf/petalinuxbsp.conf
添加:
OE_TERMINAL = "xterm"
配置指令:
petalinux-config -c kernel
配置 hdmi
(默认已经勾上)Device Drivers -> Graphics support -> <*>Xilinx LCD/HDMI drive
(默认已经勾上)Device Drivers -> Graphics support -> <*>Digilent VGA/HDMI DRM Encoder Driver
(默认已经勾上)Device Drivers -> Common Clock Framework -> <*>Digilent axi_dynclk Driver 按 y
配置 usb gadget
Device Drivers -> USB Support -> <*>USB Gadget Support -> <*> RNDIS
Device Drivers -> USB Support -> <*>USB Gadget Support -> <*> Mass storage
Device Drivers -> USB Support -> <*>USB Gadget Support -> <*> Function filesystem
1.6 配置根文件系统
petalinux-config -c rootfs
添加 python3
Filesystem Packages -> misc -> python -> python3 -> <*>python3
添加 python3-pip,python3-flask
gedit project-spec/meta-user/recipes-core/images/petalinux-image-full.bbappend
添加:
IMAGE_INSTALL_append = "python3-pip"
IMAGE_INSTALL_append = "python3-flask"
配置
petalinux-config -c rootfs
user packages -> python3-pip
user packages -> python3-flask
也可以(不过我用的是上面的方法,未确认下面的带不带flask):
Petalinux Package Groups -> packagegroup-petalinux-python-modules -> <*>packagegroup-petalinux-python-modules
添加 qt (编译时候看到版本是5.9.6)
Petalinux Package Groups -> packagegroup-petalinux-qt -> <*> packagegroup-petalinux-qt
Petalinux Package Groups -> packagegroup-petalinux-qt -> <*>populate_sdk
添加 gcc (怀疑 libatomic在这里,尝试搭建nodejs + vue依赖libatomic)
Petalinux Package Groups -> packagegroup-petalinux-self-hosted -> <*>packagegroup-petalinux-self-hosted
1.7 设备树
gedit project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi
但是无法粘贴。修改为:
/include/ "system-conf.dtsi"/ { model = "Navigator Development Board"; compatible = "microphase,zynq-7020","xlnx,zynq-7000"; usb_phy0:usb_phy@0{compatible = "ulpi-phy";#phy-cells = <0>;reg = <0xe0002000 0x1000>;view-port = <0x170>;drv-vbus;};video_timings {timing_4x3_480x272: timing0 {clock-frequency = <9000000>;hactive = <480>;vactive = <272>;hback-porch = <40>;hsync-len = <20>;hfront-porch = <5>;vback-porch = <8>;vsync-len = <3>;vfront-porch = <8>;hsync-active = <0>;vsync-active = <0>;de-active = <1>;pixelclk-active = <0>;};timing_1920x1080: timing1 {clock-frequency = <148500000>;hactive = <1280>;vactive = <720>;hback-porch = <148>;hsync-len = <44>;hfront-porch = <88>;vback-porch = <36>;vsync-len = <5>;vfront-porch = <4>;hsync-active = <0>;vsync-active = <0>;de-active = <1>;pixelclk-active = <1>;};};
};&usb0{dr_mode = "host";usb-phy = <&usb_phy0>;
};&axi_dynclk_0 {compatible = "digilent,axi-dynclk";clocks = <&clkc 15>;#clock-cells = <0>;
};&v_tc_0 {compatible = "xlnx,v-tc-5.01.a";
};&amba_pl {xlnx_vdma_hdmi {compatible = "xilinx,vdmafb";status = "okay";xlnx,vtc = <&v_tc_0>;clocks = <&axi_dynclk_0>;clock-names = "hdmi_pclk";dmas = <&axi_vdma_0 0>;dma-names = "hdmi_vdma";is-hdmi = <0x1>;display-timings = <&timing_1920x1080>;xlnx,pixel-format = "bgr888";};
};
1.7 编译工程
第一次编译
petalinux-build
如修改配置编译:
petalinux-build -x distclean
petalinux-build
1.8 打包boot.bin
petalinux-package --boot --fsbl ./images/linux/zynq_fsbl.elf --u-boot --fpga --force
1.9 编译出sdk
petalinux-build --sdk
#petalinux-package --sysroot # 这个是安装指令。
失败
| Cloning into '/home/dell/work/mizar/linux_sd_adda/build/tmp/work/x86_64-nativesdk-petalinux-linux/nativesdk-qemu-xilinx/v2.11.0-xilinx-v2018.3+gitAUTOINC+f70bd86859-r0/git/capstone'...
| fatal: unable to connect to git.qemu.org:
| git.qemu.org[0: 20.218.253.93]: errno=Connection timed out
解决办法:
修改文件:
/home/dell/work/mizar/linux_sd_adda/build/tmp/work/x86_64-nativesdk-petalinux-linux/nativesdk-qemu-xilinx/v2.11.0-xilinx-v2018.3+gitAUTOINC+f70bd86859-r0/git/.git/config
把
url = git://git.qemu.org/capstone.git
url = git://git.qemu.org/keycodemapdb.git
修改为:
url = https://gitlab.com/qemu-project/capstone.git
url = https://gitlab.com/qemu-project/keycodemapdb.git
然后命令行模式进入目录
cd /home/dell/work/mizar/linux_sd_adda/build/tmp/work/x86_64-nativesdk-petalinux-linux/nativesdk-qemu-xilinx/v2.11.0-xilinx-v2018.3+gitAUTOINC+f70bd86859-r0/git
执行命令
git submodule update
之后,重新在工程目录下执行petalinux-build --sdk即可
参考:petalinux2019.1编译sdk失败的解决办法,https://blog.csdn.net/b154265423/article/details/131976182
2. 制作SD卡文件系统
2.1 分区
ubuntu18 -> disks -> 给8GB TF卡重新分区
-> + -> 5000MB -> Next
-> Volume Name: FAT
-> type: FAT
-> + -> 剩余 2858MB -> Next
-> Volume Name: EXT
-> type: ext4
-> 弹出TF卡 -> 断开连接 再次连接到虚拟机
2.2 EXT分区
sudo tar xzvf rootfs.tar.gz -C /media/xxjianvm/EXT
sudo sync
2.3 FAT分区
直接拷贝
BOOT.bin
image.ub
到FAT分区
2.4 启动测试
2.4.1 启动
拨码开关拨到SD模式。
开关都往下拨。
2.4.2 默认登录账号密码
root/root
下篇:
petalinux_zynq7 C语言驱动DAC以及ADC模块之三:C语言API的实现-CSDN博客https://blog.csdn.net/qq_27158179/article/details/136238093