
Raspberry Pi Zero Headless Setup - davidmaitland
http://davidmaitland.me/2015/12/raspberry-pi-zero-headless-setup/
======
cnvogel
One of the very useful things to own when dealing with embedded computers is a
low-voltage/CMOS usb-to-serial cable, such as this one:
[https://www.adafruit.com/products/954](https://www.adafruit.com/products/954)

There are modules that have variable I/O voltage, very handy when dealing with
devices that have 1,8V, 2.5V, 3.3V or 5V logic:
[https://www.sparkfun.com/products/12731](https://www.sparkfun.com/products/12731)

Equipped with such a cable, you can also observe any errors that might occur
on bootup, such as when you have made a mistake in configuring your config
files on the filesystem.

For normal "Rasperry Pi"-Level work, the cheapest eBay-cable will probably be
ok. If you have more exotic devices you'll appreciate UARTs that can produce
almost arbitrary baudrates, or might support inverted Tx/Rx pins. I found some
chinese knockoffs using a "CH310" UART/i2c/spi chip to be particularly broken.

(EDIT: Added last paragraph, fixed a few typos)

~~~
unwind
I noticed that the SparkFun product has export restrictions, which seemed
funny.

I dug up this text on their site:
[https://www.sparkfun.com/support#IntExportRestrictions](https://www.sparkfun.com/support#IntExportRestrictions),
which says:

 _[...] These are products designed for civilian use, but that could be used
for devious purposes in the wrong hands. [...]_

So, I guess that tells me there are weapons or other "dangerous" machines that
have UARTs. Who would have thought that, huh? :| Really dubious restriction,
but I guess they don't have a choice.

~~~
cnvogel
You get that for an awful lot of chips or software which are thought to have
"dual use" to aid inadequately defined nefarious things.

On most orders for electronics parts, even if it's European distributors
shipping to me, in Europe, I'll have to click some boilerplate where I assert
to not make the chips available to terrorists on the Denied Persons List of
the US department of commerce, which is conveniently available in ASCII...

[https://www.bis.doc.gov/dpl/dpl.txt](https://www.bis.doc.gov/dpl/dpl.txt)

~~~
cordite
The same applies when buying microcontroller starter kits, like the MSP430 for
school.

That, and clauses about not using it to controller missiles. Which is
admittedly more applicable than the weapons of mass destruction (exaggerated)
clause in iTunes.

------
hanoz
Having had a proper play with a Raspberry Pi (Zero) for the first time this
week I've been very surprised that setting up wifi is so much harder than it
ought to be, especial when taking it out and about.

Is there any reason why Pi plus Raspbian can't/won't/doesn't have a Chromecast
style setup built in, i.e. boots up, finds wifi adapter but no known network,
hosts own network allowing connection from smartphone app to configure wifi
settings for new network?

~~~
gramasaurous
That would be a pretty useful utility to build actually. I can't think of any
reason why it wouldn't work unless these wifi adapters don't have the ability
to broadcast their own network. Would be fun to give it a try!

~~~
davidmaitland
I really like this idea actually. May see if I can cobble together a little
program to do this.

~~~
gramasaurous
Found a guide to do this [0] but without a web interface for configuration, or
figuring out if there is a wifi device. Would be easy to setup a script to run
on boot to check to see if a wireless network interface is attached, then set
up the ad-hoc network accordingly and serve a simple config page. Finally
something to do with my pi(s)!

[0][http://spin.atomicobject.com/2013/04/22/raspberry-pi-
wireles...](http://spin.atomicobject.com/2013/04/22/raspberry-pi-wireless-
communication/)

------
joeyspn
Pro-Tip: Raspbian comes with loads of bloatware. If you really need a
_headless server_ go ahead and install Ubuntu Server 14.04... IMO much better
than Snappy Ubuntu Core

[https://wiki.ubuntu.com/ARM/RaspberryPi](https://wiki.ubuntu.com/ARM/RaspberryPi)

~~~
pettou
Or Raspbian Lite:
[https://www.raspberrypi.org/downloads/raspbian/](https://www.raspberrypi.org/downloads/raspbian/)

~~~
geerlingguy
This distro was just added a couple weeks ago, and is the same as Raspbian,
but without all the GUI bits, apps like Minecraft and Wolfram, and it boots to
the console without automatic login.

I used to use 'Diet Raspbian,' which took plain Raspbian and stripped it down,
but this is a much nicer alternative, since it's an official build!

------
geerlingguy
Another way (which I usually use) is to plug in a USB ethernet adapter (or on
Pis with LAN, just plug in onboard), then when the Pi is booted, use something
like Fing[1] to ID the new IP address on the network. SSH into it (it's
enabled by default) with `ssh pi@[ip]` and away you go!

Look also at the official Raspberry Pi documentation[2], which is more
succinctly summed up on SO[3].

For WiFi, you can configure the microSD card in another Pi (I usually mint
cards on my Mac, then configure a master copy in a Pi 2, then drop it into
other Pis headless) so it has the SSID/PSK in the wpa config file.

[1] [http://www.overlooksoft.com/fing](http://www.overlooksoft.com/fing) [2]
[https://www.raspberrypi.org/documentation/troubleshooting/ha...](https://www.raspberrypi.org/documentation/troubleshooting/hardware/networking/ip-
address.md) [3]
[http://raspberrypi.stackexchange.com/a/13937/6506](http://raspberrypi.stackexchange.com/a/13937/6506)

~~~
dhcar
Thanks for posting this, I was second guessing that a simple nmap/fing and SSH
would do the trick. From there you can set up a VNC and be able to tackle most
tasks. Thats what I did on my Pi 2, not sure why it would be different on a
zero.

~~~
davidmaitland
It's no different at at. Although VNC is a bit overkill for most tasks.

------
billybilly1920
I've always just used this
[http://www.adafruit.com/products/954](http://www.adafruit.com/products/954)
and connect to the pi via serial. Although with the 0 it would require
soldering on 2-4 pins.

------
Kluny
I've got an older raspberry pi, like maybe from 2013, that I never got around
to using because I haven't got a monitor handy that'll work with it. Will this
work on that model?

~~~
davidmaitland
It sure will. It's a bit easier though as you can just use the ethernet port
as that's already configured to use DHCP. So you can skip the step that
envolves changing the files on the SD card.

~~~
Kluny
Cool, thanks.

------
dekhn
I wouldn't do this without having a USB serial cable as a fallback. It's too
easy for the pi to not come up and then you have basically zero options to
debug remotely.

~~~
davidmaitland
Umm, but you can always remount the SD card on your computer or even reinstall
the image. There is essentially no way to brick your device by doing this.

~~~
dekhn
How does that help debugging why your device didn't come up on the network?
There are a number of reasons the device won't come up; often those are not
easily deduced from a log file but can be easily debugged with a serial
connection. Also that doesn't require you to mount the SD or reinstall the
image.

~~~
davidmaitland
A serial adapter is great if you have one. But for the average person who may
have picked up their first Pi free with a magazine is highly unlikely to have
one. For most people changing two files is a pretty quick, safe and easy way
to get wireless networking going with minimal extra hardware. Although you
could easily remount the SD card and view the log files if you needed.

------
gregwtmtno
If you don't have a computer that can read and write the filesystem on the
image, it gets a little more complicated. In that case, you might be able to
make these changes using a hex editor directly on the Raspbian images.

~~~
justinsaccount
Not a chance.

~~~
gregwtmtno
I've done it myself on a FreeBSD RPi image. I don't see why it wouldn't work
on linux.

~~~
justinsaccount
What is the "it" that you did?

Changing a string like 'foo=yes' to 'foo=no ' would be easy enough - as long
as the filesystem does not checksum data.

Adding multiple lines to multiple files is not going to work very well.

~~~
gregwtmtno
I've modified configuration files on a FreeBSD filesystem image with a hex
editor to cause it to obtain a dhcp lease and allow password ssh login for the
default account. (Linux cannot read/write to the default FreeBSD filesystem.)

This allowed me to set up the RPi headless and keyboardless.

Of course the filesystem was dirty, but it's nothing an fsck couldn't solve.

