Elixir on Raspberry Pi 2 (using Windows)

Goal

Deploy an example Elixir application with the Nerves-Project to a Raspberry Pi 2, using an Ubuntu guest in VMware Player on a Windows host.

Synopsis

We are using the Nerves-project, buildroot and Ubuntu in a virtual machine to create a SD-Image, which contains the default application, blinky.

Motivation

After seeing this talk from Garth Hitchens on Embedded Elixir in Action I wanted to try the Nerves project to deploy an Elixir application to my Raspberry Pi 2. Yet, as I’ve blogged before I’m using a Windows machine and most of the build tools (for Raspberry Pi) are using Linux.

Prerequisites

We will need to install different software to our computer, therefore I assume you have the rights to do so. Also we need disk space (around 15 Gigabytes). Because we are using a virtual machine it does not hurt to have a beefy computer. More RAM+CPU = Better.

Steps

There are several steps needed to complete our goal, most of them require some Linux usage. Bear with me, we will make it! (Also have a look at Linux for Dummies)

Install VMware Player (10 Minutes)

On your Windows Computer do:

We will install a Hyper Visor on our computer. A Hyper Visor enables you to have an operating system in your original operating system (without the risk to destroy your computer).

There are several Hyper Visor solution available. On Windows 8 and 10 the Microsoft HyperV software is available (and installed by default, I think?). In general I would go with the defaults, but I deactivated HyperV for various reasons in the past (no 3d virtualization being one of the most pressing reasons) and choose VMware Player.

After installation of VMware player download the Ubuntu 14.04 (64bit )LTS server image (or the desktop image, I don’t care). So far, 32 WONT WORK!

Create a virtual machine (5 Minutes)

On your Windows Computer do:

Start VMware player and hit “create a new virtual machine”. In the wizard window choose the “Installer disc image file (iso)” option and select your previously downloaded Ubuntu server image.

Hit next and go along with the defaults* until it finishes.

* If you are constrained on the disk size, you can reduce it from 20 Gb to 10Gb. I tried it with 5Gb but failed on downloading all the needed tools.

Install Ubuntu 14.04 LTS (30 Minutes)

In the virtual machine do:

Start your virtual machine (green arrow) and go along with the installation defaults. I changed some aspects which I will highlight now:

  • Language: I’m using German as system language and as keyboard layout.
  • Encrypt File System: I politely declined. I couldn’t care less on this build machine. Also this is in theory a minor performance drain.
  • Packages to install: I checked the OpenSSH box

Let the installation finish. It will take some time and ask questions in between instead on the beginning. So have an eye on that. As a side note. Remember username and password. We need it. For convenience use KeePass 2 or similar software.

Get IP Address (1 Minute)

In the virtual machine do:

Finally we can log in. For later usage we need the IP address. After you logged in, enter

in the terminal. This will bring up the network interface configuration. We need the IP address of the interface eth0. In my case the line looks like

We only need the address: 102.168.62.129 in my case.

Install Nerves (10 Minutes + 45 Minutes of waiting…)

In the virtual machine do:

I installed everything in my home folder, but fell free to do so where ever you like (but remember it later on :-P)

Update your package sources:

The following code is provided by the Nerves-Project:

At this point the Nerves tutorial could be more on the point. They state “…  Change to the nerves-system-br directory…” yet there is no such folder. To fix this clone the Nerves-project/nerves-system-br project from Github!

Now we can change in the nerves-system-br folder:

Now we can follow the tutorial on the nerves-project Github page along again:

And now to kickstart the future “real” builds: Lets make a dry run to cache all files (this maywill take a while):

This takes around 45 Minutes.

Using Nerves (10 Minutes)

The tutorial states one has to source the environment. This sets some variables and is needed every time one brings up a new console

For testing I cloned the blinky example from Github

change in the new folder and in the blinky directory

Now the magic can happen:

This will create a file _images/blinky.fw

*.fw is the file format for fwup (don’t worry it is already installed). After some research (and lots of help by Frank Hunleth and Garth Hitchens I We figured out the correct command:

Using this command you create we create a Raspberry Pi image file (_images/blinky.img)

Get the image (5 Minutes)

On your Windows Computer do:

The resulting image is located in your virtual machine at ~/nerves-examples/blinky/_images/ .

To access that folder we need to download the folder from the virtual machine to your Windows computer. You can access the folder via WinSCP if you opted in for the OpenSSH package before:

Open WinSCP (if installed; otherwise: DownloadChoco Package) and create a new connection. Computer name is the IP address we saved before. Username and password are your credentials from the virtual machine (I told you to remember it!).

You will be presented with two explorer views. The left side is your computer, the right side is the virtual machine, already in the home folder of your user.

If you cloned the nerves-examples.git in the home folder as I suggested, you can easily follow the path. On the right side click through the folders ~/nerves-examples/blinky/_images/ until you find your file, which is called blinky.img. Copy the file to your computer, for example on the Desktop.

“Burn” the image (15 Minutes)

On your Windows Computer do:

To burn the image we need a tool which creates the file system from our downloaded image. Follow the tutorial on RaspberryPi.org.

Fun (Countless hours)

On your Raspberry Pi do:

Insert the SD-Card in your Raspberry Pi and power it on. Depending on your setup, something should happen! For example the blinky example lets you blink the LED, the demo example (should, didn’t work for me) let you connect via ethernet.

The fun you can have
The fun you can have

History:

  • Update 23.12.2015: Added hint for 64bit after @mdsebald mentioned it
  • Update 22.12.2015: Fixed the “Get the image” part
  • Update 22.12.2015: Fixed the tutorial
  • Update 21.12.2015: Marked the tutorial as broken

Visualizing data with Gnuplot

On my pursuade for a tool to visualize simple list values I found gnuplot:

from Wikipedia:

gnuplot is a command-line program that can generate two- and three-dimensional plots of functions, data, and data fits.

I will focus on the capabilities of gnuplot on two-dimensional plots and in special howto visualize data without a corresponding second data value. But first here is the idea why I needed such a tool:

Continue reading Visualizing data with Gnuplot

How to install HandBrake on Ubuntu 11.10

If not already happened: Install the synaptic package manager (search for synaptic in the Ubuntu software center)

Download this package according to your architecture. If you are not sure which architecture you need, try amd64 or i386. This are the two most used architectures.

Install the package by double clicking.

Open a terminal and execute sudo add-apt-repository ppa:stebbins/handbrake-releases

Open synaptics package manager, go to preferences / package sources / other software. There should be two entrys like “http://ppa.launchpad.net/stebbins/handbrake-releases/ubuntu”. Mark the first one and click on “change”. Alter the distribution code from “oneiric” to “natty”. Do the same for the second entry. Apply the changes

Back in synaptic, click on reload. Now you can search for handbrake in the package search

tadaaa