This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Unable to get USB Massstorage Gadget to work (USB Peripheral)

Hello,

I'm using the TI814X PG2.1 with the latest EZSDK (5_05_01_04) and cannot bring the file_storage to live. I'm loading the following modules:

insmod musb_hdrc.ko
insmod cppi41dma.ko
insmod nop-usb-xceiv.ko
insmod ti81xx.ko
insmod g_file_storage.ko file=/dev/mmcblk0p7 stall=0 removable=1

/dev/mmcblk0p7 is a non-mounted vFat partition. J23 is unplugged while J22 is plugged - it's not working on both connectors. I'm booting a kernel with only peripheral mode configured - when booting a kernel with only host-mode, the connected USB-stick can be accessed - thus the HW is working.

My problem is right now, that the module runs into sleep_thread() and doesn't recover:

# insmod g_file_storage.ko file=/dev/mmcblk0p7 stall=0 removable=1
fsg: fsg_init
fsg: fsg_alloc
musb_g.c: usb_gadget_probe_driver - start
musb_g.c: usb_gadget_probe_driver - driver id=0
musb_g.c: usb_gadget_probe_driver - retval=0
fsg: fsg_bind
fsg: check_parameters
g_file_storage gadget: No serial-number string provided!
g_file_storage gadget: File-backed Storage Gadget, version: 1 September 2010
g_file_storage gadget: Number of LUNs=1
g_file_storage gadget-lun0: ro=0, nofua=0, file: /dev/mmcblk0p7
musb_gadget.c: CALL musb_start!
musb_core.c: musb_start !!!
musb_core.h: musb_platform_enable
musb_gadget.c: probe driver returns 0
fsg: fsg_init finished with 0
fsg: fsg_main_thread
fsg: main_thread going to sleep
fsg: sleep_thread - start
fsg: sleep_thread - loop
#

I also tried to figure out, who could wakeup the thread - e.g. a bulk_in_complete or an exception. So I checked the interrupts (e.g. ti81xx_interrupt() from ti81xx.c) and none is called.

Anyone has an idea what's wrong in my configuration?

Thanks a lot,

Charly

PS: I followed the wiki about "MUSB controller in gadget mode" and "USB-ID pin configuration selection for TI81XX".

  • With the help of section "One port as host and other port as Gadget" I figured out, that the JUMPERs (J22 and J23) play an important role in my problem above. Right now I got the gadgets only running when setting "TI81XX usb connector's ID pin control" to "from software settings":

    Disabled "Support for Host-side USB"

    With disabled "Support for Host-side USB" the "Driver Mode" is set to "USB Peripheral". In this case only USB0 can be used. In TI8148-EMV's default configuration the jumper J22 is set, so USB0 cannot be used in "Peripheral Mode". Solution: Remove Jumper J22, reboot device and connect USB0 to your PC.

    Enabled "Support for Host-side USB"

    With enabled "Support for Host-side USB" the "Driver Mode" is set to "Both host and peripheral: USB OTG (On The Go) Device". In this case I configured USB0 to "Host Mode" (so Jumper J22 can stay) and USB1 to "Device Mode".

    In this case, we have to load first (on USB0) a g_zero gadget and afterwards our g_file_storage module:

    BACKING2=/root/data/backing_file_filestorage

    insmod usbcore.ko
    insmod musb_hdrc.ko
    insmod cppi41dma.ko
    insmod nop-usb-xceiv.ko
    insmod ti81xx.ko
    insmod usb-storage.ko
    insmod g_zero.ko
    insmod g_file_storage.ko file=${BACKING2} stall=0 removable=1

    When configuring "Device Mode" twice, you have to load "m_mass_storage" instead of "g_zero". Also you have to remove BOTH JUMPERS (J22 and J23).

    Further more I have figured out, that this tutorial about creating the backing-file does not fit to the best results. Instead I only created a file from /dev/zero (e.g. with "dd bs=1M count=64 if=/dev/zero of=/root/data/backing_file") and connected it to windows. There I formatted my "Removable Disk". This can be mounted with "mount -t loop /root/data/backing_file /mnt/xxx".