1

I have a Raspberry Pi Zero W configured as a USB device (latest raspian version 5.10.11+). Make a Pi Zero W Smart USB flash drive

In general it works fine, and the device will be recognized by Windows 10, other Raspberry Pi's, Mac OSX.

However, I work on a project with a special Touch Screen devices where the configured Zero W is not recognize in the running Application, while other simple USB Sticks are!

It is recognized on the "OS level" but not within the application - which can not be debugged nor changed. However, the USB Stick is recognized fine.

So as it is still not recognized, I followed Change Raspberry Pi Zero USB Gadget name from Linux File-Stor Gadget and tried to configured it like a working KINGSTON USB Stick. This also worked fine on Windows, Linux, .. but still same situation - not recognized on the target device/application.

lsusb -v shows almost the same output compared to a HW USB Stick that was recognized.

Zero W device - not recognized

Bus 001 Device 004: ID 0930:6545 Toshiba Corp. Kingston DataTraveler 102/2.0 / HEMA Flash Drive 2 GB / PNY Attache 4GB Stick
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x0930 Toshiba Corp.
  idProduct          0x6545 Kingston DataTraveler 102/2.0 / HEMA Flash Drive 2 GB / PNY Attache 4GB Stick
  bcdDevice            1.10
  iManufacturer           1
  iProduct                2
  iSerial                 3
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0020
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          4
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         8 Mass Storage
      bInterfaceSubClass      6 SCSI
      bInterfaceProtocol     80 Bulk-Only
      iInterface              5
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               1

Recognized USB Stick

Bus 001 Device 005: ID 090c:1000 Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.) Flash Drive
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x090c Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.)
  idProduct          0x1000 Flash Drive
  bcdDevice           11.00
  iManufacturer           1
  iProduct                2
  iSerial                 3
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0020
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         8 Mass Storage
      bInterfaceSubClass      6 SCSI
      bInterfaceProtocol     80 Bulk-Only
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval             255
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval             255

However, Windows SDK USB Device Viewer shows the following for the mass storage

[Port2]  :  USB Mass Storage Device

Is Port User Connectable: no Is Port Debug Capable: no Companion Port Number: 0 Companion Hub Symbolic Link Name: Protocols Supported: USB 1.1: yes USB 2.0: yes USB 3.0: no

Device Power State: PowerDeviceD0

   ---===>Device Information<===---

English product name: "DataTraveler"

ConnectionStatus:
Current Config Value: 0x01 -> Device Bus Speed: High (is not SuperSpeed or higher capable) Device Address: 0x34 Open Pipes: 2

      ===>Device Descriptor<===

bLength: 0x12 bDescriptorType: 0x01 bcdUSB: 0x0200 bDeviceClass: 0x00 -> This is an Interface Class Defined Device bDeviceSubClass: 0x00 bDeviceProtocol: 0x00 bMaxPacketSize0: 0x40 = (64) Bytes idVendor: 0x0930 = Toshiba Corporation idProduct: 0x6545 bcdDevice: 0x0110 iManufacturer: 0x01 English (United States) "Kingston" German (Standard) "Kingston" iProduct: 0x02 English (United States) "DataTraveler" German (Standard) "DataTraveler" iSerialNumber: 0x03 English (United States) "94B86DC69273E36020005166" German (Standard) "94B86DC69273E36020005166" bNumConfigurations: 0x01

      ---===>Open Pipes<===---

      ===>Endpoint Descriptor<===

bLength: 0x07 bDescriptorType: 0x05 bEndpointAddress: 0x81 -> Direction: IN - EndpointID: 1 bmAttributes: 0x02 -> Bulk Transfer Type wMaxPacketSize: 0x0200 = 0x200 max bytes bInterval: 0x00

      ===>Endpoint Descriptor<===

bLength: 0x07 bDescriptorType: 0x05 bEndpointAddress: 0x01 -> Direction: OUT - EndpointID: 1 bmAttributes: 0x02 -> Bulk Transfer Type wMaxPacketSize: 0x0200 = 0x200 max bytes bInterval: 0x01

   ---===>Full Configuration Descriptor<===---

      ===>Configuration Descriptor<===

bLength: 0x09 bDescriptorType: 0x02 wTotalLength: 0x0020 -> Validated bNumInterfaces: 0x01 bConfigurationValue: 0x01 iConfiguration: 0x04 English (United States) "0" German (Standard) "1" bmAttributes: 0x80 -> Bus Powered MaxPower: 0x32 = 100 mA

      ===>Interface Descriptor<===

bLength: 0x09 bDescriptorType: 0x04 bInterfaceNumber: 0x00 bAlternateSetting: 0x00 bNumEndpoints: 0x02 bInterfaceClass: 0x08 -> This is a Mass Storage USB Device Interface Class bInterfaceSubClass: 0x06 bInterfaceProtocol: 0x50 iInterface: 0x05 English (United States) "Mass Storage"

      ===>Endpoint Descriptor<===

bLength: 0x07 bDescriptorType: 0x05 bEndpointAddress: 0x81 -> Direction: IN - EndpointID: 1 bmAttributes: 0x02 -> Bulk Transfer Type wMaxPacketSize: 0x0200 = 0x200 max bytes bInterval: 0x00

      ===>Endpoint Descriptor<===

bLength: 0x07 bDescriptorType: 0x05 bEndpointAddress: 0x01 -> Direction: OUT - EndpointID: 1 bmAttributes: 0x02 -> Bulk Transfer Type wMaxPacketSize: 0x0200 = 0x200 max bytes bInterval: 0x01

While the working USB Stick looks like the following:

[Port1]  :  USB Mass Storage Device

Is Port User Connectable: yes Is Port Debug Capable: no Companion Port Number: 1 Companion Hub Symbolic Link Name: USB#VID_05E3&PID_0612#5&17c61b84&0&17#{f18a0e88-c30c-11d0-8815-00a0c906bed8} Protocols Supported: USB 1.1: yes USB 2.0: yes USB 3.0: no

Device Power State: PowerDeviceD0

   ---===>Device Information<===---

English product name: "USB Flash Disk"

ConnectionStatus:
Current Config Value: 0x01 -> Device Bus Speed: High (is not SuperSpeed or higher capable) Device Address: 0x35 Open Pipes: 2

      ===>Device Descriptor<===

bLength: 0x12 bDescriptorType: 0x01 bcdUSB: 0x0200 bDeviceClass: 0x00 -> This is an Interface Class Defined Device bDeviceSubClass: 0x00 bDeviceProtocol: 0x00 bMaxPacketSize0: 0x40 = (64) Bytes idVendor: 0x090C = Silicon Motion, Inc. - Taiwan idProduct: 0x1000 bcdDevice: 0x1100 iManufacturer: 0x01 English (United States) "General" iProduct: 0x02 English (United States) "USB Flash Disk" iSerialNumber: 0x03 English (United States) "04XGF0375YV9FNX3" bNumConfigurations: 0x01

      ---===>Open Pipes<===---

      ===>Endpoint Descriptor<===

bLength: 0x07 bDescriptorType: 0x05 bEndpointAddress: 0x81 -> Direction: IN - EndpointID: 1 bmAttributes: 0x02 -> Bulk Transfer Type wMaxPacketSize: 0x0200 = 0x200 max bytes bInterval: 0xFF

      ===>Endpoint Descriptor<===

bLength: 0x07 bDescriptorType: 0x05 bEndpointAddress: 0x02 -> Direction: OUT - EndpointID: 2 bmAttributes: 0x02 -> Bulk Transfer Type wMaxPacketSize: 0x0200 = 0x200 max bytes bInterval: 0xFF

   ---===>Full Configuration Descriptor<===---

      ===>Configuration Descriptor<===

bLength: 0x09 bDescriptorType: 0x02 wTotalLength: 0x0020 -> Validated bNumInterfaces: 0x01 bConfigurationValue: 0x01 iConfiguration: 0x00 bmAttributes: 0x80 -> Bus Powered MaxPower: 0xFA = 500 mA

      ===>Interface Descriptor<===

bLength: 0x09 bDescriptorType: 0x04 bInterfaceNumber: 0x00 bAlternateSetting: 0x00 bNumEndpoints: 0x02 bInterfaceClass: 0x08 -> This is a Mass Storage USB Device Interface Class bInterfaceSubClass: 0x06 bInterfaceProtocol: 0x50 iInterface: 0x00

      ===>Endpoint Descriptor<===

bLength: 0x07 bDescriptorType: 0x05 bEndpointAddress: 0x81 -> Direction: IN - EndpointID: 1 bmAttributes: 0x02 -> Bulk Transfer Type wMaxPacketSize: 0x0200 = 0x200 max bytes bInterval: 0xFF

      ===>Endpoint Descriptor<===

bLength: 0x07 bDescriptorType: 0x05 bEndpointAddress: 0x02 -> Direction: OUT - EndpointID: 2 bmAttributes: 0x02 -> Bulk Transfer Type wMaxPacketSize: 0x0200 = 0x200 max bytes bInterval: 0xFF

So the main difference seems to me that No Symbolic Link Name was generate, and "Is Port User Connectable" are set by the working USB stick. However, I have no clue how this is set and why.

Port1]  :  USB Mass Storage Device

Is Port User Connectable: yes Is Port Debug Capable: no Companion Port Number: 1 Companion Hub Symbolic Link Name: USB#VID_05E3&PID_0612#5&17c61b84&0&17#{f18a0e88-c30c-11d0-8815-00a0c906bed8}

Many thanks up front for your thoughts!

1 Answers1

2

I found the issue why it was not recognized. Problem was the image file. It did not contain a partition.

I found this in the message file of another rasperry pi when I connected the it, and compared it with the messages from the working stick.

It showed "sda:" only and not "sda: sda1" as with the working one.

Feb 17 11:14:59 raspberrypi kernel: [57675.026460] usb 1-1.3: new high-speed USB device number 27 using xhci_hcd
Feb 17 11:15:00 raspberrypi kernel: [57675.127408] usb 1-1.3: New USB device found, idVendor=0781, idProduct=5572, bcdDevice= 1.1a
Feb 17 11:15:00 raspberrypi kernel: [57675.127416] usb 1-1.3: New USB device strings: Mfr=3, Product=4, SerialNumber=5
Feb 17 11:15:00 raspberrypi kernel: [57675.127421] usb 1-1.3: Product: Cruzer Switch
Feb 17 11:15:00 raspberrypi kernel: [57675.127425] usb 1-1.3: Manufacturer: SanDisk
Feb 17 11:15:00 raspberrypi kernel: [57675.127430] usb 1-1.3: SerialNumber: 1234567890
Feb 17 11:15:00 raspberrypi kernel: [57675.129371] usb-storage 1-1.3:1.0: USB Mass Storage device detected
Feb 17 11:15:00 raspberrypi kernel: [57675.129656] scsi host0: usb-storage 1-1.3:1.0
Feb 17 11:15:00 raspberrypi mtp-probe: checking bus 1, device 27: "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.3"
Feb 17 11:15:00 raspberrypi mtp-probe: bus: 1, device: 27 was not an MTP device
Feb 17 11:15:00 raspberrypi mtp-probe: checking bus 1, device 27: "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.3"
Feb 17 11:15:00 raspberrypi mtp-probe: bus: 1, device: 27 was not an MTP device
Feb 17 11:15:01 raspberrypi kernel: [57676.155130] scsi 0:0:0:0: Direct-Access     Linux    File-Stor Gadget 0510 PQ: 0 ANSI: 2
Feb 17 11:15:01 raspberrypi kernel: [57676.155434] sd 0:0:0:0: Attached scsi generic sg0 type 0
Feb 17 11:15:01 raspberrypi kernel: [57676.158811] sd 0:0:0:0: Power-on or device reset occurred
Feb 17 11:15:01 raspberrypi kernel: [57676.159728] sd 0:0:0:0: [sda] 4194304 512-byte logical blocks: (2.15 GB/2.00 GiB)
Feb 17 11:15:01 raspberrypi kernel: [57676.159956] sd 0:0:0:0: [sda] Write Protect is off
Feb 17 11:15:01 raspberrypi kernel: [57676.160495] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
Feb 17 11:15:01 raspberrypi kernel: [57676.184522]  sda:
Feb 17 11:15:01 raspberrypi kernel: [57676.187085] sd 0:0:0:0: [sda] Attached SCSI removable disk
Feb 17 11:15:16 raspberrypi kernel: [57691.847168] usb 1-1.3: USB disconnect, device number 27
Feb 17 11:15:16 raspberrypi kernel: [57691.849264] sd 0:0:0:0: [sda] Synchronizing SCSI cache
Feb 17 11:15:16 raspberrypi kernel: [57691.849505] sd 0:0:0:0: [sda] Synchronize Cache(10) failed: Result: hostbyte=0x01 driverbyte=0x00

So i followed the steps to generate the image file from USB Gadget: Mass Storage Emulation which generates a partition within the storage file.

And now it is recognized also by the application.