michaelslab

mKernel is a small operating system intended for the PIC18Fx550 chip using an API OSEK/VDX like system build approach.  I started this project SDCC. The memory foot print  was consuming 80% of the code space. So the basic idea of Mkernel was born.

Besides of beeing simple and small, starting with Version 0.6.x the kernel API will be developed based along the OSEK/VDX specification since i like to reuse the mature semantics of the OSEK/VDX specifications as long as it creates no addtional burden.  Specially the idea of leaving the creation of the complete system to tools  using a specification language  as input has become a key element of Mkernel.

Even though, mkernel is not intended as a OSEK/VDX compliant implementation, it supports the following OSEK/VDX inspired features:

  • Extended Task Model
  • Resources
  • Counter & Alarms
  • Process communication based on OSEK/VDX like event passing
  • OIL Systembuilder
  • Process/Interrupt handler communication based on events and resources.
  • Simple device model
  • Drivers for most of the built in devices of the PIC18f4550 (ADC,PWM,CVREF, I2C, COMP).
  • Drivers for the IOR5E board

Getting started with mkernel

The kernel is implemented as a set of libraries which are linked with the application part.  Lets assume we like to write an application which is intended to toggle an LED. The first thing you need is an alarm which fires periodically and a task which does the actual toggeling. 

The implementation of such a task rather straight forward:

static byte led_state = 0;

TASK(ToggelLED) {
          led_state = !led_state;
          if(led_state) led_on(1); else led_off(1);
          TerminateTask();
}

This task needs to be associated with an periodic alarm. This is done by creating three entries in the system defintion file of the application. The following definitions do specify a counter which is associated with an alarm which activates the task ToggelLED.

COUNTER ledCounter {
   MAXALLOWEDVALUE = 20;
   TICKSPERBASE = 10;
};

ALARM ledAlarm {
   COUNTER = ledCounter;
   ACTION = ACTIVATETASK { TASK = ToggelLED; };
   AUTOSTART = TRUE { APPMODE = IOR5E;};
};

The properties of the actual task need to be specified as well.

TASK ToggelLED {
   PRIORITY = 1;
   STACKSIZE = 96;
   SCHEDULE = FULL;>
   AUTOSTART = FALSE;
};

Running the OIL compiler will provide the glue code needed to maintain the counters and the provide the task.
After linking the image it is loaded into the micro controler using e.g. a bootloader.

The most simples way of getting started is to create a directory in the root directory of the mkernel installation and  copy the Makefile and a sample testx.c into this directory from the ./samples directory.

Application Interface

The API available to applications is described in the include file kernel.h. It provides task managemant and communication function which allows an task to event on external events and to send events to other tasks. The documentation is generted from the source code using doygen. The API documentation is avaiable here!

Project Location

The source code it hosted at sourceforge.net under https://sourceforge.net/projects/mkernel/