Ubilinux on the Intel Galileo: MRAA

Hey all,
Having fixed my compiler trouble (as described in my previous two posts), I then decided to look at MRAA. MRAA (pronounced em-raa) is a hardware-abstraction library, which in English means it provides a means of using the hardware peripherals (GPIO, UART, SPI, I2C, etc) on a given board. Currently MRAA supports the Intel Galileo and Edison, and apparently also the Raspberry Pi and BeagleBone Black amongst others. MRAA aims to provide a standard interface for accessing those peripherals across these boards (and hopefully more as time wears on). Naturally MRAA is essentially C/C++ based, with Python, Node.JS and (apparently) Java bindings.
The usual way of installing MRAA is to pull it from Github, create a 'build' folder in the source tree, run cmake to generate the relevant Makefiles, and then run make and make install from the root of the source tree. However, the git version available on Ubilinux doesn't seem to work quite right on the Galileo, so I simply downloaded the source code as a zip file from Github, uncompressed it and SCP'ed the contents to the Galileo using WinSCP (yes, my primary OS is Windows. I'm not sorry.)

The whole point of this exercise is: the MRAA code is compiled into a shared library and installed somewhere on your computer, along wit the relevant header files. Your own applications will then include those header files and link against the shared library.

To build MRAA, you will need to install a few dependencies, but everything is covered on this page: http://iotdk.intel.com/docs/master/mraa/building.html . On the Galileo you will have to install git, cmake and swig3.0. I can't remember if you need Python but you might as well just install that too. On the webpage pointed to by the above URL, it explains how to turn off Node.Js and Python bindings (-DBUILDSWIGNODE=off -DBUILDSWIGPYTHON=off when running Cmake..) which I did because I really wasn't interested in using MRAA from those languages. But more importantly, the full Cmake command I ran was:


As explained in the previous posts, this will use Clang/Clang++ as the C/C++ compilers rather than gcc/g++. I did try using gcc and g++ initially but I ended up with the same "illegal compiler instruction" error as described in this post, so yeah, you definitely want to use Clang/Clang++ here. In fact, the way to use Clang/Clang++ is described on the webpage whose link I placed earlier.
Yes, although I wasn't building the Node.JS or Python bindings I remember still needing to install swig3.0.
Once that was done, I returned to the parent directory (by typing cd ..) and then ran make and make install from there. The compilation completed with no errors and installed the shared library successfully. When I tried to run one of the examples (onboard_led or something like that, which would...blink the onboard led) there was some error about not being able to find libmraa.so or something like that. Running the command "ldconfig" fixed that as the system needed to rebuild its list of shared libraries which ldconfig does...I think.
The LED blinked happily ever after.
Ps: The version I used was version 0.7.3. MRAA is currently at 0.8.0. I haven't tried to build that just yet but there shouldn't be any issues with that anyway so there.

Happy blinking!

Edit: I just downloaded the 0.8.0 sources from Github, ran the same process, and voila! Still works like a charm


Popular posts from this blog

Enabling SPI1 on the Raspberry Pi B+/Zero/2/3

Bitbanging SPI on the Raspberry Pi (via spi-gpio)

Getting Started with Logic Analyzers and Pulseview