要點:web
1. 經過修改樹莓派系統的配置 ,打開usb端口模擬網卡的功能.而後能夠經過這個虛擬的網口,用ssh方式或者vnc方式控制樹莓派.對樹莓派0這種端口不多的設備很是管用.chrome
2.是usb端口,不是usb供電口windows
3.把鏡像燒錄到tf卡上以後,修改幾個配置便可.服務器
4.win10原生認不出來usb模擬網卡.須要下載驅動.app
5.默認登陸地址是pi@raspberrypi.local.密碼是raspberryless
6.經過vncserver啓動遠程登陸的虛擬界面服務器.地址是raspberrypi.local:1ssh
Setting up a headless setup for Pi Zero W is simple. The limitation of Pi Zero and Zero W is that it doesn’t have an Ethernet port. All we have is a single USB port. We need to use it as an Ethernet via USB technique to access the Pi. There are many tutorials available for this. But if you are using Windows 10 you might be faced the problem with RNDIS driver. The RNDIS driver will install automatically on all operating systems but not in Windows 10. In Windows10 the Pi Zero W detects as a Serial USB Device instead of RNDIS Device. RNDIS is an Ethernet via USB driver which enables virtual Ethernet connection link between the Pi and your Laptop. I tried downloading the drivers and installed but most drivers didn’t work. Then finally I found a driver link in a forum and I tried installing it manually and it’s worked. So I’m going to explain the complete steps for this headless setup along with driver installation. If you are facing issue only at the driver installation part you can directly continue with step 9.ide
Hardware Required:ui
Software Required for Headless setup:this
Optional Software:
The Pi Zero W has in-built Wi-Fi, so you can use the headless Wi-Fi Setup too. Check out the Headless Wi-Fi setup tutorial here.
Step 1: Format the SD card with SD card formatter.
Step 2: After formatting open Win32 Disk Imager (or Etcher), locate the downloaded Raspbian image file and flash it to the SD Card.
Note: NOOBs will not work with this set up (NOOBs is Just an OS installer). So, we need Raspbian. The Current version is Raspbian Stretch. A Raspbian OS is an image file with the ‘.img’ extension (It also comes with ‘.zip’ file you have to extract it before flashing).
Step 3: Once flashing done. Navigate to the SD Card folder. You can able to see the files extracted from the image.
Step 4: Now open ‘cmdline.txt’ file and add this at the end of the file. (Make sure it is at the end of the file not in newline).
1 |
modules-load=dwc2,g_ether |
Step 5: Now we need to modify the ‘config.txt’ file. So open the ‘config.txt’ file in text editor. Then add the following line anywhere in the file (will be in a newline).
1 |
dtoverlay=dwc2 |
Now save this file and close it.
Step 6: SSH is disabled default in new Raspbian OS. You can enable it by simply create an empty file and name it as ssh without any extension. Make sure the file name extensions option is selected in windows view settings.
Step 7: Eject the microSD card from the computer and place it in the Raspberry Pi. Then connect the PC and Raspberry Pi via USB cable. You don’t need external power as the Pi zero W USB pin provides power as well as data transfer. Wait until the pi boots up completely. It might take up to 90 Seconds.
Step 8: If the RNDIS driver installs automatically then jump to Step 10 for SSH using Putty. If it installs as a USB Serial Device then continue the following steps. You can check this in Device Manager. In Windows 10 the RNDIS Driver installs as a USB Serial Device at COM Port. So we need to install drivers to manually enable Ethernet over USB.
Click here to download the RNDIS Driver which I got from this forum. Extract the downloaded zip files.
Step 9: Open Device Manager and you can see the Pi is detected as USB Serial Device at COM port under the PORTS & LPT. Right click on it and select 「Update Driver Software」.
Select ‘Browse my computer for driver software’.
Choose the location where you extracted the driver files on your PC.
Select the Extracted driver folder which is mod-duo-rndis. Click ok and click Next. This will install the driver.
Now you can able to see the Pi Zero W as RNDIS in Network adapters.
Step 10: Make sure you have installed Bonjour Service (Apple Inc.) on your PC. It is a service to discover the Shared resources on the network and web servers. If you have iTunes installed on your PC, then it had been already installed. If Bonjour is not installed then the Hostname will not be mapped with IP. So you are not able to use Hostname (eg: raspberripi.local) in Putty (You can use direct IP of Pi. But finding the IP will be complex for headless setup).
Open Putty and enter the Host Name as ‘raspberrypi.local’ and port as 22. Click open, this will open a terminal window asking for username and password.
Step 11: Enter the default username as ‘pi’ and default password as ‘raspberry’.
Step 12: Now type vncserver in the terminal window. This will run the virtual server on the raspberry pi.
Step 13: Now go to Google Chrome and open VNC Viewer App (You need to install from google apps store or visit website).
Step 14: Enter the Hostname as ‘raspberrypi.local:1’(Hostname or IP address of Pi with :1 at the end.)