Hunting down USB, extracting information down to chip level

A few personal notes about exploring USB. Using a  RaspberryPi  under  DietPi, will be extended from time to time.

There are a lot of tutorials that are more informative like  DebianWiki,  AskUbuntu, therefore this will be more a personal log file.

Only typing in lsusb  or  dmesg  will get you some first information:

$ dmesg | grep tty

[ 0.000000] Kernel command line: 8250.nr_uarts=0 bcm2708_fb.fbwidth=1280 bcm2708_fb.fbheight=720 bcm2708_fb.fbswap=1 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 dwc_otg.lpm_enable=0 console=ttyS0,115200 console=tty1 root=PARTUUID=6f0c83bc-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
[ 0.000808] console [tty1] enabled
[ 0.971269] 3f201000.serial: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev2
[ 2.661852] systemd[1]: getty-static.service: Cannot add dependency job, ignoring: Unit getty-static.service is masked.
[ 1448.875364] usb 1-1.3: ch341-uart converter now attached to ttyUSB0
[ 2033.853020] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
[ 2044.017844] usb 1-1.3: ch341-uart converter now attached to ttyUSB0
[ 2057.147932] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
[ 2058.608487] usb 1-1.2: ch341-uart converter now attached to ttyUSB0
[ 2065.595627] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
[ 2072.439184] usb 1-1.2: ch341-uart converter now attached to ttyUSB0
[ 4085.179543] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0

not really what I wanted, trying lsusb

$ lsusb

Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

that’s more what I want, if I put in a usb stick, there is an additional line:


Bus 001 Device 012: ID 0951:1666 Kingston Technology DataTraveler G4

and if I put in a serial device like my GMC-320:


Bus 001 Device 013: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter

That’s good but sometimes normally I want the device path of real connected devices like /dev/ttyUSB0…. Found this script (and explanation about) at StackExchange, put it as exploresusb.sh in my $home/scripts folder:


#!/bin/bash

for sysdevpath in $(find /sys/bus/usb/devices/usb*/ -name dev); do
(
syspath="${sysdevpath%/dev}"
devname="$(udevadm info -q name -p $syspath)"
[[ "$devname" == "bus/"* ]] && continue
eval "$(udevadm info -q property --export -p $syspath)"
[[ -z "$ID_SERIAL" ]] && continue
echo "/dev/$devname - $ID_SERIAL"
)
done

(don’t forget to chmod +x it…) and I got all my plugged in USB gadgets:

$./scripts/exploreusb.sh 
/dev/sda - Kingston_DataTraveler_3.0_00241D8CE563B191798F03EC-0:0
/dev/sda1 - Kingston_DataTraveler_3.0_00241D8CE563B191798F03EC-0:0
/dev/ttyUSB0 - 1a86_USB2.0-Serial
/dev/video1 - OmniVision_Technologies__Inc._USB_Camera-B4.09.24.1
/dev/snd/controlC1 - OmniVision_Technologies__Inc._USB_Camera-B4.09.24.1

so I can see a USB drive, GMC-320 and a USB camera (with video and sound). Further Information about block devices like USB drives → lsblk command explained.

To get information from serial devices I found this small python scricpt, “find_port.py” inside the sub-ser-mon package from Dave Hylands (lokal copy: usb-ser-mon-master).

Hint, for a python newbie like me: for DietPi, install the “python pip package installer” via “dietpi-software“, and install this packages used for this script (see this link for ubuntu 18.04):

$ pip install pyudev
$ pip install serial

Using find_port.py, I got this:

$./scripts/find_port.py -l
USB Serial Device 1a86:7523 with vendor '1a86' found @/dev/ttyUSB1

Searching a little bit with this information:  1a86 will link to QinHeng Electronics  like the lsusb. Found also this blogpost (Luan78zao’s Blog) linking to  some schematics  from the vendor of this chips (Chinese). I think correct one is the USB bus convert chip  CH341DS1  (local copy, English).


Thats all for now, Folks