1 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5 <a target="_blank" href="http://www.freertos.org/">FreeRTOS</a> is one of the market leading real-time operating systems
6 (RTOS) for embedded microcontrollers. It is professionally developed,
7 <a target="_blank" href="http://www.freertos.org/FreeRTOS-Coding-Standard-and-Style-Guide.html">strictly quality controlled</a>,
9 <a target="_blank" href="http://www.freertos.org/FreeRTOS_Support_Forum_Archive/freertos_support_forum_archive_index.html">supported</a>,
10 free to <a target="_blank" href="http://www.freertos.org/a00114.html">use in commercial products</a> without a requirement to
11 expose proprietary source code, and has
12 <a target="_blank" href="http://www.freertos.org/differences-between-officially-supported-and-contributed-FreeRTOS-code.html">no IP infringement</a>
15 <a href="https://arm-software.github.io/CMSIS_5/RTOS2/html/index.html"><b>CMSIS-RTOS v2</b></a> is a common API for real-time
16 operating systems (RTOS). It provides a standardized programming interface that is portable to many RTOS and enables software
17 components that can work across multiple RTOS systems. It supports the ARMv8-M architecture, dynamic object creation, for
18 multi-core systems, and has a binary compatible interface across ABI compliant compilers.
20 Using this software pack, users can choose between a native FreeRTOS implementation or one that is adhering to the
21 CMSIS-RTOS2 API and using FreeRTOS under the hood. The CMSIS-RTOS2 API enables programmers to create portable application
22 code to be used with different RTOS kernels (for example <a class="el" href="http://www.keil.com/mdk5/cmsis/rtx">Keil RTX5</a>).
24 \b Note: FreeRTOS does not support ARM Compiler v6, yet! Please refere to the
25 <a target="_blank" href="http://www.freertos.org/FreeRTOS_Support_Forum_Archive/May_2016/freertos_Anyone_Working_on_a_Port_to_Keil_ARM_Compiler_6.4_ARMCLANG_9deb244ej.html">
26 FreeRTOS Support Archive.</a>
28 This documentation shows you:
29 - how to \ref cre_freertos_proj "create a new microcontroller project" using FreeRTOS from scratch.
30 - Various \ref examples show you the usage of FreeRTOS in native and CMSIS-RTOS2 mode.
31 - the \ref tech_data of this implementation.
34 \section License License
36 The CMSIS-FreeRTOS implementation is provided free of charge by ARM under the <a href="license.txt">FreeRTOS license</a>.
39 \section CMFR_Pack_Content ARM::CMSIS-FreeRTOS Pack
41 The <b>ARM::CMSIS-FreeRTOS</b> pack contains the following:
43 File/Directory |Content
44 :--------------------------|:---------------------------------------------------------------------------------
45 \b ARM.CMSIS-FreeRTOS.pdsc | Package description file in CMSIS-Pack format.
46 \b License | FreeRTOS license agreement.
47 \b CMSIS | CMSIS-RTOS2 compliant implementation of FreeRTOS.
48 \b Config | FreeRTOS configuration header file.
49 \b Demo | FreeRTOS demo projects.
50 \b Documentation | This documentation.
51 \b DoxyGen | Source of the documentation.
52 \b Source | FreeRTOS source code.
53 \b Utilities | Utilities to build the pack.
57 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
59 \page cm_revisionHistory Revision History
61 <table class="cmtable" summary="Revision History">
64 <td>Initial release</td>
70 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
72 \page cre_freertos_proj Create a FreeRTOS project
74 You can basically choose between two option when creating a FreeRTOS project:
75 -# \ref native_freertos using the FreeRTOS API and kernel.
76 -# \ref cmsis_freertos using the CMSIS-RTOS2 API with an underlying FreeRTOS kernel.
78 \section native_freertos Create a native FreeRTOS project
80 The steps to create a microcontroller application using FreeRTOS are:
81 - Create a new project and select a microcontroller device.
82 - In the Manage Run-Time Environment window, select <b>\::Device:Startup</b>, <b>\::RTOS:CORE</b> and
83 <b>\::RTOS:Config</b> in the \b FreeRTOS variant and an applicable <b>\::RTOS:Heap</b> scheme (for more
84 information on the heap schemes, visit the FreeRTOS documentation):
86 \image html manage_rte_freertos_native.png
89 - If the <b>Validation Output</b> requires other components to be present, try to use the \b Resolve button.
90 - Click \b OK. In the \b Project window, you will see the files that have been automatically added to you project, such as
91 \b %FreeRTOSConfig.h, the source code files, as well as the system and startup files:
93 \image html project_window_freertos_native.png
95 \subsection native_freertos_config Configure FreeRTOS
97 When you have created the native FreeRTOS project, you can configure the real-time operating system using the
98 \b FreeRTOSConfig.h file. Please refer to the
99 <a href="http://www.freertos.org/a00110.html" target="_blank">FreeRTOS documentation</a> for more information on the specific
102 \image html freertos_config_h_native.png
105 \subsection native_freertos_er Add Event Recorder Visibility
106 - To use the Event Recorder together with FreeRTOS, add the software components <b>\::Compiler:Event Recorder</b> and
107 <b>\::RTOS:Event Groups</b> to your project.
108 - Add this include: \c \#include \c "EventRecorder.h"
109 - Call <b>EventRecorderInitialize(EventRecordAll, 1);</b> in your application code (ideally in \c main()).
110 - If you are using simulation mode, add an initialization file with the following content:
112 MAP 0xE0001000, 0xE0001007 READ WRITE
113 signal void DWT_CYCCNT (void) {
116 _WWORD(0xE0001004, states);
121 - Build the application code and download it to the debug hardware or run it in simulation.
123 Once the target application generates event information, it can be viewed in the µVision debugger using the \b Event
127 \section cmsis_freertos Create a CMSIS-FreeRTOS project
129 The steps to create a microcontroller application using CMSIS-FreeRTOS are:
130 - Create a new project and select a microcontroller device.
131 - In the Manage Run-Time Environment window, select <b>\::Device:Startup</b>, <b>\::CMSIS::RTOS2 (API)\::FreeRTOS</b>,
132 <b>\::RTOS:CORE</b> in the \b FreeRTOS variant, <b>\::RTOS:Config</b> in the \b CMSIS \b RTOS2 variant,
133 <b>\::RTOS:Timers</b>, <b>\::RTOS:Event Groups</b>, and an applicable <b>\::RTOS:Heap</b>
134 scheme (for more information on the heap schemes, visit the FreeRTOS documentation):
136 \image html manage_rte_freertos_rtos2.png
139 - If the <b>Validation Output</b> requires other components to be present, try to use the \b Resolve button.
140 - Click \b OK. In the \b Project window, you will see the files that have been automatically added to you project, such as
141 \b %FreeRTOSConfig.h, the source code files, as well as the system and startup files:
143 \image html project_window_freertos_rtos2.png
146 \subsection cmsis_freertos_config Configure CMSIS-FreeRTOS
148 When you have created the CMSIS-FreeRTOS project, you can configure the real-time operating system using the
149 \b FreeRTOSConfig.h file. It can be opened using the Configuration Wizard view:
151 \image html freertos_config_h_cmsis_rtos.png
153 The following settings are available:
155 Name | \#define | Description |
156 -------------------------------|------------------------------------|------------------------------------------------------------|
157 Minimal stack size [words] | configMINIMAL_STACK_SIZE | Stack for idle task and default task stack in words. |
158 Total heap size [bytes] | configTOTAL_HEAP_SIZE | Heap memory size in bytes. |
159 Kernel tick frequency [Hz] | configTICK_RATE_HZ | Kernel tick rate in Hz. |
160 Timer task stack depth [words] | configTIMER_TASK_STACK_DEPTH | Stack for timer task in words. |
161 Timer task priority | configTIMER_TASK_PRIORITY | Timer task priority. |
162 Timer queue length | configTIMER_QUEUE_LENGTH | Timer command queue length. |
163 Use time slicing | configUSE_TIME_SLICING | Enable setting to use time slicing. |
164 Idle should yield | configIDLE_SHOULD_YIELD | Control Yield behavior of the idle task. |
165 Check for stack overflow | configCHECK_FOR_STACK_OVERFLOW | Enable or disable stack overflow checking. |
166 Use idle hook | configUSE_IDLE_HOOK | Enable callback function call on each idle task iteration. |
167 Use tick hook | configUSE_TICK_HOOK | Enable callback function call during each tick interrupt. |
168 Use daemon task startup hook | configUSE_DAEMON_TASK_STARTUP_HOOK | Enable callback function call when timer service starts. |
169 Use malloc failed hook | configUSE_MALLOC_FAILED_HOOK | Enable callback function call when out of dynamic memory. |
172 \subsection cmsis_freertos_er Add Event Recorder Visibility
173 - To use the Event Recorder together with FreeRTOS, add the software component <b>\::Compiler:Event Recorder</b> to your
175 - Add this include: \c \#include \c "EventRecorder.h"
176 - Call <b>EventRecorderInitialize(EventRecordAll, 1);</b> in your application code (ideally in \c main()).
177 - If you are using simulation mode, add an initialization file with the following content:
179 MAP 0xE0001000, 0xE0001007 READ WRITE
180 signal void DWT_CYCCNT (void) {
183 _WWORD(0xE0001004, states);
188 - Build the application code and download it to the debug hardware or run it in simulation.
190 Once the target application generates event information, it can be viewed in the µVision debugger using the \b Event
195 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
197 \page examples Example projects
199 This pack contains two example projects:
200 - \ref examples_native
201 - \ref examples_cmsis
203 The first example shows how to use FreeRTOS standalone, whereas the second example shows how to use the CMSIS-RTOS2 API with
204 an underlying FreeRTOS.
206 The examples simulate a step-motor driver. Four phase variables are simulating the activation of the four output driver
207 stages. The state changes are shown in the Watch window variable \c g_phases. All four phases are displayed in the Logic
210 \image html blinky_example_simu.png
213 \section examples_native Blinky example using FreeRTOS natively
215 This example shows how to use FreeRTOS natively in a µVision project. This makes your code portable and you can
216 choose to use a different RTOS kernel anytime during development (even only for evaluation purposes).
218 To open the example, go to Pack Installer, select \b ARM in the \b Devices tab, and click on \b Copy next to the
219 <b>Native FreeRTOS Blinky (uVision Simulator)</b> project on the \b Examples tab. Select the location on your hard drive
220 where you want to copy the project to and press OK. µVision opens.
223 \section examples_cmsis Blinky example using CMSIS-FreeRTOS
225 This example shows how to use the CMSIS-RTOS2 API with an underlying FreeRTOS. This makes your code portable and you can
226 choose to use a different RTOS kernel anytime during development (even only for evaluation purposes).
228 To open the example, go to Pack Installer, select \b ARM in the \b Devices tab, and click on \b Copy next to the
229 <b>CMSIS-RTOS2 FreeRTOS Blinky (uVision Simulator)</b> project on the \b Examples tab. Select the location on your hard drive
230 where you want to copy the project to and press OK. µVision opens.
233 \section examples_cmsis_a9 Blinky example using CMSIS-FreeRTOS running on ARM Cortex-A9
235 This example shows how to use the CMSIS-RTOS2 API with an underlying FreeRTOS running on an NXP i.MX6 equipped with an ARM
236 Cortex-A9 code. This example only works in <a href="http://www.keil.com/mdk5/ds-mdk">DS-MDK</a>, the Eclipse-based
237 development environment from ARM. For information on setting up the target connection, please refer to
238 <a href="http://www2.keil.com/mdk5/ds-mdk/imx6sxsabrereference">NXP i.MX 6SoloX SABRE Reference</a>.
240 \note you need to have the i.MX6 device family pack installed to see the example in the \b Examples tab of Pack Installer.
242 To open the example, open the Pack Installer perspective, select \b NXP in the \b Devices tab, and click on \b Copy next to
243 the <b>CMSIS-RTOS2 FreeRTOS Blinky CA9 (MCIMX6SX-SABRE)</b> project on the \b Examples tab.
245 \image html copy_a9_example.png
247 Confirm the default location in the Eclipse Workspace by pressing Copy.
249 \image html copy_a9_example_ws.png
251 Right-click on the project and select \b Build \b Project. Then, right-click on the project and select \b Debug \b As and
252 then \b Debug \b Configurations. The Debug Configurations dialog opens:
254 \image html dbg_conf.png
256 The project is already set up for running from the SDRAM of the i.MX6 SABRE board. Press \b Debug. DS-MDK will switch to the
257 debug perspective. After a successful connection to the target, press \b F8 to run the application. In the \b App \b Console
258 you will see the output of the phases:
260 \image html dbg_output.png
264 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
266 \page tech_data Technical data and limitations
268 This lists the technical data of CMSIS-FreeRTOS.
271 \section td_limitations Limitations
273 The following list briefly describes the limitations and unsupported features of the CMSIS-RTOS2 wrapper for FreeRTOS:
274 - ARM Compiler v6 is not supported by FreeRTOS, yet.
275 - Static memory allocation will only work if \a all memory (from attributes structure) is provided statically. In order to
276 allocate object memory statically, you need to:
277 - provide the memory for control blocks and stack in the \c osThreadAttr_t structure for threads.
278 - provide the memory for control blocks and message data in the \c osMessageQueueAttr_t structure for memory queues.
279 - provide the memory for control blocks for other objects in the object's attributes structure.
280 - Each timer object requires additional 8 bytes of dynamic memory.
281 - \c osKernelSuspend and \c osKernelResume are not supported.
282 - \c osKernelGetTickCount is limited to a 32-bit return value.
283 - \c osThreadDetach, \c osThreadJoin() and attribute \c osThreadJoinable are not supported (\c osThreadNew returns NULL when
284 osThreadJoinable attribute is specified).
285 - \c osThreadGetStackSize is not implemented.
286 - Event flags are limited to 24 bits.
287 - \c osEventFlagsGetName is not implemented.
288 - \c osEventFlagsWait cannot be called from an ISR.
289 - Priority inherit protocol is used as default mutex behavior (\c osMutexNew creates priority inherit mutex object by default
290 and ignores \c osMutexPrioInherit attribute when specified).
291 - Robust mutex objects are not supported (\c osMutexNew returns NULL when \c osMutexRobust attribute is specified).
292 - \c osMutexGetName is not implemented and always returns NULL.
293 - \c osSemaphoreGetName is not implemented and always returns NULL.
294 - Memory Pool functions are not implemented and will always return with error.
295 - \c osMessageQueueGetName is not implemented and always returns NULL.
296 - \c osMessageQueuePut and \c osMessageQueueGet always ignore message priority.
298 \section td_validation CMSIS-RTOS validation suite results
301 <a target="_blank" href="http://arm-software.github.io/CMSIS_5/RTOS2/html/rtosValidation.html">validation suite</a> that can
302 be used to test a real-time operating system for compliance to the standard. The test suite has been run successfully on the
303 CMSIS-FreeRTOS implementation with the following exceptions:
306 - Reason: unsupported feature
307 - Test attempts to test \c osThreadJoin and \c osThreadDetach functions for invalid parameter input. These two functions are
310 \b TC_ThreadInterrupts:
311 - Reason: unsupported feature
312 - Test attempts to call \c osThreadJoin and \c osThreadDetach from the ISR. These two functions are not implemented.
314 \b TC_EventFlagsInterrupts:
315 - Reason: unsupported feature
316 - Test attempts to call \c osEventFlagsWait from the ISR. Wrapper implementation does not allow function \c osEventFlagsWait
317 to be called from interrupts.
320 - Reason: unsupported feature
321 - Test attempts to create robust mutex. FreeRTOS implementation does not support robust mutexes.
323 \b TC_MutexOwnership:
324 - Reason: unsupported feature
325 - Test attempts to release a mutex from a thread which is not the mutex owner. Test fails, because FreeRTOS implementation
326 does not verify ownership on mutex release.
330 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
332 \page functionOverview Function Overview
335 \section rtos_api2 CMSIS-RTOS2 API
337 Overview of all CMSIS-RTOS C API v2 functions that are implemented in CMSIS-FreeRTOS.
339 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__KernelCtrl.html">Kernel Information and Control</a>
340 ------------------------------
341 - \b osKernelGetInfo: supported
342 - \b osKernelGetState: supported
343 - \b osKernelGetSysTimerCount: supported
344 - \b osKernelGetSysTimerFreq: supported
345 - \b osKernelInitialize: supported
346 - \b osKernelLock: supported
347 - \b osKernelUnlock: supported
348 - \b osKernelRestoreLock: supported
349 - \b osKernelResume: \token{not implemented}
350 - \b osKernelStart: supported
351 - \b osKernelSuspend: \token{not implemented}
352 - \b osKernelGetTickCount: limited to 32-bit return value.
353 - \b osKernelGetTickFreq: supported
355 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__ThreadMgmt.html">Thread Management</a>
357 - \b osThreadDetach: \token{not implemented}
358 - \b osThreadEnumerate: supported
359 - \b osThreadExit: supported
360 - \b osThreadGetCount: supported
361 - \b osThreadGetId: supported
362 - \b osThreadGetName: supported
363 - \b osThreadGetPriority: supported
364 - \b osThreadGetStackSize: \token{not implemented}
365 - \b osThreadGetStackSpace: supported
366 - \b osThreadGetState: supported
367 - \b osThreadJoin: \token{not implemented}
368 - \b osThreadNew: supported
369 - \b osThreadResume: supported
370 - \b osThreadSetPriority: supported
371 - \b osThreadSuspend: supported
372 - \b osThreadTerminate: supported
373 - \b osThreadYield: supported
375 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__ThreadFlagsMgmt.html">Thread Flags</a>
377 - \b osThreadFlagsSet: supported
378 - \b osThreadFlagsClear: supported
379 - \b osThreadFlagsGet: supported
380 - \b osThreadFlagsWait: supported
382 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__EventFlags.html">Event Flags</a>
384 All event flags are limited to 24 bits.
385 - \b osEventFlagsGetName: \token{not implemented}
386 - \b osEventFlagsNew: supported
387 - \b osEventFlagsDelete: supported
388 - \b osEventFlagsSet: supported
389 - \b osEventFlagsClear: supported
390 - \b osEventFlagsGet: supported
391 - \b osEventFlagsWait: cannot be called from an ISR.
393 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__Wait.html">Generic Wait Functions</a>
394 ----------------------
395 - \b osDelay: supported
396 - \b osDelayUntil: supported
398 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__TimerMgmt.html">Timer Management</a>
400 - \b osTimerDelete: supported
401 - \b osTimerGetName: supported
402 - \b osTimerIsRunning: supported
403 - \b osTimerNew: supported
404 - \b osTimerStart: supported
405 - \b osTimerStop: supported
407 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__MutexMgmt.html">Mutex Management</a>
409 Priority inherit protocol is used as default mutex behavior (osMutexNew creates priority inherit mutex object by default
410 and ignores osMutexPrioInherit attribute when specified).\n
411 Robust mutex objects are not supported (osMutexNew returns NULL when osMutexRobust attribute is specified).
412 - \b osMutexAcquire: supported
413 - \b osMutexDelete: supported
414 - \b osMutexGetName: \token{not implemented}
415 - \b osMutexGetOwner: supported
416 - \b osMutexNew: supported
417 - \b osMutexRelease: supported
419 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__SemaphoreMgmt.html">Semaphores</a>
421 - \b osSemaphoreAcquire: supported
422 - \b osSemaphoreDelete: supported
423 - \b osSemaphoreGetCount: supported
424 - \b osSemaphoreGetName: \token{not implemented}
425 - \b osSemaphoreNew: supported
426 - \b osSemaphoreRelease: supported
428 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__PoolMgmt.html">Memory Pool</a>
430 Memory Pool functions are not implemented and will always return with error.
431 - \b osMemoryPoolAlloc: \token{not implemented}
432 - \b osMemoryPoolDelete: \token{not implemented}
433 - \b osMemoryPoolFree: \token{not implemented}
434 - \b osMemoryPoolGetBlockSize: \token{not implemented}
435 - \b osMemoryPoolGetCapacity: \token{not implemented}
436 - \b osMemoryPoolGetCount: \token{not implemented}
437 - \b osMemoryPoolGetName: \token{not implemented}
438 - \b osMemoryPoolGetSpace: \token{not implemented}
439 - \b osMemoryPoolNew: \token{not implemented}
441 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__Message.html">Message Queue</a>
443 - \b osMessageQueueDelete: supported
444 - \b osMessageQueueGet: ignores message priority.
445 - \b osMessageQueueGetCapacity: supported
446 - \b osMessageQueueGetCount: supported
447 - \b osMessageQueueGetMsgSize: supported
448 - \b osMessageQueueGetName: \token{not implemented}
449 - \b osMessageQueueGetSpace: supported
450 - \b osMessageQueueNew: supported
451 - \b osMessageQueuePut: ignores message priority.
452 - \b osMessageQueueReset: supported
455 /* ======================================================================================================================== */
456 // Group creation for Reference
458 \addtogroup freertos_specific CMSIS-FreeRTOS Specifics
459 \brief This section describes CMSIS-FreeRTOS specifics.
461 CMSIS-FreeRTOS interfaces to the
462 <a href="http://www.keil.com/pack/doc/compiler/EventRecorder/html/index.html" target="_blank"><b>Event Recorder</b></a>
463 to provide event information which helps you to understand and analyze the operation. Refer to \ref freertos_evr for more