Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Board Detection

Bruno Bottazzini edited this page Jun 10, 2016 · 24 revisions

One of the Soletta™ Frameworks's goals is to provide means for users to take the most of the hardware capabilities of the board in which is running. And since each board is different, it is necessary to know the underlying board in order to provide some features like pin reference by label and the capabilities of a given pin.

To keep instructions about a variety of boards in Soletta itself would be impossible and inefficient, so a board detection infrastructure was added instead. Making possible for Soletta to detect a new board without the need to recompile or update it.

In order to discover the underlying board, Soletta searches for the board name in the following places in the listed order:

  • SOL_BOARD_NAME environment variable (Linux)
  • BOARD_NAME value configured during the build
  • Detect the board by processing the rules of files found in PKGSYSCONFDIR/boards and SOL_DATADIR/boards (Linux)
    • Default folders: '/etc/soletta/boards' and '/usr/share/soletta/boards'
    • '99_board_detect.json' that is shipped with Soletta has rules for some boards like Intel Edison, Intel Galileo, Intel Minnowboard Max and Raspberry Pi

Board Detection File

Board detection files are JSON files that are in compliance with this json schema and allows one to describe a set of rules that are used to identify a given board. In general, the file is an array of boards, on which each element is a board definition (or board entry). Soletta traverses the list until a successful validation occurs and the order of the boards listed matters so pay close attention to use this fact in your favor. Here is possible to see an usage example.

Board Definition

A board definition is composed by the board name' and a validation array. A successfully validation occurs when each rule in the validation array succeed. Then, name is used by Soletta as the current board name.

The following snippet is the board entry to detect a Intel Galileo Gen1:

{
   "name": "intel-galileo-rev-d",
   "validation": [
      {
         "file_path": "/sys/devices/virtual/dmi/id/board_name",
         "match": [ "Galileo$" ]
      }
   ]
}

Validation Rule

A validation rule (or just rule) is a set of checks that need to succeed in order to the board be detected as being the one named by the board definition.

A rule has three parts:

  • file_path - on which the checks are applied
  • match array - an array of regular expressions that should have at least one match in the file pointed by file_path
  • dont_match array - similar to the match array except that the expressions cannot match the contents of the file

Only file_path is required and in this case a rule succeed if the file exists.

The following snippet is the board entry to detect a Intel Minnowboard Max running a linux kernel newer than 3.17:

{
   "name": "intel-minnow-max-linux_gt_3_17",
   "validation": [
      {
         "file_path": "/sys/devices/virtual/dmi/id/board_name",
         "match": [ "MinnowBoard MAX" ]
      },
      {
         "file_path": "/proc/sys/kernel/osrelease",
         "dont_match": [ "^[0-2][.]", "^3[.][0-9][.]", "^3[.][0-1][0-7]" ]
      }
   ]
}

It has two rules in the validation array:

{
   "file_path": "/sys/devices/virtual/dmi/id/board_name",
   "match": [ "MinnowBoard MAX" ]
},

This one is used to detect if the board as identified by the OS matches the expected name of a MinnowBoard Max. If this rule fails, the validation fails and the system skips to the next board entry.

If it succeeds, the validation proceeds to the next rule:

{
   "file_path": "/proc/sys/kernel/osrelease",
   "dont_match": [ "^[0-2][.]", "^3[.][0-9][.]", "^3[.][0-1][0-7]" ]
}

This rule is used to check if the kernel version is greater than 3.17. If it is, all validations have passed and Soletta will assume that the board is a MinnowBoard Max running a linux newer than 3.17 and "intel-minnow-max-linux_gt_3_17" will be used as the board name.

Clone this wiki locally