-
-
Notifications
You must be signed in to change notification settings - Fork 206
Using WSL2
Daniel Kampert edited this page Oct 21, 2023
·
1 revision
This section is highly experimental and not fully supported.
You can use this approach when you want to use native posix support for GUI development on a Windows machine with Visual Studio Code. WSL2 doesn´t support Bluetooth HCI yet, so it´s not possible to use Bluetooth during the emulation. Also WSL2 isn´t official supported by the Zephyr project.
- Windows 11
- Version: 10.0.22621
- Ubuntu
- Version: 22.04 LTS
- WSL
- WSL-Version: 1.2.5.0
- Kernelversion: 5.15.90.1
- WSLg-Version: 1.0.51
- MSRDC-Version: 1.2.3770
- Direct3D-Version: 1.608.2-61064218
- DXCore-Version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
- Windows-Version: 10.0.22621.2215
- Update Windows to the latest version
- Enable the
Windows-Subsystem for Linux
option and reboot the system - Install the latest version of usbipd-win
- Open an administrator PowerShell
- Update WSL by executing
wsl --update
- Install Ubuntu by executing
wsl --install -d Ubuntu
- Open an administrator PowerShell
- Get the path of the
.vhdx
file
(Get-ChildItem -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss | Where-Object { $_.GetValue("DistributionName") -eq 'Ubuntu' }).GetValue("BasePath") + "\ext4.vhdx"
- Execute
wsl --shutdown
- Execute
diskpart
- Execute
Select vdisk file="<Path>"
- Execute
expand vdisk maximum=<sizeInMegaBytes>
- Execute
exit
- Start Ubuntu and execute
sudo resize2fs /dev/sdb <sizeInMegabytes>M
resize2fs 1.44.1 (24-Mar-2021)
Filesystem at /dev/sdb is mounted on /; on-line resizing required
old_desc_blocks = 32, new_desc_blocks = 38
The filesystem on /dev/sdb is now 78643200 (4k) blocks long.
- Start Ubuntu
- Switch from
dash
tobash
by executingsudo dpkg-reconfigure dash
- Create locales by executing
sudo localedef -i en_US -f UTF-8 en_US.UTF-8
- Install the dependencies for Zephyr
- Open an administrator shell in Windows
- List all USB devices by executing
usbipd wsl list
BUSID VID:PID DEVICE STATE
BUSID VID:PID DEVICE STATE
1-6 8087:0029 Intel(R) Wireless Bluetooth(R) Not attached
2-6 0d8c:0012 KLIM PUMA, USB-Eingabegerät Not attached
3-8 04e8:61f5 Per USB angeschlossenes SCSI (UAS)-Massenspeichergerät Not attached
4-3 0b05:18f3 AURA LED Controller, USB-Eingabegerät Not attached
6-2 04d9:a119 USB-Eingabegerät Not attached
8-1 1038:1202 USB-Eingabegerät, SteelSeries Apex Gaming Keyboard, Steel... Not attached
12-1 1366:0105 JLink CDC UART Port (COM22), J-Link driver Not attached
12-4 03eb:2140 USB-Eingabegerät, JTAGICE3 Data Gateway Not attached
- Search for the BUS ID of the target device (here
12-1
) - Connect the device by executing
usbipd wsl attach --busid <busid>
NOTE: Use the command
sudo update-alternatives --install /usr/local/bin/usbip usbip $(command -v ls /usr/lib/linux-tools/*/usbip | tail -n1) 20
inside of the WSL OS when the errorusbipd: error: WSL 'usbip' client not correctly installed. See https://github.com/dorssel/usbipd-win/wiki/WSL-support for the latest instructions.
appears.
- Start Visual Studio Code
- Install the WSL Extension
- Open the command palette and type
WSL: Connect to WSL
- Install the nRF Toolchain Extensions
- Checkout the ZSWatch repository and open it in Visual Studio Code