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
23 <a class="el" href="http://www.keil.com/mdk5/cmsis/rtx">Keil RTX5</a>).
25 This documentation shows you:
26 - how to \ref cre_freertos_proj "create a new microcontroller project" using FreeRTOS from scratch.
27 - Various \ref examples show you the usage of FreeRTOS in native and CMSIS-RTOS2 mode.
28 - the \ref tech_data of this implementation.
31 \section License License
33 The CMSIS-FreeRTOS implementation is provided free of charge by ARM under the <a href="license.txt">FreeRTOS license</a>.
36 \section CMFR_Pack_Content ARM::CMSIS-FreeRTOS Pack
38 The <b>ARM::CMSIS-FreeRTOS</b> pack contains the following:
40 File/Directory |Content
41 :--------------------------|:---------------------------------------------------------------------------------
42 \b ARM.CMSIS-FreeRTOS.pdsc | Package description file in CMSIS-Pack format.
43 \b License | FreeRTOS license agreement.
44 \b CMSIS | CMSIS-RTOS2 compliant implementation of FreeRTOS.
45 \b Config | FreeRTOS configuration header file.
46 \b Demo | FreeRTOS demo projects.
47 \b Documentation | This documentation.
48 \b DoxyGen | Source of the documentation.
49 \b Source | FreeRTOS source code.
50 \b Utilities | Utilities to build the pack.
54 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
56 \page cm_revisionHistory Revision History
58 <table class="cmtable" summary="Revision History">
61 <td>Initial release</td>
67 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
69 \page cre_freertos_proj Create a FreeRTOS project
71 You can basically choose between two option when creating a FreeRTOS project:
72 -# \ref native_freertos using the FreeRTOS API and kernel.
73 -# \ref cmsis_freertos using the CMSIS-RTOS2 API with an underlying FreeRTOS kernel.
75 \section native_freertos Create a native FreeRTOS project
77 The steps to create a microcontroller application using FreeRTOS are:
78 - Create a new project and select a microcontroller device.
79 - In the Manage Run-Time Environment window, select <b>\::Device:Startup</b>, <b>\::RTOS:CORE</b> and
80 <b>\::RTOS:Config</b> in the \b FreeRTOS variant and an applicable <b>\::RTOS:Heap</b> scheme (for more
81 information on the heap schemes, visit the FreeRTOS documentation):
83 \image html manage_rte_freertos_native.png
86 - If the <b>Validation Output</b> requires other components to be present, try to use the \b Resolve button.
87 - Click \b OK. In the \b Project window, you will see the files that have been automatically added to you project, such as
88 \b %FreeRTOSConfig.h, the source code files, as well as the system and startup files:
90 \image html project_window_freertos_native.png
92 \subsection native_freertos_config Configure FreeRTOS
94 When you have created the native FreeRTOS project, you can configure the real-time operating system using the
95 \b FreeRTOSConfig.h file. Please refer to the
96 <a href="http://www.freertos.org/a00110.html" target="_blank">FreeRTOS documentation</a> for more information on the specific
99 \image html freertos_config_h_native.png
102 \subsection native_freertos_er Add Event Recorder Visibility
103 - To use the Event Recorder together with FreeRTOS, add the software components <b>\::Compiler:Event Recorder</b> and
104 <b>\::RTOS:Event Groups</b> to your project.
105 - Add this include: \c \#include \c "EventRecorder.h"
106 - Call <b>EventRecorderInitialize(EventRecordAll, 1);</b> in your application code (ideally in \c main()).
107 - If you are using simulation mode, add an initialization file with the following content:
109 MAP 0xE0001000, 0xE0001007 READ WRITE
110 signal void DWT_CYCCNT (void) {
113 _WWORD(0xE0001004, states);
118 - Build the application code and download it to the debug hardware or run it in simulation.
120 Once the target application generates event information, it can be viewed in the µVision debugger using the \b Event
124 \section cmsis_freertos Create a CMSIS-FreeRTOS project
126 The steps to create a microcontroller application using CMSIS-FreeRTOS are:
127 - Create a new project and select a microcontroller device.
128 - In the Manage Run-Time Environment window, select <b>\::Device:Startup</b>, <b>\::CMSIS::RTOS2 (API)\::FreeRTOS</b>,
129 <b>\::RTOS:CORE</b> in the \b FreeRTOS variant, <b>\::RTOS:Config</b> in the \b CMSIS \b RTOS2 variant,
130 <b>\::RTOS:Timers</b>, <b>\::RTOS:Event Groups</b>, and an applicable <b>\::RTOS:Heap</b>
131 scheme (for more information on the heap schemes, visit the FreeRTOS documentation):
133 \image html manage_rte_freertos_rtos2.png
136 - If the <b>Validation Output</b> requires other components to be present, try to use the \b Resolve button.
137 - Click \b OK. In the \b Project window, you will see the files that have been automatically added to you project, such as
138 \b %FreeRTOSConfig.h, the source code files, as well as the system and startup files:
140 \image html project_window_freertos_rtos2.png
143 \subsection cmsis_freertos_config Configure CMSIS-FreeRTOS
145 When you have created the CMSIS-FreeRTOS project, you can configure the real-time operating system using the
146 \b FreeRTOSConfig.h file. It can be opened using the Configuration Wizard view:
148 \image html freertos_config_h_cmsis_rtos.png
150 The following settings are available:
152 Name | \#define | Description |
153 -------------------------------|------------------------------------|------------------------------------------------------------|
154 Minimal stack size [words] | configMINIMAL_STACK_SIZE | Stack for idle task and default task stack in words. |
155 Total heap size [bytes] | configTOTAL_HEAP_SIZE | Heap memory size in bytes. |
156 Kernel tick frequency [Hz] | configTICK_RATE_HZ | Kernel tick rate in Hz. |
157 Timer task stack depth [words] | configTIMER_TASK_STACK_DEPTH | Stack for timer task in words. |
158 Timer task priority | configTIMER_TASK_PRIORITY | Timer task priority. |
159 Timer queue length | configTIMER_QUEUE_LENGTH | Timer command queue length. |
160 Use time slicing | configUSE_TIME_SLICING | Enable setting to use time slicing. |
161 Idle should yield | configIDLE_SHOULD_YIELD | Control Yield behavior of the idle task. |
162 Check for stack overflow | configCHECK_FOR_STACK_OVERFLOW | Enable or disable stack overflow checking. |
163 Use idle hook | configUSE_IDLE_HOOK | Enable callback function call on each idle task iteration. |
164 Use tick hook | configUSE_TICK_HOOK | Enable callback function call during each tick interrupt. |
165 Use daemon task startup hook | configUSE_DAEMON_TASK_STARTUP_HOOK | Enable callback function call when timer service starts. |
166 Use malloc failed hook | configUSE_MALLOC_FAILED_HOOK | Enable callback function call when out of dynamic memory. |
169 \subsection cmsis_freertos_er Add Event Recorder Visibility
170 - To use the Event Recorder together with FreeRTOS, add the software component <b>\::Compiler:Event Recorder</b> to your
172 - Add this include: \c \#include \c "EventRecorder.h"
173 - Call <b>EventRecorderInitialize(EventRecordAll, 1);</b> in your application code (ideally in \c main()).
174 - If you are using simulation mode, add an initialization file with the following content:
176 MAP 0xE0001000, 0xE0001007 READ WRITE
177 signal void DWT_CYCCNT (void) {
180 _WWORD(0xE0001004, states);
185 - Build the application code and download it to the debug hardware or run it in simulation.
187 Once the target application generates event information, it can be viewed in the µVision debugger using the \b Event
192 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
194 \page examples Example projects
196 This pack contains two example projects:
197 - \ref examples_native
198 - \ref examples_cmsis
200 The first example shows how to use FreeRTOS standalone, whereas the second example shows how to use the CMSIS-RTOS2 API with
201 an underlying FreeRTOS.
203 The examples simulate a step-motor driver. Four phase variables are simulating the activation of the four output driver
204 stages. The state changes are shown in the Watch window variable \c g_phases. All four phases are displayed in the Logic
207 \image html blinky_example_simu.png
210 \section examples_native Blinky example using FreeRTOS natively
212 This example shows how to use FreeRTOS natively in a µVision project. This makes your code portable and you can
213 choose to use a different RTOS kernel anytime during development (even only for evaluation purposes).
215 To open the example, go to Pack Installer, select \b ARM in the \b Devices tab, and click on \b Copy next to the
216 <b>Native FreeRTOS Blinky (uVision Simulator)</b> project on the \b Examples tab. Select the location on your hard drive
217 where you want to copy the project to and press OK. µVision opens.
220 \section examples_cmsis Blinky example using CMSIS-FreeRTOS
222 This example shows how to use the CMSIS-RTOS2 API with an underlying FreeRTOS. This makes your code portable and you can
223 choose to use a different RTOS kernel anytime during development (even only for evaluation purposes).
225 To open the example, go to Pack Installer, select \b ARM in the \b Devices tab, and click on \b Copy next to the
226 <b>CMSIS-RTOS2 FreeRTOS Blinky (uVision Simulator)</b> project on the \b Examples tab. Select the location on your hard drive
227 where you want to copy the project to and press OK. µVision opens.
230 \section examples_cmsis_a9 Blinky example using CMSIS-FreeRTOS running on ARM Cortex-A9
232 This example shows how to use the CMSIS-RTOS2 API with an underlying FreeRTOS running on an NXP i.MX6 equipped with an ARM
233 Cortex-A9 code. This example only works in <a href="http://www.keil.com/mdk5/ds-mdk">DS-MDK</a>, the Eclipse-based
234 development environment from ARM. For information on setting up the target connection, please refer to
235 <a href="http://www2.keil.com/mdk5/ds-mdk/imx6sxsabrereference">NXP i.MX 6SoloX SABRE Reference</a>.
237 \note you need to have the i.MX6 device family pack installed to see the example in the \b Examples tab of Pack Installer.
239 To open the example, open the Pack Installer perspective, select \b NXP in the \b Devices tab, and click on \b Copy next to
240 the <b>CMSIS-RTOS2 FreeRTOS Blinky CA9 (MCIMX6SX-SABRE)</b> project on the \b Examples tab.
242 \image html copy_a9_example.png
244 Confirm the default location in the Eclipse Workspace by pressing Copy.
246 \image html copy_a9_example_ws.png
248 Right-click on the project and select \b Build \b Project. Then, right-click on the project and select \b Debug \b As and
249 then \b Debug \b Configurations. The Debug Configurations dialog opens:
251 \image html dbg_conf.png
253 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
254 debug perspective. After a successful connection to the target, press \b F8 to run the application. In the \b App \b Console
255 you will see the output of the phases:
257 \image html dbg_output.png
261 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
263 \page tech_data Technical data and limitations
265 This lists the technical data of CMSIS-FreeRTOS.
268 \section td_limitations Limitations
270 The following list briefly describes the limitations and unsupported features of the CMSIS-RTOS2 wrapper for FreeRTOS:
271 - Static memory allocation will only work if \a all memory (from attributes structure) is provided statically. In order to
272 allocate object memory statically, you need to:
273 - provide the memory for control blocks and stack in the \c osThreadAttr_t structure for threads.
274 - provide the memory for control blocks and message data in the \c osMessageQueueAttr_t structure for memory queues.
275 - provide the memory for control blocks for other objects in the object's attributes structure.
276 - Each timer object requires additional 8 bytes of dynamic memory.
277 - \c osKernelSuspend and \c osKernelResume are not supported.
278 - \c osKernelGetTickCount is limited to a 32-bit return value.
279 - \c osThreadDetach, \c osThreadJoin() and attribute \c osThreadJoinable are not supported (\c osThreadNew returns NULL when
280 osThreadJoinable attribute is specified).
281 - \c osThreadGetStackSize is not implemented.
282 - Event flags are limited to 24 bits.
283 - \c osEventFlagsGetName is not implemented.
284 - \c osEventFlagsWait cannot be called from an ISR.
285 - Priority inherit protocol is used as default mutex behavior (\c osMutexNew creates priority inherit mutex object by default
286 and ignores \c osMutexPrioInherit attribute when specified).
287 - Robust mutex objects are not supported (\c osMutexNew returns NULL when \c osMutexRobust attribute is specified).
288 - \c osMutexGetName is not implemented and always returns NULL.
289 - \c osSemaphoreGetName is not implemented and always returns NULL.
290 - Memory Pool functions are not implemented and will always return with error.
291 - \c osMessageQueueGetName is not implemented and always returns NULL.
292 - \c osMessageQueuePut and \c osMessageQueueGet always ignore message priority.
294 \section td_validation CMSIS-RTOS validation suite results
297 <a target="_blank" href="http://arm-software.github.io/CMSIS_5/RTOS2/html/rtosValidation.html">validation suite</a> that can
298 be used to test a real-time operating system for compliance to the standard. The test suite has been run successfully on the
299 CMSIS-FreeRTOS implementation with the following exceptions:
302 - Reason: unsupported feature
303 - Test attempts to test \c osThreadJoin and \c osThreadDetach functions for invalid parameter input. These two functions are
306 \b TC_ThreadInterrupts:
307 - Reason: unsupported feature
308 - Test attempts to call \c osThreadJoin and \c osThreadDetach from the ISR. These two functions are not implemented.
310 \b TC_EventFlagsInterrupts:
311 - Reason: unsupported feature
312 - Test attempts to call \c osEventFlagsWait from the ISR. Wrapper implementation does not allow function \c osEventFlagsWait
313 to be called from interrupts.
316 - Reason: unsupported feature
317 - Test attempts to create robust mutex. FreeRTOS implementation does not support robust mutexes.
319 \b TC_MutexOwnership:
320 - Reason: unsupported feature
321 - Test attempts to release a mutex from a thread which is not the mutex owner. Test fails, because FreeRTOS implementation
322 does not verify ownership on mutex release.
326 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
328 \page functionOverview Function Overview
331 \section rtos_api2 CMSIS-RTOS2 API
333 Overview of all CMSIS-RTOS C API v2 functions that are implemented in CMSIS-FreeRTOS.
335 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__KernelCtrl.html">Kernel Information and Control</a>
336 ------------------------------
337 - \b osKernelGetInfo: supported
338 - \b osKernelGetState: supported
339 - \b osKernelGetSysTimerCount: supported
340 - \b osKernelGetSysTimerFreq: supported
341 - \b osKernelInitialize: supported
342 - \b osKernelLock: supported
343 - \b osKernelUnlock: supported
344 - \b osKernelRestoreLock: supported
345 - \b osKernelResume: \token{not implemented}
346 - \b osKernelStart: supported
347 - \b osKernelSuspend: \token{not implemented}
348 - \b osKernelGetTickCount: limited to 32-bit return value.
349 - \b osKernelGetTickFreq: supported
351 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__ThreadMgmt.html">Thread Management</a>
353 - \b osThreadDetach: \token{not implemented}
354 - \b osThreadEnumerate: supported
355 - \b osThreadExit: supported
356 - \b osThreadGetCount: supported
357 - \b osThreadGetId: supported
358 - \b osThreadGetName: supported
359 - \b osThreadGetPriority: supported
360 - \b osThreadGetStackSize: \token{not implemented}
361 - \b osThreadGetStackSpace: supported
362 - \b osThreadGetState: supported
363 - \b osThreadJoin: \token{not implemented}
364 - \b osThreadNew: supported
365 - \b osThreadResume: supported
366 - \b osThreadSetPriority: supported
367 - \b osThreadSuspend: supported
368 - \b osThreadTerminate: supported
369 - \b osThreadYield: supported
371 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__ThreadFlagsMgmt.html">Thread Flags</a>
373 - \b osThreadFlagsSet: supported
374 - \b osThreadFlagsClear: supported
375 - \b osThreadFlagsGet: supported
376 - \b osThreadFlagsWait: supported
378 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__EventFlags.html">Event Flags</a>
380 All event flags are limited to 24 bits.
381 - \b osEventFlagsGetName: \token{not implemented}
382 - \b osEventFlagsNew: supported
383 - \b osEventFlagsDelete: supported
384 - \b osEventFlagsSet: supported
385 - \b osEventFlagsClear: supported
386 - \b osEventFlagsGet: supported
387 - \b osEventFlagsWait: cannot be called from an ISR.
389 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__Wait.html">Generic Wait Functions</a>
390 ----------------------
391 - \b osDelay: supported
392 - \b osDelayUntil: supported
394 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__TimerMgmt.html">Timer Management</a>
396 - \b osTimerDelete: supported
397 - \b osTimerGetName: supported
398 - \b osTimerIsRunning: supported
399 - \b osTimerNew: supported
400 - \b osTimerStart: supported
401 - \b osTimerStop: supported
403 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__MutexMgmt.html">Mutex Management</a>
405 Priority inherit protocol is used as default mutex behavior (osMutexNew creates priority inherit mutex object by default
406 and ignores osMutexPrioInherit attribute when specified).\n
407 Robust mutex objects are not supported (osMutexNew returns NULL when osMutexRobust attribute is specified).
408 - \b osMutexAcquire: supported
409 - \b osMutexDelete: supported
410 - \b osMutexGetName: \token{not implemented}
411 - \b osMutexGetOwner: supported
412 - \b osMutexNew: supported
413 - \b osMutexRelease: supported
415 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__SemaphoreMgmt.html">Semaphores</a>
417 - \b osSemaphoreAcquire: supported
418 - \b osSemaphoreDelete: supported
419 - \b osSemaphoreGetCount: supported
420 - \b osSemaphoreGetName: \token{not implemented}
421 - \b osSemaphoreNew: supported
422 - \b osSemaphoreRelease: supported
424 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__PoolMgmt.html">Memory Pool</a>
426 Memory Pool functions are not implemented and will always return with error.
427 - \b osMemoryPoolAlloc: \token{not implemented}
428 - \b osMemoryPoolDelete: \token{not implemented}
429 - \b osMemoryPoolFree: \token{not implemented}
430 - \b osMemoryPoolGetBlockSize: \token{not implemented}
431 - \b osMemoryPoolGetCapacity: \token{not implemented}
432 - \b osMemoryPoolGetCount: \token{not implemented}
433 - \b osMemoryPoolGetName: \token{not implemented}
434 - \b osMemoryPoolGetSpace: \token{not implemented}
435 - \b osMemoryPoolNew: \token{not implemented}
437 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__Message.html">Message Queue</a>
439 - \b osMessageQueueDelete: supported
440 - \b osMessageQueueGet: ignores message priority.
441 - \b osMessageQueueGetCapacity: supported
442 - \b osMessageQueueGetCount: supported
443 - \b osMessageQueueGetMsgSize: supported
444 - \b osMessageQueueGetName: \token{not implemented}
445 - \b osMessageQueueGetSpace: supported
446 - \b osMessageQueueNew: supported
447 - \b osMessageQueuePut: ignores message priority.
448 - \b osMessageQueueReset: supported
451 /* ======================================================================================================================== */
452 // Group creation for Reference
454 \addtogroup freertos_specific CMSIS-FreeRTOS Specifics
455 \brief This section describes CMSIS-FreeRTOS specifics.
457 CMSIS-FreeRTOS interfaces to the
458 <a href="http://www.keil.com/pack/doc/compiler/EventRecorder/html/index.html" target="_blank"><b>Event Recorder</b></a>
459 to provide event information which helps you to understand and analyze the operation. Refer to \ref freertos_evr for more