Using embOS in CMSIS-Pack projects
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.
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.
The embOS CMSIS-Pack may be obtained from SEGGER.com.
The embOS CMSIS-Pack 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:
- Open the CMSIS-Pack Manager via Project -> CMSIS-Pack Manager
- Inside the CMSIS-Pack Manager, select CMSIS-Manager -> Import existing packs
- Import SEGGER.CMSIS-embOS.x.y.z.pack (e.g. SEGGER.CMSIS-embOS.1.0.1.pack)
This will extract the pack to your local IAR CMSIS-Pack repository and make it available in the IAR CMSIS-Manager as shown below:
After successful 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:
- 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)
- embOS kernel configuration
- Debug and Profiling
- Debug and Trace
- Extreme Release
- Stack check
- Stack check and Profiling
- embOS API configuration
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_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_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:
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:
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.
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 complains about the undefined symbol Stack_Mem, the Stack_Mem symbol needs to be exported by the start-up file (e.g. startup_stm32f407xx.s). Please add
to the start-up file.
Alternatively, if another symbol pointing to the end of the stack (lowest address of the stack) is exported, OS_InitSysStackInfo.c can be modified to use this symbol instead of Stack_Mem.
If the linker complains about the undefined symbol __initial_sp, the __initial_sp symbol needs to be exported by the start-up file (e.g. startup_stm32f407xx.s). Please add
to the start-up file.
Please note, that there might be conflicts with the stack/heap set up methods and ARM compiler V6 when __initial_sp is exported and MicroLIB is not used. In this case, and if the start-up file supports the use of MicroLIB, MicroLIB can be enabled instead of exporting __initial_sp (Options for Target -> Target -> Code Generation -> Use MicroLIB).
Alternatively, if another symbol pointing to the beginning of the stack (highest address of the stack) is exported, OS_InitSysStackInfo.c can be modified to use this symbol instead of __initial_sp.
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;
__stack_start__ = .; . = . + _Min_Stack_Size; __stack_end__ = .;
in the linker file.
Conflicting types for malloc() functions with GNU toolchains
When creating projects for GNU toolchains, embOS may be used with newlib standard libraries but not e.g. redlib standard libraries.
Usage of redlib will result in compiler errors as shown below:
To resolve this, please select newlib in the project options: