USB Gadget mode with Arch Linux and the Raspberry Pi Zero

The low-cost Raspberry Pi Zero is missing some critical hardware that usually makes the a Raspberry Pi desirable. Namely:

  • Ethernet port
  • Multiple USB Ports

Multiple USB ports are easily attached with a USB hub, and Ethernet (wired or wireless) is easily attached via USB as well.

So much cabling, though, is inconvenient. Most of the time, Ethernet and additional USB devices are only needed to develop or get code onto the pi. Gadget mode can simplify life significantly, since it allows the Pi Zero to behave as a USB host device, namely an Ethernet adapter (via the g_ether driver). Linux has apparently had this support for some time.

Thanks to the Arch Linux maintainer Kevin Mihelich for including kernel 4.4 and the appropriate kernel modules to enable this feature. The steps I took to get g_ether working are:

  • Update config.txt to resemble:
  • update /etc/modules-load.d/raspberrypi.conf
  • create /etc/modprobe.d/g_ether.conf
  • replace /etc/dhcpd.conf
  • enable the services to start on bootup
  • Restart the pi
  • At this point you should be able to use ssh alarm@ to connect ot the pi. To share your internet connection, you will need to allow forwarding and enable ip masquerading on your host computer (commands for Fedora 23):

I’m gonna save this base image somewhere so that I can quickly create a micro-sd image for a new Raspberry Pi Zero if they ever become generally available