hippy
Posts: 9167
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Why no lsusb desciption ?

Sat Jan 23, 2021 5:34 pm

With MicroPython running on the Pico, my Pi detects it is connected, creates /dev/ttyACM0, but 'lsusb' has no human readable useful description ...

Code: Select all

pi@Pi3B:~ $ dmesg
... snip ...
[158286.881924] usb 1-1.4: new full-speed USB device number 22 using dwc_otg
[158287.015568] usb 1-1.4: New USB device found, idVendor=2e8a, idProduct=0005, bcdDevice= 1.00
[158287.015590] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[158287.015605] usb 1-1.4: Product: Board in FS mode
[158287.015618] usb 1-1.4: Manufacturer: MicroPython
[158287.015632] usb 1-1.4: SerialNumber: 000000000000
[158287.018855] cdc_acm 1-1.4:1.0: ttyACM0: USB ACM device

Code: Select all

pi@Pi3B:~ $ lsusb
Bus 001 Device 018: ID 04d9:1203 Holtek Semiconductor, Inc. Keyboard
Bus 001 Device 017: ID 04f3:0213 Elan Microelectronics Corp. 
Bus 001 Device 016: ID 0a05:7211 Unknown Manufacturer hub
Bus 001 Device 022: ID 2e8a:0005        <========
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
Is this as expected ?

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 28358
Joined: Sat Jul 30, 2011 7:41 pm

Re: Why no lsusb desciption ?

Sat Jan 23, 2021 7:47 pm

It's all I've ever known.

Not sure why we don't have a description. Will ask!
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

cleverca22
Posts: 2880
Joined: Sat Aug 18, 2012 2:33 pm

Re: Why no lsusb desciption ?

Sat Jan 23, 2021 10:26 pm

i'm guessing its just a matter of adding 2 string descriptors into the usb layer

"New USB device strings: Mfr=1, Product=2, SerialNumber=3"
something in the pico needs to respond with strings #1, #2, and #3, and then lsusb can render.... but they did, ok, now i'm just confused, lol, i'll need my own board to arrive before i could answer things concretely

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2548
Joined: Thu Jul 11, 2013 2:37 pm

Re: Why no lsusb desciption ?

Sat Jan 23, 2021 10:37 pm

The default lsusb listing uses an internal database of VID:PID combinations to identify devices. Case in point: compare the SMSC adapter strings with the "not verbose" listing.
Rockets are loud.
https://astro-pi.org

cleverca22
Posts: 2880
Joined: Sat Aug 18, 2012 2:33 pm

Re: Why no lsusb desciption ?

Sat Jan 23, 2021 11:33 pm

jdb wrote:
Sat Jan 23, 2021 10:37 pm
The default lsusb listing uses an internal database of VID:PID combinations to identify devices. Case in point: compare the SMSC adapter strings with the "not verbose" listing.
now i'm just confused:

Code: Select all

Jan 23 19:31:52 amd-nixos kernel: usb 13-1: new full-speed USB device number 30 using ohci-pci
Jan 23 19:31:58 amd-nixos kernel: usb 13-1: New USB device found, idVendor=0000, idProduct=0000, bcdDevice= 0.00
Jan 23 19:31:58 amd-nixos kernel: usb 13-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jan 23 19:31:58 amd-nixos kernel: usb 13-1: Product: lk
Jan 23 19:31:58 amd-nixos kernel: usb 13-1: Manufacturer: cleverca22
Jan 23 19:31:58 amd-nixos kernel: usb 13-1: SerialNumber: 1234
[root@amd-nixos:~]# lsusb
Bus 006 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 013 Device 030: ID 0000:0000 cleverca22 lk
a custom usb gadget on a pi0(fully baremetal), is showing the Manufacturer/Product just fine with the default args

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2548
Joined: Thu Jul 11, 2013 2:37 pm

Re: Why no lsusb desciption ?

Sat Jan 23, 2021 11:42 pm

What happens if you use lsusb as someone who isn't root?
Rockets are loud.
https://astro-pi.org

cleverca22
Posts: 2880
Joined: Sat Aug 18, 2012 2:33 pm

Re: Why no lsusb desciption ?

Sat Jan 23, 2021 11:47 pm

jdb wrote:
Sat Jan 23, 2021 11:42 pm
What happens if you use lsusb as someone who isn't root?
same thing, it still works:

Code: Select all

[clever@amd-nixos:~/apps/rpi/rpi-tools]$ lsusb
Bus 006 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 013 Device 030: ID 0000:0000 cleverca22 lk
checking strace i see:

Code: Select all

[clever@amd-nixos:~/apps/rpi/rpi-tools]$ strace -e open,openat lsusb
...
openat(AT_FDCWD, "/sys/bus/usb/devices/usb6/descriptors", O_RDONLY|O_CLOEXEC) = 7
Bus 006 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
openat(AT_FDCWD, "/sys/bus/usb/devices/13-1/manufacturer", O_RDONLY) = 10
openat(AT_FDCWD, "/sys/bus/usb/devices/13-1/product", O_RDONLY) = 10
Bus 013 Device 030: ID 0000:0000 cleverca22 lk
Bus 013 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 012 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
...

Code: Select all

[clever@amd-nixos:~/apps/rpi/rpi-tools]$ strace -e open,openat lsusb 2>&1 | grep product
openat(AT_FDCWD, "/sys/bus/usb/devices/13-1/product", O_RDONLY) = 10
openat(AT_FDCWD, "/sys/bus/usb/devices/8-2/product", O_RDONLY) = 10
[clever@amd-nixos:~/apps/rpi/rpi-tools]$ cat /sys/bus/usb/devices/13-1/product
lk
[clever@amd-nixos:~/apps/rpi/rpi-tools]$ cat /sys/bus/usb/devices/8-2/product
CORSAIR DARK CORE RGB PRO Gaming Dongle
it only tries to read the raw name from the descriptors for 2 of my devices, it might be that my version falls back to the usb descriptors, when the vid:pid database lacks an answer

Code: Select all

[clever@amd-nixos:~/apps/rpi/rpi-tools]$ lsusb --version
lsusb (usbutils) 012
and my pi400 is using an older version!

Code: Select all

pi@pi400:~ $ lsusb --version
lsusb (usbutils) 010
edit:
yep, and that confirms it!
on the desktop:

Code: Select all

[clever@amd-nixos:~/apps/rpi/rpi-tools]$ lsusb
Bus 008 Device 006: ID 1b1c:1b81 Corsair CORSAIR DARK CORE RGB PRO Gaming Dongle
but on the pi400:

Code: Select all

pi@pi400:~ $ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 04d9:0007 Holtek Semiconductor, Inc.
Bus 001 Device 004: ID 1b1c:1b81 Corsair
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

hippy
Posts: 9167
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Why no lsusb desciption ?

Sun Jan 24, 2021 11:09 am

Noticed it's the same 'no description for lsusb' when the Pico is in MSD bootloader mode; "2e8a:0003" -

Code: Select all

[221504.746399] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[221504.746413] usb 1-1.4: Product: RP2 Boot
[221504.746427] usb 1-1.4: Manufacturer: Raspberry Pi
[221504.746440] usb 1-1.4: SerialNumber: E0C912D24340
[221504.750354] usb-storage 1-1.4:1.0: USB Mass Storage device detected
[221504.752010] scsi host0: usb-storage 1-1.4:1.0
[221505.765130] scsi 0:0:0:0: Direct-Access     RPI      RP2              1    PQ: 0 ANSI: 2
[221505.766828] sd 0:0:0:0: [sda] 262144 512-byte logical blocks: (134 MB/128 MiB)
[221505.767794] sd 0:0:0:0: [sda] Write Protect is off
[221505.767812] sd 0:0:0:0: [sda] Mode Sense: 03 00 00 00
[221505.767996] sd 0:0:0:0: Attached scsi generic sg0 type 0
[221505.768790] sd 0:0:0:0: [sda] No Caching mode page found
[221505.768807] sd 0:0:0:0: [sda] Assuming drive cache: write through
[221505.837618]  sda: sda1
[221505.845720] sd 0:0:0:0: [sda] Attached SCSI removable disk

cleverca22
Posts: 2880
Joined: Sat Aug 18, 2012 2:33 pm

Re: Why no lsusb desciption ?

Sun Jan 24, 2021 11:28 am

hippy wrote:
Sun Jan 24, 2021 11:09 am
Noticed it's the same 'no description for lsusb' when the Pico is in MSD bootloader mode; "2e8a:0003" -
what is your "lsusb --version", do you have another linux machine with a newer version?

hippy
Posts: 9167
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Why no lsusb desciption ?

Sun Jan 24, 2021 12:14 pm

Same version as yours; "lsusb (usbutils) 010". I'll see what RPD, WSL and Windows report when I get the time.

DWiskow
Posts: 54
Joined: Sun Apr 09, 2017 1:56 pm

Re: Why no lsusb desciption ?

Tue Jan 26, 2021 1:23 am

Try this bash script to list/detect serial devices . . .

Code: Select all

#!/bin/bash
#
# scan usb devices and list those with ID_SERIAL
#
for sysdevpath in $(find /sys/bus/usb/devices/usb*/ -name dev); do
    (
        syspath="${sysdevpath%/dev}"
        devname="$(udevadm info -q name -p $syspath)"
        [[ "$devname" == "bus/"* ]] && exit
        eval "$(udevadm info -q property --export -p $syspath)"
        [[ -z "$ID_SERIAL" ]] && exit
        echo "/dev/$devname - $ID_SERIAL"
    )
done
Save it into ~/.local/bin/lsusbserial and then add .local/bin to the PATH and you will be able to get a list of connected serial devices on a linux computer [i.e. Raspberry Pi] by using lsusbserial on the command line . . . (don’t forget to chmod +x the file after creating it)

DWiskow
Posts: 54
Joined: Sun Apr 09, 2017 1:56 pm

Re: Why no lsusb desciption ?

Fri Jan 29, 2021 2:55 pm

The Raspberry Pi (Trading) Limited Vendor ID is 2E8A and the Pico Product ID is 0005 . . .

. . . so running the python script below on your Windows, Apple or Linux computer, will automatically discover and print out the USB Serial Port on your computer that a Raspberry Pi Pico is currently plugged into.

Code: Select all

#!/usr/bin/env python3
#
# Vendor:Product ID for Raspberry Pi Pico is 2E8A:0005
#
import serial.tools.list_ports
picoPorts = list(serial.tools.list_ports.grep("2E8A:0005"))

if not picoPorts:
   print("No Raspberry Pi Pico found")
elif len(picoPorts) > 1:
   print('Multiple Raspberry Pi Picos found - make sure only one is connected')
elif len(picoPorts) == 1:
   picoSerialPort = picoPorts[0].device
   print( "Raspberry Pi Pico found at "+str(picoSerialPort) )

It does this using the serial tools library (part of pyserial) to search for connected devices with the VID:PID of "2E8A:0005", will work on all the different platforms and will typically return "COMn", "/dev/cu.usbmodem0000000000001" or "/dev/ttyACM0" for Windows, Apple & Linux computers respectively.

This code example will also be of use to those developing cross platform python applications that wish to communicate over USB serial with a Raspberry Pi Pico.

Return to “MicroPython”