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