Skip to content

Instantly share code, notes, and snippets.

@ibndias
Forked from gbaman/HowToOTGFast.md
Last active February 17, 2019 04:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ibndias/bbd6fea7668cfc45a8c51c97b8cad717 to your computer and use it in GitHub Desktop.
Save ibndias/bbd6fea7668cfc45a8c51c97b8cad717 to your computer and use it in GitHub Desktop.
Simple guide for setting up OTG modes on the Raspberry Pi Zero, the fast way!

###Setting up Pi Zero OTG - The quick way (No USB keyboard, mouse, HDMI monitor needed)
More details - http://blog.gbaman.info/?p=791

For this method, alongside your Pi Zero, MicroUSB cable and MicroSD card, only an additional computer is required, which can be running Windows (with Bonjour, iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu has it built in).
1. Flash Raspbian Jessie full or Raspbian Jessie Lite onto the SD card.
2. Once Raspbian is flashed, open up the boot partition (in Windows Explorer, Finder etc) and add to the bottom of the config.txt file dtoverlay=dwc2 on a new line, then save the file.
3. Finally, open up the cmdline.txt. Be careful with this file, it is very picky with its formatting! Each parameter is seperated by a single space (it does not use newlines). Insert modules-load=dwc2,g_ether after rootwait. To compare, an edited version of the cmdline.txt file at the time of writing, can be found here.
4. That's it, eject the SD card from your computer, put it in your Raspberry Pi Zero and connect it via USB to your computer. It will take up to 90s to boot up (shorter on subsequent boots). It should then appear as a USB Ethernet device. You can SSH into it using raspberrypi.local as the address.

$ ping raspberrypi.local

$ ssh pi@raspberrypi.local

###Troubleshoot for refused SSH connection: SSH is (infuriatingly) disabled by default in Jessie, as of 11-2016. So you will get 'Connection Refused' when you try to ssh in. The solution is either to use an older version, or after you edit the 2 files, do 'touch /path/to/boot_volume/ssh' (add a blank file named 'ssh' in the same directory where config.txt and cmdline.txt are.

###Troubleshoot for "Could not resolve hostname raspberrypi.local": AndrewS 2nd June 2016 at 11:04 am More details - http://blog.gbaman.info/?p=791#comment-136365

I also had the same problem with the USB-network only working over IPv6 on Ubuntu 14.04, but I figured out how to also get it working over IPv4, which ‘fixes’ raspberrypi.local 🙂

You need to go into the network-manager menu, Edit Connections… and edit the new Ethernet connection (for me it was “Wired connection 2”). Switch to the IPv4 tab, and change the Method to “Link-Local only”. Click Save and then Close.

The usb0 network interface will then get assigned a 169.254.x.y address, and “ssh pi@raspberrypi.local” will work just like it should.

###Troubleshoot for "Annoying new network connection each boot": PiMuncher 8th June 2016 at 4:31 pm More details - http://blog.gbaman.info/?p=791#comment-136484 One thing I noticed is the MAC address of the network connections (on both the device and host) are randomly generated at each boot. This is a bit annoying if you want to use a DHCP server to reserve a IP address for your gadget.

I got round this problem by adding the following after “rootwait modules-load=dwc2,g_ether ” in the “cmdline.txt” file: g_ether.dev_addr=11:22:33:44:55:66

You can also specify other options for host_addr, iManufacturer and iProduct, but I haven’t had time to try these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment