Difference between revisions of "Using embOS in CMSIS-Pack projects"

From SEGGER Wiki
Jump to: navigation, search
m (Download)
m
 
(8 intermediate revisions by 2 users not shown)
Line 12: Line 12:
   
 
=== Installation ===
 
=== 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 ''embOS CMSIS-Pack'' may be used as-is: it does not need to be extracted before installing it in any CMSIS-Pack capable IDE.
 
<br />
 
<br />
 
The following example installation is done using IAR Embedded Workbench, but should be similar for other IDEs:
 
The following example installation is done using IAR Embedded Workbench, but should be similar for other IDEs:
Line 18: Line 18:
 
# Open the ''CMSIS-Pack Manager'' via ''Project -> CMSIS-Pack Manager''
 
# Open the ''CMSIS-Pack Manager'' via ''Project -> CMSIS-Pack Manager''
 
# Inside the CMSIS-Pack Manager, select ''CMSIS-Manager -> Import existing packs''
 
# Inside the CMSIS-Pack Manager, select ''CMSIS-Manager -> Import existing packs''
# Import ''SEGGER.I-CUBE-embOS.1.2.0.pack'' (installs V1.2.0 of the pack, file name may differ for later versions)
+
# 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:
 
This will extract the pack to your local ''IAR CMSIS-Pack repository'' and make it available in the IAR CMSIS-Manager as shown below:
Line 24: Line 24:
   
 
=== Usage ===
 
=== Usage ===
After sucessfull installation, the embOS CMSIS-Pack can be used to generate example projects with embOS.
+
After successful installation, the embOS CMSIS-Pack can be used to generate example projects with embOS.
 
<br />
 
<br />
 
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.
 
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.
Line 71: Line 71:
 
=== Trouble-shooting ===
 
=== Trouble-shooting ===
 
==== Linker Symbols with arm Keil µVision ====
 
==== 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):
+
When creating projects for arm ''Keil µVision'', manual modification may be required to the used start-up file (e.g. startup_stm32f407xx.s).
  +
<br />
 
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
+
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
 
EXPORT Stack_Mem
 
EXPORT Stack_Mem
 
to the start-up file.
 
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
  +
EXPORT __initial_sp
  +
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 ====
 
==== Linker Symbols with GNU toolchains ====
Line 87: Line 100:
 
__stack_end__ = .;
 
__stack_end__ = .;
 
in the linker file.
 
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.<br />
  +
Usage of redlib will result in compiler errors as shown below:
  +
[[File:embOSRedlibIncompatibiliy.JPG|none|1200px|Compiler errors when using embOS and redlib in GCC-based projects]]
  +
  +
To resolve this, please select ''newlib'' in the project options:
  +
[[File:SelectingNewlibinEclipse.jpg|none|Selecting newlib in Eclipse-based IDEs]]

Latest revision as of 09:16, 22 August 2023

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 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:

  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.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:

embOS CMSIS-Pack installed in IAR Embedded Workbench

Usage

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:

  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 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

       EXPORT  Stack_Mem

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

       EXPORT  __initial_sp

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;

by

       __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:

Compiler errors when using embOS and redlib in GCC-based projects

To resolve this, please select newlib in the project options:

Selecting newlib in Eclipse-based IDEs