32blit-tools icon indicating copy to clipboard operation
32blit-tools copied to clipboard

Serial port detection fails on WSL

Open WyvernSpite opened this issue 4 years ago • 3 comments

I am using WSL following the setup guide here: https://github.com/32blit/32blit-sdk/blob/master/docs/Windows-WSL.md

While following the instructions and troubleshooting section of this page: https://github.com/32blit/32blit-sdk/blob/master/docs/32blit.md#flasher-cant-find-32blit-port

I was unable to determine how to find which port to provide to successfully push a blit to the device

Thanks to ali1234 on the discord I was finally able to manually set the port. They asked me to include the following:

python3 -m serial.tools.list_ports -v

all results return

desc: n/a
hwid: n/a

And finally:

192 ports found

WyvernSpite avatar Nov 15 '21 03:11 WyvernSpite

It seems like pyserial isn't able to get the vid and pid of the serial devices when run within WSL. This causes autodetection to fail. We can report this upstream but I suspect they will be unable to fix it unless Microsoft improves their serial port wrapper. So we should document this in the SDK docs. We could perhaps also make 32blit tool print a more helpful error if detection fails. Maybe try to detect if it is being run in WSL?

ali1234 avatar Nov 15 '21 03:11 ali1234

WSL1 just forwards COMx -> /dev/ttySx as a raw serial port, there's no USB forwarding so no USB ids. WSL2 is somehow worse than WSL1, it doesn't even forward the serial ports...

(It's apparently possible to forward USB devices in WSL2+Win11 though: https://devblogs.microsoft.com/commandline/connecting-usb-devices-to-wsl/)

Daft-Freak avatar Nov 15 '21 11:11 Daft-Freak

You can install Python and the 32blit tools directly in Windows and run it from there IIRC.

This is one of the many reasons I ditched WSL for Linux.

IIRC there were ways to detect running in WSL via /proc/version or uname -a which could probably help direct users.

Gadgetoid avatar Nov 16 '21 13:11 Gadgetoid