Tutorial: Adding embOS to a bare metal project

From SEGGER Wiki
Revision as of 14:43, 2 June 2020 by Til (talk | contribs)
Jump to: navigation, search

embOS is the preferred RTOS choice for engineers all over the world for the previous 25 years in the embedded market.
embOS supports virtually any core and compiler. All popular cores and compiler are already supported by more than 80 embOS ports, including over 500 board support packages for the embedded market.

Active Simple project

Outline

Each embOS port comes with board support packages for different devices and evalboards.
We suggest to start with one of these board support packages and add your application code.
But you can also add embOS to an existing bare metal project. The following description shows step by step how to add embOS.

Where can I download the embOS files?

If you are evaluating embOS or your are working on a non commercial project you can download and use the embOS Free edition from [1]. On the other hand once you licensed embOS you will get a download link to our download portal. In either case please download the zip file. Extract the zip-file to any folder of your choice, preserving the directory structure of this file. Keep all files in their respective sub directories. The following steps assume you like to use the embOS libraries and not the embOS source code in your project. There is a separate Wiki article which explains how to use the embOS sources in your project.

How can I add embOS to my existing bare metal project?

The following screenshots are taken from Embedded Studio but the description works for other Compiler/IDEs as well.

This is a simple bare metal project for the SEGGER emPower board (NXP K66FN2M0) without embOS:

Active Simple project


As a first step please add the new folder "embOS" to your project and add the following files from the embOS shipment:

  1. One embOS library from Start/Lib.
  2. All files from the according embOS BSP Setup folder, e.g. Start/BoardSupport/Segger/K66FN2M0_emPower/Setup.
  3. In case you like to use RTT and SystemView all files from the BSP SEGGER folder, e.g. Start/BoardSupport/Segger/K66FN2M0_emPower/SEGGER.
Active Simple project


Please add the following includes paths to your preprocessor settings and add the define "DEBUG=1":

Active Simple project
Active Simple project


You can now use embOS in your application. Every embOS application file needs to include the RTOS header file "RTOS.h".

Active Simple project


Please add the necessary code to create your first task. Every task needs a separate task stack, a separate task control block and a task function. The task simply executes the code from the main() function.

Active Simple project


The main() function needs to initialize the RTOS and the hardware. After the task is created embOS is started with the call to "OS_Start()":

Build the project. It should build without any warning or error.

Active Simple project


You can now run this embOS application in hardware. embOS will execute the task function "Task()" until the application is stopped.

Active Simple project