Supporting a New SoM Baseboard with MRAA's JSON Platform API

Intel has been developing SoM (SoC on module or System on module) for a while and with the Intel® Joule™ module and Intel® Edison module you can easily create your own daughterboard/baseboard easily.

The mraa API allows easy acces to a board's I/O in a sane and structured manner. Previously in order to support a new board you had to submit a pull request to the project and get your new board type approved and more importantly automatically detected. In the case of baseboards this can be tricky, which is why we came up with an easier way to do this in the latest mraa v1.2+ versions.

I can now write this as /etc/mycustomjoule.json, describing the I/O on my board. In this case I am redefining the I/O on the Intel Joule board, but setting the 8260 LEDs as 0 & 1, and the onboard LEDs as 2-5.

  "version": "1.3.0",
      "id": 301,
      "name": "My Custom Joule",
      "pin_count": 6,
      "gpio_count": 6,
      "aio_count": 0,
      "i2c_count": 0,
      "spi_count": 0,
      "pwmDefPeriod": 0,
      "pwmMaxPeriod": 0,
      "pwmMinPeriod": 0
        {"label": "WIFILED"},
        {"label": "BTLED"},
        {"label": "100"},
        {"label": "101"},
        {"label": "102"},
        {"label": "103"}
        { "index": 0, "rawpin": 438 },
        { "index": 1, "rawpin": 439 },
        { "index": 2, "rawpin": 337 },
        { "index": 3, "rawpin": 338 },
        { "index": 4, "rawpin": 339 },
        { "index": 5, "rawpin": 340 }

I can then use my custom file mapping like this:

import mraa as m

And then use the I/O as if my board was natively supported in mraa:

x = m.Gpio(0)

An mraa json platform file can be set in your env variables like this:

$ export MRAA_JSON_PLATFORM="/etc/mycustomjoule.json"        

Meaning that anything using mraa will load the platform configuration like mraa-gpio:

$ mraa-gpio list
01       BTLED: GPIO 
02         100: GPIO 
03         101: GPIO 
04         102: GPIO 
05         103: GPIO

Note that you can define any board that follows a Linux* sysfs interface completely like this. Note that mraa compiled from npm directly does not support json-c, so you will need to either compile it from source or use our repository to get the latest mraa. More documentation on json platform is available here:

Для получения подробной информации о возможностях оптимизации компилятора обратитесь к нашему Уведомлению об оптимизации.
Возможность комментирования русскоязычного контента была отключена. Узнать подробнее.