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

From RidgeRun Developer Connection

Revision as of 13:54, 17 February 2011 by Pbarrantes (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.

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 Host mode

  │ 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, ...) (USB_MUSB    
  │   Selected by: USB_SUPPORT && USB_MUSB_HDRC && m 
Host configuration.jpg


USB slave functionality

1. Gadget Support this feature must be selected

 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 dual role controller

  │ 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, ...) (USB_MUSB    
  │   Selected by: USB_SUPPORT && USB_MUSB_HDRC && m 

3. Recompile and install the kernel


4When 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 



Slave configuration.jpg

USB On-The-Go (OTG) functionality

To enable OTG functionality the following steps should be followed

1. Gadget Support this feature must be selected

 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 dual role controller

  │ 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, ...) (USB_MUSB    
  │   Selected by: USB_SUPPORT && USB_MUSB_HDRC && m 


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


4. Recompile and install the kernel.


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


6. 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

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