Add USB Serial to your Raspberry Pi Zero W
This tutorial is based on: https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget/serial-gadget
You must have the following:
- Raspberry Pi Zero W
- Raspbian Jessie (or Jessie Lite) installed after the May 2016 release
- USB Cable
Step 1. Edit config.txt & cmdline.txt
Insert the SD card into 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 the following to the last line in /boot/config.txt:
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:
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 fsck.repair=yes rootwait modules-load=dwc2,g_serial quiet init=/usr/lib/raspi-config/init_resize.sh
Step 2: 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. Use dmesg to check to see if your computer recognized the Pi as a serial port.
Step 3: Set up logging in on Pi Zero via Serial Gadget
Having a Serial port does not mean you can log in with it yet. The Pi knows it has a Serial port but you have to tie it to a console. You can do that very easily with:
sudo systemctl enable getty@ttyGS0.service
You can then verify its running with:
sudo systemctl is-active getty@ttyGS0.service
Step 4: Login
You can now login via PUTTY or a BASH terminal.
- In PUTTY make sure you choose "serial" as the connection type
- In a BASH terminal run the following:
screen -L /dev/ttyYOURSERIALPORT
Press enter twice then login.