Joint ICTP-IAEA School on
Zynq-7000 SoC and its
Applications for Nuclear
and Related Instrumentation
Introduction to Petalinux
Fernando Rincón
fernando.rincon@uclm.es
Smr3143 – ICTP & IAEA (Aug. & Sept. 2017)
Contents
● Why Petalinux?
● Petalinux Tools & Flow
– Project creation
– Project confguration
– Project building
– Project booting
– Project packaging
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 2
Why Petalinux?
Linux Components All these should be built!!
Tools
Application Utilities User Applications Root Filesystem
Linux Build & Development
GNU Cross-Compiler tool
(rootfs)
chain & Debugger
Libraries – Graphics, Video, Networking, etc.
Tool
Kernel
Linux Kernel Device Drivers Image
U-boot
Boot
Loader
First Stage Boot Loader
Hardware QEMU
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 3
Why Petalinux?
● Buiding a Linux system requires:
– Building the bootloader from its source code
– Building the Linux kernel:
● Requires a Toolchain for cross-platform compilation (baremetal compiler)
● Kernel source code
● Drivers source code (for peripherals not in the standard kernel tree)
– Building a root flesystem
● To hold the libraries, graphical environment, user applications, ….
– Buiding system and user applications
● Such as system services: shell, network communication, …
● And fnal user applications
● But requiring a diferent compiler:
– Also cross-compiler but using linux libraries instead of baremetal
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 4
Why Petalinux?
● Lots of documentation and good
books about the Linux building
process from scratch
● And all code specifc to Xilinx
boards and drivers is publicly
available:
– https://github.com/xilinx
– Because the standard kernel
tree and bootloaders do not
directly support all Xilinx Hw
● However, this is a really painful
and long process to go for non-
experts
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 5
Why Petalinux?
● Petalinux is a all-in-one development environment
– Kernel/library/user application sources
– Compiler toolchains
– Hardware reference designs
– PetaLinux BSP generator
– QEMU full-system simulator
– Tools to bring it all together
– Lots of documentation
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 6
Petalinux requirements
● Host machine ● Target machine
– Linux OSrequirements (supported) – ARM® CortexTM-A9 MPcore
● Red Hat Enterprise Linux CPU
6.5/6.6/7.0 (64-bit)
● CentOS 7.0 (64-bit)
– External memory controller
● SUSE Enterprise 12.0 (64-bit)
● 32 MB recommended
minimum
● Ubuntu 14.0.4 (64-bit)
– Hardware requirements
– Interrupt controller
● 4 GB RAM – Triple timer count (TTC)
● 2 GHz CPU – Other I/O as required
● Minimum of 5 GB free HDD space ● Serial, Ethernet
– Xilinx Requirements ● Flash memory
● Vivado Design Suite 2016.4 (NOR/NAND/QSPI)
● Petalinux Tools 2016.4
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 7
Petalinux Tools Flow
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 8
Petalinux Project Flow
● Create a hardware design
– Launch the Vivado Design Suite
– Use Vivado IP integrator (IPI) to
create a block design
● Add processor (ARM Cortex-A9
or MicroBlazeTM processor)
● Add required peripherals such
as AXI GPIO, AXI Interrupt
Controller, Timer
● Synthesis, implementation, and
bitstream
● Export the hardware design to
SDK
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 9
Petalinux Project Flow
● Create the Petalinux project
– petalinux-create tool
– Builds the basic project structure
– Two options
● From a template:
– General case for an architecture or board
– Preconfgured
– Customized hardware
$ petalinux-create [options] --type project --name <project_name> \
--template zynq
● From a BSP:
– Previously packed from a working confguration
– May include more hw & sw than required
$ petalinux-create [options] --type project -s <path to template>
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 10
Petalinux Project Flow
● Petalinux Project Structure
– A Built linux system is composed of:
● First Stage Boot Loader
● U-Boot
● Linux Kernel
● Device Tree
● Root Filesystem, which typically includes
– Prebuilt packages
– User applications (optional)
– User modules (optional)
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 11
Petalinux Project Flow
● Petalinux Project Structure
.
├── components
│ └── plnx_workspace Other components apart from the kernel
│ ├── device-tree-generation and user apps: fsbl, device-tree
│ ├── fsbl
│ ├── fsbl_bsp
│ ├── fsbl_hwproj
│ └── SDK.log
├── config.project Project confguration fle
├── hardware
│ └── avnet-digilent-zedboard-2016.4 Vivado hardware project
│
├── pre-built Pre-built images and bitstream
│ └── linux
│ ├── etc
│ ├── images
│ └── implementation Specifcation of the project
└── project-spec
├── attributes Kernel and rootfs confguration fles
├── configs Hw description exported from Vivado
├── hw-description
├── meta-plnx-generated Recipes for petalinux generated components
└── meta-user Recipes for user generated components: applications
├── README and overrides of the default platform settings
├── recipes-apps
└── ...
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 12
Petalinux Project Flow
● Confgure the project:
– Select the characteristics of the kernel, booting arguments, root flesystem
location & contents, …
– petalinux-config tool
– To import the hardware platform generated in vivado:
● cd to the location of the exported .hdf fle
$ petalinux-config --get-hw-description -p <path to project> \
--template zynq
– To confgure the petalinux in general
$ petalinux-config
– To confgure the kernel
$ petalinux-config -c kernel
– To confgure the root flesystem
$ petalinux-config -c rootfs
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 13
Petalinux Project Flow
● Build the project:
– petalinux-build tool
– Can generate the whole project: bootloader, kernel, root flesystem and target
image
$ petalinux-build kernel
● The bootable images will be found at: <project>/images/linux rootfs
– Or just single components:
$ petalinux-build -component <component>
– In order to clean the project:
$ petalinux-build -x clean
– Or more drastically:
$ petalinux-build -x mrproper
– Any component can be cleaned individually
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 14
Petalinux Project Flow
● Boot the image
– petalinux-boot tool
– Can boot on a real processor (Microblaze / Zynq)
– But also on an emulator (QEMU)
$ petalinux-boot--qemu|--jtag -c|--component <COMPONENT> [options]
– Some examples:
● Boot the prebuilt images 1 – FSBL
2 – Uboot
$ petalinux-boot –-jtag –prebuilt 1|2|3
3 – Kernel
● Download current bitstream
$ petalinux-boot --jtag --fpga --bitstream <BITSTREAM>
● Download current kernel
$ petalinux-boot –-jtag --kernel
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 15
Petalinux Project Flow
● QEMU: Quick EMUlator
– Open Source (GPL) multi-architecture emulator
– Like a Virtual Machine
● Emulates CPU architecture (e.g. emulating a ARM CPU on a x86 host)
● Emulates Devices (e.g. SPI Flash, Ethernet, SDHCI + SD Card, USB HCI,
etc.)
● Not a simulator, has no timing accuracy (can however interact with
simulators)
● Can load a system machine model from a Device Tree (this is only for the
Xilinx QEMU)
– Great way to test your system without needing hardware
● Quick boot times, no need to play around with JTAG/SD cards/etc to get a
booting system
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 16
Petalinux Project Flow
● QEMU Boot Flows
– FSBL is not compatible or required
● QEMU handles the Zynq Initialization
– You can boot into U-Boot
● And then follow a boot fow from a storage device
– Or you can boot directly to the Kernel
● QEMU can handle kernel, root fle system and device tree loading
– This is much quicker that loading U-Boot, and is the recommended fow
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 17
Petalinux Project Flow
● Other useful tool: petalinux-package
– packages various image format, frmware, prebuilt and BSPs
$ petalinux-package --boot| --bsp| --firmware| --image| --prebuilt [options]
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 18