This is a guide on how I get my Sonoff Zigbee 3.0 Dongle (CP210x) working through WSL2 using a custom kernel.
Guide
-
In a WSL2 instance install the dependencies for building the custom kernel.
sudo apt install build-essential flex bison libssl-dev libelf-dev dwarves libncurses-dev
-
Clone the WSL2 Linux Kernel (–depth 1 gets only the latest commit)
git clone https://github.com/microsoft/WSL2-Linux-Kernel.git --depth 1
-
Navigate to the WSL2-Linux-Kernel folder
cd WSL2-Linux-Kernel
-
Edit the kernel build configuration
make menuconfig KCONFIG_CONFIG=Microsoft/config-wsl
-
Go to
Device Drivers -> USB Support -> USB Serial Converter support
and enable the drivers you need. (For the Sonoff Dongle, CP210x is required. Other drivers may be used for different devices). -
To make this baked into the kernel, press space twice so that
<*>
is displayed instead of<M>
-
Save and Exit (Press S once and then ESC until exit menu is shown)
-
Build the kernel (
-4j
or-8j
to speed this process up)
make KCONFIG_CONFIG=Microsoft/config-wsl -4j
-
Copy kernel to Windows
cp arch/x86/boot/bzImage /mnt/c/Users/<your-user-name-here>/wsl_kernel
-
Create a file in your Windows user directory called .wslconfig and add this:
[wsl2]
kernel = C:\\Users\\<your-user-name-here>\\wsl_kernel
You can now restart your WSL2 instance and connect the device by USB like normal, using this method
Thanks to Leo Bound for all of this information