wiki:SetupPiZeroSSHOverUSB

You can use IP over USB to interact with your pi zero from a notebook computer without needing a separate keyboard and monitor for your Pi. For background see here.

After installing Raspbian Lite on your SD card, you can edit the files in the /boot partition of the SD card:

  • Edit config.txt:more info
    • Uncomment: dtparam=i2c_arm=on
    • Uncomment: framebuffer_width=1280
    • Uncomment: framebuffer_height=720 (these set the screen size for VNC when no monitor is attached)
    • Add to end: dtoverlay=dwc2 (is this the default?)
    • For PiZero platforms add to end: gpu_mem=32 (since we need all the RAM we can get on Pi Zero)
    • Edit cmdline.txt:
      • Insert modules-load=dwc2,g_ether g_ether.dev_addr=5a:77:1e:af:8e:9e g_ether.host_addr=72:8d:1f:c4:e8:ca after rootwait. This will load the IP over USB driver and configure a fixed MAC address (otherwise, the Pi will generate a new random MAC address each boot and Windows will think it is a different Pi). See here and here for more info. Use a unique pair of MAC address for each Pi. Note there is exactly one space between each term, and the whole cmdline.txt file is one line.
      • Remove the command that will automatically resize the partition to fill the disk: init=/usr/lib/raspi-config/init_resize.sh
    • create an empty file named /boot/ssh (so ssh will be enabled)
    • create an empty file named /boot/avahi (to enable mdns/zeroconfig)
    • if installing on a pi with wifi built-in, add /boot/wpa-supplicant.conf containing:
      country=US
      ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
      update_config=1
      
      network={
          ssid="My WiFi 2.4"
          psk="mypassword123"
          key_mgmt=WPA-PSK
      }
      
  • Install Bonjour on your computer from here to support automatic discovery of the Pi
  • Connect your Pi to the computer via a USB 2.0 port. On the Pi use the usb port for data and power, that's the one in the middle, not the one on the end (which is power, no data).
  • Wait a while while the Pi boots and your USB drivers for the Pi are installed. Once the light on the Pi should be solid green after a while and the driver is installed, continue.
  • Test for connectivity: at a command prompt, type: ping raspberrypi.local
  • Download PuTTY from here and connect to your Pi via SSH.
    • Hostname: pibot.local
    • Port: 22 (default)
    • Connection type: SSH (default)
    • Username: pi
    • Password: raspberry
  • Note: by default the connections use IPv6. If you want to force IPv4, disable IPv6 for the new network adapter Windows created for the USB virtual network.
  • Set up connection sharing between Windows and the Pi.
    • Go to Control Panel > Network and Sharing Center > Adapter Settings.
    • Identify the name of the network corresponding to the Pi--Its a Unidentified Network, USB Ethernet/RNDIS Gadget. Its probably something generic like "Ethernet 3".
    • Right click on your main ethernet or wifi connection. Pick Properties > Sharing Tab. Check "Allow other network users to connect through this computer's internet connection, and pick the name of the home networking connection identified in the step above. Click OK.
    • NOTE: on some systems (e.g. a laptop with WiFi? access only), you may not be able to choose the specific network connection you will share your main connection with, you just enable internet sharing. You may also need to manually add the Google name server (8.8.8.8) to the IPv4 properties of the virtual (USB) connection that corresponds to your Pi:
      • Control Panel -> Network and Internet -> Network Connections
      • Right click the connection labeled USB Ethernet/RNDIS Gadget and select Properties
      • Select Internet Protocol Version 4 (TCP/IPv4) and press the Properties button
      • Under Use the Following DNS server addresses, set the preferred DNS server to 8.8.8.8
      • Press OK
  • Enable VNC
    • Log into your Pi using PuTTY
    • sudo rasp-config
    • Enable VNC, I2C, configure localization, etc.
  • Setup DNS services on your PiZero?:
    • Log into your Pi using PuTTY
    • sudo nano /etc/dhcp/dhclient.conf
      • add: prepend domain-name-servers 8.8.8.8,8.8.4.4
    • sudo /etc/init.d/networking restart
    • test name services: ping www.yahoo.com
Last modified 3 years ago Last modified on Jun 23, 2018, 8:42:37 AM