Using embOS in CMSIS-Pack projects

From SEGGER Wiki
Jump to: navigation, search

embOS for Cortex-M complies to the Common Microcontroller Software Interface Standard (CMSIS). In addition, SEGGER offers an embOS CMSIS-Pack that allows users to generate and configure embOS projects for virtually all Cortex-M devices and various IDEs. This article provides further information on its usage.

Introduction

ARM introduced the Common Microcontroller Software Interface Standard (CMSIS) as a vendor-independent abstraction layer for simplifying software (re-)usage. The standard enables consistent and simple software interfaces e.g. to the processor and peripherals, real-time operating systems and other middleware.

Since SEGGER is one of the CMSIS partners, embOS for Cortex-M is fully CMSIS-compliant and comes with a generic CMSIS start project that can be executed on any Cortex-M device. Further start projects for specific Cortex-M devices get shipped with embOS for Cortex-M as well (e.g. more than 170 start projects are provided with embOS for Cortex-M and Embedded Studio) and are also fully CMSIS-compliant.

With the introduction of the embOS CMSIS-Pack, CMSIS-compliant embOS projects may be created with ease for arbitrary Cortex-M devices using various IDEs.

Download

The embOS CMSIS-Pack may be obtained from SEGGER.com.

Installation

The embOS expansion for STM32CubeMX may be used as-is: it does not need to be extracted before installing it in any CMSIS-Pack capable IDE.
The following example installation is done using IAR Embedded Workbench, but should be similar for other IDEs:

  1. Open the CMSIS-Pack Manager via Project -> CMSIS-Pack Manager
  2. Inside the CMSIS-Pack Manager, select CMSIS-Manager -> Import existing packs
  3. Import SEGGER.I-CUBE-embOS.1.2.0.pack (installs V1.2.0 of the pack, file name may differ for later versions)

This will extract the pack to your local IAR CMSIS-Pack repository and make it available in the IAR CMSIS-Manager as shown below:

embOS CMSIS-Pack installed in IAR Embedded Workbench

Usage

After sucessfull installation, the embOS CMSIS-Pack can be used to generate example projects with embOS.
Here, a project for a generic Cortex-M3 is created, but the same steps should be applied when creating a project for any specific device.

Select the required components in the CMSIS Manager:

  1. CMSIS
    • Core
  2. Device
    • Startup
  3. RTOS
    1. embOS API configuration
      • CMSIS-RTOS (allows usage of embOS native API and CMSIS-RTOS (v1) API)
      • CMSIS-RTOS2 (allows usage of embOS native API and CMSIS-RTOS (v2) API)
      • Native (allows usage of embOS native API only)
    2. embOS kernel configuration
      • Debug
      • Debug and Profiling
      • Debug and Trace
      • Extreme Release
      • Release
      • Stack check
      • Stack check and Profiling

An optional embOS sample application may be added as well.
We recommend adding one of these to start with, for otherwise no main() will be included in the project and it will fail to build until that main() routine is added manually:

  • OS_Mutexes.c
  • OS_Mutexes_CMSIS.c (may only be used when CMSIS-RTOS (v1) API was enabled)
  • OS_Mutexes_CMSIS2.c (may only be used when CMSIS-RTOS (v2) API was enabled)
  • OS_Start2Tasks.c
  • OS_Start2Tasks_CMSIS.c (may only be used when CMSIS-RTOS (v1) API was enabled)
  • OS_Start2Tasks_CMSIS2.c (may only be used when CMSIS-RTOS (v2) API was enabled)

For example, for a Debug and Profiling configuration using the native embOS API and the sample application OS_Start2Tasks.c, the components window would look as shown below:

embOS CMSIS-Pack project configured in IAR Embedded Workbench

Feel free to add further components as desired.
After saving the configuration and returning back to the IAR Embedded Workbench, the resulting project tree would resemble the following screenshot:

embOS CMSIS-Pack project compiled in IAR Embedded Workbench

Compilation should complete without warning or errors and you can start debugging the sample application.
Feel free to modify it and add your own application to the project.

Trouble-shooting

Linker Symbols with arm Keil µVision

When creating projects for arm Keil µVision, manual modification may be required to the used start-up file (e.g. startup_stm32f407xx.s):
If the linker cannot find Stack_Mem, an EXPORT directive for that symbol is missing in the start-up file. To resolve this, please add

       EXPORT  Stack_Mem

to the start-up file.

Linker Symbols with GNU toolchains

When creating projects for GNU toolchains, manual modification may be required to the used linker file (e.g. STM32F407IGHX_FLASH.ld):
If the linker cannot find __stack_start__ and/or __stack_end__, these symbols are not defined in the linker file. To resolve this, please replace

       . = . + _Min_Stack_Size;

by

       __stack_start__ = .;
       . = . + _Min_Stack_Size;
       __stack_end__ = .;

in the linker file.