4.12 usb device

This example demonstrates how to use USB device interface and verify the driver of USB client. The MYD-AM335X series development board works as a TF card reader, it is connected to the USB host of PC with a USB mini B to USB A cable.

Hardware Preparation:

  • Hardware debugging environment to see chapter2.
  • One TF card
  • One USB mini B to USB A cable.
Board Type MYD-AM335X MYD-AM335X-Y MYD-AM335X-J
MINI USB interface J2 J3 J3
TF Card J17 J12 J19

Software Preparation:

  • Linux Kernel 4.1.18
  • modprobe command

Test Steps:

  • After the MYD-AM335X series development is booted, connect it to the USB host interface of PC with a USB mini B to USB A cable, Insert the TF card to MYD-AM335X series development. Load the mass storage gadget driver as below:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# modprobe g_mass_storage stall=0 file=/dev/mmcblk0p1 removable=1
[ 687.171803] udc musb-hdrc.0.auto: registering UDC driver [g_mass_storage]
[ 687.179455] Mass Storage Function, version: 2009/09/11
[ 687.184933] LUN: removable file: (no medium)
[ 687.192157] lun0: open backing file: /dev/mmcblk0p1
[ 687.197379] LUN: removable file: /dev/mmcblk0p1
[ 687.202952] Number of LUNs=1
[ 687.206057] g_mass_storage gadget: adding config #1 'Linux File-Backed Storage'/bf2a45cc
[ 687.215260] Number of LUNs=1
[ 687.219060] g_mass_storage gadget: I/O thread pid: 185
[ 687.224576] g_mass_storage gadget: adding 'Mass Storage Function'/dc896b00 to config 'Linux File-Backed Storage'
/bf2a45cc
[ 687.236802] g_mass_storage gadget: cfg 1/bf2a45cc speeds: high full
[ 687.243534] g_mass_storage gadget: interface 0 = Mass Storage Function/dc896b00
[ 687.252005] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[ 687.259466] g_mass_storage gadget: userspace failed to provide iSerialNumber
[ 687.266948] g_mass_storage gadget: g_mass_storage ready
[ 687.273141] g_mass_storage musb-hdrc.0.auto: usb_gadget_udc_start
  • After g_mass_storage driver is loaded, a removable disk will be detected on PC. The content of this removable disk is just the same with the TF card.

Note: Beyond that, users can load different gadget modules to achieve different functions. such as g_ether is used to make a RNDIS network interface.