You are not logged in.

#1 2020-02-03 09:58:05

sjdh
Member
Registered: 2013-09-19
Posts: 22

[Solved] How to find serial usb device name

Hello

My ESP8266 developers board communicates via a USB serial device.
To communicate with the device, I need to know the device name (if any)
What can I try to find it?



What I have tried:
1) lsusb
Bus 002 Device 006: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter

2) dmesg
[11438.808672] usb 2-3: new full-speed USB device number 6 using xhci_hcd
[11438.949790] usb 2-3: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.54
[11438.949796] usb 2-3: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[11438.949799] usb 2-3: Product: USB2.0-Serial

3) Checking new tty* defice files in /dev
Before connecting device
ls /dev/tty* |wc -l
69

After connecting device
ls /dev/tty* |wc -l
69

No new device names starting with tty appear.

Last edited by sjdh (2020-02-05 19:41:00)

Offline

#2 2020-02-03 10:07:12

sjdh
Member
Registered: 2013-09-19
Posts: 22

Re: [Solved] How to find serial usb device name

I tried the above after a kernel update.
After a restart, a new device appeared as /dev/ttyUSB0

Communication works now.

python -m esptool -p /dev/ttyUSB0 chip_id
[sudo] password for sjoerd:
esptool.py v2.8
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: cc:50:e3:08:79:b5
Uploading stub...
Running stub...
Stub running...
Chip ID: 0x000879b5
Hard resetting via RTS pin...

Offline

#3 2020-02-03 10:16:20

sjdh
Member
Registered: 2013-09-19
Posts: 22

Re: [Solved] How to find serial usb device name

My problem is solved by trial and error. I checked if new tty devices appeared after plugging in the serial usb device, and this worked.

For my understanding I'd like to know a bit more
- Is there any other way I could have found the device name connected to the serial usb device that appeared with lsusb?
- What happens behind the scene once I attach the usb device? How come a new device file is automatically created?

I'd be grateful if anyone can give me some pointers to relevant articles.

By the way, after reboot lsusb does show the relevant message, giving the tty device name
[  241.370894] usb 2-3: new full-speed USB device number 4 using xhci_hcd
[  241.512030] usb 2-3: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.54
[  241.512035] usb 2-3: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[  241.512038] usb 2-3: Product: USB2.0-Serial
[  241.513032] ch341 2-3:1.0: ch341-uart converter detected
[  241.513520] usb 2-3: ch341-uart converter now attached to ttyUSB0

Offline

#4 2020-02-03 15:41:54

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,642

Re: [Solved] How to find serial usb device name

There are two ways that I have seen that USB serial devices enumerate. They will enumerate as /dev/ttyUSBx, or they will enumerate as /dev/ttyACMx.   In one case (ttyUSB), the device presents itself as a simple serial port.  In the case of ttyACM, the device presents itself as a USB modem (whether or not that is true).   FTDI based parts usually show up as ttyUSB; some (not all)  Arduinos show up as ttyACM.

https://rfc1149.net/blog/2013/03/05/wha … evttyacmx/

In any event, the kernel driver will instantiate the next available number (it will start with ttyUSB0, then ttyUSB1 ....)  I think there is a way of finding the mapping from the device node to the physical device, but I would have to poke around a bit to find it; I don't have access to a machine that I can plug a USB device into right now.

Last edited by ewaller (2020-02-03 15:42:32)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#5 2020-02-03 16:23:19

sjdh
Member
Registered: 2013-09-19
Posts: 22

Re: [Solved] How to find serial usb device name

Thanks Ewaller. That article was helpfull.

I'm writing a tutorial where I have to explain how to find the device name of the USB serial device on a linux machine.
I'd be happy to hear any suggestions on how to figure out the mapping with low failure rate (also for other distos). For now I would say that dmesg works (experimentally verified with n=1).

Offline

Board footer

Powered by FluxBB