element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
FPGA
  • Technologies
  • More
FPGA
Forum Vivado, Vitis and PetaLinux on Windows Sublayer for Linux (WSL2): attach and detach your USB debugger
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join FPGA to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 0 replies
  • Subscribers 550 subscribers
  • Views 1018 views
  • Users 0 members are here
  • xilinx
  • wsl
  • usb
  • vivado
  • wsl2
  • vitis
Related

Vivado, Vitis and PetaLinux on Windows Sublayer for Linux (WSL2): attach and detach your USB debugger

Jan Cumps
Jan Cumps 11 months ago

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:

image

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

image

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:

image

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:

image

That's it. Enjoy.

Why the need of the batch file? 

We need to achieve two things:

  • Run the usbipd command as Windows administrator, and
  • allow you to enter the Linux root / sudo password

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.

  • Sign in to reply
  • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube