Setting up the Raspberry Pi Zero without HDMI or OTG

The Raspberry Pi Zero W is a full featured Raspberry Pi that includes USB, GPIO connector and built-in wireless connectivity. The main limitations of the Pi Zero is its' lack of USB ports, the use of USB OTG and weaker single core CPU, similar to the first generation Raspberry Pi. A raspberry Pi Zero is an ideal device for embedded applications where higher level programming capabilities and a Linux footprint are desired.

Pi Zero Programming Options

The Pi Zero is a full featured Raspberry Pi with built in video, HDMI, USB, and a full Linux operating system.  You have exactly the same development platform options as the Pi2/Pi3.  The Pi Zero's USB OTG feature means that the Raspberry Pi Zero can act as a peripheral instead of acting as a controller.  Raspberry Pi developers have written drivers/gadgets that emulate USB disk drives, USB Ethernet adapters and others.  The Ethernet gadget makes the Pi Zero appear to a USB connected computer as if the Pi was an Ethernet card that happens to have a Raspberry Pi connected to it.  It is sort of meta. The Pi emulates the computers network device and exposes itself on that network.

This table describes the most common ways of programming a Raspberry Pi Zero.  Remember that the Pi Zero is small and may be embedded in larger devices.

Option Pros Cons
On board HDMI
and USB/OTG
Full screen access
Does not require SSH
Requires access to all ports
Uses more power
Serial Console Does not tie up any ports
Does not require SSH
Reserves GPIO14/GPIO15
Requires special Serial Cable
Single terminal interface
SSH w Wifi Does not tie up any ports
Supports multiple connections
All network services available
Must be connected to Wi-Fi
SSH must be enabled over wifi
Devices must have unique names
SSH via USB
LAN Gadget
Does not require wireless access
Supports multiple connections
All network services available
Uses the single Pi Zero USB port
Gadget is always on
Requires open USB port on PC
Terminal via USB
Serial Gadget
Does not require wireless access
Emulates universal serial device 
Uses the single Pi Zero USB port
Gadget is always on
Requires open USB port on PC
Build with SD card on Pi 3
and move SD
Full screen access
Does not require SSH
Requires access to SD card
Requires full sized Pi
Incremental development hard

You approach depends on your access to the physical device, whether or not you what wireless connectivity for development and your security profile. WiFi or LAN development can be a hassle if you have multiple Raspberry's on the same network and don't have a good way of knowing their node names or IP addresses

Enabling Connectivity

The development approaches in the previous section map down to a few choices for gaining access to the Pi Zero to develop on the Pi Zero itself.  The following table lists them and reference web sites that describe how to enable that feature.

Option Enabling Links
On board HDMI
and USB/OTG
Automatically Enabled
Can be disabled to save power
RaspberryPi.Org "getting started"
Serial Console Update config.txt in /boot Adafruit headless quickstart
USB LAN Gadget Update config.txt in /boot
Update cmdline.txt in /boot
Adafruit ethernet gadget tutorial
Hostname is raspberrypi.local
USB SerialGadget Update config.txt in /boot
Update cmdline.txt in /boot
Adafruit usb gadget tutorial

Hardware Serial Port

Enable the Serial Console when developing system where you can live with losing the GPIO pins used for TX/RX. Enable the USB LAN Gadget on a Pi Zero if you don't believe any USB devices will be embedded in the project. Enable both if you can't make up your mind.

The serial port uses two GPIO pins and a ground. The Pi Zero to the right has Green, White and Yellow wires tied to it serial and GND pins.
You usually see wires plugged to the CPU side of the Raspberry Pi.  The connector in the picture is a right angle connector with pins long enough to connect on the bottom of the board.  This makes it possible to connect a full header on one side and individual connections on the other.


Connectivity is only half the battle. You also have to also open a remote session vi SSH, a serial terminal or via some type of remote desktop software.  The console doesn't require SSH because it is a hardware terminal port.

OptionEnablingLinks
SSH
sudo systemctl enable ssh
sudo systemctl start ssh
RaspberryPi.Org remote access
SSH Headless
create "ssh" file in /boot
RaspberryPi.Org remote access
Remote WindowingVNC is the most common tool.
There are several versions


SSH Risks

    SSH, and any other remote access tool, represents a potential security hole. Enabling SSH is very convenient.  Requiring direct physical access is more secure.

    Remote Desktop Risks

      Remote desktop software represents a potential security hole. Enabling a remote desktop is very convenient.  Requiring direct physical access is more secure.

      Default User Id

      The default Raspberry Pi login information is well known. You should change the password if you enable SSH.
      • Username: pi
      • Password: raspberry

      Pi Zero Pinout

      The console approach is the only one that requires access to pins on the Raspberry Pi Zero.  

      The serial console is available on UART0.  You can use USB to TTL adapters that support 3V.  5V USB/Serial cables will fry the Raspberry Pi signal lines. 

      The console runs on UART0 which uses GPIO-14 (pin-8) , GPIO-15 (pin-10). 

      Courtesy of http://www.raspberry-projects.com

      Adafruit has a nice tutorial on connecting a serial console adapter to Raspberry pi. Their serial cable has 4 pins. Mine has 3 pins. Your cable should have at least 3, RX, TX and GND.  The cable's "TX" connects to the Pi's "RX" and the cable's "RX" connects to the Pi's "TX". 

      USB to Serial Cables

      The cable to the right is an example of  USB to 3.3V serial cable. It has three pins, TX, RX and GND.

      This is an old Prolific 2303 clone cable. This used to work with MS Windows until Prolific modified the driver to accept only genuine cables.  That driver generates the dreaded "Code 10 Error" in the driver panel. It is possible to use an older backdated driver under Windows 10 to get it to work. You will have to downgrade the driver to an older one. I have been using driver 3.3.2 from 2008. 

      Microsoft will regularly auto-update to the newer driver disabling the adapter.  You should only have to run the installer once.  Every time after that you can pick the "Let me pick from a list of available drivers on my computer" choice from "Update Driver.

      Related

      • https://joe.blog.freemansoft.com/2018/03/setting-up-raspberry-pi-zero-without.html
      • https://joe.blog.freemansoft.com/2018/03/protecting-pi-restricting-ssh-to-usb.html
      • https://joe.blog.freemansoft.com/2022/11/installing-rndis-driver-on-windows-11.htm

      Fini

      Created 2018 March 04

      Comments

      Popular posts from this blog

      Installing the RNDIS driver on Windows 11 to use USB Raspberry Pi as network attached

      Understanding your WSL2 RAM and swap - Changing the default 50%-25%

      Almost PaaS Document Parsing with Tika and AWS Elastic Beanstalk