# Board Setup

Xilinx has a documentation site that explains in detail how to setup the PYNQ-Z2 board properly. For simplicity I will go through only the necessary procedures so we can make the YOLO application work. For more details you can consult the [documentation](https://pynq.readthedocs.io/en/v2.3/getting_started/pynq_z2_setup.html).



## Preparation

***

As in the official tutorial, we are going to connect the desired cables to the board and set the jumpers correctly. Follow the numeric procedures as described on the image:

<figure><img src="https://2477548334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjW7iX6UPM2ifyvOJm6AX%2Fuploads%2FZ9BcOs44Vca5mzuNauNI%2Fimage.png?alt=media&#x26;token=181df180-5b7b-4526-8e7a-1c75a0368828" alt=""><figcaption><p>PYNQ-Z2 Setup</p></figcaption></figure>

1. Set the Boot jumper to the _SD_ position. This will make the board load the Operating System on the micro SD card;
2. Set the Power jumper to _REG_, so the board will receive power from the power regulator and not the USB cable;
3. Insert the Micro SD card with the custom image (the one we flashed with the DPU). Remember to insert it from the back as described on the image.
4. Connect the micro USB cable between your Host computer and the board.
5. Connect the Ethernet cable (RJ45) between the Laptop and the board. Don't forget to use the adapter if your computer doesn't have the RJ45 port;
6. Connect the power adapter's coaxial port on the PYNQ-Z2 to give it the necessary power;
7. Turn on the PYNQ-Z2 and the boot sequence should correspond to a red LED turning immediately on representing that the board has power. Then the Yellow/ Green LED called _Done_ will turn on showing that the Zynq service is ready.





## USB connection

***

A USB link to the board can be used to supply power or to control the board. To establish a USB connection between the PYNQ-Z2 and the host computer we can use an application like Putty. You can download it on the [official website](https://www.putty.org/) as described below.

<figure><img src="https://2477548334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjW7iX6UPM2ifyvOJm6AX%2Fuploads%2FWKJ2gCHf49B6mlPCdumL%2Frecord-000014-online-video-cuttercom_QPNgX5E8.gif?alt=media&#x26;token=3f2f4c1e-63c8-42d8-9d8e-fc4c726f6162" alt=""><figcaption><p>Putty download</p></figcaption></figure>

Before launching _Putty_, we have to see which port corresponds to the PYNQ-Z2. This is possible by going to the **Device Manager** and **COM and LPT Ports**. When you turn on the PYNQ-Z2 there should appear a new port there described as something similar to COM4.

Then we can launch _Putty_ by typing on the search bar it's name. First we need to setup the communication to **Serial**, then write the COM port according to the one you saw at the Device Manager. Next, on the **Speed** domain you write 115200 which is the Baud Rate of the data transmission. This steps are described on the image bellow:

<figure><img src="https://2477548334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjW7iX6UPM2ifyvOJm6AX%2Fuploads%2FFAUrHR00WYd1NIQUNtkW%2Fimage.png?alt=media&#x26;token=cb729796-2531-4416-92b4-243f3c942d34" alt=""><figcaption><p>Serial communication</p></figcaption></figure>



After this, a Terminal will appear and many information's regarding the Boot sequence of the PYNQ-Z2 custom image will be displayed. After that is complete, you will be asked to log in. These are the log in information's:

* **Login**: root
* **Password**: root

Now let's give the board a IP address so we can establish a SSH communication:

```
ifconfig eth0 192.168.2.99
```

On official SD card images for the PYNQ-Z2 the default IP address of the board is 192.268.2.99 and so we established the same address for simplicity. If you were to connect the PYNQ-Z2 directly to the Internet switch on your home the IP address would be the one corresponding to the port on the device.&#x20;





## Network connection

***

Now we want to connect the board to the host computer via SSH. This is done with the RJ45 cable commonly known as Ethernet cable. Remember to use the adapter RJ45 to USB if you don't have the port on your computer. In alternative, you could connect the board to your home switch but I can't confirm if it works with our custom SD card image.

The PYNQ-Z2 already has an IP address so now we need to assign a static address to the host computer on the same range so both are connected. To do this you first go to Control Panel and then Network and Internet and after that go to the Network and Sharing Center menu. Now you want to select the Ethernet connection and not the wireless connection you probably have. This can be seen on the next image:

<figure><img src="https://2477548334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjW7iX6UPM2ifyvOJm6AX%2Fuploads%2FnbLk8izw1Cu1AuH29SLm%2Fimage.png?alt=media&#x26;token=248d2a9b-83fb-4e7d-9137-60c2c849d375" alt="" width="563"><figcaption><p>Network and Sharing Center</p></figcaption></figure>

Now we need to set the Network Card of the computer with an IP on the same range as the one we gave to the PYNQ-Z2. The following image describes the steps to do exactly that. Remember that you can assign an IP between 192.168.2.1 and 192.168.2.98 for this to work. After the configuration you have to click "OK" to save the configuration. After this there will be a SSH connection between your computer and the board.

<figure><img src="https://2477548334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjW7iX6UPM2ifyvOJm6AX%2Fuploads%2Fw1Dot5rcsgQo2yUprcGo%2Fimage.png?alt=media&#x26;token=96142404-be44-460f-8e9a-3e73ba4608af" alt=""><figcaption><p>Static IP setup</p></figcaption></figure>

{% hint style="info" %}
The configurations are in Portuguese but you should be able to do it because the presentation is the same.
{% endhint %}

To confirm the Network Connection we can use the PING protocol to send packets to the board's IP address. If the connection is available, the PYNQ-Z2 must confirm the reception of the packets. You can confirm this opening the Command line on Windows (CMD) and writing "ping 192.168.2.99". A successful communication should result on a output like this:

<figure><img src="https://2477548334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjW7iX6UPM2ifyvOJm6AX%2Fuploads%2FaEGMOPuzPhyTOfKB4rVN%2Fimage.png?alt=media&#x26;token=c2667baa-c86b-445c-a120-2e6bf176807a" alt="" width="563"><figcaption><p>PÝNQ-Z2 ping</p></figcaption></figure>





## X-11 connection

***

Now that there is a safe network connection with the board, we can have total control over it using the computer. However, the Terminal interface can be a bit confusing and not intuitive for inexperienced users so we will implement a Graphical interface Network protocol (GUI - Graphical User Interface). This protocol is named X11 or X Window System and it allows the development and management of graphical applications on a remote server based on UNIX Operating System using the host computer. In other words, X11 will allow a graphical interface of the PYNQ-Z2 OS and will make it easier to create Windows and interfaces.

{% embed url="https://download.mobatek.net/2332023092000531/MobaXterm_Installer_v23.3.zip" %}
MobaXterm download link
{% endembed %}

The next image demonstrates how you can execute a X11 connection with the PYNQ-Z2 board.

<figure><img src="https://2477548334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjW7iX6UPM2ifyvOJm6AX%2Fuploads%2FDDSE23BTAQ8jseutJW1x%2Fimage.png?alt=media&#x26;token=0e066ea1-08bb-4178-a8ab-221ff1162fda" alt=""><figcaption><p>X11 connection</p></figcaption></figure>

After this you will have to login on the MobaXterm Terminal. Remember that the username is "root" and the password is "root".

{% hint style="danger" %}
The first time you put the password it will say it is wrong. You have to write the password a second time and it will work now.
{% endhint %}

After the login, the first thing to do is to activate the DNNDK libraries so that later the interaction between the API and the DPU is possible. You can do it as described on the next image.

<figure><img src="https://2477548334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjW7iX6UPM2ifyvOJm6AX%2Fuploads%2FLQUqpLyiTDXn5iwS2YxC%2Fimage.png?alt=media&#x26;token=ad9db576-3bf5-4058-a858-66e74f03e995" alt=""><figcaption><p>Activate DNNDK libraries</p></figcaption></figure>

```
cd zynq7020_dnndk_v3.1
./install.sh
```

Now everything is set to execute the YOLO on the PYNQ-Z2 board. It's almost there!
