Using mraa lib on Dragonboard

Hi,

I’ve upgraded to the latest Debian release for the Dragonboard 410c (#246-e4b1bcf6) and now the mraa library will not load into Python.

After installing the release I did a sudo apt update and sudo apt upgrade and then installed mraa following the instructions at: https://github.com/intel-iot-devkit/mraa

This gives me access to the mraa tools and it can detect the i2c device I have attached to the GPIO:

$ sudo mraa-i2c detect 0
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: 70 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

However when I try to load mraa into Python I get the following error:

$ sudo python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mraa
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/mraa.py", line 20, in swig_import_helper
    return importlib.import_module(mname)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 577, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 914, in create_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: /usr/local/lib/python3.5/dist-packages/_mraa.so: undefined symbol: mraa_i2c_lookup

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/mraa.py", line 23, in <module>
    _mraa = swig_import_helper()
  File "/usr/local/lib/python3.5/dist-packages/mraa.py", line 22, in swig_import_helper
    return importlib.import_module('_mraa')
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: /usr/local/lib/python3.5/dist-packages/_mraa.so: undefined symbol: mraa_i2c_lookup

Is anyone else seeing an issue with mraa on this release?
Or do I have an issue somewhere else?

Thanks,
Barry

OK, I’ve got this working…

A note for my future self as much as anyone else. The mraa install instructions that worked were:

sudo apt-get install git build-essential swig3.0 python-dev python3-dev nodejs-dev cmake libjson-c-dev 
wget https://github.com/intel-iot-devkit/mraa/archive/v1.7.0.tar.gz
tar -zxvf v1.7.0.tar.gz 
cd mraa-1.7.0/
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr ..
make
sudo make install

My bit of quick and dirty test code for the Silicon Labs temperature and humidity sensor are:

import mraa

class Si7034:
    def __init__(self, bus=0, slave_addr=0x70):
        self.device = mraa.I2c(bus)
        self.device.address(slave_addr)
        
    def read_temperature(self):
        reg_value = self.device.readBytesReg(0x7c, 0xa2)
        print(reg_value)
        return self._calc_temp(reg_value[0], reg_value[1])
                
    def _calc_temp(self, reg0, reg1):
        temp_code = int.from_bytes([reg0, reg1], byteorder='big')
        print(temp_code)
        act_temp = -45 + 175 * (temp_code / 2 ** 16)
        return act_temp