Professional Documents
Culture Documents
Hardware
CREG
IRQ#1 TXEV
M0APPTXEVENT
formation about the sender of the current message and the initializes the shared message queue and enables the
type of command requested to the receiver by the sender. IRQ line from Cortex-M0. Then, it releases Cortex-
Currently, these commands are available to both cores: M0 from reset in order to start executing the second
OSEK instance.
• CIAA_MULTICORE_CMD_ACTIVATETASK for re- • ciaaMulticore_init_Arch (Cortex-M0 core)
mote OSEK task activation. enables the IRQ line from Cortex-M4 (the other shared
• CIAA_MULTICORE_CMD_SETEVENT for remote resources had been initialized in the Cortex-M4 in-
OSEK event handling. stance).
Figure 6 shows a block diagram with the previously • ciaaMulticore_sendSignal_Arch is code-
described resources. equivalent in both processors. It executes a Data
Synchronization Barrier (DSB) instruction in order to
complete all pending memory accesses, then sends an
TXEV IRQ1
interrupt request to the other processor using the Send
Event (SEV) instruction, as described in section II-B.
• ISR(M0_IRQHandler) (for Cortex-M4 core) and
ciaaLibs
Master CPU CircBufType Slave CPU ISR(M4_IRQHandler) (for Cortex-M0 core) are
Cortex-M4 @0x20008000 Cortex-M0 the inter-core interrupt handlers. Each one acknowl-
(RAM AHB 16kB) edges the request and retrieves a message from the
shared queue prior to calling the dispatch internal
function.
IRQ1 TXEV
D. OSEK-OS generator improvement
Fig. 6. Resources scheme used by the multicore module. FreeOSEK PHP generator was modified in order to rec-
ognize new OIL configuration parameters:
• MULTICORE = TRUE has to be defined in the global
8 CIAA-Firmware OSEK Conformance Test main script: ctest.pl. operating system configuration parameters.
9 CIAA-Firmware commit 6bd509d. • CORE = 0 (master) or CORE = 1 (slave) has to be
10 Note: The OSEK RTOS used in CIAA-Firmware does not need
defined in each Task, Alarm, Counter and ISR within
dynamic memory allocation because it is a static operating system. Only
the POSIX driver stack depends on this functionality. the OIL configuration file in order to be generated in
11 CIAA-Firmware commit d75abf5. the corresponding OSEK instance14 .
12 CIAA-Firmware circular buffer definition: ciaaLibs_CircBuf.h.
13 CIAA-Firmware message structure: ciaaMulticore_ipcCmd_t. 14 Multicore OIL file example: blinking_multicore.oil.
E. OSEK-OS API extension • Improvements on shared memory structures for both
FreeOSEK API functions improved in this work are OSEK instances, such as definitions of tasks, alarms
described in this section. In every case, the new functionality and events that are currently located in both memory
is executed only if the parameter MULTICORE = TRUE is images.
defined in the OIL configuration file. • Definition of message queues for each core. In this
implementation there is only one message queue shared
• StartOS: besides OS initialization, now this function
by both cores.
calls ciaaMulticore_init (see section III-C)15 .
• Unification of the OSEK kernel, i.e., the master pro-
• ActivateTask now detects if the TaskID param-
cessor will be able to select the task to be executed
eter refers to a remote task. In this case, this function
by the slave. Currently, this behavior can be achieved
defines a ciaaMulticore_ipcMsg_t message and
indirectly using the ActivateTask function.
sends it through the multicore module (see section
• Although OSEK-OS is a static operating system (as
III-C)16 .
stated in section II-A), the POSIX device driver stack
• SetEvent works in a similar way to
used in CIAA-Firmware requires dynamically allocated
ActivateTask, detecting if the task ID refers
resources. This situation must be improved in order to
to a remote task. In such case, the event is set in the
define POSIX resources statically, improving stability
remote OSEK instance17 .
and determinism of the user application.
IV. F UNCTIONAL TESTS
TABLE II
A. Inter-core monitoring application T EST CASES AND RESULTS FOR ENERGY CONSUMPTION ANALYSIS .
The monitor OSEK-OS user level application18 is Test Description CPU Current
described in this section. It makes extensive use of the Case clock sink
multicore module of CIAA-Firmware: it consists of a set of [MHz] [mA]
A0 monitor application as described in 204 228.4
tasks defined on each core that will exchange information section IV-A.
through inter-core task activation and event setting. A1 Same as A0. 102 127.6
Behavior: The slave processor will poll the GPIO pe- A2 Same as A0. 51 69.8
ripheral. Should any GPIO state change, a remote task B0 All tasks running on master proces- 204 214.1
sor. Slave processor is hold in reset.
located in the master core will be activated in order to report B1 Same as B0. 102 118.7
this change using the UART connected to a USB interface B2 Same as B0. 51 68.7
in the board. At the same time, both processors will set C0 All tasks running on slave proces- 204 208.4
remote events periodically in order to implement a keep- sor. Master processor is in deep-sleep
mode.
alive functionality: if a processor does not receive the event C1 Same as C0. 102 114.3
from its remote counterpart and a certain timeout expires, C2 Same as C0. 51 66.5
an alarm condition will be raised on the system and the user
will be appropriately notified.
ACKNOWLEDGMENT
B. Energy consumption analysis The author would like to thank Alejandro Furfaro, Mar-
Different execution profiles were introduced in the iano Cerdeiro and Ariel Lutenberg for their support during
monitor application in order to measure the average the development of this OSEK-OS extension. Without their
current drawn by the microcontroller for each profile. Test advice, this work would not have been possible.
cases and results can be observed in Table II.
R EFERENCES
V. C ONCLUSION AND FUTURE LINES OF WORK [1] Beuche, D.; Guerrouat, A.; Papajewski, H.; Schroder-Preikschat, W.;
Spinczyk, O.; Spinczyk, O., “The PURE family of object-oriented
Considering the main technical requirements introduced operating systems for deeply embedded systems, in Object-Oriented
in section I, it can be concluded that the implementation of Real-Time Distributed Computing”, 1999. (ISORC ‘99) Proceedings.
the FreeOSEK multicore extension was successful. 2nd IEEE International Symposium on , vol., no., pp.45-53, 1999.
doi: 10.1109/ISORC.1999.776349.
In addition to the monitor application, the user can [2] UBM Tech, “Embedded Market Study”, 2014.
take advantage of another multicore implementation: the [3] NXP LPC4300 family press release, 2011.
blinking_multicore application19 . This simple exam- [4] OSEK/VDX Free License Letter.
[5] ISO/IEC 9899:1999 Specification, pp. 313, sec. 7.20.3 “Memory
ple takes advantage of all the features implemented in the Management Functions”.
multicore module. [6] OSEK/VDX 2.2.3 Operating System Specification.
In order to continue this work, a summary of future lines [7] POSIX.1-2008 Specification.
[8] Mariano Cerdeiro, “Introducción a OSEK-OS – El Sistema Operativo
of work and improvements are described: del CIAA-Firmware”, ACSE, 2015. ISBN 978-987-45523-6-5.
• Implementation of OSEK-OS mutual exclusion locks, [9] Joseph Yiu, “The Definitive Guide to ARM
R Cortex
-M3
R and
Cortex
-M4
R Processors”, Newnes, 2013.
called Resources [14]. [10] Joseph Yiu, “The Definitive Guide to ARM
R Cortex
-M0
R and
Cortex
-M0+
R Processors”, Newnes, 2015, pp. 89, sec. 4.1.2.
15 See StartOS.c:91. [11] LPC43xx User Manual, pp. 28, sec. 2.2.
16 See ActivateTask.c:92. [12] Joseph Yiu, “The Definitive Guide to ARM
R Cortex
-M3
R and
17 See SetEvent.c:93. Cortex
-M4
R Processors”, 3rd Ed., Newnes, 2014, pp. 46, sec. 2.9.
18 See monitor source code repository. [13] OSEK/VDX 2.2.3 Operating System Specification, pp. 13, sec. 3.2.
19 CIAA-Firmware: blinking_multicore example. [14] OSEK/VDX 2.2.3 Operating System Specification, pp. 29, sec. 8.