Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

Networking over USB

From Texas Instruments Wiki
Jump to: navigation, search


Prerequisites

  • A DaVinci DM355 EVM (USB peripheral device)
  • A computer running Linux (USB Host)
  • TI DaVinci LSP kernel source
  • A USB A to mini-B cable

Configuring the EVM Hardware

This section will cover how to configure the DaVinci hardware as a USB peripheral device.

DM355

  • J9 jumpered
  • J10 un-jumpered

Host PC

Connect the USB cable to a standard USB A socket. Connect the USB Mini-B end of the cable to the DM355 EVM (J5).

Kernel Config

USB Support:

 < > Support for Host-side USB
 <M> Inventra USB Highspeed Dual Role Controller Support
 ---   DaVinci 644x USB support
       Driver Mode (USB Peripheral (gadget stack))  --->
 [*]   Disable DMA (always use PIO)
 (0)   Logging Level (0 - none / 3 - annoying / ... )
 --- NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
     USB Gadget Support  --->

USB Gedget Support:

 <M> Support for USB Gadgets
 [*]   Debugging information files
       USB Peripheral Controller (Inventra (M)HDRC USB Peripheral)  --->
       USB Gadget Drivers
 < >     Gadget Zero (DEVELOPMENT)
 <M>     Ethernet Gadget
 [*]       RNDIS support (EXPERIMENTAL)
 < >     Gadget Filesystem (EXPERIMENTAL)
 < >     File-backed Storage Gadget
 < >     Serial Gadget

Network Operation

Connect the DM355 EVM to the Host PC via the USB cable.

Set the DM355 up as a Network Gadget:

 modprobe musb_hdrc use_dma=n
 modprobe g_ether
 ifconfig usb0 10.0.0.2 up

Output from dmesg on the DM355 EVM:

 musb_hdrc: version 2.2a/db-0.4.8 [cppi-dma] [peripheral] [debug=0]
 Registering platform device 'musb_hdrc'. Parent at platform
 musb_hdrc: ConfigData=0x06 (UTMI-8, dyn FIFOs, SoftConn)
 musb_hdrc: MHDRC RTL version 1.300
 musb_hdrc: setup fifo_mode 4
 musb_hdrc: hw_ep 0shared, max 64
 musb_hdrc: hw_ep 1tx, max 512
 musb_hdrc: hw_ep 1rx, max 512
 musb_hdrc: hw_ep 2tx, max 512
 musb_hdrc: hw_ep 2rx, max 512
 musb_hdrc: hw_ep 3tx, max 512
 musb_hdrc: hw_ep 3rx, max 512
 musb_hdrc: hw_ep 4tx, max 512
 musb_hdrc: hw_ep 4rx, max 256
 musb_hdrc: USB Peripheral mode controller at c886e000 using PIO, IRQ 12
 usb0: Ethernet Gadget, version: Equinox 2004
 usb0: using musb_hdrc, OUT ep1out IN ep1in STATUS ep2in
 usb0: MAC de:b8:d7:c3:54:27
 usb0: HOST MAC 66:ae:d1:47:3a:32
 usb0: RNDIS ready
 usb0: high speed config #3: 100 mA, Ethernet Gadget, using CDC Ethernet

The Host PC (running Linux) should have automatically loaded the necessary drivers for the USB CDC class: cdc_ether and usbnet.

Bring the network up and ping the USB device:

 ifconfig usb0 10.0.0.1 up
 ping 10.0.0.2
 
 PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
 64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=7.49 ms
 64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.390 ms

Output from dmesg on the Host PC:

 usb 7-4: new high speed USB device using ehci_hcd and address 14
 usb 7-4: configuration #3 chosen from 2 choices
 usb0: register 'cdc_ether' at usb-0000:00:1a.7-4, CDC Ethernet Device, 66:ae:d1:47:3a:32

Throughput Testing

Netcat is a very useful tool for sending and receiving data over the network.

Setup the DM355 EVM to receive data from the Host PC:

 nc -l -p 3000 > /dev/null

Create a test file on the Host PC and send this over the network to the USB device:

 dd if=/dev/urandom of=100M-random.data bs=1M count=100
 time ( cat 100M-random.data | nc -q 0 10.0.0.2 3000 )
 
 real    1m8.690s
 user    0m0.012s
 sys     0m0.404s

Therefore the throughput = ( 100MB * 8 / 68 sec ) = 11.76 Mbps

Conclusion

  • The g_ether driver does not seem to work when musb_hdrc is using DMA, and tests using the g_file_storage driver show that PIO is 5 times slower. Perhaps patches have been submitted to fix this.
  • The above result is very close to 12Mbps, which is the maximum for full-speed USB. Is this a coincidence, or is something preventing high-speed USB rates ?

I expected the throughput to be much higher...