raspberrypi / raspberrypi/linux

Wrong string descriptors in OTG mode (g_mass_storage)

Open
#2,809 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Waiting for external input
Dominant language
C
Stars
13.2k
Forks
5.5k
Avg merge
2d 21h
Merged PRs (30d)
21

Description

Describe the bug
When checking several different USB devices which are compatible with my 3d printer the string descriptors are always configured like this.

iManufacturer .... 0x01 (String Descriptor 1)
iProduct .... 0x02 (String Descriptor 2)
iSerialNumber ... 0x03 (String Descriptor 3)

This can be verified with "dmesg" command on linux or usbtreeview gui on windows.
When emulating the usb share on Raspberry Pi Zero W device the string descriptors are not in the same (correct) order.

iManufacturer is 0x03 insted of 0x01
iProduct is 0x04 instead of 0x02
iSerialNumber is 0x05 instead of 0x03

To reproduce
The usb device emulation is configured like this:
sudo modprobe g_mass_storage file=/usbdisk.img stall=0 removable=1 idProduct=0x1000 bcdDevice=0x1000 iManufacturer="PiShare" iProduct="3dPrinterShare" iSerialNumber=12345678912345

Expected behaviour
usbtreeview of emulated usb share should look like this:

iManufacturer            : 0x01 (String Descriptor 1)
 Language 0x0409         : "PiShare"
iProduct                 : 0x02 (String Descriptor 2)
 Language 0x0409         : "3dPrinterShare"
iSerialNumber            : 0x03 (String Descriptor 3)
 Language 0x0409         : "12345678912345"

Actual behaviour
usbtreeview of emulated usb share looks like this:

iManufacturer            : 0x03 (String Descriptor 3)
 Language 0x0409         : "PiShare"
iProduct                 : 0x04 (String Descriptor 4)
 Language 0x0409         : "3dPrinterShare"
iSerialNumber            : 0x05 (String Descriptor 5)
 Language 0x0409         : "12345678912345"

System
Model: Raspberry Pi Zero W
OS: 2017-07-05-raspbian-jessie-lite.img

Logs
See actual behaviour

Is this issue related to g_mass_storage implementation (bug?) or is this also user configurable?
Thanks for support.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the g_mass_storage USB gadget entry point and reproduce the issue using the provided modprobe command, checking descriptors with dmesg or usbtreeview. Trace how iManufacturer, iProduct, and iSerialNumber are assigned, then verify that the emulated device reports them as descriptors 0x01, 0x02, and 0x03.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, linux
Domain
embedded-iot, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.