• Not Answered

USB in Peripheral / Device Mode - MassStorrage working partially

Hello,

first - is this question better to be asked in the "linux-usb" mailing list? Because I cannot see, if it's a general problem with the g_file_storage gadget or a TI / Integra problem.

Generally USB is working - at least with the g_ether gadget, which provides Ethernet access over USB. But when mounting a backing file via the mass storage gadget, I get freezes of my Windows applications ( windows explorer, editor, etc).

My environment:

I'm using the kernel "linux-2.6.34-psp04.00.00.07" from the EVM SD card. I ve enabled the USB Peripheral Driver mode with

CONFIG_USB_SUPPORT=y
CONFIG_USB_ARCH_HAS_HCD=y
CONFIG_USB_ARCH_HAS_OHCI=y
CONFIG_USB_ARCH_HAS_EHCI=y
CONFIG_USB_MUSB_HDRC=m
CONFIG_USB_MUSB_SOC=y
CONFIG_USB_MUSB_PERIPHERAL=y
CONFIG_USB_GADGET_MUSB_HDRC=y
CONFIG_USB_TI_CPPI41_DMA=y
CONFIG_USB_MUSB_DEBUG=y

#
# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
#
CONFIG_USB_GADGET=m
CONFIG_USB_GADGET_DEBUG=y
CONFIG_USB_GADGET_DEBUG_FILES=y
CONFIG_USB_GADGET_DEBUG_FS=y
CONFIG_USB_GADGET_VBUS_DRAW=2
CONFIG_USB_GADGET_SELECTED=y
CONFIG_USB_GADGET_DUALSPEED=y
CONFIG_USB_ETH=m
CONFIG_USB_ETH_RNDIS=y
CONFIG_USB_ETH_EEM=y
CONFIG_USB_FILE_STORAGE=m
CONFIG_USB_FILE_STORAGE_TEST=y

The file storage gadget is loaded via

# modprobe g_file_storage file=/mnt/backing_file.iso removeable=1 stall=0 ro=0
g_file_storage gadget: File-backed Storage Gadget, version: 20 November 2008
g_file_storage gadget: Number of LUNs=1
g_file_storage gadget-lun0: ro=0, file: /mnt/backing_file.iso

First question: I spend a long time, until I found a mailing list entry, which states that Windows only mounts the mass storage when using "removeable=1 stall=0" as modprobe flags. Is this a problem, caused by the TI hardware - or something gadget specific?

Now when compiling the gadgets with DEBUG, and comparing a successful write operation with an unsuccessful one, I have these differences. First the successful write:

Jan  1 00:02:32 user.debug : g_file_storage gadget: SCSI command: PREVENT-ALLOW MEDIUM REMOVAL;  Dc=6, Dn=0;  Hc=6, Hn=0
     [...]
Jan  1 00:02:32 user.debug : g_file_storage gadget: SCSI command: WRITE(10);  Dc=10, Do=2048;  Hc=10, Ho=2048
Jan  1 00:02:32 user.debug : g_file_storage gadget: bulk_out_complete --> 0, 512/2048
Jan  1 00:02:33 user.debug : g_file_storage gadget-lun0: file write 512 @ 155648 -> 512
Jan  1 00:02:33 user.debug : g_file_storage gadget: bulk-in, length 13:
Jan  1 00:02:33 user.debug : 00000000: 55 53 42 53 28 54 8e 87 00 06 00 00 00
Jan  1 00:02:33 user.debug : g_file_storage gadget: bulk_out_complete --> 0, 512/31
Jan  1 00:02:33 user.debug : g_file_storage gadget: invalid CBW: len 512 sig 0x53425355
Jan  1 00:02:33 user.debug : g_file_storage gadget: bulk-in set wedge
Jan  1 00:02:33 user.debug : g_file_storage gadget: delayed bulk-in endpoint wedge

Jan  1 00:02:33 user.debug : g_file_storage gadget: bulk_out_complete --> 0, 512/31
Jan  1 00:02:33 user.debug : g_file_storage gadget: bulk_out_complete --> 0, 512/31
Jan  1 00:02:33 user.debug : g_file_storage gadget: disconnect or port reset
Jan  1 00:02:33 user.debug : g_file_storage gadget: bulk-out, length 0:
Jan  1 00:02:33 user.debug : g_file_storage gadget: bulk_out_complete --> -104, 0/31
Jan  1 00:02:33 user.debug : g_file_storage gadget: reset config
Jan  1 00:02:33 user.debug : g_file_storage gadget: reset interface
Jan  1 00:02:33 user.debug : g_file_storage gadget: ep0-setup, length 8:
Jan  1 00:02:33 user.debug : 00000000: 80 06 00 01 00 00 40 00
Jan  1 00:02:33 user.debug : g_file_storage gadget: get device descriptor
Jan  1 00:02:33 user.debug : g_file_storage gadget: ep0-in, length 18:
Jan  1 00:02:33 user.debug : 00000000: 12 01 00 02 00 00 00 40 25 05 a5 a4 16 03 01 02
Jan  1 00:02:33 user.debug : 00000010: 03 01
Jan  1 00:02:33 user.debug : g_file_storage gadget: disconnect or port reset
Jan  1 00:02:33 user.debug : g_file_storage gadget: ep0-setup, length 8:
Jan  1 00:02:33 user.debug : 00000000: 80 06 00 01 00 00 12 00
Jan  1 00:02:33 user.debug : g_file_storage gadget: get device descriptor
Jan  1 00:02:33 user.debug : g_file_storage gadget: ep0-in, length 18:
Jan  1 00:02:33 user.debug : 00000000: 12 01 00 02 00 00 00 40 25 05 a5 a4 16 03 01 02
Jan  1 00:02:33 user.debug : 00000010: 03 01
Jan  1 00:02:33 user.debug : g_file_storage gadget: ep0-setup, length 8:
Jan  1 00:02:33 user.debug : 00000000: 00 09 01 00 00 00 00 00
Jan  1 00:02:33 user.debug : g_file_storage gadget: set configuration
Jan  1 00:02:33 user.debug : g_file_storage gadget: set interface 0
Jan  1 00:02:33 user.debug : musb_hdrc periph: enabled ep1in for bulk IN, dma, maxpacket 512
Jan  1 00:02:33 user.debug : musb_hdrc periph: enabled ep1out for bulk OUT, dma, maxpacket 512
Jan  1 00:02:33 user.info  : g_file_storage gadget: high speed config #1
Jan  1 00:02:33 user.debug : g_file_storage gadget: bulk-out, length 31:
Jan  1 00:02:33 user.debug : 00000000: 55 53 42 43 28 54 8e 87 00 02 00 00 00 00 0a 2a
Jan  1 00:02:33 user.debug : 00000010: 00 00 00 01 34 00 00 01 00 00 00 00 00 00 00
Jan  1 00:02:33 user.debug : g_file_storage gadget: SCSI command: WRITE(10);  Dc=10, Do=512;  Hc=10, Ho=512
Jan  1 00:02:33 user.debug : g_file_storage gadget: sending command-failure status
Jan  1 00:02:33 user.debug : g_file_storage gadget:   sense data: SK x06, ASC x29, ASCQ x00;  info x0
Jan  1 00:02:33 user.debug : g_file_storage gadget: bulk-in, length 13:
Jan  1 00:02:33 user.debug : 00000000: 55 53 42 53 28 54 8e 87 00 02 00 00 01
Jan  1 00:02:33 user.debug : g_file_storage gadget: bulk-out, length 31:
Jan  1 00:02:33 user.debug : 00000000: 55 53 42 43 28 54 8e 87 12 00 00 00 80 00 0c 03
Jan  1 00:02:33 user.debug : 00000010: 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00
Jan  1 00:02:33 user.debug : g_file_storage gadget: SCSI command: REQUEST SENSE;  Dc=6, Di=18;  Hc=12, Hi=18
Jan  1 00:02:33 user.debug : g_file_storage gadget: REQUEST SENSE is buggy! Expected length 6 but we got 12
Jan  1 00:02:33 user.debug : g_file_storage gadget: bulk-in, length 18:
Jan  1 00:02:33 user.debug : 00000000: 70 00 06 00 00 00 00 0a 00 00 00 00 29 00 00 00
Jan  1 00:02:33 user.debug : 00000010: 00 00
Jan  1 00:02:33 user.debug : g_file_storage gadget: bulk-in, length 13:
Jan  1 00:02:33 user.debug : 00000000: 55 53 42 53 28 54 8e 87 00 00 00 00 00
Jan  1 00:02:33 user.debug : g_file_storage gadget: bulk-out, length 31:
Jan  1 00:02:33 user.debug : 00000000: 55 53 42 43 28 54 8e 87 00 02 00 00 00 00 0a 2a
Jan  1 00:02:33 user.debug : 00000010: 00 00 00 01 34 00 00 01 00 00 00 00 00 00 00
Jan  1 00:02:33 user.debug : g_file_storage gadget: SCSI command: WRITE(10);  Dc=10, Do=512;  Hc=10, Ho=512
Jan  1 00:02:33 user.debug : g_file_storage gadget-lun0: file write 512 @ 157696 -> 512
Jan  1 00:02:33 user.debug : g_file_storage gadget: bulk-in, length 13:
Jan  1 00:02:33 user.debug : 00000000: 55 53 42 53 28 54 8e 87 00 00 00 00 00
Jan  1 00:02:33 user.debug : g_file_storage gadget: bulk-out, length 31:
Jan  1 00:02:33 user.debug : 00000000: 55 53 42 43 30 c1 7c 87 00 00 00 00 00 00 06 00
Jan  1 00:02:33 user.debug : 00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

And second the un-successful one:

Jan  1 00:03:12 user.debug : g_file_storage gadget: SCSI command: PREVENT-ALLOW MEDIUM REMOVAL;  Dc=6, Dn=0;  Hc=6, Hn=0
     [...]
Jan  1 00:03:12 user.debug : g_file_storage gadget: SCSI command: WRITE(10);  Dc=10, Do=4096;  Hc=10, Ho=4096
Jan  1 00:03:12 user.debug : g_file_storage gadget: bulk_out_complete --> 0, 512/2048
Jan  1 00:03:12 user.debug : g_file_storage gadget: bulk_out_complete --> 0, 512/2048
Jan  1 00:03:12 user.debug : g_file_storage gadget-lun0: file write 512 @ 137216 -> 512
Jan  1 00:03:12 user.debug : g_file_storage gadget: bulk-in, length 13:
Jan  1 00:03:12 user.debug : 00000000: 55 53 42 53 28 54 8e 87 00 0e 00 00 00
Jan  1 00:03:12 user.debug : g_file_storage gadget: bulk_out_complete --> 0, 512/31
Jan  1 00:03:12 user.debug : g_file_storage gadget: invalid CBW: len 512 sig 0x7942
Jan  1 00:03:12 user.debug : g_file_storage gadget: bulk-in set wedge
Jan  1 00:03:12 user.debug : g_file_storage gadget: delayed bulk-in endpoint wedge


#########################################################################
### Thu Jan  1 00:03:48 UTC 1970 ###
### No response of Editor ###
#########################################################################

Jan  1 00:04:12 user.debug : g_file_storage gadget: disconnect or port reset
Jan  1 00:04:12 user.debug : g_file_storage gadget: reset config
Jan  1 00:04:12 user.debug : g_file_storage gadget: reset interface
Jan  1 00:04:12 user.debug : g_file_storage gadget: ep0-setup, length 8:
Jan  1 00:04:12 user.debug : 00000000: 80 06 00 01 00 00 40 00

How to make the mass storrage work? Are there improvements in the new kernel (with new drivers)? (Since I have the same problem as Lee Holeva (http://e2e.ti.com/support/dsp/integra_dsparm/f/625/t/111631.aspx) I cannot use the new kernel.)

Best regards,

Charly

3 Replies

  • Further investigations ( "echo 100 > /sys/module/musb_hdrc/parameters/debug" ) brought this output during this 1 second blackout:

    Jan  1 02:49:03 user.debug : musb_gadget_set_halt 1274: FIFO busy, cannot halt ep1in
    Jan  1 02:49:03 user.debug : set_wedge(ep) returned -11
    Jan  1 02:49:03 user.debug : musb_gadget_set_halt 1274: FIFO busy, cannot halt ep1in
    Jan  1 02:49:03 user.debug : set_wedge(ep) returned -11
    Jan  1 02:49:03 user.debug : musb_gadget_set_halt 1274: FIFO busy, cannot halt ep1in
    Jan  1 02:49:03 user.debug : set_wedge(ep) returned -11

    in code at:

            /* Cannot portably stall with non-empty FIFO */
            if (musb_ep->is_in) {
                csr = musb_readw(epio, MUSB_TXCSR);
                if (csr & MUSB_TXCSR_FIFONOTEMPTY) {
                    DBG(3, "FIFO busy, cannot halt %s\n", ep->name);
                    status = -EAGAIN;
                    goto done;
                }
            }

    This error message comes from "u16 musb_readw(const void __iomem *addr, unsigned offset)" which is defined in drivers/usb/musb/ti816x.c.

    /* ti8167 specific read/write functions */
    u16 musb_readw(const void __iomem *addr, unsigned offset)
    {
        u32 tmp;
        u16 val;

        tmp = __raw_readl(addr + (offset & ~3));

        switch (offset & 0x3) {
            [...]
        }
        return val;
    }

    Is this a known problem?

     

  • In reply to Karl Krach:

    Hmmm... I downloaded tag "TI816XPSP4.00.00.11" from ARGO project, and there g_ether and g_file_storage is working - but g_multi still fails (even the mass storage part). Is there a recommendation, which PSP to use with which evaluation module?

     

     

  • In reply to Karl Krach:

    Karl

    Some controllers there is a issue with setting the halt on bulk-in endpoints. Halting the bulk-in endpoints by gadget file storage driver causes the endpoint's Tx fifo to flush the data, but when DMA mode is enabled,  the DMA continue to send the send data endpoint and causing the endpoint Fifo Not empty condition.

    Have you tried with PIO mode, whether do you see the similar issue.

    Regards

    Ravi B