[kernel] USB OTG as Mass Storage Device #35

Closed
adam-lee opened this Issue Mar 27, 2014 · 21 comments

3 participants

@adam-lee

Verifying USB OTG as mass storage device

On Overo + Palo35

root@overo:~$  modprobe g_mass_storage file=/dev/mmcblk0   
mmcblk0    mmcblk0p1  mmcblk0p2  
root@overo:~$  modprobe g_mass_storage file=/dev/mmcblk0p1
[   30.634552]  gadget: Mass Storage Function, version: 2009/09/11
[   30.644592]  gadget: Number of LUNs=1
[   30.648468]  lun0: LUN: removable file: /dev/mmcblk0p1
[   30.658966]  gadget: Mass Storage Gadget, version: 2009/09/11
[   30.665008]  gadget: userspace failed to provide iSerialNumber
[   30.677001]  gadget: g_mass_storage ready
[   30.693756] musb-hdrc musb-hdrc: MUSB HDRC host driver
[   30.707855] musb-hdrc musb-hdrc: new USB bus registered, assigned bus number 2
[   30.723022] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002
[   30.734313] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[   30.752532] usb usb2: Product: MUSB HDRC host driver
[   30.757781] usb usb2: Manufacturer: Linux 3.5.7-yocto-standard musb-hcd
[   30.770996] usb usb2: SerialNumber: musb-hdrc
[   30.784271] hub 2-0:1.0: USB hub found
[   30.788238] hub 2-0:1.0: 1 port detected
root@overo:~$  [   40.637664]  gadget: high-speed config #1: Linux File-Backed Storage

On Host:

[2401884.860017] usb 1-2: new high-speed USB device number 20 using ehci-pci
[2401884.992856] usb 1-2: New USB device found, idVendor=0525, idProduct=a4a5
[2401884.992860] usb 1-2: New USB device strings: Mfr=2, Product=3, SerialNumber=0
[2401884.992862] usb 1-2: Product: Mass Storage Gadget
[2401884.992865] usb 1-2: Manufacturer: Linux 3.5.7-yocto-standard with musb-hdrc
[2401885.000613] usb-storage 1-2:1.0: Quirks match for vid 0525 pid a4a5: 10000
[2401885.000645] scsi10 : usb-storage 1-2:1.0
[2401886.001134] scsi 10:0:0:0: Direct-Access     Linux    File-CD Gadget   0316 PQ: 0 ANSI: 2
[2401886.001940] sd 10:0:0:0: Attached scsi generic sg5 type 0
[2401886.005245] sd 10:0:0:0: [sdf] 130944 512-byte logical blocks: (67.0 MB/63.9 MiB)
[2401886.108632] sd 10:0:0:0: [sdf] Write Protect is off
[2401886.108638] sd 10:0:0:0: [sdf] Mode Sense: 0f 00 00 00
[2401886.109742] sd 10:0:0:0: [sdf] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[2401886.222762]  sdf:
[2401886.335261] sd 10:0:0:0: [sdf] Attached SCSI removable disk
yocto@ruben:/media$ ls
boot  usb_otg_storage
yocto@ruben:/media$ sudo mount /dev/sdf /media/usb_otg_storage/
[sudo] password for yocto: 
yocto@ruben:/media$ ls usb_otg_storage/
MLO  u-boot.img  uImage
yocto@ruben:/media$ 
@adam-lee adam-lee added this to the Yocto Project 1.5 'Dora' milestone Mar 27, 2014
@adam-lee adam-lee added the Overo label Mar 27, 2014
@adam-lee adam-lee self-assigned this Mar 27, 2014
@adam-lee adam-lee added the question label Mar 27, 2014
@adam-lee

The front USB port on the host computer does not work. It must be a port on the motherboard (at the back of the computer).

@daveti

Awesome! So we do not need special config and the defconfig + g_mass_storage work, right? The root cause may be the front USB port....I was using that all the time...

@adam-lee

@daveti I was getting weird enumeration error from the front side USB port. Let me know!

@daveti

from gumstix~

[  117.255401] udc musb-hdrc: registering UDC driver [g_mass_storage]
[  117.255462]  gadget: adding config #1 'Linux File-Backed Storage'/bf13d680
[  117.255767]  lun0: open backing file: /home/root/daveti.img
[  117.256011]  gadget: Mass Storage Function, version: 2009/09/11
[  117.274444]  gadget: Number of LUNs=1
[  117.278350]  lun0: LUN: removable file: /home/root/daveti.img
[  117.293701]  gadget: I/O thread pid: 176
[  117.293792]  gadget: adding 'Mass Storage Function'/ce09f840 to config 'Linux File-Backed Storage'/bf13d680
[  117.293823]  gadget: cfg 1/bf13d680 speeds: high full
[  117.293853]  gadget:   interface 0 = Mass Storage Function/ce09f840
[  117.293884]  gadget: Mass Storage Gadget, version: 2009/09/11
[  117.305267]  gadget: userspace failed to provide iSerialNumber
[  117.311492]  gadget: g_mass_storage ready
[  117.337921] twl4030_usb twl4030_usb: twl4030_phy_resume
[  117.338012] musb-hdrc musb-hdrc: MUSB HDRC host driver
[  117.353363] musb-hdrc musb-hdrc: new USB bus registered, assigned bus number 2
[  117.369995] musb-hdrc musb-hdrc: supports USB remote wakeup
[  117.370147] usb usb2: default language 0x0409
[  117.370208] usb usb2: udev 1, busnum 2, minor = 128
[  117.370239] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002
[  117.382385] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[  117.398040] usb usb2: Product: MUSB HDRC host driver
[  117.410827] usb usb2: Manufacturer: Linux 3.5.7-yocto-standard musb-hcd
[  117.421997] usb usb2: SerialNumber: musb-hdrc
[  117.437713] usb usb2: usb_probe_device
[  117.440338] usb usb2: configuration #1 chosen from 1 choice
[  117.440429] usb usb2: adding 2-0:1.0 (config #1, interface 0)
[  117.440734] hub 2-0:1.0: usb_probe_interface
[  117.440765] hub 2-0:1.0: usb_probe_interface - got id
[  117.440795] hub 2-0:1.0: USB hub found
[  117.444793] hub 2-0:1.0: 1 port detected
[  117.464294] hub 2-0:1.0: standalone hub
[  117.464355] hub 2-0:1.0: individual port power switching
[  117.464355] hub 2-0:1.0: no over-current protection
[  117.464385] hub 2-0:1.0: Single TT
[  117.464385] hub 2-0:1.0: TT requires at most 8 FS bit times (666 ns)
[  117.464416] hub 2-0:1.0: power on to power good time: 10ms
[  117.464477] hub 2-0:1.0: 100mA bus power budget for each child
[  117.464508] hub 2-0:1.0: local power source is good
[  117.464538] hub 2-0:1.0: enabling power on all ports
[  117.563171] hub 2-0:1.0: state 7 ports 1 chg 0000 evt 0000
[  120.008392] hub 2-0:1.0: hub_suspend
[  120.008453] usb usb2: bus auto-suspend, wakeup 1
[  120.009521] twl4030_usb twl4030_usb: twl4030_phy_suspend
root@overo:/lib/modules/3.5.7-yocto-standard/kernel/drivers/usb/gadget$  

I am using the motherboard usb port still get no luck. I am not sure why hub_suspend happened on gumstix. Is this normal?

@adam-lee

Hmm the timing of when you plug in the usb to your host machine has to be right I think. It's tricky.

I plugged in the cable to the host after I ran the modprobe command. If the cable is already plugged in before I modprobe, I don't think it works.

@daveti

This time, I detached the USB OTG port before I insmod the g_mass_storage but got the same dmesg output. It seems like nothing wrong with my PC side....still doubt if defconfig matters

@daveti

Adam, would you please let me know ur defconfig? Just wanna double confirm I did not mess up with my config....

@adam-lee

@daveti please take a look at the mailing list post. I've posted the image with the kernel configuration.

@adam-lee

@daveti if you've been using insmod, try using modprobe - it's better.

@daveti

Your images do not work for me. That is so weird....anyway modprobe is used. Thanks for ur suggestion.

@adam-lee

I think the hub_suspend is ok - I get that too. The following is the full dmesg since modprobe.

[   60.354309] musb-hdrc musb-hdrc: MUSB HDRC host driver
[   60.370056] musb-hdrc musb-hdrc: new USB bus registered, assigned bus number 2
[   60.386047] musb-hdrc musb-hdrc: supports USB remote wakeup
[   60.386169] usb usb2: default language 0x0409
[   60.386230] usb usb2: udev 1, busnum 2, minor = 128
[   60.386260] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002
[   60.398529] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[   60.413909] usb usb2: Product: MUSB HDRC host driver
[   60.426940] usb usb2: Manufacturer: Linux 3.5.7-yocto-standard musb-hcd
[   60.437561] usb usb2: SerialNumber: musb-hdrc
[   60.453704] usb usb2: usb_probe_device
[   60.453735] usb usb2: configuration #1 chosen from 1 choice
[   60.453857] usb usb2: adding 2-0:1.0 (config #1, interface 0)
[   60.454132] hub 2-0:1.0: usb_probe_interface
[   60.454162] hub 2-0:1.0: usb_probe_interface - got id
[   60.454193] hub 2-0:1.0: USB hub found
[   60.458190] hub 2-0:1.0: 1 port detected
[   60.480194] hub 2-0:1.0: standalone hub
[   60.480224] hub 2-0:1.0: individual port power switching
[   60.480255] hub 2-0:1.0: no over-current protection
[   60.480255] hub 2-0:1.0: Single TT
[   60.480285] hub 2-0:1.0: TT requires at most 8 FS bit times (666 ns)
[   60.480285] hub 2-0:1.0: power on to power good time: 10ms
[   60.480346] hub 2-0:1.0: 100mA bus power budget for each child
[   60.480377] hub 2-0:1.0: local power source is good
[   60.480407] hub 2-0:1.0: enabling power on all ports
[   60.569274] twl4030_usb twl4030_usb: HW_CONDITIONS 0x90/144; link 1
[   60.578887] hub 2-0:1.0: state 7 ports 1 chg 0000 evt 0000
[   60.883941] twl4030_usb twl4030_usb: HW_CONDITIONS 0x50/80; link 0
[   60.884857] twl4030_usb twl4030_usb: twl4030_phy_suspend
[   63.008697] hub 2-0:1.0: hub_suspend
[   63.008758] usb usb2: bus auto-suspend, wakeup 1
[   67.849029] twl4030_usb twl4030_usb: HW_CONDITIONS 0x90/144; link 1
[   67.852050] twl4030_usb twl4030_usb: twl4030_phy_resume
[   68.277435]  gadget: high-speed config #1: Linux File-Backed Storage

Can you check the mode of USB OTG?

on before and after modprobe:

root@overo:/sys/devices/platform/musb-omap2430/musb-hdrc$  cat mode
b_idle

on connection to host:

root@overo:/sys/devices/platform/musb-omap2430/musb-hdrc$  cat mode
b_peripheral
@daveti

Hmm....the mode is always b_idle even after modprobe is done. What is wrong with my overo?

@adam-lee

@daveti b_idle is what's expected until you make a physical connection to a host.

@daveti

That is what happened after I plugged it into my PC....

@adam-lee

@daveti can you try using it as a host (ie, plug in a keyboard into OTG through external usb hub)? b_idle should go to a_idle.

@daveti

Sorry, I do not have such a external usb hub with either OTG interface or female USB intf....

@adam-lee

@daveti I suggest verifying if the hardware is good.

I added basic instruction on how to use the OTG as a mass storage device in the wiki - https://github.com/gumstix/Gumstix-YoctoProject-Repo/wiki

@adam-lee adam-lee closed this Mar 28, 2014
@daveti

Thanks for your time. I have no idea if there is sth wrong either with overo or palo35...Anyway, I have ordered a new overo (airStorm) + summit. Hopefully, this new combination would work. Thanks!

@anupganeshdinho

Can we access the NAND Flash and the DDR RAM on the gumstix using this hack ?

@adam-lee

@anupganeshdinho I'd imagine if you are using the NAND as your primary storage device (ie. flash your system image into NAND and boot from it), then this hack probably works just fine.

@anupganeshdinho

thanks, i'm gonna try that today !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment