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">
62 <p><b>FreeRTOS V10.0.0</b></p>
63 <p>Maintenance release for CMSIS 5.3.0:
65 <li>RTOS2 API 2.1.2</li>
66 <li>OS Tick API 1.0.1</li>
67 <li>Enhanced context switch response latency for API calls from ISR.</li>
68 <li>Enhanced debug awareness in SCVD.</li>
75 <p><b>FreeRTOS 9.0.0</b></p>
76 <p>Maintenance release for CMSIS 5.1.0:
79 Added support for ARM Compiler 6
80 (Limitations: Not available for Cortex-M0!)
82 <li>Updated Cortex-A example to use IRQ Controller component</li>
83 <li>Corrected stack size allocation in RTOS2 osThreadNew function</li>
84 <li>Added support for OS Tick component</li>
85 <li>Added documentation for configuration options (native/CMSIS-RTOS2)</li>
86 <li>Debug event TaskIncrementTick level set to Detail</li>
92 <td>Initial release</td>
98 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
100 \page cre_freertos_proj Create a FreeRTOS project
102 You can basically choose between two option when creating a FreeRTOS project:
103 -# \ref native_freertos using the FreeRTOS API and kernel.
104 -# \ref cmsis_freertos using the CMSIS-RTOS2 API with an underlying FreeRTOS kernel.
106 \section native_freertos Create a native FreeRTOS project
108 The steps to create a microcontroller application using FreeRTOS are:
109 - Create a new project and select a microcontroller device.
110 - In the Manage Run-Time Environment window, select <b>\::Device:Startup</b>, <b>\::RTOS:CORE</b> and
111 <b>\::RTOS:Config</b> in the \b FreeRTOS variant and an applicable <b>\::RTOS:Heap</b> scheme (for more
112 information on the heap schemes, visit the FreeRTOS documentation):
114 \image html manage_rte_freertos_native.png
117 - If the <b>Validation Output</b> requires other components to be present, try to use the \b Resolve button.
118 - Click \b OK. In the \b Project window, you will see the files that have been automatically added to you project, such as
119 \b %FreeRTOSConfig.h, the source code files, as well as the system and startup files:
121 \image html project_window_freertos_native.png
123 \subsection native_freertos_config Configure FreeRTOS
125 When you have created the native FreeRTOS project, you can configure the real-time operating system using the
126 \b FreeRTOSConfig.h file. Please refer to the
127 <a href="http://www.freertos.org/a00110.html" target="_blank">FreeRTOS documentation</a> for more information on the specific
130 \image html freertos_config_h_native.png
133 \subsection native_freertos_er Add Event Recorder Visibility
134 - To use the Event Recorder together with FreeRTOS, add the software components <b>\::Compiler:Event Recorder</b> and
135 <b>\::RTOS:Event Groups</b> to your project.
136 - Add this include: \c \#include \c "EventRecorder.h"
137 - Call <b>EventRecorderInitialize(EventRecordAll, 1);</b> in your application code (ideally in \c main()).
138 - If you are using simulation mode, add an initialization file with the following content:
140 MAP 0xE0001000, 0xE0001007 READ WRITE
141 signal void DWT_CYCCNT (void) {
144 _WWORD(0xE0001004, states);
149 - Build the application code and download it to the debug hardware or run it in simulation.
151 Once the target application generates event information, it can be viewed in the µVision debugger using the \b Event
155 \section cmsis_freertos Create a CMSIS-FreeRTOS project
157 The steps to create a microcontroller application using CMSIS-FreeRTOS are:
158 - Create a new project and select a microcontroller device.
159 - In the Manage Run-Time Environment window, select <b>\::Device:Startup</b>, <b>\::CMSIS::RTOS2 (API)\::FreeRTOS</b>,
160 <b>\::RTOS:CORE</b> in the \b FreeRTOS variant, <b>\::RTOS:Config</b> in the \b CMSIS \b RTOS2 variant,
161 <b>\::RTOS:Timers</b>, <b>\::RTOS:Event Groups</b>, and an applicable <b>\::RTOS:Heap</b>
162 scheme (for more information on the heap schemes, visit the FreeRTOS documentation):
164 \image html manage_rte_freertos_rtos2.png
167 - If the <b>Validation Output</b> requires other components to be present, try to use the \b Resolve button.
168 - Click \b OK. In the \b Project window, you will see the files that have been automatically added to you project, such as
169 \b %FreeRTOSConfig.h, the source code files, as well as the system and startup files:
171 \image html project_window_freertos_rtos2.png
174 \subsection cmsis_freertos_config Configure CMSIS-FreeRTOS
176 When you have created the CMSIS-FreeRTOS project, you can configure the real-time operating system using the
177 \b FreeRTOSConfig.h file. It can be opened using the Configuration Wizard view:
179 \image html freertos_config_h_cmsis_rtos.png
181 The following settings are available:
183 Name | \#define | Description |
184 -------------------------------|------------------------------------|------------------------------------------------------------|
185 Minimal stack size [words] | configMINIMAL_STACK_SIZE | Stack for idle task and default task stack in words. |
186 Total heap size [bytes] | configTOTAL_HEAP_SIZE | Heap memory size in bytes. |
187 Kernel tick frequency [Hz] | configTICK_RATE_HZ | Kernel tick rate in Hz. |
188 Timer task stack depth [words] | configTIMER_TASK_STACK_DEPTH | Stack for timer task in words. |
189 Timer task priority | configTIMER_TASK_PRIORITY | Timer task priority. |
190 Timer queue length | configTIMER_QUEUE_LENGTH | Timer command queue length. |
191 Use time slicing | configUSE_TIME_SLICING | Enable setting to use time slicing. |
192 Idle should yield | configIDLE_SHOULD_YIELD | Control Yield behavior of the idle task. |
193 Check for stack overflow | configCHECK_FOR_STACK_OVERFLOW | Enable or disable stack overflow checking. |
194 Use idle hook | configUSE_IDLE_HOOK | Enable callback function call on each idle task iteration. |
195 Use tick hook | configUSE_TICK_HOOK | Enable callback function call during each tick interrupt. |
196 Use daemon task startup hook | configUSE_DAEMON_TASK_STARTUP_HOOK | Enable callback function call when timer service starts. |
197 Use malloc failed hook | configUSE_MALLOC_FAILED_HOOK | Enable callback function call when out of dynamic memory. |
200 \subsection cmsis_freertos_er Add Event Recorder Visibility
201 - To use the Event Recorder together with FreeRTOS, add the software component <b>\::Compiler:Event Recorder</b> to your
203 - Add this include: \c \#include \c "EventRecorder.h"
204 - Call <b>EventRecorderInitialize(EventRecordAll, 1);</b> in your application code (ideally in \c main()).
205 - If you are using simulation mode, add an initialization file with the following content:
207 MAP 0xE0001000, 0xE0001007 READ WRITE
208 signal void DWT_CYCCNT (void) {
211 _WWORD(0xE0001004, states);
216 - Build the application code and download it to the debug hardware or run it in simulation.
218 Once the target application generates event information, it can be viewed in the µVision debugger using the \b Event
223 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
225 \page examples Example projects
227 This pack contains two example projects:
228 - \ref examples_native
229 - \ref examples_cmsis
231 The first example shows how to use FreeRTOS standalone, whereas the second example shows how to use the CMSIS-RTOS2 API with
232 an underlying FreeRTOS.
234 The examples simulate a step-motor driver. Four phase variables are simulating the activation of the four output driver
235 stages. The state changes are shown in the Watch window variable \c g_phases. All four phases are displayed in the Logic
238 \image html blinky_example_simu.png
241 \section examples_native Blinky example using FreeRTOS natively
243 This example shows how to use FreeRTOS natively in a µVision project. This makes your code portable and you can
244 choose to use a different RTOS kernel anytime during development (even only for evaluation purposes).
246 To open the example, go to Pack Installer, select \b ARM in the \b Devices tab, and click on \b Copy next to the
247 <b>Native FreeRTOS Blinky (uVision Simulator)</b> project on the \b Examples tab. Select the location on your hard drive
248 where you want to copy the project to and press OK. µVision opens.
251 \section examples_cmsis Blinky example using CMSIS-FreeRTOS
253 This example shows how to use the CMSIS-RTOS2 API with an underlying FreeRTOS. This makes your code portable and you can
254 choose to use a different RTOS kernel anytime during development (even only for evaluation purposes).
256 To open the example, go to Pack Installer, select \b ARM in the \b Devices tab, and click on \b Copy next to the
257 <b>CMSIS-RTOS2 FreeRTOS Blinky (uVision Simulator)</b> project on the \b Examples tab. Select the location on your hard drive
258 where you want to copy the project to and press OK. µVision opens.
261 \section examples_cmsis_a9 Blinky example using CMSIS-FreeRTOS running on Arm Cortex-A9
263 This example shows how to use the CMSIS-RTOS2 API with an underlying FreeRTOS running on an NXP i.MX6 equipped with an Arm
264 Cortex-A9 code. This example only works in <a href="http://www.keil.com/mdk5/ds-mdk">DS-MDK</a>, the Eclipse-based
265 development environment from Arm. For information on setting up the target connection, please refer to
266 <a href="http://www2.keil.com/mdk5/ds-mdk/imx6sxsabrereference">NXP i.MX 6SoloX SABRE Reference</a>.
268 \note you need to have the i.MX6 device family pack installed to see the example in the \b Examples tab of Pack Installer.
270 To open the example, open the Pack Installer perspective, select \b NXP in the \b Devices tab, and click on \b Copy next to
271 the <b>CMSIS-RTOS2 FreeRTOS Blinky CA9 (MCIMX6SX-SABRE)</b> project on the \b Examples tab.
273 \image html copy_a9_example.png
275 Confirm the default location in the Eclipse Workspace by pressing Copy.
277 \image html copy_a9_example_ws.png
279 Right-click on the project and select \b Build \b Project. Then, right-click on the project and select \b Debug \b As and
280 then \b Debug \b Configurations. The Debug Configurations dialog opens:
282 \image html dbg_conf.png
284 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
285 debug perspective. After a successful connection to the target, press \b F8 to run the application. In the \b App \b Console
286 you will see the output of the phases:
288 \image html dbg_output.png
292 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
294 \page tech_data Technical data and limitations
296 This lists the technical data of CMSIS-FreeRTOS.
299 \section td_limitations Limitations
301 The following list briefly describes the limitations and unsupported features of the CMSIS-RTOS2 wrapper for FreeRTOS:
302 - Static memory allocation will only work if \a all memory (from attributes structure) is provided statically. In order to
303 allocate object memory statically, you need to:
304 - provide the memory for control blocks and stack in the \c osThreadAttr_t structure for threads.
305 - provide the memory for control blocks and message data in the \c osMessageQueueAttr_t structure for memory queues.
306 - provide the memory for control blocks for other objects in the object's attributes structure.
307 - Each timer object requires additional 8 bytes of dynamic memory.
308 - \c osKernelSuspend and \c osKernelResume are not supported.
309 - \c osKernelGetTickCount is limited to a 32-bit return value.
310 - \c osThreadDetach, \c osThreadJoin() and attribute \c osThreadJoinable are not supported (\c osThreadNew returns NULL when
311 osThreadJoinable attribute is specified).
312 - \c osThreadGetStackSize is not implemented.
313 - Event flags are limited to 24 bits.
314 - \c osEventFlagsGetName is not implemented.
315 - \c osEventFlagsWait cannot be called from an ISR.
316 - Priority inherit protocol is used as default mutex behavior (\c osMutexNew creates priority inherit mutex object by default
317 and ignores \c osMutexPrioInherit attribute when specified).
318 - Robust mutex objects are not supported (\c osMutexNew returns NULL when \c osMutexRobust attribute is specified).
319 - \c osMutexGetName is not implemented and always returns NULL.
320 - \c osSemaphoreGetName is not implemented and always returns NULL.
321 - Memory Pool functions are not implemented and will always return with error.
322 - \c osMessageQueueGetName is not implemented and always returns NULL.
323 - \c osMessageQueuePut and \c osMessageQueueGet always ignore message priority.
325 \section td_validation CMSIS-RTOS validation suite results
328 <a target="_blank" href="http://arm-software.github.io/CMSIS_5/RTOS2/html/rtosValidation.html">validation suite</a> that can
329 be used to test a real-time operating system for compliance to the standard. The test suite has been run successfully on the
330 CMSIS-FreeRTOS implementation with the following exceptions:
333 - Reason: unsupported feature
334 - Test attempts to test \c osThreadJoin and \c osThreadDetach functions for invalid parameter input. These two functions are
337 \b TC_ThreadInterrupts:
338 - Reason: unsupported feature
339 - Test attempts to call \c osThreadJoin and \c osThreadDetach from the ISR. These two functions are not implemented.
341 \b TC_EventFlagsInterrupts:
342 - Reason: unsupported feature
343 - Test attempts to call \c osEventFlagsWait from the ISR. Wrapper implementation does not allow function \c osEventFlagsWait
344 to be called from interrupts.
347 - Reason: unsupported feature
348 - Test attempts to create robust mutex. FreeRTOS implementation does not support robust mutexes.
350 \b TC_MutexOwnership:
351 - Reason: unsupported feature
352 - Test attempts to release a mutex from a thread which is not the mutex owner. Test fails, because FreeRTOS implementation
353 does not verify ownership on mutex release.
357 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
359 \page functionOverview Function Overview
362 \section rtos_api2 CMSIS-RTOS2 API
364 Overview of all CMSIS-RTOS C API v2 functions that are implemented in CMSIS-FreeRTOS.
366 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__KernelCtrl.html">Kernel Information and Control</a>
367 ------------------------------
368 - \b osKernelGetInfo: supported
369 - \b osKernelGetState: supported
370 - \b osKernelGetSysTimerCount: supported
371 - \b osKernelGetSysTimerFreq: supported
372 - \b osKernelInitialize: supported
373 - \b osKernelLock: supported
374 - \b osKernelUnlock: supported
375 - \b osKernelRestoreLock: supported
376 - \b osKernelResume: \token{not implemented}
377 - \b osKernelStart: supported
378 - \b osKernelSuspend: \token{not implemented}
379 - \b osKernelGetTickCount: limited to 32-bit return value.
380 - \b osKernelGetTickFreq: supported
382 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__ThreadMgmt.html">Thread Management</a>
384 - \b osThreadDetach: \token{not implemented}
385 - \b osThreadEnumerate: supported
386 - \b osThreadExit: supported
387 - \b osThreadGetCount: supported
388 - \b osThreadGetId: supported
389 - \b osThreadGetName: supported
390 - \b osThreadGetPriority: supported
391 - \b osThreadGetStackSize: \token{not implemented}
392 - \b osThreadGetStackSpace: supported
393 - \b osThreadGetState: supported
394 - \b osThreadJoin: \token{not implemented}
395 - \b osThreadNew: supported
396 - \b osThreadResume: supported
397 - \b osThreadSetPriority: supported
398 - \b osThreadSuspend: supported
399 - \b osThreadTerminate: supported
400 - \b osThreadYield: supported
402 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__ThreadFlagsMgmt.html">Thread Flags</a>
404 - \b osThreadFlagsSet: supported
405 - \b osThreadFlagsClear: supported
406 - \b osThreadFlagsGet: supported
407 - \b osThreadFlagsWait: supported
409 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__EventFlags.html">Event Flags</a>
411 All event flags are limited to 24 bits.
412 - \b osEventFlagsGetName: \token{not implemented}
413 - \b osEventFlagsNew: supported
414 - \b osEventFlagsDelete: supported
415 - \b osEventFlagsSet: supported
416 - \b osEventFlagsClear: supported
417 - \b osEventFlagsGet: supported
418 - \b osEventFlagsWait: cannot be called from an ISR.
420 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__Wait.html">Generic Wait Functions</a>
421 ----------------------
422 - \b osDelay: supported
423 - \b osDelayUntil: supported
425 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__TimerMgmt.html">Timer Management</a>
427 - \b osTimerDelete: supported
428 - \b osTimerGetName: supported
429 - \b osTimerIsRunning: supported
430 - \b osTimerNew: supported
431 - \b osTimerStart: supported
432 - \b osTimerStop: supported
434 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__MutexMgmt.html">Mutex Management</a>
436 Priority inherit protocol is used as default mutex behavior (osMutexNew creates priority inherit mutex object by default
437 and ignores osMutexPrioInherit attribute when specified).\n
438 Robust mutex objects are not supported (osMutexNew returns NULL when osMutexRobust attribute is specified).
439 - \b osMutexAcquire: supported
440 - \b osMutexDelete: supported
441 - \b osMutexGetName: \token{not implemented}
442 - \b osMutexGetOwner: supported
443 - \b osMutexNew: supported
444 - \b osMutexRelease: supported
446 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__SemaphoreMgmt.html">Semaphores</a>
448 - \b osSemaphoreAcquire: supported
449 - \b osSemaphoreDelete: supported
450 - \b osSemaphoreGetCount: supported
451 - \b osSemaphoreGetName: \token{not implemented}
452 - \b osSemaphoreNew: supported
453 - \b osSemaphoreRelease: supported
455 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__PoolMgmt.html">Memory Pool</a>
457 Memory Pool functions are not implemented and will always return with error.
458 - \b osMemoryPoolAlloc: \token{not implemented}
459 - \b osMemoryPoolDelete: \token{not implemented}
460 - \b osMemoryPoolFree: \token{not implemented}
461 - \b osMemoryPoolGetBlockSize: \token{not implemented}
462 - \b osMemoryPoolGetCapacity: \token{not implemented}
463 - \b osMemoryPoolGetCount: \token{not implemented}
464 - \b osMemoryPoolGetName: \token{not implemented}
465 - \b osMemoryPoolGetSpace: \token{not implemented}
466 - \b osMemoryPoolNew: \token{not implemented}
468 <a href="http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__Message.html">Message Queue</a>
470 - \b osMessageQueueDelete: supported
471 - \b osMessageQueueGet: ignores message priority.
472 - \b osMessageQueueGetCapacity: supported
473 - \b osMessageQueueGetCount: supported
474 - \b osMessageQueueGetMsgSize: supported
475 - \b osMessageQueueGetName: \token{not implemented}
476 - \b osMessageQueueGetSpace: supported
477 - \b osMessageQueueNew: supported
478 - \b osMessageQueuePut: ignores message priority.
479 - \b osMessageQueueReset: supported
482 /* ======================================================================================================================== */
483 // Group creation for Reference
485 \addtogroup freertos_specific CMSIS-FreeRTOS Specifics
486 \brief This section describes CMSIS-FreeRTOS specifics.
488 CMSIS-FreeRTOS interfaces to the
489 <a href="http://www.keil.com/pack/doc/compiler/EventRecorder/html/index.html" target="_blank"><b>Event Recorder</b></a>
490 to provide event information which helps you to understand and analyze the operation. Refer to \ref freertos_evr for more