Close

Access to the GPIOs

A project log for Setting up the LinkIt C cross-compiler

Are you a "dyed in the wool" C programmer. Love your Arduino but want something more powerful. The LinkIt Smart MT7688 board may for you!

agpcooperagp.cooper 10/29/2017 at 02:290 Comments

Access to the GPIOs

The MRAA library is a low level skeleton for "communication" on linux devices.  It can be found here:

https://iotdk.intel.com/docs/master/mraa/

That is, "communication" as in GPIO, SPI, I2C, AIO (i.e. analog IO), PWM and UART (i.e. serial. Look there for examples and the "API" documentation.

Note that the "Mraa Hello" example on the home page does not compile as the functions are found in common.h and not mraa.h. You need to '#include "mraa/common.h"' in the source code! Here is my version:

#include "mraa.h"
#include "mraa/common.h"
int main(int argc, char** argv)
{
    const char* board_name = mraa_get_platform_name();
    fprintf(stdout, "hello mraa\n Version: %s\n Running on %s\n", mraa_get_version(), board_name);
    mraa_deinit();
    return MRAA_SUCCESS;
}

Getting the pre-compiled library for the cross-compiler

The mraa library and include files are not in the toolchain but they are in the SDK. Look in:

and

The libraries are:

Note that libmraa.so and libmraa.so.0 are symbolic links to libmraa.so.0.8.0 .

The includes are:

I have added an archive to the files download area of this project for the mraa library for your convenience.

An Example Run (Mraa hello)

alanx@alanx ~/LinkIt-cc/mraa_hello $ make

/home/alanx/LinkIt-cc/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mipsel-openwrt-linux-uclibc-gcc -I. -I /home/alanx/LinkIt-cc/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/usr/include -I /home/alanx/LinkIt-cc/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/include -o mraa_hello.run mraa_hello.c -L. -L/home/alanx/LinkIt-cc/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/usr/lib -L/home/alanx/LinkIt-cc/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/lib -lmraa -pthread -ldl
alanx@alanx ~/LinkIt-cc/mraa_hello $ scp mraa_hello.run root@mylinkit.local:~/Code/mraa_hello

root@mylinkit.local's password:

mraa_hello.run                                100% 7562     7.4KB/s   00:00    

alanx@alanx ~/LinkIt-cc/mraa_hello $ ssh root@mylinkit.local
root@mylinkit.local's password:

BusyBox v1.23.2 (2015-11-18 16:34:33 CET) built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 CHAOS CALMER (15.05+linkit, r47501)
 -----------------------------------------------------
  * 1 1/2 oz Gin            Shake with a glassful
  * 1/4 oz Triple Sec       of broken ice and pour
  * 3/4 oz Lime Juice       unstrained into a goblet.
  * 1 1/2 oz Orange Juice
  * 1 tsp. Grenadine Syrup
 -----------------------------------------------------
root@mylinkit:~# cd Code/mraa_hello

root@mylinkit:~/Code/mraa_hello# ls -lah

drwxr-xr-x    2 root     root        4.0K Oct 27 12:10 .
drwxr-xr-x    6 root     root        4.0K Oct 29 01:52 ..
-rwxr-xr-x    1 root     root        7.4K Oct 29 02:56 mraa_hello.run

root@mylinkit:~/Code/mraa_hello# ./mraa_hello.run

 hello mraa
 Version: v0.8.0
 Running on LinkIt Smart 7688

root@mylinkit:~/Code/mraa_hello# exit

Connection to mylinkit.local closed.

alanx@alanx ~/LinkIt-cc/mraa_hello $



AlanX

Discussions