How to stop brltty from claiming your USB UART interface on Linux
Today I wanted to program an ESP32 development board, the ESP-Pico-Kit v4, but when I connected it to my computer's USB port, the serial connection didn't appear in Linux. Suspecting a hardware issue, I tried another ESP32 board, the ESP32-DevKitC v4, but this didn't appear either, so then I tried another one, a NodeMCU ESP8266 board, which had the same problem. Time to investigate...
The dmesg
output looked suspicious:
[14965.786079] usb 1-1: new full-speed USB device number 5 using xhci_hcd [14965.939902] usb 1-1: New USB device found, idVendor=10c4, idProduct=ea60, bcdDevice= 1.00 [14965.939915] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [14965.939920] usb 1-1: Product: CP2102 USB to UART Bridge Controller [14965.939925] usb 1-1: Manufacturer: Silicon Labs [14965.939929] usb 1-1: SerialNumber: 0001 [14966.023629] usbcore: registered new interface driver usbserial_generic [14966.023646] usbserial: USB Serial support registered for generic [14966.026835] usbcore: registered new interface driver cp210x [14966.026849] usbserial: USB Serial support registered for cp210x [14966.026881] cp210x 1-1:1.0: cp210x converter detected [14966.031460] usb 1-1: cp210x converter now attached to ttyUSB0 [14966.090714] input: PC Speaker as /devices/platform/pcspkr/input/input18 [14966.613388] input: BRLTTY 6.4 Linux Screen Driver Keyboard as /devices/virtual/input/input19 [14966.752131] usb 1-1: usbfs: interface 0 claimed by cp210x while 'brltty' sets config #1 [14966.753382] cp210x ttyUSB0: cp210x converter now disconnected from ttyUSB0 [14966.754671] cp210x 1-1:1.0: device disconnected
So the ESP32 board, with a Silicon Labs, CP2102 USB to UART controller chip, was recognized, and it was attached to the /dev/ttyUSB0
device, as it should normally do. But then suddenly the brltty
command intervened and disconnected the serial device.
I looked up what brltty is doing, and apparently this is a system daemon that provides access to the console for a blind person using a braille display. When looking into the contents of the package on my Ubuntu 22.04 system (with dpkg -L brltty
), I saw a udev rules file, so I grepped for the product ID of my USB device in the file:
$ grep ea60 /lib/udev/rules.d/85-brltty.rules ENV{PRODUCT}=="10c4/ea60/*", ATTRS{manufacturer}=="Silicon Labs", ENV{BRLTTY_BRAILLE_DRIVER}="sk", GOTO="brltty_usb_run"
Looking at the context, this file shows:
# Device: 10C4:EA60 # Generic Identifier # Vendor: Cygnal Integrated Products, Inc. # Product: CP210x UART Bridge / myAVR mySmartUSB light # BrailleMemo [Pocket] # Seika [Braille Display] ENV{PRODUCT}=="10c4/ea60/*", ATTRS{manufacturer}=="Silicon Labs", ENV{BRLTTY_BRAILLE_DRIVER}="sk", GOTO="brltty_usb_run"
So apparently there's a Braille display with the same CP210x USB to UART controller as a lot of microcontroller development boards have. And because this udev rule claims the interface for the brltty daemon, UART communication with all these development boards isn't possible anymore.
As I'm not using these Braille displays, the fix for me was easy: just find the systemd unit that loads these rules, mask and stop it.
$ systemctl list-units | grep brltty brltty-udev.service loaded active running Braille Device Support $ sudo systemctl mask brltty-udev.service Created symlink /etc/systemd/system/brltty-udev.service → /dev/null. $ sudo systemctl stop brltty-udev.service
After this, I was able to use the serial interface again on all my development boards.