The ZUBoard recently released by Avnet is a very exciting development, it provides developers with a ZU1 CG MPSoC. This device within the AMD Cost Optimised Portfolio provides developers with dual core Arm Cortex A53 processors, Dual Core R5 processors and 82K Logic Cells. The ZUBoard itself provides developers with High Speed interfacing which offer some SYZYGY compatibility, MikroE Click along with standard USB, Ethernet, USB UART/ JTAG along with 1GB of LPDDR4, and QSPI / SD Card for boot.
The Avnet GitHub has all of the necessary build scripts and files necessary to build both bare metal and petalinux distributions.
In this project we are going to look at how we can use the recently created PYNQ image for the ZUBoard.
What is PYNQ?PYNQ is a framework which allows us to use Python running on the Processing System to control programmable logic designs. PYNQ provides a range of IP and drivers which makes developing software to control the IP within the programmable logic (called overlays). PYNQ also includes several IP which ease interaction with the PYNQ drivers within the operating system.
PYNQ applications are developed over an Jupyter notebook server which runs on the PS processor cores.
This enables a very rapid development and PYNQ has grown from its original use to being used for prototyping applications. PYNQ is also excellent for test applications were the MPSoC forms part of the test equipment.
PYNQ on ZUBoardTo get started with the PYNQ on our ZUBoard we first need to download the PYNQ image for the board from PYNQ.IO
Once we have the image we need to burn it to a SD Card using Win32DiscImager or another application which can write ISO images to SD Cards.
While the image is writing to the SD Card the next thing to do is clone or download the PYNQ Repository from GitHub. We do this as we want to make use of some of the IP which is provided with the Repo.
With the PYNQ Repo downloaded we need to build the HLS IP. We can do this by changing directory to the boards / ip / hls and double click on the build_ip.bat
This will open Vitis HLS and build and generate all of the IP cores within the PYNQ directory. Making them available for use in our applications.
The final thing to do is to insert the SD card and set the boot switches on the ZUBoard to boot from the SD Card.
Connect the USB C Power, Ethernet Cable and USB UART cable and power on the board.
PYNQ OverlayOne of the great things about PYNQ is the creation of
Create a new Vivado project targeting the ZUBoard, once the project is open create a new block diagram and add in the MPSOC processing system
Run the board automation to configure the processing element for the ZUBoard configuration
The next step is to add in the Repository
Navigate to where you built the PYNQ IP and select that directory
This will detect several new IP cores
Add in the test pattern generator
Configure it for 2 pixels per clock
Add in a Video Direct Memory Access IP block
Configure it for a write channel only
Run the connection automation
This will result in a image like below
Add colour convert 2PPC and connect its AXI Stream output of the VTPG to the colour convert input
Run the connection automation to connect to the AXI lite network
Connect the clock and resets together on the colour convert block
Add in the pixel pack 2PPC IP Block
Run the block automation and connect the clocks together
the resultant block diagram should look s below
Connect the output of the colour convert to the input of the pixel pack.
Double click on the MPSOC to recustomise it on the PS-PL tab under interrupts enable the IRQ0
On the PS-PL interfaces enable the Slave HPC0
Connect all of the MPSOC clocks together
Connect the output of the Pixel Pack block to the VMDA AXIS S2MM interface, connect the clocks together also.
Connect the output of the VDMA to the MPSOC slave input
Add in the AXI Interrupt Controller
Run the connection automation
Connect the output of the interrupt controller to the MPSOC interrupt pin
Add in a concat block, and connect the interrupts from the VDMA and VTPG to the concat block inputs. Connect the output of the concat blocks to the interrupt controller.
Right click on the block diagram in the sources tab and select create HDL wrapper. Let Vivado manage it
Generate the Bit Stream
Connecting to the ZUBoardWith the ZUBoard powered up open a file browser and select map network drive. Enter the path \\pynq\xilinx and select connect using different credentials.
Enter Xilinx, Xilinx for the user name and password
This will show the file system of the PYNQ board
Under jupyter_notebooks create a new folder called TPG_overlay
Under this directory copy the Bitfile and HardWare Handoff file from the Vivado build.
rename them both have the name tpg.bit / hwh
In a web browser navigate to pynq:9090 this will open a log in page to which the password is Xilinx
Under here you will see the directory just created.
Select the tpg_overlay directory and create a new python3 file
In the new python file enter the following
import time
import numpy as np
from pynq import pl
from pynq import Overlay
from pynq.lib.video import *
import cv2
import matplotlib.pyplot as plt
ol = Overlay('/home/xilinx/jupyter_notebooks/tpg_overlay/tpg.bit')
pixel_in = ol.pixel_pack_2_0
pixel_in.bits_per_pixel = 24
colourspace_in = ol.color_convert_2_0
rgb2bgr = [0.0, 1.0, 0.0,
1.0, 0.0, 0.0,
0.0, 0.0, 1.0,
0.0, 0.0, 0.0]
colourspace_in.colorspace = rgb2bgr
cam_vdma = ol.axi_vdma_0
lines = 512
framemode = VideoMode(640, lines, 24)
cam_vdma.readchannel.mode = framemode
cam_vdma.readchannel.start()
tpg = ol.v_tpg_0
tpg.write(0x10,512)
tpg.write(0x18,640)
tpg.write(0x40,0)
tpg.write(0x30,0)
tpg.write(0x20,0xB)
tpg.write(0x00,0x81)
frame_camera = cam_vdma.readchannel.readframe()
frame_color=cv2.cvtColor(frame_camera,cv2.COLOR_BGR2RGB)
pixels = np.array(frame_color)
plt.imshow(pixels)
plt.show()
When we run this in our PYNQ system we should see an image of the test pattern
PYNQ is an excellent framework to develop MPSoC applications. This simple example has showed how we can get up and running with ZUBoard and PYNQ.
All source code can be found here https://github.com/ATaylorCEngFIET/PYNQ_ZUBoard
Comments