OSEK overview - Embedded Engineering

Download Report

Transcript OSEK overview - Embedded Engineering

Porting GNATPro to Lego Mindstorm
NXT
Piotr Piwko
[email protected]
Summary
• Introduction & Motivations
• OSEK Operating System
• OSEK Implementation Language (OIL)
• nxtOSEK – open source firmware
• NXT Ada Library
• Demo application
• Future improvements
Slide: 2
Introduction & Motivations
• Internship consisted in:
– Porting the GNATPro ZFP Technology to ARM 7
– Writing an Ada binding for the nxtOSEK API
– Developing a working prototype
• Motivations to have a port of GNATPro to Mindstorms
– Provide a platform to learn embedded Ada programming
– Popularize the GNAT Technology in the Academic Environment
Slide: 3
OSEK overview
(http://www.osek-vdx.org/)
• OSEK - "Open Systems and the Corresponding Interfaces for
Automotive Electronics „
• Single processor operating system
• OSEK is designed to require only a minimum of hardware
resources
• OSEK Implementation Language (OIL)
• The code could be executed from ROM
• Real-time multi tasking
Slide: 4
OSEK history
• History timeline of the OSEK standard
1993
1994
1995
1997
...
2003
May 1993
January
1994
September
2003
1995
June 1997
OSEK hasThe
been
The
latest
1.0
French
founded
version
2.2.1
car
as
version
manufacturers
ofa the
joint
2.0
OSEK
project
version
Operating
PSA
in the
and
German automotive
of Renault
OSEK
System
Operating
joined
industry.
introducing
System their VDXapproach (Vehicle Distributed eXecutive)
Initial project partners:
BMW, Bosch, DaimlerChrysler, Opel, Siemens, VW
and the the University of Karlsruhe as
coordinator.
Slide: 5
OSEK compilation chain
Source: OSEK Implementation Language Specyfication 2.5
Slide: 6
OSEK application configuration files
• OSEK Implementation Language (OIL)
• The main OIL objects:
• TASK
TASK My_Task
{
AUTOSTART = FALSE;
SCHEDULE = FULL;
PRIORITY = 3;
ACTIVATION = 1;
RESOURCE = My_Res;
EVENT = My_Event;
STACKSIZE = 512;
};
• EVENT
EVENT My_Event
{
MASK = AUTO;
};
• COUNTER
COUNTER System_Counter
{
MINCYCLE = 1;
MAXALLOWEDVALUE = 10000;
/* One tick is equal to 1msec */
TICKSPERBASE = 1;
};
• RESOURCE
REROURCE My_Res
{
RESOURCEPROPERTY = STANDARD;
};
Slide: 7
OSEK application configuration files
• ALARM
ALARM Cyclic_Alarm
{
COUNTER = System_Counter;
ACTION = ACTIVATETASK
{
TASK = My_Task;
};
AUTOSTART = TRUE
{
ALARMTIME = 1;
/* My_Task is executed every 500msec */
CYCLETIME = 500;
};
};
Slide: 8
nxtOSEK
(http://lejos-osek.sourceforge.net/)
• Open source firmware for LEGO MINDSTORMS NXT
• nxtOSEK provides:
– ANSI C/C++ programming environment by using GCC tool chain
– C / C++ API for NXT Sensors, Motor, and other devices
– TOPPERS OSEK – The open-source implementation of OSEK RealTime Operating System that includes ARM7 specific porting part
• Features
– USB
– I2C bus
– Floating Point
– Direct boot from RAM (max. 64Kbytes single nxtOSEK application
uploaded to RAM, no Flash write)
Slide: 9
nxtOSEK + GNATPro ZFP
Source code which is
written in Ada
Ada binding library for the
nxtOSEK API
GNATPRO 6.1.1 arm-elf
cross-compiler
Slide: 10
NXT Ada Library
• Structure of the Ada binding library
nxtOSEK .OS
.NXT
.Types
.Utils
.Bluetooth
.I2C
.Sound
.Display
.Motor
.Acceleration_Sensor
.Gyroscopic_Sensor
.Light_Sensor
.Sonar_Sensor
.Sound_Sensor
.Touch_Sensor
Slide: 11
Overall view
• Relation between Compiler, OS and API bindings
with nxtOSEK.OS;
with nxtOSEK.Display;
procedure My_Task;
pragma Export (C, My_Task,
"TaskMainMyTask");
TASK MyTask
{
PRIORITY = 1;
ACTIVATION = 1;
SCHEDULE = FULL;
STACKSIZE = 512;
};
procedure My_Task is
begin
nxtOSEK.Display.Update;
nxtOSEK.OS.Terminate_Task;
end My_Task;
ALARM MyTask_Alarm
{
COUNTER = SysCnt;
ACTION = ACTIVATETASK
{
TASK = MyTask;
package nxtOSEK.Display is
};
procedure Update;
AUTOSTART = TRUE
private
{
pragma Import (C, Update,
ALARMTIME = 1;
"display_update");
CYCLETIME = 500;
end nxtOSEK.Display;
};
package nxtOSEK.OS is
};
procedure Terminate_Task;
private
pragma Import (C, Terminate_Task,
„terminate_task");
end nxtOSEK.OS;
Slide: 12
It’s demo time! – The Remote Control Vehicle
• Control
Vehicle Panel
– Forward
Rear-wheel
anddrive
backward
(2 motors)
movements (2 touch sensors)
– Steering (gyroscopic
System (1 motor)
sensor)
– Ultrasonic
Communication
Obstruction
SystemDetection (sonar sensor)
- master
device)
– (Bluetooth
Communication
System
(Bluetooth – slave device)
Slide: 13
Inside the demo
• Vehicle
Bluetooth protocol
Steering system
1 motor
Sonar task
Cycle:
50ms
Critical distance: 30cm
Receive task
Cycle: 5ms
Sonar warning flag
Shared resource
Main propulsions
2 motors
Slide: 14
Inside the demo
• Control panel
Movement control
2 Touch sensors
Buttons task
Cycle: 200ms
Bluetooth protocol
Receive task
Cycle: 50ms
Gyroscopic sensor
Steering task
Cycle: 5ms
LCD display
Slide: 15
Distributing GNATPro for Mindstorm NXT
• How we plan to distribute the toolset
– Look at conferences where we can use the Lego Mindstorm NXT
as a giveaway.
– Make the technology available to the GAP and Libre communities.
• What we want to include in the toolset
– arm-elf GNAT cross-compiler
– NXT Ada Library
– nxtOSEK
– Examples
Slide: 16
Future improvements
• nxtOSEK application configuration files builder
• Object-oriented nxtOSEK Ada Library
• Other Ada run-time environment, ex. Ravenscar
Slide: 17
Questions?