#StackBounty: #kernel #drivers #usb #windows #serial-port USB gadget serial-port (g_serial or composite): how do I control what name Wi…

Bounty: 50

I’m trying to add a gadget-serial interface to my project, either by way of modprobe g_serial or by way of a composite/configfs method.

I have a little script (shown below) that works perfectly when talking to a MacOS or a Linux host. And it also works when talking to a Windows host, except that the name is always wrong.

When connected to a Windows host, my gadget always shows up in the Device Manager as "USB Serial Device (COM)" instead of showing up with the right product name. Windows also lists the device’s manufacturer as Microsoft, regardless of what I set in strings/0x409/manufacturer. And the gadget’s serial-number is nowhere to be found.

How do I change this behavior? Is there some kind of magic I can do with /sys/kernel/config/usb_gadget/usb_gadget/g1/os_desc to make Windows pick up the manufacturer, product, and serialnumber fields correctly? Or is there some kind of .inf magic that I need to do on Windows?

I tried using g_serial originally, with the following command:

modprobe g_serial 
    iManufacturer="Magic Manufacturing" 
    iProduct="Gizmomatic Machine"

When I couldn’t get the name to appear correctly, I tried a configfs/gadget-serial approach instead:


set -euo pipefail

mkdir /sys/kernel/config/usb_gadget/g1
cd /sys/kernel/config/usb_gadget/g1

echo 0xEF > bDeviceClass
echo 0x02 > bDeviceSubClass
echo 0x01 > bDeviceProtocol

echo "0x4075" > idVendor
echo "0x0001" > idProduct

mkdir strings/0x409
echo "0123456789" > strings/0x409/serialnumber
echo "Magic Manufacturing" > strings/0x409/manufacturer
echo "Gizmomatic Machine" > strings/0x409/product

mkdir configs/c.1
mkdir configs/c.1/strings/0x409
echo "acm" > configs/c.1/strings/0x409/configuration

mkdir functions/acm.usb0
ln -s functions/acm.usb0 configs/c.1

echo "ci_hdrc.0" > UDC

Both variants "work" in the sense that they create a working COM-port in Windows. But neither one reports the right serial-number, manufacturer, or product name. If anybody’s got some words of wisdom here, it would help me out a lot. I’m on the 4.19.35 kernel if it matters.

Get this bounty!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.