How to configure DM365 for USB host, device and OTG support

From RidgeRun Developer Connection

(Difference between revisions)
Jump to:navigation, search
m
m (USB device functionality)
Line 63: Line 63:
             -> Inventra Highspeed Dual Role Controller (TI, ADI, ...)  
             -> Inventra Highspeed Dual Role Controller (TI, ADI, ...)  
 +
4. Change  USB Peripheral Controller to Inventra as well
 +
Prompt: USB Peripheral Controller
 +
    Defined at drivers/usb/gadget/Kconfig:112
 +
    Depends on: USB_SUPPORT && USB_GADGET
 +
    Location:
 +
      -> Kernel configuration
 +
        -> Device Drivers
 +
          -> USB support (USB_SUPPORT [=y])
 +
            -> USB Gadget Support (USB_GADGET [=y])
-
4. Recompile and install the kernel
 
 +
5. Recompile and install the kernel
-
5. When you got the linux prompt this command will allow you to mount the device (e.g the mmc mounted on the board
+
 
 +
6. When you got the linux prompt this command will allow you to mount the device (e.g the mmc mounted on the board

Revision as of 21:06, 26 April 2011

This page shows how to configure linux kernel 2.6.32 for the DM365 in order to use USB on different operation modes. The example hardware is the TI DM365 EVM.

Contents

USB host functionality

1. Gadget support this feature must be unselected

Symbol: USB_GADGET [=n]
  Prompt: USB Gadget Support
    Defined at drivers/usb/gadget/Kconfig:16
    Depends on: USB_SUPPORT
    Location:
      -> Kernel configuration
        -> Device Drivers
          -> USB support (USB_SUPPORT [=y])


2. Change the Inventra driver mode to USB Host

 Prompt: Driver Mode
    Defined at drivers/usb/musb/Kconfig:68
    Depends on: USB_SUPPORT && USB_MUSB_HDRC
    Location:
      -> Kernel configuration
        -> Device Drivers
          -> USB support (USB_SUPPORT [=y])
            -> Inventra Highspeed Dual Role Controller


Host Configuration

USB device functionality

1. Gadget support this feature must be selected

Symbol: USB_GADGET [=y]
  Prompt: USB Gadget Support
    Defined at drivers/usb/gadget/Kconfig:16
    Depends on: USB_SUPPORT
    Location:
      -> Kernel configuration
        -> Device Drivers
          -> USB support (USB_SUPPORT [=y])


2. Before you can select both host and peripheral mode for the Inventra driver, you need to enable power management

Symbol: PM [=y]
  Prompt: Power Management support
    Defined at kernel/power/Kconfig:1
    Depends on: !IA64_HP_SIM
    Location:
      -> Kernel configuration
        -> Power management options
    

3. Change the Inventra driver mode to Both host and peripheral: USB OTG (On The Go) Device

  Prompt: Driver Mode
    Defined at drivers/usb/musb/Kconfig:68
    Depends on: USB_SUPPORT && USB_MUSB_HDRC
    Location:
      -> Kernel configuration
        -> Device Drivers
          -> USB support (USB_SUPPORT [=y])
            -> Inventra Highspeed Dual Role Controller (TI, ADI, ...) 

4. Change USB Peripheral Controller to Inventra as well

Prompt: USB Peripheral Controller
    Defined at drivers/usb/gadget/Kconfig:112
    Depends on: USB_SUPPORT && USB_GADGET
    Location:
      -> Kernel configuration
        -> Device Drivers
          -> USB support (USB_SUPPORT [=y])
            -> USB Gadget Support (USB_GADGET [=y])


5. Recompile and install the kernel


6. When you got the linux prompt this command will allow you to mount the device (e.g the mmc mounted on the board


# modprobe g_file_storage file=/dev/mmcblk0p1


This command will allow you to get the data  of mmc in your PC 


Device Configuration

USB On-The-Go (OTG) functionality

To enable OTG functionality the following steps should be followed

1. Remove J26 and J6, extra jumpers can be placed on J4.


2. Gadget Support this feature must be selected on the kernel configuration menu

Symbol: USB_GADGET [=y]
  Prompt: USB Gadget Support
    Defined at drivers/usb/gadget/Kconfig:16
    Depends on: USB_SUPPORT
    Location:
      -> Kernel configuration
        -> Device Drivers
          -> USB support (USB_SUPPORT [=y])

</pre>


3. Change the Inventra driver mode to Both host and peripheral: USB OTG (On The Go) Device

 Prompt: Driver Mode
    Defined at drivers/usb/musb/Kconfig:68
    Depends on: USB_SUPPORT && USB_MUSB_HDRC
    Location:
      -> Kernel configuration
        -> Device Drivers
          -> USB support (USB_SUPPORT [=y])
            -> Inventra Highspeed Dual Role Controller (TI, ADI, ...) 


4. Choose if the devices will be registered based on a whitelist (list of devices that will pass the enumeration) or if any plugged in device will be enumerated.

  Prompt: Rely on OTG Targeted Peripherals List
    Defined at drivers/usb/core/Kconfig:115
    Depends on: USB_SUPPORT && (USB_OTG || EMBEDDED)
    Location:
      -> Kernel configuration
        -> Device Drivers
          -> USB support (USB_SUPPORT [=y])
            -> Support for Host-side USB (USB [=y])


5. Now the gadget driver must be selected from the list displayed by:

  Prompt: USB Gadget Drivers
    Defined at drivers/usb/gadget/Kconfig:556
    Depends on: USB_SUPPORT && USB_GADGET && USB_GADGET_SELECTED
    Location:
      -> Kernel configuration
        -> Device Drivers
          -> USB support (USB_SUPPORT [=y])
            -> USB Gadget Support (USB_GADGET [=y])


If USB Gadget Drivers is compiled as a kernel module, you can select multiple gadget drivers, e.g:

Symbol: USB_FILE_STORAGE [=m]
  Prompt: File-backed Storage Gadget
    Defined at drivers/usb/gadget/Kconfig:712
    Depends on: <choice> && BLOCK
    Location:
      -> Kernel configuration
        -> Device Drivers
          -> USB support (USB_SUPPORT [=y])
            -> USB Gadget Support (USB_GADGET [=y])
              -> USB Gadget Drivers (<choice> [=m])


Symbol: USB_MASS_STORAGE [=m]
  Prompt: Mass Storage Gadget
    Defined at drivers/usb/gadget/Kconfig:734
    Depends on: <choice> && BLOCK
    Location:
      -> Kernel configuration
        -> Device Drivers
          -> USB support (USB_SUPPORT [=y])
            -> USB Gadget Support (USB_GADGET [=y])

which are mass storage device drivers (with different APIs), the respective modules are called g_file_storqage and g_mass_storage. Even a composite driver can be selected:

Symbol: USB_G_MASS_STORAGE_CDC [=m]
  Prompt: CDC ACM + Mass Storage configuration
    Defined at drivers/usb/gadget/Kconfig:814
    Depends on: <choice> && BLOCK
    Location:
      -> Kernel configuration
        -> Device Drivers
          -> USB support (USB_SUPPORT [=y])
            -> USB Gadget Support (USB_GADGET [=y])
              -> USB Gadget Drivers (<choice> [=m])
              -> USB Gadget Drivers (<choice> [=m])


which module is called g_cdc_ms. This composite driver will be used in the following examples, for information on the different gadget drivers refer to the source code located in $DEVDIR/kernel/linux*/drivers/usb/gadget


6. Recompile and install the kernel.


7. To watch the contents of an SD card plugged in the target board from your host PC:

# modprobe g_cdc_ms file=/dev/mmcblk0p1


8. To start a host session plug in your device (e.g. a flash memory) to the board. If gadget driver is built as module then insert it to complete USB initialization:

# modprobe g_cdc_ms

and type

# echo "F" > /proc/driver/musb_hdrc

to start the host session, the device will be registered and you will be able to use it. For example, for a flash memory mount it using

# mkdir usb
# mount /dev/sdXX usb/

where XX should be replaced according to the specific case. Notice that if you're using MDEV to automount the devices the previous instructions are not required.

NOTE: The procfs entry /proc/driver/musb_hdrc is used to control the driver behavior and to control its status. Use

# echo "?" > /proc/driver/musb_hdrc

for further details.


9. To switch from one mode host mode to gadget mode, the g_file_storage module must be reloaded:

# rmmod g_cdc_ms
# modprobe g_cdc_ms file=/dev/mmcblk0p1

then plug the board to the host PC.


10. To switch from gadget mode to host mode refer to point 5.

Related links

Navigation
Toolbox