Difference between revisions of "Add USB Serial to your Raspberry Pi Zero W"

From Lofaro Lab Wiki
Jump to: navigation, search
(Created page with "This tutorial is based on: [https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget/serial-gadget https://learn.adafruit.com/turning-your-raspberry-pi-zero...")
 
(Step 1. Edit config.txt & cmdline.txt)
 
(4 intermediate revisions by the same user not shown)
Line 10: Line 10:
 
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.
 
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:
+
Go to the bottom and add the following to the last line in <b>/boot/config.txt</b>:
   dtoverlay=dwc2as
+
   dtoverlay=dwc2
  
 
Save the config.txt file as plain text and then open up <b>cmdline.txt</b> After <b>rootwait</b> (the last word on the first line) add a space and then:
 
Save the config.txt file as plain text and then open up <b>cmdline.txt</b> After <b>rootwait</b> (the last word on the first line) add a space and then:
 
   modules-load=dwc2,g_serial
 
   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 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 <b>dmesg</b> 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
 +
Now reboot:
 +
  sudo reboot
 +
 +
== 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.

Latest revision as of 10:39, 27 March 2019

This tutorial is based on: https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget/serial-gadget

Prerequisites

You must have the following:

  • Raspberry Pi Zero W
  • Raspbian Jessie (or Jessie Lite) installed after the May 2016 release
  • USB Cable

Steps

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:

 dtoverlay=dwc2

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 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

Now reboot:

 sudo reboot

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.