Most serial port issues are caused by the serial port being inaccessible.
Here are two really quick checks you can make before jumping into anything more technical:
- That it’s plugged in properly with the computer-side and Pico-side both being fully pushed in all the way.
- That another piece of software isn’t already using the serial port. Remember, only one piece of software can use your Pico at a time. So if you’re using Thonny and it’s connected to the Pico, VS Code won’t be able to connect.
There might be a permissions issue getting access to the serial port. To fix this, run:
sudo usermod -a -G dialout $USER
Wrong COM port or device?
If you note that Pico-Go is choosing the wrong COM port on Windows or the wrong device in macOS or Linux, you can set the correct device manually in your Global Settings file.
Ctrl+Shift+G on Windows or Linux or
Cmd+Shift+G on a Mac and change your settings as required, for example:
"auto_connect": false, "manual_com_device": "COM4",
or on a Mac:
"auto_connect": false, "manual_com_device": "/dev/tty.usbmodem0000000000002",
Other Quick Fixes
There are two things you can restart: your computer and the Pico.
Try the Pico first: disconnect the USB cable so it loses all power and then plug it in again.
If that fails, try a reboot of your computer.
No, really, try rebooting. I see a lot of experienced developers raise bugs only to close them once they’ve actually rebooted.
More Detailed Investigation
Follow these instructions to diagnose which process is using the COM port assigned to your Pico.
macOS and Linux
To establish which process is holding on to your serial port, you can try this command:
lsof | grep tty
This should return something like this:
Code\x20- 5777 chris 39u CHR 9,6 0t266 3901 /dev/tty.usbmodem0000000000001
In this example,
5777 is the process ID for what’s using
/dev/tty.usbmodem0000000000001. We can then use this command to find out what that process is:
ps -ax | grep 5777
This returns output as follows:
5777 ?? 0:04.20 /Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Code - Insiders Helper (Renderer).app/Contents/MacOS/Code - Insiders Helper (Renderer) --inspect-port=0 /Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/bootstrap-fork --type=extensionHost
We can see from this output from a Mac that
Visual Studio Code - Insiders.app is using the serial port. We can then try and establish whether this is another zombie instance of VS Code that’s holding on to the serial port and kill the process off, if necessary.