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.

L138: Configure USB File Storage into Linux Kernel

Other Parts Discussed in Thread: DA8XX

Ravi B said:

Wong

I do not have ready image with me (as i have verified long back). You can built new uImage with release kernel tree.  You can choose USB Device mode with file storage gadget configuraton (refer to user's guide for info) for storage media you can use either simple file or SATA or NAND.

     insmod g_file_storage.ko file=/mnt/sample.txt stall=0

Regards

Ravi B

Hi Ravi,

Can you show me the exact user's guide that you mentioned ?

I have built the default uImage from DaVinci-PSP-SDK-03.20.00.14 without making any configuration change.

When I connect USB to PC, I see the below message on console.

root@da850-omapl138-evm:~#
root@da850-omapl138-evm:~# da8xx_interrupt 512: Unhandled USB IRQ 00080001
da8xx_interrupt 512: Unhandled USB IRQ 00080001
da8xx_interrupt 512: Unhandled USB IRQ 00080001
musb_stage0_irq 774: unhandled DISCONNECT transition (a_idle)

root@da850-omapl138-evm:~#

 

I try to follow the below WIKI to configure USB Device mode with file storage gadget configuration, there is no such information in this page.

http://processors.wiki.ti.com/index.php/GSG:_Building_Software_Components_for_OMAP-L1/AM1x#USB_2.0

 

rgds,

kc Wong

 

  • I have managed to configure the File-backed storage Gadget and build the g_file_storage.ko module.

    < > Support for Host-side USB

    < > Inventra Highspeed Dual Role Controller (TI, ADI, ...)

    <*> USB Gadget Support  --->

           <M> USB Gadget Drivers

          <M> File-backed Storage Gadget

    I have installed it to the target root file system, but I am not able to load it. Any comment ???

     

    By the way, what is "stall=0" for ???

     

    root@da850-omapl138-evm:/lib/modules/2.6.33-rc4/kernel/drivers/usb/gadget# ls
    g_file_storage.ko

    root@da850-omapl138-evm:/lib/modules/2.6.33-rc4/kernel/drivers/usb/gadget# insmo
    d g_file_storage.ko file=/mnt/sample.txt stall=0
    insmod: error inserting 'g_file_storage.ko': -1 No such device
    root@da850-omapl138-evm:/lib/modules/2.6.33-rc4/kernel/drivers/usb/gadget# insmo
    d ./g_file_storage.ko file=/mnt/sample.txt stall=0
    insmod: error inserting './g_file_storage.ko': -1 No such device

    root@da850-omapl138-evm:/lib/modules/2.6.33-rc4/kernel/drivers/usb/gadget# modpr
    obe g_file_storage.ko file=/mnt/sample.txt stall=0
    FATAL: Module g_file_storage.ko not found.
    root@da850-omapl138-evm:/lib/modules/2.6.33-rc4/kernel/drivers/usb/gadget# modpr
    obe ./g_file_storage.ko file=/mnt/sample.txt stall=0

    FATAL: Module ./g_file_storage.ko not found.

     

    root@da850-omapl138-evm:/lib/modules/2.6.33-rc4/kernel/drivers/usb/gadget# modpr
    obe g_file_storage file=/mnt/sample.txt stall=0
    FATAL: Could not open 'kernel/drivers/usb/gadget/g_file_storage.ko': No such file or directory

    root@da850-omapl138-evm:/lib/modules/2.6.33-rc4/kernel/drivers/usb/gadget# modin
    fo g_file_storage.ko *
    filename:       g_file_storage.ko
    license:        Dual BSD/GPL
    author:         Alan Stern
    description:    File-backed Storage Gadget
    depends:
    vermagic:       2.6.33-rc4 preempt mod_unload modversions ARMv5
    parm:           file:names of backing files or devices (array of charp)
    parm:           ro:true to force read-only (array of bool)
    parm:           luns:number of LUNs (uint)
    parm:           removable:true to simulate removable media (bool)
    parm:           stall:false to prevent bulk stalls (bool)
    parm:           cdrom:true to emulate cdrom instead of disk (bool)
    filename:       g_file_storage.ko
    license:        Dual BSD/GPL
    author:         Alan Stern
    description:    File-backed Storage Gadget
    depends:
    vermagic:       2.6.33-rc4 preempt mod_unload modversions ARMv5
    parm:           file:names of backing files or devices (array of charp)
    parm:           ro:true to force read-only (array of bool)
    parm:           luns:number of LUNs (uint)
    parm:           removable:true to simulate removable media (bool)
    parm:           stall:false to prevent bulk stalls (bool)
    parm:           cdrom:true to emulate cdrom instead of disk (bool)

  • Hello

    Please check, In the insmod command there was spelling mistake for gadget module g_file_storage.ko .

    you need to download the g_file_storage.ko to target.

    Regards

    Ravi B

     

     

  • Ravi B said:

    Please check, In the insmod command there was spelling mistake for gadget module g_file_storage.ko

     

    Ya, I have corrected the spelling mistake, still not able to load.

     

    Ravi B said:

     

    you need to download the g_file_storage.ko to target.

    I have used the below command to download/install the modules into the target file system.

    make modules_install INSTALL_MOD_PATH=/home/kiunwong/workdir/filesys ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-

  • Wong

    You need to create sample file on /mnt directory. use

    dd if=/dev/zero of=/mnt/sample bs=1M count=100

    Regards

    Ravi B

     

  • OK, I have done that, still not able to load. Not sure what has gone wrong ?

     

    root@da850-omapl138-evm:/mnt# ls
    card    cf      net     ram     sample

    root@da850-omapl138-evm:/mnt# cd /lib/modules/2.6.33-rc4/kernel/drivers/usb/gadg
    et
    root@da850-omapl138-evm:/lib/modules/2.6.33-rc4/kernel/drivers/usb/gadget# ls
    g_file_storage.ko

    root@da850-omapl138-evm:/lib/modules/2.6.33-rc4/kernel/drivers/usb/gadget# insmo
    d g_file_storage.ko file=/mnt/sample stall=0
    insmod: error inserting 'g_file_storage.ko': -1 No such device

  • Wong

    I assume musb driver is built-in.

    Check for the file permission and time, date of creation of gadget module. Try even copying g_file_storage.ko to /mnt directory.

    Regards

    Ravi B

  • Ravi B said:

    I assume musb driver is built-in.

    What does this mean ? Maybe I missed this ...

    Ravi B said:

    Check for the file permission and time, date of creation of gadget module. Try even copying g_file_storage.ko to /mnt directory.

    OK, I have moved to a directory where I have a hello.ko module. This module has the same file permission as the g_file_storage.ko.

    I am able to load and unload the hello.ko without problem.

    I have verified the date of creation is correct.

    root@da850-omapl138-evm:/opt/hello_module# ls -l
    -rw-r--r--    1 1001     1001          576 Aug 19  2010 Makefile
    -rw-r--r--    1 1001     1001            0 Aug 19  2010 Module.symvers
    -rw-r--r--    1 1001     1001            8 Aug 19  2010 built-in.o
    -rw-r--r--    1 1001     1001        37777 Jul 18  2011 g_file_storage.ko
    -rw-r--r--    1 1001     1001          305 Aug 19  2010 hello.c
    -rw-r--r--    1 1001     1001         2414 Aug 19  2010 hello.ko
    -rw-r--r--    1 1001     1001          610 Aug 19  2010 hello.mod.c
    -rw-r--r--    1 1001     1001         1760 Aug 19  2010 hello.mod.o
    -rw-r--r--    1 1001     1001         1368 Aug 19  2010 hello.o
    -rw-r--r--    1 1001     1001           64 Aug 19  2010 modules.order
    root@da850-omapl138-evm:/opt/hello_module# insmod hello.ko
    Hello, world
    root@da850-omapl138-evm:/opt/hello_module# rmmod hello.ko
    Goodbye, cruel world
    root@da850-omapl138-evm:/opt/hello_module# insmod g_file_storage.ko file=/mnt/sa
    mple stall=0
    insmod: error inserting 'g_file_storage.ko': -1 No such device
    root@da850-omapl138-evm:/opt/hello_module#

     

  • Wong

    can you provide dump of cat /proc/interrupts ?

    Regards

    Ravi B

     

  • root@da850-omapl138-evm:/lib/modules/2.6.33-rc4/kernel/drivers/usb# cat /proc/in
    terrupts
               CPU0
     11:          0     cp_intc  edma
     12:          6     cp_intc  edma_error
     16:          0     cp_intc  mmc0
     19:          0     cp_intc  rtc0
     21:      23422     cp_intc  clockevent
     22:         10     cp_intc  free-run counter
     33:          0     cp_intc  eth0
     34:      36357     cp_intc  eth0
     35:      42668     cp_intc  eth0
     36:          0     cp_intc  eth0
     52:          0     cp_intc  da8xx_lcdc
     56:          0     cp_intc  spi_davinci.1
     61:       3228     cp_intc  serial
     67:          0     cp_intc  ahci
     93:          0     cp_intc  edma
     94:          0     cp_intc  edma_error
    Err:          0
    root@da850-omapl138-evm:/lib/modules/2.6.33-rc4/kernel/drivers/usb#

  • Wong

    The musb driver is not built-in to the kernel. Either you can built the musb into kernel or built as module. Please check musb_hdrc.ko available in driver/usb/musb.

    You can load the module musb_hdrc.ko available in driver/usb/musb/musb_hdrc.ko and nop-usb-xceiv.ko from driver/usb/otg directory, then load the g_file_storage.ko module.

    Regards

    Ravi B

     

  • No, they are not there. Below is the list of module available for my build.

    Do you know which configuration is corresponding to these 2 modules ???

     

    kiunwong@ubu1004:~/DaVinci-PSP-SDK-03.20.00.14/src/kernel/linux-03.20.00.14$ make modules_install INSTALL_MOD_PATH=/home/kiunwong/workdir/filesys ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
      INSTALL drivers/block/loop.ko
      INSTALL drivers/char/hw_random/rng-core.ko
      INSTALL drivers/input/keyboard/atkbd.ko
      INSTALL drivers/input/keyboard/xtkbd.ko
      INSTALL drivers/scsi/scsi_wait_scan.ko
      INSTALL drivers/usb/gadget/g_file_storage.ko
      INSTALL fs/autofs4/autofs4.ko
      INSTALL fs/exportfs/exportfs.ko
      INSTALL fs/minix/minix.ko
      INSTALL fs/nfsd/nfsd.ko
      INSTALL fs/nls/nls_ascii.ko
      INSTALL fs/nls/nls_utf8.ko
      INSTALL fs/smbfs/smbfs.ko
      INSTALL lib/crc-ccitt.ko
      INSTALL lib/crc-t10dif.ko
      INSTALL net/ipv4/tunnel4.ko
      INSTALL net/ipv6/ipv6.ko
      INSTALL net/ipv6/sit.ko
      INSTALL net/ipv6/xfrm6_mode_beet.ko
      INSTALL net/ipv6/xfrm6_mode_transport.ko
      INSTALL net/ipv6/xfrm6_mode_tunnel.ko
      DEPMOD  2.6.33-rc4

  • wong

    In menuconfig enable the musb driver support as followes.

    goto menuconfig->"Device drivers"->USB support->

     < >   Support for Host-side USB                                                 
      │ │                                    [ ]     Rely on OTG Targeted Peripherals List
      │ │                                    [ ]     Disable external hubs                             
      │ │                                    <*>   Inventra Highspeed Dual Role Controller (TI, ADI, ...)
      │ │                                            Driver Mode (USB Peripheral (gadget stack))  --->      
      │ │                                    [ ]     Disable DMA (always use PIO)                                      
      │ │                                    [*]     Enable debugging messages                                      
      │ │                                          *** NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may ***                                       
      │ │                                    <*>   USB Gadget Support  --->                                                                           
      │ │                                          *** OTG and related infrastructure ***                                                          
      │ │                                    < >   GPIO based peripheral-only VBUS sensing 'transceiver'                      
      │ │                                    [ ]   Generic ULPI Transceiver Driver                                                                   
      │ │                                    -*-   NOP USB Transceiver Driver

    Regards

    Ravi B

  • Hi Ravi,

    I purposely removed Inventra Highspeed Dual Role Controller (TI, ADI, ...) because it gave me build error.

    So, I guess this is the musb driver. What does the build error mean ???

     

    kiunwong@ubu1004:~/DaVinci-PSP-SDK-03.20.00.14/src/kernel/linux-03.20.00.14$ make uImage ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-scripts/kconfig/conf -s arch/arm/Kconfig
      CHK     include/linux/version.h
      CHK     include/generated/utsrelease.h
    make[1]: `include/generated/mach-types.h' is up to date.
      CALL    scripts/checksyscalls.sh
      CHK     include/generated/compile.h
      CC      arch/arm/mach-davinci/usb.o
      CC      arch/arm/mach-davinci/da850.o
      CC      arch/arm/mach-davinci/devices-da8xx.o
      CC      arch/arm/mach-davinci/board-da850-evm.o
      CC      arch/arm/mach-davinci/pm.o
      LD      arch/arm/mach-davinci/built-in.o
      GZIP    kernel/config_data.gz
      IKCFG   kernel/config_data.h
      CC      kernel/configs.o
      LD      kernel/built-in.o
      CC      drivers/ata/ahci-platform.o
      LD      drivers/ata/libata.o
      CC      drivers/ata/ahci.o
      LD      drivers/ata/built-in.o
      CC      drivers/media/IR/ir-keytable.o
      LD      drivers/media/IR/ir-core.o
      LD      drivers/media/IR/ir-common.o
      LD      drivers/media/IR/built-in.o
      LD      drivers/media/built-in.o
      CC      drivers/usb/musb/musb_core.o
    In file included from drivers/usb/musb/musb_core.c:108:
    drivers/usb/musb/musb_core.h:94:2: error: #error bogus Kconfig output ... select CONFIG_USB_GADGET_MUSB_HDRC
    make[2]: *** [drivers/usb/musb/musb_core.o] Error 1
    make[1]: *** [drivers/usb/musb] Error 2
    make: *** [drivers] Error 2

     

    rgds,

    kc Wong

  • Wong

    do the following

    1) goto menuconfig->Device Drivers->"USB Drivers"->"Gadget support"

     --- USB Gadget Support                                                                                   
                                       [ ]   Debugging information files (DEVELOPMENT)                                                        
                                      [ ]   Debugging information files in debugfs (DEVELOPMENT)                                             
                                        (2)   Maximum VBUS Power usage (2-500 mA)                                                                
                                               USB Peripheral Controller (Inventra HDRC USB Peripheral (TI, ADI, ...))  --->            
                                        <*>   USB Gadget Drivers (Ethernet Gadget (with CDC Ethernet support))  --->   
                                             Ethernet Gadget (with CDC Ethernet support)     
                                        [*]       RNDIS support                                                    
                                        [ ]       Ethernet Emulation Model (EEM) support

    Regards

    Ravi B

  • I have done so, there is no build error.

    I reboot the target with the new uImage, and try to load the g_file_storage.ko module again, it has below errors.

     

    root@da850-omapl138-evm:/lib/modules/2.6.33-rc4/kernel/drivers/usb/gadget# insmo
    d g_file_storage.ko file=/mnt/sample stall=0
    g_file_storage: disagrees about version of symbol usb_gadget_register_driver
    g_file_storage: Unknown symbol usb_gadget_register_driver
    g_file_storage: disagrees about version of symbol usb_gadget_unregister_driver
    g_file_storage: Unknown symbol usb_gadget_unregister_driver
    insmod: error inserting 'g_file_storage.ko': -1 Unknown symbol in module

     

  • The kernel image and g_file_storage.ko version symbol should be same. 

    Build the uImage and modules together and try.

    Regards

    Ravi B

  • Hi Ravi,

    I think Ethernet RNDIS Gadget and File Storage Gadget are mutually exclusive. As I built the module and install/download again, I didn't see g_file_storage.ko any more.

    Anyway, when I connect the device to PC, the PC is able to detect the Etherner RNDIS Gadget. I have use the Ellysis to capture the enumeration USB traffic.

    From GetDescriptor (Device), the device only has string for iProduct, not iSerialNumber.

    Anyway, as you can see from the capture, the GetDescriptor (String iProduct)  requests are always failed. I have expanded one of them, there is no ACK packet after SETUP and DATA0.

    rgds,

    kc Wong

  • Wong

    You should not select the RNDIS support in menuconfig of "Gadget support". Select only FSG (file storage gadget) as module. I am sorry if i would have mailed you copy paste of menuconfig screen shot with RNDIS included. also refer to users guide.

    please see below

     

       --- USB Gadget Support                                                                               
                                [ ]   Debugging information files (DEVELOPMENT)                                                      
                                   [ ]   Debugging information files in debugfs (DEVELOPMENT)  
                                   (2)   Maximum VBUS Power usage (2-500 mA)                            
                                         USB Peripheral Controller (Inventra HDRC USB Peripheral (TI, ADI, ...))  --->                 
                                   <M>   USB Gadget Drivers                                                                             
                                  < >     Gadget Zero (DEVELOPMENT)                                                          
                                  < >     Audio Gadget (EXPERIMENTAL)                                                        
                                   < >     Ethernet Gadget (with CDC Ethernet support)                                
                                   < >     Gadget Filesystem (EXPERIMENTAL)                                              
                                   <M>     File-backed Storage Gadget                                                             
                                   [*]       File-backed Storage Gadget testing version                                   
                                   < >     Mass Storage Gadget                                                                          
                                   < >     Serial Gadget (with CDC ACM and CDC OBEX support)              
                                   < >     MIDI Gadget (EXPERIMENTAL)

    Regards

    Ravi B

  • Thanks, Ravi. I am able to load FSG module.

  • Wong

    Good.

    You should be able do it with help User's guide , let us know if you find any difficult in following the steps mentioned in user's guide. 

    Regards

    Ravi B

     

     

  • Hi Ravi,

    I have a similar problem "insmod: error inserting 'g_file_storage.ko': -1 No such device
    "   with OMAP 3530.

    When I try to use

    insmod /lib/modules/2.6.24_mvl5024-omap3530_evm/kernel/drivers/usb/gadget/g_file_storage.ko storage file=/mnt/depo/backing_file stall=0

    I get the message

    error inserting '/lib/modules/2.6.24_mvl5024-omap3530_evm/kernel/drivers/usb/gadget/g_file_storage.ko': -1 No such device

    Also, I tried

    modprobe g_file_storage file=/mnt/depo/backing_file stall=0

    FATAL: Error inserting g_file_storage (/lib/modules/2.6.24_mvl5024-omap3530_evm/kernel/drivers/usb/gadget/g_file_storage.ko): No such device

     

    The USB related configs are

    #
    # OMAP 343x high speed USB support
    #
    # CONFIG_USB_MUSB_HOST is not set
    CONFIG_USB_MUSB_PERIPHERAL=y
    # CONFIG_USB_MUSB_OTG is not set
    CONFIG_USB_GADGET_MUSB_HDRC=y
    # CONFIG_MUSB_PIO_ONLY is not set
    CONFIG_USB_INVENTRA_DMA=y
    # CONFIG_MUSB_USE_SYSTEM_DMA_RX is not set
    # CONFIG_USB_TI_CPPI_DMA is not set
    CONFIG_USB_MUSB_LOGLEVEL=0

    #
    # NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
    #

    #
    # USB Gadget Support
    #
    CONFIG_USB_GADGET=y
    # CONFIG_USB_GADGET_DEBUG_FILES is not set
    # CONFIG_USB_GADGET_DEBUG_FS is not set
    CONFIG_USB_GADGET_SELECTED=y
    # CONFIG_USB_GADGET_AMD5536UDC is not set
    # CONFIG_USB_GADGET_ATMEL_USBA is not set
    # CONFIG_USB_GADGET_FSL_USB2 is not set
    # CONFIG_USB_GADGET_NET2280 is not set
    # CONFIG_USB_GADGET_PXA2XX is not set
    # CONFIG_USB_GADGET_M66592 is not set
    # CONFIG_USB_GADGET_GOKU is not set
    # CONFIG_USB_GADGET_LH7A40X is not set
    # CONFIG_USB_GADGET_OMAP is not set
    # CONFIG_USB_GADGET_S3C2410 is not set
    # CONFIG_USB_GADGET_AT91 is not set
    # CONFIG_USB_GADGET_DUMMY_HCD is not set
    CONFIG_USB_GADGET_DUALSPEED=y
    # CONFIG_USB_ZERO is not set
    # CONFIG_USB_ETH is not set
    # CONFIG_USB_GADGETFS is not set
    CONFIG_USB_FILE_STORAGE=m
    CONFIG_USB_FILE_STORAGE_TEST=y
    # CONFIG_USB_G_SERIAL is not set
    # CONFIG_USB_MIDI_GADGET is not set
    # CONFIG_MMC is not set
    # CONFIG_NEW_LEDS is not set
    CONFIG_RTC_LIB=y
    CONFIG_RTC_CLASS=y
    CONFIG_RTC_HCTOSYS=y
    CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
    # CONFIG_RTC_DEBUG is not set

    Also musb_hdrc is built-in.

    If you inform me about how I can fix the problem, I will be pleased to you.

     

    Thanks in advance