CHIP Wifi setup over serial connection


I'm a sucker for tiny, low-power, cheap single board computers. It pre-dates the Raspberry Pi, as my familiarity with OpenWRT is testament to, but the Pi gave everything a massive kick up the bum. The number of tiny computing devices I've got now is, frankly, ridiculous - Moore's Law means things are getting cheaper and/or more powerful all the time, and like any nerd I like to play with the latest stuff.

Recently things have gone mental. Before the Raspberry Pi Zero stole its thunder as a "$5" computer (yeah, good luck getting it at that price - and factor in the various adaptors, leads and an SD card to make it usable), Next Thing Co's CHIP Kickstarter was gaining lots and lots of press as a "$9" computer (which it would be, if it weren't for the shipping). I had to get one though.
CHIP, by Aric Crabb/Bay Area News Group Personally, I think the CHIP is a far better board than the Pi Zero, and I should probably write up a proper review of it. Three stand-out features for this post, though, are:

  • No need for an SD card, as there's a 4GB eMMC chip (so it's good to go straight out the remarkably attractive box)
  • There's Wifi and Bluetooth radios on-board (something that's just come to the Pi 3, which is more spendy)
  • The micro USB port used for power doubles up as a serial-over-USB port without any modification (you can do this on a Pi Zero's main USB port after a load of config hacking, but not its power port)

It took a mere handful of seconds for me to realise I'd be able to set up the Wifi over the serial connection to get it online headless. And, in case the title of this post isn't enough of a clue, here's how I did it!

Host setup

These days I'm mainly on Windows boxes for development. If I were on Mac or Linux, I'd be able to use the screen command to connect to the serial terminal CHIP presents, but I used MobaXterm instead, which is pretty good (a hell of a lot better than what I remember being built into Windows 98).

The CHIP's serial terminal runs at 115200 bps, so it's not a slouch. When you plug it into your Windows box via USB, Windows (for me, at least) sees it as PI USB to Serial in the Device Manager (yeah, I know). Once you're plugged in and it's booted far enough, you will be able to get a shell on this port. Log in as root with the password chip (and consider changing it shortly after).


I would love to be able to remember how to do all the wpa_supplicant gubbins that will sort out Wifi "properly" but, alas, I'm getting old and for every new thing I learn, an something else gets crumpled up to make space for it - or it just falls by the wayside. But I remembered that every time I type wpa_ and then press tab, I see wpa_cli as one of the options (and this is on any Linux device - not just CHIP). That'll be a handy-dandy command line tool, ripe for the usage then!

  1. First, at the command line, run wpa_cli to go into interactive mode.
  2. Run scan to, erm, scan. You'll get some text come up to let you know what's going on and when there's some results for you to check.
  3. The scan_results command will list all the access points that has shown up. If the network you're trying to connect to isn't listed, something's gone wrong, and I can't help you (sorry).
  4. Found your network? Run add_network. It will return a network number, which will almost certainly be 0 (and as such I'm going to assume it is for the rest of this).
  5. Set the SSID of the network with set_network 0 ssid "name-of-network-here" and the password for it with set_network 0 psk "password-for-network-here". If your network doesn't have a password, I'm not going to help you any further - it's 2016, sort it out will ya!
  6. Tell the underlying system what we're going to use by running select_network 0. Once this is done, exit back to your shell with exit or Ctrl+D.
  7. Finally, get the the DHCP server on the network (probably your router) to give you an IP address by running dhclient wlan0.

And, with that, you should be online, able to ping and apt-get with the best of them. Hurrah!