Skip to content

Instantly share code, notes, and snippets.

@drmaq
Forked from gbaman/HowToOTG.md
Created October 22, 2018 03:22
Show Gist options
  • Select an option

  • Save drmaq/950668a96af606a7cc2d624de7f6eac8 to your computer and use it in GitHub Desktop.

Select an option

Save drmaq/950668a96af606a7cc2d624de7f6eac8 to your computer and use it in GitHub Desktop.

Revisions

  1. @gbaman gbaman revised this gist May 18, 2016. 1 changed file with 1 addition and 5 deletions.
    6 changes: 1 addition & 5 deletions HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -12,11 +12,7 @@ There are 2 routes you can take for setting up the Raspberry Pi Zero as a USB Sl
    2. **The modular slower, but more flexible route** - This route requires a screen and keyboard to configure your Pi Zero once it has completed its first boot.

    ###1. Very quick way (No USB keyboard, mouse, HDMI monitor needed)
    For this method, only an additional computer is required, which can be running Windows (with [Bonjour](https://support.apple.com/kb/DL999), iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu has it built in).
    **1.** Flash Raspbian full or Raspbian Jessie [onto the SD card](https://www.raspberrypi.org/documentation/installation/installing-images/README.md).
    **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](http://pastebin.com/WygSaptQ).
    **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.
    The newer method has now been brought out into a separate Gist, [which can be found here](http://bit.ly/pi-otg).

    ###2. Modular, but slower to setup method
    For this method, a Pi Zero, SD card (with Raspbian Jessie lite or full), screen and keyboard are required.
  2. @gbaman gbaman revised this gist May 18, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ It is also important to note, that **a USB to UART serial adapter is not needed
    ##Which process should I choose?
    There are 2 routes you can take for setting up the Raspberry Pi Zero as a USB Slave (OTG mode).
    1. **The quick route** - The quick route doesn't require anything beside your Pi Zero, SD card and a Windows, Mac or Linux computer. It though only supports setting up the Pi Zero as a virtual Ethernet device (allowing full SSH, SFTP, VNC etc). For any of the other USB Gadget drivers (beside g_ether), use route 2.
    2. **The modular slower, but more flexible route** - This route requires a screen and keyboard to configure your Pi Zero once it has completed its first boot, but no web connectivity is required.
    2. **The modular slower, but more flexible route** - This route requires a screen and keyboard to configure your Pi Zero once it has completed its first boot.

    ###1. Very quick way (No USB keyboard, mouse, HDMI monitor needed)
    For this method, only an additional computer is required, which can be running Windows (with [Bonjour](https://support.apple.com/kb/DL999), iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu has it built in).
  3. @gbaman gbaman revised this gist May 18, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@ For this method, only an additional computer is required, which can be running W
    **1.** Flash Raspbian full or Raspbian Jessie [onto the SD card](https://www.raspberrypi.org/documentation/installation/installing-images/README.md).
    **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](http://pastebin.com/WygSaptQ).
    **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.
    **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.

    ###2. Modular, but slower to setup method
    For this method, a Pi Zero, SD card (with Raspbian Jessie lite or full), screen and keyboard are required.
  4. @gbaman gbaman revised this gist May 18, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ There are 2 routes you can take for setting up the Raspberry Pi Zero as a USB Sl
    ###1. Very quick way (No USB keyboard, mouse, HDMI monitor needed)
    For this method, only an additional computer is required, which can be running Windows (with [Bonjour](https://support.apple.com/kb/DL999), iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu has it built in).
    **1.** Flash Raspbian full or Raspbian Jessie [onto the SD card](https://www.raspberrypi.org/documentation/installation/installing-images/README.md).
    **2.** Once Raspbian is flashed, open up the boot partition and add to the bottom of the ```config.txt``` file ```dtoverlay=dwc2``` on a new line, then save the file.
    **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](http://pastebin.com/WygSaptQ).
    **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.

  5. @gbaman gbaman revised this gist May 18, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ There are 2 routes you can take for setting up the Raspberry Pi Zero as a USB Sl
    2. **The modular slower, but more flexible route** - This route requires a screen and keyboard to configure your Pi Zero once it has completed its first boot, but no web connectivity is required.

    ###1. Very quick way (No USB keyboard, mouse, HDMI monitor needed)
    For this method, only an additional computer is required, which can be running Windows (with [Bonjour](https://support.apple.com/kb/DL999), iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu).
    For this method, only an additional computer is required, which can be running Windows (with [Bonjour](https://support.apple.com/kb/DL999), iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu has it built in).
    **1.** Flash Raspbian full or Raspbian Jessie [onto the SD card](https://www.raspberrypi.org/documentation/installation/installing-images/README.md).
    **2.** Once Raspbian is flashed, open up the boot partition 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](http://pastebin.com/WygSaptQ).
  6. @gbaman gbaman revised this gist May 18, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ There are 2 routes you can take for setting up the Raspberry Pi Zero as a USB Sl
    2. **The modular slower, but more flexible route** - This route requires a screen and keyboard to configure your Pi Zero once it has completed its first boot, but no web connectivity is required.

    ###1. Very quick way (No USB keyboard, mouse, HDMI monitor needed)
    For this method, only an additional computer is required, which can be running Windows (with (Bonjour)[https://support.apple.com/kb/DL999], iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu).
    For this method, only an additional computer is required, which can be running Windows (with [Bonjour](https://support.apple.com/kb/DL999), iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu).
    **1.** Flash Raspbian full or Raspbian Jessie [onto the SD card](https://www.raspberrypi.org/documentation/installation/installing-images/README.md).
    **2.** Once Raspbian is flashed, open up the boot partition 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](http://pastebin.com/WygSaptQ).
  7. @gbaman gbaman revised this gist May 18, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ For this method, only an additional computer is required, which can be running W
    **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](http://pastebin.com/WygSaptQ).
    **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.

    ###2. Modular, but slower method
    ###2. Modular, but slower to setup method
    For this method, a Pi Zero, SD card (with Raspbian Jessie lite or full), screen and keyboard are required.
    You are able to set up any of the below modules using this method and are not just limited to ```g_ether```. The required kernels are also now shipped with Raspbian 2016-05-10 releases and beyond. So no need to do a ```raspi-update```.
    No web connectivity is required, nor is a USB-UART adapter required for this method.
  8. @gbaman gbaman revised this gist May 18, 2016. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -13,10 +13,10 @@ There are 2 routes you can take for setting up the Raspberry Pi Zero as a USB Sl

    ###1. Very quick way (No USB keyboard, mouse, HDMI monitor needed)
    For this method, only an additional computer is required, which can be running Windows (with (Bonjour)[https://support.apple.com/kb/DL999], iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu).
    1. Flash Raspbian full or Raspbian Jessie [onto the SD card](https://www.raspberrypi.org/documentation/installation/installing-images/README.md).
    2. Once Raspbian is flashed, open up the boot partition 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```. My file now reads (although could change in the future), ```dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether quiet init=/usr/lib/raspi-config/init_resize.sh```.
    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.
    **1.** Flash Raspbian full or Raspbian Jessie [onto the SD card](https://www.raspberrypi.org/documentation/installation/installing-images/README.md).
    **2.** Once Raspbian is flashed, open up the boot partition 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](http://pastebin.com/WygSaptQ).
    **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.

    ###2. Modular, but slower method
    For this method, a Pi Zero, SD card (with Raspbian Jessie lite or full), screen and keyboard are required.
  9. @gbaman gbaman revised this gist May 18, 2016. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -4,12 +4,12 @@ Simple guide for setting up OTG modes on the Raspberry Pi Zero - By Andrew Mulho
    The Raspberry Pi Zero (and model A and A+) support USB On The Go, given the processor is connected directly to the USB port, unlike on the B, B+ or Pi 2 B, which goes via a USB hub.
    Because of this, if setup to, the Pi can act as a USB slave instead, providing virtual serial (a terminal), virtual ethernet, virtual mass storage device (pendrive) or even other virtual devices like HID, MIDI, or act as a virtual webcam!
    It is important to note that, although the model A and A+ can support being a USB slave, they are missing the ID pin (is tied to ground internally) so are unable to dynamically switch between USB master/slave mode. As such, they default to USB master mode. There is no easy way to change this right now.
    It is also important to note, that **a USB to UART serial adapter is not needed for any of these guides**, as may be documented elsewhere across the internet.

    ##Which process should I choose?
    There are 2 routes you can take for setting up the Raspberry Pi Zero as a USB Slave (OTG mode).
    1. **The quick route** - The quick route doesn't require anything beside your Pi Zero, SD card and a Windows, Mac or Linux computer. It though only supports setting up the Pi Zero as a virtual Ethernet device (allowing full SSH, SFTP, VNC etc). For any of the other USB Gadget drivers (beside g_ether), use route 2. A **USB-UART adapter is also not required for this route**.
    There are 2 routes you can take for setting up the Raspberry Pi Zero as a USB Slave (OTG mode).
    1. **The quick route** - The quick route doesn't require anything beside your Pi Zero, SD card and a Windows, Mac or Linux computer. It though only supports setting up the Pi Zero as a virtual Ethernet device (allowing full SSH, SFTP, VNC etc). For any of the other USB Gadget drivers (beside g_ether), use route 2.
    2. **The modular slower, but more flexible route** - This route requires a screen and keyboard to configure your Pi Zero once it has completed its first boot, but no web connectivity is required.
    A **USB-UART adapter is also not required for this route**.

    ###1. Very quick way (No USB keyboard, mouse, HDMI monitor needed)
    For this method, only an additional computer is required, which can be running Windows (with (Bonjour)[https://support.apple.com/kb/DL999], iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu).
  10. @gbaman gbaman revised this gist May 18, 2016. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -7,8 +7,9 @@ It is important to note that, although the model A and A+ can support being a US

    ##Which process should I choose?
    There are 2 routes you can take for setting up the Raspberry Pi Zero as a USB Slave (OTG mode).
    1. The quick route - The quick route doesn't require anything beside your Pi Zero, SD card and a Windows, Mac or Linux computer. It though only supports setting up the Pi Zero as a virtual Ethernet device (allowing full SSH, SFTP, VNC etc). For any of the other USB Gadget drivers (beside g_ether), use route 2. A **USB-UART adapter is also not required for this route**.
    2. The modular slower, but more flexible route - This route requires a screen and keyboard to configure your Pi Zero once it has completed its first boot, but no web connectivity is required. A **USB-UART adapter is also not required for this route**.
    1. **The quick route** - The quick route doesn't require anything beside your Pi Zero, SD card and a Windows, Mac or Linux computer. It though only supports setting up the Pi Zero as a virtual Ethernet device (allowing full SSH, SFTP, VNC etc). For any of the other USB Gadget drivers (beside g_ether), use route 2. A **USB-UART adapter is also not required for this route**.
    2. **The modular slower, but more flexible route** - This route requires a screen and keyboard to configure your Pi Zero once it has completed its first boot, but no web connectivity is required.
    A **USB-UART adapter is also not required for this route**.

    ###1. Very quick way (No USB keyboard, mouse, HDMI monitor needed)
    For this method, only an additional computer is required, which can be running Windows (with (Bonjour)[https://support.apple.com/kb/DL999], iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu).
  11. @gbaman gbaman revised this gist May 18, 2016. 1 changed file with 8 additions and 8 deletions.
    16 changes: 8 additions & 8 deletions HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -5,17 +5,17 @@ The Raspberry Pi Zero (and model A and A+) support USB On The Go, given the proc
    Because of this, if setup to, the Pi can act as a USB slave instead, providing virtual serial (a terminal), virtual ethernet, virtual mass storage device (pendrive) or even other virtual devices like HID, MIDI, or act as a virtual webcam!
    It is important to note that, although the model A and A+ can support being a USB slave, they are missing the ID pin (is tied to ground internally) so are unable to dynamically switch between USB master/slave mode. As such, they default to USB master mode. There is no easy way to change this right now.

    ##Which process should I choose?
    There are 2 routes you can take for setting up the Raspberry Pi Zero as a USB Slave (OTG mode).
    1. The quick route - The quick route doesn't require anything beside your Pi Zero, SD card and a Windows, Mac or Linux computer. It though only supports setting up the Pi Zero as a virtual Ethernet device (allowing full SSH, SFTP, VNC etc). For any of the other USB Gadget drivers (beside g_ether), use route 2. A **USB-UART adapter is also not required for this route**.
    2. The modular slower, but more flexible route - This route requires a screen and keyboard to configure your Pi Zero once it has completed its first boot, but no web connectivity is required. A **USB-UART adapter is also not required for this route**.
    ##Which process should I choose?
    There are 2 routes you can take for setting up the Raspberry Pi Zero as a USB Slave (OTG mode).
    1. The quick route - The quick route doesn't require anything beside your Pi Zero, SD card and a Windows, Mac or Linux computer. It though only supports setting up the Pi Zero as a virtual Ethernet device (allowing full SSH, SFTP, VNC etc). For any of the other USB Gadget drivers (beside g_ether), use route 2. A **USB-UART adapter is also not required for this route**.
    2. The modular slower, but more flexible route - This route requires a screen and keyboard to configure your Pi Zero once it has completed its first boot, but no web connectivity is required. A **USB-UART adapter is also not required for this route**.

    ###1. Very quick way (No USB keyboard, mouse, HDMI monitor needed)
    For this method, only an additional computer is required, which can be running Windows (with (Bonjour)[https://support.apple.com/kb/DL999], iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu).
    1. Flash Raspbian full or Raspbian Jessie [onto the SD card](https://www.raspberrypi.org/documentation/installation/installing-images/README.md).
    2. Once Raspbian is flashed, open up the boot partition 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```. My file now reads (although could change in the future), ```dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether quiet init=/usr/lib/raspi-config/init_resize.sh```
    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.
    1. Flash Raspbian full or Raspbian Jessie [onto the SD card](https://www.raspberrypi.org/documentation/installation/installing-images/README.md).
    2. Once Raspbian is flashed, open up the boot partition 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```. My file now reads (although could change in the future), ```dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether quiet init=/usr/lib/raspi-config/init_resize.sh```.
    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.

    ###2. Modular, but slower method
    For this method, a Pi Zero, SD card (with Raspbian Jessie lite or full), screen and keyboard are required.
  12. @gbaman gbaman revised this gist May 18, 2016. 1 changed file with 22 additions and 9 deletions.
    31 changes: 22 additions & 9 deletions HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -3,9 +3,25 @@ Simple guide for setting up OTG modes on the Raspberry Pi Zero - By Andrew Mulho

    The Raspberry Pi Zero (and model A and A+) support USB On The Go, given the processor is connected directly to the USB port, unlike on the B, B+ or Pi 2 B, which goes via a USB hub.
    Because of this, if setup to, the Pi can act as a USB slave instead, providing virtual serial (a terminal), virtual ethernet, virtual mass storage device (pendrive) or even other virtual devices like HID, MIDI, or act as a virtual webcam!
    It is important to note that, although the model A and A+ can support being a USB slave, they are missing the ID pin (is tied to ground internally) so are unable to dynamically switch between USB master/slave mode. As such, they default to USB master mode. There is no easy way to change this right now.

    ##Modular (official branch) - Recommended
    This is now the recommended process, all other processes use custom kernels. This process uses the official Raspberry Pi Foundation maintained kernels, although they still are classed as alpha. This new documentation is based off the excellent work from a number of people on the [Github pull request](https://github.com/raspberrypi/linux/pull/1239).
    ##Which process should I choose?
    There are 2 routes you can take for setting up the Raspberry Pi Zero as a USB Slave (OTG mode).
    1. The quick route - The quick route doesn't require anything beside your Pi Zero, SD card and a Windows, Mac or Linux computer. It though only supports setting up the Pi Zero as a virtual Ethernet device (allowing full SSH, SFTP, VNC etc). For any of the other USB Gadget drivers (beside g_ether), use route 2. A **USB-UART adapter is also not required for this route**.
    2. The modular slower, but more flexible route - This route requires a screen and keyboard to configure your Pi Zero once it has completed its first boot, but no web connectivity is required. A **USB-UART adapter is also not required for this route**.

    ###1. Very quick way (No USB keyboard, mouse, HDMI monitor needed)
    For this method, only an additional computer is required, which can be running Windows (with (Bonjour)[https://support.apple.com/kb/DL999], iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu).
    1. Flash Raspbian full or Raspbian Jessie [onto the SD card](https://www.raspberrypi.org/documentation/installation/installing-images/README.md).
    2. Once Raspbian is flashed, open up the boot partition 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```. My file now reads (although could change in the future), ```dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether quiet init=/usr/lib/raspi-config/init_resize.sh```
    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.

    ###2. Modular, but slower method
    For this method, a Pi Zero, SD card (with Raspbian Jessie lite or full), screen and keyboard are required.
    You are able to set up any of the below modules using this method and are not just limited to ```g_ether```. The required kernels are also now shipped with Raspbian 2016-05-10 releases and beyond. So no need to do a ```raspi-update```.
    No web connectivity is required, nor is a USB-UART adapter required for this method.
    This documentation is based off the initial excellent work done on this [Github pull request](https://github.com/raspberrypi/linux/pull/1239).
    **Modules included**
    - Serial (g_serial)
    - Ethernet (g_ether)
    @@ -21,14 +37,11 @@ In addition to the above modules, a few other (less useful) modules are included
    - Printer (g_printer)
    - Gadget tester (g_zero)

    Hopefully, these modules will be included with the next Raspbian release, but for now you can manually add them.

    1. First, flash Jessie (only tested on full, lite version may also work though) onto a blank microSD card.
    2. Boot it up and resize the root partition (open a terminal and enter ```sudo raspi-config```, then select expand and reboot).
    3. **(step only needed if running Raspbain version before 2016-05-10)** Once it starts up again, run ```sudo BRANCH=next rpi-update```. This will take a while.
    4. Next we need to make sure we are using the dwc2 USB driver ```echo "dtoverlay=dwc2" | sudo tee -a /boot/config.txt```.
    5. And enable it in Raspbian ```echo "dwc2" | sudo tee -a /etc/modules```
    6. Need to now pick which module you want to use from the list above, for example for ethernet ```echo "g_ether" | sudo tee -a /etc/modules```. You can only pick one of the above modules to use at a time.
    2. **(step only needed if running Raspbain version before 2016-05-10)** Once it starts up again, run ```sudo BRANCH=next rpi-update```. This will take a while.
    3. Next we need to make sure we are using the dwc2 USB driver ```echo "dtoverlay=dwc2" | sudo tee -a /boot/config.txt```.
    4. And enable it in Raspbian ```echo "dwc2" | sudo tee -a /etc/modules```
    5. Need to now pick which module you want to use from the list above, for example for ethernet ```echo "g_ether" | sudo tee -a /etc/modules```. You can only pick one of the above modules to use at a time.

    ### Using the modules
    - **g_serial** - To use the standard serial module, you need to tell the Pi to forward the serial console to it with ```sudo systemctl enable [email protected]```, then you can connect to the device via Putty or Screen.
  13. @gbaman gbaman revised this gist May 18, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ Hopefully, these modules will be included with the next Raspbian release, but fo

    1. First, flash Jessie (only tested on full, lite version may also work though) onto a blank microSD card.
    2. Boot it up and resize the root partition (open a terminal and enter ```sudo raspi-config```, then select expand and reboot).
    3. (step only needed if running Raspbain version before 2016-05-10) Once it starts up again, run ```sudo BRANCH=next rpi-update```. This will take a while.
    3. **(step only needed if running Raspbain version before 2016-05-10)** Once it starts up again, run ```sudo BRANCH=next rpi-update```. This will take a while.
    4. Next we need to make sure we are using the dwc2 USB driver ```echo "dtoverlay=dwc2" | sudo tee -a /boot/config.txt```.
    5. And enable it in Raspbian ```echo "dwc2" | sudo tee -a /etc/modules```
    6. Need to now pick which module you want to use from the list above, for example for ethernet ```echo "g_ether" | sudo tee -a /etc/modules```. You can only pick one of the above modules to use at a time.
  14. @gbaman gbaman revised this gist May 18, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ Hopefully, these modules will be included with the next Raspbian release, but fo

    1. First, flash Jessie (only tested on full, lite version may also work though) onto a blank microSD card.
    2. Boot it up and resize the root partition (open a terminal and enter ```sudo raspi-config```, then select expand and reboot).
    3. Once it starts up again, run ```sudo BRANCH=next rpi-update```. This will take a while.
    3. (step only needed if running Raspbain version before 2016-05-10) Once it starts up again, run ```sudo BRANCH=next rpi-update```. This will take a while.
    4. Next we need to make sure we are using the dwc2 USB driver ```echo "dtoverlay=dwc2" | sudo tee -a /boot/config.txt```.
    5. And enable it in Raspbian ```echo "dwc2" | sudo tee -a /etc/modules```
    6. Need to now pick which module you want to use from the list above, for example for ethernet ```echo "g_ether" | sudo tee -a /etc/modules```. You can only pick one of the above modules to use at a time.
  15. @gbaman gbaman revised this gist May 9, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,7 @@ In addition to the above modules, a few other (less useful) modules are included

    Hopefully, these modules will be included with the next Raspbian release, but for now you can manually add them.

    1. First, flash Jessie (full, not lite) onto a blank microSD card.
    1. First, flash Jessie (only tested on full, lite version may also work though) onto a blank microSD card.
    2. Boot it up and resize the root partition (open a terminal and enter ```sudo raspi-config```, then select expand and reboot).
    3. Once it starts up again, run ```sudo BRANCH=next rpi-update```. This will take a while.
    4. Next we need to make sure we are using the dwc2 USB driver ```echo "dtoverlay=dwc2" | sudo tee -a /boot/config.txt```.
  16. @gbaman gbaman revised this gist Mar 6, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -27,12 +27,12 @@ Hopefully, these modules will be included with the next Raspbian release, but fo
    2. Boot it up and resize the root partition (open a terminal and enter ```sudo raspi-config```, then select expand and reboot).
    3. Once it starts up again, run ```sudo BRANCH=next rpi-update```. This will take a while.
    4. Next we need to make sure we are using the dwc2 USB driver ```echo "dtoverlay=dwc2" | sudo tee -a /boot/config.txt```.
    5. And enable it in Raspbian ```echo "dwc2" | sudo tee /etc/modules```
    5. And enable it in Raspbian ```echo "dwc2" | sudo tee -a /etc/modules```
    6. Need to now pick which module you want to use from the list above, for example for ethernet ```echo "g_ether" | sudo tee -a /etc/modules```. You can only pick one of the above modules to use at a time.

    ### Using the modules
    - **g_serial** - To use the standard serial module, you need to tell the Pi to forward the serial console to it with ```sudo systemctl enable [email protected]```, then you can connect to the device via Putty or Screen.
    - **g_ether** - Using virtual ethernet, you should simply be able to ssh into the address of your Raspberry Pi. To do this, there is a little extra configuration required though. There is a few ways we could set up the point to point networking. The proper way would be to set up a DHCP server on one of the ends. A far simplier was though is just to give the Raspberry Pi a fixed IP address. To do this, you will need to run ```echo -e "interface usb0 \nstatic ip_address=169.254.64.64" | sudo tee /etc/dhcpcd.conf```. You can then access the Raspberry Pi Zero by connecting to ```169.254.64.64```, or by using ```raspberrypi.local``` if your computer has Bonjour installed (Mac and most Linux OSs including Raspbian). Note this method does not support adding a fixed address to the cmdline.txt file. For that, you have to use the Ethernet only kernel below.
    - **g_ether** - Using virtual ethernet, you should simply be able to ssh into the address of your Raspberry Pi. To do this, there is a little extra configuration required though. There is a few ways we could set up the point to point networking. The proper way would be to set up a DHCP server on one of the ends. A far simplier was though is just to give the Raspberry Pi a fixed IP address. To do this, you will need to run ```echo -e "interface usb0 \nstatic ip_address=169.254.64.64" | sudo tee -a /etc/dhcpcd.conf```. You can then access the Raspberry Pi Zero by connecting to ```169.254.64.64```, or by using ```raspberrypi.local``` if your computer has Bonjour installed (Mac and most Linux OSs including Raspbian). Note this method does not support adding a fixed address to the cmdline.txt file. For that, you have to use the Ethernet only kernel below.
    - **g_mass_storage** - To have your Pi Zero appear as a mass storage device (flash drive), first create a mini filesystem in a file on your Pi with ```sudo dd if=/dev/zero of=/piusb.bin bs=512 count=2880``` and set it up as a fat32 filesystem with ```sudo mkdosfs /piusb.bin```. Then, when enabling it, add ```file=/piusb.bin stall=0``` onto the end, for example ```sudo modprobe g_mass_storage file=/piusb.bin stall=0```.

    In theory, most USB devices should work alongside these kernels, to switch to USB OTG mode, simply don't use an OTG adapter cable and use a standard USB cable to plug your Pi Zero into another computer, it should auto switch.
  17. @gbaman gbaman revised this gist Feb 14, 2016. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -26,13 +26,13 @@ Hopefully, these modules will be included with the next Raspbian release, but fo
    1. First, flash Jessie (full, not lite) onto a blank microSD card.
    2. Boot it up and resize the root partition (open a terminal and enter ```sudo raspi-config```, then select expand and reboot).
    3. Once it starts up again, run ```sudo BRANCH=next rpi-update```. This will take a while.
    4. Next we need to make sure we are using the dwc2 USB driver ```sudo echo "dtoverlay=dwc2" | tee /boot/config.txt```.
    5. And enable it in Raspbian ```sudo echo "dwc2" | tee /etc/modules```
    6. Need to now pick which module you want to use from the list above, for example for ethernet ```sudo echo "g_ether" >> /etc/modules```. You can only pick one of the above modules to use at a time.
    4. Next we need to make sure we are using the dwc2 USB driver ```echo "dtoverlay=dwc2" | sudo tee -a /boot/config.txt```.
    5. And enable it in Raspbian ```echo "dwc2" | sudo tee /etc/modules```
    6. Need to now pick which module you want to use from the list above, for example for ethernet ```echo "g_ether" | sudo tee -a /etc/modules```. You can only pick one of the above modules to use at a time.

    ### Using the modules
    - **g_serial** - To use the standard serial module, you need to tell the Pi to forward the serial console to it with ```sudo systemctl enable [email protected]```, then you can connect to the device via Putty or Screen.
    - **g_ether** - Using virtual ethernet, you should simply be able to ssh into the address of your Raspberry Pi. To do this, there is a little extra configuration required though. There is a few ways we could set up the point to point networking. The proper way would be to set up a DHCP server on one of the ends. A far simplier was though is just to give the Raspberry Pi a fixed IP address. To do this, you will need to run ```sudo echo -e "interface usb0 \nstatic ip_address=169.254.64.64" | sudo tee /etc/dhcpcd.conf```. You can then access the Raspberry Pi Zero by connecting to ```169.254.64.64```, or by using ```raspberrypi.local``` if your computer has Bonjour installed (Mac and most Linux OSs including Raspbian). Note this method does not support adding a fixed address to the cmdline.txt file. For that, you have to use the Ethernet only kernel below.
    - **g_ether** - Using virtual ethernet, you should simply be able to ssh into the address of your Raspberry Pi. To do this, there is a little extra configuration required though. There is a few ways we could set up the point to point networking. The proper way would be to set up a DHCP server on one of the ends. A far simplier was though is just to give the Raspberry Pi a fixed IP address. To do this, you will need to run ```echo -e "interface usb0 \nstatic ip_address=169.254.64.64" | sudo tee /etc/dhcpcd.conf```. You can then access the Raspberry Pi Zero by connecting to ```169.254.64.64```, or by using ```raspberrypi.local``` if your computer has Bonjour installed (Mac and most Linux OSs including Raspbian). Note this method does not support adding a fixed address to the cmdline.txt file. For that, you have to use the Ethernet only kernel below.
    - **g_mass_storage** - To have your Pi Zero appear as a mass storage device (flash drive), first create a mini filesystem in a file on your Pi with ```sudo dd if=/dev/zero of=/piusb.bin bs=512 count=2880``` and set it up as a fat32 filesystem with ```sudo mkdosfs /piusb.bin```. Then, when enabling it, add ```file=/piusb.bin stall=0``` onto the end, for example ```sudo modprobe g_mass_storage file=/piusb.bin stall=0```.

    In theory, most USB devices should work alongside these kernels, to switch to USB OTG mode, simply don't use an OTG adapter cable and use a standard USB cable to plug your Pi Zero into another computer, it should auto switch.
  18. @gbaman gbaman revised this gist Jan 17, 2016. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -26,13 +26,13 @@ Hopefully, these modules will be included with the next Raspbian release, but fo
    1. First, flash Jessie (full, not lite) onto a blank microSD card.
    2. Boot it up and resize the root partition (open a terminal and enter ```sudo raspi-config```, then select expand and reboot).
    3. Once it starts up again, run ```sudo BRANCH=next rpi-update```. This will take a while.
    4. Next we need to make sure we are using the dwc2 USB driver ```sudo echo "dtoverlay=dwc2" >> /boot/config.txt```.
    5. And enable it in Raspbian ```sudo echo "dwc2" >> /etc/modules```
    4. Next we need to make sure we are using the dwc2 USB driver ```sudo echo "dtoverlay=dwc2" | tee /boot/config.txt```.
    5. And enable it in Raspbian ```sudo echo "dwc2" | tee /etc/modules```
    6. Need to now pick which module you want to use from the list above, for example for ethernet ```sudo echo "g_ether" >> /etc/modules```. You can only pick one of the above modules to use at a time.

    ### Using the modules
    - **g_serial** - To use the standard serial module, you need to tell the Pi to forward the serial console to it with ```sudo systemctl enable [email protected]```, then you can connect to the device via Putty or Screen.
    - **g_ether** - Using virtual ethernet, you should simply be able to ssh into the address of your Raspberry Pi. To do this, there is a little extra configuration required though. There is a few ways we could set up the point to point networking. The proper way would be to set up a DHCP server on one of the ends. A far simplier was though is just to give the Raspberry Pi a fixed IP address. To do this, you will need to run ```sudo echo -e "interface usb0 \nstatic ip_address=169.254.64.64" >> /etc/dhcpcd.conf```. You can then access the Raspberry Pi Zero by connecting to ```169.254.64.64```, or by using ```raspberrypi.local``` if your computer has Bonjour installed (Mac and most Linux OSs including Raspbian). Note this method does not support adding a fixed address to the cmdline.txt file. For that, you have to use the Ethernet only kernel below.
    - **g_ether** - Using virtual ethernet, you should simply be able to ssh into the address of your Raspberry Pi. To do this, there is a little extra configuration required though. There is a few ways we could set up the point to point networking. The proper way would be to set up a DHCP server on one of the ends. A far simplier was though is just to give the Raspberry Pi a fixed IP address. To do this, you will need to run ```sudo echo -e "interface usb0 \nstatic ip_address=169.254.64.64" | sudo tee /etc/dhcpcd.conf```. You can then access the Raspberry Pi Zero by connecting to ```169.254.64.64```, or by using ```raspberrypi.local``` if your computer has Bonjour installed (Mac and most Linux OSs including Raspbian). Note this method does not support adding a fixed address to the cmdline.txt file. For that, you have to use the Ethernet only kernel below.
    - **g_mass_storage** - To have your Pi Zero appear as a mass storage device (flash drive), first create a mini filesystem in a file on your Pi with ```sudo dd if=/dev/zero of=/piusb.bin bs=512 count=2880``` and set it up as a fat32 filesystem with ```sudo mkdosfs /piusb.bin```. Then, when enabling it, add ```file=/piusb.bin stall=0``` onto the end, for example ```sudo modprobe g_mass_storage file=/piusb.bin stall=0```.

    In theory, most USB devices should work alongside these kernels, to switch to USB OTG mode, simply don't use an OTG adapter cable and use a standard USB cable to plug your Pi Zero into another computer, it should auto switch.
  19. @gbaman gbaman revised this gist Jan 15, 2016. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -30,5 +30,14 @@ Hopefully, these modules will be included with the next Raspbian release, but fo
    5. And enable it in Raspbian ```sudo echo "dwc2" >> /etc/modules```
    6. Need to now pick which module you want to use from the list above, for example for ethernet ```sudo echo "g_ether" >> /etc/modules```. You can only pick one of the above modules to use at a time.

    ### Using the modules
    - **g_serial** - To use the standard serial module, you need to tell the Pi to forward the serial console to it with ```sudo systemctl enable [email protected]```, then you can connect to the device via Putty or Screen.
    - **g_ether** - Using virtual ethernet, you should simply be able to ssh into the address of your Raspberry Pi. To do this, there is a little extra configuration required though. There is a few ways we could set up the point to point networking. The proper way would be to set up a DHCP server on one of the ends. A far simplier was though is just to give the Raspberry Pi a fixed IP address. To do this, you will need to run ```sudo echo -e "interface usb0 \nstatic ip_address=169.254.64.64" >> /etc/dhcpcd.conf```. You can then access the Raspberry Pi Zero by connecting to ```169.254.64.64```, or by using ```raspberrypi.local``` if your computer has Bonjour installed (Mac and most Linux OSs including Raspbian). Note this method does not support adding a fixed address to the cmdline.txt file. For that, you have to use the Ethernet only kernel below.
    - **g_mass_storage** - To have your Pi Zero appear as a mass storage device (flash drive), first create a mini filesystem in a file on your Pi with ```sudo dd if=/dev/zero of=/piusb.bin bs=512 count=2880``` and set it up as a fat32 filesystem with ```sudo mkdosfs /piusb.bin```. Then, when enabling it, add ```file=/piusb.bin stall=0``` onto the end, for example ```sudo modprobe g_mass_storage file=/piusb.bin stall=0```.

    In theory, most USB devices should work alongside these kernels, to switch to USB OTG mode, simply don't use an OTG adapter cable and use a standard USB cable to plug your Pi Zero into another computer, it should auto switch.



    ## Legacy guides
    The legacy guides can be [found on a separate Gist](https://gist.github.com/gbaman/4c1345c0c4d6d82149d4).
  20. @gbaman gbaman revised this gist Jan 15, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -22,6 +22,7 @@ In addition to the above modules, a few other (less useful) modules are included
    - Gadget tester (g_zero)

    Hopefully, these modules will be included with the next Raspbian release, but for now you can manually add them.

    1. First, flash Jessie (full, not lite) onto a blank microSD card.
    2. Boot it up and resize the root partition (open a terminal and enter ```sudo raspi-config```, then select expand and reboot).
    3. Once it starts up again, run ```sudo BRANCH=next rpi-update```. This will take a while.
  21. @gbaman gbaman revised this gist Jan 15, 2016. 1 changed file with 18 additions and 59 deletions.
    77 changes: 18 additions & 59 deletions HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -3,72 +3,31 @@ Simple guide for setting up OTG modes on the Raspberry Pi Zero - By Andrew Mulho

    The Raspberry Pi Zero (and model A and A+) support USB On The Go, given the processor is connected directly to the USB port, unlike on the B, B+ or Pi 2 B, which goes via a USB hub.
    Because of this, if setup to, the Pi can act as a USB slave instead, providing virtual serial (a terminal), virtual ethernet, virtual mass storage device (pendrive) or even other virtual devices like HID, MIDI, or act as a virtual webcam!
    Below are a serial of precompiled kernels with instructions for each. It is recommended to go for the Modular kernel below, as it has support for all the Linux Gadget USB modules. It also has full standard USB support, where as some of the non modular ones do not.
    **Note** - If wanting to use the SD card on a Raspberry Pi 2, comment (add a hash in front of) the ```device_tree=``` line on the config.txt file on the boot partition.

    ##Modular (all modules) - Recommended
    Kernels - https://dl.dropboxusercontent.com/u/1122948/temp/PiOTG-Test/PiZeroCombined.tar.gz
    **Modules included**
    ##Modular (official branch) - Recommended
    This is now the recommended process, all other processes use custom kernels. This process uses the official Raspberry Pi Foundation maintained kernels, although they still are classed as alpha. This new documentation is based off the excellent work from a number of people on the [Github pull request](https://github.com/raspberrypi/linux/pull/1239).
    **Modules included**
    - Serial (g_serial)
    - Ethernet (g_ether)
    - Mass storage (g_mass_storage)
    - MIDI (g_midi)
    - Audio (g_audio)
    - Keyboard/Mouse (g_hid)
    - Mass storage and Serial (g_acm_ms)
    - Ethernet and Serial (g_cdc)
    - Multi (g_multi) - Allows you to configure 2 from Ethernet, Mass storage and Serial

    **Note** This section includes standard USB support as well, so can use normal USB devices (like a keyboard) throughout. It should auto switch when plugged into another computer.

    1. First, flash Jessie (full, not lite) onto a blank microSD card.
    2. Copy the tar.gz file onto the boot partition of the image.
    3. Start it up, at this stage should be fine with any Pi, including Pi2.
    4. Do normal first boot stuff (resize image etc with ```sudo raspi-config```).
    5. Run ```tar xvzfC /boot/PiZeroCombined.tar.gz /tmp/```.
    6. Then run ```sudo cp -R /tmp/PiZeroCombined/fat32/* /boot/``` (to copy the kernel and device tree stuff)
    7. Then run ```sudo cp -R /tmp/PiZeroCombined/ext4/lib/* /lib/``` (to copy the kernel modules themselves)
    8. At this point, you have 2 options, you can either set the module you want to run on startup, or dynamically load and unload them.
    9. To set a module to load on startup, edit the modules file with ```sudo nano /etc/modules``` and add the module name you want to start (e.g. g_ether) to the end on a new line. **Also, make sure to the check the "Using the modules" section before rebooting.**
    9. Then, reboot the Raspberry Pi using ```sudo reboot```.
    10. To manually load a kernel module, after rebooting use ```sudo modprobe moduleName```. To unload a module, use ```sudo rmmod moduleName```.

    ### Using the modules
    - **g_serial** - To use the standard serial module, you need to tell the Pi to forward the serial console to it with ```sudo systemctl enable [email protected]```, then you can connect to the device via Putty or Screen.
    - **g_ether** - Using virtual ethernet, you should simply be able to ssh into the address of your Raspberry Pi. To do this, there is a little extra configuration required though. There is a few ways we could set up the point to point networking. The proper way would be to set up a DHCP server on one of the ends. A far simplier was though is just to give the Raspberry Pi a fixed IP address. To do this, you will need to run ```sudo echo -e "interface usb0 \nstatic ip_address=169.254.64.64" >> /etc/dhcpcd.conf```. You can then access the Raspberry Pi Zero by connecting to ```169.254.64.64```, or by using ```raspberrypi.local``` if your computer has Bonjour installed (Mac and most Linux OSs including Raspbian). Note this method does not support adding a fixed address to the cmdline.txt file. For that, you have to use the Ethernet only kernel below.
    - **g_mass_storage** - To have your Pi Zero appear as a mass storage device (flash drive), first create a mini filesystem in a file on your Pi with ```sudo dd if=/dev/zero of=/piusb.bin bs=512 count=2880``` and set it up as a fat32 filesystem with ```sudo mkdosfs /piusb.bin```. Then, when enabling it, add ```file=/piusb.bin stall=0``` onto the end, for example ```sudo modprobe g_mass_storage file=/piusb.bin stall=0```.

    In theory, most USB devices should work alongside these kernels, to switch to USB OTG mode, simply don't use an OTG adapter cable and use a standard USB cable to plug your Pi Zero into another computer, it should auto switch.
    If you have any auto switching issues, try any of the other sets of kernels below.
    In addition to the above modules, a few other (less useful) modules are included.
    - Webcam (g_webcam)
    - Printer (g_printer)
    - Gadget tester (g_zero)

    **Note** - Using these kernels below will disable standard USB on the Pi Zero with that SD card, it is recommended to also have a USB UART serial adapter on hand in case you get locked out due to lack of keyboard.

    #Older kernels

    ##USB Virtual Ethernet - No standard USB support (only Gadget)
    **Note** - This section is no longer recommended, it is much better to use the modular approach above as includes full standard USB support.
    Ethernet kernels download - https://dl.dropboxusercontent.com/u/1122948/temp/PiOTG-Test/PiZeroEthernet.tar.gz

    1. First, flash Jessie (full, not lite) onto a blank microSD card.
    2. Copy the tar.gz file onto the boot partition of the image.
    3. Start it up, at this stage should be fine with any Pi, including Pi2.
    4. Do normal first boot stuff (resize image etc with ```sudo raspi-config```).
    5. Run ```tar xvzfC /boot/PiZeroEthernet.tar.gz /tmp/```.
    6. Then run ```sudo cp -R /tmp/PiZeroEthernet/fat32/* /boot/``` (to copy the kernel and device tree stuff)
    7. Then run ```sudo cp -R /tmp/PiZeroEthernet/ext4/lib/* /lib/``` (to copy the kernel modules themselves)
    8. Next, you will need to manually asign a fixed IP to the Pi, you can do this by editing the cmdline.txt file (using ```sudo nano /boot/cmdline.txt```) and add on the end ```ip=169.254.64.64:::255.255.0.0```. This will allow you to connect the Pi using the address ```169.254.64.64``` from your computer.
    9. Finally, reboot your Pi. It will appear on your computer as a virtual network card, make sure you also assign a fixed IP address on the PC side. (On Mac OS, a much easier way is go into settings, sharing and enable internet sharing from wifi etc to the Gadget device. Using this, you don't even have to have a fixed IP on each side as it will get one via DHCP, will be 192.168.2.3 usually)


    ##USB Virtual Serial - No standard USB support (only Gadget)
    **Note** - This section is no longer recommended, it is much better to use the modular approach above as includes full standard USB support.
    Ethernet kernels download - https://dl.dropboxusercontent.com/u/1122948/temp/PiOTG-Test/PiZeroSerial.tar.gz

    1. First, flash Jessie (full, not lite) onto a blank microSD card.
    2. Copy the tar.gz file onto the boot partition of the image.
    3. Start it up, at this stage should be fine with any Pi, including Pi2.
    4. Do normal first boot stuff (resize image etc with ```sudo raspi-config```).
    5. Run ```tar xvzfC /boot/PiZeroSerial.tar.gz /tmp/```.
    6. Then run ```sudo cp -R /tmp/PiZeroSerial/fat32/* /boot/``` (to copy the kernel and device tree stuff)
    7. Then run ```sudo cp -R /tmp/PiZeroSerial/ext4/lib/* /lib/``` (to copy the kernel modules themselves)
    8. Finally, to enable the serial service, run ```sudo systemctl enable [email protected]```.
    9. Everything is now configured, shutdown the Pi ```sudo shutdown now``` and insert the card into your Pi Zero, plug in the USB data port into your computer and it should appear as a Gadget serial device.
    Hopefully, these modules will be included with the next Raspbian release, but for now you can manually add them.
    1. First, flash Jessie (full, not lite) onto a blank microSD card.
    2. Boot it up and resize the root partition (open a terminal and enter ```sudo raspi-config```, then select expand and reboot).
    3. Once it starts up again, run ```sudo BRANCH=next rpi-update```. This will take a while.
    4. Next we need to make sure we are using the dwc2 USB driver ```sudo echo "dtoverlay=dwc2" >> /boot/config.txt```.
    5. And enable it in Raspbian ```sudo echo "dwc2" >> /etc/modules```
    6. Need to now pick which module you want to use from the list above, for example for ethernet ```sudo echo "g_ether" >> /etc/modules```. You can only pick one of the above modules to use at a time.

    ## Legacy guides
    The legacy guides can be [found on a separate Gist](https://gist.github.com/gbaman/4c1345c0c4d6d82149d4).
  22. @gbaman gbaman revised this gist Jan 6, 2016. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -44,7 +44,8 @@ If you have any auto switching issues, try any of the other sets of kernels belo

    #Older kernels

    ##USB Virtual Ethernet - No standard USB support (only Gadget)
    ##USB Virtual Ethernet - No standard USB support (only Gadget)
    **Note** - This section is no longer recommended, it is much better to use the modular approach above as includes full standard USB support.
    Ethernet kernels download - https://dl.dropboxusercontent.com/u/1122948/temp/PiOTG-Test/PiZeroEthernet.tar.gz

    1. First, flash Jessie (full, not lite) onto a blank microSD card.
    @@ -58,8 +59,9 @@ Ethernet kernels download - https://dl.dropboxusercontent.com/u/1122948/temp/PiO
    9. Finally, reboot your Pi. It will appear on your computer as a virtual network card, make sure you also assign a fixed IP address on the PC side. (On Mac OS, a much easier way is go into settings, sharing and enable internet sharing from wifi etc to the Gadget device. Using this, you don't even have to have a fixed IP on each side as it will get one via DHCP, will be 192.168.2.3 usually)


    ##USB Virtual Serial - No standard USB support (only Gadget)
    Ethernet kernels download - https://dl.dropboxusercontent.com/u/1122948/temp/PiOTG-Test/PiZeroSerial.tar.gz
    ##USB Virtual Serial - No standard USB support (only Gadget)
    **Note** - This section is no longer recommended, it is much better to use the modular approach above as includes full standard USB support.
    Ethernet kernels download - https://dl.dropboxusercontent.com/u/1122948/temp/PiOTG-Test/PiZeroSerial.tar.gz

    1. First, flash Jessie (full, not lite) onto a blank microSD card.
    2. Copy the tar.gz file onto the boot partition of the image.
  23. @gbaman gbaman revised this gist Dec 29, 2015. 1 changed file with 1 addition and 26 deletions.
    27 changes: 1 addition & 26 deletions HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -69,29 +69,4 @@ Ethernet kernels download - https://dl.dropboxusercontent.com/u/1122948/temp/PiO
    6. Then run ```sudo cp -R /tmp/PiZeroSerial/fat32/* /boot/``` (to copy the kernel and device tree stuff)
    7. Then run ```sudo cp -R /tmp/PiZeroSerial/ext4/lib/* /lib/``` (to copy the kernel modules themselves)
    8. Finally, to enable the serial service, run ```sudo systemctl enable [email protected]```.
    9. Everything is now configured, shutdown the Pi ```sudo shutdown now``` and insert the card into your Pi Zero, plug in the USB data port into your computer and it should appear as a Gadget serial device.

    ##Modular (all modules) - No standard USB support (only Gadget)
    Kernels - https://dl.dropboxusercontent.com/u/1122948/temp/PiOTG-Test/PiZeroCombined.tar.gz
    **Modules included**
    - Serial (g_serial)
    - Ethernet (g_ether)
    - Mass storage (g_mass_storage)
    - MIDI (g_midi)
    - Audio (g_audio)
    - Mass storage and Serial (g_acm_ms)
    - Ethernet and Serial (g_cdc)
    - Multi (g_multi) - Allows you to configure 2 from Ethernet, Mass storage and Serial

    **Note** This one requires a USB UART serial adapter to use to configure. **Note**

    1. First, flash Jessie (full, not lite) onto a blank microSD card.
    2. Copy the tar.gz file onto the boot partition of the image.
    3. Start it up, at this stage should be fine with any Pi, including Pi2.
    4. Do normal first boot stuff (resize image etc with ```sudo raspi-config```).
    5. Run ```tar xvzfC /boot/PiZeroCombinedOld.tar.gz /tmp/```.
    6. Then run ```sudo cp -R /tmp/PiZeroCombinedOld/fat32/* /boot/``` (to copy the kernel and device tree stuff)
    7. Then run ```sudo cp -R /tmp/PiZeroCombinedOld/ext4/lib/* /lib/``` (to copy the kernel modules themselves)
    9. Everything is now configured, shutdown the Pi ```sudo reboot``` and insert the card into your Pi Zero and attach your UART adapter.
    10. Fire up the Pi Zero, you can manually enable any of the drivers by using ```sudo modprobe g_DriverName```.
    11. If you want to have the module run at startup, edit the modules file ```sudo nano /etc/modules``` and add the module name, then reboot.
    9. Everything is now configured, shutdown the Pi ```sudo shutdown now``` and insert the card into your Pi Zero, plug in the USB data port into your computer and it should appear as a Gadget serial device.
  24. @gbaman gbaman revised this gist Dec 29, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,7 @@ Kernels - https://dl.dropboxusercontent.com/u/1122948/temp/PiOTG-Test/PiZeroComb

    ### Using the modules
    - **g_serial** - To use the standard serial module, you need to tell the Pi to forward the serial console to it with ```sudo systemctl enable [email protected]```, then you can connect to the device via Putty or Screen.
    - **g_ether** - Using virtual ethernet, you should simply be able to ssh into the address of your Raspberry Pi. To do this, there is a little extra configuration required though. There is a few ways we could set up the point to point networking. The proper way would be to set up a DHCP server on one of the ends. A far simplier was though is just to give the Raspberry Pi a fixed IP address. To do this, you will need to run ```sudo echo -e "interface usb0 \nstatic ip_address=169.254.66.66" >> /etc/dhcpcd.conf```. You can then access the Raspberry Pi Zero by connecting to ```169.254.64.64```, or by using ```raspberrypi.local``` if your computer has Bonjour installed (Mac and most Linux OSs including Raspbian). Note this method does not support adding a fixed address to the cmdline.txt file. For that, you have to use the Ethernet only kernel below.
    - **g_ether** - Using virtual ethernet, you should simply be able to ssh into the address of your Raspberry Pi. To do this, there is a little extra configuration required though. There is a few ways we could set up the point to point networking. The proper way would be to set up a DHCP server on one of the ends. A far simplier was though is just to give the Raspberry Pi a fixed IP address. To do this, you will need to run ```sudo echo -e "interface usb0 \nstatic ip_address=169.254.64.64" >> /etc/dhcpcd.conf```. You can then access the Raspberry Pi Zero by connecting to ```169.254.64.64```, or by using ```raspberrypi.local``` if your computer has Bonjour installed (Mac and most Linux OSs including Raspbian). Note this method does not support adding a fixed address to the cmdline.txt file. For that, you have to use the Ethernet only kernel below.
    - **g_mass_storage** - To have your Pi Zero appear as a mass storage device (flash drive), first create a mini filesystem in a file on your Pi with ```sudo dd if=/dev/zero of=/piusb.bin bs=512 count=2880``` and set it up as a fat32 filesystem with ```sudo mkdosfs /piusb.bin```. Then, when enabling it, add ```file=/piusb.bin stall=0``` onto the end, for example ```sudo modprobe g_mass_storage file=/piusb.bin stall=0```.

    In theory, most USB devices should work alongside these kernels, to switch to USB OTG mode, simply don't use an OTG adapter cable and use a standard USB cable to plug your Pi Zero into another computer, it should auto switch.
  25. @gbaman gbaman revised this gist Dec 29, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,7 @@ Kernels - https://dl.dropboxusercontent.com/u/1122948/temp/PiOTG-Test/PiZeroComb

    ### Using the modules
    - **g_serial** - To use the standard serial module, you need to tell the Pi to forward the serial console to it with ```sudo systemctl enable [email protected]```, then you can connect to the device via Putty or Screen.
    - **g_ether** - Using virtual ethernet, you should simply be able to ssh into the address of your Raspberry Pi. To do this, there is a little extra configuration required though. There is a few ways we could set up the point to point networking. The proper way would be to set up a DHCP server on one of the ends. A far simplier was though is just to give the Raspberry Pi a fixed IP address. To do this, you will need to run ```sudo echo -e "interface usb0 \nstatic ip_address=169.254.66.66" >> /etc/dhcpcd.conf```. You can then access the Raspberry Pi Zero by connecting to ```169.254.66.66```, or by using ```raspberrypi.local``` if your computer has Bonjour installed (Mac and most Linux OSs including Raspbian). Note this method does not support adding a fixed address to the cmdline.txt file. For that, you have to use the Ethernet only kernel below.
    - **g_ether** - Using virtual ethernet, you should simply be able to ssh into the address of your Raspberry Pi. To do this, there is a little extra configuration required though. There is a few ways we could set up the point to point networking. The proper way would be to set up a DHCP server on one of the ends. A far simplier was though is just to give the Raspberry Pi a fixed IP address. To do this, you will need to run ```sudo echo -e "interface usb0 \nstatic ip_address=169.254.66.66" >> /etc/dhcpcd.conf```. You can then access the Raspberry Pi Zero by connecting to ```169.254.64.64```, or by using ```raspberrypi.local``` if your computer has Bonjour installed (Mac and most Linux OSs including Raspbian). Note this method does not support adding a fixed address to the cmdline.txt file. For that, you have to use the Ethernet only kernel below.
    - **g_mass_storage** - To have your Pi Zero appear as a mass storage device (flash drive), first create a mini filesystem in a file on your Pi with ```sudo dd if=/dev/zero of=/piusb.bin bs=512 count=2880``` and set it up as a fat32 filesystem with ```sudo mkdosfs /piusb.bin```. Then, when enabling it, add ```file=/piusb.bin stall=0``` onto the end, for example ```sudo modprobe g_mass_storage file=/piusb.bin stall=0```.

    In theory, most USB devices should work alongside these kernels, to switch to USB OTG mode, simply don't use an OTG adapter cable and use a standard USB cable to plug your Pi Zero into another computer, it should auto switch.
  26. @gbaman gbaman revised this gist Dec 28, 2015. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -34,9 +34,6 @@ Kernels - https://dl.dropboxusercontent.com/u/1122948/temp/PiOTG-Test/PiZeroComb

    ### Using the modules
    - **g_serial** - To use the standard serial module, you need to tell the Pi to forward the serial console to it with ```sudo systemctl enable [email protected]```, then you can connect to the device via Putty or Screen.
    - **g_ether** - To use virtual ethernet, you should simply be able to ssh into the address of your Raspberry Pi. This IP address can be found by running ```watch hostname -I``` before switching over the keyboard cable, as it will repeatedly display the address on screen. . On operating systems with Bonjour support (Mac and most Linux OSs including Raspbian), it should be as simple as running ```ssh [email protected]```. You may also instead want to set up your Raspberry Pi with a fixed IP address. Note this method does not support adding a fixed address to the cmdline.txt file. For that, you have to use the Ethernet only kernel below.
    -

    - **g_ether** - Using virtual ethernet, you should simply be able to ssh into the address of your Raspberry Pi. To do this, there is a little extra configuration required though. There is a few ways we could set up the point to point networking. The proper way would be to set up a DHCP server on one of the ends. A far simplier was though is just to give the Raspberry Pi a fixed IP address. To do this, you will need to run ```sudo echo -e "interface usb0 \nstatic ip_address=169.254.66.66" >> /etc/dhcpcd.conf```. You can then access the Raspberry Pi Zero by connecting to ```169.254.66.66```, or by using ```raspberrypi.local``` if your computer has Bonjour installed (Mac and most Linux OSs including Raspbian). Note this method does not support adding a fixed address to the cmdline.txt file. For that, you have to use the Ethernet only kernel below.
    - **g_mass_storage** - To have your Pi Zero appear as a mass storage device (flash drive), first create a mini filesystem in a file on your Pi with ```sudo dd if=/dev/zero of=/piusb.bin bs=512 count=2880``` and set it up as a fat32 filesystem with ```sudo mkdosfs /piusb.bin```. Then, when enabling it, add ```file=/piusb.bin stall=0``` onto the end, for example ```sudo modprobe g_mass_storage file=/piusb.bin stall=0```.

  27. @gbaman gbaman revised this gist Dec 28, 2015. 1 changed file with 8 additions and 5 deletions.
    13 changes: 8 additions & 5 deletions HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -2,9 +2,9 @@
    Simple guide for setting up OTG modes on the Raspberry Pi Zero - By Andrew Mulholland (gbaman).

    The Raspberry Pi Zero (and model A and A+) support USB On The Go, given the processor is connected directly to the USB port, unlike on the B, B+ or Pi 2 B, which goes via a USB hub.
    Because of this, if setup to, the Pi can act as a USB slave instead, providing virtual serial (a terminal), virtual ethernet or even other virtual devices like HID, MIDI, or act as a virtual webcam!
    It can also act as a Mass Storage device (aka, like a flashdrive), although am still figuring out how to get this working.
    Below is some precompiled kernels and their required modules.
    Because of this, if setup to, the Pi can act as a USB slave instead, providing virtual serial (a terminal), virtual ethernet, virtual mass storage device (pendrive) or even other virtual devices like HID, MIDI, or act as a virtual webcam!
    Below are a serial of precompiled kernels with instructions for each. It is recommended to go for the Modular kernel below, as it has support for all the Linux Gadget USB modules. It also has full standard USB support, where as some of the non modular ones do not.
    **Note** - If wanting to use the SD card on a Raspberry Pi 2, comment (add a hash in front of) the ```device_tree=``` line on the config.txt file on the boot partition.

    ##Modular (all modules) - Recommended
    Kernels - https://dl.dropboxusercontent.com/u/1122948/temp/PiOTG-Test/PiZeroCombined.tar.gz
    @@ -28,13 +28,16 @@ Kernels - https://dl.dropboxusercontent.com/u/1122948/temp/PiOTG-Test/PiZeroComb
    6. Then run ```sudo cp -R /tmp/PiZeroCombined/fat32/* /boot/``` (to copy the kernel and device tree stuff)
    7. Then run ```sudo cp -R /tmp/PiZeroCombined/ext4/lib/* /lib/``` (to copy the kernel modules themselves)
    8. At this point, you have 2 options, you can either set the module you want to run on startup, or dynamically load and unload them.
    9. To set a module to load on startup, edit the modules file with ```sudo nano /etc/modules``` and add the module name you want to start (e.g. g_ether) to the end on a new line. Also, make sure to the check the "Using the modules" section before rebooting.
    9. To set a module to load on startup, edit the modules file with ```sudo nano /etc/modules``` and add the module name you want to start (e.g. g_ether) to the end on a new line. **Also, make sure to the check the "Using the modules" section before rebooting.**
    9. Then, reboot the Raspberry Pi using ```sudo reboot```.
    10. To manually load a kernel module, after rebooting use ```sudo modprobe moduleName```. To unload a module, use ```sudo rmmod moduleName```.

    ### Using the modules
    - **g_serial** - To use the standard serial module, you need to tell the Pi to forward the serial console to it with ```sudo systemctl enable [email protected]```, then you can connect to the device via Putty or Screen.
    - **g_ether** - To use virtual ethernet, you should simply be able to ssh into the address of your Raspberry Pi. This IP address can be found by running ```watch hostname -I``` before switching over the keyboard cable, as it will repeatedly display the address on screen. . On operating systems with Bonjour support (Mac and most Linux OSs including Raspbian), it should be as simple as running ```ssh [email protected]```. You may also instead want to set up your Raspberry Pi with a fixed IP address. Note this method does not support adding a fixed address to the cmdline.txt file. For that, you have to use the Ethernet only kernel below.
    - **g_ether** - To use virtual ethernet, you should simply be able to ssh into the address of your Raspberry Pi. This IP address can be found by running ```watch hostname -I``` before switching over the keyboard cable, as it will repeatedly display the address on screen. . On operating systems with Bonjour support (Mac and most Linux OSs including Raspbian), it should be as simple as running ```ssh [email protected]```. You may also instead want to set up your Raspberry Pi with a fixed IP address. Note this method does not support adding a fixed address to the cmdline.txt file. For that, you have to use the Ethernet only kernel below.
    -

    - **g_ether** - Using virtual ethernet, you should simply be able to ssh into the address of your Raspberry Pi. To do this, there is a little extra configuration required though. There is a few ways we could set up the point to point networking. The proper way would be to set up a DHCP server on one of the ends. A far simplier was though is just to give the Raspberry Pi a fixed IP address. To do this, you will need to run ```sudo echo -e "interface usb0 \nstatic ip_address=169.254.66.66" >> /etc/dhcpcd.conf```. You can then access the Raspberry Pi Zero by connecting to ```169.254.66.66```, or by using ```raspberrypi.local``` if your computer has Bonjour installed (Mac and most Linux OSs including Raspbian). Note this method does not support adding a fixed address to the cmdline.txt file. For that, you have to use the Ethernet only kernel below.
    - **g_mass_storage** - To have your Pi Zero appear as a mass storage device (flash drive), first create a mini filesystem in a file on your Pi with ```sudo dd if=/dev/zero of=/piusb.bin bs=512 count=2880``` and set it up as a fat32 filesystem with ```sudo mkdosfs /piusb.bin```. Then, when enabling it, add ```file=/piusb.bin stall=0``` onto the end, for example ```sudo modprobe g_mass_storage file=/piusb.bin stall=0```.

    In theory, most USB devices should work alongside these kernels, to switch to USB OTG mode, simply don't use an OTG adapter cable and use a standard USB cable to plug your Pi Zero into another computer, it should auto switch.
  28. @gbaman gbaman revised this gist Dec 26, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,7 @@ Kernels - https://dl.dropboxusercontent.com/u/1122948/temp/PiOTG-Test/PiZeroComb

    ### Using the modules
    - **g_serial** - To use the standard serial module, you need to tell the Pi to forward the serial console to it with ```sudo systemctl enable [email protected]```, then you can connect to the device via Putty or Screen.
    - **g_ether** - To use virtual ethernet, make sure the Pi has a fixed IP (can just add ```ip=169.254.64.64:::255.255.0.0``` to the end of the ```/boot/cmdline.txt``` file to force the 169.254.64.64 address on it). You can then ssh from your laptop/desktop to that address.
    - **g_ether** - To use virtual ethernet, you should simply be able to ssh into the address of your Raspberry Pi. This IP address can be found by running ```watch hostname -I``` before switching over the keyboard cable, as it will repeatedly display the address on screen. . On operating systems with Bonjour support (Mac and most Linux OSs including Raspbian), it should be as simple as running ```ssh [email protected]```. You may also instead want to set up your Raspberry Pi with a fixed IP address. Note this method does not support adding a fixed address to the cmdline.txt file. For that, you have to use the Ethernet only kernel below.
    - **g_mass_storage** - To have your Pi Zero appear as a mass storage device (flash drive), first create a mini filesystem in a file on your Pi with ```sudo dd if=/dev/zero of=/piusb.bin bs=512 count=2880``` and set it up as a fat32 filesystem with ```sudo mkdosfs /piusb.bin```. Then, when enabling it, add ```file=/piusb.bin stall=0``` onto the end, for example ```sudo modprobe g_mass_storage file=/piusb.bin stall=0```.

    In theory, most USB devices should work alongside these kernels, to switch to USB OTG mode, simply don't use an OTG adapter cable and use a standard USB cable to plug your Pi Zero into another computer, it should auto switch.
  29. @gbaman gbaman revised this gist Dec 25, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -28,7 +28,7 @@ Kernels - https://dl.dropboxusercontent.com/u/1122948/temp/PiOTG-Test/PiZeroComb
    6. Then run ```sudo cp -R /tmp/PiZeroCombined/fat32/* /boot/``` (to copy the kernel and device tree stuff)
    7. Then run ```sudo cp -R /tmp/PiZeroCombined/ext4/lib/* /lib/``` (to copy the kernel modules themselves)
    8. At this point, you have 2 options, you can either set the module you want to run on startup, or dynamically load and unload them.
    9. To set a module to load on startup, edit the modules file with ``sudo nano /etc/modules``` and add the module name you want to start (e.g. g_ether) to the end on a new line.
    9. To set a module to load on startup, edit the modules file with ```sudo nano /etc/modules``` and add the module name you want to start (e.g. g_ether) to the end on a new line. Also, make sure to the check the "Using the modules" section before rebooting.
    9. Then, reboot the Raspberry Pi using ```sudo reboot```.
    10. To manually load a kernel module, after rebooting use ```sudo modprobe moduleName```. To unload a module, use ```sudo rmmod moduleName```.

  30. @gbaman gbaman revised this gist Dec 25, 2015. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions HowToOTG.md
    Original file line number Diff line number Diff line change
    @@ -27,10 +27,11 @@ Kernels - https://dl.dropboxusercontent.com/u/1122948/temp/PiOTG-Test/PiZeroComb
    5. Run ```tar xvzfC /boot/PiZeroCombined.tar.gz /tmp/```.
    6. Then run ```sudo cp -R /tmp/PiZeroCombined/fat32/* /boot/``` (to copy the kernel and device tree stuff)
    7. Then run ```sudo cp -R /tmp/PiZeroCombined/ext4/lib/* /lib/``` (to copy the kernel modules themselves)
    9. Everything is now configured, shutdown the Pi ```sudo reboot``` and insert the card into your Pi Zero and attach your UART adapter.
    10. Fire up the Pi Zero, you can manually enable any of the drivers by using ```sudo modprobe g_DriverName``` (your keyboard may die, unplug and replug it in to fix this).
    11. If you want to have the module run at startup, edit the modules file ```sudo nano /etc/modules``` and add the module name, then reboot.

    8. At this point, you have 2 options, you can either set the module you want to run on startup, or dynamically load and unload them.
    9. To set a module to load on startup, edit the modules file with ``sudo nano /etc/modules``` and add the module name you want to start (e.g. g_ether) to the end on a new line.
    9. Then, reboot the Raspberry Pi using ```sudo reboot```.
    10. To manually load a kernel module, after rebooting use ```sudo modprobe moduleName```. To unload a module, use ```sudo rmmod moduleName```.

    ### Using the modules
    - **g_serial** - To use the standard serial module, you need to tell the Pi to forward the serial console to it with ```sudo systemctl enable [email protected]```, then you can connect to the device via Putty or Screen.
    - **g_ether** - To use virtual ethernet, make sure the Pi has a fixed IP (can just add ```ip=169.254.64.64:::255.255.0.0``` to the end of the ```/boot/cmdline.txt``` file to force the 169.254.64.64 address on it). You can then ssh from your laptop/desktop to that address.