FalconF16
Posts: 16
Joined: Thu May 28, 2020 1:42 am

Can't set up Pi Zero in headless mode!

Tue Jun 02, 2020 4:30 pm

Hi all, I'm brand new to Raspberry Pi and purchased my first Pi (Pi Zero... but not the W model... just the $5 Zero) yesterday!

I don't have a display/keyboard/mouse to use with it, so I was trying to do the setup in headless mode. I first downloaded the Raspberry Pi OS Lite version to my 8GB microSD, and then I followed the instructions from Tom's Hardware website to setup the Pi Zero in headless mode. Here's the link I followed:

https://www.tomshardware.com/reviews/ra ... ,6028.html

I did everything exactly as the post states. I added that last line to the config file, I added the line to the cmdline file, and I also created a ssh file, all exactly as described (note, the screenshot of the cmdline doesn't show the full image... don't worry, I didn't delete anything!):
config.png
config.png (45.94 KiB) Viewed 657 times
cmdline.png
cmdline.png (15.79 KiB) Viewed 657 times
I inserted the microSD into my Pi Zero and then plugged my microUSB to the Pi Zero and my laptop. I started PuTTY and tried connecting to "raspberrypi.local", but I keep getting an error saying "Unable to open connection to raspberrypi.local Host does not exist":
putty.png
putty.png (4.52 KiB) Viewed 657 times
Furthermore, I can't even see the Pi in my device manager or anywhere. I've been searching throughout the web yesterday and today, but had no luck in fixing this problem. All solutions seem to be for the Pi Zero W, which doesn't work in my case since I'm not using WiFi to set it up. I formatted my SD card and tried multiple times, and still had no luck. It's really disappointing and frustrating since I was so excited but it doesn't work! :( I would appreciate it if anyone had any guidance for what to do.

Also: something I noticed is that after inserting the microSD into my Pi Zero and powering it on, and then after I take it out and place it in my computer, the ssh file isn't there anymore. Furthermore, all of the stuff that came after the "modules-load=dwc2,g_ether" that I added to my cmdline file disappeared.

User avatar
mooblie
Posts: 220
Joined: Fri Oct 14, 2016 2:07 pm
Location: The Scottish Highlands

Re: Can't set up Pi Zero in headless mode!

Tue Jun 02, 2020 7:09 pm

Just scanning your post - if it's a PiZero (NOT W), how are you expecting to connect it to your network? Am I missing something obvious here, or are you?? :)

You need to add either:
- a USB-to-wired Ethernet dongle, and an Ethernet patch cable to your router, or
- a USB-wifi dongle (in which case the PiZeroW would be a better buy)
Last edited by mooblie on Tue Jun 02, 2020 7:16 pm, edited 1 time in total.

FalconF16
Posts: 16
Joined: Thu May 28, 2020 1:42 am

Re: Can't set up Pi Zero in headless mode!

Tue Jun 02, 2020 7:14 pm

mooblie wrote:
Tue Jun 02, 2020 7:09 pm
Just scanning your post - if it's a PiZero (NOT W), how are you expecting to connect to your network?
Hi moobie, thanks for your reply. I'm not exactly sure; I'm completely new to Raspberry Pi and am only following the directions.

I read that once you insert your OS to the microSD, you need to do an initial setup... which is what I was trying to do. However, it's not working. Maybe I'm misunderstanding, and I don't need to do this initial setup at all?

All I want to do is get my Raspberry Pi Zero up and running so I can begin using it :)

I don't think internet is a necessity, otherwise the Zero would be useless! I just want to do some simple projects onboard that don't require internet/wifi.

To be clear, I just want to be able to access the Pi Zero using my laptop so that I can program and add my programs into the Pi Zero to run them (I don't want to purchase a display for it).
Last edited by FalconF16 on Tue Jun 02, 2020 7:19 pm, edited 1 time in total.

User avatar
mooblie
Posts: 220
Joined: Fri Oct 14, 2016 2:07 pm
Location: The Scottish Highlands

Re: Can't set up Pi Zero in headless mode!

Tue Jun 02, 2020 7:19 pm

True, you don't HAVE to connect it to the internet to do some projects, but you have a choice:

- either run it headless, and use your inhouse network to talk to it from another computer, or

- connect a keyboard and screen to the Pi directly, and run it in complete isolation, or

- connect it via USB direct to your laptop, like this:
https://www.thepolyglotdeveloper.com/20 ... cable-ssh/
Last edited by mooblie on Tue Jun 02, 2020 7:22 pm, edited 1 time in total.

User avatar
rpdom
Posts: 17723
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Can't set up Pi Zero in headless mode!

Tue Jun 02, 2020 7:19 pm

mooblie wrote:
Tue Jun 02, 2020 7:09 pm
Just scanning your post - if it's a PiZero (NOT W), how are you expecting to connect it to your network? Am I missing something obvious here, or are you?? :)

You need to add either:
- a USB-to-wired Ethernet dongle, and an Ethernet patch cable to your router, or
- a USB-wifi dongle (in which case the PiZeroW would be a better buy)
Or use the USB Ethernet gadget as shown in the OPs post.
Unreadable squiggle

FalconF16
Posts: 16
Joined: Thu May 28, 2020 1:42 am

Re: Can't set up Pi Zero in headless mode!

Tue Jun 02, 2020 7:21 pm

mooblie wrote:
Tue Jun 02, 2020 7:19 pm
True, you don't HAVE to connect it to the internet to do some projects, but you have a choice:

- either run it headless, and use your inhouse network to talk to it from another computer, or

- connect a keyboard and screen to the Pi directly, and run it in complete isolation.
Hmm, there's no way to use the Pi Zero without a screen built for it? Or without a network?

I thought SSH would allow me to access it through my laptop through the USB? I'm just trying to insert a program I've written into the Pi Zero so that it runs completely independently when I plug it in. For example, a simple script that will keep flashing an LED when I power on the Pi.

User avatar
mooblie
Posts: 220
Joined: Fri Oct 14, 2016 2:07 pm
Location: The Scottish Highlands

Re: Can't set up Pi Zero in headless mode!

Tue Jun 02, 2020 7:24 pm

Yes, I've just added a link in my previous post to another article about using the PiZero in gadget mode - as I assume Tom's Hardware guide attempt, and as rpdom helpfully suggested above too.

Sorry I haven't' ever done that myself - can't help much more...
Last edited by mooblie on Tue Jun 02, 2020 7:28 pm, edited 1 time in total.

FalconF16
Posts: 16
Joined: Thu May 28, 2020 1:42 am

Re: Can't set up Pi Zero in headless mode!

Tue Jun 02, 2020 7:25 pm

mooblie wrote:
Tue Jun 02, 2020 7:19 pm
True, you don't HAVE to connect it to the internet to do some projects, but you have a choice:

- either run it headless, and use your inhouse network to talk to it from another computer, or

- connect a keyboard and screen to the Pi directly, and run it in complete isolation, or

- connect it via USB direct to your laptop, like this:
https://www.thepolyglotdeveloper.com/20 ... cable-ssh/
I've tried the last link you shared, but that's where I'm getting the error. When I try connecting with PuTTY, I keep getting the host name error (screenshot in original post).

FalconF16
Posts: 16
Joined: Thu May 28, 2020 1:42 am

Re: Can't set up Pi Zero in headless mode!

Tue Jun 02, 2020 7:27 pm

rpdom wrote:
Tue Jun 02, 2020 7:19 pm
mooblie wrote:
Tue Jun 02, 2020 7:09 pm
Just scanning your post - if it's a PiZero (NOT W), how are you expecting to connect it to your network? Am I missing something obvious here, or are you?? :)

You need to add either:
- a USB-to-wired Ethernet dongle, and an Ethernet patch cable to your router, or
- a USB-wifi dongle (in which case the PiZeroW would be a better buy)
Or use the USB Ethernet gadget as shown in the OPs post.
Hi rpdom! That's the method I tried, using USB Ethernet gadget. However, I'm still getting that host name error as seen in the original post. I can't find any solutions online. Have you ever used this method to set it up?

User avatar
rpdom
Posts: 17723
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Can't set up Pi Zero in headless mode!

Tue Jun 02, 2020 7:35 pm

Sorry, no I've never got around to trying it. All my zeroes either use USB ethernet adaptors or have wireless.
Unreadable squiggle

User avatar
thagrol
Posts: 3749
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Can't set up Pi Zero in headless mode!

Tue Jun 02, 2020 8:14 pm

FalconF16 wrote:
Tue Jun 02, 2020 7:27 pm
rpdom wrote:
Tue Jun 02, 2020 7:19 pm
mooblie wrote:
Tue Jun 02, 2020 7:09 pm
Just scanning your post - if it's a PiZero (NOT W), how are you expecting to connect it to your network? Am I missing something obvious here, or are you?? :)

You need to add either:
- a USB-to-wired Ethernet dongle, and an Ethernet patch cable to your router, or
- a USB-wifi dongle (in which case the PiZeroW would be a better buy)
Or use the USB Ethernet gadget as shown in the OPs post.
Hi rpdom! That's the method I tried, using USB Ethernet gadget. However, I'm still getting that host name error as seen in the original post. I can't find any solutions online. Have you ever used this method to set it up?
Make sure that your PC has recongised the zero as an ethernet adapter and installed the correct drivers for it.

Then make sure that you have installed bonjour/avhi/whatever it's called these days on it.

And check the cable. There are cheap charge only cables out there that will power a zero but don't have the data pins connected.

Edit: and make sure you're connecting to the correct micro USB port as only one of them has the data pins connected (the inner one).
Arguing with strangers on the internet since 1993.

FalconF16
Posts: 16
Joined: Thu May 28, 2020 1:42 am

Re: Can't set up Pi Zero in headless mode!

Tue Jun 02, 2020 8:38 pm

thagrol wrote:
Tue Jun 02, 2020 8:14 pm
FalconF16 wrote:
Tue Jun 02, 2020 7:27 pm
rpdom wrote:
Tue Jun 02, 2020 7:19 pm

Or use the USB Ethernet gadget as shown in the OPs post.
Hi rpdom! That's the method I tried, using USB Ethernet gadget. However, I'm still getting that host name error as seen in the original post. I can't find any solutions online. Have you ever used this method to set it up?
Make sure that your PC has recongised the zero as an ethernet adapter and installed the correct drivers for it.

Then make sure that you have installed bonjour/avhi/whatever it's called these days on it.

And check the cable. There are cheap charge only cables out there that will power a zero but don't have the data pins connected.

Edit: and make sure you're connecting to the correct micro USB port as only one of them has the data pins connected (the inner one).
Hi Thagrol, I've ensured that the USB is connected to the right port, installed bonjour, etc. By the way, what are we even supposed to do with Bonjour? None of the guides really specify.

Anyway, when I plug my Pi in, I can't find it in Device Manager (Windows 10). I've tried multiple USB ports on my laptop, and also tried another laptop (also Windows 10).

It doesn't even come up as "unrecognized usb ethernet rndis" (or whatever it's supposed to be), so I can't do much since the device isn't even present. Even still, I downloaded and installed the driver, but no change! I've been searching online about how to fix this, and can't find a single thing! Do you have any other ideas? This is super frustrating!

User avatar
thagrol
Posts: 3749
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Can't set up Pi Zero in headless mode!

Tue Jun 02, 2020 9:23 pm

Potentially a bad cable.

Try the following:
  • Reboot your laptop.
  • Using the same micro USB cable connect a different device to your laptop. Is that device detected?
  • If you have one try a different cable with the zero
  • Try the minimal config:
    • Disconnect the zero
    • Remove the SD card
    • Reconnect the zero to the laptop
    Windows should show a "BCM2708 Boot" device
  • Try using a different gadget module:
    Replace "g_ether" in your cmdline.txt with g_mass_storage. You should see an empty USB storage device but may have to open disc management to see it.
TBH, without some sort of connection to the zero this is going to be hard to debug. A monitor may help as you'll be able to see the boot and console messages.

A serial connection would be better as that would allow you to login as well. You'd need a USB to 3.3v TTL serial dongle for your laptop and the GPIO header fitted. By the time you've done that you'll be matching or exceeding the cost of a zeroW.

Being brutally frank, your easiest option is to set the zero to one side and replace it with a zeroW(H), a 3A+, or a 4B (in ascending order of cost).

If it is a windows software issue, I guess you could try again after booting your laptop with a live linux USB/CD/DVD (try the RPF/RPT one).
Arguing with strangers on the internet since 1993.

User avatar
thagrol
Posts: 3749
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Can't set up Pi Zero in headless mode!

Tue Jun 02, 2020 9:24 pm

Oh, regarding bonjour. Once installed and following a reboot it should "just work".
Arguing with strangers on the internet since 1993.

User avatar
HawaiianPi
Posts: 6001
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Can't set up Pi Zero in headless mode!

Tue Jun 02, 2020 9:55 pm

Just skimmed the thread, so I might have missed something.

What OS are you trying to run on the Pi0?

What OS are you running on your laptop?


Try my image
I have a pre-configured Raspbian Buster Lite image that you can just burn-n-boot.
2020-02-13-raspbian-buster-lite_Pi0USB.zip
SHA256=2839dc045388dac8002df0c6f2494e6505e97b4c2643e20a7d9873dd46143969

Write this to an SD card using Etcher or the Raspberry Pi Imager, then safely eject the SD card from your computer and put it into the Pi Zero.

Next get a standard micro-USB data cable and connect that to the USB data port of the Pi Zero (the one closer to the HDMI port). Don't connect anything to the other USB port (power). Finally, plug the other end of the micro-USB cable into your main (Windows/Mac) computer and the Pi Zero should start booting (green activity LED will flash intermittently).

Give the little Pi a couple of minutes to boot and you should be able to SSH into pi@raspberrypi.local (or pi@raspberrypi) from your main PC (mDNS hostname resolving is available in up-to-date versions of Windows 10, Linux and Mac OS, if you have an older OS you might need to install Apple's Bonjour printer service).


Internet Access:
If all has gone well you can share your Internet connection from your main PC with the USB Gadget to give 'net access to your little Pi.


MAC Address fix:
If you want Internet Connection Sharing to survive reboots you need a fixed MAC address for your USB Ethernet/RNDIS Gadget network adapter, and for that you can try the following command (not tested it with the latest Raspberry Pi OS image, but it worked on older images).

Code: Select all

echo 'options g_ether host_addr='$(dmesg | awk '/: HOST MAC/{print $NF}')' dev_addr='$(dmesg | awk '/: MAC/{print $NF}') | sudo tee /etc/modprobe.d/g_ether.conf

Troubleshooting:
If you have trouble, check device manager and make sure your Pi Zero shows up as a USB Ethernet/RNDIS Gadget network adapter.
Pi0_Eth_Gadget.gif
Pi0_Eth_Gadget.gif (13.37 KiB) Viewed 486 times

If that's not what you see, then something is wrong with your Windows system and can try this driver (all the details match the driver installed by my Win10 system). Other hardware - Acer USB Ethernet/RNDIS Gadget

This image has been tested on a Pi Zero v1.3 and my Windows 10 laptop.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

FalconF16
Posts: 16
Joined: Thu May 28, 2020 1:42 am

Re: Can't set up Pi Zero in headless mode!

Tue Jun 02, 2020 10:59 pm

@thargol and @HawaiianPi

You guys are really awesome, I followed your guys' tips and it finally works! Seriously, thanks a ton - I'm super excited to get started now! I and many others really appreciate all of the help you provide on the forum! Have a great week! :D

Return to “Troubleshooting”