Serial Gadget

We'll start with Serial Gadget, which is the 'simplest' of the USB gadgets. This one basically makes it so when you plug in the Pi Zero to your computer, it will pop up as a Serial (COM) Port - the nice thing about this technique is you can use the pi with any computer and operating system and it doesnt require special drivers or configuration.

Thx for the tips from Andrew, as of May 2016, Raspbian Jessie does not require a new kernel

Step 0. Download and install latest Jessie

We're using Jessie Lite but plain Jessie Raspbian should work too! You need May 2016 or later (tested with 2016-05-27)

This tutorial has the details

Step 1. Edit config.txt & cmdline.txt

After burning the SD card, do not eject it from your computer! Use a text editor to open up the config.txt file that is in the SD card post-burn.

Go to the bottom and add dtoverlay=dwc2as the last line:

Save the config.txt file as plain text and then open up cmdline.txt After rootwait (the last word on the first line) add a space and then modules-load=dwc2,g_serial

At the time of writing, this is the full cmdline.txt contents (in case you need to start over). Note it is one very long line

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait modules-load=dwc2,g_serial quiet init=/usr/lib/raspi-config/

Log into your Pi Zero

Insert the SD into your Pi Zero, connect the console cable, power the Pi & log into via the USB console.

While booting, or later when runing sudo dmesg you can see that it bound driver g_serial

(don't forget the sudo like i did at first!)

You can then verify its running with

  • sudo systemctl is-active [email protected]

Thats...pretty much it. run sudo reboot to start up your Pi Zero. Plug in a USB Micro cable from your computer to the Pi Zero.

While the Zero is rebooting you can see that it loads the g_cdc module which provides "CDC USB Serial support" (CDC stands for 'communications device class')

On your computer you'll see a new Serial port is created. Check the Windows device driver:

On mac, it will be a new device called /dev/tty.usbmodelNNNN where NNNN can be any number

Log into your Pi using Serial Port Software

OK now that your Pi is rebooted and you get that USB serial device again, you can connect to it at 115200 baud (8N1 8-bit No-parity 1-stop if you need to set that)

you can disconnect the console cable, so you dont mix up the USB console cable and the direct-console connection (since they both have COM/Serial ports)

You can also remove the power cable to the 'power USB' port, since the desktop computer will be powering the Pi thru the USB gadget port.

You may have to hit return a few times to get it to come up with the login prompt. But that's it! You're now connected to your Pi Zero directly

Last updated on 2016-08-21 at 11.47.30 PM Published on 2015-12-24 at 05.29.22 PM