USB Gadget

We can do all sorts of nifty things with a USB OTG connector. Here are some of them.

= USB Ethernet support =

This allows ethernet emulation over USB, allowing for all sorts of nifty things like SSH and NFS in one go plus charging over the same wire, at higher speeds than most Wifi connections.

Kernel support
Currently, the g_ether module is not compiled as part of our kernel configuration.

To enable this, follow the kernel building information of our manual build howto. But then after making defconfig, either run: make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig

Then trawl down the options and set the "Ethernet Gadget" to "m": Device Drivers ---> USB support ---> <*>   USB Gadget Support  --->    Ethernet Gadget (with CDC Ethernet support) <*>   NOP USB Transceiver Driver [*]   SUNXI USB2.0 Dual Role Controller support ---> [*]   Sunxi USB2.0 Manager USB0 Controller support (otg support) ---> (*) otg support Or just run: ./scripts/config -m CONFIG_USB_ETH -e CONFIG_USB_ETH_RNDIS -e CONFIG_USB_OTG_UTILS -e CONFIG_NOP_USB_XCEIV -e CONFIG_USB_SW_SUNXI_USB -e CONFIG_USB_SW_SUNXI_USB_MANAGER -e CONFIG_USB_SW_SUNXI_USB0_OTG

You can now continue following our manual build howto to continue kernel compilation and installation.

Loading the driver (on the device)
We should now be able to run: modprobe g_ether successfully. We can then make this module autoload by adding it to /etc/modules.

Now, so that g_ether doesn't randomly generate a new id every reboot, stick the following in /etc/modprobe.d/g_ether.conf: options g_ether host_addr=00:11:22:33:44:55

g_ether should've just generated a pair of addresses for you, so replace 00:11:22:33:44:55 with the outcome of: dmesg | grep "HOST MAC"

Without network manager
Stop networkmanager: stop network-manager

To prevent network-manager from starting, run: echo "manual" > /etc/init/network-manager.override

Now add the following to /etc/network/interfaces: auto usb0 iface usb0 inet static address 192.168.0.2 netmask 255.255.255.0

To manually activate the interface and set an IP: ifconfig usb0 up     ifconfig usb0 192.168.0.2

Setting up the host
You can convince networkmanager to connect automatically to a specific MAC address, and then you need to hardcode the address to 192.168.0.1 for this connection.

If all goes well, you should now be able to just plug in the USB cable.

= USB storage support =

TODO.