目錄
1,在Vivado上建立硬體平台
2,在linux中建立工程
3,導入硬體配置檔案
4,生成鏡像檔案
5,SD卡啟動
對于特定的硬體平台(開發闆),petalinux可以通過下載下傳官方BSP來直接建立檔案,可以省去很多麻煩。但是在實際運用中,不可能隻是從BSP生成,現在我們開始建立一個自定義的工程。
1,在Vivado上建立硬體平台
在Vivado上建立硬體平台,生成*.hdf檔案。(我的Vivado安裝在Window下);
Create Project
Create Block Design
Create IP
根據UG1144中對硬體的要求設定IP(預設就行)
Generate output products -->Create HDL Wrapper -->Generate Bistream -->Export Hardware
生成的hdf檔案在:<工程目錄>\Miz_sys.sdk檔案夾内
2,在linux中建立工程
在linux中建立一個工程目錄,我的放在桌面上
$ cd ~/Desktop/
$ mkdir petalinux_proj
在工程目錄中建立工程
$ cd ~/Desktop/petalinux_proj/
$ petalinux-create --type project --template zynq --name my_first_proj
INFO: Create project: my_first_proj
INFO: New project successfully created in /home/zhupy/Desktop/petalinux_proj/my_first_proj
3,導入硬體配置檔案
将步驟1中生成的hdf檔案從windows中拖拽到my_first_proj這個檔案夾中。導入硬體配置檔案
$ cd ~/Desktop/petalinux_proj/my_first_proj/
$ petalinux-config --get-hw-description=./ #這裡的./是hdf檔案的存放位置
設定項的内容直接預設,save後退出。(細節可以參考UG1144的附錄B和附錄C)開始config。。。。完成後出現以下資訊:
[INFO] generating u-boot configuration files
[INFO] generating kernel configuration files
[INFO] generating kconfig for Rootfs
Generate rootfs kconfig
[INFO] oldconfig rootfs
[INFO] generating petalinux-user-image.bb
此時在你的~/Desktop/petalinux_proj/my_first_proj/project-spec/hw-description檔案目錄下,可以看到:
$ ls
config.project ps7_init_gpl.c ps7_init.html system_wrapper.bit
metadata ps7_init_gpl.h ps7_init.tcl
ps7_init.c ps7_init.h system.hdf
4,生成鏡像檔案
$ cd ~/Desktop/petalinux_proj/my_first_proj/ #切換到工程檔案夾
$ petalinux-build
[INFO] building project
[INFO] sourcing bitbake
INFO: bitbake petalinux-user-image
Parsing recipes: 100% |##########################################| Time: 0:00:38
Parsing of 2466 .bb files complete (0 cached, 2466 parsed). 3259 targets, 226 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
Initialising tasks: 100% |#######################################| Time: 0:00:07
Checking sstate mirror object availability: 3% | | ETA: 0:00:03
..........
INFO: Copying Images from deploy to images
INFO: Creating images/linux directory
NOTE: Successfully copied built images to tftp dir: /tftpboot
[INFO] successfully built project
此時,你的工程目錄内多出一個images檔案夾
$ cd ./images/linux/
$ ls
image.ub rootfs.ext4 system.dtb vmlinux
rootfs.cpio rootfs.ext4.gz System.map.linux zImage
rootfs.cpio.gz rootfs.jffs2 system_wrapper.bit zynq_fsbl.elf
rootfs.cpio.gz.u-boot rootfs.manifest u-boot.bin
rootfs.ext3 rootfs.tar.gz u-boot.elf
裡面就是我們所需要的。
(1)使用petalinux-package指令生成鏡像檔案
$ cd ./image/linux
$ petalinux-package --boot --fsbl zynq_fsbl.elf --fpga system_wrapper.bit --u-boot --force
--force指令是用來覆寫之前的BOOT.BIN檔案
(2)sdk生成鏡像檔案:
不用petalinux-package指令,用sdk的話,需要把以下四個檔案拷貝到windows中備用
在Windows中打開SDK Xilinx-->Create Boot Image,按順序加入 zynq_fsbl.elf--->IFC_TOP_wrapper.bit--->u-boot.elf 三個檔案。點選 Create Image 按鈕,生成BOOT.bin檔案
5,SD卡啟動
将生成的BOOT.bin和之前拷貝的image.ub複制到SD卡上
将SD卡插入開發闆上電,打開Putty,參數設定如下:
檢視putty上的log資訊:
liunx成功跑起來了。。。。