On Mon, Jun 5, 2017 at 9:52 PM, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote: > [Please use Reply-To-All so that your message gets sent to the mailing > list as well as to me.] Oops, apologies - now done! > On Mon, 5 Jun 2017, Alan Robertson wrote: > >> On Mon, Jun 5, 2017 at 3:02 PM, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote: >> > On Sun, 4 Jun 2017, Alan Robertson wrote: >> > >> >> Hi >> >> >> >> Apologies for my first post here being a request for help, but after >> >> extensive searching online I've not yet been able to find and answer >> >> and am hopeful the expertise here may be able to help! >> >> >> >> I have a Raspberry Pi Zero W that I'm using in OTG/gadget mode. I've >> >> activated dwc2 USB, partitioned and formatted the file that is to be >> >> used as filesystem and loaded g_mass_storage. >> >> >> >> It is working fine in Windows - I can connect and see the contents, >> >> add/delete files, eject and reconnect seeing changes fine. I can mount >> >> it in Raspbian to check contents and can also attach it to other >> >> devices and interact with it fine. >> >> >> >> However, I've got some devices that are very picky about what USB >> >> devices they will connect to (solely flash drives). The problem is the >> >> OTG mass storage gadget is being identified as "File-Stor Gadget (Rev: >> >> 0404)" for device type, which is causing it to be rejected. >> >> >> >> I can successfully use a USB flash drive in the target devices and >> >> have scraped the vendor/product ID, etc from this flash drive to see >> >> if I can mimic them via g_mass_storage. >> >> >> >> I have adjusted modprobe to the following: >> >> >> >> $ sudo modprobe g_mass_storage file=/home/pi/piusb.bin stall=0 >> >> removable=1 idVendor=0x0781 idProduct=0x5572 bcdDevice=0x011a > > I should point out that this bcdDevice value is not valid (it isn't a > binary-coded-decimal value). Thanks, now corrected to 0x0126 - this seems to show up OK in lsusb as 1.26 now >> >> iManufacturer="SanDisk" iProduct="Cruzer Switch" >> >> iSerialNumber="123456789012" >> >> >> >> Unfortunately this doesn't seem to have made any difference and it is >> >> still rejected by the target devices. >> >> >> >> As far as I can tell the above parameters are getting passed through correctly >> >> $ ls /sys/module/g_mass_storage/parameters/* >> >> /sys/module/g_mass_storage/parameters/bcdDevice >> >> /sys/module/g_mass_storage/parameters/cdrom >> >> /sys/module/g_mass_storage/parameters/file >> >> /sys/module/g_mass_storage/parameters/idProduct >> >> /sys/module/g_mass_storage/parameters/idVendor >> >> /sys/module/g_mass_storage/parameters/iManufacturer >> >> /sys/module/g_mass_storage/parameters/iProduct >> >> /sys/module/g_mass_storage/parameters/iSerialNumber >> >> /sys/module/g_mass_storage/parameters/luns >> >> /sys/module/g_mass_storage/parameters/nofua >> >> /sys/module/g_mass_storage/parameters/removable >> >> /sys/module/g_mass_storage/parameters/ro >> >> /sys/module/g_mass_storage/parameters/stall >> >> >> >> $ cat /sys/module/g_mass_storage/parameters/* >> >> 282 >> >> /home/pi/piusb.bin >> >> 21874 >> >> 1921 >> >> SanDisk >> >> Cruzer_Switch >> >> 123456789012 >> >> 0 >> >> Y >> >> N >> >> >> >> However when connecting to Windows, here's what the USB mass storage >> >> displays - it appears that the iSerialNumber is making it through, but >> >> nothing else is being altered. My router shows similar issues, >> >> identifying it as "File-Stor Gadget (Rev: 0404)" >> >> >> >> USBSTOR\DISK&VEN_LINUX&PROD_FILE-STOR_GADGET&REV_0404\123456789012&0 > > It looks like Windows is remembering an earlier version of your gadget > and matching it with the current version based on the serial number > string. I've changed the SN and still getting it showing as 'File-Stor Gadget' on Linux, Windows, router >> >> USBSTOR\DiskLinux___File-Stor_Gadget0404 >> >> USBSTOR\DiskLinux___File-Stor_Gadget >> >> USBSTOR\DiskLinux___ >> >> USBSTOR\Linux___File-Stor_Gadget0 >> >> Linux___File-Stor_Gadget0 >> >> USBSTOR\GenDisk >> >> GenDisk >> >> >> >> By comparison, here's what SanDisk shows: >> >> >> >> USBSTOR\DISK&VEN_SANDISK&PROD_CRUZER_SWITCH&REV_1.26\4C532015741508522393&0 >> >> USBSTOR\DiskSanDisk_Cruzer_Switch___1.26 >> >> USBSTOR\DiskSanDisk_Cruzer_Switch___ >> >> USBSTOR\DiskSanDisk_ >> >> USBSTOR\SanDisk_Cruzer_Switch___1 >> >> SanDisk_Cruzer_Switch___1 >> >> USBSTOR\GenDisk >> >> GenDisk >> > >> > Never mind Windows -- if you connect your gadget to a computer running >> > Linux, what does "lsusb -v" show? >> > >> > Alan Stern >> > >> Thanks for the reply, Alan. >> >> Can provide the full output if it would help, but relevant part seems >> to be the below: >> >> Bus 001 Device 004: ID 0781:5572 SanDisk Corp. >> Device Descriptor: >> bLength 18 >> bDescriptorType 1 >> bcdUSB 2.00 >> bDeviceClass 0 (Defined at Interface level) >> bDeviceSubClass 0 >> bDeviceProtocol 0 >> bMaxPacketSize0 64 >> idVendor 0x0781 SanDisk Corp. >> idProduct 0x5572 >> bcdDevice 1.1a >> iManufacturer 3 SanDisk >> iProduct 4 Cruzer_Switch >> iSerial 5 123456789012 >> bNumConfigurations 1 >> Configuration Descriptor: >> bLength 9 >> bDescriptorType 2 >> wTotalLength 32 >> bNumInterfaces 1 >> bConfigurationValue 1 >> iConfiguration 0 >> bmAttributes 0xc0 >> Self Powered >> MaxPower 2mA >> Interface Descriptor: >> bLength 9 >> bDescriptorType 4 >> bInterfaceNumber 0 >> bAlternateSetting 0 >> bNumEndpoints 2 >> bInterfaceClass 8 Mass Storage >> bInterfaceSubClass 6 SCSI >> bInterfaceProtocol 80 Bulk-Only >> iInterface 1 Mass Storage >> 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 >> Device Qualifier (for other device speed): >> bLength 10 >> bDescriptorType 6 >> bcdUSB 2.00 >> bDeviceClass 0 (Defined at Interface level) >> bDeviceSubClass 0 >> bDeviceProtocol 0 >> bMaxPacketSize0 64 >> bNumConfigurations 1 >> Device Status: 0x0000 >> (Bus Powered) > > This all seems to be valid, except for the bcdDevice value. Does the 3/4/5 (vs 1/2/3) number of iManufac/Prod/Serial matter at all? >> I also ran the comparison with the original SanDisk drive that works >> in target devices. The lines that have differences in the original >> compared to the USB gadget are as below: >> >> bcdDevice 1.26 [1.1a above] >> iManufacturer 1 SanDisk [has a 3 rather than 1] >> iProduct 2 Cruzer Switch [has a 4 rather than 2] >> iSerial 3 4C532015970328112493 [has a 5 rather than >> 3, plus obviously different SN] >> >> bmAttributes 0x80 [I can see why this happens, not sure much >> can be done about it though?] >> (Bus Powered) >> >> MaxPower 200mA [same] >> >> Interface Descriptor: >> iInterface 0 [this is 1 Mass Storage for gadget] >> >> Endpoint Descriptor: >> bEndpointAddress 0x02 EP 2 OUT [not sure if this is relevant] > > I shouldn't think these small differences would matter. > >> So overall it does seem to be passing across variables, however it is >> still appearing slightly differently - for example the mention of >> 'File-Stor Gadget' appears in Ubuntu and in my Linux-based router. >> Plus the devices I'm trying to use it on run a mix of Linux and >> Windows Embedded, thus the File-Stor Gadget vs USB flash drive >> appearance still seems to be confusing them... >> >> Any thoughts/suggestions? > > Try changing bcdDevice to a valid number, and change the serial number > string to something different from what you were using before. Have changed both and also cleared Windows USB cache with DriveCleanup from www.uwe-sieber.de (which forces redetection). Eject removable media is showing as Cruzer Switch, but it is still showing as "Linux File-Stor Gadget USB Device" in device manager (and as File-Stor on other non-Windows devices I tried). I'm guessing we've now changed all that's changeable with g_mass_storage but happy to take any further suggestions! - something is still making it appear subtly different to systems cf a native USB flash drive :( Alan -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html