ZC706+petalinux+vivado最小系统建立实践

1.首先搭建硬件环境(导出hdf文件)

1)进入vivado工程选择合适的板子型号,题主的板卡是zc706,芯片型号如下:

2)创建IPdesign

3)本文硬件上,将在ZYNQ Processing system里启用TTC、UART、SD以及之后可能用到的USB、Ethernet(网口0在bank1,bank1电压要选1.8V,否则报错)

 MDIO也得选

4)然后automation自动连接外设

 5)generate block design and generate output products

 选择global

6)create HDL wrapper

7) 然后综合和implement,最后export hardware 生成hdf硬件描述语言

 2.petalinux构建镜像文件

2.1步骤:

1.创建petalinux工程

2.将.hdf文件导入petalinux工程中

3.配置petalinux工程(配置内核,配置uboot,以及根文件系统)

4.编译petalinux工程(uboot镜像,内核镜像,rootfs,bitstream,fsbl镜像文件)

5.启动开发板子

 2.2实践:

进入petalinux目录

命令说明

petalinux -boot 启动开发板

petalinux -build编译

petalinux -config 配置

petalinux -create 创建

petalinux -package 打包

z@ubuntu:~/PetaLinux2019.1$ petalinux-create --help
petalinux-create             (c) 2005-2019 Xilinx, Inc.

This command creates a new PetaLinux Project or component

Usage:
  petalinux-create [options] <-t|--type <TYPE> <-n|--name <COMPONENT_NAME>

Required:
  -t, --type <TYPE>                     Available type:
                                          * project : PetaLinux project
                                          * apps    : Linux user application
                                          * modules : Linux user module
  -n, --name <COMPONENT_NAME>           specify a name for the component or
                                        project. It is OPTIONAL to create a
                                        PROJECT. If you specify source BSP when
                                        you create a project, you are not
                                        required to specify the name.
Options:
  -p, --project <PROJECT>               specify full path to a PetaLinux project
                                        this option is NOT USED for PROJECT CREATION.
                                        default is the working project.
  --force                               force overwriting an existing component
                                        directory.
  -h, --help                            show function usage
  --enable                              this option applies to all types except
                                        project.
                                        enable the created component

Options for project:
  --template <TEMPLATE>                 zynqMP|zynq|microblaze
                                        user needs specify which template to use.
  -s|--source <SOURCE>                  specify a PetaLinux BSP as a project
                                        source.

Options for apps:
  --template <TEMPLATE>                 <c|c++|autoconf|install>
                                        c   : c user application(default)
                                        c++ : c++ user application
                                        autoconf: autoconf user application
                                        install: install data only
  -s, --source <SOURCE>                 valid source name format:
                                          *.tar.gz, *.tgz, *.tar.bz2, *.tar,
                                          *.zip, app source directory

Options for modules: (No specific options for modules)

EXAMPLES:

Create project from PetaLinux Project BSP:
  $ petalinux-create -t project -s <PATH_TO_PETALINUX_PROJECT_BSP>

Create project from template:
For microblaze project,
  $ petalinux-create -t project -n <PROJECT> --template microblaze
For zynq project,
  $ petalinux-create -t project -n <PROJECT> --template zynq
For zynqMP project,
  $ petalinux-create -t project -n <PROJECT> --template zynqMP


Create an app and enable it:
  $ petalinux-create -t apps -n myapp --enable
The application "myapp" will be created with c template in:
  <PROJECT>/project-spec/meta-user/recipes-apps/myapp


Create an module and enable it:
  $ petalinux-create -t modules -n mymodule --enable
The module "mymodule" will be created with template in:
  <PROJECT>/project-spec/meta-user/recipes-modules/mymodule

1.创建工程

z@ubuntu:~/PetaLinux2019.1$ petalinux-create -t project --template zynq -n zynq_linux 
INFO: Create project: zynq_linux
INFO: New project successfully created in /home/z/PetaLinux2019.1/zynq_linux

2.将hdf 文件导入到工程中

导入成功进入字符图形配置界面

下面要配置开发板的调试串口

 

默认为uart_1为调试串口

首次运行比较慢。

直接运行petalinux-config直接打开界面

z@ubuntu:~/PetaLinux2019.1/zynq_linux$ petalinux-config --get-hw-description /home/z/hdf/petalinux_smallsystem.sdk/
INFO: Getting hardware description...
INFO: Rename design_1_wrapper.hdf to system.hdf
[INFO] generating Kconfig for project
[INFO] menuconfig project


*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.

[INFO] sourcing bitbake
[INFO] generating plnxtool conf
[INFO] generating meta-plnx-generated layer
[INFO] generating user layers
[INFO] generating machine configuration
[INFO] generating bbappends for project . This may take time ! 

 因为太慢了我把处理器的内核改了一下,改成3GB,八核。然后终于成功了。

3.下面:petalinux-config -c u-boot 等待一段时间跳出图形化界面

然后在另外一个终端打开字符图形化界面:

同理

4.petalinux-config -c kernel

5.petalinux-config -c rootfs

6.编译整个petalinux工程,也可以单独编译0

petalinux-build

 最后生成的结果是在images/linux生成镜像文件

7.制作启动镜像文件BOOT.bin文件

boot.bin是多个镜像文件组合而成的,包括fsbl镜像文件,bitstream镜像文件,用户程序镜像文件

petalinux-package --boot --fsbl --fpga --u-boot --force

--boot:生成BOOT.bin镜像文件

--fsbl:用于指向fsbl镜像文件路径

--fpga:用于指向bitstream文件

--u-boot 用于指定u-boot(用户镜像文件)

--force :强制覆盖

z@ubuntu:~/PetaLinux2019.1/zynq_linux/images/linux$ petalinux-package --boot --fsbl ./zynq_fsbl.elf  --fpga ./system.bit --u-boot ./u-boot.elf --force
INFO: File in BOOT BIN: "/home/z/PetaLinux2019.1/zynq_linux/images/linux/zynq_fsbl.elf"
INFO: File in BOOT BIN: "/home/z/PetaLinux2019.1/zynq_linux/images/linux/system.bit"
INFO: File in BOOT BIN: "/home/z/PetaLinux2019.1/zynq_linux/images/linux/u-boot.elf"
INFO: Generating Zynq binary package BOOT.BIN...


****** Xilinx Bootgen v2019.1
  **** Build date : May 11 2019-11:15:10
    ** Copyright 1986-2019 Xilinx, Inc. All Rights Reserved.

INFO: Binary is ready.
WARNING: Unable to access the TFTPBOOT folder /tftpboot!!!
WARNING: Skip file copy to TFTPBOOT folder!!!

image.ub包括kernel,设备树和根文件系统。所有我们只需提供image.ub和BOOT.bin文件就可以了。

8.制作SD启动卡

将image.ub和BOOT.bin拷贝到SD卡的FAT32分区,再插入SD卡启动板卡。

首先将SD卡用读卡器读入,读入进入虚拟机,在虚拟机中查看板卡的挂载点:

z@ubuntu:~/PetaLinux2019.1/zynq_linux/images/linux$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1.5G     0  1.5G   0% /dev
tmpfs           298M  8.8M  290M   3% /run
/dev/sda1       984G   36G  898G   4% /
tmpfs           1.5G  212K  1.5G   1% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           1.5G     0  1.5G   0% /sys/fs/cgroup
vmhgfs-fuse     932G  623G  309G  67% /mnt/hgfs
tmpfs           298M   48K  298M   1% /run/user/1000
/dev/sdb1        60G  3.4G   57G   6% /media/z/DA18-EBFA

这张卡是旧卡,要把这个设备点卸载掉,创建一个新的FAT32分区。

z@ubuntu:~/PetaLinux2019.1/zynq_linux/images/linux$ umount /media/z/DA18-EBFA 

然后再用df命令就找不到挂载点了

下面我们要创建FAT32分区,

z@ubuntu:~/PetaLinux2019.1/zynq_linux/images/linux$ sudo fdisk /dev/sdb

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): m

Help:

  DOS (MBR)
   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag

  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu
   u   change display/entry units
   x   extra functionality (experts only)

  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table


Command (m for help): 

查看设备分区:

Command (m for help): p
Disk /dev/sdb: 59.7 GiB, 64088965120 bytes, 125173760 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x06f41121

Device     Boot Start       End   Sectors  Size Id Type
/dev/sdb1       32768 125173759 125140992 59.7G  c W95 FAT32 (LBA)

现在把这个分区删掉:

Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

下面创建新的分区

Command (m for help): p
Disk /dev/sdb: 59.7 GiB, 64088965120 bytes, 125173760 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x06f41121

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): 

Using default response p.
Partition number (1-4, default 1): 1
First sector (2048-125173759, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-125173759, default 125173759): 

Created a new partition 1 of type 'Linux' and of size 59.7 GiB.

指定分区为FAT32

Command (m for help): t
Selected partition 1
Partition type (type L to list all types): L

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris        
 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden or  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx         
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data    
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility   
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt         
 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access     
 a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O        
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor      
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi ea  Rufus alignment
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         eb  BeOS fs        
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ee  GPT            
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        ef  EFI (FAT-12/16/
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f0  Linux/PA-RISC b
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f1  SpeedStor      
14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f4  SpeedStor      
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      f2  DOS secondary  
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fb  VMware VMFS    
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fc  VMware VMKCORE 
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fd  Linux raid auto
1c  Hidden W95 FAT3 75  PC/IX           bc  Acronis FAT32 L fe  LANstep        
1e  Hidden W95 FAT1 80  Old Minix       be  Solaris boot    ff  BBT            
Partition type (type L to list all types): c
Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.

保存退出:

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

格式化:

z@ubuntu:~/PetaLinux2019.1/zynq_linux/images/linux$ sudo mkfs.vfat -F 32 -n boot /dev/sdb1
mkfs.fat 3.0.28 (2015-05-16)
mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows

然后手动挂载查看挂载点df -h

拷贝文件:

z@ubuntu:~/PetaLinux2019.1/zynq_linux/images/linux$ cp -a BOOT.BIN image.ub /media/z/boot/

同步和卸载:

z@ubuntu:~/PetaLinux2019.1/zynq_linux/images/linux$ sync
z@ubuntu:~/PetaLinux2019.1/zynq_linux/images/linux$ umount /media/z/boot 

用户名和密码默认都是root. 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

雪中奇侠

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值