Month: September 2015

Getting started with Minnowboard MAX

Update October 12, 2015

MRAA 8.0 and UPM 4.0 have been released recently. These releases offer improvements in both stability and, in the case of UPM, an increase in number the sensors supported. I have updated this post to install the latest versions of this software.

End Update.

After recently receiving my Minnow Board Max  (MBM)  I found that there are few good resources for getting started with it. Unlike the BeagleBone Black I have used before, the MBM does not have a 4GB eMMC that we can program by flashing a prebuilt OS image. Instead we need to use one of the external connectors to provide storage for the OS. We have a choice of using a mini SD card, USB storage, or a SATA2 device. I chose to use an 230 GB OCZ Vector on the SATA port.

The beauty of the MBM is that it is essentially a low powered X64 compatible computer. This opens up many options for OS that we can use. Since I have such a large SSD on the system I chose to dual boot Windows and Linux. I put Windows 8.1 on just because I could, not because I have any plans to develop with it. Surprisingly, 64 bit Windows runs pretty well on the MBM — not nearly as laggy as I expected. But Windows heavily loads the MBM making it run hot compared to running it with Linux. Complete instructions for installing Windows 8.1 on the MBM can be found here.

For my needs Linux is a better choice. I want to be able to take advantage of the MRAA and UPM libraries as well as have a desktop OS on the board. Since we only have 2 gigs of memory on the MBM I want a distro with a very lightweight window manager. I also want to use Ubuntu as I have a long history with it (plus I am not that crazy about Yocto anyway). This lead me to Xubuntu — an Ubuntu distro that utilizes the XFCE window manager. I chose to use version 15.04.

To get the system I am looking for I will be following these steps:

  1. Update BIOS
  2. Install OS
  3. Install Nodejs
  4. Compile and install SWIG 3.0.7.
  5. Compile and Install MRAA 8.0
  6. Compile and install UPM 4.0

Update BIOS: 

My board shipped with version 0.80 of 64 bit BIOS.  As of 9/10/15 the latest bios is 0.82, which can be found here. I used MinnowBoard.MAX.FirmwareUpdateX64 for the update. Instructions for updating using the MBM Flash Utility can be found here.

Install O/S

Xubuntu 15.04 can be downloaded here. Be sure to get the 64 bit version. The image can be burned to a DVD or put on miniSD or thumb drive. The Ubuntu site has some detailed instructions for setting up install media. I chose to copy the Xubuntu image to a thumb drive for the install. The instructions for installing are here – they describe 14.04 but work for 15.04 as well. When complete you should go ahead and do all the updates before proceeding.

Install Nodejs:

Nodejs is available in the Ubuntu repositories, but that version will not work if we try to compile MRAA nor will it allow us to install the version of MRAA that is in NPM. There are a couple of options to get around this. We can use the Nodesource PPA and use APT or we can just download the tarball from the Node site.

The instructions for using the Nodesource PPA are here. Even though they specify 14.04, the instructions are valid for 15.04 as well.

I will use the tarball from the Node site.

It’s a simple install if we use the compiled download so I downloaded the  0.12.x  version of node. The read me in the archive details the install, but it can be difficult to decipher so I will summarize here. All we need to do is copy the files from the archive to /usr/local in the file system. We can accomplish this as follows:

cd /usr/local
sudo tar --strip-components 1 -xzf /path/to/node-v0.12.7-linux-x64.tar.gz

Or use whatever tool you are comfortable with to copy the files to the correct directories. A favorite tool of mine is Midnight Commander (which can be installed via APT).

Since we are copying the files onto the system we will need to set the NODE_PATH environment variable ourselves. This can be done by editing the /etc/environment file. Add the following line to the file:

NODE_PATH="/usr/lib/node_modules"

We need to get the change picked up by the environment. To do so enter:

 sudo source /etc/environment

Alternatively you can reboot the device. If you see node related errors later, check to make sure the environment is set correctly.

Install SWIG

SWIG needs to be installed if we are going to build MRAA. SWIG has a dependency of Perl regular expressions. Install the the needed files as follows:

sudo apt-get install libpcre3 libpcre3-dev

Then download SWIG 3.0.7 from here. Detailed build instructions can be found here. Download and decompress the SWIG source files. Change to the root of the SWIG source and run the following commands:

./configure
make
sudo make install

Install MRAA:

We need build MRAA so that we can take advantage of the Python and Java bindings as well as Node. Detailed build instructions can be found here. I will summarize the steps I followed:

First – install the perquisites. This includes a Java SDK, python dev modules, cmake and git.

sudo apt-get install python-dev python3-dev cmake git

Version 8.0 of MRAA requires JNI 8, so we need to install oracle java. Instructions for doing so can be found here. (The page may look a little funny because I chose the https address). Just follow the install instructions and  test to ensure Java 8 JDK is installed.  The Java home environment variable should be set during the install. If not set it by editing the /etc/environment again by adding JAVA_HOME. Add this line to /etc/environment:

JAVA_HOME="/usr/lib/jvm/java-8-oracle"

To ensure the JAVA_HOME setting is picked up run ‘sudo source /etc/environment’ (or reboot).

Next we need to clone the MRAA repo from git hub:

git clone https://github.com/intel-iot-devkit/mraa.git

Now we are ready to build. We will used the same out of tree build as described in the MRAA documentation.

mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr -DBUILDSWIGJAVA=ON
make
sudo make install

Install UPM:

UPM can be cloned with the following:

git clone https://github.com/intel-iot-devkit/upm.git

We will again be using the out of tree build as described in the documentation. Enter these commands to build and install:

mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr
make 
sudo make install

Testing:

There are several examples installed in /usr/share/mraa/examples that can be used to test our installation with. These can be copied to a directory we have write access to and modified to test our set up. Be sure to use the MRAA numbers for the MBM pinouts when connecting devices to the system.

Other options:

I chose a Linux setup that worked for me, but there are other options that could be used. There are several options described on the web at Minnowborad.org using different distros of Linux, 32 bit versions of the firmware and alternate BIOS firmware.

So there it is. Hopefully this post will save you some time in getting your MinnowBoard Max configured for use. It took me a couple of days to gather all the info I needed to get my setup working. Feel free to hit me up if you have any questions or found something I did wrong.

SSD1306 i2c UPM Library with the Intel Edison

UPDATE October 6, 2015.

The current version of UPM (4.0) includes this driver. However, UPM 4.0 requires MRAA 8.0. It is pretty simple to install both of these on your Edison. I have updated this guide to use the latest library.

End Update.

The SSD1306 is a very common display driver. There are tons of SSD1306 based devices to be found on Ebay and Amazon – some very inexpensive. Adafruit has several versions for sell that can easily be added to a Edison project. The main stumbling block to using these low cost displays has been the lack of an easy to use driver. Well that problem has been solved. I have recently contributed to the intel-iot-devkit UPM library an implementation of an i2c driver for this device. As of 1-Sept-15 I have been told it will be accepted and be available in the next release.

Why the UPM library? The UPM library provides a set of commonly used drivers that can be used in multiple languages. Each driver can be made available for C/C++, nodejs, java and python. The library I implemented is configured for all supported languages but only tested on C++ and nodejs. If someone uses the driver on java or python I’d like to hear about the results.

But what if we want to use the library in node before the next release? Well that is the topic of this blog post. We will go through the steps needed to compile the driver and install it on an Edison.

For C++ utilizing the driver is simpler than nodejs, python and java. All you need to do is add the source files to your iot dev kit project. The files needed are:

  1. hd44780_bits.h
  2. lcd.h
  3. lcd.cxx
  4. ssd.h
  5. ssd1306.h
  6. ssd1306.cxx

All are available in the repo  in the src/lcd directory. There is a C++ test file in the examples directory. (Make sure you are in the ssd1306 branch). If you need help configuring the iot dev kit check out this link.

If we want to use nodejs or one of the other languages we have a little more work to do.

As always, lets unsure we have the latest version of the Yocto on our system. To check your version login to your Edison and run the following:

configure_edison --version

You will need to be on version 159 to use this driver. If you need to update I find it is really easy to use the flash tool for Edison.

Once we are up to date we need to install git on our Edison. The instructions for installing git are here.

Install MRAA

Next we need to clone the MRAA repo from git hub:

git clone https://github.com/intel-iot-devkit/mraa.git

Change to the mraa directory and  checkout the 8.0 version.

git checkout tags/v0.8.0

Then we are ready to build. We will used the same out of tree build as described in the MRAA documentation.

mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr 
make
sudo make install

Install UPM:

Change back to your home directory and run the following:

git clone https://github.com/intel-iot-devkit/upm.git

Then cd to the upm directory and checkout the 4.0 version with this command:

git checkout tags/v0.4.0

We will again be using the out of tree build as described in the documentation. Enter these commands to build and install:

mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr
make 
sudo make install

There is a test script for nodejs in my repo.  Simply load this up in the XDK and run it on your device. This script will run through all the functions available in the SSD1306 driver.

Installing the SSD1306 driver is a little complicated but not that difficult to accomplish. I hope these instructions make it easy for you do get this working. If you have problems feel free to let me know in the comments and I’ll see if I can help.

This should be considered the initial implementation of this driver. I have plans to add further functionality to the driver after I get a few other things done. I’d like to have the driver handle multiple display geometries (currently it only accommodates 128*64) as well and add some graphics drawing abilities. The current implementation is very functional though, and fits my requirements pretty well.