6

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.

karel
  • 122,292
  • 133
  • 301
  • 332
realdebil
  • 61
  • 1
  • 3

2 Answers2

7

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.

1

Had the same issue on Manjaro (5.13.19-2-MANJARO) with an ESP32 (one with a CH340). Whenever I would connect a second ESP32 (even if it was one with a cp2102) the CH340 one would start disconnecting and reconnecting every few seconds. After also trying to disable autosuspend with udev rules (which seemed to have no effect at all). I found this post on r/archlinux where someone suggested to use TLP to disable usb autosuspend.

In my case TLP was already installed so changing the config in /etc/tlp.conf to include the CH340 usb device info (1a86 being vendorId and 7523 productId):

USB_DENYLIST="1a86:7523"

and enabling it via

systemctl enable tlp.service

did the trick for me.

Not sure if the same steps will work on Ubuntu but since I couldn't find another solution I figured I'd share it.

scsere
  • 111