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 On-The-Go (OTG) functionality: Removing unnecesary </pre> tag)
(16 intermediate revisions not shown)
Line 1: Line 1:
-
This page shows how to configure linux kernel 2.6.32 for the DM365 in order to use USB on different operation modes.
+
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.
== USB host functionality  ==
== USB host functionality  ==
 +
1. Gadget support this feature must be '''unselected'''
-
1. Gadget Support this feature must be '''unselected'''
+
Symbol: USB_GADGET [=n]
-
<pre> Symbol: USB_GADGET [=n]
+
   Prompt: USB Gadget Support
   Prompt: USB Gadget Support
     Defined at drivers/usb/gadget/Kconfig:16
     Defined at drivers/usb/gadget/Kconfig:16
Line 13: Line 13:
         -&gt; Device Drivers
         -&gt; Device Drivers
           -&gt; USB support (USB_SUPPORT [=y])
           -&gt; USB support (USB_SUPPORT [=y])
-
 
-
</pre>
 
-
2. Change the Inventra driver mode to '''Host mode'''
+
2. Change the Inventra driver mode to '''USB Host'''
-
<pre>  │ Prompt: Driver Mode
+
  Prompt: Driver Mode
     Defined at drivers/usb/musb/Kconfig:68
     Defined at drivers/usb/musb/Kconfig:68
     Depends on: USB_SUPPORT &amp;&amp; USB_MUSB_HDRC
     Depends on: USB_SUPPORT &amp;&amp; USB_MUSB_HDRC
Line 25: Line 23:
         -&gt; Device Drivers
         -&gt; Device Drivers
           -&gt; USB support (USB_SUPPORT [=y])
           -&gt; USB support (USB_SUPPORT [=y])
-
             -&gt; Inventra Highspeed Dual Role Controller (TI, ADI, ...) (USB_MUSB
+
             -&gt; Inventra Highspeed Dual Role Controller
-
    Selected by: USB_SUPPORT &amp;&amp; USB_MUSB_HDRC &amp;&amp; m
+
-
</pre>
+
-
[[Image:Host configuration.jpg|thumb|center|320x240px|Host configuration.jpg]]
+
-
<br>
+
{| border=2
 +
! TI DM365 EVM !! LeopardBoard 365
 +
|-
 +
| [[Image:Host configuration.jpg|thumb|center|320x240px|Host Configuration]]
 +
|| Jumper J1 pins 1 and 2<br> Jumper J4 pins 2 and 3
 +
|}
-
== USB slave functionality  ==
+
== USB device functionality  ==
-
1. Gadget Support this feature must be '''selected'''
+
1. Gadget support this feature must be '''selected'''
-
<pre> Symbol: USB_GADGET [=n]
+
Symbol: USB_GADGET [=y]
   Prompt: USB Gadget Support
   Prompt: USB Gadget Support
     Defined at drivers/usb/gadget/Kconfig:16
     Defined at drivers/usb/gadget/Kconfig:16
Line 43: Line 43:
         -&gt; Device Drivers
         -&gt; Device Drivers
           -&gt; USB support (USB_SUPPORT [=y])
           -&gt; USB support (USB_SUPPORT [=y])
-
</pre>
 
-
2. Change the Inventra driver mode to '''dual role controller'''
+
2. Before you can select both host and peripheral mode for the Inventra driver, you need to enable power management
-
<pre>  Prompt: Driver Mode
+
 
 +
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
     Defined at drivers/usb/musb/Kconfig:68
     Depends on: USB_SUPPORT &amp;&amp; USB_MUSB_HDRC
     Depends on: USB_SUPPORT &amp;&amp; USB_MUSB_HDRC
Line 54: Line 65:
         -&gt; Device Drivers
         -&gt; Device Drivers
           -&gt; USB support (USB_SUPPORT [=y])
           -&gt; USB support (USB_SUPPORT [=y])
-
             -&gt; Inventra Highspeed Dual Role Controller (TI, ADI, ...) (USB_MUSB
+
             -&gt; Inventra Highspeed Dual Role Controller (TI, ADI, ...)  
-
    Selected by: USB_SUPPORT &amp;&amp; USB_MUSB_HDRC &amp;&amp; m
+
-
</pre>
+
 +
4. Change  USB Peripheral Controller to Inventra as well
-
3. Recompile and install the kernel
+
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:
-
4. When you got the linux prompt this command will allow you to mount the device (e.g the mmc mounted on the board
+
<pre>
 +
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
 +
</pre>
 +
Other configuration items are fine as well.  You can list your USB configuration items using
-
<pre># modprobe g_file_storage file=/dev/mmcblk0p1
+
<pre>
 +
fgrep USB $DEVDIR/kernel/linux*/.config | grep -v '^#'
</pre>
</pre>
-
<br>
 
-
:This command will allow you to get the data &nbsp;of mmc in your PC&nbsp;<br>
+
5. Recompile and install the kernel
-
<br>
 
-
<br>
+
6. When you got the linux prompt this command will allow you to mount the device (e.g the mmc mounted on the board
-
[[Image:Slave configuration.jpg|thumb|center|320x240px|Slave configuration.jpg]]
+
 
 +
<pre>
 +
modprobe g_file_storage file=/dev/mmcblk0p1
 +
</pre>
 +
 
 +
 
 +
:This command will allow you to get the data &nbsp;of mmc in your PC&nbsp;<br>
 +
 
 +
{| border=2
 +
! TI DM365 EVM !! LeopardBoard 365
 +
|-
 +
| [[Image:Slave configuration.jpg|thumb|center|320x240px|Device Configuration]]
 +
|| No jumper on J1 <br> Jumper J4 pins 3 and 4
 +
|}
== USB On-The-Go (OTG) functionality  ==
== USB On-The-Go (OTG) functionality  ==
Line 84: Line 126:
-
2. Gadget Support this feature must be '''selected''' on the kernel configuration menur
+
2. Gadget Support this feature must be '''selected''' on the kernel configuration menu
-
<pre> Symbol: USB_GADGET [=n]
+
 
 +
Symbol: USB_GADGET [=y]
   Prompt: USB Gadget Support
   Prompt: USB Gadget Support
     Defined at drivers/usb/gadget/Kconfig:16
     Defined at drivers/usb/gadget/Kconfig:16
Line 93: Line 136:
         -&gt; Device Drivers
         -&gt; Device Drivers
           -&gt; USB support (USB_SUPPORT [=y])
           -&gt; USB support (USB_SUPPORT [=y])
-
</pre>
 
-
3. Change the Inventra driver mode to '''dual role controller'''
+
3. Change the Inventra driver mode to '''Both host and peripheral:  USB OTG (On The Go) Device'''
-
<pre>  Prompt: Driver Mode
+
 
 +
  Prompt: Driver Mode
     Defined at drivers/usb/musb/Kconfig:68
     Defined at drivers/usb/musb/Kconfig:68
     Depends on: USB_SUPPORT &amp;&amp; USB_MUSB_HDRC
     Depends on: USB_SUPPORT &amp;&amp; USB_MUSB_HDRC
Line 104: Line 147:
         -&gt; Device Drivers
         -&gt; Device Drivers
           -&gt; USB support (USB_SUPPORT [=y])
           -&gt; USB support (USB_SUPPORT [=y])
-
             -&gt; Inventra Highspeed Dual Role Controller (TI, ADI, ...) (USB_MUSB
+
             -&gt; Inventra Highspeed Dual Role Controller (TI, ADI, ...)  
-
    Selected by: USB_SUPPORT &amp;&amp; USB_MUSB_HDRC &amp;&amp; m
+
 
-
</pre>
+
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.
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
   Prompt: Rely on OTG Targeted Peripherals List
     Defined at drivers/usb/core/Kconfig:115
     Defined at drivers/usb/core/Kconfig:115
Line 135: Line 178:
gadget drivers, e.g:
gadget drivers, e.g:
-
  Symbol: USB_FILE_STORAGE [=m]
+
Symbol: USB_FILE_STORAGE [=m]
   Prompt: File-backed Storage Gadget
   Prompt: File-backed Storage Gadget
     Defined at drivers/usb/gadget/Kconfig:712
     Defined at drivers/usb/gadget/Kconfig:712
Line 160: Line 203:
Even a composite driver can be selected:
Even a composite driver can be selected:
-
  Symbol: USB_G_MASS_STORAGE_CDC [=m]
+
Symbol: USB_G_MASS_STORAGE_CDC [=m]
   Prompt: CDC ACM + Mass Storage configuration
   Prompt: CDC ACM + Mass Storage configuration
     Defined at drivers/usb/gadget/Kconfig:814
     Defined at drivers/usb/gadget/Kconfig:814
Line 181: Line 224:
7. To watch the contents of an SD card plugged in the target board from your host PC:
7. To watch the contents of an SD card plugged in the target board from your host PC:
-
<br>
+
 
-
<pre># modprobe g_cdc_ms file=/dev/mmcblk0p1
+
<pre>
 +
# modprobe g_cdc_ms file=/dev/mmcblk0p1
</pre>
</pre>
Line 197: Line 241:
the previous instructions are not required.
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
+
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
  # echo "?" > /proc/driver/musb_hdrc
-
for further details.
+
for further details on the procfs entry.
Line 211: Line 268:
== Related links ==
== Related links ==
 +
*[http://processors.wiki.ti.com/index.php/UserGuideUsbDriver_PSP_03.00.00.04#Features USB driver User Guide PSP 3.0]
*[http://processors.wiki.ti.com/index.php/UserGuideUsbDriver_PSP_03.00.00.04#Features USB driver User Guide PSP 3.0]
*[http://www.maxim-ic.com/app-notes/index.mvp/id/1822 USB On-The-Go Basics]
*[http://www.maxim-ic.com/app-notes/index.mvp/id/1822 USB On-The-Go Basics]
*[http://support.spectrumdigital.com/boards/evmdm365/revf/files/EVMDM365_TechRef_revf.pdf DM365 EVM technical reference]
*[http://support.spectrumdigital.com/boards/evmdm365/revf/files/EVMDM365_TechRef_revf.pdf DM365 EVM technical reference]
 +
*[http://e2e.ti.com/support/embedded/linux/f/354/t/106554.aspx AM3715 instructions for removable file backed storage]
 +
 +
== Morteza's Instructions ==
 +
 +
See http://designsomething.org/leopardboard/f/23/p/743/2753.aspx#2753 for community contributed instructions.
 +
 +
== Common Problems and Solutions ==
 +
 +
=== drivers/usb/gadget/r8a66597-udc.c error implicit declaration of function IS_ERR ===
 +
 +
For some reason when you enable USB device (gadget) functionality, it automatically selects CONFIG_USB_R8A66597.  Using '''make config''' to switch the USB Peripheral Controller from ''Renesas R8A66597 USB Peripheral Controller'' to ''Inventra HDRC USB Peripheral'' in  Kernel configuration --> Device Drivers --> USB support --> USB Gadget Support --> USB Peripheral Controller.
 +
 +
If you don't see ''Inventra HDRC USB Peripheral'' as an option, you first need to select ''gadget stack'' under Kernel configuration --> Device --> USB support --> Inventra Highspeed Dual Role Controller --> Driver Mode.
-
[[Category:HowTo]]
+
[[Category:HowTo]] [[Category:USB]]

Revision as of 15:32, 31 December 2012

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


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

Morteza's Instructions

See http://designsomething.org/leopardboard/f/23/p/743/2753.aspx#2753 for community contributed instructions.

Common Problems and Solutions

drivers/usb/gadget/r8a66597-udc.c error implicit declaration of function IS_ERR

For some reason when you enable USB device (gadget) functionality, it automatically selects CONFIG_USB_R8A66597. Using make config to switch the USB Peripheral Controller from Renesas R8A66597 USB Peripheral Controller to Inventra HDRC USB Peripheral in Kernel configuration --> Device Drivers --> USB support --> USB Gadget Support --> USB Peripheral Controller.

If you don't see Inventra HDRC USB Peripheral as an option, you first need to select gadget stack under Kernel configuration --> Device --> USB support --> Inventra Highspeed Dual Role Controller --> Driver Mode.

Navigation
Toolbox