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

From RidgeRun Developer Connection

Revision as of 15:42, 6 June 2011 by Tfischer (Talk | contribs)
Jump to:navigation, search

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
TI DM365 EVM LeopardBoard 365
Host Configuration
Jumper J1 pins 1 and 2
Jumper J4 pins 2 and 3

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])

The key kernel configuration settings for DM365 USB device configuration include:

CONFIG_USB_SUPPORT=y
CONFIG_USB_ARCH_HAS_HCD=y
CONFIG_USB=y
CONFIG_USB_OTG=y
CONFIG_USB_MUSB_HDRC=y
CONFIG_USB_MUSB_SOC=y
CONFIG_USB_MUSB_OTG=y
CONFIG_USB_GADGET_MUSB_HDRC=y
CONFIG_USB_MUSB_HDRC_HCD=y
CONFIG_USB_TI_CPPI_DMA=y

Other configuration items are fine as well. You can list your USB configuration items using

fgrep USB $DEVDIR/kernel/linux*/.config | grep -v '^#'

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 
TI DM365 EVM LeopardBoard 365
Device Configuration
No jumper on J1
Jumper J4 pins 3 and 4

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. for the driver to create it you must enable the USB debugging messages:

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

Use

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

for further details on the procfs entry.


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