Difference between revisions of "Tutorial: Adding embOS to a bare metal project"

From SEGGER Wiki
Jump to: navigation, search
(Created page with "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 popul...")
 
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
embOS is the preferred RTOS choice for engineers all over the world for the previous 25 years in the embedded market.
+
embOS has been the preferred RTOS choice for engineers all over the world for the past 25 years in the embedded market.<br>
 
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.
 
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.
   
[[File:emPower_RevD_201905.png|400px|none|alt=Active Simple project]]
+
[[File:emPower_RevD_201905.png|400px|none|alt=emPower]]
  +
   
 
=== Outline ===
 
=== Outline ===
Each embOS port comes with board support packages for different devices and evalboards.
+
Every embOS port comes with many board support packages for different devices and evalboards.<br>
  +
We suggest starting with one of these board support packages and adding your application code.<br>
Although in most cases it is not necessary to create your own board support package .
 
  +
But you can also add embOS to an existing bare metal project.
But further board support packages may easily be created on your own or can be requested by SEGGER.
 
  +
The following description shows step by step, how to use embOS.
Usually we suggest to start with one of these board support packages and add your application code.
 
   
  +
=== Where can I download the embOS files? ===
You can also add embOS to an existing project.
 
  +
If you are evaluating embOS or are working on a non-commercial project, you can download and use the embOS Library variant under the [https://www.segger.com/purchase/licensing/license-sfl/ SEGGER’s Friendly License (SFL)] from [https://www.segger.com/downloads/embos].
The following description shows step by step how to add embOS.
 
  +
On the other hand, once you have 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 [[Source code project|Wiki article]] which explains how to use the embOS sources in your project.
   
=== Where can I get the embOS files? ===
+
=== 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.<br>
If you evaluate embOS or your are working on a non commercial project you can download and use the embOS Free edition from [https://www.segger.com/downloads/embos].
 
  +
This is a simple bare metal project for the SEGGER emPower board (NXP K66FN2M0) without embOS:
Once you licensed embOS you will get a download link to our download portal. In either case please download the zip file.
 
  +
[[File:K66_emPower_SimpleProject.png|none|alt=Bare metal project]]
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 are working with the embOS libraries and not with the embOS source code.
 
There is a separate Wiki article about replacing the embOS library with the embOS source code.
 
   
=== How can I add embOS to my existing project? ===
 
The following screenshots are taken from Embedded Studio but the description works for other Compiler/IDEs as well.
 
   
  +
We will use the appropriate embOS board support package from the embOS shipment in the folder ''Start/BoardSupport/Segger/K66FN2M0_emPower''.
This is a simple project for a SEGGER emPower board (NXP K66FN2M0) without embOS:
 
  +
[[File:embOS_BSP_folder.png|none|alt=BSP folder]]
   
[[File:K66_emPower_SimpleProject.png|none|alt=Active Simple project]]
 
   
  +
=== Files ===
   
As a first step please add the new folder "embOS" to your project and add the following files:
+
As a first step, please add the new folder ''embOS'' to your project and add the following files from the embOS shipment:
  +
* One embOS library from ''Start/Lib''. If you are unsure which embOS library you should use, please have a look at the CPU/compiler specific embOS manual in the chapter "Libraries".
# One embOS library from Start/Lib.
 
# All files from the according embOS BSP Setup folder, e.g. Start/BoardSupport/Segger/K66FN2M0_emPower/Setup.
+
* All files from the according Setup folder, e.g. ''Start/BoardSupport/Segger/K66FN2M0_emPower/Setup''.
# In case you like to use RTT and SystemView all files from the BSP SEGGER folder, e.g. Start/BoardSupport/Segger/K66FN2M0_emPower/SEGGER.
+
* If you like to use RTT and SystemView all files from the SEGGER folder, e.g. ''Start/BoardSupport/Segger/K66FN2M0_emPower/SEGGER''.
   
[[File:embOS_files.png|none|alt=Active Simple project]]
 
   
  +
[[File:embOS_files.png|none|alt=embOS files]]
   
  +
=== Preprocessor settings ===
Please add the following includes paths to your preprocessor settings and add the define "DEBUG=1":
 
   
  +
Please add the following include paths to your preprocessor settings and add the define ''DEBUG=1'':
[[File:embOS_Includes.png|none|alt=Active Simple project]]
 
   
[[File:embOS_Defines.png|none|alt=Active Simple project]]
+
[[File:embOS_Includes.png|none|alt=embOS includes]]
   
   
  +
[[File:embOS_Defines.png|none|alt=embOS defines]]
You can now use embOS in your application. Every embOS application file needs to include the RTOS header file "RTOS.h".
 
   
  +
=== Additional settings ===
[[File:embOS_RTOS_h.png|none|alt=Active Simple project]]
 
  +
  +
With specific embOS ports additional project, stack or linker settings might be necessary.
  +
For example, if the CPU uses a separate interrupt stack, the interrupt stack size might need to be adjusted.
  +
  +
=== Application ===
  +
  +
You can now use embOS in your application. Every embOS application file needs to include the RTOS header file ''RTOS.h''.
  +
  +
[[File:embOS_RTOS_h.png|none|alt=RTOS.h]]
   
   
Line 51: Line 62:
 
The task simply executes the code from the main() function.
 
The task simply executes the code from the main() function.
   
[[File:embOS_Stack_TCB.png|none|alt=Active Simple project]]
+
[[File:embOS_Stack_TCB.png|none|alt=Task stack and control block]]
   
   
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()":
+
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()'':<br>
 
 
Build the project. It should build without any warning or error.
 
Build the project. It should build without any warning or error.
  +
  +
[[File:embOS_main.png|none|alt=main()]]
  +
  +
 
You can now run this embOS application in hardware.
 
You can now run this embOS application in hardware.
embOS will execute the task function "Task()" until the application is stopped.
+
embOS will execute the task function ''Task()'' until the application is stopped.
  +
  +
[[File:embOS_Run.png|none|alt=embOS debug session]]
  +
   
  +
=== Conclusion ===
[[File:embOS_main.png|none|alt=Active Simple project]]
 
  +
embOS can be added to every bare metal project very easily. A first RTOS project can be setup within a few minutes.
  +
Please let us know if you have any further questions.

Latest revision as of 10:51, 24 October 2023

embOS has been the preferred RTOS choice for engineers all over the world for the past 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.

emPower


Outline

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

Where can I download the embOS files?

If you are evaluating embOS or are working on a non-commercial project, you can download and use the embOS Library variant under the SEGGER’s Friendly License (SFL) from [1]. On the other hand, once you have 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:

Bare metal project


We will use the appropriate embOS board support package from the embOS shipment in the folder Start/BoardSupport/Segger/K66FN2M0_emPower.

BSP folder


Files

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

  • One embOS library from Start/Lib. If you are unsure which embOS library you should use, please have a look at the CPU/compiler specific embOS manual in the chapter "Libraries".
  • All files from the according Setup folder, e.g. Start/BoardSupport/Segger/K66FN2M0_emPower/Setup.
  • If you like to use RTT and SystemView all files from the SEGGER folder, e.g. Start/BoardSupport/Segger/K66FN2M0_emPower/SEGGER.


embOS files

Preprocessor settings

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

embOS includes


embOS defines

Additional settings

With specific embOS ports additional project, stack or linker settings might be necessary. For example, if the CPU uses a separate interrupt stack, the interrupt stack size might need to be adjusted.

Application

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

RTOS.h


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.

Task stack and control block


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.

main()


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

embOS debug session


Conclusion

embOS can be added to every bare metal project very easily. A first RTOS project can be setup within a few minutes. Please let us know if you have any further questions.