NOTICE: The Processors Wiki will End-of-Life in December of 2020. It is recommended to download any files or other content you may need that are hosted on The site is now set to read only.

USB File Storage Gadget

From Texas Instruments Wiki
Jump to: navigation, search

Davinci Linux can run in the host, or in the peripheral mode. This document covers how to configure Linux kernel for a USB peripheral device (DVEVM in this case). Document chooses File-backed Storage Gadget (FSG) module on USB peripheral device. The FSG acts as a USB mass storage disk drive. As its storage repository it can use a regular file or a block device (in much the same way as the "loop" device driver), specified as a module parameter.

 | Host-Side | Generic USB | USB Host   |
 | Operating | Storage     | Controller |   
 | System    | Driver      | Driver     |<-------
 |           |             | and        |        |  
 |           |             | USB Stack  |        | 
  --------------------------------------         |
                                                 | USB Cable ( Male-Male)
  DVEVM                                          |
  --------------------------------------         |
 |             |           | USB Periph.|        |
 | Device-Side | USB Gadget| Controller |        |
 | Operating   | File      | Driver     |<-------
 | System      | Storage   | and        |
 | (Linux)     | Driver    | USB Stack  |

Rebuilding Kernel

This section of document covers the kernel configuration needed for DVEVM. Launch kernel menuconfig and enable the following options in sequence.

 Device  Driver ->  USB Support -> USB Gadget ->
                                  <*>  Support for USB Gadget
 Device  Driver ->  USB Support -> Driver Mode ->
                                  <*> Gadget Stack
 Device  Driver ->  USB Support -> USB Gadget -> 
                                   USB peripheral controller
                                      <*> Inverntra (M) USB peripheral 
                                   <M> USB Gadget driver
                                   <M> File-backed Storage gadget

Note: Make sure USB DMA is enabled.

Configuring backing storage device

Refer Backing Storage for the File-backed Storage Gadget for creating temporary FSG device.

In this artical we will use Compact Flash as a FSG device. Make sure that CF support is enabled in Davinci Kernel (System types and features -> TI Implementation -> <*> CF Support)

Putting it all together

1. Insert CF card on DVEVM

2. Set J7 jumper to enable USB slave mode

3. Boot DVEVM with kernel built in previous steps

4. Run "insmod g_file_storage.ko file=/dev/hda1" command to install FSG module.

5. Connect DVEVM with Host machine using USB male-male cable.

On success, host machine will detect a USB mass storage device. In case of Windows Host, you will see a new drive letter in your Explorer window.