PYNQ on Corazon-AI: AI applications for all

Introduction

The Corazon-AI board from iWave is very interesting: it has everything you need for an embedded vision application. In the AI world, the time-to-market parameter is very important for a winning application; also currently there is fierce competition, also against the real competitor of the FPGA, the GPU. So we choose to integrate on the Corazon-AI the best ally: the PYNQ framework. PYNQ gives to you the right instruments to create a product-ready application, Python based. You will find a simple tutorial for building the PYNQ framework for the Corazon-AI platform, also you will find the complete image in the final section.

The Corazon-AI board

Corazon-AI is an embedded EdgeAI platform from iWave company with a Zynq Ultrascale+ MPSoC device. It supports Vitis AI and has a compact form factor (100mm x 72mm). This platform is coupled with multiple high-speed connectivity options, such as:

  • Dual GbE,
  • Wi-Fi,
  • BT 5.0,
  • 4G network support via an M.2 expansion slot,
  • Dual CAN,
  • USB 3.0.

With the provision to connect 8 IP cameras, Corazon-AI becomes an ideal fit for EdgeAI Gateways bringing intelligence to the edge.

CorazonAI

You can find every detail following this link.

Due to the fact that supports completely the Vitis AI framework for Machine Learning application, it is a perfect candidate for a product-ready application. Finally, this board is certification-ready (e.g. for CE certification), also for industrial-grade, shall we continue?

The PYNQ integration

Ok, now we have the board for our embedded vision application, but how can I use it in a simplified way? You need to release your application as faster as possible, also you don’t want to create an entire custom application for this specific platform. The solution is the PYNQ framework.

PYNQ is an open-source project from Xilinx that makes it easier to use Xilinx platforms. Using the Python language and libraries (without losing performance!), designers can exploit the benefits of programmable logic and microprocessors to build more capable and exciting electronic systems. PYNQ can be used with ZynqZynq UltraScale+Zynq RFSoCAlveo accelerator boards, and AWS-F1 to create high-performance applications.

You can find all the source code and tutorials on Github page. Also on our Github page you can find some examples and applications that run on the PYNQ framework. PYNQ also add to your image the “apt” package manager, so you can install in a Ubuntu style any packages you want!

We really love PYNQ 😊 .

The main feature of PYNQ is that is easily ported on a custom platform (like Corazon-AI). In particular, you need these things:

  • a Petalinux 2020.1 BSP file or XSA file of your platform (the iWave team will provide you the XSA file once you purchase the board)
  • a Petalinux 2020.1 toolchain installed on your PC
  • a complete Vitis 2020.1 toolchain installed on your PC
  • a local repository of PYNQ with local branch set to the right version of PYNQ (if you want to build PYNQ 2.6, you need to switch the branch to “image_v2.6”)

Cookbook for PYNQ

First of all, we need to create a custom board template directory, that usually is placed in the PYNQ project root in the directory “custom_boards” (if it is not present, simply create it). We will name it “CorazonAI”.
PYNQ directory

PYNQ Corazon AI

If you see, there are some specific files:

  • CorazonAI.spec: it describes the structure of the project (will go deeper on it soon)
  • CorazonAI.bsp: the generated bsp file from a petalinux build
  • petalinux: a local petalinux project
  • base: it contains the base bitstream of PYNQ, but is not interesting now, we can assume that is the same as ZCU104 (we will not use it, so it is not important)

The CorazonAI.spec file contains those lines:

ARCH_CorazonAI := aarch64
BSP_CorazonAI := CorazonAI.bsp
BITSTREAM_CorazonAI := base/base.bit

STAGE4_PACKAGES_CorazonAI := pynq ethernet

If you notice, every line reports the “_CorazonAI” string, which might be the same as the project name (in our case “CorazonAI”).

The first line represents the architecture of the board (arm/aarch64), the second line represents the name of the bsp that will be used for the project, the third line represents the file name of the “base” bitstream (but is not useful for our purposes) and the last line represents the additional steps for the last stage of the building of PYNQ (if you need to add additional packages, you can specify them on this line).

So, after the definition of the “spec” file, let’s create a petalinux project:

petalinux-create -t project -n petalinux --template zynqMP
cd petalinux
petalinux-config --get-hw-description ../top_mod.xsa # iWave provide to us the xsa file with this name
petalinux-build
petalinux-package --bsp -p . --output ../CorazonAI.bsp

After some minutes, you will obtain the BSP file in the parent directory.

Now we are ready to build the SD Card image of PYNQ! So, go to the “sdcard” directory of your PYNQ local repository and run this command:

make all BOARDDIR=<absolute path of local PYNQ directory>/PYNQ/custom_boards BOARDS="CorazonAI"

After an hour or less, you will obtain the SD Card in the “output” directory. You can flash on an SD Card with Balena Etcher software as every SD Card image of PYNQ.

 

Test PYNQ on Corazon-AI

Now we are ready to test a simple application (sum between 2 arrays of 256 integers) on the PYNQ image.

So, connect with the browser to the Jupyter Notebook manager of the Corazon-AI and you can test it as follow:

Jupyter Notebook Corazon-AI 1

Jupyter Notebook Corazon-AI 2

Jupyter Notebook Corazon-AI 3

ok, we can say that PYNQ works on Corazon-AI!

You can download the complete image from this link:
https://s3.eu-central-1.wasabisys.com/pynq-images/CORAZON_AI_PYNQ.zip

So, What's next?

PYNQ offers great advantages, also for the big amount of examples that you can find on the official site: http://pynq.io/

The best solution that you might be interested is the following:  https://github.com/Xilinx/DPU-PYNQ

With PYNQ DPU, you have a perfect wrapper for Python to interface with FPGA DPU. Due to the fact that the best strategy to represent the arrays, matrixes, and tensors is the library NumPy, you can use an FPGA…like a GPU, so the enemy can surrender!

Also, PYNQ is perfect to interface easily with our product MuseBox, for easy integration for commercial software, so we think that you definitely need to test PYNQ on your custom board.