|
| 1 | +--- |
| 2 | +title: RFSoC-PYNQ |
| 3 | +permalink: /rfsoc-pynq |
| 4 | +layout: default |
| 5 | +nav_order: 2 |
| 6 | +--- |
| 7 | + |
| 8 | +# RFSoC-PYNQ |
| 9 | +{: .no_toc } |
| 10 | + |
| 11 | +--- |
| 12 | +## Table of Contents |
| 13 | +{: .no_toc .text-delta } |
| 14 | +1. TOC |
| 15 | +{:toc} |
| 16 | +--- |
| 17 | + |
| 18 | +## Setting up PYNQ in RFSoC FPGA |
| 19 | + |
| 20 | +See the official [PYNQ documentation](https://www.rfsoc-pynq.io/) for detailed instructions and image download. |
| 21 | + |
| 22 | +## Internet Access on PYNQ |
| 23 | +Usually when connected using Ethernet, the PYNQ board will not have internet access. |
| 24 | +However, for package installation including [`RFSoC-MTS`](https://github.com/Xilinx/RFSoC-MTS), internet access is required. |
| 25 | + |
| 26 | +Here is a working method to enable internet access on PYNQ used by me. |
| 27 | + |
| 28 | +{: .callout .callout-warning } |
| 29 | +> Use at your own risk. Different systems and network environments may require different settings. |
| 30 | +
|
| 31 | +### Prerequisites |
| 32 | +- A computer with internet access (Wi-Fi in this case) using Linux (tested on Ubuntu 20.04) |
| 33 | +- Ethernet connection to the PYNQ board |
| 34 | +- PYNQ board IP assumes to be `192.168.2.99`, the default for PYNQ boards |
| 35 | + |
| 36 | +### Step 1: Configuration at Computer |
| 37 | +Set the computer Ethernet IP to be in the same subnet as the PYNQ board. |
| 38 | +We set the IPv4 to be the manual mode. |
| 39 | +In this case, we also want it to be the gateway for the PYNQ board, so it is `192.168.2.1`. |
| 40 | +The subnet mask is `255.255.255.0`, and the gateway is left blank. |
| 41 | +IPv6 will be disabled. |
| 42 | + |
| 43 | +Then, in a terminal, we setup the WiFi sharing. |
| 44 | +```bash |
| 45 | +sudo sysctl -w net.ipv4.ip_forward=1 |
| 46 | +``` |
| 47 | + |
| 48 | +Use `ip link` or `ifconfig` to find the WiFi and Ethernet interface names. |
| 49 | +Then run |
| 50 | + |
| 51 | +```bash |
| 52 | +# Define your interface names here |
| 53 | +export WAN=wlan0 # Your WiFi interface (Internet source) |
| 54 | +export LAN=eth0 # Your Ethernet interface (Connected to RFSoC) |
| 55 | + |
| 56 | +# Enable Network Address Translation (Masquerading) |
| 57 | +sudo iptables -t nat -A POSTROUTING -o $WAN -j MASQUERADE |
| 58 | + |
| 59 | +# Allow traffic forwarding between interfaces |
| 60 | +sudo iptables -A FORWARD -i $WAN -o $LAN -m state --state RELATED,ESTABLISHED -j ACCEPT |
| 61 | +sudo iptables -A FORWARD -i $LAN -o $WAN -j ACCEPT |
| 62 | +``` |
| 63 | + |
| 64 | +### Step 2: Configuration at PYNQ Board |
| 65 | + |
| 66 | +Configure the RFSoC gateway to the computer |
| 67 | +```bash |
| 68 | +sudo ip route add default via 192.168.2.1 |
| 69 | +``` |
| 70 | + |
| 71 | +Set DNS |
| 72 | +```bash |
| 73 | +echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf |
| 74 | +``` |
| 75 | + |
| 76 | +Now it should work. |
| 77 | + |
| 78 | +## Using VS Code for Jupyter Notebook |
| 79 | + |
| 80 | +The following procedures are tested by the author on ZCU208 with PYNQ image v3.0.1. |
| 81 | + |
| 82 | +### Setting up SSH |
| 83 | + |
| 84 | +First connect to SSH `root@192.168.2.99` with password `xilinx`, |
| 85 | +and then run the following command: [^for-vscode-ssh-config] |
| 86 | + |
| 87 | +```bash |
| 88 | +sudo chmod u+w /etc/ssh/sshd_config |
| 89 | +sudo echo "PermitRootLogin yes" >> /etc/ssh/sshd_config |
| 90 | +sudo service sshd restart |
| 91 | +``` |
| 92 | + |
| 93 | +In VS Code, connect to remote SSH: |
| 94 | + |
| 95 | +Username |
| 96 | +: `root@192.168.2.99` |
| 97 | + |
| 98 | +Password |
| 99 | +: `xilinx` |
| 100 | + |
| 101 | +Install the required extensions as needed. |
| 102 | +For Jupyter Notebook, select the kernel from existing kernels named `pynq-venv`. |
| 103 | + |
| 104 | +### Using GitHub Copilot |
| 105 | +GitHub Copilot may show the log-in failed error message. |
| 106 | +Use the following settings in `.vscode/settings.json`: [^vscode-github-copilot-fix] |
| 107 | + |
| 108 | +```json |
| 109 | +{ |
| 110 | + "remote.extensionKind": { |
| 111 | + "GitHub.copilot": [ |
| 112 | + "ui", |
| 113 | + ], |
| 114 | + "GitHub.copilot-chat": [ |
| 115 | + "ui", |
| 116 | + ], |
| 117 | + } |
| 118 | +} |
| 119 | +``` |
| 120 | + |
| 121 | +[^for-vscode-ssh-config]: Reference: [this discussion on PYNQ forum](https://discuss.pynq.io/t/microsofts-vs-code-for-c-c-python-development-on-xilinx-platforms/2031#example-1-vitis-ai-c-debug-4) |
| 122 | +[^vscode-github-copilot-fix]: Reference: [this discussion on GitHub](https://github.com/orgs/community/discussions/50328#discussioncomment-8238634) |
0 commit comments