'usbserial not recognizing any device after platformio flash fails
I have a very strange phenomenon with usbserial driver. I have a project based on platformio that is flashed to a device using usbserial via /dev/ttyUSBx port.
When trying to flash the device while the port is already busy (connected with another piece of software) platformio cancels with an error. At this point the nightmare starts. My Linux (Ubuntu 21.04) is not recognizing any usbserial device anymore.
First I tried to unplug the device and plug it in again without any success. Then I restarted Linux and everything worked as expected again. I am not happy with this solution and don't want to restart my machine every time this happens, so I tried to find another solution.
Afaik all this is driven by the Linux usbserial driver, so I tried to restart it.
❯ lsmod | grep usbserial
usbserial 53248 2 ftdi_sio,cp210x
❯ sudo rmmod cp210x
❯ sudo rmmod ftdi_sio
❯ sudo rmmod usbserial
❯ lsmod | grep usbserial
❯ sudo modprobe usbserial
❯ lsmod | grep usbserial
usbserial 53248 0
As you can see I have two usbserial devices connected and both are just not recognized anymore. restarting usbserial had not the expected effect and now I am running out of ideas. Normally the device drivers (ftdi_sio,cp210x) are loaded automatically when connected and appear as /dev/ttyUSBx devices, but they are just ignored after platformio failure. They even don't appear in /sys as they do normally.
❯ ll /sys/class/tty/ttyUSB*
lrwxrwxrwx 1 root root 0 Mär 30 09:58 /sys/class/tty/ttyUSB0 -> ../../devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.3/1-1.3:1.0/ttyUSB0/tty/ttyUSB0
lrwxrwxrwx 1 root root 0 Mär 30 09:58 /sys/class/tty/ttyUSB1 -> ../../devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.1/1-1.1.1/1-1.1.1:1.0/ttyUSB1/tty/ttyUSB1
I couldn't find anything in the web, so I hope someone can point me in the right direction. Any suggestion is appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
