MicroZed Chronicles: PetaLinux Build
Having looked at creating the virtual machine and the different build elements of PetaLinux.
In this blog I am going to demonstrate how we create a PetaLinux embedded Linux solution for our Zynq design. In this case we are going to use the Cora Z7 as the target development board.
To create an embedded Linux solution for our Zynq, Zynq MPSoC or MicroBlaze solutions we start with a hardware design in Vivado.
For this application we are going to connect the Zynq Processing System (PS) to the LED and Push Buttons which are on the Cora Z7. This will make for a nice example in our next blog on interfacing between the PS and Programmable Logic (PL).
This connection is made using a AXI GPIO IP located within the PL, this is then connected to the PS Master AXI port as shown below.
Once this block diagram has been completed we need to implement the Vivado design and export the XSA with the bit stream included.
Export the XSA to the project directory, this XSA will inform our embedded Linux solution about the configuration of the hardware.
With the XSA exported the next steps take place all within PetaLinux, the first thing we need to do is create a new project.
Within our Virtual Machine, the next step is to open a terminal window and create a new project using the command.
petalinux-create --type project --template zynq --name cora_z7
This will create a new project targeting the Zynq architecture with a project name of cora_z7.
The next step is to change directory into the newly created project, and then configure the project for the Cora Z7 and our design using the XSA just created in Vivado.
petalinux-config --get-hw-description=/<location of XSA>
This will open the PetaLinux system configuration
In this case we do not wish to make any modifications, as such the we can select exit.
If you want to explore the kernel and rootfs settings you can use the commands
petalinux-config -c kernel
petalinux-config -c rootfs
As we do not need to make changes to either the kernel or the rootfs we can now build the PetaLinux operating system using
petalinx-build
Once the build process has finished, it may take some time we can then try the image on our Cora Z7 hardware using the commands
petalinux-build --jtag --fpga
petalinux-build --jtag -- kernel
This will program the Zynq device with the bit stream and then download the kernel.
Watching the boot output on a serial terminal will show you the Linux image booting on the Cora
If the above steps work and we have finished our testing and development we can then package the build objects to create a Bin file for booting from memory.
petalinux-package --boot --fsbl zynq_fsbl.elf --uboot uboot.elf --fpga system.bit
We can also package the PetaLinux project as a BSP such that if we wish to make changes to the PetaLinux system in the future we can use the BSP to create a new project, which is already configured correctly for our system.
Unlike all of the other commands this needs to be executed outside the project
petalinux-package --bsp -p <project location>
No we have successfully built a Embedded Linux OS which is up and running on the Cora Board.
Next time we will look at how we can interface between the PS and PL when we are using PetaLinux.
See My FPGA / SoC Projects: Adam Taylor on Hackster.io
Get the Code: ATaylorCEngFIET (Adam Taylor)
Access the MicroZed Chronicles Archives with over 300 articles on the FPGA / Zynq / Zynq MpSoC updated weekly at MicroZed Chronicles.