raspberry pi 2: reflections going forward

“Raspberry Pi 2 Model B v1.1” by Multicherry. Licensed under CC BY-SA 4.0

My work with the Raspberry Pi started with the original Raspberry Pi 1 model B, the version that came with just two USB ports and the most amount of RAM at the time, 512MB. I purchased the B+, and then earlier this year, the Raspberry Pi 2 Model B. During all that time I’ve run some distribution of Linux on it; Arch first and for the most amount of time, then Raspbian when Arch suddenly corrupted itself after what turned out to be an ill-advised update on the B+.

If you look at the entries in this blog under Raspberry Pi you’ll note that it’s been for the most part light weight and a way to get to know how the hardware and software work together. I’ve looked up and followed along, making changes necessary for it to work on my end. I’ve not published anything unique that advanced the use of the Raspberry Pi. My excuses boil down to lack of time to really research and then apply what I’ve learned. I’ve got all sorts of big ideas, but just need to figure out how to make them real.

To that end I’ve started to look at the latest releases of operating systems available for the latest Raspberry Pi 2. Before the trip I managed to install the latest Arch, Raspbian, and Windows 10 for IoT. Here’s a quick rundown on what I discovered.

Arch

The latest Arch Linux for ARM has a page devoted to installing Arch directly onto a micro SD card for the Raspberry Pi 2, using Arch Linux as the tool bench. In my case I used my Samsung R580 notebook running Ubuntu 15.04. The only tool I needed to add via apt-get was bsdtar. Otherwise the directions given for the Arch environment worked identically on Ubuntu (taking micro SD card device differences into account).

Once the installation process was finished, I put the micro SD card into the RPi 2 and watched it book into a text console. Nothing out of the ordinary in that, and in a way I prefer text over a GUI. My only complaint with the latest Arch is the lack of out-of-the-box WiFi support for the most common WiFi dongles. I had to install WiFi support after my first initial installation of Arch Linux nearly two years ago. Here I am with the latest and I find I’ve got to do that same all over again. My main reason for looking at Arch is its relatively lean footprint, but lack of WiFi support is just a bit too lean. It’s annoying to fix this issue, especially as WiFi networking on the Raspberry Pi is a big feature, two years since the last time is a long time, and when it’s not there out of the box, it’s a big issue.

Raspbian

The latest Raspbian image was installed using my Ubuntu system and the ‘dd’ method for copying the image onto another micro SD card. Once booted, Raspbian will walk you through an initial configuration and expand the file system, consuming the rest of the card. It now boots immediately into a graphical desktop. This is all well and good, but even with a quad-core ARM processor and 1GB of memory, the GUI still taxes the Raspberry Pi 2. This so-called taxing shows as a jitteriness of the mouse cursor as it moves across the screen, among other issues.

I give points to the distribution for fully recognizing my Apple USB keyboard without having to perform any kernel-level configurations, and it recognized both of my WiFi dongles and thus joined the network at boot. For a distribution where you want the greatest assurance it will come up and be usable by an absolute novice to the Raspberry Pi, the current Raspbian distribution can’t be beat. To quote Apple, “It Just Works.”

But I’m still not quite happy with it…

Windows 10 IoT

This was the most sophisticated, and in the end, the most disappointing of the three. I’m glad I gave it a spin, but I would never use it for my own work nor can I recommend it for anyone else to use.

Microsoft has a page to help you get started here. I chose to download an ISO image and to install the tools necessary to flash a micro SD card with the IoT image that comes bundled with that ISO. Once installed on the Raspberry Pi, the Pi booted into Windows 10 with absolutely no problem. The problems came later when it turned out it wouldn’t work with either of the two WiFi USB dongles I’ve been using with Linux ever since the original Raspberry Pi B was purchased.

I spent more time than I cared to slumming through the forums, but no-one seemed to know how to get WiFi working. After about an hour of trying various so-called solutions I shut it down and deleted everything. Yes, I could have plugged the Pi 2 into an open network port on my home router, but I still had no guarantee I would find the proper drivers to make WiFi work. I know how to get all that to work under various Linux distributions. The bigger issue is the requirement to have a desktop Windows system in order to develop for the Raspberry Pi 2. As I’ve written about here you can do some serious and sophisticated work natively on the Raspberry Pi, reaching back to a desktop/laptop only when the development needs are fairly serious. I don’t want to be forced to do this out of the gate. I lived that development life back in the 1990s with Wind River’s VxWorks. While that was fine back then, I don’t want to go back to that, especially now. Even the Beagle Bone Black, which requires a laptop to bootstrap it’s development tools, has everything local to the BBB, and only requires you use a browser.

Unless it changes drastically I’m done with Windows 10 IoT.

Conclusions

There’s a lot that has happened over the last two years, especially with regards to security and encryption. I knew the Internet had devolved into a dangerous place, but I didn’t know how dangerous until the leaks from Edward Snowden and other’s he’s inspired. That has in turn motivated me to think about best practices for securing an internet-of-things device such as the Raspberry Pi 2, and how best to encrypt data both at rest on the device as well as across the wire into and out of the Pi. I’ll have more to write about later, but for the present, I can’t approach this with the same naivete I did in the beginning.

cobbling together a golang development environment

Over the weekend, in between all the other tasks I do as husband, father, home owner and tax payer, I cobbled together a Go programming environment using Vim on my Ubuntu 14.10 notebook. Adding this capability required that I install Go, Go tools, and a series of Vim plugins pulled from Github.

Why Go?

I chose to go to Go (or golang) as a programming environment, specifically on the Raspberry Pi, because I’d finally had my fill of the node.js and the Io.js fork melodrama. I’d already grown quite tired of how Joyent was handling the stewardship of node.js and was loosing faith that node.js would stay up to date, such as running with Google’s latest V8 Javascript engine. In the end I decided I needed more of a mature language and supporting development tools written and managed by real adults. That’s when I decided to give a go with Go.

Go, in case you’re curious, is aimed more at systems level programming (which is where I tend to reside). Go is also a Google product, invented by two of the most iconic hackers the software world knows: Rob Pike and Ken Thompson. I know of Rob Pike primarily through his book “The Unix Programming Environment” he wrote along with Brian Kernighan. I’ve had that book since the late 1980s, along with “The C Programming Language.” That latter book was co-written by Ken Thompson along with Brian Kernighan (as well). And, of course, in his spare time, Ken Thompson was the principal inventor of Unix. And they’re now both working for Google Research.

Beyond Go’s stellar heritage, there are many reasons to use Go. Two that come immediately to my mind are Go’s ability to work closely with C/C++ code and Dave Cheney’s “Unofficial ARM Tarballs for Go” for various ARM-based tiny computers. One of the unofficial ARM targets is ARM6 and the Raspberry Pi. A second target is ARM7 and the Beagle Bone Black Rev C. The goal of this exercise is thus in two parts: get Go tooling up and running under Ubuntu, start developing Go under Ubuntu, run the products of said development under Raspbian on the Raspberry Pi using one of the unofficial tarballs, then move the entire development environment over to the Raspberry Pi itself if all of that works satisfactorily.

If Go is a poor fit on the RPi and BBB, then I intent to drop back to good ol’ C and C++. I’m done with node.js and Javascript.

Golang Setup under Ubuntu 14.10

Setting up Go is straightforward in Ubuntu (or another other major OS). The best way is to go follow the steps on the Golang site: download, follow the directions exactly, and then you’re done. That sets up the initial Go build/run environment, and you can start writing code from that point. For this exercise I downloaded and installed Go 1.4.1.

But I wanted more. I wanted an IDE, or the equivalent thereof, for Go code development. I wanted to use Vim specifically because I didn’t want to have to run a graphical desktop on the Raspberry Pi; I wanted to run on the console. In the end I chose to use Vim as my Go IDE and found reasonably current directions at myitcv:blog, “Programming with Go in Vim.”

The blog entry has everything you need to do broken down in easy-to-follow steps. Here are my comments on those steps.

  1. My version of Vim was the same, but built October 2014.
  2. I downloaded and installed Go version 1.4.1.
  3. I know how to add Vim plugins, and that’s the route I chose.
  4. For installing godef, make sure you have Mercurial installed. I didn’t and installation failed the first time.
  5. I installed all the plugins via git clone from Github. I’m using Pathogen to rule them all.

Here’s Vim performing an IDE-like function, code completion in a tiny snippet of Go code. It was this feature I wanted more than any other. I can keep the general language in my head, but code completion helps to “remember” it all. I do need to tweak the colors a bit; gray on purple doesn’t quite make it (white or yellow would be better), but it’s usable regardless. Here’s my .vimrc with what I’ve enabled so far. It will change quickly.

execute pathogen#infect()filetype plugin onset omnifunc=syntaxcomplete#Completecolo elflordsyntax onset nuset autoreadset rulerset cmdheight=2set expandtabset smarttabset shiftwidth=4set tabstop=4set statusline+=%#warningmsg#set statusline+=%{SyntasticStatuslineFlag()}set statusline+=%*let g:syntastic_always_populate_loc_list = 1let g:syntastic_auto_loc_list = 1let g:syntastic_check_on_open = 1let g:syntastic_check_on_wq = 0let g:godef_split=3let g:godef_same_file_in_same_window=1

I’ll keep updating this as I go along, with seperate posts, but for now it’s operational enough for me to learn how to write Go code. More to follow…