ARTe Documentation


As explained in the introduction, the ARTE programming model has been designed to result as similar as possible to the original Arduino programming model. Each periodic loop defined by the user is specified as follows:

void loop_i(int period)
{
    ...
}
						







where i = 1,2,3,... and period represents the time interval (in milliseconds) with which the loop is executed. As in the original Arduino programming model, the setup() function is also available under ARTE with the same syntax and semantics. Similarly, the original loop() function can also be used under ARTE, offering the programmer the possibility to execute background activities when no other pending loops are running.

The ARTE build process is first presented to explain how the user code (i.e., the sketch) is processed to obtain a multitasking ERIKA application and the binary executable file. Then is illustrated how ARTE can provide support for mutual exclusion and how this is integrated inside the Arduino libraries. The whole ARTE build process flow is shown in the figure. The original Arduino framework includes a sketch pre-processing phase, denoted in the flow chart as Arduino pre-processing, which is implemented inside the Arduino IDE. The principal part of the ARTE build process consists in extending the build process with an additional processing phase performed by the ARTe parser. ARTE parser is an external software component which processes the sketch before the original Arduino processing.



The build process

ARTE Parser

ARTe parser’s first aim is to manipulate the user code, to make it understandable by the regular Arduino building process. During this phase, the sketch is processed to extract the structure of the application, that is, the identification of the loops with their periods, to automatically generate the ERIKA configuration supporting the execution of the user application. User code tagging has been done using an external open-source tool: Doxygen. For each identified loop, an ERIKA task configuration is generated in an OIL file and then associated with the code inside the loop. Also, the period of the loop is extracted and used to configure an OSEK alarm, which is the OSEK standard mechanism conceived to trigger periodic activities. The remaining part of the ERIKA configuration consists in an OIL section that specifies the underlying hardware platform; this section is selected from a set of predefined OIL templates. This phase is also responsible for transforming the sketch into an ERIKA application and modify the .cpp file produced in the previous step to make it compiler-compatible. Specifically, each ARTE loop declaration is turned into an OSEK compliant task declaration, in the form TASK(loop_i). Also, since Arduino sketches are written in C++, while Erika is written in C, the ERIKA code has to be wrapped into an extern "C" declaration to avoid errors when the code is linked together. At this point, the sketch is ready to be compiled, but it still requires additions to make it fully functional. In particular, all the ERIKA initialization functions are added in the setup() function (i.e., before any user-defined code is executed), and each OSEK alarm is activated. In this way, task activations will be entirely transparent to the user.

Arduino build process

This phase consists of the default Arduino transformation needed to produce a compiler-compatible code. In particular, the original sketch (in .ino formats) is converted to a standard .cpp file (i.e., C++ code); any additional files besides the main one are appended to it. Please refer to the official Arduino documentation for further details on this phase.

Linking

As shown in the figure, the ARTe parsing stage produces as output the ERIKA configuration consisting of an OIL file. This file is given as input to the RT-DRUID tool, which generates the specific files of ERIKA describing its configuration. At this time, the ERIKA build process is executed to obtain the RTOS binary. Note that this binary file is an RTOS image configured explicitly for the user application needs that are automatically derived from the ARTE sketch. On the other side, the user code is built employing the standard Arduino build process, enhanced to have the visibility of ERIKA C headers, so obtaining the object files of the user application. Finally, the LINK phase puts together the ERIKA binary with the object files resulted from the Arduino build process, generating the final ELF binary file ready to be loaded into the microcontroller.