PetaLinux for Artix-7 Arty Base Project

In the final part of the Arty base project tutorial, we build a PetaLinux project that’s tailored to our Arty base design. Then we boot PetaLinux on our hardware and verify that we have network connectivity by checking the Arty’s DHCP assigned IP address and then pinging it from a PC.

Tools used

I used the following setup to do this project:

  • Vivado 2017.3 on a Windows 10 machine
  • PetaLinux 2017.3 on a Ubuntu 16.04 LTS machine

Vivado project modifications

Before we get started with PetaLinux, we have to make sure that our Vivado design satisfies the minimum requirements for running PetaLinux:

  • Microblaze must use configuration “Linux with MMU” or “Low-end Linux with MMU
  • At least 32MB of external memory
  • Dual channel timer with interrupt connected
  • UART IP with interrupt connected
  • Ethernet IP with interrupt connected

Our original base design satisfies all but one of those requirements - the first one. So the first thing we have to do in this tutorial is to select the “Linux with MMU” configuration for the Microblaze. The next thing we do is to enable the GPIO interrupts and connect them through to the Microblaze - this isn’t a requirement, but it’s useful. We then have to save our block design, re-generate a bitstream for the project and export it.

PetaLinux tool commands

To build the PetaLinux project, we transfer our entire Vivado project to a Linux machine with the PetaLinux tools installed. These are the PetaLinux tool commands that we use in the tutorial, in the order that we use them:

  # Launch PetaLinux tools (note that you'll have to specify your own PetaLinux install path)
  source ./PetaLinux-2017-3/
  # Cd to the working directory (where the arty_base directory has been copied to)
  cd /media/opsero/arty
  # Create the PetaLinux project, using the "microblaze" template
  petalinux-create --type project --template microblaze --name arty_petalinux
  # Cd to the PetaLinux project
  cd arty_petalinux
  # Import the hardware description into our PetaLinux project
  petalinux-config --get-hw-description ../arty_base/arty_base.sdk --oldconfig
  # Optional: Configure the kernel
  petalinux-config -c kernel
  # Optional: Configure the root filesystem
  petalinux-config -c rootfs
  # Build the PetaLinux project

Kernel configuration

The Linux driver for the AXI Ethernetlite IP requires certain drivers to be enabled in the PetaLinux kernel. Fortunately, the PetaLinux tools are pretty good at enabling the drivers for the IP that it finds in your exported Vivado design. So the required drivers are already enabled and we don’t have to run the kernel configuration (petalinux-config -c kernel), but for completeness, here is a list of the required kernel configurations:


Device tree modification

We have to make an addition to the device tree in order to specify the Ethernet PHY’s address with respect to the MDIO bus. This address depends on how the PHY is physically wired, for any particular board it is usually mentioned in the user guide or if not we can usually figure it out from the schematics. In the case of the Arty, the PHY address is 1 (one) and we need to specify this in the device tree so that the Ethernet driver can communicate with the PHY. Below is the device tree code that we need to add to the system-user.dtsi file.


&axi_ethernetlite_0 {
  local-mac-address = [00 0a 35 00 01 22];
  phy-handle = <&phy0>;
  xlnx,has-mdio = <0x1>;
  mdio {
    #address-cells = <1>;
    #size-cells = <0>;
    phy0: phy@1 {
      device_type = "ethernet-phy";
      reg = <1>;

Launching it on the Arty

Once the PetaLinux project is built, we then launch the Putty UART console and program the FPGA with bitstream and kernel. Here are the commands we used:

  # Launch Putty, the UART console
  sudo putty &
  # Program the FPGA with the bitstream
  petalinux-boot --jtag --fpga
  # Load the kernel into memory and run it
  petalinux-boot --jtag --kernel

How to package the PetaLinux project

It’s useful to be able to program the flash with our bitstream and Linux kernel so that it boots up automatically when we power up the board. To be able to do this, we need to package the PetaLinux project and generate a .mcs file. We don’t go through this in the video, but if you’re interested, here’s how to do it:

  • In the Linux command terminal, type:

petalinux-config- In the menu, enable the following option: Subsystem AUTO Hardware Settings->Advanced bootable images storage Settings- Set the flash partition sizes as follows:

Subsystem AUTO Hardware Settings->Flash Settings

fpga partition size 0x300000 boot partition size 0x100000 bootenv partition size 0x100000 kernel partition size 0xA40000- Build the PetaLinux project:

petalinux-build- Package the PetaLinux project:

petalinux-package --boot --force --fpga ../arty_base/arty_base.runs/impl_1/design_1_wrapper.bit --u-boot --kernel --flash-size 16 --flash-intf SPIx1

You’ll find the boot.mcs file under arty_petalinux/images/linux.

Try it yourself

If you want to run this project on your Arty board, just download the boot files that I’ve provided here: Arty PetaLinux boot files

JTAG instructions

In the compressed file, you’ll find a bitstream and .elf file (the PetaLinux kernel) that can be downloaded to your Arty via JTAG using the XMD tool. Launch XMD and type these commands:

  fpga -f design_1_wrapper.bit
  connect mb mdm
  dow image.elf

Flash instructions

Also in the compressed file, you’ll find a .mcs file that you can program into the Arty’s flash memory so that PetaLinux boots up every time you power up the board. To program the Arty’s flash memory:

  1. launch the Hardware Manager in Vivado
  2. make a connection with the FPGA
  3. add configuration memory device n25q128-3.3v-spi-x1_x2_x4
  4. program the configuration memory device with the .mcs file

Digilent has a good tutorial on this here: Programming the Arty using Quad SPI Flash

Make sure to open a UART terminal for a baud rate of 9600, so that you don’t miss the boot log. Also, remember to connect the Arty to your network router so that the IP address gets automatically assigned during the boot sequence.

See also