10

I have a random speaker and I want to develop a driver for it so I can report statistics, battery, etc to the dev file system. However, I'm having a hard time finding the speaker's vendor and device id in order to properly associate it with the driver.

I don't even know who the manufacturer is and my Linux machine doesn't detect it (lsusb, and other utils), T&G has a speaker that looks exactly like mine, but mine has a different logo on it (orange flower), not T&G's one.

  • Does every device have a vendor and product id associated with it?

  • if so, how do you find it if you don't know your device, and your machine doesn't recognize it?

  • Is it even possible to report battery and other stats to my machine through a USB port of my speaker, which I believe is supposed to be used with a USB card?

6
  • 3
    With "a random speaker", do you mean a Bluetooth speaker? If it's a cheap one, the USB port might be "charging only", so it might only accept power and not actually communicate as a proper USB device at all. If you have a multimeter, you could measure the resistance (ohms) between the two USB data lines (two middle contacts in the USB 2 connector): if the resistance is less than 200 ohms, it's a Dedicated Charging Port which will not communicate, so no identification nor any stats will be available to the computer.
    – telcoM
    Commented May 26, 2023 at 8:20
  • @telcoM Yes, a bluetooth speaker, and it seems like you are correct. The usb port seems to accept only USB cards, and cannot communicate. Looks like it can only report battery information through bluetooth.
    – vmemmap
    Commented May 26, 2023 at 8:35
  • @telcoM Do you know what a device need to have in order to get its own product/device id? It seems like not every device have those.
    – vmemmap
    Commented May 26, 2023 at 8:36
  • 2
    when I read this question, I remembered youtube.com/watch?v=VG5bWzEPfsg. They discuss the topic in detail, how little has to go right for a USB device to show up in [...] Linux dmesg Commented May 26, 2023 at 16:04
  • What do you mean by a "USB card"?
    – plugwash
    Commented May 26, 2023 at 19:12

4 Answers 4

13

Every device that communicates via USB has a VID (Vendor ID) and PID (Product ID). A vendor ID is obtained via the USB implementer forum (USB.org), which more or less guarantees its uniqueness.

When you plug-in a USB device, you should see it in the output of dmesg, even if the device is not supported. I have not yet seen a USB device that does not show this way.

The alternative is, that the device does not communicatie via USB at all, but only uses the USB connector for charging.

7
  • 1
    I see, so the generic USB driver (usb-generic) just supports the basic connection and recognition of the device, but if you want to support its actual features (E.g. joystick) you should have a dedicated driver for it?
    – vmemmap
    Commented May 26, 2023 at 19:26
  • 3
    @Roi USB has a number of standardized, predefined device classes (keyboard, mass storage device, etc). The generic USB drivers on a system will generally support any device that implements one of those predefined device classes. You'll need a specialized driver when you don't implement one of those standard classes, or when you have extra features that go above and beyond what's defined in the standard.
    – bta
    Commented May 26, 2023 at 19:41
  • @bta Well if a certain keyboard have leds that can be configured, it does require a driver to support the configuration, is that correct? Or maybe leds are also defined by the standard and it's just a matter of sending control packets? Thanks a lot!
    – vmemmap
    Commented May 26, 2023 at 19:58
  • 2
    @Roi That's the sort of thing I was referring to by "beyond what's in the standard". The standard only covers the core functionality (buttons, caps lock LED, etc). You can likely still use the standard driver and just ignore those additional functions, but to make the vendor-specific bells and whistles work you'd need a custom driver.
    – bta
    Commented May 26, 2023 at 20:09
  • @bta support for non-standard keys (e.g. media buttons) can't even be guaranteed, though it's pretty good on many models and others will work after fiddling.
    – Chris H
    Commented May 26, 2023 at 21:18
5

Every "USB device" has a vendor ID and product ID. However we must be careful what we mean by "USB device". Not everything with a USB port on it is a "USB device".

First off a USB host is not considered a "device". In principle (ignoring USB C for now) hosts should have A connectors, devices should have B connectors and devices capable of acting as both should have AB connectors. In practice this is often ignored.

Secondly a lot of stuff just uses the USB connector as a power port for charging and don't act as a USB host or devices at all.

If it doesn't show up in lsusb it almost certainly isn't acting as a USB device.


USB C further muddies the waters, the connector can be used for hosts, devices and "dual-role devices" (things that can act as both host and device).

At the simplest level, C ports that only operate in device mode can indicate that fact using resistors on the "CC" pins. Fixed-host ports are a little more complicated because they are not supposed to provide power unless a device is connected on the other end, but still relatively simple. IIRC dual-role ports are supposed to switch quickly back and forth between acting as host ports and acting as device ports.

However USB C also has the option of using active negotiation on the "CC" pins. This can be used to negotiate higher power levels, negotiate transmission of power in the opposite direction to data, or even negotiate use of a protocol other than USB.

2
  • 1
    USB-C literally has support for "Alternate Modes" which basically means "not USB". The system-defined Alternate Modes for USB-C are Thunderbolt, DisplayPort, HDMI, MHL, and VisualLink, but vendors are allowed to create their own. In addition, there is Audio Adapter Accessory Mode and, of course, USB-PD. And that's only the usages that are foreseen by the USB IF itself, there are thousands of vendors which use the USB-C connector for things that have nothing to do with USB, just because it is convenient. Similarly, my employer has standardized all internal connections in our devices to RJ45, … Commented May 27, 2023 at 15:42
  • 1
    … most of which has nothing to do with Ethernet. We use it for (low) power, analog line-level audio, headphone audio, AES3 digital audio, GPIO, RS-232 serial, CANbus, and many other things. We use it because even though RJ45 and Cat5e are over specified for what we do, it is still cheaper because of mass production than the custom-built cables and connectors we had before. The same is true for USB-C. Commented May 27, 2023 at 15:43
1

Every USB device must identify itself with a packet containing 16-bit values in the VID and PID fields. Given that there are probably more than 65,535 entities producing USB devices, it would be impossible for all entities that produce USB devices to have unique VIDs associated with them.

In many situations where a USB controller chip vendor allows configuration of its device report, devices using the chip will be programmed with a vendor-specific name, but the manufacturer's default VID/PID combination. This will allow the vendor's supplied drivers to work with the device without requiring modification, but will require that software examine device names to ascertain which devices it should try to talk to.

Back in the 1990s, when USB was being developed, the use of 16-bit VID/PID might possibly have almost made sense, but the number of vendors and products means they are nowadays woefully small for their intended purpose.

3
  • 4
    A lot of devices use the chip manufacturers VID (e.g. FTDI's) - this will account for a lot of the minor device manufacturers
    – Chris H
    Commented May 26, 2023 at 21:19
  • Even worse, a lot of vendors don't bother licensing an USB-IF identifier and sell devices that use woefully "unique" IDs like 0x0000, 0x0001 and 0xffff but are otherwise unrelated (meaning by their finished product or even USB chip vendor, OEMs, device purpose, further protocols and suitable drivers). I gather some orgs that got vendor IDs earlier re-sell product ranges in them, or in some cases make them freely available to tinkerers. I think this may be against the USB-IF rules, but apparently does happen. And might be a decent way out of the lack of enough IDs actually.
    – Jim Klimov
    Commented May 28, 2023 at 14:52
  • IIRC, the Consortium expressly forbade resale of IDs, but the use of 16-bit IDs seems IMHO almost laughable as a primary ID mechanism. What might have made more sense would have been to have both 16-bit and 32-bit vendor and device IDs, with a proviso that devices whose manufacturers paid extra for a 16-bit ID could be enumerated somewhat faster than those whose manufacturers did not, somewhat analogous to the way some companies pay extra for compact UPC codes.
    – supercat
    Commented May 29, 2023 at 14:18
1

Others have already mentioned that dmesg reports the VID/PID of connected USB devices, once enumeration has completed.

dmesg can also report errors failing to enumerate a USB device.

E.g. under Ubuntu 18.04 just attempted to plug in a USB 2 device, which didn't show up in the output of lsusb. On checking dmesg there were the following errors:

[19852.532042] usb 3-6: new high-speed USB device number 6 using xhci_hcd
[19858.240057] usb 3-6: device descriptor read/64, error -110
[19874.656054] usb usb3-port6: Cannot enable. Maybe the USB cable is bad?
[19875.624047] usb usb3-port6: Cannot enable. Maybe the USB cable is bad?
[19875.624099] usb usb3-port6: attempt power cycle
[19876.668040] usb usb3-port6: Cannot enable. Maybe the USB cable is bad?
[19877.636052] usb usb3-port6: Cannot enable. Maybe the USB cable is bad?
[19877.636127] usb usb3-port6: unable to enumerate USB device

Disconnected and then re-connected the USB device and this time the device showed up in the output of lsusb and dmesg also reported the VID/PID:

[20158.004079] usb 3-6: new high-speed USB device number 18 using xhci_hcd
[20158.152321] usb 3-6: New USB device found, idVendor=03fd, idProduct=0008
[20158.152324] usb 3-6: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[20158.152327] usb 3-6: Product: XILINX    
[20158.152329] usb 3-6: Manufacturer: XILINX 
1
  • Mine doesn't log anything. I believe my speaker is just not a USB device so the process of enumeration is not even called. Thanks though!
    – vmemmap
    Commented May 27, 2023 at 19:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .