zynq学习笔记之petalinux (3)petalinux 创建自定义工程

目录

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成功跑起来了。。。。

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值