Using I-CUBE-embOS with STM32CubeMX
embOS was granted the MadeForSTM32 label. As part of that, SEGGER offers the I-CUBE-embOS expansion for STM32CubeMX that allows users to generate and configure embOS projects in STM32CubeMX for use with virtually all STM32 devices and various IDEs. This article provides further information on that expansion and its usage.
For using a regular embOS shipment with STM32CubeMX (i.e. not using the expansion package), please refer to Using embOS with STM32CubeMX.
- 1 MadeForSTM32
- 2 embOS expansion for STM32CubeMX
MadeForSTM32 is a quality label delivered by ST and granted after an extended evaluation process. It helps engineers identify software solutions with the highest level of integration and quality for the STM32 microcontrollers' ecosystem.
embOS was one of the first solutions to receive the MadeForSTM32 (v1) label in an advanced collaboration of SEGGER and ST Microelectronics and has since been certified to MadeForSTM32 (v2) as well. As a result, SEGGER has published the official I-CUBE-embOS expansion for STM32CubeMX, which may be used to generate ready-to-go embOS projects for virtually all Cortex-M devices and various IDEs.
For more information on MadeForSTM32, please visit SEGGER.com.
embOS expansion for STM32CubeMX
The I-CUBE-embOS expansion for STM32CubeMX contains the embOS CMSIS-Pack, which may also be used independently of STM32CubeMX.
This article focuses on its usage in STM32CubeMX. For its independent usage in various IDEs, please refer to Using embOS in CMSIS-Pack projects.
The I-CUBE-embOS expansion for STM32CubeMX may be obtained from SEGGER.com.
After download, the *.pack-file may be accessed or extracted like a *.zip-file and contains the following files and folders:
|File / Folder||Description|
|Middlewares\||Contains the embOS documentation, pre-build libraries, include files and target source files for use with GNU, IAR and Keil toolchains|
|Projects\||Contains a pre-generated STM32CubeMX example project for the STM3240G-Eval board each for IAR Embedded Workbench, arm Keil µVision, and STM32CubeIDE|
|STM32CubeMX\||Contains additional source code templates for code generation using STM32CubeMX|
|License.txt||The license agreement under which this software pack is provided|
|ReadMe.txt||Trouble-shooting guide for this software pack (also available in #Trouble-shooting)|
|SEGGER.I-CUBE-embOS.pdsc||The Pack description file for this software pack|
The I-CUBE-embOS expansion for STM32CubeMX may be used as-is: it does not need to be extracted before installing it in STM32CubeMX.
To install it, the following steps should be taken:
- Upon starting STM32CubeMX, select Help -> Manage embedded software packages
- Select From Local ... and specify the downloaded 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 STM32Cube repository and make it available in the Packages Manager as shown below:
After sucessfull installation, the I-CUBE-embOS expansion for STM32CubeMX can be used to generate various projects with embOS.
Here, a project for the STM3240G-Eval board and the IAR Embedded Workbench is created, but the same steps should be applied when creating a project for any other evaluation board or device and/or any other IDE.
Creating the basic project
Start STM32CubeMX and create a project for the desired target hardware. After the project was initialized, feel free to add clock configurations, GPIO settings and further settings as needed. The result should resemble the screenshot below:
Adding embOS to the project
Now, select Software Packs -> Select components and add embOS to the project. To do so, select the required components:
- RTOS embOS
- embOS API configuration
- Native (allows usage of embOS native API only)
- 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)
- embOS kernel configuration
- Debug and Trace
- Debug and Profiling
- Stack check and Profiling
- Stack check
- Extreme Release
- embOS API configuration
- RTOS embOS
An optional embOS sample application may be added as well. However, we do not recommend adding one of these with STM32CubeMX, for this will result in duplicate implementations of main(). Instead, we will customize a sample application in STM32CubeMX later on.
For example, for a Debug and Profiling configuration using the native embOS API, the Component Selector window would look as shown below:
Feel free to add further components as desired.
After closing the component selector, the selected embOS components need to be activated in the Software Packs -> Mode view:
Customizing the sample application
Now, Software Packs -> Configuration may be used to customize the generation of main.c (i.e. the sample application) for demonstrating embOS' usage (a real-world application would need to modify the generated source code manually in order to fully customize the application, which is not possible in STM32CubeMX itself).
In this example, we will implement one task body and create two extended tasks executing that body, and also implement and create one software timer. Hence, the Tasks tab would look like this:
The Software timer tab would like as follows:
Feel free to add further embOS objects to your application as desired.
Generating and executing the project
The STM32CubeMX configuration may now be used to create a project for the desired IDE. In this example, we create a project for IAR Embedded Workbench. After creation, open the project which should resemble the following structure:
Subsequently, the project may be compiled without warning or error and executed in hardware.
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 cannot find Stack_Mem, an EXPORT directive for that symbol is missing in the start-up file. To resolve this, please add
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;
__stack_start__ = .; . = . + _Min_Stack_Size; __stack_end__ = .;
in the linker file.