Raspberry Pi Zero, how to manage it using only USB

luca 10/04/2017 2

After having brought a Raspberry Pi Zero, I asked myself how to access it and do some initial configuration because of in that moment I hadn’t an HDMI monitor or an USB keyboard and a mouse.

Fortunately, this Raspberry model supports USB OTG (On The Go): it can “become” a slave USB device such as a storage device, a HID peripheral or even a webcam. Today I’ll show you how to configure a Raspberry Pi Zero so that it will be identified by a PC as a network interface: we’ll be therefore able to connect to it via SSH using a simple USB connection.

More importantly, we’ll be able to do all the configuration steps working directly on the SD card, without the need to connect the Raspberry to external peripherals (monitor, keyboard…).

Configuration

First, install (flash) on an SD card a recent version of the Raspbian distribution. My PC runs Windows, so I uses Win32 Disk Imager:

rndis-00a

When the process completes, view the SD card content and open with a text editor the config.txt file:

rndis-00b

Add at the end of the file the line dtoverlay=dwc2 (if you want, you can also add a comment as in the screenshot below):

rndis-00c

Now open the file cmdline.txt. Locate the word rootwait and immediately after it add modules-load=dwc2,g_ether. Pay special attention to the white spaces, see the screenshot:

rndis-00d

The final step is to create an empty file, named ssh (without extension!), to enable the sshd server:

rndis-10

The configuration is complete: now insert the SD card into your Raspberry, power it on and wait some seconds until the boot process ends. If you now connect the Raspberry to your PC, this should identify it as an RNDIS/Ethernet Gadget.

Driver installation

On some PCs it may happen that the peripheral is not automatically identified:

rndis-01

In this case, open the Device Manager from the Control Panel:

rndis-02

You’ll find the new peripheral under Other devices. Double click on it:

rndis-03

Open the Driver tab and click on Update Driver…:

rndis-04

Choose Browse my compiter…:

rndis-05

Then Let me pick from a list…:

rndis-06

Now choose Microsoft Corporation as Manufacturer and you can finally find the correct driver:

rndis-07

Connection

Thanks to the RNDIS driver, we can connect to the Raspberry Pi Zero as we were in a local network. Open an SSH client (I normally use PuTTY) and type raspberrypi.local as target hostname:

rndis-08

If the connection fails with an unknown host error, it means that your PC doesn’t support the mDNS (Multicast DNS) service. If your operating system is Windows, you can install the Bonjour service by Apple, while under Linux it’s available the Avahi daemon.

Internet sharing

Using the connection you’ve just set up, you can also share with the Raspberry your Internet connection.

Open the network connections of your computer and right click on your “main” connection (the one that provides you Internet access). Choose Properties, then open the Sharing tab and click on Allow other network usersIn the combobox, select the network connection between your PC and the Raspberry Pi Zero:

rndis-09

Now verify that your Raspberry Pi Zero too can reach Internet addresses:

rndis-11

2 Comments »

  1. David Simmons 14/04/2017 at 14:45 - Reply

    This is great! I also needed to configure my Pi Zero W without a monitor, keyboard, etc. but I solved it a slightly different way: https://davidgs.com/2017/accessing-your-raspberry-pi-zero-w/

    • luca 14/04/2017 at 15:06 - Reply

      Hi David, nice solution if your Raspberry has wifi connectivity! Thanks for sharing

Leave A Response »

This website uses cookies to ensure you get the best experience on our website maggiori informazioni

Questo sito utilizza i cookie per fonire la migliore esperienza di navigazione possibile. Continuando a utilizzare questo sito senza modificare le impostazioni dei cookie o clicchi su "Accetta" permetti al loro utilizzo.

Chiudi