logo
background
 Home and Links
 Your PC and Security
 Server NAS
 Wargames
 Astronomy
 PhotoStory
 DVD making
 Raspberry Pi
 PIC projects
 Other projects
 Next >>

Pi Zero as a USB Ethernet device

Pi Zero as USB device
1) USB 'device' operation works with the Pi Zero because it has a 5pin micro-USB socket (and makes use of the 5th 'master/slave' pin) and has low enough power consumption to be powered from a standard USB socket. There is a good chance that the same approach can be taken with the Pi A/A+ (since the USB pins are wired direct to the SoC, with no USB hub getting in the way), however power may be an issue. For sure this won't work with any B series Pi, since they all have an on-board USB hub isolating the SoC GPIO USB pins from the rest of the world.

2) Basic access to the Internet is possible via ICS, however (with Jessie 2016=05-07) 'apt-get' fails due to problems accessing the 'mirrordirector' server. These problems ONLY exist when using ICS - a Pi connected directly to your LAN (and thus directly to the Internet Router, i.e. not using ICS), works fine. This drastically limits the use of 'Device' mode (essentially you can't update or install anything new)


The original source of much of the information below can be found on this blog

The Pi Zero as a USB Device (aka 'USB Gadget')

A USB 'device' is powered and controlled by a USB 'host'. A USB 'host' is just any computer (like a PC, or the Pi) that powers and controls USB devices.

The main difference beyween a 'host' and a 'device' is that the host not only has to provide power to the device but also has to 'know' how to control it.
 
Fortunatly, there are lots of 'standard' devices that 'every' host computer already knows how to control (examples include USB Keyboards, mice, memory sticks etc).

So, why would you want to make the Pi Zero 'look like a USB device' ???

Well, first this lets your computer (PC) power the Pi Zero (instead of you needing a separate power supply) and second the Pi can 'pretned' to by any (indeed, more than one) 'standard' USB device that the PC already knows how to handle.
 
For example, if the Pi 'pretends' to be a 'standard' USB Ethernet controller, all 'normal' PC networking utilities (such as shared folders (Map network drive), ICS (Internet Connection Sharing) and NIC LAN Bridging etc) 'just work'.
 
The Pi might emulate a USB camera, in which case it will be able to 'feed' photos and movies to almost any standard application running on your PC without you having to write one line of PC code.
 
Even better, if the Pi reports it's a USB Memory stick, you can use the Pi as a 'path' to almost any storage system you care to build - or even have the Pi Zero perform some sort of 'data acquisition' and have standard PC applications (such as MS Office Excel spreadsheet or Access database) just 'read in' the data (as a text file from the 'USB memory stick') !

For more information, visit here

The Pi Zero as a 'USB Ethernet device'

It is only necessary to A USB device can be plugged directly into any standard USB socket and 'just starts working'. Setting up the Pi Zero is then just a matter of plugging it into your PC using a normal 'OTG' cable. Of course, as with anything *nix, it isn't quite that simple :-)

The Raspberry Pi was conceived as an educational tool. So whilst you needed a PC (or Mac) to download and 'burn' the Pi Operating System into it's SDHC card, after this step users were expected to plug a display and keyboard directly into the Pi and 'learn how to program'. However even as the Pi was being launched, users of mobile phones were already plugging them into their PC's USB port to upload and download images and ring tones etc. so it is somewhat surprising that it took so long time to overcome the limitations of the 'binary blob' USB code and allow the Pi to 'just be plugged in'

But then you didn't really need it for the Pi B series = which all have Ethernet sockets, which allows them to be setup and controlled from a PC using SSH PuTTY command terminal via your LAN. Whilst the A series Pi's come without an Ethernet socket, you can always plug in an USB 'Ethernet dongle' (although that costs money) or 'build' on a B and move the SDHC chip to an A

So it was only with the launch of the Pi Zero, with it's low power consumption and 5pin micro-USB socket, that 'OTG mode' becomes 'possible'

OTG mode allows the Pi to be seen as a USB 'device' (rather than be a USB Controller). The PC sees the Pi as an 'USB Ethernet connected device', which allows utilities (such as PuTTY) to 'talk' direct to the Pi.

The B series, with their on-board USB hubs, won't ever support OTG mode. However the single USB socket of the A/A+ is connected direct to the SoC pins (just like the Zero). This means it should be quite possible to 'switch' the USB D+/D- pin functions on the A/A+ into OTG mode (so long as the Pi 'Gadget' software 'works' even without 'detecting' the OTG cable via the '5th pin')

How the Pi "USB device" works

The trick is to have the Pi run a "USB Ethernet Dongle" emulation driver on it's USB port. The Pi and PC will then 'see' each other as normal computers connected together on the same LAN. The emulation driver means that both Pi and PC will 'see' a "RNDIS Ethernet Gadget" USB dongle.

Of course we want to 'activate' the emulation driver on first boot (to avoid the need to plug in a display/keyboard). So, after 'burning' Raspbian Jessie (release 2016-05-10, or later) to SDHC and before moving it to the Pi Zero, we modify 2 files in the 'boot partition' (config.txt and cmdline.txt) and the Pi will then launch the emulation driver immediately it's turned on.
 
We then use a standard OTG cable to plug the Pi Zero into one of the PC's USB ports in order to power it up, thus avoiding the need for a separate power supply = so when asked "what extra is needed to get the Pi Zero going ?" you can answer "just the SDHC chip and a (micro-USB) OTG cable" !
 
The only problem is that the files we need to access in order to set a 'static IP address' (such as 192.168.132.2) are not on the Fat32 boot partition, so are more difficult to modify.
Image
The Ethernet dongle emulation driver 'fools' both the PC and the Pi itself into thinking there is a RNDIS Ethernet Gadget - a physical Ethernet 'dongle' - plugged into the USB ports of both computers.
 
The PC sees the RNDIS Gadget as an Ethernet interface controlling it's own subnet LAN. The Pi sees itself as a computer on that LAN.
 
The Pi Zero (raspberrypi.local) also sees the RNDIS Gadget as an Ethernet interface controlling it's own subnet LAN. However (unlike the PC), the Pi will expect to get it's IP address (and DNS server and Gateway/Router address) from the RNDIS Ethernet Gadget (and thus reach the Internet via that LAN).

The problem is that when the Pi DHCP fails, the Pi will then choose some random IP address in the 169.254.x.x range. Getting access to the Pi then becomes 'a challenge' (see later), however once we have access to the Pi we can set it to a Static IP address. Once this has been done, it's an easy matter to set up a path (on the PC) for the Pi to reach the Internet

Using ICS

If we activate ICS on the PC however, this not only provides the Pi with a 'path' to the Internet but also 'cures' the DHCP problem

Normally MS regards DHCP as a 'Server' function (so expects you to pay through the nose for one of their Server Operating Systems) - but DHCP is, in fact, built into Windows XP (and later) as part of ICS !
 
So 'all' you need to do is enable ICS on your 'Internet' connection and Windows XP will run DHCP on the RNDIS Gadget adapter (see later) !

Modify the Pi SDHC so it boots the USB Ethernet device driver

I started by downloading the Jessie lite .img file onto the PC and 'burning' a SD card. The PC can then access the 'boot' partition (because it's FAT32) and we can change 2 files so the Pi boot as an Ethernet USB device as follows :-

1. Start by burning a Raspbian Jessie full or Raspbian Jessie Lite (release version 2016-05-10 or later) .img to a FAT32 formatted SD card (for details, including how to format a 'used' Pi SD card, see my Burning the Pi SD card page).
 
2. Open the SDHC card image using Windows Explorer (double-click 'My Computer', double-click the SD card 'boot' (typically 'boot (E:)' or similar).
This can be a bit 'hit or miss' since sometimes Windows refuses to 'spot' the new FAT32 partition, keeps showing the card as a 'removable drive' (or 'SD drive') with Properties 'File system = RAW' and asking you if you want to Format it. I usually manage to 'get in' by swapping the SDHC card reader to a different USB socket and waiting a few minutes before trying to 'open' it
 
3. Modify the Pi boot partition config.txt file so the Pi boots into OTG mode. Use a text edit utility (NotePad++ or similar) to open the config.txt file and add the following line to the end of the file :-
dtoverlay=dwc2
 
Save the file and exit.
 
4. To modify the Pi boot partition cmdline.txt file so the Pi will launch the emulation driver (g_ether) during boot-up, use a text editor to open the cmdline.txt file (NOT the /boot/config.txt file). Note, the second parameter sets a static MAC address for the RNDIS Gadget (otherwise the Pi will set a random MAC on each boot up and Windows will get confused) :-
Warning - do not use 'line wrap' or similar on this file. The file contains a single line of parameters, each separated by a single space, with NO END OF LINE codes.
 
Add the two new 'space separated' parameters, directly after rootwait and before quiet :-
 modules-load=dwc2,g_ether g_ether.host_addr=00:11:22:33:44:55
 
UPDATE. To set a fixed IP address (like 192.168.1.200), try adding the following between rootwait and quiet:-
 ip=192.168.1.100::192.168.1.1:255.255.255.0:rpi:usb0:off
(my previous attempt to set a fixed address failed when DHCP 'failed' and 'overwrote' it with a '169.254.x.x' address - the 'usb0:off' should prevent this (the original information was for an Ethernet 'dongle' and specified 'eth0:off') =  I can't say if this works as I've not tried it)

 
After the insertion, cmdline.txt contents should look like :-
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_ether g_ether.host_addr=00:11:22:33:44:55 quiet init=/usr/lib/raspi-config/init_resize.sh
 
The g_ether parameters can also be found in the /etc/modprobe.d/g_ether.conf file (in the Ext4 partition). Note that you can 'fix' the MAC addresses on Pi side as well (g_ether.dev_addr=00:66:77:88:99:00)
Digging around on Google I found this, which suggested that you can add "ip=(Pi address)::(Gateway address)" to the end of cmdline.txt. Unfortunately, this just doesn't work = at a guess when DHCP is run at the end of the boot sequence it just 'overrides' this setting with the 'DHCP failed auto-169.254.xxx.xxx address'

Both the above files can be 'seen' by Windows because they are in the root FAT32 partition of the SDHC card. At this point you can move the SDHC card to the Pi and power on - however the 'problem' is that you don't know the Pi IP address.

Those with older laptops that come with a 9pin RS232 serial link can 'plug into' the Pi 'command console' (on Pi header pins 8 TxD and 10 Rxd). Note on most laptops TxD will be 0-5v (so you will need a 'level converter' on that wire). You can then connect to the Pi using PuTTY (at 115400 baud) and set a static IP address (see below) thus avoiding the need to find the Pi's 'auto set' IP address

Finding the Pi IP address

Everything is rather more difficult because the Pi 'network manager' will try to get it's IP address for usb0 / eth0 (the g_ether 'port') using DHCP - and it always does this right at the end of the boot sequence. This means anything you set 'earlier' will just get over written by some random address (like 169.254.100.231) when DHCP fails

On the other hand, because the RNDIS Adapter 'comes up' first, this gives your PC a chance to 'spot' it, enable ICS (and thus DHCP) in time to respond to the Pi.

The Pi 'announces' it's IP address at the end of the boot sequence on it's 'console screen' (if you have a display plugged in) and also sends it to the 'command terminal serial link' (which is now 115k baud)
 
You can plug a 'serial link to USB' adapter into the command terminal GPIO pins and this will let you 'see' the IP on a second USB port (most adapters have four wires = red power, black ground, white Pi Tx (into USB) and green Pi Rx (out of the USB) - but WATCH OUT - on some cables 'red' is PC USB port 5v POWER OUT, on others it's serial voltage 'IN' (i.e. needs to be plugged onto a Pi GPIO 3v3 header pin to set the Rx/Tx to Pi standard 3v3, rather than the common laptop PC 5v).
 
Note:
1) you only need the 4 wire (or 3 wire) serial to USB cable, and not the 'full' "FTDI cable" (which includes extra wires for programming Atmel/PIC chips)
2) if your 3 wire serial link cable has a 5v TxD output, you can 'reduce' this to 3v3 (for the Pi RxD input) by using 2 resistors (TxD to 2k2 + wire to Pi RxD + 3k3 to Gnd)

If you don't have a display or a serial link USB dongle, there are (in theory) at least 4 ways to find (or set) the Pi's IP address via the 'USB Gadget device' link. I explain each below and then describe how I (eventually) managed to achieved 'success' in each on my XP computer (unlike most other 'how to' guides which don't actually work)

1) Each time the Pi boots up it will attempt to get an IP address using DHCP. This will fail and (if you didn't set anything else) the Pi will end up choosing some random address in the 169.254.xxx.xxx range. So, "all" you need to do is scan the entire 169.254.x.x range (64k addresses) until you find it :-)
 
2) Instead of scanning, install Apple 'Bonjour' services on your PC and use that to locate the Pi 'by name' (if the Bonjour Service is running, you can ping "raspberrypi.local" and it will show the IP assigned to the Pi).
 
3) To stop the PI DHCP failing, you can set up a DHCP Server service on the PC (for the RNDIS Gadget Ethernet adapter) by using ICS or an Open Source DHCP utility (such as this one from Source Forge).
 
4) The final approach is to use your PC to set up a specific (static) IP address for the Pi. This means your PC has to access the Ext4 *nix partition after 'burning' the SDHC card (and before moving it to the Pi).
NOTE = this is my preferred approach because later I can return the Pi SDHC card to the PC and access my scripts etc. and back them up or even copy them to another SDHC card.

1) Scanning the 169.254.x.x subnet = not recommended, but it works :-)

NOTE - the RNDIS Gadget must exist in Network Connections and you MUST have manually set it's IP address to 169.254.0.1 with a subnet mask of 255.255.0.0 (and leaving Default Gateway 'blank') before trying to 'ping' anything in the 169.254.xxx.xxx range

You can ping the entire 169.254.x.x range from a CMD prompt using :-

for /l %i in (0,1,254) do for /l %j in (1,1,254) do @ping 169.254.%i.%j -n 1 -w 5 | find "Reply">> results.txt
 
This scans all 64k addresses waiting 5mS for a 'Reply' from each, before going on to the next. When you hit the right address, the Pi should respond within 1mS, so waiting for only 5mS is fine.
 
The problem is, on my PC, this only scans about 120 addresses a minute = so to do the entire 64k range will take about 9 hours ('on average' you should find it after 4.45 Hrs i.e. by the 'half way' point :-) )
 
Whilst 'not recommended' this is 'guaranteed to work' = I've done it multiple times, sometimes letting it run overnight = and in the morning 'results.txt' always contains the Pi IP address (instead of it being scrolled off the top of the command window as each 'outer loop' command is echo'd)

You might think that one reason why the above is so slow is the 'find' command has to trawl through each response looking for 'Reply' = so perhaps you can speed things up by dumping the text to NUL and using '&&' after the echo (which only executes if the ping succeeds) ?

for /l %i in (0,1,254) do for /l %j in (1,1,254) do @ping 169.254.%i.%j -n 1 -w 5 >nul && echo 169.254.%i.%j>> results.txt

Guess what ? the above runs at exactly the same speed :-) plus, sometimes the '&&' fails and I get nothing ...

Another idea I had was to setup a 'batch (.cmd) file' :-

@echo off
echo Starting scan of 169.254.x.x > results.txt
SET c=-1
:cloop
SET /a c=%c%+1
IF %c%==255 goto :eof
SET d=0
echo Now starting subnet 169.254.%c%.%d% >> results.txt
:dloop
SET /a d=%d%+1
ping -n 1 -w 5 169.254.%c%.%d% >nul
IF %errorlevel%==0 echo 169.254.%c%.%d% REPLY >> results.txt
IF %d%==254 goto cloop
GOTO dloop

Well this turns out to run significantly SLOWER than the straight command line !

You can find a number of Open Source utilities that will scan an IP address range rather faster than any of the above 'hacks' (for example NMAP - with the command line version, just "nmap -PE 169.245.0.0/16", however I had problems getting the .zip package to work, so suggest you stick to the 'installer' download).

NB. The well 'advertised' and adware infected 'Angry IP Scanner' should be avoided like the plague it is

Once you have the Pi IP address, you can 'get in' with PuTTY and set the Pi to a Static IP (see below) so you don't have to re-scan every time you re-boot it.

2) Using Bonjour

The Pi is always "raspberrypi.local" so if you download and install Apple Bonjour you can always find it.

The current version (2.2) of BonjourPSSetup.exe (5.3Mb) from Apple turned out to be of no use all - all does is install some unwanted 'Apple Updater' service and a rather useless printer 'wizard' = what it doesn't do is install the Bonjour Service (as the other 'how to' guides would have discovered had they actually tried to 'do it for real').
 
The actual Bonjour Service is included in iTunes etc., which (of course) Apple assumes 'everyone' already has installed. If you don't want iTunes DRM'ing your PC, then (for Windows XP) you need "BonjourSetup.exe v1.0.106" (2.1Mb) which you can find via Google (or 'right click' and 'Save link as' from here). This package installs the actual Service and also offers to install the Apple Printer Wizard ('just say no'). WinPatrol should spot the sneaky attempt to install the Apple 'Updater Service' (which you can also reject). Finally, I had to reboot my PC before the Bonjour Service actually started up.
 
Note, Bonjour will automatically open UDP port 5353 on Windows Firewall (so it can communicate with .local 'named' devices). If you are using a non-Microsoft firewall (such as CoMoDo), when it detects the RNDIS Gadget and pops up with 'New network detected' just click 'Home network' and all will be well.
 
NB. You need to make sure UDP port 5353 is blocked at your Router Firewall or 'Bonjour' will be saying 'hello world' to the Internet (i.e. "I've no idea what I'm doing, come and hack me")

The interesting thing about Bonjour is that so long as you have the Bonjour Service running, when you ping "raspberrypoi.local" it will give the Pi's address even if it's not on the current RNDIS subnet i.e. even if RNDIS Gadget is set to 192.168.137.1 and the Pi is on 169.254.100.231 (so the 'ping' will report 'Request timed out')

3) Setting up ICS (DHCP service)

If your Internet Router is on 192.168.0.1, you can't use ICS unless you move your Router to some other address range (eg 192.168.1.0)

If you enable ICS you 'kill 2 birds with one stone'. First ICS provides DHCP to the Pi (so the Pi gets an IP address) and second it provides the Pi a path to the Internet.

For those of us who have discovered their SDHC reader is 'incompatible' with Paragon ExtFS (see below), don't want to wait whilst scanning the subnet and are uncomfortable with saying 'Bonjour tout le monde' this is the only option.
On your PC, in Start - Settings - Network Connections, highlight your existing "Local Area Network Connection {N}" right click and rename it 'Internet Connection' (this will avoid lots of confusion later)
 
Boot the Pi and wait for your PC to find the RNDIS Gadget (it has to be 'seen' before you can enable ICS)
 
On the PC, in Start - Settings - Network Connections highlight the RNDIS Gadget "Local Area Network Connection {N}", right clock and rename it 'LAN' (this will avoid more confusion later).
 
Now open the 'Internet Connection' Properties, Advanced tab and, in the Internet Connection Sharing box, select 'Allow other network users ....' (if this option does not exist, check that the "Windows Firewall/Internet Connection Sharing (ICS)" Service is running (in Admin Tools, Services)).
 
Close the Internet Connection properties (if you get a warning re: LAN set to 192.168.0.1 that's fine). Open the RNDIS Gadget 'LAN' network connection Properties and check that it's TCP/IP address has indeed been set to 192.168.1.0. You can set the Preferred DNS to 8.8.8.8 now
 
Reboot the Pi (i.e pull it out and plug it back in again)
 
Wait for the RNDIS Gadget to be 'seen' by the PC, then open a CMD window and PING the 'RNDIS Gadget' LAN at 192.168.0.1 (just to make sure the RNDIS Gadget is 'seen' OK)
 
Next you need to find the IP address that ICS DHCP has assigned to the Pi (you don't think MS would assign IP's starting at 192.168.0.2 do you ??)
 
So it's the usual 'scan all addresses' although this time it's only the 255 in the 192.168.0.xx subnet :-
for /l %j in (1,1,254) do @ping 192.168.0.%j -n 1 -w 5 >nul && echo 192.168.0.%j
Image
  or (if && 'fails') :- for /l %j in (1,1,254) do @ping 192.168.0.%j -n 1 -w 5 | find "Reply">> results.txt   Finally, use PuTTY to SSH into the Pi and ping 8.8.8.8 (to confirm it can reach the Internet)

Using Open Source DHCP

For those who don't want to move their Router from the 192.168.0.xxx subnet (or don't want to enable ICS), you can use an Open Source DHCP Service that can be configured to some arbitrary subnet range (like 192.168.137.xx)

It's a pain to set up and there is no guarantee it will work. The 'Gadget' is a Pi software emulation - so there is a 'race' between the PC DHCP service 'spotting' the Gadget coming on-line and the Pi timing-out waiting for the DHCP service (on the PC) to respond, although changing the RNDIS IP address (from the PC) causes the Pi to re-run it's DHCP, so it usually works 'in the end'.

Download the Open Source DHCP service from Sourge Forge (or right click and 'save link as' OpenDHCPServerInstallerV1.64.exe)
 
Install the service, then go to Start, Programs, Open DHCP Server and click 'Configure'. The OpenDHCPServer.ini file will open in your text editor.
 
Adjust the parameters as follows :-
[LISTEN_ON]
192.168.137.1
 
[RANGE_SET]
DHCPRange=192.168.137.2-192.168.137.2
SubnetMask=255.255.255.0
DomainServer=8.8.8.8
Router=192.168.137.1
 
Save and exit the edit, then Reboot your PC (actually, restarting the Service may be enough)

The RNDIS Gadget is, of course, not present until the Pi is turned on - so initially there is no DHCP Server so the Pi ends up with a 169.254.100.xxx address.

The trick to 'making it work', is to wait for the Pi to boot, Pi DHCP to fail and the RNDIS Gadget to be 'spotted' by your PC.
 
On the PC, you then change the IP address of the RNDIS Gadget from 192.168.137.1 to 'something else' - the Pi will DHCP again and fail again.
 
You then change the RNDIS Gadget to 192.168.137.1. When this takes effect, the PC DHCP Server will 'spot it' and be ready in time to deliver the 192.168.137.2 address to the Pi when it DHCP's the 3rd time.
 
You can now 'ping 192.168.137.2' and get a reply

4) Getting access to the Ext4 partition

For further information, click to open the note below :-

(+) Accessing the SDHC card system image


Setting a Static MAC

If you have access to the Ext4 partition, you can set the RNDIS Gadget to a fixed MAC address

The emulation driver settings are held in the file /etc/modprobe.d/g_ether.conf. This is where you can setup it's MAC address (if you don't, it will assign a random MAC on each boot and stupid Windows won't realise it's the same device next time you plug in the Pi)
g_ether.dev_addr=12:34:56:78:9a:bc
 
To set the Pi's MAC address (which is only required if you need to ID the Pi from the PC - for example if you are running a DHCP Server on the PC and use 'MAC locking'), add the following to the Pi network setup file (?) :-
dev_addr=de:f0:12:34:56:78

Setting the Pi to a static IP address

Once you get access to th files in the Ext4 partition (either direct on the PC or via PuTTY command terminal), you can set the Pi Zero to a static IP address (and forget all about scanning subnets and running DHCP services or Bonjour).

Of course, as with everything *nix, there are multiple places where the Pi IP address can be set. By default the Pi attempts to get it's IP using DHCP and if it can't find a DHCP server it then generates some random address in the 169.254.xxx.xxx range (although I have occasionally caught it choosing one within the RNDIS assigned 192.168.137.xxx subnet).

The problem is, of course, that setting a static IP for the Pi 'early' in the boot sequence isn't going to help when the Pi runs DHCP 'later' (since the DHCP 'result' will always 'overwrite' any previous set value) ...
... and (of course) DHCP is about the last thing done at boot-up !
 
So we have two problems = set a static IP, stop the Pi overwriting it.
 
Of course, Raspbian Jessie differs from the older Wheezy release, and most guides will direct you to the wrong file = it's no longer "/etc/network/interfaces" - instead you have to edit /etc/dhcpcd.conf
Edit /etc/dhcpcd.conf and add at the end :-

interface usb0
 
static ip_address=192.168.137.2/24
static routers=192.168.137.1
static domain_name_servers=8.8.8.8
 
Note, when using the g_ether Gadget, it's 'usb0' NOT 'eth0' (which you will see in guides where the author hasn't actually 'done it for real' :-) )
 
Note also the /24, which means 'subnet mask 255.255.255.0' (so if you forget the Pi static IP address, you only have to 'scan' 255 :-) )

It's quite likely that you will want to 'set up the Pi' using g_ether mode and then 'switch' to a 'Pi as USB master' system. In that case, any real USB adapter will indeed be 'eth0' = and, if the Pi can't find a DHCP server on that 'port', you might want to set it to a static IP within your router LAN (eg 192.168.1.123). In that case, use the 'fallback' command to 'point' at the static address settings (add them to the end of the file)

interface eth0
fallback nodhcp
 
profile nodhcp
static ip_address=192.168.1.123/24
static routers=192.168.1.1
static domain_name_servers=8.8.8.8

For more on dhcpcd.conf, see the manual pages (man dhcpcd.conf)

Trying to read the man page for dhcpcd.conf in the PuTTY SSH window 'keyhole' is an exercise in futility. Fortunately the same page can be found on-line here

If you are doing this direct to the SD card from Windows, make sure to use the ExtFS for Windows manager to 'Unmount' the file system before you eject the SDHC (and plug it into your Pi Zero)

If you are doing this via PuTTY (after scanning the subnet or using Bonjour), just reboot the Pi - and then SSH in on the new address

Booting up the Pi for the first time

Power-up the Pi by plugging it into any USB port on your PC using a micro-USB to USB 'OTG' style cable (and not a 'phone charger cable', many of which don't even connect the data lines at all).

Make sure the OTG cable is plugged into the Pi USB communications socket (the second i.e. 'middle' one) and NOT the power-socket .. if you get it wrong, the Pi will still power up but you won't be able to 'see' it from the PC :-)

Wait for the Pi to boot up (it takes about 90 seconds). Windows should 'see' the USB device as a "RNDIS/Ethernet Gadget" and auto-install the required driver,

If the USB driver does not auto-install, go into Device Manager and look in the '? Other devices' section for "RNDIS/Ethernet Gadget".
 
The Driver you want is a Network Adapter, from Microsoft Corporation the "Remote NDIS Compatible Device".
 
If the driver is not already on your PC, and you can't find it elsewhere, I have a copy here (right click, 'save link as', unpack the zip and then select the 'have disk' option (after selecting Network Adapter in the New Hardware Found wizard) and browse to the unpacked driver .inf)

After installing the driver, go to Start > Settings > Network Connections and look for the new Local Area Connection icon< Open Properties > Internet Protocol and change the IP settings from 'auto' to 192.168.137.1 (subnet 255.255.255.0, Gateway 192.168.137.1) Close Properties to apply the new values.

If you installed a DHCP Server service, you may have to stop and start the service before it 'spots' the Gadget and starts issuing addresses (and then restart the Pi so it gets an address)

'ping' the Pi's IP address after scanning the subnet, using Windows to access the Ext4 files or running a DHCP Server. If using Bonjour, you can ping "raspberrypi.local"

Controlling the Pi from your PC

Once you have the Pi address (or are using Bonjour), you can use PuTTY to link to 192.168.137.2 user 'pi' password 'raspberry' (or, if using Bonjour, to "raspberrypi.local", user 'pi@raspberrypi.local', password 'raspberry')

Pi access to the Internet without ICS

Since (on Jessie 2016-05-27) 'apt-get' fails when attempting to access 'mirrordirector.raspbian.org' on the Internet via ICS, it's worth looking into 'other' (non-ICS) approaches.

The alternative to using ICS is Network Bridge = however this means changing the Pi to an address in your Router subnet range (Bridging can only be used to join together two physical adapters into a single LAN when the computers on both adapters are already be assigned addresses within that LAN)

If your 'main' (Internet) PC adapter is IP 192.168.0.100/24 with Gateway 192.168.0.1, then you will need to set the Pi Gadget to some address like 192.168.0.200/24 (Gateway 192.168.0.1) and the Pi itself must have a suitable static IP eg. 192.168.1.201/24 (Gateway 192.168.0.1)
 
The 'easy' way to do this is to start by using ICS to get access to the Pi's setup files, then modify them to use the eg. 192.168.1.201/24 (Gateway 192.168.0.1) address.
 
To Bridge the two adapters, in Start - Settings - Network Connections, select (highlight) both adapters, right click and select 'Bridge Connections'.
 
When Bridging 'joins' the Pi side (192.168.1.20x/24) to your main adapter (192.168.0.100/24) the TCP/IP Properties are removed from both adapters and 'combined' into a single set in the 'Bridge Connection' virtual adapter (thus enforcing the 'single LAN' subnet)

Back in PuTTY, connect to the Pi and use the command 'ping 8.8.8.8' (the Google DNS server) to make sure Pi can access the Internet

Transferring data from the PC to the Pi

Often you will want to 'pre-load' the Pi with data from your PC - for example .jpg images to display or .wav / .mp3 music tracks to play etc. It will usually be a lot faster if you can use the PC to load directly onto the SDHC card (before booting the Pi), which means Accessing the SDHC card system image :-

(+) Accessing the SDHC card system image

If you can't get access on the PC, then you will have to transfer the data via your LAN. It actually turns out to be simpler to use the Pi to 'pull' the data from yur pC (i.e. make a Windows 'share' for the Pi) :-

(+) Accessing PC shares from the Pi

Alternatively you 'map' the Pi on your PC and 'push' data from the PC to the Pi :-

(+) Installing samba - (the Pi as a Network Share on your PC)

Next page :- Using QEMU - (Pi emulation on your PC)

[top]