You can run Vivado and Vitis on WSL2. One reason to do that, is that you can run the provided build scripts as is.
You 'll be able to recreate the source for the Pynq Base Vivado project, and Digilent's Vivado project for the Arty Z7 (and S7).
It 'll also allow you to build a PetaLinux image.
If you also want to program or debug your design from Vivado or Vitus on WSL2, you will find that it's not able to detect your board / debugger USB.
You will first have to hand over control of the USB port to WSL2. Follow instructions of Connecting USB devices to WSL to get the necessary commands set up in Windows, and how to use them.
Create Windows shortcuts to attach and detach your debugger to WSL2
assumption: you are able to attach and detach your USB debugger to WSL2 from an administrator Windows command line, as described in the instructions above.
First, create a batch file that can run the attach and detach instructions:
I called mine attachpynq.bat , and placed it in the C:\Xilinx folder
"C:\Program Files\usbipd-win\usbipd.exe" wsl %1 --busid %2
Then I created 2 Windows shortcuts, one for attach, one for detach:
I first created the attach one. I right-clicked in the folder where I wanted to create it, and selected Windows ShortCut.
Target: C:\Xilinx\attachpynq.bat attach 2-1 & pause
Start in: my home folder (it's not relevant in this scenario)
Advanced -> Run as administrator
Rename it (I use "attach PYNQ to WSL2").
Confirm and test it:
Start WSL2, if not running yet. You can do this by opening a WSL2 terminal.
When you execute the shortcut (double-click it), you'll first be prompted to run it as admin. Select Yes.
Then the script will ask you to enter the WSL2 root / sudo user's password.
If you manage to enter the right password, the USB port will be passe through to WSL2:
Now create a detach shortcut:
Copy the attach one. Rename it (I use "detach PYNQ to WSL2"). Right click, select Properties.
In the Target field, replace attach by detach.
Test, by executing the shortcut. The USB device should now disappear in the WSL2 /dev directory:
That's it. Enjoy.
Why the need of the batch file? We need to achieve two things:
Creating the shortcut is an easy way to execute the commands as admin. If I would not use a batch script and put all commands in the Target of the shortcut, it would not prompt for the password. When you put the commands in a batch file and call that from the shortcut, it waits. Windows experts may know a better way to handle this. Comment if you have an easier solution. |