There is a nice article and video explaining how to connect USB serial to Linux in WSL2.
Just few details are missing. Here is the full list of steps necessary to flash ESP32 with FTDI from WSL2:
- Install Windows 11, open Windows Update – join Windows Insider Program (Beta channel) – install updates, reboot machine
- Windows Update – Advanced Options – check the option “Receive updates for other Microsoft products” – Back – Check for updates
- Reboot or shutdown WSL2 images
- start a new WSL2 image e.g. with Ubuntu 20 LTS, check that you have kernel 5.10: uname -a. It does not work on 4.x kernel from normal WSL2
- install https://github.com/dorssel/usbipd-win/releases on Windows
- in Linux – sudo apt install linux-tools-5.4.0-77-generic hwdata
- in Linux – visudo
- in Linux – prepend path Defaults secure_path=”/usr/lib/linux-tools/5.4.0-77-generic:
- connect ESP device with FTDI in Windows PowerShell (administrator) type: usbipd wsl list
- search for 5-3 USB Serial Converter A, USB Serial Converter B Not attached
- type in Windows: usbipd wsl attach -b 5-3 -d Ubuntu
- type in Linux:cd examples/get-started/blink; idf.py build flash monitor
Result:
I (263) example: Example configured to blink addressable LED! I (263) example: Turning the LED OFF! I (1273) example: Turning the LED ON!