https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Automotive Embedded
Systems part2
(OSEK/VDX)
Operating System
ENG.KEROLES SHENOUDA
1
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
OSEK/VDX
Operating System
it's time to wake up 
2
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
AUTOSAR
 AUTOSAR = AUTomotive Open System Architecture
 More informations on the site: http://www.autosar.org
3Will talk in details in the next parts. But Now I need to focus
on the AUTOSAR OS
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
AUTOSAR
 AUTOSAR = AUTomotive Open System Architecture
 More informations on the site: http://www.autosar.org
4Will talk in details in the next parts. But Now I need to focus
on the AUTOSAR OS
Application layer: software
components which implement ECU
functions
RTE: middleware which
implements and access to the
hardware resources
for the application layer
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
AUTOSAR
 AUTOSAR = AUTomotive Open System Architecture
 More informations on the site: http://www.autosar.org
5Will talk in details in the next parts. But Now I need to focus
on the AUTOSAR OS
Services layer: AUTOSAR OS
kernel, communication protocols,
NVRAM
access services, diagnostic services.
ECU abstraction layer: high level
access to on-board and off-board
devices
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
AUTOSAR
 AUTOSAR = AUTomotive Open System Architecture
 More informations on the site: http://www.autosar.org
6Will talk in details in the next parts. But Now I need to focus
on the AUTOSAR OS
Micro-controller abstraction layer:
low level access to on-board devices.
Complex drivers: free slot in the
architecture to implement special
device drivers
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
AUTOSAR OS
 AUTOSAR OS is the specification of an OS kernel
for AUTOSAR architecture.
 It is based on OSEK/VDX OS :
 It adds new concepts: OS-Application, Schedule
Table, Global Time, Software Counter.
 the main improvement is the addition of configurable
mechanisms for error detection in the kernel (called
“protection facilities”) This rectify the OSEK/VDX
OS inability to support critical systems
7
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
AUTOSAR OS
 AUTOSAR OS is the specification of an OS kernel for
AUTOSAR architecture.
 It is based on OSEK/VDX OS :
 Software counters
 Schedule Tables
 Global time synchronization
 Stack monitoring
 OS Applications
 Protection mechanisms
 the main improvement is the addition of configurable
mechanisms for error detection in the kernel (called
“protection facilities”) This rectify the OSEK/VDX OS
inability to support critical systems
8
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
What is the OSEK-VDX ?
9
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
OSEK/VDX Overview
 OSEK : "Open System sand the Corresponding
Interfaces for Automotive Electronics"
 VDX : Vehicle Distributed executive
 The OSEK API was designed by automotive suppliers.
 System specification (architecture, interfaces et
behavior) for automotive electronic embedded systems
(http://www.osek-vdx.org )
 OSEK/VDX (OSEK Vehicle Distributed eXecutive)
 Operating System(OS)
 Communications(COM)
 Network Management(NM)
10
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
OSEK Specifications
 OSEK OS
 serves as a basis for the controlled real-
time execution of concurrent applications
 OSEK OIL
 OIL provides a possibility to configure an
OSEK/VDX application inside a particular
CPU
 OSEK COM / NM
 provides interfaces and protocols for the
transfer of data within vehicle networks
11
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Goals & Motivations
 High expenses coming from the development
and/or port of operating system
 No interoperability of systems built by
different providers
 Standardized interfacing features
 Utilization of the existing resources in the
vehicle, enhance the performance of the overall
system without requiring additional hardware.
 Basic software reusability, Application
portability.
12Reusability
Distributed functions
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Where is OSEK compared to other OS ?
13
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
ECU software architecture
14
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
OSEK/VDX OS
15
Services of OSEK:
• Task services
• Synchronization services (events)
• Mutual exclusion services (resources)
• One-shot and periodical services (counters and alarms)
• Interrupt management services
• Communication services
• System services and error management
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
OSEK OS + OIL Application
 Objects of an OSEK application are all defined when the
application is designed
 Objects are static.
 i.e: there are no creation/deletion of tasks, resources, ...dynamically
during the execution of the application.
 Data structures are used to store the properties of the objects
and are defined
statically when the application is built.
 A language has been defined (and standardized) to define the
attributes of the objects in a simple way:
 OIL: OSEK Implementation Language
 The OIL syntax is a simple one: based on objects (tasks,
resources, …) with a value for each attribute. Some attributes
have sub-attributes.
16
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Applications
17
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
So We will make our labs on
Trampoline, So
What is Trampoline?
18
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
What is Trampoline?
 Trampoline is an open platform for small embedded systems with
real-time constraints
 It is based on the OSEK/VDX OS and AUTOSAR OS standards
 So it is compatible with OSEK/VDX OS and AUTOSAR OS API.
 OSEK/VDX and Autosar os are static operating systems.
 That means the objects of the application, tasks, events, resources, . . . ,
cannot be created or deleted during the execution of the application. All
objects are statically designed
 and instead of forcing the user to describe the application in C, a work
that can be error prone, a specfic language is used, OIL or XML2.
 A compiler, goil, is used to translate the description in the equivalent C
structures. goil performs verifications too.
19
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Tasks in OSEK
20
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Tasks in OSEK
 Tasks are « active » elements of the application
2 categories of tasks exist in OSEK/VDX:
21
Basic tasks Extended tasks
A basic task is a sequential C
code that must terminate
The task that are
able to wait for an
event are called
Extended tasks
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Basic task states
22
Basic tasks only release
the processor, if
• they terminate,
• the OSEK operating system
switches to a higher-priority
task, or
• an interrupt occurs which
causes the processor to
switch to an interrupt service
routine (ISR).
The state model of basic tasks is nearly identical to the extended
tasks state model. The only exception is that basic tasks do not
have a waiting state.
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
States and status transitions for basic tasks
23
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_systemExtended tasks 24
Extended tasks have four task states:
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
OSEK scheduling policy
25
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
OSEK scheduling policy
 Scheduling is done dynamically during the execution of the application.
 Tasks have a fixed priority
 The priority of a task is given at design stage;
 The priority does not change (almost, taking and releasing resources may change
the priority);
 No round-robin.
 If more than one task have the same priority, tasks are run one after the other.
ie a task may not preempt a task having the same priority
 Tasks may be preemptable or not (almost)
 This property is defined at design stage.
26
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Scheduling modes
 “Full preemptive”:
 All tasks are preemptable.
 “Full non preemptive”:
 All tasks are non-preemptable
 “Mixed”:
 Each task may be configured as preemptable or non-preemptable
 It is the most flexible model.
 For instance, a very short task (in execution time) may be configured as non-
preemptable because the context switch is longer than its execution.
27
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Processing Levels
28
 The OSEK operating system enables a
controlled real-time execution of several
processes which appear to run in parallel
 Entities which are competing for the CPU
are:
 Interrupt service routines
 Tasks
 OSEK defines three processing levels:
 Interrupt level
 Logical level for scheduler
 Task level
 Priority rules:
 Interrupts have precedence over tasks
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Full preemptive
 Full preemptive scheduling will put the running task into the ready state,
as soon as a higher-priority task has got ready. The task context is saved
so that the preempted task can be continued at the location where it was
preempted.
 EX: task T2 with the lower priority does not delay the scheduling of task
T1 with higher priority.
29
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Full non preemptive
 the non preemptable section of a running task with lower priority delays the
start of a task with higher priority up to the next point of rescheduling
 EX: task T2 with the lower priority delays task T1 with higher priority up to
the next point of rescheduling (in this case termination of task T2).
30
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Tasks’ services
31
TASK(myTask)
{
//Task’s instructions
…
//Task_Service API
}
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
TerminateTask Service
StatusType TerminateTask(void);
 StatusType is an error code:
 E_OK: no error
 E_OS_RESOURCE: the task hold a resource
 E_OS_CALLEVEL: the service is called from an interrupt
 The service stops the calling task. The task goes from
running state to suspended state.
 A task may not stop another task
32
TASK(myTask)
{
//Task’s instructions
…
TerminateTask();
}
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
ActivateTask service:
StatusType ActivateTask(TaskType <TaskId>);
 The argument is the id of the task to activate.
 StatusType is an error code:
 E_OK: no error
 E_OS_ID: invalid TaskId (no task with such an id)
 E_OS_LIMIT: too many activations of the task
 This service puts the task <TaskId> in ready state
If the activated task has a higher priority (preemptive), the calling task is
put in the ready state. The new one goes in the running state.
33
TASK(myTask)
{
//Task’s instructions
…
ActivateTask(T2);
…..
}
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Example 1 34
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Example 2 35
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Example 3 36
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
ChainTask service
StatusType ChainTask(TaskType <TaskId>);
 The argument is the id of the task to activate;
 StatusType is an error code:
 E_OK: No error
 E_OS_ID: invalid TaskId (no task with such an id)
 E_OS_LIMIT: too many activations of the task
 This service puts task <TaskId> in ready state, and the calling task
in the suspended state.
 This service replaces TerminateTask for the calling task
37
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Example 4
38
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Be HapPy
Now the Lab Time 
39
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
40
• The requirement
• Two Basic Tasks T1 And T2
• T1 (autosatart)will toggle led 0
• T2 Will toggle led 1
• T1(priority) > T2(priority)
• Led0 @ PortA bin 4
• Led1 @ PortA pin 5
Led0
Led1
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
First Write the oil File 41
We will learn
the oil
Parameters
step by step
Through labs

https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
The Oil File
 PRIORITY : integer: the
priority of the process.
 ACTIVATION : integer:
the number of activation of
a task. 1 for and extended
task or an ISR.
 AUTOSTART: boolean :
true if the process is an
autostart task, false otherwise.
42
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
The lab1.c
43
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
The output
44
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
45
• The requirement
• Two Basic Tasks T1 And T2
• T1 (autosatart)will toggle led 0
• T2 Will toggle led 1
• T1(priority) > T2(priority)
• Led0 @ PortA bin 4
• Led1 @ PortA pin 5
Led0
Led1
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
lab2
46
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
lab2
47
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
48
Oil file
Lab2.c
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
49
• The requirement
• Two Basic Tasks T1 And T2
• T1 (autosatart)will toggle led 0
• T2 Will toggle led 1
• T1(priority) < T2(priority)
• Led0 @ PortA bin 4
• Led1 @ PortA pin 5
Led0
Led1
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Oil file
50
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
lab3
51
Lab3.c
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
lab3
52
Lab3.c
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
lab3
53
Lab3.c
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Tasks’ synchronization
 Synchronization of tasks: A task should be able to wait an external
event (a verified condition).
 To implement this feature, OSEK uses events.
 Task’s model is modified to add a new state: waiting.
 The task that are able to wait for an event are called Extended tasks
54
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Will go #in_depth in the next session
get Break 
55
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
References
 Embedded Microcomputer Systems Real Time Interfacing Third
Edition Jonathan W. Valvano University of Texas at Austin.
 MicroC/OS-II the real-time kernel second edition jean j.labrosse.
 RTOS Concepts http://www.embeddedcraft.org.
 OSEK/VDX Operating System Specification 2.2.3
 AUTOSAR Layered Software Architecture
 The Trampoline Handbook release 2.0
 Trampoline (OSEK/VDX OS) Test Implementation -Version 1.0,
Florent PAVIN ; Jean-Luc BECHENNEC
56
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
References
 Trampoline:an open platform for (small) embedded systems based on
OSEK/VDX and AUTOSAR
http://trampoline.rts-software.org/
Jean-Luc Béchennec1;2, Sébastien Faucou1;3
1IRCCyN (Institute of Research in Communications and Cybernetics of Nantes)
2CNRS (National Center for Scientific Research) / 3University of Nantes
10th Libre Software Meeting
57
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
References
 Real Time Systems (RETSY)
Jean-Luc Béchennec - Jean-Luc.Bechennec@irccyn.ec-nantes.fr
Sébastien Faucou - Sebastien.Faucou@univ-nantes.fr
jeudi 12 novembre 15
 AUTOSAR Specification of Operating System V5.0.0 R4.0 Rev 3
 OSEK OS Session Speaker Deepak V.
M.S Ramaiah School of Advanced Studies - Bangalore 1
58
https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
59

Automotive embedded systems part2 v1