The purpose of this page is to describe how to use PetaLinux to build Linux system and boot on the ZynqMPSoC platform.

SOFTWARE TOOLS AND SYSTEM REQUIREMENTS

  • Linux host RHEL 6 64bit
  • Set up BASH as default shell
  • Install 32bit libs on the Linux host
  • Install the libs/tools documented in the "PetaLinux Tools Installation Requirements" section in "Reference Guide" of PetaLinux tools 2014.4.
  • Download petalinux-v2015.2_ZUB2-dev-installer.run installer

Install PetaLinux Tools and Reference BSP


Download the PetaLinux installer and Install PetaLinux Tools by running the installer
$./petalinux-v2015.3-dev-installer.run

Source PetaLinux tools settings
$ source petalinux-v2015.3-dev/settings.sh
PetaLinux environment set to '/petalinux-v2015.3-dev'
INFO: Checking free disk space
INFO: Checking installed tools
INFO: Checking installed development libraries
INFO: Checking network and other services
Turn off webtalk since it is not working for ZynqMPSoC early access
$ petalinux-util --webtalk off
INFO: Turn off webtalk feature
Install the PetaLinux reference BSP
To extract the reference design project within the BSP to your working directory.
$ petalinux-create -t project -s Xilinx-ZynqMP-QEMU-2015.3.bsp
INFO: Create project:
INFO: Projects:
INFO: * Xilinx-ZynqMP-QEMU-2015.3
INFO: has been successfully installed to /petalinux-v2015.3_0820_2/
INFO: New project successfully created in /petalinux-v2015.3_0820_2/
If you want to rename the extracted reference design project, you can run
$ petalinux-create -t project -s Xilinx-ZynqMP-QEMU-2015.3.bsp -n <MYPROJ>

Go inside the PetaLinux project directory
$ cd Xilinx-ZynqMP-QEMU-2015.3

Boot prebuilt Linux image with QEMU
$ petalinux-boot --qemu --prebuilt 3
Sending discover...
[ 18.230839] macb ff0b0000.ethernet eth0: link up (100/Full)
[ 18.234414] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
Sending discover...
Sending select for 10.0.2.15...
Lease of 10.0.2.15 obtained, lease time 86400
/etc/udhcpc.d/50default: Adding DNS 10.0.2.3
done.
Stopping Bootlog daemon: Warning unable to detect baudrate, use 115200!
Use default dev ttyPS0
Running dynamic getty on ttyPS0/115200
 
Built with PetaLinux v2015.3 (Yocto 1.8) Xilinx-ZynqMP-QEMU-2015_3 /dev/ttyPS0
Xilinx-ZynqMP-QEMU-2015_3 login: root
Password:
login[1335]: root login on 'ttyPS0'
root@Xilinx-ZynqMP-QEMU-2015_3:~#

To Rebuild the Whole PetaLinux Project
$ petalinux-build
INFO: Checking component...
INFO: Generating make files and build linux
INFO: Generating make files for the subcomponents of linux
INFO: Building linux
[INFO ] pre-build linux/rootfs/rpmsg_echo_test_kern_app
[INFO ] pre-build linux/rootfs/rpmsg_mat_mul_kern_app
[INFO ] pre-build linux/rootfs/rpmsg_proxy_dev_driver
[INFO ] pre-build linux/rootfs/rpmsg_user_dev_driver
[INFO ] pre-build linux/rootfs/echo_test
[INFO ] pre-build linux/rootfs/fwupgrade
[INFO ] pre-build linux/rootfs/getty-baud
[INFO ] pre-build linux/rootfs/gpio-demo
[INFO ] pre-build linux/rootfs/mat_mul_demo
[INFO ] pre-build linux/rootfs/peekpoke
[INFO ] pre-build linux/rootfs/proxy_app
[INFO ] pre-build linux/rootfs/xen
[INFO ] build system.dtb
[INFO ] build linux/kernel
[INFO ] update linux/u-boot source
[INFO ] generate linux/u-boot configuration files
[INFO ] build linux/u-boot
[INFO ] build zynqmp_fsbl
[INFO ] update linux/arm-trusted-firmware source
[INFO ] build linux/arm-trusted-firmware
[INFO ] Setting up stage config
[INFO ] Setting up rootfs config
[INFO ] Updating for aarch64
[INFO ] Updating package manager
[INFO ] Expanding stagefs
[INFO ] build kernel in-tree modules
[INFO ] modules linux/kernel
[INFO ] build linux/rootfs/rpmsg_echo_test_kern_app
[INFO ] modules linux/kernel
[INFO ] build linux/rootfs/rpmsg_mat_mul_kern_app
[INFO ] modules linux/kernel
[INFO ] build linux/rootfs/rpmsg_proxy_dev_driver
[INFO ] modules linux/kernel
[INFO ] build linux/rootfs/rpmsg_user_dev_driver
[INFO ] modules linux/kernel
[INFO ] build linux/rootfs/echo_test
[INFO ] build linux/rootfs/fwupgrade
[INFO ] build linux/rootfs/getty-baud
[INFO ] build linux/rootfs/gpio-demo
[INFO ] build linux/rootfs/mat_mul_demo
[INFO ] build linux/rootfs/peekpoke
[INFO ] build linux/rootfs/proxy_app
[INFO ] build linux/rootfs/xen
[INFO ] post-build linux/rootfs/rpmsg_echo_test_kern_app
[INFO ] post-build linux/rootfs/rpmsg_mat_mul_kern_app
[INFO ] post-build linux/rootfs/rpmsg_proxy_dev_driver
[INFO ] post-build linux/rootfs/rpmsg_user_dev_driver
[INFO ] post-build linux/rootfs/echo_test
[INFO ] post-build linux/rootfs/fwupgrade
[INFO ] post-build linux/rootfs/getty-baud
[INFO ] post-build linux/rootfs/gpio-demo
[INFO ] post-build linux/rootfs/mat_mul_demo
[INFO ] post-build linux/rootfs/peekpoke
[INFO ] post-build linux/rootfs/proxy_app
[INFO ] post-build linux/rootfs/xen
[INFO ] pre-install linux/rootfs/rpmsg_echo_test_kern_app
[INFO ] pre-install linux/rootfs/rpmsg_mat_mul_kern_app
[INFO ] pre-install linux/rootfs/rpmsg_proxy_dev_driver
[INFO ] pre-install linux/rootfs/rpmsg_user_dev_driver
[INFO ] pre-install linux/rootfs/echo_test
[INFO ] pre-install linux/rootfs/fwupgrade
[INFO ] pre-install linux/rootfs/getty-baud
[INFO ] pre-install linux/rootfs/gpio-demo
[INFO ] pre-install linux/rootfs/mat_mul_demo
[INFO ] pre-install linux/rootfs/peekpoke
[INFO ] pre-install linux/rootfs/proxy_app
[INFO ] pre-install linux/rootfs/xen
[INFO ] install system.dtb
[INFO ] install linux/kernel
[INFO ] update linux/u-boot source
[INFO ] generate linux/u-boot configuration files
[INFO ] build linux/u-boot
[INFO ] install linux/u-boot
[INFO ] install linux/arm-trusted-firmware
[INFO ] Expanding rootfs
[INFO ] install sys_init
[INFO ] install kernel in-tree modules
[INFO ] modules_install linux/kernel
[INFO ] install linux/rootfs/rpmsg_echo_test_kern_app
[INFO ] modules_install linux/kernel
[INFO ] install linux/rootfs/rpmsg_mat_mul_kern_app
[INFO ] modules_install linux/kernel
[INFO ] install linux/rootfs/rpmsg_proxy_dev_driver
[INFO ] modules_install linux/kernel
[INFO ] install linux/rootfs/rpmsg_user_dev_driver
[INFO ] modules_install linux/kernel
[INFO ] install linux/rootfs/echo_test
[INFO ] install linux/rootfs/fwupgrade
[INFO ] install linux/rootfs/getty-baud
[INFO ] install linux/rootfs/gpio-demo
[INFO ] install linux/rootfs/mat_mul_demo
[INFO ] install linux/rootfs/peekpoke
[INFO ] install linux/rootfs/proxy_app
[INFO ] install linux/rootfs/xen
[INFO ] post-install linux/rootfs/rpmsg_echo_test_kern_app
[INFO ] post-install linux/rootfs/rpmsg_mat_mul_kern_app
[INFO ] post-install linux/rootfs/rpmsg_proxy_dev_driver
[INFO ] post-install linux/rootfs/rpmsg_user_dev_driver
[INFO ] post-install linux/rootfs/echo_test
[INFO ] post-install linux/rootfs/fwupgrade
[INFO ] post-install linux/rootfs/getty-baud
[INFO ] post-install linux/rootfs/gpio-demo
[INFO ] post-install linux/rootfs/mat_mul_demo
[INFO ] post-install linux/rootfs/peekpoke
[INFO ] post-install linux/rootfs/proxy_app
[INFO ] post-install linux/rootfs/xen
[INFO ] package rootfs.cpio to /Xilinx-ZynqMP-QEMU-2015.3/images/linux
[INFO ] Update and install vmlinux image
[INFO ] vmlinux linux/kernel
[INFO ] install linux/kernel
[INFO ] package Image
[INFO ] Image linux/kernel
[INFO ] install linux/kernel
[INFO ] Package HDF bitstream
 
 
Rebuild Specific Component Only
To build only kernel
$ petalinux-build -c kernel
INFO: Checking component...
INFO: Generating make files and build linux/kernel
INFO: Generating make files for the subcomponents of linux/kernel
INFO: Building linux/kernel
[INFO ] build linux/kernel
[INFO ] install linux/kernel

To build other components
$ petalinux-build -c device-tree
INFO: Checking component...
INFO: Generating make files and build linux/device-tree
INFO: Generating make files for the subcomponents of linux/device-tree
INFO: Building linux/device-tree
[INFO ] build system.dtb
[INFO ] install system.dtb
$ petalinux-build -c bootloader
INFO: Checking component...
INFO: Generating make files and build linux/bootloader
INFO: Generating make files for the subcomponents of linux/bootloader
INFO: Building linux/bootloader
[INFO ] build zynqmp_fsbl
$ petalinux-build -c arm-trusted-firmware
INFO: Checking component...
INFO: Generating make files and build linux/arm-trusted-firmware
INFO: Generating make files for the subcomponents of linux/arm-trusted-firmware
INFO: Building linux/arm-trusted-firmware
[INFO ] update linux/arm-trusted-firmware source
[INFO ] build linux/arm-trusted-firmware
[INFO ] install linux/arm-trusted-firmware
$ petalinux-build -c u-boot
INFO: Checking component...
INFO: Generating make files and build linux/u-boot
INFO: Generating make files for the subcomponents of linux/u-boot
INFO: Building linux/u-boot
[INFO ] update linux/u-boot source
[INFO ] generate linux/u-boot configuration files
[INFO ] build linux/u-boot
[INFO ] update linux/u-boot source
[INFO ] generate linux/u-boot configuration files
[INFO ] build linux/u-boot
[INFO ] install linux/u-boot
$ petalinux-build -c rootfs
INFO: Checking component...
INFO: Generating make files and build linux/rootfs
INFO: Generating make files for the subcomponents of linux/rootfs
INFO: Building linux/rootfs
[INFO ] pre-build linux/rootfs/rpmsg_echo_test_kern_app
[INFO ] pre-build linux/rootfs/rpmsg_mat_mul_kern_app
[INFO ] pre-build linux/rootfs/rpmsg_proxy_dev_driver
[INFO ] pre-build linux/rootfs/rpmsg_user_dev_driver
[INFO ] pre-build linux/rootfs/echo_test
[INFO ] pre-build linux/rootfs/fwupgrade
[INFO ] pre-build linux/rootfs/getty-baud
[INFO ] pre-build linux/rootfs/gpio-demo
[INFO ] pre-build linux/rootfs/mat_mul_demo
[INFO ] pre-build linux/rootfs/peekpoke
[INFO ] pre-build linux/rootfs/proxy_app
[INFO ] pre-build linux/rootfs/xen
[INFO ] Setting up stage config
[INFO ] Setting up rootfs config
[INFO ] Updating for aarch64
[INFO ] Updating package manager
[INFO ] Expanding stagefs
[INFO ] build kernel in-tree modules
[INFO ] modules linux/kernel
[INFO ] build linux/rootfs/rpmsg_echo_test_kern_app
[INFO ] modules linux/kernel
[INFO ] build linux/rootfs/rpmsg_mat_mul_kern_app
[INFO ] modules linux/kernel
[INFO ] build linux/rootfs/rpmsg_proxy_dev_driver
[INFO ] modules linux/kernel
[INFO ] build linux/rootfs/rpmsg_user_dev_driver
[INFO ] modules linux/kernel
[INFO ] build linux/rootfs/echo_test
[INFO ] build linux/rootfs/fwupgrade
[INFO ] build linux/rootfs/getty-baud
[INFO ] build linux/rootfs/gpio-demo
[INFO ] build linux/rootfs/mat_mul_demo
[INFO ] build linux/rootfs/peekpoke
[INFO ] build linux/rootfs/proxy_app
[INFO ] build linux/rootfs/xen
[INFO ] post-build linux/rootfs/rpmsg_echo_test_kern_app
[INFO ] post-build linux/rootfs/rpmsg_mat_mul_kern_app
[INFO ] post-build linux/rootfs/rpmsg_proxy_dev_driver
[INFO ] post-build linux/rootfs/rpmsg_user_dev_driver
[INFO ] post-build linux/rootfs/echo_test
[INFO ] post-build linux/rootfs/fwupgrade
[INFO ] post-build linux/rootfs/getty-baud
[INFO ] post-build linux/rootfs/gpio-demo
[INFO ] post-build linux/rootfs/mat_mul_demo
[INFO ] post-build linux/rootfs/peekpoke
[INFO ] post-build linux/rootfs/proxy_app
[INFO ] post-build linux/rootfs/xen
[INFO ] pre-install linux/rootfs/rpmsg_echo_test_kern_app
[INFO ] pre-install linux/rootfs/rpmsg_mat_mul_kern_app
[INFO ] pre-install linux/rootfs/rpmsg_proxy_dev_driver
[INFO ] pre-install linux/rootfs/rpmsg_user_dev_driver
[INFO ] pre-install linux/rootfs/echo_test
[INFO ] pre-install linux/rootfs/fwupgrade
[INFO ] pre-install linux/rootfs/getty-baud
[INFO ] pre-install linux/rootfs/gpio-demo
[INFO ] pre-install linux/rootfs/mat_mul_demo
[INFO ] pre-install linux/rootfs/peekpoke
[INFO ] pre-install linux/rootfs/proxy_app
[INFO ] pre-install linux/rootfs/xen
[INFO ] Expanding rootfs
[INFO ] install sys_init
[INFO ] install kernel in-tree modules
[INFO ] modules_install linux/kernel
[INFO ] install linux/rootfs/rpmsg_echo_test_kern_app
[INFO ] modules_install linux/kernel
[INFO ] install linux/rootfs/rpmsg_mat_mul_kern_app
[INFO ] modules_install linux/kernel
[INFO ] install linux/rootfs/rpmsg_proxy_dev_driver
[INFO ] modules_install linux/kernel
[INFO ] install linux/rootfs/rpmsg_user_dev_driver
[INFO ] modules_install linux/kernel
[INFO ] install linux/rootfs/echo_test
[INFO ] install linux/rootfs/fwupgrade
[INFO ] install linux/rootfs/getty-baud
[INFO ] install linux/rootfs/gpio-demo
[INFO ] install linux/rootfs/mat_mul_demo
[INFO ] install linux/rootfs/peekpoke
[INFO ] install linux/rootfs/proxy_app
[INFO ] install linux/rootfs/xen
To regenerate the image.ub, Image and rootfs.cpio.gz
$ petalinux-build -x package
INFO: Checking component...
INFO: Generating make files and build linux
INFO: Generating make files for the subcomponents of linux
INFO: Building linux
[INFO ] package rootfs.cpio to /Xilinx-ZynqMP-QEMU-2015.3/images/linux
[INFO ] Update and install vmlinux image
[INFO ] vmlinux linux/kernel
[INFO ] install linux/kernel
[INFO ] package Image
[INFO ] Image linux/kernel
[INFO ] install linux/kernel
[INFO ] Package HDF bitstream
If you want to cleanup the built component before rebuilding
$ petalinux-build -c device-tree -x mrproper
INFO: Checking component...
INFO: Generating make files and build linux/device-tree
To generate BOOT.BIN with fsbl and u-boot
$ petalinux-package --boot --u-boot

To generate BOOT.BIN with fsbl
$ petalinux-package --boot

Reconfigure Linux Components

To reconfigure kernel
$ petalinux-config -c kernel
It will show you the kernel configuration menu
INFO: Checking component...
INFO: Config linux/kernel
[INFO ] config linux/kernel
 
 
*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.

To reconfigure rootfs
$ petalinux-config -c rootfs
It will show you the rootfs configuration menu
INFO: Checking component...
INFO: Config linux/rootfs
[INFO ] config linux/rootfs
 
 
*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.
To add linux application
First create the application
$ petalinux-create -t apps -n myapp --enable
The above command will create a Linux application "myapp" in "components/apps/myapp" from "C" template, and it will be enabled to the rootfs.
If you want to create different type of Linux application, such as C++, autoconf, install-only binary, you can run "petalinux-create -t apps --help", it will shows you all the available options.
hello is the application
INFO: Create apps: hello
INFO: New apps successfully created in /Xilinx-ZynqMP-QEMU-2015.3/components/apps/hello
INFO: Enabling created component...
INFO: It has been enabled to linux/rootfs

Rebuild PetaLinux project for the Linux application
You can rebuild the whole project,rootfs or just the application
$ petalinux-build
$ petalinux-build -c rootfs
$ petalinux-build -c rootfs/myapp
hello is myapp
INFO: Checking component...
INFO: Generating make files and build linux/rootfs/hello
INFO: Generating make files for the subcomponents of linux/rootfs/hello
INFO: Building linux/rootfs/hello
[INFO ] pre-build linux/rootfs/hello
[INFO ] build linux/rootfs/hello
[INFO ] post-build linux/rootfs/hello
[INFO ] pre-install linux/rootfs/hello
[INFO ] install linux/rootfs/hello

To add Linux user libraries to your rootfs.
$ petalinux-create -t libs -n mylib --enable
The above command will create a Linux user library "mylib" in "components/libs/mylib"
hello_lib is the mylib
INFO: Create libs: hello_lib
INFO: New libs successfully created in /Xilinx-ZynqMP-QEMU-2015.3/components/libs/hello_lib
INFO: Enabling created component...
INFO: It has been enabled to linux/rootfs

Again rebuild the whole project,rootfs or just the library
$ petalinux-build -c rootfs/mylib
INFO: Checking component...
INFO: Generating make files and build linux/rootfs/hello_lib
INFO: Generating make files for the subcomponents of linux/rootfs/hello_lib
INFO: Building linux/rootfs/hello_lib
[INFO ] pre-build linux/rootfs/hello_lib
[INFO ] build linux/rootfs/hello_lib
[INFO ] post-build linux/rootfs/hello_lib
[INFO ] pre-install linux/rootfs/hello_lib
[INFO ] install linux/rootfs/hello_lib

PetaLinux uses library priorities to decide the compilation sequence of the user libraries.
To specify the priority of you library
$ petalinux-create -t libs -n mylib --enable --priority X
X is the priority of your library."1" has the highest priority which will be built first.
Please find the available priorities from with the "--help" of "petalinux-create -t libs".

Test Your Rebuilt Images on QEMU
Boot u-boot on QEMU
$ petalinux-boot --qemu --u-boot
In: serial
Out: serial
Err: serial
SCSI: SATA link 0 timeout.
AHCI 0001.0000 32 slots 2 ports 1.5 Gbps 0x3 impl SATA mode
flags: ncq only
scanning bus for devices...
Found 0 device(s).
Net: Gem.ff0b0000
Hit any key to stop autoboot: 0
ZynqMP>

Boot kernel with QEMU
$ petalinux-boot --qemu --kernel
Sending discover...
Sending select for 10.0.2.15...
Lease of 10.0.2.15 obtained, lease time 86400
/etc/udhcpc.d/50default: Adding DNS 10.0.2.3
done.
Stopping Bootlog daemon: Warning unable to detect baudrate, use 115200!
Use default dev ttyPS0
Running dynamic getty on ttyPS0/115200
 
Built with PetaLinux v2015.3 (Yocto 1.8) Xilinx-ZynqMP-QEMU-2015_3 /dev/ttyPS0
Xilinx-ZynqMP-QEMU-2015_3 login: root
Password:
login[1337]: root login on 'ttyPS0'
root@Xilinx-ZynqMP-QEMU-2015_3:~#

Related Links

  • Title 1 & Link 1
  • Title 1 & Link 1