CH340 Serial device doesn't appear in /dev/ (WSL)
So as of writing this, the reason for the lack of support for USB serial devices is due to their modules not being included in the WSL kernel.
You can compile your own WSL kernel with the modules by doing the following:
-
You may need these dependencies:
sudo apt install build-essential flex bison libssl-dev libelf-dev dwarves libncurses-dev
-
Clone the WSL2 repo with:
git clone https://github.com/microsoft/WSL2-Linux-Kernel.git
-
Change directory into the WSL2-Linux-Kernel folder:
cd WSL2-Linux-Kernel
-
Modify the kernel config by running
make menuconfig KCONFIG_CONFIG=Microsoft/config-wsl
. -
Go to
Device Drivers -> USB Support -> USB Serial Converter support
then enable your drivers in here.- The CP210x family are also common on microcontroller dev boards.
- You probably want these baked into the kernel so press
y
orspace
twice to make sure they are enabled with<*>
rather than<M>
.
Then save and exit menuconfig and overwrite config-wsl.
- You probably shouldn't use the following struck through points but they are an alternative to the previous two -
3. Modify the config-wsl file: nano Microsoft/config-wsl
(Or use your editor of choice).
Go to line 2409 (shift+_ then 2409 in nano) and replace # CONFIG_USB_SERIAL_CH341 is not set
with CONFIG_USB_SERIAL_CH341=y
- You may want to do the same for CONFIG_USB_SERIAL_CP210X
- another common serial-usb adapter.
-
Close your text editor and save (
ctrl + x
theny
thenenter
with nano). -
Build the kernel using the WSL2 kernel configuration:
make KCONFIG_CONFIG=Microsoft/config-wsl
- This can take a while - You can speed this up with the -j argument but make sure to specify a value e.g. -j4 -
Copy the compiled kernel to your Windows user directory:
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 paste this into it:
[wsl2]
kernel = C:\\Users\\<your-user-name-here>\\wsl_kernel
-
Shut down WSL with
wsl --shutdown
in a Windows command prompt. -
Open your WSL terminal and now you should be able to connect USB serial devices as outlined here.
And hopefully everything should work! (Tested on Win10 and Win11 with Ubuntu WSL2 distro)