ESP-01Sへのプログラムライタとして使っている、 CH340 搭載 USBシリアルコンバータを Ubuntu 22.04 で使おうとすると、BRLTTYに邪魔をされて使えない状態に。Udevルールを編集してこれまで通りに使えるようにしました。
ESP-01S用USBシリアルコンバータが使えない
ESP8266を搭載したモジュールの中でもコンパクトな構成の、ESP-01S(関連記事はこちら)へのプログラム書込みに使う専用のUSBシリアルコンバータを、
普段とは異なるUbuntu 22.04搭載ノートPC(関連記事はこちら)へ繋いだときのこと。
1 2 3 4 5 6 7 8 9 |
$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.2 LTS Release: 22.04 Codename: jammy $ uname -a Linux VPCSA26GGu 5.15.0-67-generic #74-Ubuntu SMP Wed Feb 22 14:14:39 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux |
lsusb では確かに見えるのに、 ttyUSB* デバイスが一向に現れず、当然シリアルデバイスとして利用不可。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
$ lsusb Bus 002 Device 018: ID 1a86:7523 QinHeng Electronics CH340 serial converter Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 003 Device 002: ID 045e:00f0 Microsoft Corp. Microsoft ® Laser Mouse 6000 Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 005: ID 05ca:18c0 Ricoh Co., Ltd USB2.0 Camera Bus 001 Device 004: ID 8087:0032 Intel Corp. AX210 Bluetooth Bus 001 Device 003: ID 08ff:168f AuthenTec, Inc. AES1660 Fingerprint Sensor Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub $ ls /dev/ttyUSB* ls: '/dev/ttyUSB*' にアクセスできません: そのようなファイルやディレクトリはありません $ sudo minicom -s minicom: /dev/ttyUSB0 をオープンできません : そのようなファイルやディレクトリはありません |
USBポートへ挿した際のログを確認すると、見慣れないBRLTTY関連のエントリで溢れていました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
Mar 23 21:00:56 VPCSA26GGu kernel: [ 4899.230550] usb 2-1.2: new full-speed USB device number 17 using ehci-pci Mar 23 21:00:56 VPCSA26GGu kernel: [ 4899.340268] usb 2-1.2: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.54 Mar 23 21:00:56 VPCSA26GGu kernel: [ 4899.340287] usb 2-1.2: New USB device strings: Mfr=0, Product=2, SerialNumber=0 Mar 23 21:00:56 VPCSA26GGu kernel: [ 4899.340294] usb 2-1.2: Product: USB2.0-Serial Mar 23 21:00:56 VPCSA26GGu kernel: [ 4899.340861] ch341 2-1.2:1.0: ch341-uart converter detected Mar 23 21:00:56 VPCSA26GGu kernel: [ 4899.346678] usb 2-1.2: ch341-uart converter now attached to ttyUSB0 Mar 23 21:00:56 VPCSA26GGu mtp-probe: checking bus 2, device 17: "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2" Mar 23 21:00:56 VPCSA26GGu mtp-probe: bus: 2, device: 17 was not an MTP device Mar 23 21:00:56 VPCSA26GGu snapd[954]: udevmon.go:149: udev event error: Unable to parse uevent, err: cannot parse libudev event: invalid env data Mar 23 21:00:56 VPCSA26GGu systemd[1]: Starting Braille Device Support... Mar 23 21:00:56 VPCSA26GGu brltty[58326]: BRLTTY 6.4 rev BRLTTY-6.4 [https://brltty.app/] Mar 23 21:00:56 VPCSA26GGu brltty[58326]: BRLTTY 6.4 rev BRLTTY-6.4 [https://brltty.app/] Mar 23 21:00:56 VPCSA26GGu brltty[58326]: executing as the invoking user: root Mar 23 21:00:56 VPCSA26GGu brltty[58326]: brltty: executing as the invoking user: root Mar 23 21:00:56 VPCSA26GGu snapd[954]: hotplug.go:200: hotplug device add event ignored, enable experimental.hotplug Mar 23 21:00:56 VPCSA26GGu systemd-udevd[58318]: 2-1.2:1.0: Process '/usr/lib/snapd/snap-device-helper bind snap_cups_cupsd /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 0:0' failed with exit code 1. Mar 23 21:00:56 VPCSA26GGu systemd-udevd[58318]: 2-1.2:1.0: Process '/usr/lib/snapd/snap-device-helper bind snap_cups_ippeveprinter /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 0:0' failed with exit code 1. Mar 23 21:00:56 VPCSA26GGu mtp-probe: checking bus 2, device 17: "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2" Mar 23 21:00:56 VPCSA26GGu mtp-probe: bus: 2, device: 17 was not an MTP device Mar 23 21:00:56 VPCSA26GGu systemd-udevd[58318]: 2-1.2: Process '/usr/lib/snapd/snap-device-helper bind snap_cups_cupsd /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2 189:144' failed with exit code 1. Mar 23 21:00:56 VPCSA26GGu systemd-udevd[58318]: 2-1.2: Process '/usr/lib/snapd/snap-device-helper bind snap_cups_ippeveprinter /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2 189:144' failed with exit code 1. Mar 23 21:00:56 VPCSA26GGu snapd[954]: udevmon.go:149: udev event error: Unable to parse uevent, err: cannot parse libudev event: invalid env data Mar 23 21:00:56 VPCSA26GGu brltty[58326]: BrlAPI Server: release 0.8.3 Mar 23 21:00:56 VPCSA26GGu brltty[58326]: brltty: BrlAPI Server: release 0.8.3 Mar 23 21:00:56 VPCSA26GGu systemd[1]: Started Braille Device Support. Mar 23 21:00:56 VPCSA26GGu brltty[58326]: Linux Screen Driver: Mar 23 21:00:56 VPCSA26GGu brltty[58326]: brltty: Linux Screen Driver: Mar 23 21:00:56 VPCSA26GGu kernel: [ 4899.925587] input: BRLTTY 6.4 Linux Screen Driver Keyboard as /devices/virtual/input/input19 Mar 23 21:00:57 VPCSA26GGu brltty[58326]: USB configuration set error 16: デバイスもしくはリソースがビジー状態です Mar 23 21:00:57 VPCSA26GGu kernel: [ 4900.071727] usb 2-1.2: usbfs: interface 0 claimed by ch341 while 'brltty' sets config #1 Mar 23 21:00:57 VPCSA26GGu brltty[58326]: brltty: USB configuration set error 16: デバイスもしくはリソースがビジー状態です Mar 23 21:00:57 VPCSA26GGu brltty[58326]: brltty: USB interface in use: 0 (ch341) Mar 23 21:00:57 VPCSA26GGu brltty[58326]: USB interface in use: 0 (ch341) Mar 23 21:00:57 VPCSA26GGu kernel: [ 4900.072276] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0 Mar 23 21:00:57 VPCSA26GGu kernel: [ 4900.072300] ch341 2-1.2:1.0: device disconnected Mar 23 21:00:57 VPCSA26GGu ModemManager[1029]: <info> [base-manager] port ttyUSB0 released by device '/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2' Mar 23 21:00:57 VPCSA26GGu ModemManager[1029]: <info> [base-manager] couldn't check support for device '/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2': Operation was cancelled Mar 23 21:00:57 VPCSA26GGu brltty[58326]: NoSpeech Speech Driver: Mar 23 21:00:57 VPCSA26GGu brltty[58326]: brltty: NoSpeech Speech Driver: Mar 23 21:00:57 VPCSA26GGu systemd-udevd[58318]: 2-1.2:1.0: Process '/usr/lib/snapd/snap-device-helper unbind snap_cups_cupsd /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 0:0' failed with exit code 1. Mar 23 21:00:57 VPCSA26GGu systemd-udevd[58318]: 2-1.2:1.0: Process '/usr/lib/snapd/snap-device-helper unbind snap_cups_ippeveprinter /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 0:0' failed with exit code 1. Mar 23 21:00:57 VPCSA26GGu gnome-shell[1568]: Window manager warning: Overwriting existing binding of keysym 35 with keysym 35 (keycode e). Mar 23 21:00:57 VPCSA26GGu gnome-shell[1568]: Window manager warning: Overwriting existing binding of keysym 38 with keysym 38 (keycode 11). Mar 23 21:00:57 VPCSA26GGu gnome-shell[1568]: Window manager warning: Overwriting existing binding of keysym 36 with keysym 36 (keycode f). Mar 23 21:00:57 VPCSA26GGu gnome-shell[1568]: Window manager warning: Overwriting existing binding of keysym 34 with keysym 34 (keycode d). Mar 23 21:00:57 VPCSA26GGu gnome-shell[1568]: Window manager warning: Overwriting existing binding of keysym 31 with keysym 31 (keycode a). Mar 23 21:00:57 VPCSA26GGu gnome-shell[1568]: Window manager warning: Overwriting existing binding of keysym 37 with keysym 37 (keycode 10). Mar 23 21:00:57 VPCSA26GGu gnome-shell[1568]: Window manager warning: Overwriting existing binding of keysym 33 with keysym 33 (keycode c). Mar 23 21:00:57 VPCSA26GGu gnome-shell[1568]: Window manager warning: Overwriting existing binding of keysym 39 with keysym 39 (keycode 12). Mar 23 21:00:57 VPCSA26GGu gnome-shell[1568]: Window manager warning: Overwriting existing binding of keysym 32 with keysym 32 (keycode b). Mar 23 21:01:12 VPCSA26GGu brltty[58326]: Ignored Byte: 8D Mar 23 21:01:12 VPCSA26GGu brltty[58326]: brltty: Ignored Byte: 8D Mar 23 21:01:12 VPCSA26GGu brltty[58326]: brltty: Ignored Byte: 43 Mar 23 21:01:12 VPCSA26GGu brltty[58326]: brltty: Ignored Byte: A1 Mar 23 21:01:12 VPCSA26GGu brltty[58326]: brltty: Ignored Byte: 6D Mar 23 21:01:12 VPCSA26GGu brltty[58326]: brltty: Ignored Byte: D2 Mar 23 21:01:12 VPCSA26GGu brltty[58326]: brltty: Ignored Byte: 8C Mar 23 21:01:12 VPCSA26GGu brltty[58326]: brltty: Ignored Byte: DC Mar 23 21:01:12 VPCSA26GGu brltty[58326]: Ignored Byte: 43 Mar 23 21:01:12 VPCSA26GGu brltty[58326]: Ignored Byte: A1 Mar 23 21:01:12 VPCSA26GGu brltty[58326]: Ignored Byte: 6D Mar 23 21:01:12 VPCSA26GGu brltty[58326]: Ignored Byte: D2 Mar 23 21:01:12 VPCSA26GGu brltty[58326]: Ignored Byte: 8C Mar 23 21:01:12 VPCSA26GGu brltty[58326]: Ignored Byte: DC Mar 23 21:01:12 VPCSA26GGu brltty[58326]: Ignored Byte: B0 |
BRLTTYが掴まないようUdevルール変更
調べてみると、同じようにUbuntu 22.04では使えないという事例がありました。
普段、このUSBシリアルコンバータを使えている別のPCはUbuntu 18.04という点でも、同じ事例とみて間違い無さそうです。
このコンバータで使われているIC、南京沁恒 QinHeng CH340のデバイスIDは、先ほどの lsusb から 1a86:7523 であることを確認済みなので、
BRLTTYのUdevルール /usr/lib/udev/rules.d/85-brltty.rules から、CH340の以下のエントリをコメントアウトしてしまいます。
1 2 3 |
# Device: 1A86:7523 # Baum [NLS eReader Zoomax (20 cells)] #ENV{PRODUCT}=="1a86/7523/*", ENV{BRLTTY_BRAILLE_DRIVER}="bm", GOTO="brltty_usb_run" |
変更後、次のコマンドでUdevルールが反映されると言う記述も散見されるも、期待通りにはならず、
1 |
$ sudo udevadm control --reload-rules |
結局システムを再起動させて変更したルールを反映させ、以降は問題無くUSBシリアルコンバータが使えるようになりました。
ちなみに、もっと手っ取り早くBRLTTYパッケージをアンインストールしたり、サービスを無効化するなど、他のさまざまなアプローチについて、こちらに詳しい記述がありました。
CH340は今回のような形態のみならず、一部のESP-12Eモジュール(関連記事はこちら)や、WeMOS D1 miniにも搭載されていることが確認されているので、そうしたデバイスをUSBポートに挿しても正常に認識されない場合は、この解決策が使えそうです。