Contents

Issue with CH340 Driver in Linux

1 Driver Issue

I just got an “ESP8266 D1 mini Dev Broad” by a friend of mine, and tried to play around. If you are not familiar, it is an MCU by Espressif company, enhanced by extra features to make it a good dev board.

This dev board is really easy to use (as other Espressif products), specially because of Micro USB (or USB-C) port on it. So you can just connect it to your computer and flash the MCU. Attaching a USB port was possible as dev board has a CH340 USB-to-UART chip. The chip is responsible for converting USB to Serial communication.

Most Linux distributions (such as Ubuntu) already have the CH340 driver installed. You can check it like:

1
2
3
❯ lsmod | grep ch34
ch341                  24576  0
usbserial              57344  1 ch341

I connected the board to computer, selected correct board in Arduino IDE, but then noticed “Port” option is grayed out in the IDE (Tools menu). This means device is not connected or not accessible. Quick check showed that there’s no USB device:

1
2
❯ ls /dev/ttyUSB*
zsh: no matches found: /dev/ttyUSB*

but at least dmesg says USB was there but disconnected!

1
2
3
4
❯ sudo dmesg| grep ch34
[12988.441725] usb 1-2: ch341-uart converter now attached to ttyUSB0
[13061.347165] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
[13061.347235] ch341 1-2:1.0: device disconnected

More investigations in dmesg shows kind of conflict by brltty daemon. Easily you can remove it if you don’t use it:

1
❯ sudo apt remove brltty

and if we connect the board again, and check dmesg, no disconnect has logged:

1
2
3
❯ sudo dmesg| grep ch34
[23964.629757] ch341 1-2:1.0: ch341-uart converter detected
[23964.630183] usb 1-2: ch341-uart converter now attached to ttyUSB0

and USB device is there:

1
2
❯ ls -l /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 0 Feb 27 21:06 /dev/ttyUSB0

Now you can select /dev/ttyUSB0 in Arduino IDE Port option and flash the MCU.

2 Power Consumption

Unstable USB connection, also could be from power consumption (specially if you connect to WiFi in your program). Note that when you’re programming MCU, it’s better to disconnect it from other circuit parts (e.g. sensors, display, etc) and connect it standalone to USB cable. Power that provided with USB cable is not enough to handle whole circuit. Other option is using a “data only” USB cable (voltage wires are disconnected in this type of cables) for programming MCU, while it’s connected to a separate power supplier.

Enjoy hacking!