Wednesday, June 1, 2016

Iotivity on the Intel IoT Gateway

Iotivity is "an open source software framework enabling seamless device-to-device connectivity to address the emerging needs of the Internet of Things."  It has the backing (as in paid programmers) of some of the major players, including Intel and Samsung, to name just two.

You probably wouldn't want to build Iotivity on an IoT gateway machine; it is designed as embedded software, after all, so you'd cross-compile it on a more powerful machine and then install it.  Or rather, you'd build a platform image in the proper way, but that is beyond the scope of this article (I'll blog about it later).  But if you're working on Iotivity itself, and if you're pulling changes on the bleeding edge, you need to build it by hand. Here's how.

The instructions for Linux on the Iotivity website are for Ubuntu LTS 12.04.  They assume that apt-get is installed, which is not the case with WindRiver Linux on a gateway.  WRLinux does have rpm, but I'm not yet familiar that so let's do it by hand.

WARNING: this is a little bit messy at the moment, as I'm composing it as my build proceeds, but it should be of some use.  I'll clean it up a bit later.

Note that the build scripts are supposed to do some of this stuff automatically (e.g. download and compile some of the deps).  Which they do, on Ubuntu.  I had some trouble getting them to work on WRLinux (also OS X), plus the build scripts make some assumptions that only work on Ubuntu. So I decided to pull out most (all?) of the dependency stuff and handle it separately, manually.  Once you have that stuff installed the build seems to proceed smoothly.

  • tinycbor - see below
  • gtest-1.7.0
    • the build scripts use, but google has switched to github:
  • bzip2 - only need for downloading other deps?
  • uuid
  • libicu
  • gio - BLE uses gdbus.  deps:
    • glib - low-level C routines etc. from the Gnome project
      • libffi - Foreign Function Interface
        • - download zipfile, ./, .configure...
      • libpcre - Perl Compatible Regular Expressions
  • python 2.7.*
  • scons
  1. Python 2.7.* - should be already installed.  Needed for scons
  2. Install bzip2
    1. $ wget
    2. verify md5 checksum:  $ md5sum ...
    3. $ tar -zxvf bzip2-1.0.6.tar.gz
    4. $ cd bzip2-1.0.6
    5. $ sudo make install
  3. Install libuuid
    1. $ wget
      1. Do NOT use OSSP uuid, it seems to be missing some fns
    2. verify integrity - on Sourceforge you can find the checksums in the file browser; see Verifying Downloaded Files.
    3. $ tar -zxvf libuuid-1.0.3.tar.gz
    4. $ cd libuuid-1.0.3
    5. $ ./configure
    6. $ make
    7. $ sudo make install
  4. Install libicu
    1. e.g. $ wget
    2. build it
  5. Install libpcre (
    1. $ wget
    2. $ wget
    3. $ gpg --verify pcre-8.38.tar.bz2.sig
    4. $ gpg --recv-keys FB0F43D8 (or whatever key is shown by the --verify op)
    5. $ tar -jxvf pcre-8.38.tar.bz2
    6. $ ./configure --enable-utf --enable-unicode-properties
    7.  $make && sudo make install - puts libs in /usr/local/lib
  6. Install libffi
  7. Install glib - this may be a pain, see Notes on glib below.
    1. blah....
    2. $ ./configure
      1. Unfortunately the system pcre lib in /usr/lib64 is apparently not compiled with unicode support so ./configure will not finish.  I linked /usr/lib65/ to /usr/local/lib.  I dunno if that's a good idea, but it got me thru ./configure
  8. Install boost
    1. $ wget
    2. verify sha256 hash:  $ sha256sum ...
    3. $ tar -jzvf boost_1_61_0.tar.bz2
    4. $ cd boost_1_61_0
    5. $ ./ --with-libraries=system,filesystem,date_time,thread,regex,log,iostreams,program_options --prefix=/usr/local
    6. $ ./b2
    7. go make a cup of coffee, the build takes a long time
    8. $ sudo ./b2 install
  9. Install scons
    1. $ wget
    2. see  Building and Installing SCons on Any System
  10. Build Iotivity
    1. Download:  $
      1. NOTE: download the zip file and check the sha256 sum.  As of the time of writing, the tar.gz file does NOT match its checksum!
      2. $ unzip
      3. $ cd iotivity-1.1.0
      4. $ scons
The build takes quite a while.


At the very beginning you will see a message like this:

*********************************** Error: *************************************
* Please download cbor using the following command:                               *
*     $ git clone extlibs/tinycbor/tinycbor *

But when you try to do this you will get an error:

fatal: unable to access '': Problem with the SSL CA cert (path? access rights?)

Gateways running WRLinux come with lots of certificates (see /etc/ssl/certs) but apparently not the one we need for git cloning.  The workaround is to use wget.  Go to the tinycbor git repo in your browser, click on the "Clone or download" button, then right click on the "Download zip" link to copy the link address.  On the gateway, cd to iotivity-1.1.0/extlibs/tinycbor, wget the zip file, and unzip it.  You'll get a directory called tinycbor-master.  Rename this to tinycbor, and then return to the iotivity-1.1.0 dir and rerun scons.

Other notes:

$ scons -c  seems to hang when it gets to "scons: Cleaning targets ..."  ???

Notes on glib:

The bluetooth le stuff for linux depends on the Bluez stack, which
depends on gdbus, which depends on gio, then glib, etc.

So we install glib-2.0, and then the trouble starts.  The pkg-config
files go in /usr/local/lib/pkgconfig, but when scons runs pkg-config
it only uses the default dir, namely /usr/lib64/pkgconfig.  I don't
know how to get it to also look in /usr/local, you can't pass stuff
via env vars.  So the quick-n-dirty is to copy the relevant *.pc
files.  Ditto for the headers; copy /usr/local/include/gio-unix-2.0 to

No comments:

Post a Comment