Difference between revisions of "EMAC OE USB Gadget Connections"

From wiki.emacinc.com
Jump to: navigation, search
(added to ethernet gadget section)
(changed code formatting and added usb gadget serial section)
Line 7: Line 7:
 
  allow-hotplug usb0
 
  allow-hotplug usb0
 
  iface usb0 inet static
 
  iface usb0 inet static
address 192.168.0.2
+
    address 192.168.0.2
netmask 255.255.255.0
+
    netmask 255.255.255.0
gateway 192.168.0.1
+
    gateway 192.168.0.1
  
 
Also, add a configuration for the device connection on the host. The configuration will vary depending on the host operating system and flavor. The IP address of the host should be set to the value used for the gateway setting on the device (192.168.0.1 using the example above). An example configuration for a system that uses the <code>/etc/network/interfaces</code> networking configuration is shown below.
 
Also, add a configuration for the device connection on the host. The configuration will vary depending on the host operating system and flavor. The IP address of the host should be set to the value used for the gateway setting on the device (192.168.0.1 using the example above). An example configuration for a system that uses the <code>/etc/network/interfaces</code> networking configuration is shown below.
 
  allow-hotplug usb0
 
  allow-hotplug usb0
 
  iface usb0 inet static
 
  iface usb0 inet static
address 192.168.0.1
+
    address 192.168.0.1
netmask 255.255.255.0
+
    netmask 255.255.255.0
gateway 192.168.0.1
+
    gateway 192.168.0.1
  
 
Once the configuration is finished and the host and device systems are connected via a USB cable, load the gadget Ethernet driver on the device with the following command.
 
Once the configuration is finished and the host and device systems are connected via a USB cable, load the gadget Ethernet driver on the device with the following command.
Line 23: Line 23:
  
 
The host system will most likely automatically detect and load the appropriate drivers. If this does not occur, verify that the usbnet driver is installed and loaded on a Linux distribution. See the [http://msdn.microsoft.com/en-us/library/windows/hardware/gg463293.aspx Microsoft RNDIS driver documentation] for more information on configuring this driver for Windows hosts.
 
The host system will most likely automatically detect and load the appropriate drivers. If this does not occur, verify that the usbnet driver is installed and loaded on a Linux distribution. See the [http://msdn.microsoft.com/en-us/library/windows/hardware/gg463293.aspx Microsoft RNDIS driver documentation] for more information on configuring this driver for Windows hosts.
 +
 +
== USB Gadget Serial ==
 +
The USB Gadget Serial driver can be used to emulate a serial port over a USB cable. This can be a useful method for getting serial access to the target machine from a system that does not have a serial port or when there is no spare serial port on the target system to utilize for access. Note that their is currently limited support for using the USB gadget serial device as a console for accessing the bootloader on most systems, so a hardware serial console is generally required for development.

Revision as of 07:05, 28 March 2013

Systems that have a USB device port can be connected to a PC or other system through a USB host port. A USB cable will need to be connected between the USB device port on the board and a USB host port on the other system. This page covers the process of establishing a connection using the gadget Ethernet driver and several of the available USB gadget function drivers. More information regarding the USB Gadget drivers for Linux can be found at the Linux USB Project.

USB Gadget Ethernet

The USB Gadget Ethernet driver allows a device to enumerate and communicate as an Ethernet device over the USB link. On the host system, this requires the usbnet driver for a Linux system or the RNDIS driver for Windows hosts.

To establish a connection, first create an entry in the /etc/network/interfaces file on the device system for the usb0 interface. An example of this configuration is shown below. Note that in almost all circumstances you will want to use a different subnetwork for the USB Ethernet link than what is used for the LAN connection on either the host or device system.

allow-hotplug usb0
iface usb0 inet static
    address 192.168.0.2
    netmask 255.255.255.0
    gateway 192.168.0.1

Also, add a configuration for the device connection on the host. The configuration will vary depending on the host operating system and flavor. The IP address of the host should be set to the value used for the gateway setting on the device (192.168.0.1 using the example above). An example configuration for a system that uses the /etc/network/interfaces networking configuration is shown below.

allow-hotplug usb0
iface usb0 inet static
    address 192.168.0.1
    netmask 255.255.255.0
    gateway 192.168.0.1

Once the configuration is finished and the host and device systems are connected via a USB cable, load the gadget Ethernet driver on the device with the following command.

root@emac-oe:~# modprobe g_ether

After loading the driver, ifconfig should show an entry for the usb0 interface. Depending on the configuration, you may need to run ifup usb0 to configure the device.

The host system will most likely automatically detect and load the appropriate drivers. If this does not occur, verify that the usbnet driver is installed and loaded on a Linux distribution. See the Microsoft RNDIS driver documentation for more information on configuring this driver for Windows hosts.

USB Gadget Serial

The USB Gadget Serial driver can be used to emulate a serial port over a USB cable. This can be a useful method for getting serial access to the target machine from a system that does not have a serial port or when there is no spare serial port on the target system to utilize for access. Note that their is currently limited support for using the USB gadget serial device as a console for accessing the bootloader on most systems, so a hardware serial console is generally required for development.