Score:2

Ch340 keeps disconnecting

bs flag

I recently bought a esp32 devkit with ch340 USB-UART bridge. After plugging it into the USB port of my Ubuntu 22.04 the serial port /dev/ttyUSB0 repeatedly connects and disconnects.

Also, I have tried this on Windows and Fedora where it worked as expected, so I think it might be a Ubuntu related issue.

dmesg output:

[ 662.091302] usb 1-2: new full-speed USB device number 117 using xhci_hcd
[ 662.253355] usb 1-2: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice=81.33
[ 662.253366] usb 1-2: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 662.253370] usb 1-2: Product: USB Serial
[ 662.258186] ch341 1-2:1.0: ch341-uart converter detected
[ 662.272620] usb 1-2: ch341-uart converter now attached to ttyUSB0
[ 665.739336] usb 1-2: USB disconnect, device number 117
[ 665.739737] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
[ 665.739770] ch341 1-2:1.0: device disconnected

tail -f /var/log/syslog shows two additional lines:

checking bus 1, device 125: "/sys/devices/pci0000:00/0000:00:08.1/0000:05:00.3/usb1/1-2"   
bus: 1, device: 125 was not an MTP device

I tried:

  • disabling autosuspend with udev rules as described in arch wiki (I'm not sure why this doesn't work)
  • disabling autosuspend by changing /sys/devices/*/power/level to on (the file is set back to auto after a few seconds)
  • updating to the latest kernel
  • debugging the driver with kprobe

Does anyone have an idea how to solve this? If I won't fix it I'll probably have to change distro, and I don't really have time to do it right now.

David avatar
cn flag
Certainly seems to be the driver.
Terrance avatar
id flag
`rmmod` will only remove the driver. If you want to stop that driver from loading you need to blacklist it as well. Add `blacklist ch341` to the `/etc/modprobe.d/blacklist.conf` file to stop the driver from reloading.
Macuilxochitl avatar
bs flag
Blacklisting doesn't help, new driver is loaded and used, but the device is still connecting and disconnecting
Terrance avatar
id flag
Try disabling all power saving features for USB. I never said that blacklisting will fix your issue, but it will stop the original ch341 driver from reloading is all since you claimed that driver reloaded within a few seconds of removing the module.
Macuilxochitl avatar
bs flag
Made an edit on disabling auto suspend
Terrance avatar
id flag
Not sure if what you followed would work with autosuspend on the USB. Some are claiming that this one is still working. https://askubuntu.com/a/1161074/231142 But, I see that you went to Fedora, so this is all moot now.
Score:1
cn flag

In my case the Ubuntu braille reader was hogging the port. This worked for me.

sudo apt remove brltty

After that I was able to see the device connect and stay connected. You won't have to run that command again.

Macuilxochitl avatar
bs flag
Thank you, but this doesn't work for me. Do you know if there's a way to check if any other program is using the same port?
Peter Chaula avatar
cn flag
If it was brltty the device wouldn't connect at all. I doubt the this would solve the problem.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.