A few weeks ago, we looked at how we could create and run a PetaLinux on the MicroBlaze (P1 + P2).

One of the key benefits of using an embedded OS, i.e. PetaLinux, is that it makes networking much simpler and we can connect to IoT frameworks such as IBM BlueMix, Adafruit.io and AWS services like Lambda.

Before we can work with these services, we first need to ensure our MicroBlaze PetaLinux build is correctly configured to support Ethernet.

The first stage is performed with Vivado and this ensures that all of the necessary IO needed to support the Ethernet Phy is in place. Within our Vivado design it is common to use the AXI Ethernet lite IP core.

This allows us to work with Phys which uses a Media Independent Interface (MII) and is controlled over a Management Data Input / Output (MDIO) Interface.

Carefully check the Phy reference clock needs

However, using this block alone may not be sufficient, the Phy may require additional reference clocks and resets. One commonly overlooked signal is the Phy reference clock. In the case of the example board we are using (Arty A7 100T) and its Phy, we need to ensure a 25 MHz reference clock is provided.

To support this in the design example, I enabled a third clock output on the clock wizard at 25 MHz. This output was assigned to the IO pin and the design and HDF file rebuilt.

Of course, rebuilding the HDF means we need to reapply this configuration to the PetaLinux project to ensure the updates to the hardware are reflected.

Updating the clock wizard

Once this is completed, in order to be able to use the Ethernet interface, we need to add in bindings into the device tree source. In PetaLinux, most of the device tree generation is handled automatically; however, we can make additions and customizations in the user meta layer. Under this layer we can modify the system-user.dsti which is compiled into the overall device tree blob when we build PetaLinux. You can find the system-user.dsti under the following path:

/project-spec/recipes-bsp/device-tree/files

To be able to work with Ethernet, we need to add in the MAC address, Phy Handle and the MDIO Address into the system-user.dsti.

Typically, we cannot tell the MDIO address from the Vivado design instead we must normally review the schematics to see how it was designed into the system.

The MAC address we obtain from the PetaLinux configuration, as shown below:

Petalinux MAC settings

When we create the system-user.dsti, we must use this same MAC address. If we do not, we will notice issues when PetaLinux boots and have no Ethernet functionality.

Once we have made these changes, we can rebuild the PetaLinux image using the command:

petalinux-build

With the build complete, we can download the FPGA and the Kernel image and start working with our new network capable MicroBlaze instantiation.

To confirm the image works correctly with Ethernet, we can log in over a serial port and run the command:

ifconfig

This will list the IP address and also the state of the Ethernet link.

If we want to prove we are connected to the external internet, we can ping an external IP address, for example adiuvoengineering.com.

Now that we are connected, we can start working with these IoT services. We will take at how we do that next week.

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.