We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

Showing results for 
Search instead for 
Did you mean: 

MicroZed Chronicles: Building PetaLinux for MicroBlaze HW Build Part 2

Xilinx Employee
Xilinx Employee
0 0 851

This content is republished from the MicroZed Chronicles, with permission from the author and Hackster.io.


In last week’s blog we implemented the Vivado design and proved the basic hardware design using BareMetal SW for a MicroBlaze on which we can run PetaLinux. In this blog we are going build the PetaLinux image and download it in to the Artix FPGA, so that we can use the PetaLinux Kernel.

To do this I am going to be using a Virtual Machine, running Ubuntu, with Vivado webpack 2018.3 and PetaLinux 2018.3 also installed. I also have a shared drive between the host windows 10 OS and the VM.

To create the PetaLinux project we will need to use the hardware definition file (HDF) we exported from Vivado.

The first thing to do in a Linux terminal window is to create a PetaLinux Project, we do this using the command below

petalinux-create --type project --template microblaze --name linux_mb

This creates a PetaLinux project with the name of linux_mb and configures the project for a MicroBlaze processor. However, the project does not yet include the configuration of our MicroBlaze design. To configure the PetaLinux for our hardware design we use the command below

petalinux-config --get-hw-description ../

Point the hardware description to the directory containing the HDF of our MicroBlaze solution. Ensure there is only one HDF in the directory otherwise you may get a different configuration to what you may think. This configuration will bring up the PetaLinux configuration window.

Fig1_PetaLinux configuration windows.png


You do not need to change anything here, but you may want to look around and check that the processor is a MicroBlaze.

Fig2_PetaLinux configuration windows MicroBlaze.png


Once you exit this dialog you will see the bitbake recipes running.

Fig3_bitbake recipes.png


Once the configuration has completed, as we do not want to make any changes to the Kernel or Root File System, we can build the image.

Use the command



This may take a little while but by the time it is completed we will have all the files necessary to run PetaLinux on the Artix, using either a JTAG download or from the QSPI memory. However before I run the image on the hardware itself I first want to check it will run OK, to do this I used QEMU which allows me to test the Kernel image in the virtual machine.

We can run QEMU using the command

petalinux-boot –-QEMU –-kernel


This may take a few minutes to boot up but eventually you should see a log in screen as below in the terminal window.

Fig4_login screen.png


The next thing to do is connect the target board to the virtual machine and then we can download the FPGA image and the Kernel Image. We to do this we use the command

petalinux-boot –-jtag –-fpga

petalinux-boot –-jtag –-kernel 


The FPGA download is pretty quick however the Image download can take some time (several minutes) so please be patient unless you see an error reported it is downloading.

Fig5_error message 1.png


Fig6_error message 2.png


With the image downloaded the next thing is to connect a terminal window and log into Petalinux running on the board.

Fig7_terminal window Petalinux running on the board.png


The log in for both of login and password is root.

The board I am using to test this image on is an Arty A7, it as four LEDS as such to test the image is working, I am going to toggle one of the LEDs. To do this we need to know the GPIO ID, to do this we change directory into the /sys/class/gpio directory and then examine the contents of the directory. As there is only one AXI GPIO in the design connected to the LEDs, we know the ident is gpiochip508.


The four LEDs will therefore be numbered 508 to 511. To drive the first LED from the console I am going to export that GPIO before setting its direction and a value which will illuminate the LED

In a terminal I used the following commands to set the first LED on.

$ echo 508 > /sys/class/gpio/export

$ echo out > /sys/class/gpio/gpio508/direction

$ echo 1 > /sys/class/gpio/gpio508/value

Fig9_gpio value.png


Entering these commands turns on the LED on the board.



Now we have Linux running on our MicroBlaze we can use this to help us with our networking and communication with the internet of things which is something we will look at in another blog soon.


See My FPGA / SoC Projects: Adam Taylor on Hackster.io

Get the Code: ATaylorCEngFIET (Adam Taylor)

Access the MicroZed Chronicles Archives with over 280 articles on the Zynq / Zynq MpSoC updated weekly at MicroZed Chronicles.